summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorhathach <[email protected]>2014-03-31 11:59:43 +0700
committerhathach <[email protected]>2014-03-31 11:59:43 +0700
commit6682720b2aecb777d8f8aceedbd49aaff4fbbc27 (patch)
tree9fcb36a06d168b31b0027affdcb8265560b33a79 /demos
parent0bb2cc64b0e1248bfc8e564755a0850b5e5ad762 (diff)
implement & document all the device class _mounted_cb & _unmounted_cb callbacks
Diffstat (limited to 'demos')
-rw-r--r--demos/device/src/cdc_device_app.c30
-rw-r--r--demos/device/src/mouse_device_app.c6
-rw-r--r--demos/device/src/msc_device_app.c10
-rw-r--r--demos/device/src/tusb_config.h4
4 files changed, 35 insertions, 15 deletions
diff --git a/demos/device/src/cdc_device_app.c b/demos/device/src/cdc_device_app.c
index 543f30b1c..572db4b0c 100644
--- a/demos/device/src/cdc_device_app.c
+++ b/demos/device/src/cdc_device_app.c
@@ -58,30 +58,27 @@ OSAL_SEM_DEF(cdcd_semaphore);
static osal_semaphore_handle_t sem_hdl;
-TUSB_CFG_ATTR_USBRAM static uint8_t serial_rx_buffer[CDCD_APP_BUFFER_SIZE];
-TUSB_CFG_ATTR_USBRAM static uint8_t serial_tx_buffer[CDCD_APP_BUFFER_SIZE];
-
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
+TUSB_CFG_ATTR_USBRAM static uint8_t serial_rx_buffer[CDCD_APP_BUFFER_SIZE];
+TUSB_CFG_ATTR_USBRAM static uint8_t serial_tx_buffer[CDCD_APP_BUFFER_SIZE];
+
FIFO_DEF(fifo_serial, CDCD_APP_BUFFER_SIZE, uint8_t, true);
//--------------------------------------------------------------------+
-// IMPLEMENTATION
+// tinyusb Callbacks
//--------------------------------------------------------------------+
-void cdcd_serial_app_init(void)
+void tusbd_cdc_mounted_cb(uint8_t coreid)
{
- sem_hdl = osal_semaphore_create( OSAL_SEM_REF(cdcd_semaphore) );
- ASSERT_PTR( sem_hdl, VOID_RETURN);
+ osal_semaphore_reset(sem_hdl);
- ASSERT( TUSB_ERROR_NONE == osal_task_create( OSAL_TASK_REF(cdcd_serial_app_task) ), VOID_RETURN);
+ tusbd_cdc_receive(coreid, serial_rx_buffer, CDCD_APP_BUFFER_SIZE, true);
}
-void tusbd_cdc_mounted_cb(uint8_t coreid)
+void tusbd_cdc_unmounted_cb(uint8_t coreid)
{
- osal_semaphore_reset(sem_hdl);
- tusbd_cdc_receive(coreid, serial_rx_buffer, CDCD_APP_BUFFER_SIZE, true);
}
void tusbd_cdc_xfer_cb(uint8_t coreid, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes)
@@ -116,6 +113,17 @@ void tusbd_cdc_xfer_cb(uint8_t coreid, tusb_event_t event, cdc_pipeid_t pipe_id,
}
}
+//--------------------------------------------------------------------+
+// APPLICATION CODE
+//--------------------------------------------------------------------+
+void cdcd_serial_app_init(void)
+{
+ sem_hdl = osal_semaphore_create( OSAL_SEM_REF(cdcd_semaphore) );
+ ASSERT_PTR( sem_hdl, VOID_RETURN);
+
+ ASSERT( TUSB_ERROR_NONE == osal_task_create( OSAL_TASK_REF(cdcd_serial_app_task) ), VOID_RETURN);
+}
+
OSAL_TASK_FUNCTION( cdcd_serial_app_task , p_task_para)
{
OSAL_TASK_LOOP_BEGIN
diff --git a/demos/device/src/mouse_device_app.c b/demos/device/src/mouse_device_app.c
index 982a4829c..f38e4f062 100644
--- a/demos/device/src/mouse_device_app.c
+++ b/demos/device/src/mouse_device_app.c
@@ -1,4 +1,4 @@
-/**************************************************************************/
+ /**************************************************************************/
/*!
@file mouse_device_app.c
@author hathach (tinyusb.org)
@@ -42,6 +42,7 @@
//--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+
+#include "app_os_prio.h"
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
@@ -50,7 +51,7 @@
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
-OSAL_TASK_DEF(mouse_device_app_task, 128, MOUSED_APP_TASK_PRIO);
+OSAL_TASK_DEF(mouse_device_app_task, 128, MOUSE_APP_TASK_PRIO);
TUSB_CFG_ATTR_USBRAM hid_mouse_report_t mouse_report;
@@ -90,6 +91,7 @@ void tusbd_hid_mouse_set_report_cb(uint8_t coreid, hid_request_report_type_t rep
{
// mouse demo does not support set report --> do nothing
}
+
//--------------------------------------------------------------------+
// APPLICATION CODE
//--------------------------------------------------------------------+
diff --git a/demos/device/src/msc_device_app.c b/demos/device/src/msc_device_app.c
index c6c12eab6..cc4063c80 100644
--- a/demos/device/src/msc_device_app.c
+++ b/demos/device/src/msc_device_app.c
@@ -93,6 +93,16 @@ static scsi_mode_parameters_t const msc_dev_mode_para =
//--------------------------------------------------------------------+
// tinyusb callback (ISR context)
//--------------------------------------------------------------------+
+void tusbd_msc_mounted_cb(uint8_t coreid)
+{
+
+}
+
+void tusbd_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)
{
// read10 & write10 has their own callback and MUST not be handled here
diff --git a/demos/device/src/tusb_config.h b/demos/device/src/tusb_config.h
index 23c2dfd23..c21caaade 100644
--- a/demos/device/src/tusb_config.h
+++ b/demos/device/src/tusb_config.h
@@ -59,10 +59,10 @@
//------------- CLASS -------------//
#define TUSB_CFG_DEVICE_HID_KEYBOARD 1
-#define TUSB_CFG_DEVICE_HID_MOUSE 0
+#define TUSB_CFG_DEVICE_HID_MOUSE 1
#define TUSB_CFG_DEVICE_HID_GENERIC 0 // not supported yet
#define TUSB_CFG_DEVICE_MSC 1
-#define TUSB_CFG_DEVICE_CDC 0
+#define TUSB_CFG_DEVICE_CDC 1
//--------------------------------------------------------------------+
// COMMON CONFIGURATION