mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/usb/ubsus/cdc/acm: move board reset function
The board reset function `usb_board_reset_coding_cb` can be used on any CDC ACM interface. It is not necessary that the highlevel STDIO is used. Therefore, the call of the board reset function `usb_board_reset_coding_cb` has been moved from the USBUS STDIO CDC ACM implementation to USBUS CDC ACM implementation and is thus a feature of the USBUS CDC ACM interface that don't require any other functionality.
This commit is contained in:
parent
2274a56fef
commit
5f0d9ff3a6
@ -29,6 +29,8 @@
|
||||
#include "usb/usbus/cdc/acm.h"
|
||||
#include "usb/usbus/control.h"
|
||||
|
||||
#include "usb_board_reset_internal.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
@ -259,7 +261,7 @@ static int _control_handler(usbus_t *usbus, usbus_handler_t *handler,
|
||||
usbus_cdcacm_device_t *cdcacm = (usbus_cdcacm_device_t*)handler;
|
||||
switch (setup->request) {
|
||||
case USB_CDC_MGNT_REQUEST_SET_LINE_CODING:
|
||||
if (!(cdcacm->coding_cb)) {
|
||||
if (!(cdcacm->coding_cb) && !IS_USED(MODULE_USB_BOARD_RESET)) {
|
||||
/* Line coding not supported, return STALL */
|
||||
DEBUG("CDCACM: line coding not supported\n");
|
||||
return -1;
|
||||
@ -279,6 +281,12 @@ static int _control_handler(usbus_t *usbus, usbus_handler_t *handler,
|
||||
sizeof(usb_req_cdcacm_coding_t), len);
|
||||
return -1;
|
||||
}
|
||||
if (IS_USED(MODULE_USB_BOARD_RESET)) {
|
||||
/* call board reset function first if reset is received */
|
||||
usb_board_reset_coding_cb(cdcacm, coding->baud,
|
||||
coding->databits, coding->parity,
|
||||
coding->format);
|
||||
}
|
||||
if (cdcacm->coding_cb) {
|
||||
DEBUG("Setting line coding to baud rate %" PRIu32 ", "
|
||||
"%u data bits, parity value %u, stop bit value %u\n",
|
||||
|
@ -34,10 +34,6 @@
|
||||
#include "vfs.h"
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_USB_BOARD_RESET
|
||||
#include "usb_board_reset_internal.h"
|
||||
#endif
|
||||
|
||||
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];
|
||||
@ -91,7 +87,4 @@ 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));
|
||||
#ifdef MODULE_USB_BOARD_RESET
|
||||
usbus_cdc_acm_set_coding_cb(&cdcacm, usb_board_reset_coding_cb);
|
||||
#endif
|
||||
}
|
||||
|
@ -47,11 +47,11 @@ int usb_board_reset_coding_cb(usbus_cdcacm_device_t *cdcacm,
|
||||
(void)stop;
|
||||
switch (baud) {
|
||||
case RESET_IN_BOOTLOADER_TRIGGER_BAUDRATE:
|
||||
LOG_DEBUG("[cdc-acm-stdio] reset in bootloader");
|
||||
LOG_DEBUG("[cdc-acm] reset in bootloader\n");
|
||||
usb_board_reset_in_bootloader();
|
||||
break;
|
||||
case RESET_IN_APPLICATION_TRIGGER_BAUDRATE:
|
||||
LOG_DEBUG("[cdc-acm-stdio] reset in application");
|
||||
LOG_DEBUG("[cdc-acm] reset in application\n");
|
||||
usb_board_reset_in_application();
|
||||
break;
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user