mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/usb/cdc/acm: port to new interface
This commit is contained in:
parent
76997fdd76
commit
68c8a9a3a2
@ -26,34 +26,15 @@
|
||||
|
||||
#include "log.h"
|
||||
#include "isrpipe.h"
|
||||
#include "stdio_base.h"
|
||||
|
||||
#include "usb/usbus.h"
|
||||
#include "usb/usbus/cdc/acm.h"
|
||||
|
||||
static usbus_cdcacm_device_t cdcacm;
|
||||
static uint8_t _cdc_tx_buf_mem[CONFIG_USBUS_CDC_ACM_STDIO_BUF_SIZE];
|
||||
static uint8_t _cdc_rx_buf_mem[CONFIG_USBUS_CDC_ACM_STDIO_BUF_SIZE];
|
||||
static isrpipe_t _cdc_stdio_isrpipe = ISRPIPE_INIT(_cdc_rx_buf_mem);
|
||||
|
||||
void stdio_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
#if IS_USED(MODULE_STDIO_AVAILABLE)
|
||||
int stdio_available(void)
|
||||
{
|
||||
return tsrb_avail(&_cdc_stdio_isrpipe.tsrb);
|
||||
}
|
||||
#endif
|
||||
|
||||
ssize_t stdio_read(void* buffer, size_t len)
|
||||
{
|
||||
(void)buffer;
|
||||
(void)len;
|
||||
return isrpipe_read(&_cdc_stdio_isrpipe, buffer, len);
|
||||
}
|
||||
|
||||
ssize_t stdio_write(const void* buffer, size_t len)
|
||||
static ssize_t _write(const void* buffer, size_t len)
|
||||
{
|
||||
const char *start = buffer;
|
||||
do {
|
||||
@ -71,7 +52,7 @@ static void _cdc_acm_rx_pipe(usbus_cdcacm_device_t *cdcacm,
|
||||
{
|
||||
(void)cdcacm;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
isrpipe_write_one(&_cdc_stdio_isrpipe, data[i]);
|
||||
isrpipe_write_one(&stdin_isrpipe, data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,3 +61,5 @@ void usb_cdc_acm_stdio_init(usbus_t *usbus)
|
||||
usbus_cdc_acm_init(usbus, &cdcacm, _cdc_acm_rx_pipe, NULL,
|
||||
_cdc_tx_buf_mem, sizeof(_cdc_tx_buf_mem));
|
||||
}
|
||||
|
||||
STDIO_PROVIDER(STDIO_USBUS_CDC_ACM, NULL, NULL, _write)
|
||||
|
Loading…
Reference in New Issue
Block a user