stm32/usbd_cdc_interface: Rename USBD_CDC_xx opts to MICROPY_HW_USB_xx.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2021-08-05 12:21:58 +10:00
parent f28e8b9073
commit 3b32b3d1b3
7 changed files with 37 additions and 28 deletions

View File

@@ -172,7 +172,7 @@ int8_t usbd_cdc_control(usbd_cdc_state_t *cdc_in, uint8_t cmd, uint8_t *pbuf, ui
}
static inline uint16_t usbd_cdc_tx_buffer_mask(uint16_t val) {
return val & (USBD_CDC_TX_DATA_SIZE - 1);
return val & (MICROPY_HW_USB_CDC_TX_DATA_SIZE - 1);
}
static inline uint16_t usbd_cdc_tx_buffer_size(usbd_cdc_itf_t *cdc) {
@@ -188,18 +188,18 @@ static inline bool usbd_cdc_tx_buffer_will_be_empty(usbd_cdc_itf_t *cdc) {
}
static inline bool usbd_cdc_tx_buffer_full(usbd_cdc_itf_t *cdc) {
return usbd_cdc_tx_buffer_size(cdc) == USBD_CDC_TX_DATA_SIZE;
return usbd_cdc_tx_buffer_size(cdc) == MICROPY_HW_USB_CDC_TX_DATA_SIZE;
}
static uint16_t usbd_cdc_tx_send_length(usbd_cdc_itf_t *cdc) {
uint16_t to_end = USBD_CDC_TX_DATA_SIZE - usbd_cdc_tx_buffer_mask(cdc->tx_buf_ptr_out);
uint16_t to_end = MICROPY_HW_USB_CDC_TX_DATA_SIZE - usbd_cdc_tx_buffer_mask(cdc->tx_buf_ptr_out);
return MIN(usbd_cdc_tx_buffer_size(cdc), to_end);
}
static void usbd_cdc_tx_buffer_put(usbd_cdc_itf_t *cdc, uint8_t data, bool check_overflow) {
cdc->tx_buf[usbd_cdc_tx_buffer_mask(cdc->tx_buf_ptr_in)] = data;
cdc->tx_buf_ptr_in++;
if (check_overflow && usbd_cdc_tx_buffer_size(cdc) > USBD_CDC_TX_DATA_SIZE) {
if (check_overflow && usbd_cdc_tx_buffer_size(cdc) > MICROPY_HW_USB_CDC_TX_DATA_SIZE) {
cdc->tx_buf_ptr_out++;
cdc->tx_buf_ptr_out_next = cdc->tx_buf_ptr_out;
}
@@ -270,7 +270,7 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
bool usbd_cdc_rx_buffer_full(usbd_cdc_itf_t *cdc) {
int get = cdc->rx_buf_get, put = cdc->rx_buf_put;
int remaining = (get - put) + (-((int)(get <= put)) & USBD_CDC_RX_DATA_SIZE);
int remaining = (get - put) + (-((int)(get <= put)) & MICROPY_HW_USB_CDC_RX_DATA_SIZE);
return remaining < CDC_DATA_MAX_PACKET_SIZE + 1;
}
@@ -298,7 +298,7 @@ int8_t usbd_cdc_receive(usbd_cdc_state_t *cdc_in, size_t len) {
if (cdc->attached_to_repl && *src == mp_interrupt_char) {
pendsv_kbd_intr();
} else {
uint16_t next_put = (cdc->rx_buf_put + 1) & (USBD_CDC_RX_DATA_SIZE - 1);
uint16_t next_put = (cdc->rx_buf_put + 1) & (MICROPY_HW_USB_CDC_RX_DATA_SIZE - 1);
if (next_put == cdc->rx_buf_get) {
// overflow, we just discard the rest of the chars
break;
@@ -322,7 +322,7 @@ int8_t usbd_cdc_receive(usbd_cdc_state_t *cdc_in, size_t len) {
int usbd_cdc_tx_half_empty(usbd_cdc_itf_t *cdc) {
int32_t tx_waiting = usbd_cdc_tx_buffer_size(cdc);
return tx_waiting <= USBD_CDC_TX_DATA_SIZE / 2;
return tx_waiting <= MICROPY_HW_USB_CDC_TX_DATA_SIZE / 2;
}
// Writes only the data that fits if flow & CTS, else writes all data
@@ -405,7 +405,7 @@ void usbd_cdc_tx_always(usbd_cdc_itf_t *cdc, const uint8_t *buf, uint32_t len) {
int usbd_cdc_rx_num(usbd_cdc_itf_t *cdc) {
int32_t rx_waiting = (int32_t)cdc->rx_buf_put - (int32_t)cdc->rx_buf_get;
if (rx_waiting < 0) {
rx_waiting += USBD_CDC_RX_DATA_SIZE;
rx_waiting += MICROPY_HW_USB_CDC_RX_DATA_SIZE;
}
usbd_cdc_rx_check_resume(cdc);
return rx_waiting;
@@ -434,7 +434,7 @@ int usbd_cdc_rx(usbd_cdc_itf_t *cdc, uint8_t *buf, uint32_t len, uint32_t timeou
// Copy byte from device to user buffer
buf[i] = cdc->rx_user_buf[cdc->rx_buf_get];
cdc->rx_buf_get = (cdc->rx_buf_get + 1) & (USBD_CDC_RX_DATA_SIZE - 1);
cdc->rx_buf_get = (cdc->rx_buf_get + 1) & (MICROPY_HW_USB_CDC_RX_DATA_SIZE - 1);
}
usbd_cdc_rx_check_resume(cdc);