Merge pull request #532 from hathach/house-keeping

House keeping
This commit is contained in:
Ha Thach 2020-10-09 21:25:17 +07:00 committed by GitHub
commit 8a07b9b9c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
73 changed files with 118 additions and 165 deletions

View File

@ -35,7 +35,7 @@ jobs:
- 'device/hid_composite'
- 'device/hid_composite_freertos'
- 'device/hid_generic_inout'
- 'device/hid_multipleinterface'
- 'device/hid_multiple_interface'
- 'device/midi_test'
- 'device/msc_dual_lun'
- 'device/net_lwip_webserver'
@ -66,14 +66,14 @@ jobs:
npm install --global xpm
xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest
xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@latest
echo "::add-path::`echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin`"
echo "::add-path::`echo $HOME/opt/xPacks/@xpack-dev-tools/riscv-none-embed-gcc/*/.content/bin`"
echo `echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin` >> $GITHUB_PATH
echo `echo $HOME/opt/xPacks/@xpack-dev-tools/riscv-none-embed-gcc/*/.content/bin` >> $GITHUB_PATH
# TI MSP430 GCC
mkdir -p /tmp/dl/
[ -f "/tmp/dl/msp430-gcc.tar.bz2" ] || wget --progress=dot:mega $MSP430GCC_URL -O /tmp/dl/msp430-gcc.tar.bz2
tar -C $HOME -xaf /tmp/dl/msp430-gcc.tar.bz2
echo "::add-path::`echo $HOME/msp430-gcc-*_linux64/bin`"
echo `echo $HOME/msp430-gcc-*_linux64/bin` >> $GITHUB_PATH
- name: Checkout TinyUSB
uses: actions/checkout@v2

View File

