Skip to content

Commit 3336e16

Browse files
committed
update tinyusb
1 parent f43338a commit 3336e16

File tree

8 files changed

+69
-31
lines changed

8 files changed

+69
-31
lines changed

src/class/audio/audio_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ typedef struct
340340

341341
#if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
342342
struct {
343-
uint32_t value; // Feedback value for asynchronous mode (in 16.16 format).
343+
CFG_TUSB_MEM_ALIGN uint32_t value; // Feedback value for asynchronous mode (in 16.16 format).
344344
uint32_t min_value; // min value according to UAC2 FMT-2.0 section 2.3.1.1.
345345
uint32_t max_value; // max value according to UAC2 FMT-2.0 section 2.3.1.1.
346346

src/class/cdc/cdc_host.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ typedef struct {
6262
tu_edpt_stream_t rx;
6363

6464
uint8_t tx_ff_buf[CFG_TUH_CDC_TX_BUFSIZE];
65-
CFG_TUSB_MEM_ALIGN uint8_t tx_ep_buf[CFG_TUH_CDC_TX_EPSIZE];
65+
CFG_TUH_MEM_ALIGN uint8_t tx_ep_buf[CFG_TUH_CDC_TX_EPSIZE];
6666

6767
uint8_t rx_ff_buf[CFG_TUH_CDC_TX_BUFSIZE];
68-
CFG_TUSB_MEM_ALIGN uint8_t rx_ep_buf[CFG_TUH_CDC_TX_EPSIZE];
68+
CFG_TUH_MEM_ALIGN uint8_t rx_ep_buf[CFG_TUH_CDC_TX_EPSIZE];
6969
} stream;
7070

7171
} cdch_interface_t;
@@ -74,7 +74,7 @@ typedef struct {
7474
// INTERNAL OBJECT & FUNCTION DECLARATION
7575
//--------------------------------------------------------------------+
7676

77-
CFG_TUSB_MEM_SECTION
77+
CFG_TUH_MEM_SECTION
7878
static cdch_interface_t cdch_data[CFG_TUH_CDC];
7979

8080
static inline cdch_interface_t* get_itf(uint8_t idx)

src/class/hid/hid_host.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ typedef struct
5858
uint16_t epin_size;
5959
uint16_t epout_size;
6060

61-
uint8_t epin_buf[CFG_TUH_HID_EPIN_BUFSIZE];
62-
uint8_t epout_buf[CFG_TUH_HID_EPOUT_BUFSIZE];
61+
CFG_TUH_MEM_ALIGN uint8_t epin_buf[CFG_TUH_HID_EPIN_BUFSIZE];
62+
CFG_TUH_MEM_ALIGN uint8_t epout_buf[CFG_TUH_HID_EPOUT_BUFSIZE];
6363
} hidh_interface_t;
6464

65-
CFG_TUSB_MEM_SECTION
65+
CFG_TUH_MEM_SECTION
6666
tu_static hidh_interface_t _hidh_itf[CFG_TUH_HID];
6767

6868
//--------------------------------------------------------------------+

src/class/msc/msc_host.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ typedef struct
7171
tuh_msc_complete_cb_t complete_cb;
7272
uintptr_t complete_arg;
7373

74-
msc_cbw_t cbw;
75-
msc_csw_t csw;
74+
CFG_TUH_MEM_ALIGN msc_cbw_t cbw;
75+
CFG_TUH_MEM_ALIGN msc_csw_t csw;
7676
}msch_interface_t;
7777

78-
CFG_TUSB_MEM_SECTION static msch_interface_t _msch_itf[CFG_TUH_DEVICE_MAX];
78+
CFG_TUH_MEM_SECTION static msch_interface_t _msch_itf[CFG_TUH_DEVICE_MAX];
7979

8080
// buffer used to read scsi information when mounted
8181
// largest response data currently is inquiry TODO Inquiry is not part of enum anymore
82-
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4)
82+
CFG_TUH_MEM_SECTION CFG_TUH_MEM_ALIGN
8383
static uint8_t _msch_buffer[sizeof(scsi_inquiry_resp_t)];
8484

