device API rename

This commit is contained in:
hathach 2018-03-01 12:51:19 +07:00
parent 8bb35e2604
commit 9a2924fb36
13 changed files with 71 additions and 72 deletions

View File

@ -64,19 +64,19 @@ FIFO_DEF(fifo_serial, SERIAL_BUFFER_SIZE, uint8_t, true);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// tinyusb callbacks // tinyusb callbacks
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void tusbd_cdc_mounted_cb(uint8_t coreid) void tud_cdc_mounted_cb(uint8_t coreid)
{ {
osal_semaphore_reset(sem_hdl); osal_semaphore_reset(sem_hdl);
tusbd_cdc_receive(coreid, serial_rx_buffer, SERIAL_BUFFER_SIZE, true); tud_cdc_receive(coreid, serial_rx_buffer, SERIAL_BUFFER_SIZE, true);
} }
void tusbd_cdc_unmounted_cb(uint8_t coreid) void tud_cdc_unmounted_cb(uint8_t coreid)
{ {
} }
void tusbd_cdc_xfer_cb(uint8_t coreid, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes) void tud_cdc_xfer_cb(uint8_t coreid, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes)
{ {
switch ( pipe_id ) switch ( pipe_id )
{ {
@ -92,7 +92,7 @@ void tusbd_cdc_xfer_cb(uint8_t coreid, tusb_event_t event, cdc_pipeid_t pipe_id,
break; break;
case TUSB_EVENT_XFER_ERROR: case TUSB_EVENT_XFER_ERROR:
tusbd_cdc_receive(0, serial_rx_buffer, SERIAL_BUFFER_SIZE, true); // ignore, queue transfer again tud_cdc_receive(0, serial_rx_buffer, SERIAL_BUFFER_SIZE, true); // ignore, queue transfer again
break; break;
case TUSB_EVENT_XFER_STALLED: case TUSB_EVENT_XFER_STALLED:
@ -139,10 +139,10 @@ tusb_error_t cdcd_serial_subtask(void)
osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_WAIT_FOREVER, &error); osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_WAIT_FOREVER, &error);
(void) error; // suppress compiler's warnings (void) error; // suppress compiler's warnings
if ( tusbd_is_configured(0) ) if ( tud_configured(0) )
{ {
// echo back data in the fifo // echo back data in the fifo
if ( !tusbd_cdc_is_busy(0, CDC_PIPE_DATA_IN) ) if ( !tud_cdc_busy(0, CDC_PIPE_DATA_IN) )
{ {
uint16_t count=0; uint16_t count=0;
while( fifo_read(&fifo_serial, &serial_tx_buffer[count]) ) while( fifo_read(&fifo_serial, &serial_tx_buffer[count]) )
@ -152,12 +152,12 @@ tusb_error_t cdcd_serial_subtask(void)
if (count) if (count)
{ {
tusbd_cdc_send(0, serial_tx_buffer, count, false); tud_cdc_send(0, serial_tx_buffer, count, false);
} }
} }
// getting more data from host // getting more data from host
tusbd_cdc_receive(0, serial_rx_buffer, SERIAL_BUFFER_SIZE, true); tud_cdc_receive(0, serial_rx_buffer, SERIAL_BUFFER_SIZE, true);
} }
OSAL_SUBTASK_END OSAL_SUBTASK_END

View File

@ -56,17 +56,17 @@ TUSB_CFG_ATTR_USBRAM hid_keyboard_report_t keyboard_report;
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// tinyusb callbacks // tinyusb callbacks
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void tusbd_hid_keyboard_mounted_cb(uint8_t coreid) void tud_hid_keyboard_mounted_cb(uint8_t coreid)
{ {
} }
void tusbd_hid_keyboard_unmounted_cb(uint8_t coreid) void tud_hid_keyboard_unmounted_cb(uint8_t coreid)
{ {
} }
void tusbd_hid_keyboard_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_bytes) void tud_hid_keyboard_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_bytes)
{ {
switch(event) switch(event)
{ {
@ -77,7 +77,7 @@ void tusbd_hid_keyboard_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_
} }
} }
uint16_t tusbd_hid_keyboard_get_report_cb(uint8_t coreid, hid_request_report_type_t report_type, void** pp_report, uint16_t requested_length) uint16_t tud_hid_keyboard_get_report_cb(uint8_t coreid, hid_request_report_type_t report_type, void** pp_report, uint16_t requested_length)
{ {
// get other than input report is not supported by this keyboard demo // get other than input report is not supported by this keyboard demo
if ( report_type != HID_REQUEST_REPORT_INPUT ) return 0; if ( report_type != HID_REQUEST_REPORT_INPUT ) return 0;
@ -86,7 +86,7 @@ uint16_t tusbd_hid_keyboard_get_report_cb(uint8_t coreid, hid_request_report_typ
return requested_length; return requested_length;
} }
void tusbd_hid_keyboard_set_report_cb(uint8_t coreid, hid_request_report_type_t report_type, uint8_t p_report_data[], uint16_t length) void tud_hid_keyboard_set_report_cb(uint8_t coreid, hid_request_report_type_t report_type, uint8_t p_report_data[], uint16_t length)
{ {
// set other than output report is not supported by this keyboard demo // set other than output report is not supported by this keyboard demo
if ( report_type != HID_REQUEST_REPORT_OUTPUT ) return; if ( report_type != HID_REQUEST_REPORT_OUTPUT ) return;
@ -126,7 +126,7 @@ tusb_error_t keyboard_device_subtask(void)
osal_task_delay(50); osal_task_delay(50);
if ( tusbd_is_configured(0) && !tusbd_hid_keyboard_is_busy(0) ) if ( tud_configured(0) && !tud_hid_keyboard_busy(0) )
{ {
static uint32_t button_mask = 0; static uint32_t button_mask = 0;
uint32_t new_button_mask = board_buttons(); uint32_t new_button_mask = board_buttons();
@ -141,7 +141,7 @@ tusb_error_t keyboard_device_subtask(void)
keyboard_report.keycode[i] = BIT_TEST_(button_mask, i) ? (0x04+i) : 0; keyboard_report.keycode[i] = BIT_TEST_(button_mask, i) ? (0x04+i) : 0;
} }
tusbd_hid_keyboard_send(0, &keyboard_report ); tud_hid_keyboard_send(0, &keyboard_report );
} }
} }

