update to use sdk 1.2.0

This commit is contained in:
Triss 2021-06-13 20:07:54 +02:00
parent 9f77e9764b
commit 4de8c00613
6 changed files with 31 additions and 25 deletions

View File

@ -18,14 +18,21 @@ if(FAMILY STREQUAL "rp2040")
cmake_minimum_required(VERSION 3.12)
if (USE_SYSTEMWIDE_PICOSDK)
set(TOP "$ENV{PICO_SDK_PATH}/lib/tinyusb")
get_filename_component(TOP "${TOP}" REALPATH)
include(pico_sdk_import.cmake)
else()
set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk)
include(${PICO_SDK_PATH}/pico_sdk_init.cmake)
endif()
include(${TOP}/hw/bsp/${FAMILY}/family.cmake) # tinyusb stuff
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
project(${PROJECT})
pico_sdk_init()
family_initialize_project(PROJECT ${CMAKE_CURRENT_LIST_DIR}) # calls pico_sdk_init()
#pico_sdk_init()
add_executable(${PROJECT})
# need uart stdio, usb is busy doing other stuff
@ -38,7 +45,6 @@ if(FAMILY STREQUAL "rp2040")
endif()
pico_enable_stdio_usb(${PROJECT} 0)
# Example source
target_sources(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/main.c
${CMAKE_CURRENT_SOURCE_DIR}/usb_descriptors.c
@ -53,7 +59,6 @@ if(FAMILY STREQUAL "rp2040")
${CMAKE_CURRENT_SOURCE_DIR}/cdc_serprog.c
${CMAKE_CURRENT_SOURCE_DIR}/rtconf.c
)
# Example include
target_include_directories(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/
${CMAKE_CURRENT_SOURCE_DIR}/libco/
@ -63,16 +68,9 @@ if(FAMILY STREQUAL "rp2040")
${CMAKE_CURRENT_SOURCE_DIR}/bsp/default/
)
# need to do this AFTER the regular includes, so that our bsp folder can
# override the tinyusb board.h header
include(${TOP}/hw/bsp/${FAMILY}/family.cmake) # tinyusb hardware-specific stuff
# Example defines
#target_compile_definitions(${PROJECT} PUBLIC
#)
target_link_libraries(${PROJECT} pico_stdlib pico_unique_id hardware_spi
pico_fix_rp2040_usb_device_enumeration)
pico_fix_rp2040_usb_device_enumeration
tinyusb_device tinyusb_board tinyusb_additions)
if(USE_USBCDC_FOR_STDIO)
target_sources(${PROJECT} PUBLIC
@ -84,8 +82,10 @@ if(FAMILY STREQUAL "rp2040")
)
# extremely ugly hack to prevent the Pico SDK to declare *its* TinyUSB config
# and also to modify the tinyusb board.h file a bit
target_compile_definitions(${PROJECT} PUBLIC
_PICO_STDIO_USB_TUSB_CONFIG_H=1
BOARD_H_=1
)
target_link_libraries(${PROJECT} pico_stdio)

View File

@ -24,24 +24,26 @@
* This file is part of the TinyUSB stack.
*/
#ifndef BOARD_H_
#define BOARD_H_
#ifndef BOARD_H_MOD
#define BOARD_H_MOD
#ifdef __cplusplus
extern "C" {
#endif
#ifdef PICO_DEFAULT_LED_PIN
#define LED_PIN PICO_DEFAULT_LED_PIN
#define LED_STATE_ON 1
#define LED_STATE_ON (!(PICO_DEFAULT_LED_PIN_INVERTED))
#endif
// Button pin is BOOTSEL which is flash CS pin
#define BUTTON_BOOTSEL
#define BUTTON_STATE_ACTIVE 0
#ifndef USE_USBCDC_FOR_STDIO
#define UART_DEV uart0
#define UART_TX_PIN 0
#define UART_RX_PIN 1
#if !defined(USE_USBCDC_FOR_STDIO) && defined(PICO_DEFAULT_UART_TX_PIN) && defined(PICO_DEFAULT_UART_RX_PIN) && defined(PICO_DEFAULT_UART)
#define UART_DEV PICO_DEFAULT_UART
#define UART_TX_PIN PICO_DEFAULT_UART_TX_PIN
#define UART_RX_PIN PICO_DEFAULT_UART_RX_PIN
#endif
#ifdef __cplusplus

View File

@ -107,7 +107,7 @@ def main():
for k, v in option_table.items():
if args.__dict__[k] is not None:
resp = do_xfer(args, v.optid, val2byte(v.type, args.__dict__[k]), args.tty)
resp = do_xfer(args, v.optid, val2byte(v.type, args.__dict__[k]), args.tty[0])
if resp is None:
return 1
if args.verbose: print("-> %d" % resp)

6
main.c
View File

@ -152,9 +152,10 @@ int main(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_get_report_cb(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 instance, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
{
// TODO not Implemented
(void) instance;
(void) report_id;
(void) report_type;
(void) buffer;
@ -163,12 +164,13 @@ uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type,
return 0;
}
void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* RxDataBuffer, uint16_t bufsize)
void tud_hid_set_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t const* RxDataBuffer, uint16_t bufsize)
{
static uint8_t TxDataBuffer[CFG_TUD_HID_EP_BUFSIZE];
uint32_t response_size = TU_MIN(CFG_TUD_HID_EP_BUFSIZE, bufsize);
// This doesn't use multiple report and report ID
(void) instance;
(void) report_id;
(void) report_type;

@ -1 +1 @@
Subproject commit 09868434cd9f53394350cce682333ada97f796c3
Subproject commit d49938d0f5052bce70e55c652b657c0a6a7e84fe

View File

@ -90,8 +90,10 @@ static uint8_t const desc_hid_report[] =
// 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_descriptor_report_cb(void)
uint8_t const * tud_hid_descriptor_report_cb(uint8_t instance)
{
(void) instance;
return desc_hid_report;
}
@ -164,7 +166,7 @@ uint8_t const desc_configuration[] =
#ifdef DBOARD_HAS_CMSISDAP
// Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval
TUD_HID_INOUT_DESCRIPTOR(ITF_NUM_HID_CMSISDAP, 0, HID_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID_CMSISDAP, 0x80 | (EPNUM_HID_CMSISDAP+0), CFG_TUD_HID_EP_BUFSIZE, 1),
TUD_HID_INOUT_DESCRIPTOR(ITF_NUM_HID_CMSISDAP, 0, 0/*HID_PROTOCOL_NONE*/, sizeof(desc_hid_report), EPNUM_HID_CMSISDAP, 0x80 | (EPNUM_HID_CMSISDAP+0), CFG_TUD_HID_EP_BUFSIZE, 1),
#endif
#ifdef DBOARD_HAS_SERPROG