Skip to content

Commit ff2b72f

Browse files
committed
feature(cdc_class): Applied sections & alignment to cdc data buffers
1 parent 7807c6b commit ff2b72f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/class/cdc/cdc_device.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
#define BULK_PACKET_SIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
4747

4848
typedef struct {
49+
// Endpoint Transfer buffer
50+
// Hint: When DMA capability is enabled and cache is used and the buffers
51+
// should be in specific section CFG_TUD_MEM_SECTION we declare them first
52+
CFG_TUSB_MEM_ALIGN uint8_t epout_buf[CFG_TUD_CDC_EP_BUFSIZE];
53+
CFG_TUSB_MEM_ALIGN uint8_t epin_buf[CFG_TUD_CDC_EP_BUFSIZE];
54+
4955
uint8_t itf_num;
5056
uint8_t ep_notif;
5157
uint8_t ep_in;
@@ -68,17 +74,15 @@ typedef struct {
6874
OSAL_MUTEX_DEF(rx_ff_mutex);
6975
OSAL_MUTEX_DEF(tx_ff_mutex);
7076

71-
// Endpoint Transfer buffer
72-
CFG_TUSB_MEM_ALIGN uint8_t epout_buf[CFG_TUD_CDC_EP_BUFSIZE];
73-
CFG_TUSB_MEM_ALIGN uint8_t epin_buf[CFG_TUD_CDC_EP_BUFSIZE];
7477
} cdcd_interface_t;
7578

7679
#define ITF_MEM_RESET_SIZE offsetof(cdcd_interface_t, wanted_char)
7780

7881
//--------------------------------------------------------------------+
7982
// INTERNAL OBJECT & FUNCTION DECLARATION
8083
//--------------------------------------------------------------------+
81-
CFG_TUD_MEM_SECTION static cdcd_interface_t _cdcd_itf[CFG_TUD_CDC];
84+
CFG_TUD_MEM_SECTION CFG_TUSB_MEM_ALIGN tu_static cdcd_interface_t _cdcd_itf[CFG_TUD_CDC];
85+
8286
static tud_cdc_configure_fifo_t _cdcd_fifo_cfg;
8387

8488
static bool _prep_out_transaction (cdcd_interface_t* p_cdc) {

0 commit comments

Comments
 (0)