@ -34,6 +34,12 @@
// MACRO CONSTANT TYPEDEF PROTYPES
//--------------------------------------------------------------------+
// Interface index depends on the order in configuration descriptor
enum {
ITF_KEYBOARD = 0,
ITF_MOUSE = 1
};
/* Blink pattern
* - 250 ms : device not mounted
* - 1000 ms : device mounted
@ -104,10 +110,6 @@ void tud_resume_cb(void)
void hid_task(void)
{
//Set up interfaces
const uint8_t keyboard_interface = 0;
const uint8_t mouse_interface = 1;
// Poll every 10ms
const uint32_t interval_ms = 10;
static uint32_t start_ms = 0;
@ -126,7 +128,7 @@ void hid_task(void)
}
/*------------- Keyboard -------------*/
if ( tud_hid_n_ready(keyboard_interface) )
if ( tud_hid_n_ready(ITF_KEYBOARD) )
{
// use to avoid send multiple consecutive zero report for keyboard
static bool has_key = false;
@ -136,29 +138,26 @@ void hid_task(void)
uint8_t keycode[6] = { 0 };
keycode[0] = HID_KEY_A;
tud_hid_n_keyboard_report(keyboard_interface, 0, 0, keycode);
tud_hid_n_keyboard_report(ITF_KEYBOARD, 0, 0, keycode);
has_key = true;
}else
{
// send empty key report if previously has key pressed
if (has_key) tud_hid_n_keyboard_report(keyboard_interface, 0, 0, NULL);
if (has_key) tud_hid_n_keyboard_report(ITF_KEYBOARD, 0, 0, NULL);
has_key = false;
}
}
/*------------- Mouse -------------*/
if ( tud_hid_n_ready(mouse_interface) )
if ( tud_hid_n_ready(ITF_MOUSE) )
{
if ( btn )
{
int8_t const delta = 5;
// no button, right + down, no scroll pan
tud_hid_n_mouse_report(mouse_interface, 0, 0x00, delta, delta, 0, 0);
// delay a bit before attempt to send keyboard report
board_delay(10);
tud_hid_n_mouse_report(ITF_MOUSE, 0, 0x00, delta, delta, 0, 0);
}
}
}
@ -167,7 +166,7 @@ void hid_task(void)
// Invoked when received GET_REPORT control request
// Application must fill buffer report's content and return its length.
// Return zero will cause the stack to STALL request
uint16_t tud_hid_n_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
{
// TODO not Implemented
(void) itf;
@ -181,7 +180,7 @@ uint16_t tud_hid_n_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type
// Invoked when received SET_REPORT control request or
// received data on OUT endpoint ( Report ID = 0, Type = 0 )
void tud_hid_n_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize)
void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize)
{
// TODO set LED based on CAPLOCK, NUMLOCK etc...
(void) itf;

View File

@ -83,7 +83,7 @@ uint8_t const desc_hid_report2[] =
// Invoked when received GET HID REPORT DESCRIPTOR
// Application return pointer to descriptor
// Descriptor contents must exist long enough for transfer to complete
uint8_t const * tud_hid_n_descriptor_report_cb(uint8_t itf)
uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf)
{
if (itf == 0)
{

View File

@ -147,6 +147,8 @@ else
JLINKEXE = JLinkExe
endif
JLINK_IF ?= swd
# Flash using jlink
flash-jlink: $(BUILD)/$(BOARD)-firmware.hex
@echo halt > $(BUILD)/$(BOARD).jlink
@ -161,4 +163,9 @@ flash-jlink: $(BUILD)/$(BOARD)-firmware.hex
flash-stlink: $(BUILD)/$(BOARD)-firmware.elf
STM32_Programmer_CLI --connect port=swd --write $< --go
# flash with pyocd
flash-pyocd: $(BUILD)/$(BOARD)-firmware.hex
pyocd flash -t $(PYOCD_TARGET) $<
pyocd reset -t $(PYOCD_TARGET)
endif # Make target

View File

@ -49,7 +49,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = nRF52840_xxAA
JLINK_IF = swd
# For uf2 conversion
UF2_FAMILY = 0xADA52840

View File

@ -51,7 +51,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = nRF52840_xxAA
JLINK_IF = swd
# flash using bossac (as part of Nano33 BSP tools)
# can be found in arduino15/packages/arduino/tools/bossac/

View File

@ -49,7 +49,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = nRF52840_xxAA
JLINK_IF = swd
# For uf2 conversion
UF2_FAMILY = 0xADA52840

View File

@ -38,7 +38,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = ATSAMD21G18
JLINK_IF = swd
# flash using jlink
flash: $(BUILD)/$(BOARD)-firmware.uf2

View File

@ -57,7 +57,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = ATSAME51J19
JLINK_IF = swd
# flash using jlink
flash: flash-jlink

View File

@ -38,7 +38,6 @@ FREERTOS_PORT = ARM_CM33_NTZ/non_secure
# For flash-jlink target
JLINK_DEVICE = DA14695
JLINK_IF = swd
# flash using jlink but with some twists
flash: flash-dialog

View File

@ -38,7 +38,6 @@ FREERTOS_PORT = ARM_CM33_NTZ/non_secure
# For flash-jlink target
JLINK_DEVICE = DA14699
JLINK_IF = swd
# flash using jlink but with some twists
flash: flash-dialog

View File

@ -42,7 +42,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = LPC4088
JLINK_IF = swd
# flash using jlink
flash: flash-jlink

View File

@ -42,7 +42,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = LPC4357_M4
JLINK_IF = swd
# flash using jlink
flash: flash-jlink

View File

@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = ATSAMD21G18
JLINK_IF = swd
# flash using bossac at least version 1.8
# can be found in arduino15/packages/arduino/tools/bossac/

View File

@ -42,7 +42,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = ATSAMD51J19
JLINK_IF = swd
# flash using bossac at least version 1.8
# can be found in arduino15/packages/arduino/tools/bossac/

View File

@ -50,7 +50,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = nRF52840_xxAA
JLINK_IF = swd
# For uf2 conversion
UF2_FAMILY = 0xADA52840

View File

@ -49,7 +49,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = nRF52840_xxAA
JLINK_IF = swd
# For uf2 conversion
UF2_FAMILY = 0xADA52840

View File

@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = stm32f405rg
JLINK_IF = swd
# Path to STM32 Cube Programmer CLI, should be added into system path
STM32Prog = STM32_Programmer_CLI

View File

@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = ATSAMD21G18
JLINK_IF = swd
# flash using bossac at least version 1.8
# can be found in arduino15/packages/arduino/tools/bossac/

View File

@ -42,7 +42,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = ATSAMD51J19
JLINK_IF = swd
# flash using bossac at least version 1.8
# can be found in arduino15/packages/arduino/tools/bossac/

View File

@ -50,7 +50,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = nRF52840_xxAA
JLINK_IF = swd
# For uf2 conversion
UF2_FAMILY = 0xADA52840

View File

@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = LPC11U37/401
JLINK_IF = swd
# flash using pyocd
flash: $(BUILD)/$(BOARD)-firmware.hex

View File

@ -37,7 +37,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = LPC11U68
JLINK_IF = swd
# flash using pyocd
flash: $(BUILD)/$(BOARD)-firmware.hex

View File

@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM3
# For flash-jlink target
JLINK_DEVICE = LPC1347
JLINK_IF = swd
# flash using jlink
flash: flash-jlink

View File

@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM3
# For flash-jlink target
JLINK_DEVICE = LPC1549
JLINK_IF = swd
# flash using jlink
flash: flash-jlink

View File

@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM3
# For flash-jlink target
JLINK_DEVICE = LPC1769
JLINK_IF = swd
# flash using jlink
flash: flash-jlink

View File

@ -41,7 +41,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = LPC51U68
JLINK_IF = swd
# flash using pyocd (51u68 is not supported yet)
flash: $(BUILD)/$(BOARD)-firmware.hex

View File

@ -43,7 +43,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = LPC54114J256_M4
JLINK_IF = swd
# flash using pyocd
flash: $(BUILD)/$(BOARD)-firmware.hex

View File

@ -43,7 +43,6 @@ FREERTOS_PORT = ARM_CM33_NTZ/non_secure
# For flash-jlink target
JLINK_DEVICE = LPC55S69
JLINK_IF = swd
# flash using pyocd
flash: $(BUILD)/$(BOARD)-firmware.hex

View File

@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = ATSAMD21G18
JLINK_IF = swd
# flash using jlink
flash: $(BUILD)/$(BOARD)-firmware.bin

View File

@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM3
# For flash-jlink target
JLINK_DEVICE = LPC1768
JLINK_IF = swd
# flash using pyocd
flash: $(BUILD)/$(BOARD)-firmware.hex

View File

@ -37,7 +37,6 @@ FREERTOS_PORT = ARM_CM3
# For flash-jlink target
JLINK_DEVICE = LPC1857
JLINK_IF = swd
# flash using jlink
flash: flash-jlink

View File

@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = ATSAMD21G18
JLINK_IF = swd
# flash using bossac at least version 1.8
# can be found in arduino15/packages/arduino/tools/bossac/

View File

@ -42,7 +42,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = ATSAMD51J19
JLINK_IF = swd
# flash using bossac at least version 1.8
# can be found in arduino15/packages/arduino/tools/bossac/

View File

@ -49,8 +49,9 @@ FREERTOS_PORT = ARM_CM7/r0p1
# For flash-jlink target
JLINK_DEVICE = MIMXRT1011DAE5A
JLINK_IF = swd
# flash by copying bin file to DAP Mass Storage
flash: $(BUILD)/$(BOARD)-firmware.bin
cp $< /media/$(USER)/RT1010-EVK/
# For flash-pyocd target
PYOCD_TARGET = mimxrt1010
# flash using pyocd
flash: flash-pyocd

View File

@ -45,12 +45,9 @@ FREERTOS_PORT = ARM_CM7/r0p1
# For flash-jlink target
JLINK_DEVICE = MIMXRT1015DAF5A
JLINK_IF = swd
# flash by copying bin file to DAP Mass Storage
flash: $(BUILD)/$(BOARD)-firmware.bin
cp $< /media/$(USER)/RT1015-EVK/
# For flash-pyocd target
PYOCD_TARGET = mimxrt1015
# flash using pyocd
#flash: $(BUILD)/$(BOARD)-firmware.hex
# pyocd flash -b MIMXRT1015-EVK $<
flash: flash-pyocd

View File

@ -45,8 +45,9 @@ FREERTOS_PORT = ARM_CM7/r0p1
# For flash-jlink target
JLINK_DEVICE = MIMXRT1021DAG5A
JLINK_IF = swd
# flash by copying bin file to DAP Mass Storage
flash: $(BUILD)/$(BOARD)-firmware.bin
cp $< /media/$(USER)/RT1020-EVK/
# For flash-pyocd target
PYOCD_TARGET = mimxrt1020
# flash using pyocd
flash: flash-pyocd

View File

@ -43,10 +43,8 @@ CHIP_FAMILY = transdimension
# For freeRTOS port source
FREERTOS_PORT = ARM_CM7/r0p1
# For flash-jlink target
JLINK_DEVICE = MIMXRT1052xxx6B
JLINK_IF = swd
# For flash-pyocd target
PYOCD_TARGET = mimxrt1050
# flash by copying bin file to DAP Mass Storage
flash: $(BUILD)/$(BOARD)-firmware.bin
cp $< /media/$(USER)/RT1050-EVK/
# flash using pyocd
flash: flash-pyocd

View File

@ -45,8 +45,9 @@ FREERTOS_PORT = ARM_CM7/r0p1
# For flash-jlink target
JLINK_DEVICE = MIMXRT1062xxx6A
JLINK_IF = swd
# flash by copying bin file to DAP Mass Storage
flash: $(BUILD)/$(BOARD)-firmware.bin
cp $< /media/$(USER)/RT1060-EVK/
# For flash-pyocd target
PYOCD_TARGET = mimxrt1060
# flash using pyocd
flash: flash-pyocd

View File

@ -45,8 +45,9 @@ FREERTOS_PORT = ARM_CM7/r0p1
# For flash-jlink target
JLINK_DEVICE = MIMXRT1064xxx6A
JLINK_IF = swd
# flash by copying bin file to DAP Mass Storage
flash: $(BUILD)/$(BOARD)-firmware.bin
cp $< /media/$(USER)/RT1064-EVK/
# For flash-pyocd target
PYOCD_TARGET = mimxrt1064
# flash using pyocd
flash: flash-pyocd

View File

@ -48,7 +48,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = nRF52840_xxAA
JLINK_IF = swd
# flash using Nordic nrfutil (pip2 install nrfutil)
# make BOARD=nrf52840_mdk_dongle SERIAL=/dev/ttyACM0 all flash

View File

@ -49,7 +49,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = NUC121SC2AE
JLINK_IF = swd
# Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton
# Please compile and install it from github source

View File

@ -33,7 +33,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = NUC125SC2AE
JLINK_IF = swd
# Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton
# Please compile and install it from github source

View File

@ -53,7 +53,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = NUC126VG4AE
JLINK_IF = swd
# Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton
# Please compile and install it from github source

View File

@ -49,7 +49,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = NUC120LE3
JLINK_IF = swd
# Flash using Nuvoton's openocd fork at https://github.com/OpenNuvoton/OpenOCD-Nuvoton
# Please compile and install it from github source

View File

@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = NUC505YO13Y
JLINK_IF = swd
# Note
# To be able to program the SPI flash, it need to boot with ICP mode "1011".

View File

@ -50,7 +50,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = nRF52840_xxAA
JLINK_IF = swd
# flash using jlink
flash: flash-jlink

View File

@ -49,7 +49,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = nRF52840_xxAA
JLINK_IF = swd
# flash using Nordic nrfutil (pip2 install nrfutil)
# make BOARD=pca10059 SERIAL=/dev/ttyACM0 all flash

View File

@ -50,7 +50,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = nRF52833_XXAA
JLINK_IF = swd
# flash using jlink
flash: flash-jlink

View File

@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = stm32f405rg
JLINK_IF = swd
# flash target using on-board stlink
flash: flash-stlink

View File

@ -48,7 +48,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = nRF52840_xxAA
JLINK_IF = swd
# flash using jlink
flash: flash-jlink

View File

@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = ATSAMD11D14
JLINK_IF = swd
# flash using edbg
flash: $(BUILD)/$(BOARD)-firmware.bin

View File

@ -47,7 +47,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = ATSAMG55J19
JLINK_IF = swd
# flash using edbg from https://github.com/ataradov/edbg
flash: $(BUILD)/$(BOARD)-firmware.bin

View File

@ -39,7 +39,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = ATSAMD21G18
JLINK_IF = swd
# flash using jlink
flash: flash-jlink

View File

@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = stm32f070rb
JLINK_IF = swd
# flash target using on-board stlink
flash: flash-stlink

View File

@ -45,7 +45,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = stm32f072rb
JLINK_IF = swd
# flash target using on-board stlink
flash: flash-stlink

View File

@ -43,7 +43,6 @@ FREERTOS_PORT = ARM_CM3
# For flash-jlink target
JLINK_DEVICE = stm32f103c8
JLINK_IF = swd
# flash target ROM bootloader
flash: $(BUILD)/$(BOARD)-firmware.bin

View File

@ -43,7 +43,6 @@ FREERTOS_PORT = ARM_CM3
# For flash-jlink target
JLINK_DEVICE = stm32f207zg
JLINK_IF = swd
# flash target using on-board stlink
flash: flash-stlink

View File

@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = stm32f303vc
JLINK_IF = swd
# flash target using on-board stlink
flash: flash-stlink

View File

@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = stm32f401cc
JLINK_IF = swd
# flash target ROM bootloader
flash: $(BUILD)/$(BOARD)-firmware.bin

View File

@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = stm32f407vg
JLINK_IF = swd
# flash target using on-board stlink
flash: flash-stlink

View File

@ -40,7 +40,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = stm32f411ce
JLINK_IF = swd
# flash target ROM bootloader
flash: $(BUILD)/$(BOARD)-firmware.bin

View File

@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = stm32f411ve
JLINK_IF = swd
# flash target using on-board stlink
flash: flash-stlink

View File

@ -45,7 +45,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = stm32f41zx
JLINK_IF = swd
# flash target using on-board stlink
flash: flash-stlink

View File

@ -57,7 +57,6 @@ FREERTOS_PORT = ARM_CM7/r0p1
# For flash-jlink target
JLINK_DEVICE = stm32h743xi
JLINK_IF = swd
# flash target using on-board stlink
flash: flash-stlink

View File

@ -52,7 +52,6 @@ FREERTOS_PORT = ARM_CM7/r0p1
# For flash-jlink target
JLINK_DEVICE = stm32h745xi
JLINK_IF = swd
# flash target using on-board stlink
flash: flash-stlink

View File

@ -44,7 +44,6 @@ FREERTOS_PORT = ARM_CM0
# For flash-jlink target
JLINK_DEVICE = STM32L053R8
JLINK_IF = swd
# Path to STM32 Cube Programmer CLI, should be added into system path
STM32Prog = STM32_Programmer_CLI

View File

@ -43,7 +43,6 @@ FREERTOS_PORT = ARM_CM4F
# For flash-jlink target
JLINK_DEVICE = stm32l476vg
JLINK_IF = swd
# Path to STM32 Cube Programmer CLI, should be added into system path
STM32Prog = STM32_Programmer_CLI

View File

@ -45,7 +45,6 @@ FREERTOS_PORT = ARM_CM7/r0p1
# For flash-jlink target
JLINK_DEVICE = MIMXRT1062xxx6A
JLINK_IF = swd
# flash by using teensy_loader_cli https://github.com/PaulStoffregen/teensy_loader_cli
# Make sure it is in your PATH

View File

@ -57,17 +57,7 @@ typedef struct
CFG_TUSB_MEM_SECTION static hidd_interface_t _hidd_itf[CFG_TUD_HID];
/*------------- Helpers -------------*/
static inline hidd_interface_t* get_interface_by_itfnum(uint8_t itf_num)
{
for (uint8_t i=0; i < CFG_TUD_HID; i++ )
{
if ( itf_num == _hidd_itf[i].itf_num ) return &_hidd_itf[i];
}
return NULL;
}
static inline uint8_t get_hid_index_by_itfnum(uint8_t itf_num)
static inline uint8_t get_index_by_itfnum(uint8_t itf_num)
{
for (uint8_t i=0; i < CFG_TUD_HID; i++ )
{
@ -227,13 +217,10 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request
{
TU_VERIFY(request->bmRequestType_bit.recipient == TUSB_REQ_RCPT_INTERFACE);
hidd_interface_t* p_hid = get_interface_by_itfnum( (uint8_t) request->wIndex );
TU_ASSERT(p_hid);
uint8_t const hid_itf = get_index_by_itfnum((uint8_t) request->wIndex);
TU_VERIFY(hid_itf < CFG_TUD_HID);
#if CFG_TUD_HID>1
uint8_t const hid_itf = get_hid_index_by_itfnum((uint8_t) request->wIndex);
TU_VERIFY(hid_itf<0xFF);
#endif
hidd_interface_t* p_hid = &_hidd_itf[hid_itf];
if (request->bmRequestType_bit.type == TUSB_REQ_TYPE_STANDARD)
{
@ -249,11 +236,11 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request
}
else if (request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT)
{
#if CFG_TUD_HID>1
uint8_t const * desc_report = tud_hid_n_descriptor_report_cb(hid_itf);
#else
uint8_t const * desc_report = tud_hid_descriptor_report_cb();
#endif
uint8_t const * desc_report = tud_hid_descriptor_report_cb(
#if CFG_TUD_HID > 1
hid_itf // TODO for backward compatible callback, remove later when appropriate
#endif
);
tud_control_xfer(rhport, request, (void*) desc_report, p_hid->report_desc_len);
}
else
@ -272,11 +259,12 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request
uint8_t const report_type = tu_u16_high(request->wValue);
uint8_t const report_id = tu_u16_low(request->wValue);
#if CFG_TUD_HID>1
uint16_t xferlen = tud_hid_n_get_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength);
#else
uint16_t xferlen = tud_hid_get_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength);
#endif
uint16_t xferlen = tud_hid_get_report_cb(
#if CFG_TUD_HID > 1
hid_itf, // TODO for backward compatible callback, remove later when appropriate
#endif
report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength
);
TU_ASSERT( xferlen > 0 );
tud_control_xfer(rhport, request, p_hid->epin_buf, xferlen);
@ -293,7 +281,12 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request
if ( tud_hid_set_idle_cb )
{
// stall request if callback return false
if ( !tud_hid_set_idle_cb(p_hid->idle_rate) ) return false;
TU_VERIFY( tud_hid_set_idle_cb(
#if CFG_TUD_HID > 1
hid_itf, // TODO for backward compatible callback, remove later when appropriate
#endif
p_hid->idle_rate)
);
}
tud_control_status(rhport, request);
@ -314,7 +307,15 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request
case HID_REQ_CONTROL_SET_PROTOCOL:
p_hid->boot_mode = 1 - request->wValue; // 0 is Boot, 1 is Report protocol
if (tud_hid_boot_mode_cb) tud_hid_boot_mode_cb(p_hid->boot_mode);
if (tud_hid_boot_mode_cb)
{
tud_hid_boot_mode_cb(
#if CFG_TUD_HID > 1
hid_itf, // TODO for backward compatible callback, remove later when appropriate
#endif
p_hid->boot_mode
);
}
tud_control_status(rhport, request);
break;
@ -334,8 +335,11 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request
bool hidd_control_complete(uint8_t rhport, tusb_control_request_t const * p_request)
{
(void) rhport;
hidd_interface_t* p_hid = get_interface_by_itfnum( (uint8_t) p_request->wIndex );
TU_ASSERT(p_hid);
uint8_t const hid_itf = get_index_by_itfnum((uint8_t) p_request->wIndex);
TU_VERIFY(hid_itf < CFG_TUD_HID);
hidd_interface_t* p_hid = &_hidd_itf[hid_itf];
if (p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS &&
p_request->bRequest == HID_REQ_CONTROL_SET_REPORT)
@ -344,13 +348,12 @@ bool hidd_control_complete(uint8_t rhport, tusb_control_request_t const * p_requ
uint8_t const report_type = tu_u16_high(p_request->wValue);
uint8_t const report_id = tu_u16_low(p_request->wValue);
#if CFG_TUD_HID>1
uint8_t const hid_itf = get_hid_index_by_itfnum((uint8_t)p_request->wIndex);
TU_VERIFY(hid_itf<0xFF);
tud_hid_n_set_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength);
#else
tud_hid_set_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength);
#endif
tud_hid_set_report_cb(
#if CFG_TUD_HID > 1
hid_itf, // TODO for backward compatible callback, remove later when appropriate
#endif
report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength
);
}
return true;
@ -372,11 +375,12 @@ bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
if (ep_addr == p_hid->ep_out)
{
#if CFG_TUD_HID>1
tud_hid_n_set_report_cb(itf, 0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes);
#else
tud_hid_set_report_cb(0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes);
#endif
tud_hid_set_report_cb(
#if CFG_TUD_HID > 1
itf, // TODO for backward compatible callback, remove later when appropriate
#endif
0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes
);
TU_ASSERT(usbd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf)));
}

