mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-19 06:40:45 +00:00
- update nrf52 bsp for cmake
- add empty tuh_int_handler/tud_int_handler if corresponidng stack not enabled - add hcd_template.c
This commit is contained in:
parent
1fdf29075d
commit
9257a0f562
5
hw/bsp/nrf/boards/adafruit_clue/board.cmake
Normal file
5
hw/bsp/nrf/boards/adafruit_clue/board.cmake
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
set(MCU_VARIANT nrf52840)
|
||||||
|
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/../../linker/nrf52840_s140_v6.ld)
|
||||||
|
|
||||||
|
function(update_board TARGET)
|
||||||
|
endfunction()
|
5
hw/bsp/nrf/boards/arduino_nano33_ble/board.cmake
Normal file
5
hw/bsp/nrf/boards/arduino_nano33_ble/board.cmake
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
set(MCU_VARIANT nrf52840)
|
||||||
|
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/arduino_nano33_ble.ld)
|
||||||
|
|
||||||
|
function(update_board TARGET)
|
||||||
|
endfunction()
|
@ -0,0 +1,5 @@
|
|||||||
|
set(MCU_VARIANT nrf52840)
|
||||||
|
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/../../linker/nrf52840_s140_v6.ld)
|
||||||
|
|
||||||
|
function(update_board TARGET)
|
||||||
|
endfunction()
|
6
hw/bsp/nrf/boards/feather_nrf52840_express/board.cmake
Normal file
6
hw/bsp/nrf/boards/feather_nrf52840_express/board.cmake
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
set(MCU_VARIANT nrf52840)
|
||||||
|
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/../../linker/nrf52840_s140_v6.ld)
|
||||||
|
# set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf52840_xxaa.ld)
|
||||||
|
|
||||||
|
function(update_board TARGET)
|
||||||
|
endfunction()
|
5
hw/bsp/nrf/boards/feather_nrf52840_sense/board.cmake
Normal file
5
hw/bsp/nrf/boards/feather_nrf52840_sense/board.cmake
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
set(MCU_VARIANT nrf52840)
|
||||||
|
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/../../linker/nrf52840_s140_v6.ld)
|
||||||
|
|
||||||
|
function(update_board TARGET)
|
||||||
|
endfunction()
|
5
hw/bsp/nrf/boards/itsybitsy_nrf52840/board.cmake
Normal file
5
hw/bsp/nrf/boards/itsybitsy_nrf52840/board.cmake
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
set(MCU_VARIANT nrf52840)
|
||||||
|
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/../../linker/nrf52840_s140_v6.ld)
|
||||||
|
|
||||||
|
function(update_board TARGET)
|
||||||
|
endfunction()
|
5
hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.cmake
Normal file
5
hw/bsp/nrf/boards/nrf52840_mdk_dongle/board.cmake
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
set(MCU_VARIANT nrf52840)
|
||||||
|
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/nrf52840_mdk_dongle.ld)
|
||||||
|
|
||||||
|
function(update_board TARGET)
|
||||||
|
endfunction()
|
@ -2,7 +2,4 @@ set(MCU_VARIANT nrf52840)
|
|||||||
set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf52840_xxaa.ld)
|
set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf52840_xxaa.ld)
|
||||||
|
|
||||||
function(update_board TARGET)
|
function(update_board TARGET)
|
||||||
target_compile_definitions(${TARGET} PUBLIC
|
|
||||||
NRF52840_XXAA
|
|
||||||
)
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
5
hw/bsp/nrf/boards/pca10059/board.cmake
Normal file
5
hw/bsp/nrf/boards/pca10059/board.cmake
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
set(MCU_VARIANT nrf52840)
|
||||||
|
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/pca10059.ld)
|
||||||
|
|
||||||
|
function(update_board TARGET)
|
||||||
|
endfunction()
|
@ -2,10 +2,6 @@ set(MCU_VARIANT nrf5340_application)
|
|||||||
set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf5340_xxaa_application.ld)
|
set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf5340_xxaa_application.ld)
|
||||||
|
|
||||||
function(update_board TARGET)
|
function(update_board TARGET)
|
||||||
target_compile_definitions(${TARGET} PUBLIC
|
|
||||||
NRF5340_XXAA
|
|
||||||
NRF5340_XXAA_APPLICATION
|
|
||||||
)
|
|
||||||
target_sources(${TARGET} PRIVATE
|
target_sources(${TARGET} PRIVATE
|
||||||
${NRFX_DIR}/drivers/src/nrfx_usbreg.c
|
${NRFX_DIR}/drivers/src/nrfx_usbreg.c
|
||||||
)
|
)
|
||||||
|
5
hw/bsp/nrf/boards/pca10100/board.cmake
Normal file
5
hw/bsp/nrf/boards/pca10100/board.cmake
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
set(MCU_VARIANT nrf52833)
|
||||||
|
set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf52833_xxaa.ld)
|
||||||
|
|
||||||
|
function(update_board TARGET)
|
||||||
|
endfunction()
|
5
hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.cmake
Normal file
5
hw/bsp/nrf/boards/raytac_mdbt50q_rx/board.cmake
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
set(MCU_VARIANT nrf52840)
|
||||||
|
set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf52840_xxaa.ld)
|
||||||
|
|
||||||
|
function(update_board TARGET)
|
||||||
|
endfunction()
|
@ -33,13 +33,20 @@ function(add_board_target BOARD_TARGET)
|
|||||||
add_library(${BOARD_TARGET} STATIC
|
add_library(${BOARD_TARGET} STATIC
|
||||||
# driver
|
# driver
|
||||||
${NRFX_DIR}/drivers/src/nrfx_power.c
|
${NRFX_DIR}/drivers/src/nrfx_power.c
|
||||||
|
${NRFX_DIR}/drivers/src/nrfx_spim.c
|
||||||
${NRFX_DIR}/drivers/src/nrfx_uarte.c
|
${NRFX_DIR}/drivers/src/nrfx_uarte.c
|
||||||
# mcu
|
# mcu
|
||||||
${NRFX_DIR}/mdk/system_${MCU_VARIANT}.c
|
${NRFX_DIR}/mdk/system_${MCU_VARIANT}.c
|
||||||
)
|
)
|
||||||
target_compile_definitions(${BOARD_TARGET} PUBLIC
|
target_compile_definitions(${BOARD_TARGET} PUBLIC CONFIG_GPIO_AS_PINRESET)
|
||||||
CONFIG_GPIO_AS_PINRESET
|
|
||||||
)
|
if (MCU_VARIANT STREQUAL "nrf52840")
|
||||||
|
target_compile_definitions(${BOARD_TARGET} PUBLIC NRF52840_XXAA)
|
||||||
|
elseif (MCU_VARIANT STREQUAL "nrf52833")
|
||||||
|
target_compile_definitions(${BOARD_TARGET} PUBLIC NRF52833_XXAA)
|
||||||
|
elseif (MCU_VARIANT STREQUAL "nrf5340_application")
|
||||||
|
target_compile_definitions(${BOARD_TARGET} PUBLIC NRF5340_XXAA NRF5340_XXAA_APPLICATION)
|
||||||
|
endif ()
|
||||||
|
|
||||||
if (TRACE_ETM STREQUAL "1")
|
if (TRACE_ETM STREQUAL "1")
|
||||||
# ENABLE_TRACE will cause system_nrf5x.c to set up ETM trace
|
# ENABLE_TRACE will cause system_nrf5x.c to set up ETM trace
|
||||||
@ -115,6 +122,7 @@ function(family_configure_example TARGET RTOS)
|
|||||||
family_add_tinyusb(${TARGET} OPT_MCU_NRF5X ${RTOS})
|
family_add_tinyusb(${TARGET} OPT_MCU_NRF5X ${RTOS})
|
||||||
target_sources(${TARGET}-tinyusb PUBLIC
|
target_sources(${TARGET}-tinyusb PUBLIC
|
||||||
${TOP}/src/portable/nordic/nrf5x/dcd_nrf5x.c
|
${TOP}/src/portable/nordic/nrf5x/dcd_nrf5x.c
|
||||||
|
#${TOP}/src/portable/analog/max3421e/hcd_max3421e.c
|
||||||
)
|
)
|
||||||
target_link_libraries(${TARGET}-tinyusb PUBLIC board_${BOARD})
|
target_link_libraries(${TARGET}-tinyusb PUBLIC board_${BOARD})
|
||||||
|
|
||||||
|
@ -50,8 +50,7 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr);
|
|||||||
|
|
||||||
// Task function should be called in main/rtos loop
|
// Task function should be called in main/rtos loop
|
||||||
TU_ATTR_ALWAYS_INLINE static inline
|
TU_ATTR_ALWAYS_INLINE static inline
|
||||||
void tud_task (void)
|
void tud_task (void) {
|
||||||
{
|
|
||||||
tud_task_ext(UINT32_MAX, false);
|
tud_task_ext(UINT32_MAX, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,8 +79,7 @@ bool tud_suspended(void);
|
|||||||
|
|
||||||
// Check if device is ready to transfer
|
// Check if device is ready to transfer
|
||||||
TU_ATTR_ALWAYS_INLINE static inline
|
TU_ATTR_ALWAYS_INLINE static inline
|
||||||
bool tud_ready(void)
|
bool tud_ready(void) {
|
||||||
{
|
|
||||||
return tud_mounted() && !tud_suspended();
|
return tud_mounted() && !tud_suspended();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,8 +198,7 @@ extern void hcd_event_handler(hcd_event_t const* event, bool in_isr);
|
|||||||
|
|
||||||
// Helper to send device attach event
|
// Helper to send device attach event
|
||||||
TU_ATTR_ALWAYS_INLINE static inline
|
TU_ATTR_ALWAYS_INLINE static inline
|
||||||
void hcd_event_device_attach(uint8_t rhport, bool in_isr)
|
void hcd_event_device_attach(uint8_t rhport, bool in_isr) {
|
||||||
{
|
|
||||||
hcd_event_t event;
|
hcd_event_t event;
|
||||||
event.rhport = rhport;
|
event.rhport = rhport;
|
||||||
event.event_id = HCD_EVENT_DEVICE_ATTACH;
|
event.event_id = HCD_EVENT_DEVICE_ATTACH;
|
||||||
@ -211,8 +210,7 @@ void hcd_event_device_attach(uint8_t rhport, bool in_isr)
|
|||||||
|
|
||||||
// Helper to send device removal event
|
// Helper to send device removal event
|
||||||
TU_ATTR_ALWAYS_INLINE static inline
|
TU_ATTR_ALWAYS_INLINE static inline
|
||||||
void hcd_event_device_remove(uint8_t rhport, bool in_isr)
|
void hcd_event_device_remove(uint8_t rhport, bool in_isr) {
|
||||||
{
|
|
||||||
hcd_event_t event;
|
hcd_event_t event;
|
||||||
event.rhport = rhport;
|
event.rhport = rhport;
|
||||||
event.event_id = HCD_EVENT_DEVICE_REMOVE;
|
event.event_id = HCD_EVENT_DEVICE_REMOVE;
|
||||||
@ -224,10 +222,8 @@ void hcd_event_device_remove(uint8_t rhport, bool in_isr)
|
|||||||
|
|
||||||
// Helper to send USB transfer event
|
// Helper to send USB transfer event
|
||||||
TU_ATTR_ALWAYS_INLINE static inline
|
TU_ATTR_ALWAYS_INLINE static inline
|
||||||
void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, uint32_t xferred_bytes, xfer_result_t result, bool in_isr)
|
void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, uint32_t xferred_bytes, xfer_result_t result, bool in_isr) {
|
||||||
{
|
hcd_event_t event = {
|
||||||
hcd_event_t event =
|
|
||||||
{
|
|
||||||
.rhport = 0, // TODO correct rhport
|
.rhport = 0, // TODO correct rhport
|
||||||
.event_id = HCD_EVENT_XFER_COMPLETE,
|
.event_id = HCD_EVENT_XFER_COMPLETE,
|
||||||
.dev_addr = dev_addr,
|
.dev_addr = dev_addr,
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "tusb_option.h"
|
#include "tusb_option.h"
|
||||||
|
|
||||||
#if CFG_TUSB_MCU == OPT_MCU_NONE
|
#if CFG_TUD_ENABLED && CFG_TUSB_MCU == OPT_MCU_NONE
|
||||||
|
|
||||||
#include "device/dcd.h"
|
#include "device/dcd.h"
|
||||||
|
|
||||||
@ -141,4 +141,6 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
|
|||||||
(void) ep_addr;
|
(void) ep_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
162
src/portable/template/hcd_template.c
Normal file
162
src/portable/template/hcd_template.c
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Ha Thach (tinyusb.org)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* This file is part of the TinyUSB stack.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tusb_option.h"
|
||||||
|
|
||||||
|
#if CFG_TUH_ENABLED && CFG_TUSB_MCU == OPT_MCU_NONE
|
||||||
|
|
||||||
|
#include "host/hcd.h"
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// Controller API
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// optional hcd configuration, called by tuh_configure()
|
||||||
|
bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param) {
|
||||||
|
(void) rhport;
|
||||||
|
(void) cfg_id;
|
||||||
|
(void) cfg_param;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize controller to host mode
|
||||||
|
bool hcd_init(uint8_t rhport) {
|
||||||
|
(void) rhport;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interrupt Handler
|
||||||
|
void hcd_int_handler(uint8_t rhport) {
|
||||||
|
(void) rhport;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable USB interrupt
|
||||||
|
void hcd_int_enable (uint8_t rhport) {
|
||||||
|
(void) rhport;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable USB interrupt
|
||||||
|
void hcd_int_disable(uint8_t rhport) {
|
||||||
|
(void) rhport;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get frame number (1ms)
|
||||||
|
uint32_t hcd_frame_number(uint8_t rhport) {
|
||||||
|
(void) rhport;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// Port API
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// Get the current connect status of roothub port
|
||||||
|
bool hcd_port_connect_status(uint8_t rhport) {
|
||||||
|
(void) rhport;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset USB bus on the port. Return immediately, bus reset sequence may not be complete.
|
||||||
|
// Some port would require hcd_port_reset_end() to be invoked after 10ms to complete the reset sequence.
|
||||||
|
void hcd_port_reset(uint8_t rhport) {
|
||||||
|
(void) rhport;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Complete bus reset sequence, may be required by some controllers
|
||||||
|
void hcd_port_reset_end(uint8_t rhport) {
|
||||||
|
(void) rhport;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get port link speed
|
||||||
|
tusb_speed_t hcd_port_speed_get(uint8_t rhport) {
|
||||||
|
(void) rhport;
|
||||||
|
|
||||||
|
return TUSB_SPEED_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// HCD closes all opened endpoints belong to this device
|
||||||
|
void hcd_device_close(uint8_t rhport, uint8_t dev_addr) {
|
||||||
|
(void) rhport;
|
||||||
|
(void) dev_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// Endpoints API
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// Open an endpoint
|
||||||
|
bool hcd_edpt_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_endpoint_t const * ep_desc) {
|
||||||
|
(void) rhport;
|
||||||
|
(void) dev_addr;
|
||||||
|
(void) ep_desc;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Submit a transfer, when complete hcd_event_xfer_complete() must be invoked
|
||||||
|
bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_t buflen) {
|
||||||
|
(void) rhport;
|
||||||
|
(void) dev_addr;
|
||||||
|
(void) ep_addr;
|
||||||
|
(void) buffer;
|
||||||
|
(void) buflen;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Abort a queued transfer. Note: it can only abort transfer that has not been started
|
||||||
|
// Return true if a queued transfer is aborted, false if there is no transfer to abort
|
||||||
|
bool hcd_edpt_abort_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr) {
|
||||||
|
(void) rhport;
|
||||||
|
(void) dev_addr;
|
||||||
|
(void) ep_addr;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Submit a special transfer to send 8-byte Setup Packet, when complete hcd_event_xfer_complete() must be invoked
|
||||||
|
bool hcd_setup_send(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet[8]) {
|
||||||
|
(void) rhport;
|
||||||
|
(void) dev_addr;
|
||||||
|
(void) setup_packet;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// clear stall, data toggle is also reset to DATA0
|
||||||
|
bool hcd_edpt_clear_stall(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr) {
|
||||||
|
(void) rhport;
|
||||||
|
(void) dev_addr;
|
||||||
|
(void) ep_addr;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -64,7 +64,10 @@
|
|||||||
#if CFG_TUH_VENDOR
|
#if CFG_TUH_VENDOR
|
||||||
#include "class/vendor/vendor_host.h"
|
#include "class/vendor/vendor_host.h"
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#ifndef tuh_int_handler
|
||||||
|
#define tuh_int_handler(_x)
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//------------- DEVICE -------------//
|
//------------- DEVICE -------------//
|
||||||
@ -118,6 +121,10 @@
|
|||||||
#if CFG_TUD_BTH
|
#if CFG_TUD_BTH
|
||||||
#include "class/bth/bth_device.h"
|
#include "class/bth/bth_device.h"
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#ifndef tud_int_handler
|
||||||
|
#define tud_int_handler(_x)
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user