View File

@ -89,17 +89,17 @@ static scsi_mode_parameters_t const msc_dev_mode_para =
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// tinyusb callbacks // tinyusb callbacks
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void tusbd_msc_mounted_cb(uint8_t coreid) void tud_msc_mounted_cb(uint8_t coreid)
{ {
} }
void tusbd_msc_unmounted_cb(uint8_t coreid) void tud_msc_unmounted_cb(uint8_t coreid)
{ {
} }
msc_csw_status_t tusbd_msc_scsi_cb (uint8_t coreid, uint8_t lun, uint8_t scsi_cmd[16], void const ** pp_buffer, uint16_t* p_length) msc_csw_status_t tud_msc_scsi_cb (uint8_t coreid, uint8_t lun, uint8_t scsi_cmd[16], void const ** pp_buffer, uint16_t* p_length)
{ {
// read10 & write10 has their own callback and MUST not be handled here // read10 & write10 has their own callback and MUST not be handled here
switch (scsi_cmd[0]) switch (scsi_cmd[0])

View File

@ -91,13 +91,13 @@ uint8_t msc_device_ramdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// IMPLEMENTATION // IMPLEMENTATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
uint16_t tusbd_msc_read10_cb (uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count) uint16_t tud_msc_read10_cb (uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count)
{ {
(*pp_buffer) = msc_device_ramdisk[lba]; (*pp_buffer) = msc_device_ramdisk[lba];
return min16_of(block_count, DISK_BLOCK_NUM); return min16_of(block_count, DISK_BLOCK_NUM);
} }
uint16_t tusbd_msc_write10_cb(uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count) uint16_t tud_msc_write10_cb(uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count)
{ {
(*pp_buffer) = msc_device_ramdisk[lba]; (*pp_buffer) = msc_device_ramdisk[lba];

View File

@ -66,7 +66,7 @@ STATIC_VAR cdcd_data_t cdcd_data[CONTROLLER_DEVICE_NUMBER];
static tusb_error_t cdcd_xfer(uint8_t coreid, cdc_pipeid_t pipeid, void * p_buffer, uint32_t length, bool is_notify) static tusb_error_t cdcd_xfer(uint8_t coreid, cdc_pipeid_t pipeid, void * p_buffer, uint32_t length, bool is_notify)
{ {
ASSERT(tusbd_is_configured(coreid), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED); ASSERT(tud_configured(coreid), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED);
cdcd_data_t* p_cdc = &cdcd_data[coreid]; cdcd_data_t* p_cdc = &cdcd_data[coreid];
@ -79,17 +79,17 @@ static tusb_error_t cdcd_xfer(uint8_t coreid, cdc_pipeid_t pipeid, void * p_buf
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// APPLICATION API (Parameters requires validation) // APPLICATION API (Parameters requires validation)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
bool tusbd_cdc_is_busy(uint8_t coreid, cdc_pipeid_t pipeid) bool tud_cdc_busy(uint8_t coreid, cdc_pipeid_t pipeid)
{ {
return dcd_pipe_is_busy( cdcd_data[coreid].edpt_hdl[pipeid] ); return dcd_pipe_is_busy( cdcd_data[coreid].edpt_hdl[pipeid] );
} }
tusb_error_t tusbd_cdc_receive(uint8_t coreid, void * p_buffer, uint32_t length, bool is_notify) tusb_error_t tud_cdc_receive(uint8_t coreid, void * p_buffer, uint32_t length, bool is_notify)
{ {
return cdcd_xfer(coreid, CDC_PIPE_DATA_OUT, p_buffer, length, is_notify); return cdcd_xfer(coreid, CDC_PIPE_DATA_OUT, p_buffer, length, is_notify);
} }
tusb_error_t tusbd_cdc_send(uint8_t coreid, void * p_data, uint32_t length, bool is_notify) tusb_error_t tud_cdc_send(uint8_t coreid, void * p_data, uint32_t length, bool is_notify)
{ {
return cdcd_xfer(coreid, CDC_PIPE_DATA_IN, p_data, length, is_notify); return cdcd_xfer(coreid, CDC_PIPE_DATA_IN, p_data, length, is_notify);
} }
@ -170,7 +170,7 @@ tusb_error_t cdcd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_int
p_cdc->interface_number = p_interface_desc->bInterfaceNumber; p_cdc->interface_number = p_interface_desc->bInterfaceNumber;
tusbd_cdc_mounted_cb(coreid); tud_cdc_mounted_cb(coreid);
return TUSB_ERROR_NONE; return TUSB_ERROR_NONE;
} }
@ -180,7 +180,7 @@ void cdcd_close(uint8_t coreid)
// no need to close opened pipe, dcd bus reset will put controller's endpoints to default state // no need to close opened pipe, dcd bus reset will put controller's endpoints to default state
memclr_(&cdcd_data[coreid], sizeof(cdcd_data_t)); memclr_(&cdcd_data[coreid], sizeof(cdcd_data_t));
tusbd_cdc_unmounted_cb(coreid); tud_cdc_unmounted_cb(coreid);
} }
tusb_error_t cdcd_control_request_subtask(uint8_t coreid, tusb_control_request_t const * p_request) tusb_error_t cdcd_control_request_subtask(uint8_t coreid, tusb_control_request_t const * p_request)
@ -218,7 +218,7 @@ tusb_error_t cdcd_xfer_cb(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32
{ {
if ( endpointhandle_is_equal(edpt_hdl, p_cdc->edpt_hdl[pipeid]) ) if ( endpointhandle_is_equal(edpt_hdl, p_cdc->edpt_hdl[pipeid]) )
{ {
tusbd_cdc_xfer_cb(edpt_hdl.coreid, event, pipeid, xferred_bytes); tud_cdc_xfer_cb(edpt_hdl.coreid, event, pipeid, xferred_bytes);
break; break;
} }
} }

View File

@ -61,7 +61,7 @@
* \retval false if the interface is not busy meaning the stack successfully transferred data from/to host * \retval false if the interface is not busy meaning the stack successfully transferred data from/to host
* \note This function is primarily used for polling/waiting result after \ref tusbd_hid_keyboard_send. * \note This function is primarily used for polling/waiting result after \ref tusbd_hid_keyboard_send.
*/ */
bool tusbd_cdc_is_busy(uint8_t coreid, cdc_pipeid_t pipeid) ATTR_PURE ATTR_WARN_UNUSED_RESULT; bool tud_cdc_busy(uint8_t coreid, cdc_pipeid_t pipeid) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
/** \brief Submit USB transfer /** \brief Submit USB transfer
* \param[in] coreid USB Controller ID * \param[in] coreid USB Controller ID
@ -77,7 +77,7 @@ bool tusbd_cdc_is_busy(uint8_t coreid, cdc_pipeid_t pipeid) ATTR_PURE ATTR_WARN
* \note This function is non-blocking and returns immediately. Data will be transferred when USB Host work with this interface. * \note This function is non-blocking and returns immediately. Data will be transferred when USB Host work with this interface.
* The result of usb transfer will be reported by the interface's callback function if \a is_notify is true * The result of usb transfer will be reported by the interface's callback function if \a is_notify is true
*/ */
tusb_error_t tusbd_cdc_send(uint8_t coreid, void * p_data, uint32_t length, bool is_notify); tusb_error_t tud_cdc_send(uint8_t coreid, void * p_data, uint32_t length, bool is_notify);
/** \brief Submit USB transfer /** \brief Submit USB transfer
* \param[in] coreid USB Controller ID * \param[in] coreid USB Controller ID
@ -93,7 +93,7 @@ tusb_error_t tusbd_cdc_send(uint8_t coreid, void * p_data, uint32_t length, bool
* \note This function is non-blocking and returns immediately. Data will be transferred when USB Host work with this interface. * \note This function is non-blocking and returns immediately. Data will be transferred when USB Host work with this interface.
* The result of usb transfer will be reported by the interface's callback function if \a is_notify is true * The result of usb transfer will be reported by the interface's callback function if \a is_notify is true
*/ */
tusb_error_t tusbd_cdc_receive(uint8_t coreid, void * p_buffer, uint32_t length, bool is_notify); tusb_error_t tud_cdc_receive(uint8_t coreid, void * p_buffer, uint32_t length, bool is_notify);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// APPLICATION CALLBACK API // APPLICATION CALLBACK API
@ -102,13 +102,13 @@ tusb_error_t tusbd_cdc_receive(uint8_t coreid, void * p_buffer, uint32_t length,
* \param[in] coreid USB Controller ID of the interface * \param[in] coreid USB Controller ID of the interface
* \note This callback should be used by Application to \b set-up interface-related data * \note This callback should be used by Application to \b set-up interface-related data
*/ */
void tusbd_cdc_mounted_cb(uint8_t coreid); void tud_cdc_mounted_cb(uint8_t coreid);
/** \brief Callback function that will be invoked when this interface is unmounted (bus reset/unplugged) /** \brief Callback function that will be invoked when this interface is unmounted (bus reset/unplugged)
* \param[in] coreid USB Controller ID of the interface * \param[in] coreid USB Controller ID of the interface
* \note This callback should be used by Application to \b tear-down interface-related data * \note This callback should be used by Application to \b tear-down interface-related data
*/ */
void tusbd_cdc_unmounted_cb(uint8_t coreid); void tud_cdc_unmounted_cb(uint8_t coreid);
/** \brief Callback function that is invoked when an completion (error or success) of an USB transfer previously submitted /** \brief Callback function that is invoked when an completion (error or success) of an USB transfer previously submitted
* by application (e.g \ref tusbd_cdc_send or \ref tusbd_cdc_send) with \a is_notify set to true. * by application (e.g \ref tusbd_cdc_send or \ref tusbd_cdc_send) with \a is_notify set to true.
@ -118,8 +118,8 @@ void tusbd_cdc_unmounted_cb(uint8_t coreid);
* \param[in] xferred_bytes is actual number of bytes transferred via USB bus. This value in general can be different to * \param[in] xferred_bytes is actual number of bytes transferred via USB bus. This value in general can be different to
* the one that previously submitted by application. * the one that previously submitted by application.
*/ */
void tusbd_cdc_xfer_cb(uint8_t coreid, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes); void tud_cdc_xfer_cb(uint8_t coreid, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes);
//void tusbd_cdc_line_coding_changed_cb(uint8_t coreid, cdc_line_coding_t* p_line_coding); //void tud_cdc_line_coding_changed_cb(uint8_t coreid, cdc_line_coding_t* p_line_coding);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// USBD-CLASS DRIVER API // USBD-CLASS DRIVER API

View File

@ -58,7 +58,6 @@ typedef struct {
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// USBH-CLASS DRIVER API // USBH-CLASS DRIVER API
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
STATIC_ INLINE_ bool tusbh_custom_is_mounted(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id) ATTR_PURE ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
STATIC_ INLINE_ bool tusbh_custom_is_mounted(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id) STATIC_ INLINE_ bool tusbh_custom_is_mounted(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id)
{ {
(void) vendor_id; // TODO check this later (void) vendor_id; // TODO check this later

View File

@ -83,11 +83,11 @@ static hidd_class_driver_t const hidd_class_driver[HIDD_NUMBER_OF_SUBCLASS] =
[HID_PROTOCOL_KEYBOARD] = [HID_PROTOCOL_KEYBOARD] =
{ {
.p_interface = &keyboardd_data, .p_interface = &keyboardd_data,
.mounted_cb = tusbd_hid_keyboard_mounted_cb, .mounted_cb = tud_hid_keyboard_mounted_cb,
.unmounted_cb = tusbd_hid_keyboard_unmounted_cb, .unmounted_cb = tud_hid_keyboard_unmounted_cb,
.xfer_cb = tusbd_hid_keyboard_cb, .xfer_cb = tud_hid_keyboard_cb,
.get_report_cb = tusbd_hid_keyboard_get_report_cb, .get_report_cb = tud_hid_keyboard_get_report_cb,
.set_report_cb = tusbd_hid_keyboard_set_report_cb .set_report_cb = tud_hid_keyboard_set_report_cb
}, },
#endif #endif
@ -113,14 +113,14 @@ TUSB_CFG_ATTR_USBRAM STATIC_VAR uint8_t m_hid_buffer[ HIDD_BUFFER_SIZE ];
#if TUSB_CFG_DEVICE_HID_KEYBOARD #if TUSB_CFG_DEVICE_HID_KEYBOARD
STATIC_VAR hidd_interface_t keyboardd_data; STATIC_VAR hidd_interface_t keyboardd_data;
bool tusbd_hid_keyboard_is_busy(uint8_t coreid) bool tud_hid_keyboard_busy(uint8_t coreid)
{ {
return dcd_pipe_is_busy(keyboardd_data.ept_handle); return dcd_pipe_is_busy(keyboardd_data.ept_handle);
} }
tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_report) tusb_error_t tud_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_report)
{ {
ASSERT(tusbd_is_configured(coreid), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED); ASSERT(tud_configured(coreid), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED);
hidd_interface_t * p_kbd = &keyboardd_data; // TODO &keyboardd_data[coreid]; hidd_interface_t * p_kbd = &keyboardd_data; // TODO &keyboardd_data[coreid];
@ -143,7 +143,7 @@ bool tusbd_hid_mouse_is_busy(uint8_t coreid)
tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_report) tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_report)
{ {
ASSERT(tusbd_is_configured(coreid), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED); ASSERT(tud_configured(coreid), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED);
hidd_interface_t * p_mouse = &moused_data; // TODO &keyboardd_data[coreid]; hidd_interface_t * p_mouse = &moused_data; // TODO &keyboardd_data[coreid];

View File

@ -62,7 +62,7 @@
* \retval false if the interface is not busy meaning the stack successfully transferred data from/to host * \retval false if the interface is not busy meaning the stack successfully transferred data from/to host
* \note This function is primarily used for polling/waiting result after \ref tusbd_hid_keyboard_send. * \note This function is primarily used for polling/waiting result after \ref tusbd_hid_keyboard_send.
*/ */
bool tusbd_hid_keyboard_is_busy(uint8_t coreid); bool tud_hid_keyboard_busy(uint8_t coreid);
/** \brief Submit USB transfer /** \brief Submit USB transfer
* \param[in] coreid USB Controller ID * \param[in] coreid USB Controller ID
@ -75,7 +75,7 @@ bool tusbd_hid_keyboard_is_busy(uint8_t coreid);
* \note This function is non-blocking and returns immediately. Data will be transferred when USB Host work with this interface. * \note This function is non-blocking and returns immediately. Data will be transferred when USB Host work with this interface.
* The result of usb transfer will be reported by the interface's callback function * The result of usb transfer will be reported by the interface's callback function
*/ */
tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_report); tusb_error_t tud_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_report);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// APPLICATION CALLBACK API // APPLICATION CALLBACK API
@ -85,13 +85,13 @@ tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const
* \param[in] coreid USB Controller ID of the interface * \param[in] coreid USB Controller ID of the interface
* \note This callback should be used by Application to \b set-up interface-related data * \note This callback should be used by Application to \b set-up interface-related data
*/ */
void tusbd_hid_keyboard_mounted_cb(uint8_t coreid); void tud_hid_keyboard_mounted_cb(uint8_t coreid);
/** \brief Callback function that will be invoked when this interface is unmounted (bus reset/unplugged) /** \brief Callback function that will be invoked when this interface is unmounted (bus reset/unplugged)
* \param[in] coreid USB Controller ID of the interface * \param[in] coreid USB Controller ID of the interface
* \note This callback should be used by Application to \b tear-down interface-related data * \note This callback should be used by Application to \b tear-down interface-related data
*/ */
void tusbd_hid_keyboard_unmounted_cb(uint8_t coreid); void tud_hid_keyboard_unmounted_cb(uint8_t coreid);
/** \brief Callback function that is invoked when an transferring event occurred /** \brief Callback function that is invoked when an transferring event occurred
* after invoking \ref tusbd_hid_keyboard_send * after invoking \ref tusbd_hid_keyboard_send
@ -102,7 +102,7 @@ void tusbd_hid_keyboard_unmounted_cb(uint8_t coreid);
* - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error. * - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error.
* - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device. * - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device.
*/ */
void tusbd_hid_keyboard_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_bytes); void tud_hid_keyboard_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_bytes);
/** \brief Callback function that is invoked when USB host request \ref HID_REQUEST_CONTROL_GET_REPORT /** \brief Callback function that is invoked when USB host request \ref HID_REQUEST_CONTROL_GET_REPORT
* via control endpoint. * via control endpoint.
@ -117,7 +117,7 @@ void tusbd_hid_keyboard_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_
* the completion of this control request will not be reported to application. * the completion of this control request will not be reported to application.
* For Keyboard, USB host often uses this to turn on/off the LED for CAPLOCKS, NUMLOCK (\ref hid_keyboard_led_bm_t) * For Keyboard, USB host often uses this to turn on/off the LED for CAPLOCKS, NUMLOCK (\ref hid_keyboard_led_bm_t)
*/ */
uint16_t tusbd_hid_keyboard_get_report_cb(uint8_t coreid, hid_request_report_type_t report_type, void** pp_report, uint16_t requested_length); uint16_t tud_hid_keyboard_get_report_cb(uint8_t coreid, hid_request_report_type_t report_type, void** pp_report, uint16_t requested_length);
/** \brief Callback function that is invoked when USB host request \ref HID_REQUEST_CONTROL_SET_REPORT /** \brief Callback function that is invoked when USB host request \ref HID_REQUEST_CONTROL_SET_REPORT
* via control endpoint. * via control endpoint.
@ -128,7 +128,7 @@ uint16_t tusbd_hid_keyboard_get_report_cb(uint8_t coreid, hid_request_report_typ
* \note By the time this callback is invoked, the USB control transfer is already completed in the hardware side. * \note By the time this callback is invoked, the USB control transfer is already completed in the hardware side.
* Application are free to handle data at its own will. * Application are free to handle data at its own will.
*/ */
void tusbd_hid_keyboard_set_report_cb(uint8_t coreid, hid_request_report_type_t report_type, uint8_t p_report_data[], uint16_t length); void tud_hid_keyboard_set_report_cb(uint8_t coreid, hid_request_report_type_t report_type, uint8_t p_report_data[], uint16_t length);
/** @} */ /** @} */
/** @} */ /** @} */
@ -147,7 +147,7 @@ void tusbd_hid_keyboard_set_report_cb(uint8_t coreid, hid_request_report_type_t
* \retval false if the interface is not busy meaning the stack successfully transferred data from/to host * \retval false if the interface is not busy meaning the stack successfully transferred data from/to host
* \note This function is primarily used for polling/waiting result after \ref tusbd_hid_mouse_send. * \note This function is primarily used for polling/waiting result after \ref tusbd_hid_mouse_send.
*/ */
bool tusbd_hid_mouse_is_busy(uint8_t coreid); bool tud_hid_mouse_is_busy(uint8_t coreid);
/** \brief Perform transfer queuing /** \brief Perform transfer queuing
* \param[in] coreid USB Controller ID * \param[in] coreid USB Controller ID
@ -160,7 +160,7 @@ bool tusbd_hid_mouse_is_busy(uint8_t coreid);
* \note This function is non-blocking and returns immediately. Data will be transferred when USB Host work with this interface. * \note This function is non-blocking and returns immediately. Data will be transferred when USB Host work with this interface.
* The result of usb transfer will be reported by the interface's callback function * The result of usb transfer will be reported by the interface's callback function
*/ */
tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_report); tusb_error_t tud_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_report);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// APPLICATION CALLBACK API // APPLICATION CALLBACK API
@ -169,13 +169,13 @@ tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_re
* \param[in] coreid USB Controller ID of the interface * \param[in] coreid USB Controller ID of the interface
* \note This callback should be used by Application to \b set-up interface-related data * \note This callback should be used by Application to \b set-up interface-related data
*/ */
void tusbd_hid_mouse_mounted_cb(uint8_t coreid); void tud_hid_mouse_mounted_cb(uint8_t coreid);
/** \brief Callback function that will be invoked when this interface is unmounted (bus reset/unplugged) /** \brief Callback function that will be invoked when this interface is unmounted (bus reset/unplugged)
* \param[in] coreid USB Controller ID of the interface * \param[in] coreid USB Controller ID of the interface
* \note This callback should be used by Application to \b tear-down interface-related data * \note This callback should be used by Application to \b tear-down interface-related data
*/ */
void tusbd_hid_mouse_unmounted_cb(uint8_t coreid); void tud_hid_mouse_unmounted_cb(uint8_t coreid);
/** \brief Callback function that is invoked when an transferring event occurred /** \brief Callback function that is invoked when an transferring event occurred
* after invoking \ref tusbd_hid_mouse_send * after invoking \ref tusbd_hid_mouse_send
@ -186,7 +186,7 @@ void tusbd_hid_mouse_unmounted_cb(uint8_t coreid);
* - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error. * - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error.
* - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device. * - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device.
*/ */
void tusbd_hid_mouse_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_bytes); void tud_hid_mouse_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_bytes);
/** \brief Callback function that is invoked when USB host request \ref HID_REQUEST_CONTROL_GET_REPORT /** \brief Callback function that is invoked when USB host request \ref HID_REQUEST_CONTROL_GET_REPORT
* via control endpoint. * via control endpoint.
@ -200,7 +200,7 @@ void tusbd_hid_mouse_cb(uint8_t coreid, tusb_event_t event, uint32_t xferred_byt
* \note After this callback, the request is silently executed by the tinyusb stack, thus * \note After this callback, the request is silently executed by the tinyusb stack, thus
* the completion of this control request will not be reported to application * the completion of this control request will not be reported to application
*/ */
uint16_t tusbd_hid_mouse_get_report_cb(uint8_t coreid, hid_request_report_type_t report_type, void** pp_report, uint16_t requested_length); uint16_t tud_hid_mouse_get_report_cb(uint8_t coreid, hid_request_report_type_t report_type, void** pp_report, uint16_t requested_length);
/** \brief Callback function that is invoked when USB host request \ref HID_REQUEST_CONTROL_SET_REPORT /** \brief Callback function that is invoked when USB host request \ref HID_REQUEST_CONTROL_SET_REPORT
* via control endpoint. * via control endpoint.
@ -211,7 +211,7 @@ uint16_t tusbd_hid_mouse_get_report_cb(uint8_t coreid, hid_request_report_type_t
* \note By the time this callback is invoked, the USB control transfer is already completed in the hardware side. * \note By the time this callback is invoked, the USB control transfer is already completed in the hardware side.
* Application are free to handle data at its own will. * Application are free to handle data at its own will.
*/ */
void tusbd_hid_mouse_set_report_cb(uint8_t coreid, hid_request_report_type_t report_type, uint8_t p_report_data[], uint16_t length); void tud_hid_mouse_set_report_cb(uint8_t coreid, hid_request_report_type_t report_type, uint8_t p_report_data[], uint16_t length);
/** @} */ /** @} */
/** @} */ /** @} */

View File

@ -82,7 +82,7 @@ void mscd_init(void)
void mscd_close(uint8_t coreid) void mscd_close(uint8_t coreid)
{ {
memclr_(&mscd_data, sizeof(mscd_interface_t)); memclr_(&mscd_data, sizeof(mscd_interface_t));
tusbd_msc_unmounted_cb(coreid); tud_msc_unmounted_cb(coreid);
} }
tusb_error_t mscd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length) tusb_error_t mscd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length)
@ -112,7 +112,7 @@ tusb_error_t mscd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_int
(*p_length) += sizeof(tusb_descriptor_interface_t) + 2*sizeof(tusb_descriptor_endpoint_t); (*p_length) += sizeof(tusb_descriptor_interface_t) + 2*sizeof(tusb_descriptor_endpoint_t);
tusbd_msc_mounted_cb(coreid); tud_msc_mounted_cb(coreid);
//------------- Queue Endpoint OUT for Command Block Wrapper -------------// //------------- Queue Endpoint OUT for Command Block Wrapper -------------//
ASSERT_STATUS( dcd_pipe_xfer(p_msc->edpt_out, (uint8_t*) &p_msc->cbw, sizeof(msc_cmd_block_wrapper_t), true) ); ASSERT_STATUS( dcd_pipe_xfer(p_msc->edpt_out, (uint8_t*) &p_msc->cbw, sizeof(msc_cmd_block_wrapper_t), true) );
@ -177,7 +177,7 @@ tusb_error_t mscd_xfer_cb(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32
// TODO SCSI data out transfer is not yet supported // TODO SCSI data out transfer is not yet supported
ASSERT_FALSE( p_cbw->xfer_bytes > 0 && !BIT_TEST_(p_cbw->dir, 7), TUSB_ERROR_NOT_SUPPORTED_YET); ASSERT_FALSE( p_cbw->xfer_bytes > 0 && !BIT_TEST_(p_cbw->dir, 7), TUSB_ERROR_NOT_SUPPORTED_YET);
p_csw->status = tusbd_msc_scsi_cb(edpt_hdl.coreid, p_cbw->lun, p_cbw->command, &p_buffer, &actual_length); p_csw->status = tud_msc_scsi_cb(edpt_hdl.coreid, p_cbw->lun, p_cbw->command, &p_buffer, &actual_length);
//------------- Data Phase (non READ10, WRITE10) -------------// //------------- Data Phase (non READ10, WRITE10) -------------//
if ( p_cbw->xfer_bytes ) if ( p_cbw->xfer_bytes )
@ -233,8 +233,8 @@ static bool read10_write10_data_xfer(mscd_interface_t* p_msc)
uint16_t const block_count = __be2n_16(p_readwrite->block_count); uint16_t const block_count = __be2n_16(p_readwrite->block_count);
void *p_buffer = NULL; void *p_buffer = NULL;
uint16_t xferred_block = (SCSI_CMD_READ_10 == p_cbw->command[0]) ? tusbd_msc_read10_cb (edpt_hdl.coreid, p_cbw->lun, &p_buffer, lba, block_count) : uint16_t xferred_block = (SCSI_CMD_READ_10 == p_cbw->command[0]) ? tud_msc_read10_cb (edpt_hdl.coreid, p_cbw->lun, &p_buffer, lba, block_count) :
tusbd_msc_write10_cb(edpt_hdl.coreid, p_cbw->lun, &p_buffer, lba, block_count); tud_msc_write10_cb(edpt_hdl.coreid, p_cbw->lun, &p_buffer, lba, block_count);
xferred_block = min16_of(xferred_block, block_count); xferred_block = min16_of(xferred_block, block_count);
uint16_t const xferred_byte = xferred_block * (p_cbw->xfer_bytes / block_count); uint16_t const xferred_byte = xferred_block * (p_cbw->xfer_bytes / block_count);

View File

@ -63,13 +63,13 @@
* \param[in] coreid USB Controller ID of the interface * \param[in] coreid USB Controller ID of the interface
* \note This callback should be used by Application to \b set-up interface-related data * \note This callback should be used by Application to \b set-up interface-related data
*/ */
void tusbd_msc_mounted_cb(uint8_t coreid); void tud_msc_mounted_cb(uint8_t coreid);
/** \brief Callback function that will be invoked when this interface is unmounted (bus reset/unplugged) /** \brief Callback function that will be invoked when this interface is unmounted (bus reset/unplugged)
* \param[in] coreid USB Controller ID of the interface * \param[in] coreid USB Controller ID of the interface
* \note This callback should be used by Application to \b tear-down interface-related data * \note This callback should be used by Application to \b tear-down interface-related data
*/ */
void tusbd_msc_unmounted_cb(uint8_t coreid); void tud_msc_unmounted_cb(uint8_t coreid);
/** \brief Callback that is invoked when tinyusb stack received \ref SCSI_CMD_READ_10 command from host /** \brief Callback that is invoked when tinyusb stack received \ref SCSI_CMD_READ_10 command from host
* \param[in] coreid USB Controller ID * \param[in] coreid USB Controller ID
@ -87,7 +87,7 @@ void tusbd_msc_unmounted_cb(uint8_t coreid);
* \n\n Although this callback is called by tinyusb device task (non-isr context), however as all the classes share * \n\n Although this callback is called by tinyusb device task (non-isr context), however as all the classes share
* the same task (to save resource), any delay in this callback will cause delay in reponse on other classes. * the same task (to save resource), any delay in this callback will cause delay in reponse on other classes.
*/ */
uint16_t tusbd_msc_read10_cb (uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count); uint16_t tud_msc_read10_cb (uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count);
/** \brief Callback that is invoked when tinyusb stack received \ref SCSI_CMD_WRITE_10 command from host /** \brief Callback that is invoked when tinyusb stack received \ref SCSI_CMD_WRITE_10 command from host
* \param[in] coreid USB Controller ID * \param[in] coreid USB Controller ID
@ -105,7 +105,7 @@ uint16_t tusbd_msc_read10_cb (uint8_t coreid, uint8_t lun, void** pp_buffer, uin
* \n\n Although this callback is called by tinyusb device task (non-isr context), however as all the classes share * \n\n Although this callback is called by tinyusb device task (non-isr context), however as all the classes share
* the same task (to save resource), any delay in this callback will cause delay in reponse on other classes. * the same task (to save resource), any delay in this callback will cause delay in reponse on other classes.
*/ */
uint16_t tusbd_msc_write10_cb(uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count); uint16_t tud_msc_write10_cb(uint8_t coreid, uint8_t lun, void** pp_buffer, uint32_t lba, uint16_t block_count);
// p_length [in,out] allocated/maximum length, application update with actual length // p_length [in,out] allocated/maximum length, application update with actual length
/** \brief Callback that is invoked when tinyusb stack received an SCSI command other than \ref SCSI_CMD_WRITE_10 and /** \brief Callback that is invoked when tinyusb stack received an SCSI command other than \ref SCSI_CMD_WRITE_10 and
@ -122,7 +122,7 @@ uint16_t tusbd_msc_write10_cb(uint8_t coreid, uint8_t lun, void** pp_buffer, uin
* \note Although this callback is called by tinyusb device task (non-isr context), however as all the classes share * \note Although this callback is called by tinyusb device task (non-isr context), however as all the classes share
* the same task (to save resource), any delay in this callback will cause delay in reponse on other classes. * the same task (to save resource), any delay in this callback will cause delay in reponse on other classes.
*/ */
msc_csw_status_t tusbd_msc_scsi_cb (uint8_t coreid, uint8_t lun, uint8_t scsi_cmd[16], void const ** pp_buffer, uint16_t* p_length); msc_csw_status_t tud_msc_scsi_cb (uint8_t coreid, uint8_t lun, uint8_t scsi_cmd[16], void const ** pp_buffer, uint16_t* p_length);
/** @} */ /** @} */
/** @} */ /** @} */

View File

@ -102,7 +102,7 @@ static tusb_error_t get_descriptor(uint8_t coreid, tusb_control_request_t const
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// APPLICATION INTERFACE // APPLICATION INTERFACE
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
bool tusbd_is_configured(uint8_t coreid) bool tud_configured(uint8_t coreid)
{ {
return usbd_devices[coreid].state == TUSB_DEVICE_STATE_CONFIGURED; return usbd_devices[coreid].state == TUSB_DEVICE_STATE_CONFIGURED;
} }

View File

@ -91,8 +91,8 @@ typedef struct {
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// APPLICATION API // APPLICATION API
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
bool tusbd_is_configured(uint8_t coreid) ATTR_WARN_UNUSED_RESULT; bool tud_configured(uint8_t coreid);
//void tusbd_device_suspended_cb(uint8_t coreid); //void tud_device_suspended_cb(uint8_t coreid);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// CLASS-USBD & INTERNAL API // CLASS-USBD & INTERNAL API