libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
logger_impl.h
Go to the documentation of this file.
1#pragma once
2#ifndef __DSY_LOGGER_IMPL_H
3#define __DSY_LOGGER_IMPL_H
4#include <unistd.h>
5#include <cassert>
6#include "hid/usb.h"
7#include "sys/system.h"
8
9
10namespace daisy
11{
21
26template <LoggerDestination dest>
28{
29 public:
32 static void Init() {}
33
36 static bool Transmit(const void* buffer, size_t bytes) { return true; }
37};
38
39
42template <>
44{
45 public:
48 static void Init()
49 {
53 static_assert(1u == sizeof(usb_handle_), "UsbHandle is not static");
54 usb_handle_.Init(UsbHandle::FS_INTERNAL);
55 }
56
59 static bool Transmit(const void* buffer, size_t bytes)
60 {
62 == usb_handle_.TransmitInternal((uint8_t*)buffer, bytes);
63 }
64
65 protected:
69};
70
71
74template <>
76{
77 public:
80 static void Init()
81 {
85 static_assert(1u == sizeof(usb_handle_), "UsbHandle is not static");
86 usb_handle_.Init(UsbHandle::FS_EXTERNAL);
87 }
88
91 static bool Transmit(const void* buffer, size_t bytes)
92 {
94 == usb_handle_.TransmitExternal((uint8_t*)buffer, bytes);
95 }
96
97 protected:
101};
102
103
106template <>
108{
109 public:
112 static void Init() {}
113
116 static bool Transmit(const void* buffer, size_t bytes)
117 {
119 return true;
120 }
121};
122
123
124} /* namespace daisy */
125
126#endif //__DSY_LOGGER_IMPL_H
Interface for initializing and using the USB Peripherals on the daisy.
Definition usb.h:19
@ FS_EXTERNAL
Definition usb.h:32
@ FS_INTERNAL
Definition usb.h:31
Definition leddriver.h:33
void Init(I2CHandle i2c, const uint8_t(&addresses)[numDrivers], DmaBuffer dma_buffer_a, DmaBuffer dma_buffer_b, Pin oe_pin=Pin(PORTX, 0))
Definition leddriver.h:65
static bool Transmit(const void *buffer, size_t bytes)
Definition logger_impl.h:91
static void Init()
Definition logger_impl.h:80
static UsbHandle usb_handle_
Definition logger_impl.h:100
static void Init()
Definition logger_impl.h:48
static bool Transmit(const void *buffer, size_t bytes)
Definition logger_impl.h:59
static UsbHandle usb_handle_
Definition logger_impl.h:68
static bool Transmit(const void *buffer, size_t bytes)
Definition logger_impl.h:116
static void Init()
Definition logger_impl.h:112
Logging I/O underlying implementation.
Definition logger_impl.h:28
static void Init()
Definition logger_impl.h:32
static bool Transmit(const void *buffer, size_t bytes)
Definition logger_impl.h:36
Hardware defines and helpers for daisy field platform.
Definition index.h:2
LoggerDestination
Definition logger_impl.h:15
@ LOGGER_INTERNAL
Definition logger_impl.h:17
@ LOGGER_EXTERNAL
Definition logger_impl.h:18
@ LOGGER_SEMIHOST
Definition logger_impl.h:19
@ LOGGER_NONE
Definition logger_impl.h:16