8585
TU_ATTR_ALWAYS_INLINE

src/class/usbtmc/usbtmc.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -262,32 +262,32 @@ typedef struct TU_ATTR_PACKED
262262

263263
struct TU_ATTR_PACKED
264264
{
265-
unsigned int listenOnly :1;
266-
unsigned int talkOnly :1;
267-
unsigned int supportsIndicatorPulse :1;
265+
uint8_t listenOnly :1;
266+
uint8_t talkOnly :1;
267+
uint8_t supportsIndicatorPulse :1;
268268
} bmIntfcCapabilities;
269269

270270
struct TU_ATTR_PACKED
271271
{
272-
unsigned int canEndBulkInOnTermChar :1;
272+
uint8_t canEndBulkInOnTermChar :1;
273273
} bmDevCapabilities;
274274

275275
uint8_t _reserved2[6];
276276
uint16_t bcdUSB488;
277277

278278
struct TU_ATTR_PACKED
279279
{
280-
unsigned int is488_2 :1;
281-
unsigned int supportsREN_GTL_LLO :1;
282-
unsigned int supportsTrigger :1;
280+
uint8_t supportsTrigger :1;
281+
uint8_t supportsREN_GTL_LLO :1;
282+
uint8_t is488_2 :1;
283283
} bmIntfcCapabilities488;
284284

285285
struct TU_ATTR_PACKED
286286
{
287-
unsigned int SCPI :1;
288-
unsigned int SR1 :1;
289-
unsigned int RL1 :1;
290-
unsigned int DT1 :1;
287+
uint8_t DT1 :1;
288+
uint8_t RL1 :1;
289+
uint8_t SR1 :1;
290+
uint8_t SCPI :1;
291291
} bmDevCapabilities488;
292292
uint8_t _reserved3[8];
293293
} usbtmc_response_capabilities_488_t;

src/host/hub.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ typedef struct
4343
uint8_t port_count;
4444
uint8_t status_change; // data from status change interrupt endpoint
4545

46-
hub_port_status_response_t port_status;
47-
hub_status_response_t hub_status;
46+
CFG_TUH_MEM_ALIGN hub_port_status_response_t port_status;
47+
CFG_TUH_MEM_ALIGN hub_status_response_t hub_status;
4848
} hub_interface_t;
4949

50-
CFG_TUSB_MEM_SECTION static hub_interface_t hub_data[CFG_TUH_HUB];
51-
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4) static uint8_t _hub_buffer[sizeof(descriptor_hub_desc_t)];
50+
CFG_TUH_MEM_SECTION static hub_interface_t hub_data[CFG_TUH_HUB];
51+
CFG_TUH_MEM_SECTION CFG_TUH_MEM_ALIGN static uint8_t _hub_buffer[sizeof(descriptor_hub_desc_t)];
5252

5353
TU_ATTR_ALWAYS_INLINE
5454
static inline hub_interface_t* get_itf(uint8_t dev_addr)

src/host/usbh.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static usbh_dev0_t _dev0;
203203
// all devices excluding zero-address
204204
// hub address start from CFG_TUH_DEVICE_MAX+1
205205
// TODO: hub can has its own simpler struct to save memory
206-
CFG_TUSB_MEM_SECTION usbh_device_t _usbh_devices[TOTAL_DEVICES];
206+
static usbh_device_t _usbh_devices[TOTAL_DEVICES];
207207

208208
// Mutex for claiming endpoint
209209
#if OSAL_MUTEX_REQUIRED
@@ -218,15 +218,15 @@ CFG_TUSB_MEM_SECTION usbh_device_t _usbh_devices[TOTAL_DEVICES];
218218
OSAL_QUEUE_DEF(usbh_int_set, _usbh_qdef, CFG_TUH_TASK_QUEUE_SZ, hcd_event_t);
219219
static osal_queue_t _usbh_q;
220220