View File

@ -84,39 +84,42 @@ static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8
// Callbacks (Weak is optional)
//--------------------------------------------------------------------+
#if CFG_TUD_HID > 1
// Invoked when received GET HID REPORT DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
#if CFG_TUD_HID>1
uint8_t const * tud_hid_n_descriptor_report_cb(uint8_t itf);
#else
uint8_t const * tud_hid_descriptor_report_cb(void);
#endif
uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf);
// Invoked when received GET_REPORT control request
// Application must fill buffer report's content and return its length.
// Return zero will cause the stack to STALL request
#if CFG_TUD_HID>1
uint16_t tud_hid_n_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
#else
uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
#endif
uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
// Invoked when received SET_REPORT control request or
// received data on OUT endpoint ( Report ID = 0, Type = 0 )
#if CFG_TUD_HID>1
void tud_hid_n_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
#else
void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
#endif
void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
// Invoked when received SET_PROTOCOL request ( mode switch Boot <-> Report )
TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t itf, uint8_t boot_mode);
// Invoked when received SET_IDLE request. return false will stall the request
// - Idle Rate = 0 : only send report if there is changes, i.e skip duplication
// - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms).
TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t itf, uint8_t idle_rate);
#else
// TODO for backward compatible callback, remove later when appropriate
uint8_t const * tud_hid_descriptor_report_cb(void);
uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate);
#endif
//--------------------------------------------------------------------+
// Inline Functions
//--------------------------------------------------------------------+