diff options
| author | hathach <[email protected]> | 2013-05-31 21:24:40 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-05-31 21:24:40 +0700 |
| commit | 9e49056721e7fbba2bdb5933c7eabf9548f4279f (patch) | |
| tree | effefd26f21bd8d179aed469368c112df4b8127b | |
| parent | 03d85acfc7cb18a5469146f98c210a5747218cb3 (diff) | |
refractor change tusbd_hid_keyboard_send_report API
| -rw-r--r-- | demos/device/keyboard/.cproject | 66 | ||||
| -rw-r--r-- | demos/device/keyboard/main.c | 7 | ||||
| -rw-r--r-- | tests/test/device/usbd/test_usbd.c | 3 | ||||
| -rw-r--r-- | tinyusb/class/hid_device.c | 9 | ||||
| -rw-r--r-- | tinyusb/class/hid_device.h | 10 | ||||
| -rw-r--r-- | tinyusb/device/usbd.c | 33 | ||||
| -rw-r--r-- | tinyusb/device/usbd.h | 1 |
7 files changed, 74 insertions, 55 deletions
diff --git a/demos/device/keyboard/.cproject b/demos/device/keyboard/.cproject index b97fad98c..e06b38e20 100644 --- a/demos/device/keyboard/.cproject +++ b/demos/device/keyboard/.cproject @@ -119,7 +119,7 @@ <builder buildPath="${workspace_loc:/device_keyboard/Debug}" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator" id="com.crt.advproject.builder.exe.debug.1603637140" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.exe.debug"/> <tool id="com.crt.advproject.cpp.exe.debug.1912680765" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.exe.debug"/> <tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${CFLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="com.crt.advproject.gcc.exe.debug.901878888" name="MCU C Compiler" superClass="com.crt.advproject.gcc.exe.debug"> - <option id="com.crt.advproject.gcc.arch.227583493" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm0" valueType="enumerated"/> + <option id="com.crt.advproject.gcc.arch.227583493" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/> <option id="com.crt.advproject.gcc.thumb.1429919562" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/> <option id="gnu.c.compiler.option.preprocessor.def.symbols.690334585" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> <listOptionValue builtIn="false" value="__REDLIB__"/> @@ -142,7 +142,7 @@ <inputType id="com.crt.advproject.compiler.input.1660235734" superClass="com.crt.advproject.compiler.input"/> </tool> <tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.gas.exe.debug.1919954827" name="MCU Assembler" superClass="com.crt.advproject.gas.exe.debug"> - <option id="com.crt.advproject.gas.arch.62277376" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm0" valueType="enumerated"/> + <option id="com.crt.advproject.gas.arch.62277376" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm3" valueType="enumerated"/> <option id="com.crt.advproject.gas.thumb.567012827" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/> <option id="gnu.both.asm.option.flags.crt.1544048579" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -D__REDLIB__ -DDEBUG -D__CODE_RED" valueType="string"/> <inputType id="com.crt.advproject.assembler.input.2112542401" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/> @@ -150,7 +150,7 @@ </tool> <tool id="com.crt.advproject.link.cpp.exe.debug.438186138" name="MCU C++ Linker" superClass="com.crt.advproject.link.cpp.exe.debug"/> <tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GLDErrorParser" id="com.crt.advproject.link.exe.debug.332994381" name="MCU Linker" superClass="com.crt.advproject.link.exe.debug"> - <option id="com.crt.advproject.link.arch.5439507" name="Architecture" superClass="com.crt.advproject.link.arch" value="com.crt.advproject.link.target.cm0" valueType="enumerated"/> + <option id="com.crt.advproject.link.arch.5439507" name="Architecture" superClass="com.crt.advproject.link.arch" value="com.crt.advproject.link.target.cm3" valueType="enumerated"/> <option id="com.crt.advproject.link.thumb.1052282054" name="Thumb mode" superClass="com.crt.advproject.link.thumb" value="true" valueType="boolean"/> <option id="com.crt.advproject.link.script.1723865493" name="Linker script" superClass="com.crt.advproject.link.script" value=""device_keyboard_Board_rf1ghznode.ld"" valueType="string"/> <option id="com.crt.advproject.link.manage.314167409" name="Manage linker script" superClass="com.crt.advproject.link.manage" value="true" valueType="boolean"/> @@ -277,45 +277,49 @@ <storageModule moduleId="com.crt.config"> <projectStorage><?xml version="1.0" encoding="UTF-8"?> <TargetConfig> -<Properties property_0="" property_3="NXP" property_4="LPC11U37/401" property_count="5" version="1"/> -<infoList vendor="NXP"><info chip="LPC11U37/401" match_id="0x00017C40" name="LPC11U37/401" stub="crt_emu_lpc11_13_nxp"><chip><name>LPC11U37/401</name> -<family>LPC11Uxx</family> +<Properties property_0="" property_3="NXP" property_4="LPC1347" property_count="5" version="1"/> +<infoList vendor="NXP"><info chip="LPC1347" match_id="0x08020543" name="LPC1347" stub="crt_emu_lpc11_13_nxp"><chip><name>LPC1347</name> +<family>LPC13xx (12bit ADC)</family> <vendor>NXP (formerly Philips)</vendor> <reset board="None" core="Real" sys="Real"/> <clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/> <memory can_program="true" id="Flash" is_ro="true" type="Flash"/> <memory id="RAM" type="RAM"/> <memory id="Periph" is_volatile="true" type="Peripheral"/> -<memoryInstance derived_from="Flash" id="MFlash128" location="0x0" size="0x20000"/> +<memoryInstance derived_from="Flash" id="MFlash64" location="0x0" size="0x10000"/> <memoryInstance derived_from="RAM" id="RamLoc8" location="0x10000000" size="0x2000"/> <memoryInstance derived_from="RAM" id="RamUsb2" location="0x20004000" size="0x800"/> -<prog_flash blocksz="0x1000" location="0x0" maxprgbuff="0x400" progwithcode="TRUE" size="0x20000"/> -<peripheralInstance derived_from="CM0_NVIC" id="NVIC" location="0xe000e000"/> -<peripheralInstance derived_from="LPC11U_GPIO" id="GPIO" location="0x50000000"/> -<peripheralInstance derived_from="LPC11U_USBDEV" id="USB" location="0x40080000"/> -<peripheralInstance derived_from="CM0_DCR" id="DCR" location="0xe000edf0"/> -<peripheralInstance derived_from="LPC11U_GPIO_GROUP_INT" id="GPIOGROUP0INT" location="0x40060000"/> -<peripheralInstance derived_from="LPC11U_GPIO_GROUP_INT" id="GPIOGROUP1INT" location="0x4005c000"/> -<peripheralInstance derived_from="LPC11U_GPIO_INT" id="GPIOINT" location="0x4004c000"/> -<peripheralInstance derived_from="LPC11_13_SSP" id="SSP1" location="0x40058000"/> -<peripheralInstance derived_from="LPC11U_FMC" id="FMC" location="0x4003c000"/> -<peripheralInstance derived_from="LPC11U_SYSCTL" id="SYSCTL" location="0x40048000"/> -<peripheralInstance derived_from="LPC11U_IOCON" id="IOCON" location="0x40044000"/> -<peripheralInstance derived_from="LPC11_13_SSP" id="SSP0" location="0x40040000"/> -<peripheralInstance derived_from="LPC11_13_PMU" id="PMU" location="0x40038000"/> -<peripheralInstance derived_from="LPC11_13_ADC" id="ADC" location="0x4001c000"/> -<peripheralInstance derived_from="LPC11_13_TIMER32" id="TIMER1" location="0x40018000"/> -<peripheralInstance derived_from="LPC11_13_TIMER32" id="TIMER0" location="0x40014000"/> -<peripheralInstance derived_from="LPC11_13_TIMER16" id="TMR161" location="0x40010000"/> -<peripheralInstance derived_from="LPC11_13_TIMER16" id="TMR160" location="0x4000c000"/> -<peripheralInstance derived_from="LPC1xxx_UART_MODEM" id="UART0" location="0x40008000"/> -<peripheralInstance derived_from="LPC11_13_WDT" id="WDT" location="0x40004000"/> -<peripheralInstance derived_from="LPC11_13_I2C" id="I2C0" location="0x40000000"/> +<memoryInstance derived_from="RAM" id="RamPeriph2" location="0x20000000" size="0x800"/> +<prog_flash blocksz="0x1000" location="0x0" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/> +<peripheralInstance derived_from="V7M_MPU" id="MPU" location="0xe000ed90"/> +<peripheralInstance derived_from="V7M_NVIC" id="NVIC" location="0xe000e000"/> +<peripheralInstance derived_from="V7M_DCR" id="DCR" location="0xe000edf0"/> +<peripheralInstance derived_from="V7M_ITM" id="ITM" location="0xe0000000"/> +<peripheralInstance derived_from="I2C" id="I2C" location="0x40000000"/> +<peripheralInstance derived_from="WWDT" id="WWDT" location="0x40004000"/> +<peripheralInstance derived_from="USART" id="USART" location="0x40008000"/> +<peripheralInstance derived_from="CT16B0" id="CT16B0" location="0x4000c000"/> +<peripheralInstance derived_from="CT16B1" id="CT16B1" location="0x40010000"/> +<peripheralInstance derived_from="CT32B0" id="CT32B0" location="0x40014000"/> +<peripheralInstance derived_from="CT32B1" id="CT32B1" location="0x40018000"/> +<peripheralInstance derived_from="ADC" id="ADC" location="0x4001c000"/> +<peripheralInstance derived_from="PMU" id="PMU" location="0x40038000"/> +<peripheralInstance derived_from="FLASHCTRL" id="FLASHCTRL" location="0x4003c000"/> +<peripheralInstance derived_from="SSP0" id="SSP0" location="0x40040000"/> +<peripheralInstance derived_from="IOCON" id="IOCON" location="0x40044000"/> +<peripheralInstance derived_from="SYSCON" id="SYSCON" location="0x40048000"/> +<peripheralInstance derived_from="GPIO-PIN-INT" id="GPIO-PIN-INT" location="0x4004c000"/> +<peripheralInstance derived_from="SSP1" id="SSP1" location="0x40058000"/> +<peripheralInstance derived_from="GPIO-GROUP-INT0" id="GPIO-GROUP-INT0" location="0x4005c000"/> +<peripheralInstance derived_from="GPIO-GROUP-INT1" id="GPIO-GROUP-INT1" location="0x40060000"/> +<peripheralInstance derived_from="RITIMER" id="RITIMER" location="0x40064000"/> +<peripheralInstance derived_from="USB" id="USB" location="0x40080000"/> +<peripheralInstance derived_from="GPIO-PORT" id="GPIO-PORT" location="0x50000000"/> </chip> -<processor><name gcc_name="cortex-m0">Cortex-M0</name> +<processor><name gcc_name="cortex-m3">Cortex-M3</name> <family>Cortex-M</family> </processor> -<link href="nxp_lpc11_13_peripheral.xme" show="embed" type="simple"/> +<link href="nxp_lpc13Uxx_peripheral.xme" show="embed" type="simple"/> </info> </infoList> </TargetConfig></projectStorage> diff --git a/demos/device/keyboard/main.c b/demos/device/keyboard/main.c index 22ceffb0d..cdf7fe452 100644 --- a/demos/device/keyboard/main.c +++ b/demos/device/keyboard/main.c @@ -100,9 +100,12 @@ void keyboard_device_app_task(void * p_para) static uint32_t count =0; if (count < 4) { - uint8_t keys[6] = {0x04}; // A character - tusbd_hid_keyboard_send_report(0x00, keys, 1); count++; + + tusbd_hid_keyboard_send_report( + &(tusb_keyboard_report_t) { + .keycode = { 0x04 } } + ); } } } diff --git a/tests/test/device/usbd/test_usbd.c b/tests/test/device/usbd/test_usbd.c index 05c338199..e8f114b0a 100644 --- a/tests/test/device/usbd/test_usbd.c +++ b/tests/test/device/usbd/test_usbd.c @@ -43,8 +43,9 @@ #include "tusb_descriptors.h" -#include "mock_dcd.h" #include "usbd.h" +#include "mock_dcd.h" +//#include "mock_" void setUp(void) { diff --git a/tinyusb/class/hid_device.c b/tinyusb/class/hid_device.c index 2e68fd4d0..dc340841f 100644 --- a/tinyusb/class/hid_device.c +++ b/tinyusb/class/hid_device.c @@ -226,7 +226,7 @@ tusb_error_t hidd_configured(USBD_HANDLE_T hUsb) } #if TUSB_CFG_DEVICE_HID_KEYBOARD -tusb_error_t tusbd_hid_keyboard_send_report(uint8_t modifier, uint8_t keycodes[], uint8_t numkey) +tusb_error_t tusbd_hid_keyboard_send_report(tusb_keyboard_report_t *p_kbd_report) { // uint32_t start_time = systickGetSecondsActive(); // while (bKeyChanged) // TODO blocking while previous key has yet sent - can use fifo to improve this @@ -239,12 +239,9 @@ tusb_error_t tusbd_hid_keyboard_send_report(uint8_t modifier, uint8_t keycodes[] return TUSB_ERROR_FAILED; } - ASSERT(keycodes && numkey && numkey <=6, ERR_FAILED); - - hid_keyboard_report.modifier = modifier; - memset(hid_keyboard_report.keycode, 0, 6); - memcpy(hid_keyboard_report.keycode, keycodes, numkey); + ASSERT_PTR(p_kbd_report, TUSB_ERROR_FAILED); + hid_keyboard_report = *p_kbd_report; bKeyChanged = true; return TUSB_ERROR_NONE; diff --git a/tinyusb/class/hid_device.h b/tinyusb/class/hid_device.h index f01685e25..38282f624 100644 --- a/tinyusb/class/hid_device.h +++ b/tinyusb/class/hid_device.h @@ -36,12 +36,6 @@ */ /**************************************************************************/ -/** \file - * \brief TBD - * - * \note TBD - */ - /** \ingroup TBD * \defgroup TBD * \brief TBD @@ -63,8 +57,8 @@ //--------------------------------------------------------------------+ // KEYBOARD Application API //--------------------------------------------------------------------+ -tusb_error_t tusbd_hid_keyboard_send_report(uint8_t modifier, uint8_t keycodes[], uint8_t numkey); -tusb_error_t tusb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y); +tusb_error_t tusbd_hid_keyboard_send_report(tusb_keyboard_report_t *p_kbd_report); +tusb_error_t tusbd_hid_mouse_send_report(uint8_t buttons, int8_t x, int8_t y); //--------------------------------------------------------------------+ // USBD-CLASS DRIVER API diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c index bed745985..5fb5d0202 100644 --- a/tinyusb/device/usbd.c +++ b/tinyusb/device/usbd.c @@ -61,12 +61,35 @@ //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ +static tusb_error_t usbd_string_descriptor_init(void); + +//--------------------------------------------------------------------+ +// APPLICATION INTERFACE +//--------------------------------------------------------------------+ +//bool tusbd_is_configured(uint8_t coreid) +//{ +// +//} //--------------------------------------------------------------------+ // IMPLEMENTATION //--------------------------------------------------------------------+ tusb_error_t usbd_init (void) { + ASSERT_STATUS ( usbd_string_descriptor_init() ); + + ASSERT_STATUS ( dcd_init() ); + + return TUSB_ERROR_NONE; +} + +#endif + +//--------------------------------------------------------------------+ +// HELPER +//--------------------------------------------------------------------+ +static tusb_error_t usbd_string_descriptor_init(void) +{ ASSERT_INT( USB_STRING_LEN(sizeof(TUSB_CFG_DEVICE_STRING_MANUFACTURER)-1), app_tusb_desc_strings.manufacturer.bLength, TUSB_ERROR_USBD_DESCRIPTOR_STRING); @@ -78,22 +101,18 @@ tusb_error_t usbd_init (void) for(uint32_t i=0; i < sizeof(TUSB_CFG_DEVICE_STRING_MANUFACTURER)-1; i++) { - app_tusb_desc_strings.manufacturer.unicode_string[i] = TUSB_CFG_DEVICE_STRING_MANUFACTURER[i]; + app_tusb_desc_strings.manufacturer.unicode_string[i] = (uint16_t) TUSB_CFG_DEVICE_STRING_MANUFACTURER[i]; } for(uint32_t i=0; i < sizeof(TUSB_CFG_DEVICE_STRING_PRODUCT)-1; i++) { - app_tusb_desc_strings.product.unicode_string[i] = TUSB_CFG_DEVICE_STRING_PRODUCT[i]; + app_tusb_desc_strings.product.unicode_string[i] = (uint16_t) TUSB_CFG_DEVICE_STRING_PRODUCT[i]; } for(uint32_t i=0; i < sizeof(TUSB_CFG_DEVICE_STRING_SERIAL)-1; i++) { - app_tusb_desc_strings.serial.unicode_string[i] = TUSB_CFG_DEVICE_STRING_SERIAL[i]; + app_tusb_desc_strings.serial.unicode_string[i] = (uint16_t) TUSB_CFG_DEVICE_STRING_SERIAL[i]; } - ASSERT_STATUS ( dcd_init() ); - return TUSB_ERROR_NONE; } - -#endif diff --git a/tinyusb/device/usbd.h b/tinyusb/device/usbd.h index 25aaaa946..5ed8ebd93 100644 --- a/tinyusb/device/usbd.h +++ b/tinyusb/device/usbd.h @@ -67,6 +67,7 @@ //--------------------------------------------------------------------+ // APPLICATION API //--------------------------------------------------------------------+ +bool tusbd_is_configured(uint8_t coreid) ATTR_WARN_UNUSED_RESULT; //--------------------------------------------------------------------+ // CLASS-USBD & INTERNAL API |
