diff options
| author | hathach <[email protected]> | 2018-12-13 15:20:28 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-12-13 15:20:28 +0700 |
| commit | 07bcc6ca911d342c228b691cbe966aec377de891 (patch) | |
| tree | 1890f0be5269ca555a00f72809edc0544f5f5fe8 /examples/obsolete/device/src | |
| parent | a6b943260060224cdffe0d55d50fb4e377b65392 (diff) | |
clean up files
Diffstat (limited to 'examples/obsolete/device/src')
| -rw-r--r-- | examples/obsolete/device/src/WinCDCdriver.inf | 106 | ||||
| -rw-r--r-- | examples/obsolete/device/src/app_os_prio.h | 71 | ||||
| -rw-r--r-- | examples/obsolete/device/src/cdc_device_app.c | 111 | ||||
| -rw-r--r-- | examples/obsolete/device/src/cdc_device_app.h | 80 | ||||
| -rw-r--r-- | examples/obsolete/device/src/keyboard_device_app.c | 153 | ||||
| -rw-r--r-- | examples/obsolete/device/src/keyboard_device_app.h | 79 | ||||
| -rw-r--r-- | examples/obsolete/device/src/main.c | 205 | ||||
| -rw-r--r-- | examples/obsolete/device/src/mouse_device_app.c | 153 | ||||
| -rw-r--r-- | examples/obsolete/device/src/mouse_device_app.h | 78 | ||||
| -rw-r--r-- | examples/obsolete/device/src/msc_device_app.c | 129 | ||||
| -rw-r--r-- | examples/obsolete/device/src/msc_device_app.h | 93 | ||||
| -rw-r--r-- | examples/obsolete/device/src/msc_device_ramdisk.c | 114 | ||||
| -rw-r--r-- | examples/obsolete/device/src/msc_device_romdisk.c | 119 | ||||
| -rw-r--r-- | examples/obsolete/device/src/tusb_config.h | 144 | ||||
| -rw-r--r-- | examples/obsolete/device/src/tusb_descriptors.c | 100 |
15 files changed, 0 insertions, 1735 deletions
diff --git a/examples/obsolete/device/src/WinCDCdriver.inf b/examples/obsolete/device/src/WinCDCdriver.inf deleted file mode 100644 index b2ef6ba90..000000000 --- a/examples/obsolete/device/src/WinCDCdriver.inf +++ /dev/null @@ -1,106 +0,0 @@ -;************************************************************ -; Windows USB CDC ACM Setup File -; Copyright (c) 2000 Microsoft Corporation - - -[Version] -Signature="$Windows NT$" -Class=Ports -ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} -Provider=%MFGNAME% -LayoutFile=layout.inf -CatalogFile=%MFGFILENAME%.cat -DriverVer=11/15/2007,5.1.2600.0 - -[Manufacturer] -%MFGNAME%=DeviceList, NTamd64 - -[DestinationDirs] -DefaultDestDir=12 - - -;------------------------------------------------------------------------------ -; Windows 2000/XP/Vista-32bit Sections -;------------------------------------------------------------------------------ - -[DriverInstall.nt] -include=mdmcpq.inf -CopyFiles=DriverCopyFiles.nt -AddReg=DriverInstall.nt.AddReg - -[DriverCopyFiles.nt] -usbser.sys,,,0x20 - -[DriverInstall.nt.AddReg] -HKR,,DevLoader,,*ntkern -HKR,,NTMPDriver,,%DRIVERFILENAME%.sys -HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" - -[DriverInstall.nt.Services] -AddService=usbser, 0x00000002, DriverService.nt - -[DriverService.nt] -DisplayName=%SERVICE% -ServiceType=1 -StartType=3 -ErrorControl=1 -ServiceBinary=%12%\%DRIVERFILENAME%.sys - -;------------------------------------------------------------------------------ -; Vista-64bit Sections -;------------------------------------------------------------------------------ - -[DriverInstall.NTamd64] -include=mdmcpq.inf -CopyFiles=DriverCopyFiles.NTamd64 -AddReg=DriverInstall.NTamd64.AddReg - -[DriverCopyFiles.NTamd64] -%DRIVERFILENAME%.sys,,,0x20 - -[DriverInstall.NTamd64.AddReg] -HKR,,DevLoader,,*ntkern -HKR,,NTMPDriver,,%DRIVERFILENAME%.sys -HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" - -[DriverInstall.NTamd64.Services] -AddService=usbser, 0x00000002, DriverService.NTamd64 - -[DriverService.NTamd64] -DisplayName=%SERVICE% -ServiceType=1 -StartType=3 -ErrorControl=1 -ServiceBinary=%12%\%DRIVERFILENAME%.sys - - -;------------------------------------------------------------------------------ -; Vendor and Product ID Definitions -;------------------------------------------------------------------------------ -; When developing your USB device, the VID and PID used in the PC side -; application program and the firmware on the microcontroller must match. -; Modify the below line to use your VID and PID. Use the format as shown below. -; Note: One INF file can be used for multiple devices with different VID and PIDs. -; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. -;------------------------------------------------------------------------------ -[SourceDisksFiles] -[SourceDisksNames] -[DeviceList] -%DESCRIPTION%=DriverInstall, USB\VID_CAFE&PID_4001&MI_00, USB\VID_CAFE&PID_4003&MI_00, USB\VID_CAFE&PID_4005&MI_00, USB\VID_CAFE&PID_4007&MI_00, USB\VID_CAFE&PID_4009&MI_00, USB\VID_CAFE&PID_400b&MI_00, USB\VID_CAFE&PID_400d&MI_00, USB\VID_CAFE&PID_400f&MI_00, USB\VID_CAFE&PID_4011&MI_00, USB\VID_CAFE&PID_4013&MI_00, USB\VID_CAFE&PID_4015&MI_00, USB\VID_CAFE&PID_4017&MI_00, USB\VID_CAFE&PID_4019&MI_00, USB\VID_CAFE&PID_401b&MI_00, USB\VID_CAFE&PID_401d&MI_00, USB\VID_CAFE&PID_401f&MI_00, USB\VID_CAFE&PID_4021&MI_00, USB\VID_CAFE&PID_4023&MI_00, USB\VID_CAFE&PID_4025&MI_00, USB\VID_CAFE&PID_4027&MI_00, USB\VID_CAFE&PID_4029&MI_00, USB\VID_CAFE&PID_402b&MI_00, USB\VID_CAFE&PID_402d&MI_00, USB\VID_CAFE&PID_402f&MI_00, USB\VID_CAFE&PID_4031&MI_00, USB\VID_CAFE&PID_4033&MI_00, USB\VID_CAFE&PID_4035&MI_00, USB\VID_CAFE&PID_4037&MI_00, USB\VID_CAFE&PID_4039&MI_00, USB\VID_CAFE&PID_403b&MI_00, USB\VID_CAFE&PID_403d&MI_00, USB\VID_CAFE&PID_403f&MI_00 - - -[DeviceList.NTamd64] -%DESCRIPTION%=DriverInstall, USB\VID_CAFE&PID_4001&MI_00, USB\VID_CAFE&PID_4003&MI_00, USB\VID_CAFE&PID_4005&MI_00, USB\VID_CAFE&PID_4007&MI_00, USB\VID_CAFE&PID_4009&MI_00, USB\VID_CAFE&PID_400b&MI_00, USB\VID_CAFE&PID_400d&MI_00, USB\VID_CAFE&PID_400f&MI_00, USB\VID_CAFE&PID_4011&MI_00, USB\VID_CAFE&PID_4013&MI_00, USB\VID_CAFE&PID_4015&MI_00, USB\VID_CAFE&PID_4017&MI_00, USB\VID_CAFE&PID_4019&MI_00, USB\VID_CAFE&PID_401b&MI_00, USB\VID_CAFE&PID_401d&MI_00, USB\VID_CAFE&PID_401f&MI_00, USB\VID_CAFE&PID_4021&MI_00, USB\VID_CAFE&PID_4023&MI_00, USB\VID_CAFE&PID_4025&MI_00, USB\VID_CAFE&PID_4027&MI_00, USB\VID_CAFE&PID_4029&MI_00, USB\VID_CAFE&PID_402b&MI_00, USB\VID_CAFE&PID_402d&MI_00, USB\VID_CAFE&PID_402f&MI_00, USB\VID_CAFE&PID_4031&MI_00, USB\VID_CAFE&PID_4033&MI_00, USB\VID_CAFE&PID_4035&MI_00, USB\VID_CAFE&PID_4037&MI_00, USB\VID_CAFE&PID_4039&MI_00, USB\VID_CAFE&PID_403b&MI_00, USB\VID_CAFE&PID_403d&MI_00, USB\VID_CAFE&PID_403f&MI_00 - -;------------------------------------------------------------------------------ -; String Definitions -;------------------------------------------------------------------------------ -;Modify these strings to customize your device -;------------------------------------------------------------------------------ -[Strings] -MFGFILENAME="CDC_vista" -DRIVERFILENAME ="usbser" -MFGNAME="tinyusb.org" -INSTDISK="tinyusb CDC driver" -DESCRIPTION="tinyusb Serial Port" -SERVICE="USB RS-232 Emulation Driver"
\ No newline at end of file diff --git a/examples/obsolete/device/src/app_os_prio.h b/examples/obsolete/device/src/app_os_prio.h deleted file mode 100644 index 4f7fea2ce..000000000 --- a/examples/obsolete/device/src/app_os_prio.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************/ -/*! - @file app_os_prio.h - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -#ifndef _TUSB_APP_OS_PRIO_H_ -#define _TUSB_APP_OS_PRIO_H_ - - -#ifdef __cplusplus - extern "C" { -#endif - -#include "tusb.h" - -#if CFG_TUSB_OS == OPT_OS_NONE - #define LOWER_PRIO(x) 0 // does not matter -#elif CFG_TUSB_OS == OPT_OS_FREERTOS - #define LOWER_PRIO(x) ((x)-1) // freeRTOS lower number --> lower priority -#else - #error Priority is not configured for this RTOS -#endif - -enum { - STANDARD_APP_TASK_PRIO = LOWER_PRIO(CFG_TUD_TASK_PRIO), // Application Task is lower than usb system task - LED_BLINKING_APP_TASK_PRIO = LOWER_PRIO(STANDARD_APP_TASK_PRIO), // Blinking task is lower than normal task - - KEYBOARD_APP_TASK_PRIO = STANDARD_APP_TASK_PRIO, - MOUSE_APP_TASK_PRIO = STANDARD_APP_TASK_PRIO, - CDC_SERIAL_APP_TASK_PRIO = STANDARD_APP_TASK_PRIO, - MSC_APP_TASK_PRIO = STANDARD_APP_TASK_PRIO -}; - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_APP_OS_PRIO_H_ */ diff --git a/examples/obsolete/device/src/cdc_device_app.c b/examples/obsolete/device/src/cdc_device_app.c deleted file mode 100644 index 7989d86ab..000000000 --- a/examples/obsolete/device/src/cdc_device_app.c +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************/ -/*! - @file cdc_device_app.c - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -#include "cdc_device_app.h" - -#if CFG_TUD_CDC - -#include "common/tusb_fifo.h" // TODO refractor -#include "app_os_prio.h" - -//--------------------------------------------------------------------+ -// MACRO CONSTANT TYPEDEF -//--------------------------------------------------------------------+ -enum { SERIAL_BUFFER_SIZE = 64 }; - -//--------------------------------------------------------------------+ -// INTERNAL OBJECT & FUNCTION DECLARATION -//--------------------------------------------------------------------+ -void cdc_serial_app_task(void* param); - -OSAL_TASK_DEF(cdc_task_def, "blinky", cdc_serial_app_task, CDC_SERIAL_APP_TASK_PRIO, 128); - -//--------------------------------------------------------------------+ -// tinyusb callbacks -//--------------------------------------------------------------------+ -void cdc_serial_app_mount(uint8_t rhport) -{ -} - -void cdc_serial_app_umount(uint8_t rhport) -{ - -} - -void tud_cdc_rx_cb(uint8_t itf) -{ - -} - -//--------------------------------------------------------------------+ -// APPLICATION CODE -//--------------------------------------------------------------------+ -void cdc_serial_app_init(void) -{ - osal_task_create(&cdc_task_def); -} - -tusb_error_t cdc_serial_subtask(void); - -void cdc_serial_app_task(void* param) -{ - (void) param; - - OSAL_TASK_BEGIN - cdc_serial_subtask(); - OSAL_TASK_END -} - -tusb_error_t cdc_serial_subtask(void) -{ - OSAL_SUBTASK_BEGIN - - if ( tud_mounted() && tud_cdc_available() ) - { - uint8_t buf[64]; - - // read and echo back - uint32_t count = tud_cdc_read(buf, sizeof(buf)); - - tud_cdc_write(buf, count); - } - - OSAL_SUBTASK_END -} - -#endif diff --git a/examples/obsolete/device/src/cdc_device_app.h b/examples/obsolete/device/src/cdc_device_app.h deleted file mode 100644 index 71b4bdf28..000000000 --- a/examples/obsolete/device/src/cdc_device_app.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************/ -/*! - @file cdc_device_app.h - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -/** \ingroup TBD - * \defgroup TBD - * \brief TBD - * - * @{ - */ - -#ifndef _TUSB_CDCD_DEVICE_APP_H_ -#define _TUSB_CDCD_DEVICE_APP_H_ - -#include "bsp/board.h" -#include "tusb.h" - -#ifdef __cplusplus - extern "C" { -#endif - -#if CFG_TUD_CDC - -void cdc_serial_app_init(void); -void cdc_serial_app_task(void* param); - -void cdc_serial_app_mount(uint8_t rhport); -void cdc_serial_app_umount(uint8_t rhport); - -#else - -#define cdc_serial_app_init() -#define cdc_serial_app_task(x) -#define cdc_serial_app_mount(x) -#define cdc_serial_app_umount(x) - -#endif - - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_CDCD_DEVICE_APP_H_ */ - -/** @} */ diff --git a/examples/obsolete/device/src/keyboard_device_app.c b/examples/obsolete/device/src/keyboard_device_app.c deleted file mode 100644 index 5e14c56c9..000000000 --- a/examples/obsolete/device/src/keyboard_device_app.c +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************/ -/*! - @file keyboard_device_app.c - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -#include "keyboard_device_app.h" - -#if CFG_TUD_HID_KEYBOARD -//--------------------------------------------------------------------+ -// INCLUDE -//--------------------------------------------------------------------+ -#include "app_os_prio.h" - -//--------------------------------------------------------------------+ -// MACRO CONSTANT TYPEDEF -//--------------------------------------------------------------------+ - -//--------------------------------------------------------------------+ -// INTERNAL OBJECT & FUNCTION DECLARATION -//--------------------------------------------------------------------+ -CFG_TUSB_MEM_SECTION hid_keyboard_report_t keyboard_report; - -//--------------------------------------------------------------------+ -// tinyusb callbacks -//--------------------------------------------------------------------+ -void keyboard_app_mount(uint8_t rhport) -{ - -} - -void keyboard_app_umount(uint8_t rhport) -{ - -} - -void tud_hid_keyboard_cb(uint8_t rhport, xfer_result_t event, uint32_t xferred_bytes) -{ - switch(event) - { - case XFER_RESULT_SUCCESS: - case XFER_RESULT_FAILED: - case XFER_RESULT_STALLED: - default: break; - } -} - -uint16_t tud_hid_keyboard_get_report_cb(hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) -{ - // get other than input report is not supported by this keyboard demo - if ( report_type != HID_REPORT_TYPE_INPUT ) return 0; - - memcpy(buffer, &keyboard_report, reqlen); - return reqlen; -} - -void tud_hid_keyboard_set_report_cb(hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) -{ - // set other than output report is not supported by this keyboard demo - if ( report_type != HID_REPORT_TYPE_OUTPUT ) return; - - uint8_t kbd_led = buffer[0]; - uint32_t interval_divider = 1; // each LED will reduce blinking interval by a half - - if (kbd_led & KEYBOARD_LED_NUMLOCK ) interval_divider *= 2; - if (kbd_led & KEYBOARD_LED_CAPSLOCK ) interval_divider *= 2; - if (kbd_led & KEYBOARD_LED_SCROLLLOCK) interval_divider *= 2; - - // TODO remove - extern void led_blinking_set_interval(uint32_t ms); - led_blinking_set_interval( 1000 / interval_divider); -} - -//--------------------------------------------------------------------+ -// APPLICATION CODE -//--------------------------------------------------------------------+ -void keyboard_app_init(void) -{ - osal_task_create(keyboard_app_task, "kbd", 128, NULL, KEYBOARD_APP_TASK_PRIO); -} - -tusb_error_t keyboard_device_subtask(void); - -void keyboard_app_task(void* param) -{ - (void) param; - - OSAL_TASK_BEGIN - keyboard_device_subtask(); - OSAL_TASK_END -} - -tusb_error_t keyboard_device_subtask(void) -{ - OSAL_SUBTASK_BEGIN - - osal_task_delay(50); - - if ( tud_mounted() && tud_hid_keyboard_ready(0) ) - { - static uint32_t button_mask = 0; - uint32_t new_button_mask = board_buttons(); - - //------------- button pressed -------------// - if (button_mask != new_button_mask) - { - button_mask = new_button_mask; - - for (uint8_t i=0; i<6; i++) - { // demo support up to 6 buttons, button0 = 'a', button1 = 'b', etc ... - keyboard_report.keycode[i] = BIT_TEST_(button_mask, i) ? (0x04+i) : 0; - } - - tud_hid_keyboard_send(0, &keyboard_report ); - } - } - - OSAL_SUBTASK_END -} - -#endif diff --git a/examples/obsolete/device/src/keyboard_device_app.h b/examples/obsolete/device/src/keyboard_device_app.h deleted file mode 100644 index 45c843876..000000000 --- a/examples/obsolete/device/src/keyboard_device_app.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************/ -/*! - @file keyboard_device_app.h - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -/** \ingroup TBD - * \defgroup TBD - * \brief TBD - * - * @{ - */ - -#ifndef _TUSB_KEYBOARDD_DEVICE_APP_H_ -#define _TUSB_KEYBOARDD_DEVICE_APP_H_ - -#include "bsp/board.h" -#include "tusb.h" - -#ifdef __cplusplus - extern "C" { -#endif - -#if CFG_TUD_HID_KEYBOARD - -void keyboard_app_init(void); -void keyboard_app_task(void* param); - -void keyboard_app_mount(uint8_t rhport); -void keyboard_app_umount(uint8_t rhport); - -#else - -#define keyboard_app_init() -#define keyboard_app_task(x) -#define keyboard_app_mount(x) -#define keyboard_app_umount(x) - -#endif - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_KEYBOARDD_DEVICE_APP_H_ */ - -/** @} */ diff --git a/examples/obsolete/device/src/main.c b/examples/obsolete/device/src/main.c deleted file mode 100644 index 7de6fd32b..000000000 --- a/examples/obsolete/device/src/main.c +++ /dev/null @@ -1,205 +0,0 @@ -/**************************************************************************/ -/*! - @file main.c - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -//--------------------------------------------------------------------+ -// INCLUDE -//--------------------------------------------------------------------+ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "bsp/board.h" -#include "app_os_prio.h" -#include "tusb.h" - -#include "msc_device_app.h" -#include "keyboard_device_app.h" -#include "mouse_device_app.h" -#include "cdc_device_app.h" - -//--------------------------------------------------------------------+ -// MACRO CONSTANT TYPEDEF -//--------------------------------------------------------------------+ - -//--------------------------------------------------------------------+ -// INTERNAL OBJECT & FUNCTION DECLARATION -//--------------------------------------------------------------------+ -void print_greeting(void); -void led_blinking_init(void); -void led_blinking_task(void* param); - - -#if CFG_TUSB_OS == OPT_OS_NONE -// like a real RTOS, this function is a main loop invoking each task in application and never return -void os_none_start_scheduler(void) -{ - while (1) - { - tusb_task(); - led_blinking_task(NULL); - - msc_app_task(NULL); - keyboard_app_task(NULL); - mouse_app_task(NULL); - cdc_serial_app_task(NULL); - } -} -#endif - -int main(void) -{ - board_init(); - print_greeting(); - - tusb_init(); - - //------------- application task init -------------// - led_blinking_init(); - - msc_app_init(); - keyboard_app_init(); - mouse_app_init(); - cdc_serial_app_init(); - - //------------- start OS scheduler (never return) -------------// -#if CFG_TUSB_OS == OPT_OS_FREERTOS - vTaskStartScheduler(); -#elif CFG_TUSB_OS == OPT_OS_NONE - os_none_start_scheduler(); -#else - #error need to start RTOS schduler -#endif - - return 0; -} - -//--------------------------------------------------------------------+ -// tinyusb callbacks -//--------------------------------------------------------------------+ -void tud_mount_cb(void) -{ - uint8_t rhport = 0; // TODO remove - cdc_serial_app_mount(rhport); - keyboard_app_mount(rhport); - msc_app_mount(rhport); -} - -void tud_umount_cb(void) -{ - uint8_t rhport = 0; // TODO remove - cdc_serial_app_umount(rhport); - keyboard_app_umount(rhport); - msc_app_umount(rhport); -} - -//--------------------------------------------------------------------+ -// BLINKING TASK -//--------------------------------------------------------------------+ -OSAL_TASK_DEF(blink_task_def, "blinky", led_blinking_task, LED_BLINKING_APP_TASK_PRIO, 128); - -static uint32_t led_blink_interval_ms = 1000; // default is 1 second - -void led_blinking_init(void) -{ - led_blink_interval_ms = 1000; - osal_task_create(&blink_task_def); -} - -void led_blinking_set_interval(uint32_t ms) -{ - led_blink_interval_ms = ms; -} - -tusb_error_t led_blinking_subtask(void); -void led_blinking_task(void* param) -{ - (void) param; - - OSAL_TASK_BEGIN - led_blinking_subtask(); - OSAL_TASK_END -} - -tusb_error_t led_blinking_subtask(void) -{ - OSAL_SUBTASK_BEGIN - - static bool led_state = false; - - osal_task_delay(led_blink_interval_ms); - - board_led_control(led_state); - led_state = 1 - led_state; // toggle - -// uint32_t btn_mask; -// btn_mask = board_buttons(); -// -// for(uint8_t i=0; i<32; i++) -// { -// if ( BIT_TEST_(btn_mask, i) ) printf("button %d is pressed\n", i); -// } - - OSAL_SUBTASK_END -} - -//--------------------------------------------------------------------+ -// HELPER FUNCTION -//--------------------------------------------------------------------+ -void print_greeting(void) -{ - char const * const rtos_name[] = - { - [OPT_OS_NONE] = "None", - [OPT_OS_FREERTOS] = "FreeRTOS", - }; - - printf("\n\ ---------------------------------------------------------------------\n\ -- Device Demo (a tinyusb example)\n\ -- if you find any bugs or get any questions, feel free to file an\n\ -- issue at https://github.com/hathach/tinyusb\n\ ---------------------------------------------------------------------\n\n" - ); - - puts("This DEVICE demo is configured to support:"); - printf(" - RTOS = %s\n", rtos_name[CFG_TUSB_OS]); - if (CFG_TUD_HID_MOUSE ) puts(" - HID Mouse"); - if (CFG_TUD_HID_KEYBOARD ) puts(" - HID Keyboard"); - if (CFG_TUD_MSC ) puts(" - Mass Storage"); - if (CFG_TUD_CDC ) puts(" - Communication Device Class"); -} diff --git a/examples/obsolete/device/src/mouse_device_app.c b/examples/obsolete/device/src/mouse_device_app.c deleted file mode 100644 index 6869f1a05..000000000 --- a/examples/obsolete/device/src/mouse_device_app.c +++ /dev/null @@ -1,153 +0,0 @@ - /**************************************************************************/ -/*! - @file mouse_device_app.c - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -#include "mouse_device_app.h" - -#if CFG_TUD_HID_MOUSE -//--------------------------------------------------------------------+ -// INCLUDE -//--------------------------------------------------------------------+ -#include "app_os_prio.h" - -//--------------------------------------------------------------------+ -// MACRO CONSTANT TYPEDEF -//--------------------------------------------------------------------+ - -//--------------------------------------------------------------------+ -// INTERNAL OBJECT & FUNCTION DECLARATION -//--------------------------------------------------------------------+ -CFG_TUSB_MEM_SECTION hid_mouse_report_t mouse_report; - -//--------------------------------------------------------------------+ -// tinyusb callbacks -//--------------------------------------------------------------------+ -void mouse_app_mount(uint8_t rhport) -{ - -} - -void mouse_app_umount(uint8_t rhport) -{ - -} - -void tud_hid_mouse_cb(uint8_t rhport, xfer_result_t event, uint32_t xferred_bytes) -{ - switch(event) - { - case XFER_RESULT_SUCCESS: - case XFER_RESULT_FAILED: - case XFER_RESULT_STALLED: - default: break; - } -} - -uint16_t tud_hid_mouse_get_report_cb(hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) -{ - if ( report_type != HID_REPORT_TYPE_INPUT ) return 0; // not support other report type for this mouse demo - - memcpy(buffer, &mouse_report, reqlen); - return reqlen; -} - -//--------------------------------------------------------------------+ -// APPLICATION CODE -//--------------------------------------------------------------------+ -void mouse_app_init(void) -{ - osal_task_create(mouse_app_task, "mouse", 128, NULL, MOUSE_APP_TASK_PRIO); -} - -void mouse_app_subtask(void); - -void mouse_app_task(void * param) -{ - (void) param; - OSAL_TASK_BEGIN - mouse_app_subtask(); - OSAL_TASK_END -} - -void mouse_app_subtask(void) -{ - OSAL_SUBTASK_BEGIN - - osal_task_delay(20); - - if ( tud_mounted() && !tud_hid_mouse_is_busy(0) ) - { - static uint8_t prev_mouse_buttons = 0; - - enum { - BUTTON_UP = 0, // map to button mask - BUTTON_DOWN = 1, - BUTTON_LEFT = 2, - BUTTON_RIGHT = 3, - BUTTON_CLICK_LEFT = 4, - BUTTON_CLICK_RIGHT = 5, - BUTTON_CLICK_MIDDLE = 6 - }; - - enum { MOUSE_RESOLUTION = 5 }; - - uint32_t button_mask = board_buttons(); - tu_memclr(&mouse_report, sizeof(hid_mouse_report_t)); - - if ( BIT_TEST_(button_mask, BUTTON_UP ) ) mouse_report.y = -MOUSE_RESOLUTION; - if ( BIT_TEST_(button_mask, BUTTON_DOWN ) ) mouse_report.y = MOUSE_RESOLUTION; - - if ( BIT_TEST_(button_mask, BUTTON_LEFT ) ) mouse_report.x = -MOUSE_RESOLUTION; - if ( BIT_TEST_(button_mask, BUTTON_RIGHT ) ) mouse_report.x = MOUSE_RESOLUTION; - - if ( BIT_TEST_(button_mask, BUTTON_CLICK_LEFT ) ) mouse_report.buttons |= MOUSE_BUTTON_LEFT; - if ( BIT_TEST_(button_mask, BUTTON_CLICK_RIGHT ) ) mouse_report.buttons |= MOUSE_BUTTON_RIGHT; - if ( BIT_TEST_(button_mask, BUTTON_CLICK_MIDDLE ) ) mouse_report.buttons |= MOUSE_BUTTON_MIDDLE; - - if ( ! (prev_mouse_buttons == mouse_report.buttons && mouse_report.y == 0 && mouse_report.x == 0 && mouse_report.wheel == 0) ) - { // send report if clicked buttons are changed or there is any movement x, y, wheel - prev_mouse_buttons = mouse_report.buttons; - - tud_hid_mouse_send(0, &mouse_report); - } - } - - OSAL_SUBTASK_END -} - -#endif - diff --git a/examples/obsolete/device/src/mouse_device_app.h b/examples/obsolete/device/src/mouse_device_app.h deleted file mode 100644 index 2eeb5794a..000000000 --- a/examples/obsolete/device/src/mouse_device_app.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************/ -/*! - @file mouse_device_app.h - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -/** \ingroup TBD - * \defgroup TBD - * \brief TBD - * - * @{ - */ - -#ifndef _TUSB_MOUSED_DEVICE_APP_H_ -#define _TUSB_MOUSED_DEVICE_APP_H_ - -#include "bsp/board.h" -#include "tusb.h" - -#ifdef __cplusplus - extern "C" { -#endif - -#if CFG_TUD_HID_MOUSE - -void mouse_app_init(void); -void mouse_app_task(void * param); -void mouse_app_mount(uint8_t rhport); -void mouse_app_umount(uint8_t rhport); - -#else - -#define mouse_app_init() -#define mouse_app_task(x) -#define mouse_app_mount(x) -#define mouse_app_umount(x) - -#endif - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_MOUSED_DEVICE_APP_H_ */ - -/** @} */ diff --git a/examples/obsolete/device/src/msc_device_app.c b/examples/obsolete/device/src/msc_device_app.c deleted file mode 100644 index 5190e6265..000000000 --- a/examples/obsolete/device/src/msc_device_app.c +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************/ -/*! - @file msc_device_app.c - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -#include "msc_device_app.h" - -#if CFG_TUD_MSC -#include "app_os_prio.h" - -//--------------------------------------------------------------------+ -// MACRO CONSTANT TYPEDEF -//--------------------------------------------------------------------+ - -//--------------------------------------------------------------------+ -// tinyusb callbacks -//--------------------------------------------------------------------+ -void msc_app_mount(uint8_t rhport) -{ - -} - -void msc_app_umount(uint8_t rhport) -{ - -} - -int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize) -{ - // read10 & write10 has their own callback and MUST not be handled here - - void const* ptr = NULL; - uint16_t len = 0; - - // most scsi handled is input - bool in_xfer = true; - - switch (scsi_cmd[0]) - { - case SCSI_CMD_TEST_UNIT_READY: - // Command that host uses to check our readiness before sending other commands - len = 0; - break; - - case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL: - // Host is about to read/write etc ... better not to disconnect disk - len = 0; - break; - - case SCSI_CMD_START_STOP_UNIT: - // Host try to eject/safe remove/powerof us. We could safely disconnect with disk storage, or go into lower power - // scsi_start_stop_unit_t const * cmd_start_stop = (scsi_start_stop_unit_t const *) scsi_cmd - len = 0; - break; - - default: - // negative is error -> Data stage is STALL, status = failed - return -1; - } - - // return len must not larger than bufsize - TU_ASSERT( bufsize >= len ); - - if ( ptr && len ) - { - if(in_xfer) - { - memcpy(buffer, ptr, len); - }else - { - // SCSI output - } - } - - return len; -} - -//--------------------------------------------------------------------+ -// APPLICATION CODE -//--------------------------------------------------------------------+ -void msc_app_task(void* param) -{ // no need to implement the task yet - (void) param; - - OSAL_TASK_BEGIN - - OSAL_TASK_END -} - -void msc_app_init (void) -{ - -} - - -#endif diff --git a/examples/obsolete/device/src/msc_device_app.h b/examples/obsolete/device/src/msc_device_app.h deleted file mode 100644 index 6f2e95630..000000000 --- a/examples/obsolete/device/src/msc_device_app.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************/ -/*! - @file msc_device_app.h - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -/** \ingroup group_demo - * \defgroup Mass Storage Device App - * @{ */ - -#ifndef _TUSB_MSCD_DEVICE_APP_H_ -#define _TUSB_MSCD_DEVICE_APP_H_ - -#include "bsp/board.h" -#include "tusb.h" - -#ifdef __cplusplus - extern "C" { -#endif - -#if CFG_TUD_MSC - -enum -{ - DISK_BLOCK_NUM = 16, // 8KB is the smallest size that windows allow to mount - DISK_BLOCK_SIZE = 512 -}; - -#define README_CONTENTS \ -"This is tinyusb's MassStorage Class demo.\r\n\r\n\ -If you find any bugs or get any questions, feel free to file an\r\n\ -issue at github.com/hathach/tinyusb" - -#if CFG_TUSB_MCU==OPT_MCU_LPC11UXX || CFG_TUSB_MCU==OPT_MCU_LPC13XX - #define MSCD_APP_ROMDISK -#else // defaults is ram disk - #define MSCD_APP_RAMDISK -#endif - -void msc_app_init(void); -void msc_app_task(void* param); - -void msc_app_mount(uint8_t rhport); -void msc_app_umount(uint8_t rhport); - -#else - -#define msc_app_init() -#define msc_app_task(x) -#define msc_app_mount(x) -#define msc_app_umount(x) - -#endif - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_MSCD_DEVICE_APP_H_ */ - -/** @} */ diff --git a/examples/obsolete/device/src/msc_device_ramdisk.c b/examples/obsolete/device/src/msc_device_ramdisk.c deleted file mode 100644 index f28690b73..000000000 --- a/examples/obsolete/device/src/msc_device_ramdisk.c +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************/ -/*! - @file msc_device_ramdisk.c - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -#include "msc_device_app.h" - -#if CFG_TUD_MSC && defined (MSCD_APP_RAMDISK) - -//--------------------------------------------------------------------+ -// MACRO CONSTANT TYPEDEF -//--------------------------------------------------------------------+ - -//--------------------------------------------------------------------+ -// INTERNAL OBJECT & FUNCTION DECLARATION -//--------------------------------------------------------------------+ -CFG_TUSB_MEM_SECTION -uint8_t msc_device_ramdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] = -{ - //------------- Boot Sector -------------// - // byte_per_sector = DISK_BLOCK_SIZE; fat12_sector_num_16 = DISK_BLOCK_NUM; - // sector_per_cluster = 1; reserved_sectors = 1; - // fat_num = 1; fat12_root_entry_num = 16; - // sector_per_fat = 1; sector_per_track = 1; head_num = 1; hidden_sectors = 0; - // drive_number = 0x80; media_type = 0xf8; extended_boot_signature = 0x29; - // filesystem_type = "FAT12 "; volume_serial_number = 0x1234; volume_label = "tinyusb msc"; - [0] = - { - 0xEB, 0x3C, 0x90, 0x4D, 0x53, 0x44, 0x4F, 0x53, 0x35, 0x2E, 0x30, 0x00, 0x02, 0x01, 0x01, 0x00, - 0x01, 0x10, 0x00, 0x10, 0x00, 0xF8, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x29, 0x34, 0x12, 0x00, 0x00, 0x74, 0x69, 0x6E, 0x79, 0x75, - 0x73, 0x62, 0x20, 0x6D, 0x73, 0x63, 0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, 0x00, 0x00, - [510] = 0x55, [511] = 0xAA // FAT magic code - }, - - //------------- FAT12 Table -------------// - [1] = - { - 0xF8, 0xFF, 0xFF, 0xFF, 0x0F // // first 2 entries must be F8FF, third entry is cluster end of readme file - }, - - //------------- Root Directory -------------// - [2] = - { - // first entry is volume label - 0x54, 0x49, 0x4E, 0x59, 0x55, 0x53, 0x42, 0x20, 0x4D, 0x53, 0x43, 0x08, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x6D, 0x65, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // second entry is readme file - 'R' , 'E' , 'A' , 'D' , 'M' , 'E' , ' ' , ' ' , 'T' , 'X' , 'T' , 0x20, 0x00, 0xC6, 0x52, 0x6D, - 0x65, 0x43, 0x65, 0x43, 0x00, 0x00, 0x88, 0x6D, 0x65, 0x43, 0x02, 0x00, - sizeof(README_CONTENTS)-1, 0x00, 0x00, 0x00 // readme's filesize (4 Bytes) - }, - - //------------- Readme Content -------------// - [3] = README_CONTENTS -}; - -//--------------------------------------------------------------------+ -// IMPLEMENTATION -//--------------------------------------------------------------------+ -int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) -{ - (void) rhport; (void) lun; - - uint8_t* addr = msc_device_ramdisk[lba] + offset; - memcpy(buffer, (uint8_t*) addr, bufsize); - - return bufsize; -} - -int32_t tud_msc_write10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) -{ - (void) rhport; (void) lun; - - uint8_t* addr = msc_device_ramdisk[lba] + offset; - memcpy(addr, buffer, bufsize); - - return bufsize; -} - -#endif diff --git a/examples/obsolete/device/src/msc_device_romdisk.c b/examples/obsolete/device/src/msc_device_romdisk.c deleted file mode 100644 index 1e6ca1bc3..000000000 --- a/examples/obsolete/device/src/msc_device_romdisk.c +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************/ -/*! - @file msc_device_romdisk.c - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -#include "msc_device_app.h" - -#if CFG_TUD_MSC && defined (MSCD_APP_ROMDISK) - -//--------------------------------------------------------------------+ -// INCLUDE -//--------------------------------------------------------------------+ - -//--------------------------------------------------------------------+ -// MACRO CONSTANT TYPEDEF -//--------------------------------------------------------------------+ - -//--------------------------------------------------------------------+ -// INTERNAL OBJECT & FUNCTION DECLARATION -//--------------------------------------------------------------------+ -const uint8_t msc_device_app_rommdisk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] = -{ - //------------- Boot Sector -------------// - // byte_per_sector = DISK_BLOCK_SIZE; fat12_sector_num_16 = DISK_BLOCK_NUM; - // sector_per_cluster = 1; reserved_sectors = 1; - // fat_num = 1; fat12_root_entry_num = 16; - // sector_per_fat = 1; sector_per_track = 1; head_num = 1; hidden_sectors = 0; - // drive_number = 0x80; media_type = 0xf8; extended_boot_signature = 0x29; - // filesystem_type = "FAT12 "; volume_serial_number = 0x1234; volume_label = "tinyusb msc"; - [0] = - { - 0xEB, 0x3C, 0x90, 0x4D, 0x53, 0x44, 0x4F, 0x53, 0x35, 0x2E, 0x30, 0x00, 0x02, 0x01, 0x01, 0x00, - 0x01, 0x10, 0x00, 0x10, 0x00, 0xF8, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x29, 0x34, 0x12, 0x00, 0x00, 0x74, 0x69, 0x6E, 0x79, 0x75, - 0x73, 0x62, 0x20, 0x6D, 0x73, 0x63, 0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, 0x00, 0x00, - [510] = 0x55, [511] = 0xAA // FAT magic code - }, - - //------------- FAT12 Table -------------// - [1] = - { - 0xF8, 0xFF, 0xFF, 0xFF, 0x0F // first 2 entries must be F8FF, third entry is cluster end of readme file - }, - - //------------- Root Directory -------------// - [2] = - { - // first entry is volume label - 0x54, 0x49, 0x4E, 0x59, 0x55, 0x53, 0x42, 0x20, 0x4D, 0x53, 0x43, 0x08, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x6D, 0x65, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // second entry is readme file - 0x52, 0x45, 0x41, 0x44, 0x4D, 0x45, 0x20, 0x20, 0x54, 0x58, 0x54, 0x20, 0x00, 0xC6, 0x52, 0x6D, - 0x65, 0x43, 0x65, 0x43, 0x00, 0x00, 0x88, 0x6D, 0x65, 0x43, 0x02, 0x00, - sizeof(README_CONTENTS)-1, 0x00, 0x00, 0x00 // readme's filesize - }, - - //------------- Readme Content -------------// - [3] = README_CONTENTS -}; - -//--------------------------------------------------------------------+ -// IMPLEMENTATION -//--------------------------------------------------------------------+ -int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) -{ - (void) rhport; (void) lun; - - uint8_t* addr = msc_device_ramdisk[lba] + offset; - memcpy(buffer, (uint8_t*) addr, bufsize); - - return bufsize; -} - - -// Stall write10 by return 0, as this is readonly disk -int32_t tud_msc_write10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize) -{ - (void) rhport; (void) lun; - - // let host know that this is read-only disk - mscd_sense_data.sense_key = SCSI_SENSEKEY_DATA_PROTECT; - return 0; -} - -#endif - diff --git a/examples/obsolete/device/src/tusb_config.h b/examples/obsolete/device/src/tusb_config.h deleted file mode 100644 index 2fd35102f..000000000 --- a/examples/obsolete/device/src/tusb_config.h +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************/ -/*! - @file tusb_config.h - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -#ifndef _TUSB_CONFIG_H_ -#define _TUSB_CONFIG_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -//--------------------------------------------------------------------+ -// CONTROLLER CONFIGURATION -//--------------------------------------------------------------------+ -//#define CFG_TUSB_MCU will be passed from IDE/command line for easy board/mcu switching - -#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE) -//#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE) - -#define CFG_TUSB_DEBUG 2 - -/*------------- RTOS -------------*/ -//#define CFG_TUSB_OS OPT_OS_NONE // be passed from IDE/command line for easy project switching - -//--------------------------------------------------------------------+ -// DEVICE CONFIGURATION -//--------------------------------------------------------------------+ - -/*------------- Core -------------*/ -#define CFG_TUD_DESC_AUTO 1 - -// #define CFG_TUD_DESC_VID 0xCAFE -// #define CFG_TUD_DESC_PID 0x0001 - -#define CFG_TUD_ENDOINT0_SIZE 64 - -//------------- CLASS -------------// -#define CFG_TUD_MSC 1 -#define CFG_TUD_CDC 1 -#define CFG_TUD_HID_KEYBOARD 0 -#define CFG_TUD_HID_MOUSE 0 - -/*------------------------------------------------------------------*/ -/* CLASS DRIVER - *------------------------------------------------------------------*/ - -// FIFO size of CDC TX and RX -#define CFG_TUD_CDC_RX_BUFSIZE 128 -#define CFG_TUD_CDC_TX_BUFSIZE 128 - -// Number of supported Logical Unit Number (At least 1) -#define CFG_TUD_MSC_MAXLUN 1 - -// Buffer size of Device Mass storage -#define CFG_TUD_MSC_BUFSIZE 512 - -//--------------------------------------------------------------------+ -// USB RAM PLACEMENT -//--------------------------------------------------------------------+ -#ifdef __CODE_RED // compiled with lpcxpresso - - #if (CFG_TUSB_MCU == OPT_MCU_LPC11UXX) || (CFG_TUSB_MCU == OPT_MCU_LPC13XX) - #define CFG_TUSB_MEM_SECTION ATTR_SECTION(.data.$RAM2) ATTR_ALIGNED(64) // lp11u & lp13u requires data to be 64 byte aligned - #elif CFG_TUSB_MCU == OPT_MCU_LPC175X_6X - #define CFG_TUSB_MEM_SECTION // LPC17xx USB DMA can access all - #elif (CFG_TUSB_MCU == OPT_MCU_LPC43XX) - #define CFG_TUSB_MEM_SECTION ATTR_SECTION(.data.$RAM3) - #endif - -#elif defined __CC_ARM // Compiled with Keil armcc, USBRAM_SECTION is defined in scatter files - - #if (CFG_TUSB_MCU == OPT_MCU_LPC11UXX) || (CFG_TUSB_MCU == OPT_MCU_LPC13XX) - #define CFG_TUSB_MEM_SECTION ATTR_SECTION(USBRAM_SECTION) ATTR_ALIGNED(64) // lp11u & lp13u requires data to be 64 byte aligned - #elif (CFG_TUSB_MCU == OPT_MCU_LPC175X_6X) - #define CFG_TUSB_MEM_SECTION // LPC17xx USB DMA can access all address - #elif (CFG_TUSB_MCU == OPT_MCU_LPC43XX) - #define CFG_TUSB_MEM_SECTION // Use keil tool configure to have AHB SRAM as default memory - #endif - -#elif defined __ICCARM__ // compiled with IAR - - #if (CFG_TUSB_MCU == OPT_MCU_LPC11UXX) || (CFG_TUSB_MCU == OPT_MCU_LPC13XX) - #define CFG_TUSB_MEM_SECTION _Pragma("location=\"USB_PACKET_MEMORY\"") ATTR_ALIGNED(64) - #elif (CFG_TUSB_MCU == OPT_MCU_LPC175X_6X) - #define CFG_TUSB_MEM_SECTION - #elif (CFG_TUSB_MCU == OPT_MCU_LPC43XX) - #define CFG_TUSB_MEM_SECTION _Pragma("location=\".ahb_sram1\"") - #endif - -#else - - #error compiler not specified - -#endif - -// LPC11uxx and LPC13uxx requires each buffer has to be 64-byte alignment -#if CFG_TUSB_MCU == OPT_MCU_LPC11UXX || CFG_TUSB_MCU == OPT_MCU_LPC13XX - #define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(64) -#elif CFG_TUSB_MCU == OPT_MCU_NRF5X - #define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4) -#else - #define CFG_TUSB_MEM_ALIGN -#endif - - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_CONFIG_H_ */ diff --git a/examples/obsolete/device/src/tusb_descriptors.c b/examples/obsolete/device/src/tusb_descriptors.c deleted file mode 100644 index 2ba5434cc..000000000 --- a/examples/obsolete/device/src/tusb_descriptors.c +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************/ -/*! - @file tusb_descriptors.c - @author hathach (tinyusb.org) - - @section LICENSE - - Software License Agreement (BSD License) - - Copyright (c) 2013, hathach (tinyusb.org) - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This file is part of the tinyusb stack. -*/ -/**************************************************************************/ - -#include "tusb.h" - -//--------------------------------------------------------------------+ -// STRING DESCRIPTORS -//--------------------------------------------------------------------+ -#define STRING_LEN_UNICODE(n) (2 + (2*(n))) // also includes 2 byte header -#define ENDIAN_BE16_FROM( high, low) ENDIAN_BE16(high << 8 | low) - -// array of pointer to string descriptors -uint16_t const * const string_desc_arr [] = -{ - [0] = (uint16_t []) { // supported language - ENDIAN_BE16_FROM( STRING_LEN_UNICODE(1), TUSB_DESC_STRING ), - 0x0409 // English - }, - - [1] = (uint16_t []) { // manufacturer - ENDIAN_BE16_FROM( STRING_LEN_UNICODE(11), TUSB_DESC_STRING), - 't', 'i', 'n', 'y', 'u', 's', 'b', '.', 'o', 'r', 'g' // len = 11 - }, - - [2] = (uint16_t []) { // product - ENDIAN_BE16_FROM( STRING_LEN_UNICODE(14), TUSB_DESC_STRING), - 't', 'i', 'n', 'y', 'u', 's', 'b', ' ', 'd', 'e', 'v', 'i', 'c', 'e' // len = 14 - }, - - [3] = (uint16_t []) { // serials - ENDIAN_BE16_FROM( STRING_LEN_UNICODE(4), TUSB_DESC_STRING), - '1', '2', '3', '4' // len = 4 - }, - - [4] = (uint16_t []) { // CDC Interface - ENDIAN_BE16_FROM( STRING_LEN_UNICODE(3), TUSB_DESC_STRING), - 'c', 'd', 'c' // len = 3 - }, - - [5] = (uint16_t []) { // Keyboard Interface - ENDIAN_BE16_FROM( STRING_LEN_UNICODE(5), TUSB_DESC_STRING), - 'm', 'o', 'u', 's', 'e' // len = 5 - }, - - [6] = (uint16_t []) { // Keyboard Interface - ENDIAN_BE16_FROM( STRING_LEN_UNICODE(8), TUSB_DESC_STRING), - 'k', 'e', 'y', 'b', 'o', 'a', 'r', 'd' // len = 8 - }, - - [7] = (uint16_t []) { // MSC Interface - ENDIAN_BE16_FROM( STRING_LEN_UNICODE(3), TUSB_DESC_STRING), - 'm', 's', 'c' // len = 3 - } -}; - - -// tud_desc_set is required by tinyusb stack -// since CFG_TUD_DESC_AUTO is enabled, we only need to set string_arr -tud_desc_set_t tud_desc_set = -{ - .device = NULL, - .config = NULL, - .string_arr = (uint8_t const **) string_desc_arr, - .hid_report = NULL -}; |