221-
CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN
221+
CFG_TUH_MEM_SECTION CFG_TUH_MEM_ALIGN
222222
static uint8_t _usbh_ctrl_buf[CFG_TUH_ENUMERATION_BUFSIZE];
223223

224224
// Control transfers: since most controllers do not support multiple control transfers
225225
// on multiple devices concurrently and control transfers are not used much except for
226226
// enumeration, we will only execute control transfers one at a time.
227-
CFG_TUSB_MEM_SECTION struct
227+
CFG_TUH_MEM_SECTION struct
228228
{
229-
tusb_control_request_t request TU_ATTR_ALIGNED(4);
229+
CFG_TUH_MEM_ALIGN tusb_control_request_t request;
230230
uint8_t* buffer;
231231
tuh_xfer_cb_t complete_cb;
232232
uintptr_t user_data;

src/tusb_option.h

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,15 @@
289289
#define CFG_TUSB_DEBUG 0
290290
#endif
291291

292-
// place data in accessible RAM for usb controller
292+
// TODO MEM_SECTION can be different for host and device controller
293+
// should use CFG_TUD_MEM_SECTION, CFG_TUH_MEM_SECTION
293294
#ifndef CFG_TUSB_MEM_SECTION
294295
#define CFG_TUSB_MEM_SECTION
295296
#endif
296297

297298
// alignment requirement of buffer used for endpoint transferring
299+
// TODO MEM_ALIGN can be different for host and device controller
300+
// should use CFG_TUD_MEM_ALIGN, CFG_TUH_MEM_ALIGN
298301
#ifndef CFG_TUSB_MEM_ALIGN
299302
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
300303
#endif
@@ -312,6 +315,26 @@
312315
// Device Options (Default)
313316
//--------------------------------------------------------------------
314317

318+
// Attribute to place data in accessible RAM for device controller
319+
// default to CFG_TUSB_MEM_SECTION for backward-compatible
320+
#ifndef CFG_TUD_MEM_SECTION
321+
#ifdef CFG_TUSB_MEM_SECTION
322+
#define CFG_TUD_MEM_SECTION CFG_TUSB_MEM_SECTION
323+
#else
324+
#define CFG_TUD_MEM_SECTION
325+
#endif
326+
#endif
327+
328+
// Attribute to align memory for device controller
329+
// default to CFG_TUSB_MEM_ALIGN for backward-compatible
330+
#ifndef CFG_TUD_MEM_ALIGN
331+
#ifdef CFG_TUSB_MEM_ALIGN
332+
#define CFG_TUD_MEM_ALIGN CFG_TUSB_MEM_ALIGN
333+
#else
334+
#define CFG_TUD_MEM_ALIGN TU_ATTR_ALIGNED(4)
335+
#endif
336+
#endif
337+
315338
#ifndef CFG_TUD_ENDPOINT0_SIZE
316339
#define CFG_TUD_ENDPOINT0_SIZE 64
317340
#endif
@@ -390,6 +413,21 @@
390413
#endif
391414
#endif // CFG_TUH_ENABLED
392415

416+
// Attribute to place data in accessible RAM for host controller
417+
// default to CFG_TUSB_MEM_SECTION for backward-compatible
418+
#ifndef CFG_TUH_MEM_SECTION
419+
#ifdef CFG_TUSB_MEM_SECTION
420+
#define CFG_TUH_MEM_SECTION CFG_TUSB_MEM_SECTION
421+
#else
422+
#define CFG_TUH_MEM_SECTION
423+
#endif
424+
#endif
425+
426+
// Attribute to align memory for host controller
427+
#ifndef CFG_TUH_MEM_ALIGN
428+
#define CFG_TUH_MEM_ALIGN TU_ATTR_ALIGNED(4)
429+
#endif
430+
393431
//------------- CLASS -------------//
394432

395433
#ifndef CFG_TUH_HUB

0 commit comments

Comments
 (0)