mirror of
https://github.com/hrvach/deskhop.git
synced 2025-08-18 16:38:37 +02:00
- add windows workaround
- add mouse acceleration (configurable in user_config.h) - add keyboard shortcuts for output configuration - after several reports, bundling pico-sdk and tinyusb to simplify building - bugfixes
This commit is contained in:
97
pico-sdk/lib/tinyusb/hw/bsp/ansi_escape.h
Normal file
97
pico-sdk/lib/tinyusb/hw/bsp/ansi_escape.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 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.
|
||||
*/
|
||||
|
||||
/** \ingroup group_board
|
||||
* \defgroup group_ansi_esc ANSI Escape Code
|
||||
* @{ */
|
||||
|
||||
#ifndef _TUSB_ANSI_ESC_CODE_H_
|
||||
#define _TUSB_ANSI_ESC_CODE_H_
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CSI_CODE(seq) "\33[" seq
|
||||
#define CSI_SGR(x) CSI_CODE(#x) "m"
|
||||
|
||||
//------------- Cursor movement -------------//
|
||||
/** \defgroup group_ansi_cursor Cursor Movement
|
||||
* @{ */
|
||||
#define ANSI_CURSOR_UP(n) CSI_CODE(#n "A") ///< Move cursor up
|
||||
#define ANSI_CURSOR_DOWN(n) CSI_CODE(#n "B") ///< Move cursor down
|
||||
#define ANSI_CURSOR_FORWARD(n) CSI_CODE(#n "C") ///< Move cursor forward
|
||||
#define ANSI_CURSOR_BACKWARD(n) CSI_CODE(#n "D") ///< Move cursor backward
|
||||
#define ANSI_CURSOR_LINE_DOWN(n) CSI_CODE(#n "E") ///< Move cursor to the beginning of the line (n) down
|
||||
#define ANSI_CURSOR_LINE_UP(n) CSI_CODE(#n "F") ///< Move cursor to the beginning of the line (n) up
|
||||
#define ANSI_CURSOR_POSITION(n, m) CSI_CODE(#n ";" #m "H") ///< Move cursor to position (n, m)
|
||||
/** @} */
|
||||
|
||||
//------------- Screen -------------//
|
||||
/** \defgroup group_ansi_screen Screen Control
|
||||
* @{ */
|
||||
#define ANSI_ERASE_SCREEN(n) CSI_CODE(#n "J") ///< Erase the screen
|
||||
#define ANSI_ERASE_LINE(n) CSI_CODE(#n "K") ///< Erase the line (n)
|
||||
#define ANSI_SCROLL_UP(n) CSI_CODE(#n "S") ///< Scroll the whole page up (n) lines
|
||||
#define ANSI_SCROLL_DOWN(n) CSI_CODE(#n "T") ///< Scroll the whole page down (n) lines
|
||||
/** @} */
|
||||
|
||||
//------------- Text Color -------------//
|
||||
/** \defgroup group_ansi_text Text Color
|
||||
* @{ */
|
||||
#define ANSI_TEXT_BLACK CSI_SGR(30)
|
||||
#define ANSI_TEXT_RED CSI_SGR(31)
|
||||
#define ANSI_TEXT_GREEN CSI_SGR(32)
|
||||
#define ANSI_TEXT_YELLOW CSI_SGR(33)
|
||||
#define ANSI_TEXT_BLUE CSI_SGR(34)
|
||||
#define ANSI_TEXT_MAGENTA CSI_SGR(35)
|
||||
#define ANSI_TEXT_CYAN CSI_SGR(36)
|
||||
#define ANSI_TEXT_WHITE CSI_SGR(37)
|
||||
#define ANSI_TEXT_DEFAULT CSI_SGR(39)
|
||||
/** @} */
|
||||
|
||||
//------------- Background Color -------------//
|
||||
/** \defgroup group_ansi_background Background Color
|
||||
* @{ */
|
||||
#define ANSI_BG_BLACK CSI_SGR(40)
|
||||
#define ANSI_BG_RED CSI_SGR(41)
|
||||
#define ANSI_BG_GREEN CSI_SGR(42)
|
||||
#define ANSI_BG_YELLOW CSI_SGR(43)
|
||||
#define ANSI_BG_BLUE CSI_SGR(44)
|
||||
#define ANSI_BG_MAGENTA CSI_SGR(45)
|
||||
#define ANSI_BG_CYAN CSI_SGR(46)
|
||||
#define ANSI_BG_WHITE CSI_SGR(47)
|
||||
#define ANSI_BG_DEFAULT CSI_SGR(49)
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TUSB_ANSI_ESC_CODE_H_ */
|
||||
|
||||
/** @} */
|
114
pico-sdk/lib/tinyusb/hw/bsp/board.c
Normal file
114
pico-sdk/lib/tinyusb/hw/bsp/board.c
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018, hathach (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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "board_api.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// newlib read()/write() retarget
|
||||
//--------------------------------------------------------------------+
|
||||
#ifdef __ICCARM__
|
||||
#define sys_write __write
|
||||
#define sys_read __read
|
||||
#elif defined(__MSP430__) || defined(__RX__)
|
||||
#define sys_write write
|
||||
#define sys_read read
|
||||
#else
|
||||
#define sys_write _write
|
||||
#define sys_read _read
|
||||
#endif
|
||||
|
||||
#if defined(LOGGER_RTT)
|
||||
// Logging with RTT
|
||||
|
||||
// If using SES IDE, use the Syscalls/SEGGER_RTT_Syscalls_SES.c instead
|
||||
#if !(defined __SES_ARM) && !(defined __SES_RISCV) && !(defined __CROSSWORKS_ARM)
|
||||
#include "SEGGER_RTT.h"
|
||||
|
||||
TU_ATTR_USED int sys_write(int fhdl, const char *buf, size_t count) {
|
||||
(void) fhdl;
|
||||
SEGGER_RTT_Write(0, (const char *) buf, (int) count);
|
||||
return (int) count;
|
||||
}
|
||||
|
||||
TU_ATTR_USED int sys_read(int fhdl, char *buf, size_t count) {
|
||||
(void) fhdl;
|
||||
int rd = (int) SEGGER_RTT_Read(0, buf, count);
|
||||
return (rd > 0) ? rd : -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#elif defined(LOGGER_SWO)
|
||||
// Logging with SWO for ARM Cortex
|
||||
#include "board_mcu.h"
|
||||
|
||||
TU_ATTR_USED int sys_write (int fhdl, const char *buf, size_t count) {
|
||||
(void) fhdl;
|
||||
uint8_t const* buf8 = (uint8_t const*) buf;
|
||||
|
||||
for(size_t i=0; i<count; i++) {
|
||||
ITM_SendChar(buf8[i]);
|
||||
}
|
||||
|
||||
return (int) count;
|
||||
}
|
||||
|
||||
TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) {
|
||||
(void) fhdl;
|
||||
(void) buf;
|
||||
(void) count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// Default logging with on-board UART
|
||||
TU_ATTR_USED int sys_write (int fhdl, const char *buf, size_t count) {
|
||||
(void) fhdl;
|
||||
return board_uart_write(buf, (int) count);
|
||||
}
|
||||
|
||||
TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count) {
|
||||
(void) fhdl;
|
||||
int rd = board_uart_read((uint8_t*) buf, (int) count);
|
||||
return (rd > 0) ? rd : -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//TU_ATTR_USED int _close(int fhdl) {
|
||||
// (void) fhdl;
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
//TU_ATTR_USED int _fstat(int file, struct stat *st) {
|
||||
// memset(st, 0, sizeof(*st));
|
||||
// st->st_mode = S_IFCHR;
|
||||
//}
|
||||
|
||||
int board_getchar(void) {
|
||||
char c;
|
||||
return (sys_read(0, &c, 1) > 0) ? (int) c : (-1);
|
||||
}
|
172
pico-sdk/lib/tinyusb/hw/bsp/board_api.h
Normal file
172
pico-sdk/lib/tinyusb/hw/bsp/board_api.h
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 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.
|
||||
*/
|
||||
|
||||
#ifndef _BOARD_API_H_
|
||||
#define _BOARD_API_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "tusb.h"
|
||||
|
||||
// Define the default baudrate
|
||||
#ifndef CFG_BOARD_UART_BAUDRATE
|
||||
#define CFG_BOARD_UART_BAUDRATE 115200 ///< Default baud rate
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Board Porting API
|
||||
// For simplicity, only one LED and one Button are used
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Initialize on-board peripherals : led, button, uart and USB
|
||||
void board_init(void);
|
||||
|
||||
// Init board after tinyusb is initialized
|
||||
void board_init_after_tusb(void) TU_ATTR_WEAK;
|
||||
|
||||
// Turn LED on or off
|
||||
void board_led_write(bool state);
|
||||
|
||||
// Control led pattern using phase duration in ms.
|
||||
// For each phase, LED is toggle then repeated, board_led_task() is required to be called
|
||||
//void board_led_pattern(uint32_t const phase_ms[], uint8_t count);
|
||||
|
||||
// Get the current state of button
|
||||
// a '1' means active (pressed), a '0' means inactive.
|
||||
uint32_t board_button_read(void);
|
||||
|
||||
// Get board unique ID for USB serial number. Return number of bytes. Note max_len is typically 16
|
||||
TU_ATTR_WEAK size_t board_get_unique_id(uint8_t id[], size_t max_len);
|
||||
|
||||
// Get characters from UART. Return number of read bytes
|
||||
int board_uart_read(uint8_t *buf, int len);
|
||||
|
||||
// Send characters to UART. Return number of sent bytes
|
||||
int board_uart_write(void const *buf, int len);
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
// Get current milliseconds, must be implemented when no RTOS is used
|
||||
uint32_t board_millis(void);
|
||||
|
||||
#elif CFG_TUSB_OS == OPT_OS_FREERTOS
|
||||
static inline uint32_t board_millis(void) {
|
||||
return ( ( ((uint64_t) xTaskGetTickCount()) * 1000) / configTICK_RATE_HZ );
|
||||
}
|
||||
|
||||
#elif CFG_TUSB_OS == OPT_OS_MYNEWT
|
||||
static inline uint32_t board_millis(void) {
|
||||
return os_time_ticks_to_ms32( os_time_get() );
|
||||
}
|
||||
|
||||
#elif CFG_TUSB_OS == OPT_OS_PICO
|
||||
#include "pico/time.h"
|
||||
static inline uint32_t board_millis(void) {
|
||||
return to_ms_since_boot(get_absolute_time());
|
||||
}
|
||||
|
||||
#elif CFG_TUSB_OS == OPT_OS_RTTHREAD
|
||||
static inline uint32_t board_millis(void) {
|
||||
return (((uint64_t)rt_tick_get()) * 1000 / RT_TICK_PER_SECOND);
|
||||
}
|
||||
|
||||
#elif CFG_TUSB_OS == OPT_OS_CUSTOM
|
||||
// Implement your own board_millis() in any of .c file
|
||||
|
||||
#else
|
||||
#error "board_millis() is not implemented for this OS"
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Helper functions
|
||||
//--------------------------------------------------------------------+
|
||||
static inline void board_led_on(void) {
|
||||
board_led_write(true);
|
||||
}
|
||||
|
||||
static inline void board_led_off(void) {
|
||||
board_led_write(false);
|
||||
}
|
||||
|
||||
// Get USB Serial number string from unique ID if available. Return number of character.
|
||||
// Input is string descriptor from index 1 (index 0 is type + len)
|
||||
static inline size_t board_usb_get_serial(uint16_t desc_str1[], size_t max_chars) {
|
||||
uint8_t uid[16] TU_ATTR_ALIGNED(4);
|
||||
size_t uid_len;
|
||||
|
||||
if ( board_get_unique_id ) {
|
||||
uid_len = board_get_unique_id(uid, sizeof(uid));
|
||||
}else {
|
||||
// fixed serial string is 01234567889ABCDEF
|
||||
uint32_t* uid32 = (uint32_t*) (uintptr_t) uid;
|
||||
uid32[0] = 0x67452301;
|
||||
uid32[1] = 0xEFCDAB89;
|
||||
uid_len = 8;
|
||||
}
|
||||
|
||||
if ( uid_len > max_chars / 2 ) uid_len = max_chars / 2;
|
||||
|
||||
for ( size_t i = 0; i < uid_len; i++ ) {
|
||||
for ( size_t j = 0; j < 2; j++ ) {
|
||||
const char nibble_to_hex[16] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
uint8_t const nibble = (uid[i] >> (j * 4)) & 0xf;
|
||||
desc_str1[i * 2 + (1 - j)] = nibble_to_hex[nibble]; // UTF-16-LE
|
||||
}
|
||||
}
|
||||
|
||||
return 2 * uid_len;
|
||||
}
|
||||
|
||||
// TODO remove
|
||||
static inline void board_delay(uint32_t ms) {
|
||||
uint32_t start_ms = board_millis();
|
||||
while ( board_millis() - start_ms < ms ) {
|
||||
// take chance to run usb background
|
||||
#if CFG_TUD_ENABLED
|
||||
tud_task();
|
||||
#endif
|
||||
|
||||
#if CFG_TUH_ENABLED
|
||||
tuh_task();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// stdio getchar() is blocking, this is non-blocking version
|
||||
int board_getchar(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
178
pico-sdk/lib/tinyusb/hw/bsp/board_mcu.h
Normal file
178
pico-sdk/lib/tinyusb/hw/bsp/board_mcu.h
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BOARD_MCU_H_
|
||||
#define BOARD_MCU_H_
|
||||
|
||||
#include "tusb_option.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Low Level MCU header include. Example should be
|
||||
// platform independent and mostly doesn't need to include this file.
|
||||
// However there are still certain situation where this file is needed:
|
||||
// - FreeRTOSConfig.h to set up correct clock and NVIC interrupts for ARM Cortex
|
||||
// - SWO logging for Cortex M with ITM_SendChar() / ITM_ReceiveChar()
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Include order follows OPT_MCU_ number
|
||||
#if TU_CHECK_MCU(OPT_MCU_LPC11UXX, OPT_MCU_LPC13XX, OPT_MCU_LPC15XX) || \
|
||||
TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC18XX) || \
|
||||
TU_CHECK_MCU(OPT_MCU_LPC40XX, OPT_MCU_LPC43XX)
|
||||
#include "chip.h"
|
||||
|
||||
#elif TU_CHECK_MCU(OPT_MCU_LPC51UXX, OPT_MCU_LPC54XXX, OPT_MCU_LPC55XX, OPT_MCU_MCXN9)
|
||||
#include "fsl_device_registers.h"
|
||||
|
||||
#elif TU_CHECK_MCU(OPT_MCU_KINETIS_KL, OPT_MCU_KINETIS_K32L)
|
||||
#include "fsl_device_registers.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_NRF5X
|
||||
#include "nrf.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_SAMD11 || CFG_TUSB_MCU == OPT_MCU_SAMD21 || \
|
||||
CFG_TUSB_MCU == OPT_MCU_SAMD51 || CFG_TUSB_MCU == OPT_MCU_SAME5X || \
|
||||
CFG_TUSB_MCU == OPT_MCU_SAML22 || CFG_TUSB_MCU == OPT_MCU_SAML21
|
||||
#include "sam.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_SAMG
|
||||
#undef LITTLE_ENDIAN // hack to suppress "LITTLE_ENDIAN" redefined
|
||||
#include "sam.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32F0
|
||||
#include "stm32f0xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32F1
|
||||
#include "stm32f1xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32F2
|
||||
#include "stm32f2xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32F3
|
||||
#include "stm32f3xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32F4
|
||||
#include "stm32f4xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32F7
|
||||
#include "stm32f7xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32G4
|
||||
#include "stm32g4xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32H5
|
||||
#include "stm32h5xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32H7
|
||||
#include "stm32h7xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32L0
|
||||
#include "stm32l0xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32L1
|
||||
#include "stm32l1xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32L4
|
||||
#include "stm32l4xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32WB
|
||||
#include "stm32wbxx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32U5
|
||||
#include "stm32u5xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32G0
|
||||
#include "stm32g0xx.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_CXD56
|
||||
// no header needed
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_MSP430x5xx
|
||||
#include "msp430.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_MSP432E4
|
||||
#include "msp.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_VALENTYUSB_EPTRI
|
||||
// no header needed
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_MIMXRT1XXX
|
||||
#include "fsl_device_registers.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_NUC120
|
||||
#include "NUC100Series.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_NUC121 || CFG_TUSB_MCU == OPT_MCU_NUC126
|
||||
#include "NuMicro.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_NUC505
|
||||
#include "NUC505Series.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_ESP32S2
|
||||
// no header needed
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_ESP32S3
|
||||
// no header needed
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_DA1469X
|
||||
#include "DA1469xAB.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_RP2040
|
||||
#include "pico.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_EFM32GG
|
||||
#include "em_device.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_RX63X || CFG_TUSB_MCU == OPT_MCU_RX65X
|
||||
// no header needed
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_RAXXX
|
||||
#include "bsp_api.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_GD32VF103
|
||||
#include "gd32vf103.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_MM32F327X
|
||||
#include "mm32_device.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_XMC4000
|
||||
#include "xmc_device.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_TM4C123
|
||||
#include "TM4C123.h"
|
||||
|
||||
#elif CFG_TUSB_MCU == OPT_MCU_CH32F20X
|
||||
#include "ch32f20x.h"
|
||||
|
||||
#elif TU_CHECK_MCU(OPT_MCU_BCM2711, OPT_MCU_BCM2835, OPT_MCU_BCM2837)
|
||||
// no header needed
|
||||
|
||||
#else
|
||||
#error "Missing MCU header"
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* BOARD_MCU_H_ */
|
480
pico-sdk/lib/tinyusb/hw/bsp/family_support.cmake
Normal file
480
pico-sdk/lib/tinyusb/hw/bsp/family_support.cmake
Normal file
@@ -0,0 +1,480 @@
|
||||
include_guard(GLOBAL)
|
||||
|
||||
include(CMakePrintHelpers)
|
||||
|
||||
# TOP is path to root directory
|
||||
set(TOP "${CMAKE_CURRENT_LIST_DIR}/../..")
|
||||
get_filename_component(TOP ${TOP} ABSOLUTE)
|
||||
|
||||
# Default to gcc
|
||||
if (NOT DEFINED TOOLCHAIN)
|
||||
set(TOOLCHAIN gcc)
|
||||
endif ()
|
||||
|
||||
# FAMILY not defined, try to detect it from BOARD
|
||||
if (NOT DEFINED FAMILY)
|
||||
if (NOT DEFINED BOARD)
|
||||
message(FATAL_ERROR "You must set a FAMILY variable for the build (e.g. rp2040, espressif).
|
||||
You can do this via -DFAMILY=xxx on the cmake command line")
|
||||
endif ()
|
||||
|
||||
# Find path contains BOARD
|
||||
file(GLOB BOARD_PATH LIST_DIRECTORIES true
|
||||
RELATIVE ${TOP}/hw/bsp
|
||||
${TOP}/hw/bsp/*/boards/${BOARD}
|
||||
)
|
||||
if (NOT BOARD_PATH)
|
||||
message(FATAL_ERROR "Could not detect FAMILY from BOARD=${BOARD}")
|
||||
endif ()
|
||||
|
||||
# replace / with ; so that we can get the first element as FAMILY
|
||||
string(REPLACE "/" ";" BOARD_PATH ${BOARD_PATH})
|
||||
list(GET BOARD_PATH 0 FAMILY)
|
||||
endif ()
|
||||
|
||||
if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/${FAMILY}/family.cmake)
|
||||
message(FATAL_ERROR "Family '${FAMILY}' is not known/supported")
|
||||
endif()
|
||||
|
||||
if (NOT FAMILY STREQUAL rp2040)
|
||||
# enable LTO if supported skip rp2040
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT IPO_SUPPORTED)
|
||||
cmake_print_variables(IPO_SUPPORTED)
|
||||
if (IPO_SUPPORTED)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(WARNING_FLAGS_GNU
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-Wfatal-errors
|
||||
-Wdouble-promotion
|
||||
-Wstrict-prototypes
|
||||
-Wstrict-overflow
|
||||
-Werror-implicit-function-declaration
|
||||
-Wfloat-equal
|
||||
-Wundef
|
||||
-Wshadow
|
||||
-Wwrite-strings
|
||||
-Wsign-compare
|
||||
-Wmissing-format-attribute
|
||||
-Wunreachable-code
|
||||
-Wcast-align
|
||||
-Wcast-function-type
|
||||
-Wcast-qual
|
||||
-Wnull-dereference
|
||||
-Wuninitialized
|
||||
-Wunused
|
||||
-Wreturn-type
|
||||
-Wredundant-decls
|
||||
)
|
||||
|
||||
set(WARNING_FLAGS_IAR "")
|
||||
|
||||
|
||||
# Filter example based on only.txt and skip.txt
|
||||
function(family_filter RESULT DIR)
|
||||
get_filename_component(DIR ${DIR} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if (EXISTS "${DIR}/only.txt")
|
||||
file(READ "${DIR}/only.txt" ONLYS)
|
||||
# Replace newlines with semicolon so that it is treated as a list by CMake
|
||||
string(REPLACE "\n" ";" ONLYS_LINES ${ONLYS})
|
||||
|
||||
# For each mcu
|
||||
foreach(MCU IN LISTS FAMILY_MCUS)
|
||||
# For each line in only.txt
|
||||
foreach(_line ${ONLYS_LINES})
|
||||
# If mcu:xxx exists for this mcu or board:xxx then include
|
||||
if (${_line} STREQUAL "mcu:${MCU}" OR ${_line} STREQUAL "board:${BOARD}")
|
||||
set(${RESULT} 1 PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
# Didn't find it in only file so don't build
|
||||
set(${RESULT} 0 PARENT_SCOPE)
|
||||
|
||||
elseif (EXISTS "${DIR}/skip.txt")
|
||||
file(READ "${DIR}/skip.txt" SKIPS)
|
||||
# Replace newlines with semicolon so that it is treated as a list by CMake
|
||||
string(REPLACE "\n" ";" SKIPS_LINES ${SKIPS})
|
||||
|
||||
# For each mcu
|
||||
foreach(MCU IN LISTS FAMILY_MCUS)
|
||||
# For each line in only.txt
|
||||
foreach(_line ${SKIPS_LINES})
|
||||
# If mcu:xxx exists for this mcu then skip
|
||||
if (${_line} STREQUAL "mcu:${MCU}")
|
||||
set(${RESULT} 0 PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
# Didn't find in skip file so build
|
||||
set(${RESULT} 1 PARENT_SCOPE)
|
||||
else()
|
||||
|
||||
# Didn't find skip or only file so build
|
||||
set(${RESULT} 1 PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(family_add_subdirectory DIR)
|
||||
family_filter(SHOULD_ADD "${DIR}")
|
||||
if (SHOULD_ADD)
|
||||
add_subdirectory(${DIR})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(family_get_project_name OUTPUT_NAME DIR)
|
||||
get_filename_component(SHORT_NAME ${DIR} NAME)
|
||||
set(${OUTPUT_NAME} ${TINYUSB_FAMILY_PROJECT_NAME_PREFIX}${SHORT_NAME} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
function(family_initialize_project PROJECT DIR)
|
||||
# set output suffix to .elf (skip espressif and rp2040)
|
||||
if(NOT FAMILY STREQUAL "espressif" AND NOT FAMILY STREQUAL "rp2040")
|
||||
set(CMAKE_EXECUTABLE_SUFFIX .elf PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
family_filter(ALLOWED "${DIR}")
|
||||
if (NOT ALLOWED)
|
||||
get_filename_component(SHORT_NAME ${DIR} NAME)
|
||||
message(FATAL_ERROR "${SHORT_NAME} is not supported on FAMILY=${FAMILY}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# Common Target Configure
|
||||
# Most families use these settings except rp2040 and espressif
|
||||
#-------------------------------------------------------------
|
||||
|
||||
# Add RTOS to example
|
||||
function(family_add_rtos TARGET RTOS)
|
||||
if (RTOS STREQUAL "freertos")
|
||||
# freertos config
|
||||
if (NOT TARGET freertos_config)
|
||||
add_library(freertos_config INTERFACE)
|
||||
target_include_directories(freertos_config INTERFACE ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${FAMILY}/FreeRTOSConfig)
|
||||
# add board definition to freertos_config mostly for SystemCoreClock
|
||||
target_link_libraries(freertos_config INTERFACE board_${BOARD})
|
||||
endif()
|
||||
|
||||
# freertos kernel
|
||||
if (NOT TARGET freertos_kernel)
|
||||
add_subdirectory(${TOP}/lib/FreeRTOS-Kernel ${CMAKE_BINARY_DIR}/lib/freertos_kernel)
|
||||
endif ()
|
||||
|
||||
target_link_libraries(${TARGET} PUBLIC freertos_kernel)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
|
||||
# Add common configuration to example
|
||||
function(family_configure_common TARGET RTOS)
|
||||
family_add_rtos(${TARGET} ${RTOS})
|
||||
|
||||
string(TOUPPER ${BOARD} BOARD_UPPER)
|
||||
string(REPLACE "-" "_" BOARD_UPPER ${BOARD_UPPER})
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
BOARD_${BOARD_UPPER}
|
||||
)
|
||||
|
||||
# run size after build
|
||||
find_program(SIZE_EXE ${CMAKE_SIZE})
|
||||
if(NOT ${SIZE_EXE} STREQUAL SIZE_EXE-NOTFOUND)
|
||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||
COMMAND ${SIZE_EXE} $<TARGET_FILE:${TARGET}>
|
||||
)
|
||||
endif ()
|
||||
# Add warnings flags
|
||||
target_compile_options(${TARGET} PUBLIC ${WARNING_FLAGS_${CMAKE_C_COMPILER_ID}})
|
||||
|
||||
# Generate linker map file
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_options(${TARGET} PUBLIC "LINKER:-Map=$<TARGET_FILE:${TARGET}>.map")
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
|
||||
target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
|
||||
endif ()
|
||||
endif()
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${TARGET} PUBLIC "LINKER:--map=$<TARGET_FILE:${TARGET}>.map")
|
||||
endif()
|
||||
|
||||
|
||||
# ETM Trace option
|
||||
if (TRACE_ETM STREQUAL "1")
|
||||
target_compile_definitions(${TARGET} PUBLIC TRACE_ETM)
|
||||
endif ()
|
||||
|
||||
# LOGGER option
|
||||
if (DEFINED LOGGER)
|
||||
target_compile_definitions(${TARGET} PUBLIC LOGGER_${LOGGER})
|
||||
|
||||
# Add segger rtt to example
|
||||
if(LOGGER STREQUAL "RTT" OR LOGGER STREQUAL "rtt")
|
||||
if (NOT TARGET segger_rtt)
|
||||
add_library(segger_rtt STATIC ${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c)
|
||||
target_include_directories(segger_rtt PUBLIC ${TOP}/lib/SEGGER_RTT/RTT)
|
||||
#target_compile_definitions(segger_rtt PUBLIC SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL)
|
||||
endif()
|
||||
target_link_libraries(${TARGET} PUBLIC segger_rtt)
|
||||
endif ()
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
|
||||
# Add tinyusb to example
|
||||
function(family_add_tinyusb TARGET OPT_MCU RTOS)
|
||||
# tinyusb target is built for each example since it depends on example's tusb_config.h
|
||||
set(TINYUSB_TARGET_PREFIX ${TARGET}-)
|
||||
add_library(${TARGET}-tinyusb_config INTERFACE)
|
||||
|
||||
# path to tusb_config.h
|
||||
target_include_directories(${TARGET}-tinyusb_config INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
target_compile_definitions(${TARGET}-tinyusb_config INTERFACE CFG_TUSB_MCU=${OPT_MCU})
|
||||
|
||||
if (DEFINED LOG)
|
||||
target_compile_definitions(${TARGET}-tinyusb_config INTERFACE CFG_TUSB_DEBUG=${LOG})
|
||||
if (LOG STREQUAL "4")
|
||||
# no inline for debug level 4
|
||||
target_compile_definitions(${TARGET}-tinyusb_config INTERFACE TU_ATTR_ALWAYS_INLINE=)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
if (RTOS STREQUAL "freertos")
|
||||
target_compile_definitions(${TARGET}-tinyusb_config INTERFACE CFG_TUSB_OS=OPT_OS_FREERTOS)
|
||||
endif ()
|
||||
|
||||
# tinyusb's CMakeList.txt
|
||||
add_subdirectory(${TOP}/src ${CMAKE_CURRENT_BINARY_DIR}/tinyusb)
|
||||
|
||||
if (RTOS STREQUAL "freertos")
|
||||
# link tinyusb with freeRTOS kernel
|
||||
target_link_libraries(${TARGET}-tinyusb PUBLIC freertos_kernel)
|
||||
endif ()
|
||||
|
||||
# use max3421 as host controller
|
||||
if (MAX3421_HOST STREQUAL "1")
|
||||
target_compile_definitions(${TARGET}-tinyusb_config INTERFACE CFG_TUH_MAX3421=1)
|
||||
target_sources(${TARGET}-tinyusb PUBLIC
|
||||
${TOP}/src/portable/analog/max3421/hcd_max3421.c
|
||||
)
|
||||
endif ()
|
||||
|
||||
endfunction()
|
||||
|
||||
|
||||
# Add bin/hex output
|
||||
function(family_add_bin_hex TARGET)
|
||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${TARGET}> $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.bin
|
||||
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${TARGET}> $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.hex
|
||||
VERBATIM)
|
||||
endfunction()
|
||||
|
||||
|
||||
#----------------------------------
|
||||
# Example Target Configure (Default rule)
|
||||
# These function can be redefined in FAMILY/family.cmake
|
||||
#----------------------------------
|
||||
|
||||
function(family_configure_example TARGET RTOS)
|
||||
# empty function, should be redefined in FAMILY/family.cmake
|
||||
endfunction()
|
||||
|
||||
# Configure device example with RTOS
|
||||
function(family_configure_device_example TARGET RTOS)
|
||||
family_configure_example(${TARGET} ${RTOS})
|
||||
endfunction()
|
||||
|
||||
# Configure host example with RTOS
|
||||
function(family_configure_host_example TARGET RTOS)
|
||||
family_configure_example(${TARGET} ${RTOS})
|
||||
endfunction()
|
||||
|
||||
# Configure host + device example with RTOS
|
||||
function(family_configure_dual_usb_example TARGET RTOS)
|
||||
family_configure_example(${TARGET} ${RTOS})
|
||||
endfunction()
|
||||
|
||||
function(family_example_missing_dependency TARGET DEPENDENCY)
|
||||
message(WARNING "${DEPENDENCY} submodule needed by ${TARGET} not found, please run 'python tools/get_deps.py ${DEPENDENCY}' to fetch it")
|
||||
endfunction()
|
||||
|
||||
#----------------------------------
|
||||
# RPI specific: refactor later
|
||||
#----------------------------------
|
||||
function(family_add_default_example_warnings TARGET)
|
||||
target_compile_options(${TARGET} PUBLIC
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-Wfatal-errors
|
||||
-Wdouble-promotion
|
||||
-Wfloat-equal
|
||||
# FIXME commented out because of https://github.com/raspberrypi/pico-sdk/issues/1468
|
||||
#-Wshadow
|
||||
-Wwrite-strings
|
||||
-Wsign-compare
|
||||
-Wmissing-format-attribute
|
||||
-Wunreachable-code
|
||||
-Wcast-align
|
||||
-Wcast-qual
|
||||
-Wnull-dereference
|
||||
-Wuninitialized
|
||||
-Wunused
|
||||
-Wredundant-decls
|
||||
#-Wstrict-prototypes
|
||||
#-Werror-implicit-function-declaration
|
||||
#-Wundef
|
||||
)
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
|
||||
target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
|
||||
endif()
|
||||
|
||||
# GCC 10
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
|
||||
target_compile_options(${TARGET} PUBLIC -Wconversion)
|
||||
endif()
|
||||
|
||||
# GCC 8
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
|
||||
target_compile_options(${TARGET} PUBLIC -Wcast-function-type -Wstrict-overflow)
|
||||
endif()
|
||||
|
||||
# GCC 6
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
|
||||
target_compile_options(${TARGET} PUBLIC -Wno-strict-aliasing)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#----------------------------------
|
||||
# Flashing target
|
||||
#----------------------------------
|
||||
|
||||
# Add flash jlink target
|
||||
function(family_flash_jlink TARGET)
|
||||
if (NOT DEFINED JLINKEXE)
|
||||
set(JLINKEXE JLinkExe)
|
||||
endif ()
|
||||
|
||||
file(GENERATE
|
||||
OUTPUT $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.jlink
|
||||
CONTENT "halt
|
||||
loadfile $<TARGET_FILE:${TARGET}>
|
||||
r
|
||||
go
|
||||
exit"
|
||||
)
|
||||
|
||||
add_custom_target(${TARGET}-jlink
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${JLINKEXE} -device ${JLINK_DEVICE} -if swd -JTAGConf -1,-1 -speed auto -CommandFile $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.jlink
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
# Add flash stlink target
|
||||
function(family_flash_stlink TARGET)
|
||||
if (NOT DEFINED STM32_PROGRAMMER_CLI)
|
||||
set(STM32_PROGRAMMER_CLI STM32_Programmer_CLI)
|
||||
endif ()
|
||||
|
||||
add_custom_target(${TARGET}-stlink
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${STM32_PROGRAMMER_CLI} --connect port=swd --write $<TARGET_FILE:${TARGET}> --go
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
# Add flash openocd target
|
||||
function(family_flash_openocd TARGET CLI_OPTIONS)
|
||||
if (NOT DEFINED OPENOCD)
|
||||
set(OPENOCD openocd)
|
||||
endif ()
|
||||
|
||||
separate_arguments(CLI_OPTIONS_LIST UNIX_COMMAND ${CLI_OPTIONS})
|
||||
|
||||
# note skip verify since it has issue with rp2040
|
||||
add_custom_target(${TARGET}-openocd
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${OPENOCD} ${CLI_OPTIONS_LIST} -c "program $<TARGET_FILE:${TARGET}> reset exit"
|
||||
VERBATIM
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# Add flash pycod target
|
||||
function(family_flash_pyocd TARGET)
|
||||
if (NOT DEFINED PYOC)
|
||||
set(PYOCD pyocd)
|
||||
endif ()
|
||||
|
||||
add_custom_target(${TARGET}-pyocd
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${PYOCD} flash -t ${PYOCD_TARGET} $<TARGET_FILE:${TARGET}>
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
# Add flash using NXP's LinkServer (redserver)
|
||||
# https://www.nxp.com/design/software/development-software/mcuxpresso-software-and-tools-/linkserver-for-microcontrollers:LINKERSERVER
|
||||
function(family_flash_nxplink TARGET)
|
||||
if (NOT DEFINED LINKSERVER)
|
||||
set(LINKSERVER LinkServer)
|
||||
endif ()
|
||||
|
||||
# LinkServer has a bug that can only execute with full path otherwise it throws:
|
||||
# realpath error: No such file or directory
|
||||
execute_process(COMMAND which ${LINKSERVER} OUTPUT_VARIABLE LINKSERVER_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
add_custom_target(${TARGET}-nxplink
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${LINKSERVER_PATH} flash ${NXPLINK_DEVICE} load $<TARGET_FILE:${TARGET}>
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
function(family_flash_dfu_util TARGET OPTION)
|
||||
if (NOT DEFINED DFU_UTIL)
|
||||
set(DFU_UTIL dfu-util)
|
||||
endif ()
|
||||
|
||||
add_custom_target(${TARGET}-dfu-util
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${DFU_UTIL} -R -d ${DFU_UTIL_VID_PID} -a 0 -D $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.bin
|
||||
VERBATIM
|
||||
)
|
||||
endfunction()
|
||||
|
||||
#----------------------------------
|
||||
# Family specific
|
||||
#----------------------------------
|
||||
|
||||
# family specific: can override above functions
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/${FAMILY}/family.cmake)
|
||||
|
||||
if (NOT FAMILY_MCUS)
|
||||
set(FAMILY_MCUS ${FAMILY})
|
||||
endif()
|
||||
|
||||
# if use max3421 as host controller, expand FAMILY_MCUS to include max3421
|
||||
if (MAX3421_HOST STREQUAL "1")
|
||||
set(FAMILY_MCUS ${FAMILY_MCUS} MAX3421)
|
||||
endif ()
|
||||
|
||||
# save it in case of re-inclusion
|
||||
set(FAMILY_MCUS ${FAMILY_MCUS} CACHE INTERNAL "")
|
92
pico-sdk/lib/tinyusb/hw/bsp/rp2040/board.h
Normal file
92
pico-sdk/lib/tinyusb/hw/bsp/rp2040/board.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021, 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.
|
||||
*/
|
||||
|
||||
#ifndef BOARD_H_
|
||||
#define BOARD_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// LED
|
||||
#ifdef PICO_DEFAULT_LED_PIN
|
||||
#define LED_PIN PICO_DEFAULT_LED_PIN
|
||||
#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
|
||||
|
||||
// UART
|
||||
#if defined(PICO_DEFAULT_UART_TX_PIN) && defined(PICO_DEFAULT_UART_RX_PIN) && \
|
||||
defined(PICO_DEFAULT_UART) && defined(LIB_PICO_STDIO_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
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// PIO_USB
|
||||
// default to pin on Adafruit Feather rp2040 USB Host or Tester if defined
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// #define USE_ADAFRUIT_FEATHER_RP2040_USBHOST
|
||||
#ifdef USE_ADAFRUIT_FEATHER_RP2040_USBHOST
|
||||
#define PICO_DEFAULT_PIO_USB_DP_PIN 16
|
||||
#define PICO_DEFAULT_PIO_USB_VBUSEN_PIN 18
|
||||
#endif
|
||||
|
||||
#ifndef PICO_DEFAULT_PIO_USB_DP_PIN
|
||||
#define PICO_DEFAULT_PIO_USB_DP_PIN 20
|
||||
#endif
|
||||
|
||||
// VBUS enable pin and its active state
|
||||
#ifndef PICO_DEFAULT_PIO_USB_VBUSEN_PIN
|
||||
#define PICO_DEFAULT_PIO_USB_VBUSEN_PIN 22
|
||||
#endif
|
||||
|
||||
// VBUS enable state
|
||||
#ifndef PICO_DEFAULT_PIO_USB_VBUSEN_STATE
|
||||
#define PICO_DEFAULT_PIO_USB_VBUSEN_STATE 1
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// USB Host MAX3421E
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
#define MAX3421_SPI PICO_DEFAULT_SPI_INSTANCE
|
||||
#define MAX3421_SCK_PIN PICO_DEFAULT_SPI_SCK_PIN
|
||||
#define MAX3421_MOSI_PIN PICO_DEFAULT_SPI_TX_PIN
|
||||
#define MAX3421_MISO_PIN PICO_DEFAULT_SPI_RX_PIN
|
||||
#define MAX3421_CS_PIN 10
|
||||
#define MAX3421_INTR_PIN 9
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BOARD_H_ */
|
@@ -0,0 +1 @@
|
||||
# This builds with settings based purely on the current PICO_BOARD set via the SDK
|
@@ -0,0 +1 @@
|
||||
set(PICO_BOARD pico)
|
314
pico-sdk/lib/tinyusb/hw/bsp/rp2040/family.c
Normal file
314
pico-sdk/lib/tinyusb/hw/bsp/rp2040/family.c
Normal file
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
|
||||
* Copyright (c) 2021, 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 "pico/stdlib.h"
|
||||
#include "pico/binary_info.h"
|
||||
#include "pico/unique_id.h"
|
||||
#include "hardware/gpio.h"
|
||||
#include "hardware/sync.h"
|
||||
#include "hardware/resets.h"
|
||||
#include "hardware/structs/ioqspi.h"
|
||||
#include "hardware/structs/sio.h"
|
||||
|
||||
#include "bsp/board_api.h"
|
||||
#include "board.h"
|
||||
|
||||
#ifdef UART_DEV
|
||||
static uart_inst_t *uart_inst;
|
||||
#endif
|
||||
|
||||
#if CFG_TUH_RPI_PIO_USB || CFG_TUD_RPI_PIO_USB
|
||||
#include "pio_usb.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUH_ENABLED && CFG_TUH_MAX3421
|
||||
#include "hardware/spi.h"
|
||||
static void max3421_init(void);
|
||||
#endif
|
||||
|
||||
#ifdef BUTTON_BOOTSEL
|
||||
// This example blinks the Picoboard LED when the BOOTSEL button is pressed.
|
||||
//
|
||||
// Picoboard has a button attached to the flash CS pin, which the bootrom
|
||||
// checks, and jumps straight to the USB bootcode if the button is pressed
|
||||
// (pulling flash CS low). We can check this pin in by jumping to some code in
|
||||
// SRAM (so that the XIP interface is not required), floating the flash CS
|
||||
// pin, and observing whether it is pulled low.
|
||||
//
|
||||
// This doesn't work if others are trying to access flash at the same time,
|
||||
// e.g. XIP streamer, or the other core.
|
||||
bool __no_inline_not_in_flash_func(get_bootsel_button)(void) {
|
||||
const uint CS_PIN_INDEX = 1;
|
||||
|
||||
// Must disable interrupts, as interrupt handlers may be in flash, and we
|
||||
// are about to temporarily disable flash access!
|
||||
uint32_t flags = save_and_disable_interrupts();
|
||||
|
||||
// Set chip select to Hi-Z
|
||||
hw_write_masked(&ioqspi_hw->io[CS_PIN_INDEX].ctrl,
|
||||
GPIO_OVERRIDE_LOW << IO_QSPI_GPIO_QSPI_SS_CTRL_OEOVER_LSB,
|
||||
IO_QSPI_GPIO_QSPI_SS_CTRL_OEOVER_BITS);
|
||||
|
||||
// Note we can't call into any sleep functions in flash right now
|
||||
for (volatile int i = 0; i < 1000; ++i);
|
||||
|
||||
// The HI GPIO registers in SIO can observe and control the 6 QSPI pins.
|
||||
// Note the button pulls the pin *low* when pressed.
|
||||
bool button_state = (sio_hw->gpio_hi_in & (1u << CS_PIN_INDEX));
|
||||
|
||||
// Need to restore the state of chip select, else we are going to have a
|
||||
// bad time when we return to code in flash!
|
||||
hw_write_masked(&ioqspi_hw->io[CS_PIN_INDEX].ctrl,
|
||||
GPIO_OVERRIDE_NORMAL << IO_QSPI_GPIO_QSPI_SS_CTRL_OEOVER_LSB,
|
||||
IO_QSPI_GPIO_QSPI_SS_CTRL_OEOVER_BITS);
|
||||
|
||||
restore_interrupts(flags);
|
||||
|
||||
return button_state;
|
||||
}
|
||||
#endif
|
||||
|
||||
//------------- Segger RTT retarget -------------//
|
||||
#if defined(LOGGER_RTT)
|
||||
// Logging with RTT
|
||||
// - If RTT Control Block is not found by 'Auto Detection` try to use 'Search Range` with '0x20000000 0x10000'
|
||||
// - SWD speed is rather slow around 1000Khz
|
||||
#include "pico/stdio/driver.h"
|
||||
#include "SEGGER_RTT.h"
|
||||
|
||||
static void stdio_rtt_write (const char *buf, int length) {
|
||||
SEGGER_RTT_Write(0, buf, (unsigned) length);
|
||||
}
|
||||
|
||||
static int stdio_rtt_read (char *buf, int len) {
|
||||
return (int) SEGGER_RTT_Read(0, buf, (unsigned) len);
|
||||
}
|
||||
|
||||
static stdio_driver_t stdio_rtt = {
|
||||
.out_chars = stdio_rtt_write,
|
||||
.out_flush = NULL,
|
||||
.in_chars = stdio_rtt_read
|
||||
};
|
||||
|
||||
void stdio_rtt_init(void) {
|
||||
stdio_set_driver_enabled(&stdio_rtt, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
//
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
#if CFG_TUH_RPI_PIO_USB || CFG_TUD_RPI_PIO_USB
|
||||
// Set the system clock to a multiple of 120mhz for bitbanging USB with pico-usb
|
||||
set_sys_clock_khz(120000, true);
|
||||
|
||||
#ifdef PICO_DEFAULT_PIO_USB_VBUSEN_PIN
|
||||
gpio_init(PICO_DEFAULT_PIO_USB_VBUSEN_PIN);
|
||||
gpio_set_dir(PICO_DEFAULT_PIO_USB_VBUSEN_PIN, GPIO_OUT);
|
||||
gpio_put(PICO_DEFAULT_PIO_USB_VBUSEN_PIN, PICO_DEFAULT_PIO_USB_VBUSEN_STATE);
|
||||
#endif
|
||||
|
||||
// rp2040 use pico-pio-usb for host tuh_configure() can be used to passed pio configuration to the host stack
|
||||
// Note: tuh_configure() must be called before tuh_init()
|
||||
pio_usb_configuration_t pio_cfg = PIO_USB_DEFAULT_CONFIG;
|
||||
pio_cfg.pin_dp = PICO_DEFAULT_PIO_USB_DP_PIN;
|
||||
tuh_configure(BOARD_TUH_RHPORT, TUH_CFGID_RPI_PIO_USB_CONFIGURATION, &pio_cfg);
|
||||
#endif
|
||||
|
||||
#ifdef LED_PIN
|
||||
bi_decl(bi_1pin_with_name(LED_PIN, "LED"));
|
||||
gpio_init(LED_PIN);
|
||||
gpio_set_dir(LED_PIN, GPIO_OUT);
|
||||
#endif
|
||||
|
||||
// Button
|
||||
#ifndef BUTTON_BOOTSEL
|
||||
#endif
|
||||
|
||||
#ifdef UART_DEV
|
||||
bi_decl(bi_2pins_with_func(UART_TX_PIN, UART_RX_PIN, GPIO_FUNC_UART));
|
||||
uart_inst = uart_get_instance(UART_DEV);
|
||||
stdio_uart_init_full(uart_inst, CFG_BOARD_UART_BAUDRATE, UART_TX_PIN, UART_RX_PIN);
|
||||
#endif
|
||||
|
||||
#if defined(LOGGER_RTT)
|
||||
stdio_rtt_init();
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_ENABLED
|
||||
// TODO probably set up device mode?
|
||||
#endif
|
||||
|
||||
#if CFG_TUH_ENABLED
|
||||
#if CFG_TUH_MAX3421
|
||||
max3421_init();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !CFG_TUD_ENABLED && !CFG_TUH_ENABLED
|
||||
// board test exxample, reset usb controller
|
||||
reset_block(RESETS_RESET_USBCTRL_BITS);
|
||||
unreset_block_wait(RESETS_RESET_USBCTRL_BITS);
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Board porting API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
void board_led_write(bool state) {
|
||||
(void) state;
|
||||
|
||||
#ifdef LED_PIN
|
||||
gpio_put(LED_PIN, state ? LED_STATE_ON : (1 - LED_STATE_ON));
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t board_button_read(void) {
|
||||
#ifdef BUTTON_BOOTSEL
|
||||
return BUTTON_STATE_ACTIVE == get_bootsel_button();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t board_get_unique_id(uint8_t id[], size_t max_len) {
|
||||
pico_unique_board_id_t pico_id;
|
||||
pico_get_unique_board_id(&pico_id);
|
||||
|
||||
size_t len = PICO_UNIQUE_BOARD_ID_SIZE_BYTES;
|
||||
if (len > max_len) len = max_len;
|
||||
|
||||
memcpy(id, pico_id.id, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
int board_uart_read(uint8_t *buf, int len) {
|
||||
#ifdef UART_DEV
|
||||
int count = 0;
|
||||
while ( (count < len) && uart_is_readable(uart_inst) ) {
|
||||
buf[count] = uart_getc(uart_inst);
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
#else
|
||||
(void) buf; (void) len;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int board_uart_write(void const *buf, int len) {
|
||||
#ifdef UART_DEV
|
||||
char const *bufch = (char const *) buf;
|
||||
for ( int i = 0; i < len; i++ ) {
|
||||
uart_putc(uart_inst, bufch[i]);
|
||||
}
|
||||
return len;
|
||||
#else
|
||||
(void) buf; (void) len;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int board_getchar(void) {
|
||||
return getchar_timeout_us(0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB Interrupt Handler
|
||||
// rp2040 implementation will install appropriate handler when initializing
|
||||
// tinyusb. There is no need to forward IRQ from application
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// API: SPI transfer with MAX3421E, must be implemented by application
|
||||
//--------------------------------------------------------------------+
|
||||
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
|
||||
|
||||
void max3421_int_handler(uint gpio, uint32_t event_mask) {
|
||||
if (!(gpio == MAX3421_INTR_PIN && event_mask & GPIO_IRQ_EDGE_FALL)) return;
|
||||
tuh_int_handler(BOARD_TUH_RHPORT, true);
|
||||
}
|
||||
|
||||
static void max3421_init(void) {
|
||||
// CS pin
|
||||
gpio_init(MAX3421_CS_PIN);
|
||||
gpio_set_dir(MAX3421_CS_PIN, GPIO_OUT);
|
||||
gpio_put(MAX3421_CS_PIN, true);
|
||||
|
||||
// Interrupt pin
|
||||
gpio_init(MAX3421_INTR_PIN);
|
||||
gpio_set_dir(MAX3421_INTR_PIN, GPIO_IN);
|
||||
gpio_pull_up(MAX3421_INTR_PIN);
|
||||
gpio_set_irq_enabled_with_callback(MAX3421_INTR_PIN, GPIO_IRQ_EDGE_FALL, true, max3421_int_handler);
|
||||
|
||||
// SPI init
|
||||
spi_init(MAX3421_SPI, 4*1000000ul);
|
||||
gpio_set_function(MAX3421_SCK_PIN, GPIO_FUNC_SPI);
|
||||
gpio_set_function(MAX3421_MOSI_PIN, GPIO_FUNC_SPI);
|
||||
gpio_set_function(MAX3421_MISO_PIN, GPIO_FUNC_SPI);
|
||||
spi_set_format(MAX3421_SPI, 8, SPI_CPOL_0, SPI_CPHA_0, SPI_MSB_FIRST);
|
||||
}
|
||||
|
||||
//// API to enable/disable MAX3421 INTR pin interrupt
|
||||
void tuh_max3421_int_api(uint8_t rhport, bool enabled) {
|
||||
(void) rhport;
|
||||
irq_set_enabled(IO_IRQ_BANK0, enabled);
|
||||
}
|
||||
|
||||
// API to control MAX3421 SPI CS
|
||||
void tuh_max3421_spi_cs_api(uint8_t rhport, bool active) {
|
||||
(void) rhport;
|
||||
gpio_put(MAX3421_CS_PIN, !active);
|
||||
}
|
||||
|
||||
// API to transfer data with MAX3421 SPI
|
||||
// Either tx_buf or rx_buf can be NULL, which means transfer is write or read only
|
||||
bool tuh_max3421_spi_xfer_api(uint8_t rhport, uint8_t const* tx_buf, uint8_t* rx_buf, size_t xfer_bytes) {
|
||||
(void) rhport;
|
||||
|
||||
if (tx_buf == NULL && rx_buf == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret;
|
||||
|
||||
if (tx_buf == NULL) {
|
||||
ret = spi_read_blocking(MAX3421_SPI, 0, rx_buf, xfer_bytes);
|
||||
}else if (rx_buf == NULL) {
|
||||
ret = spi_write_blocking(MAX3421_SPI, tx_buf, xfer_bytes);
|
||||
}else {
|
||||
ret = spi_write_read_blocking(spi0, tx_buf, rx_buf, xfer_bytes);
|
||||
}
|
||||
|
||||
return ret == (int) xfer_bytes;
|
||||
}
|
||||
|
||||
#endif
|
371
pico-sdk/lib/tinyusb/hw/bsp/rp2040/family.cmake
Normal file
371
pico-sdk/lib/tinyusb/hw/bsp/rp2040/family.cmake
Normal file
@@ -0,0 +1,371 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
include_guard(GLOBAL)
|
||||
|
||||
if (NOT BOARD)
|
||||
message("BOARD not specified, defaulting to pico_sdk")
|
||||
set(BOARD pico_sdk)
|
||||
endif()
|
||||
|
||||
# add the SDK in case we are standalone tinyusb example (noop if already present)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/pico_sdk_import.cmake)
|
||||
|
||||
# include basic family CMake functionality
|
||||
set(FAMILY_MCUS RP2040)
|
||||
set(JLINK_DEVICE rp2040_m0_0)
|
||||
set(OPENOCD_OPTION "-f interface/cmsis-dap.cfg -f target/rp2040.cfg -c \"adapter speed 5000\"")
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
|
||||
|
||||
if (NOT PICO_TINYUSB_PATH)
|
||||
set(PICO_TINYUSB_PATH ${TOP})
|
||||
endif()
|
||||
|
||||
if (NOT TINYUSB_OPT_OS)
|
||||
set(TINYUSB_OPT_OS OPT_OS_PICO)
|
||||
endif()
|
||||
|
||||
#------------------------------------
|
||||
# Base config for both device and host; wrapped by SDK's tinyusb_common
|
||||
#------------------------------------
|
||||
add_library(tinyusb_common_base INTERFACE)
|
||||
|
||||
target_sources(tinyusb_common_base INTERFACE
|
||||
${TOP}/src/tusb.c
|
||||
${TOP}/src/common/tusb_fifo.c
|
||||
)
|
||||
|
||||
target_include_directories(tinyusb_common_base INTERFACE
|
||||
${TOP}/src
|
||||
)
|
||||
|
||||
if(DEFINED LOG)
|
||||
set(TINYUSB_DEBUG_LEVEL ${LOG})
|
||||
elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message("Compiling TinyUSB with CFG_TUSB_DEBUG=1")
|
||||
set(TINYUSB_DEBUG_LEVEL 1)
|
||||
else ()
|
||||
set(TINYUSB_DEBUG_LEVEL 0)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(tinyusb_common_base INTERFACE
|
||||
CFG_TUSB_MCU=OPT_MCU_RP2040
|
||||
CFG_TUSB_OS=${TINYUSB_OPT_OS}
|
||||
CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL}
|
||||
)
|
||||
|
||||
target_link_libraries(tinyusb_common_base INTERFACE
|
||||
hardware_structs
|
||||
hardware_irq
|
||||
hardware_resets
|
||||
pico_sync
|
||||
)
|
||||
|
||||
#------------------------------------
|
||||
# Base config for device mode; wrapped by SDK's tinyusb_device
|
||||
#------------------------------------
|
||||
add_library(tinyusb_device_base INTERFACE)
|
||||
target_sources(tinyusb_device_base INTERFACE
|
||||
${TOP}/src/portable/raspberrypi/rp2040/dcd_rp2040.c
|
||||
${TOP}/src/portable/raspberrypi/rp2040/rp2040_usb.c
|
||||
${TOP}/src/device/usbd.c
|
||||
${TOP}/src/device/usbd_control.c
|
||||
${TOP}/src/class/cdc/cdc_device.c
|
||||
${TOP}/src/class/hid/hid_device.c
|
||||
)
|
||||
|
||||
#------------------------------------
|
||||
# Base config for host mode; wrapped by SDK's tinyusb_host
|
||||
#------------------------------------
|
||||
add_library(tinyusb_host_base INTERFACE)
|
||||
target_sources(tinyusb_host_base INTERFACE
|
||||
${TOP}/src/portable/raspberrypi/rp2040/hcd_rp2040.c
|
||||
${TOP}/src/portable/raspberrypi/rp2040/rp2040_usb.c
|
||||
${TOP}/src/host/usbh.c
|
||||
${TOP}/src/host/hub.c
|
||||
${TOP}/src/class/cdc/cdc_host.c
|
||||
${TOP}/src/class/hid/hid_host.c
|
||||
${TOP}/src/class/msc/msc_host.c
|
||||
${TOP}/src/class/vendor/vendor_host.c
|
||||
)
|
||||
|
||||
# Sometimes have to do host specific actions in mostly common functions
|
||||
target_compile_definitions(tinyusb_host_base INTERFACE
|
||||
RP2040_USB_HOST_MODE=1
|
||||
)
|
||||
|
||||
#------------------------------------
|
||||
# Host MAX3421
|
||||
#------------------------------------
|
||||
add_library(tinyusb_host_max3421 INTERFACE)
|
||||
target_sources(tinyusb_host_max3421 INTERFACE
|
||||
${TOP}/src/portable/analog/max3421/hcd_max3421.c
|
||||
)
|
||||
target_compile_definitions(tinyusb_host_max3421 INTERFACE
|
||||
CFG_TUH_MAX3421=1
|
||||
)
|
||||
target_link_libraries(tinyusb_host_max3421 INTERFACE
|
||||
hardware_spi
|
||||
)
|
||||
|
||||
#------------------------------------
|
||||
# BSP & Additions
|
||||
#------------------------------------
|
||||
add_library(tinyusb_bsp INTERFACE)
|
||||
target_sources(tinyusb_bsp INTERFACE
|
||||
${TOP}/hw/bsp/rp2040/family.c
|
||||
)
|
||||
target_include_directories(tinyusb_bsp INTERFACE
|
||||
${TOP}/hw
|
||||
)
|
||||
target_link_libraries(tinyusb_bsp INTERFACE pico_unique_id)
|
||||
|
||||
# tinyusb_additions will hold our extra settings for examples
|
||||
add_library(tinyusb_additions INTERFACE)
|
||||
|
||||
target_compile_definitions(tinyusb_additions INTERFACE
|
||||
PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1
|
||||
PICO_RP2040_USB_DEVICE_UFRAME_FIX=1
|
||||
)
|
||||
|
||||
if(LOGGER STREQUAL "RTT" OR LOGGER STREQUAL "rtt")
|
||||
target_compile_definitions(tinyusb_additions INTERFACE
|
||||
LOGGER_RTT
|
||||
#SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
|
||||
)
|
||||
|
||||
target_sources(tinyusb_additions INTERFACE
|
||||
${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c
|
||||
)
|
||||
|
||||
set_source_files_properties(${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-cast-qual -Wno-cast-align -Wno-sign-conversion")
|
||||
|
||||
target_include_directories(tinyusb_additions INTERFACE
|
||||
${TOP}/lib/SEGGER_RTT/RTT
|
||||
)
|
||||
endif()
|
||||
|
||||
#------------------------------------
|
||||
# Functions
|
||||
#------------------------------------
|
||||
|
||||
function(family_configure_target TARGET RTOS)
|
||||
if (RTOS STREQUAL noos OR RTOS STREQUAL "")
|
||||
set(RTOS_SUFFIX "")
|
||||
else()
|
||||
set(RTOS_SUFFIX _${RTOS})
|
||||
endif()
|
||||
# export RTOS_SUFFIX to parent scope
|
||||
set(RTOS_SUFFIX ${RTOS_SUFFIX} PARENT_SCOPE)
|
||||
|
||||
pico_add_extra_outputs(${TARGET})
|
||||
pico_enable_stdio_uart(${TARGET} 1)
|
||||
target_link_libraries(${TARGET} PUBLIC pico_stdlib pico_bootsel_via_double_reset tinyusb_board${RTOS_SUFFIX} tinyusb_additions)
|
||||
|
||||
# family_flash_openocd(${TARGET} ${OPENOCD_OPTION})
|
||||
family_flash_jlink(${TARGET})
|
||||
endfunction()
|
||||
|
||||
|
||||
function(rp2040_family_configure_example_warnings TARGET)
|
||||
if (NOT PICO_TINYUSB_NO_EXAMPLE_WARNINGS)
|
||||
family_add_default_example_warnings(${TARGET})
|
||||
endif()
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_compile_options(${TARGET} PRIVATE -Wno-unreachable-code)
|
||||
endif()
|
||||
suppress_tinyusb_warnings()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(family_configure_device_example TARGET RTOS)
|
||||
family_configure_target(${TARGET} ${RTOS})
|
||||
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_device${RTOS_SUFFIX})
|
||||
rp2040_family_configure_example_warnings(${TARGET})
|
||||
endfunction()
|
||||
|
||||
|
||||
function(family_add_pico_pio_usb TARGET)
|
||||
target_link_libraries(${TARGET} PUBLIC tinyusb_pico_pio_usb)
|
||||
endfunction()
|
||||
|
||||
|
||||
# since Pico-PIO_USB compiler support may lag, and change from version to version, add a function that pico-sdk/pico-examples
|
||||
# can check (if present) in case the user has updated their TinyUSB
|
||||
function(is_compiler_supported_by_pico_pio_usb OUTVAR)
|
||||
if ((NOT CMAKE_C_COMPILER_ID STREQUAL "GNU"))
|
||||
SET(${OUTVAR} 0 PARENT_SCOPE)
|
||||
else()
|
||||
set(${OUTVAR} 1 PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(family_configure_host_example TARGET RTOS)
|
||||
family_configure_target(${TARGET} ${RTOS})
|
||||
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_host${RTOS_SUFFIX})
|
||||
rp2040_family_configure_example_warnings(${TARGET})
|
||||
|
||||
# For rp2040 enable pico-pio-usb
|
||||
if (TARGET tinyusb_pico_pio_usb)
|
||||
# Pico-PIO-USB does not compile with all pico-sdk supported compilers, so check before enabling it
|
||||
is_compiler_supported_by_pico_pio_usb(PICO_PIO_USB_COMPILER_SUPPORTED)
|
||||
if (PICO_PIO_USB_COMPILER_SUPPORTED)
|
||||
family_add_pico_pio_usb(${PROJECT})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# for max3421 host
|
||||
if (MAX3421_HOST STREQUAL "1")
|
||||
target_link_libraries(${TARGET} PUBLIC tinyusb_host_max3421)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(family_configure_dual_usb_example TARGET RTOS)
|
||||
family_configure_target(${TARGET} ${RTOS})
|
||||
# require tinyusb_pico_pio_usb
|
||||
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_device tinyusb_host tinyusb_pico_pio_usb )
|
||||
rp2040_family_configure_example_warnings(${TARGET})
|
||||
endfunction()
|
||||
|
||||
|
||||
function(check_and_add_pico_pio_usb_support)
|
||||
# check for pico_generate_pio_header (as depending on environment we may be called before SDK is
|
||||
# initialized in which case it isn't available yet), and only do the initialization once
|
||||
if (COMMAND pico_generate_pio_header AND NOT TARGET tinyusb_pico_pio_usb)
|
||||
#------------------------------------
|
||||
# PIO USB for both host and device
|
||||
#------------------------------------
|
||||
|
||||
if (NOT DEFINED PICO_PIO_USB_PATH)
|
||||
set(PICO_PIO_USB_PATH "${TOP}/hw/mcu/raspberry_pi/Pico-PIO-USB")
|
||||
endif()
|
||||
|
||||
if (EXISTS ${PICO_PIO_USB_PATH}/src/pio_usb.c)
|
||||
add_library(tinyusb_pico_pio_usb INTERFACE)
|
||||
target_sources(tinyusb_device_base INTERFACE
|
||||
${TOP}/src/portable/raspberrypi/pio_usb/dcd_pio_usb.c
|
||||
)
|
||||
target_sources(tinyusb_host_base INTERFACE
|
||||
${TOP}/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c
|
||||
)
|
||||
|
||||
target_sources(tinyusb_pico_pio_usb INTERFACE
|
||||
${PICO_PIO_USB_PATH}/src/pio_usb.c
|
||||
${PICO_PIO_USB_PATH}/src/pio_usb_host.c
|
||||
${PICO_PIO_USB_PATH}/src/pio_usb_device.c
|
||||
${PICO_PIO_USB_PATH}/src/usb_crc.c
|
||||
)
|
||||
|
||||
target_include_directories(tinyusb_pico_pio_usb INTERFACE
|
||||
${PICO_PIO_USB_PATH}/src
|
||||
)
|
||||
|
||||
target_link_libraries(tinyusb_pico_pio_usb INTERFACE
|
||||
hardware_dma
|
||||
hardware_pio
|
||||
pico_multicore
|
||||
)
|
||||
|
||||
target_compile_definitions(tinyusb_pico_pio_usb INTERFACE
|
||||
PIO_USB_USE_TINYUSB
|
||||
)
|
||||
|
||||
pico_generate_pio_header(tinyusb_pico_pio_usb ${PICO_PIO_USB_PATH}/src/usb_tx.pio)
|
||||
pico_generate_pio_header(tinyusb_pico_pio_usb ${PICO_PIO_USB_PATH}/src/usb_rx.pio)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Try to add Pico-PIO_USB support now for the case where this file is included directly
|
||||
# after Pico SDK initialization, but without using the family_ functions (as is the case
|
||||
# when included by the SDK itself)
|
||||
check_and_add_pico_pio_usb_support()
|
||||
|
||||
|
||||
function(family_initialize_project PROJECT DIR)
|
||||
# call the original version of this function from family_common.cmake
|
||||
_family_initialize_project(${PROJECT} ${DIR})
|
||||
enable_language(C CXX ASM)
|
||||
pico_sdk_init()
|
||||
|
||||
# now re-check for adding Pico-PIO_USB support now SDK is definitely available
|
||||
check_and_add_pico_pio_usb_support()
|
||||
endfunction()
|
||||
|
||||
|
||||
# This method must be called from the project scope to suppress known warnings in TinyUSB source files
|
||||
function(suppress_tinyusb_warnings)
|
||||
# some of these are pretty silly warnings only occurring in some older GCC versions 9 or prior
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_LESS 10.0)
|
||||
set(CONVERSION_WARNING_FILES
|
||||
${PICO_TINYUSB_PATH}/src/tusb.c
|
||||
${PICO_TINYUSB_PATH}/src/common/tusb_fifo.c
|
||||
${PICO_TINYUSB_PATH}/src/device/usbd.c
|
||||
${PICO_TINYUSB_PATH}/src/device/usbd_control.c
|
||||
${PICO_TINYUSB_PATH}/src/host/usbh.c
|
||||
${PICO_TINYUSB_PATH}/src/class/cdc/cdc_device.c
|
||||
${PICO_TINYUSB_PATH}/src/class/cdc/cdc_host.c
|
||||
${PICO_TINYUSB_PATH}/src/class/hid/hid_device.c
|
||||
${PICO_TINYUSB_PATH}/src/class/hid/hid_host.c
|
||||
${PICO_TINYUSB_PATH}/src/class/audio/audio_device.c
|
||||
${PICO_TINYUSB_PATH}/src/class/dfu/dfu_device.c
|
||||
${PICO_TINYUSB_PATH}/src/class/dfu/dfu_rt_device.c
|
||||
${PICO_TINYUSB_PATH}/src/class/midi/midi_device.c
|
||||
${PICO_TINYUSB_PATH}/src/class/usbtmc/usbtmc_device.c
|
||||
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/rp2040/hcd_rp2040.c
|
||||
)
|
||||
foreach(SOURCE_FILE IN LISTS CONVERSION_WARNING_FILES)
|
||||
set_source_files_properties(
|
||||
${SOURCE_FILE}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-conversion")
|
||||
endforeach()
|
||||
endif()
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0)
|
||||
set_source_files_properties(
|
||||
${PICO_TINYUSB_PATH}/lib/fatfs/source/ff.c
|
||||
COMPILE_FLAGS "-Wno-stringop-overflow -Wno-array-bounds")
|
||||
endif()
|
||||
set_source_files_properties(
|
||||
${PICO_TINYUSB_PATH}/lib/fatfs/source/ff.c
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-conversion -Wno-cast-qual")
|
||||
|
||||
set_source_files_properties(
|
||||
${PICO_TINYUSB_PATH}/lib/lwip/src/core/tcp_in.c
|
||||
${PICO_TINYUSB_PATH}/lib/lwip/src/core/tcp_out.c
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-conversion")
|
||||
|
||||
set_source_files_properties(
|
||||
${PICO_TINYUSB_PATH}/lib/networking/dnserver.c
|
||||
${PICO_TINYUSB_PATH}/lib/networking/dhserver.c
|
||||
${PICO_TINYUSB_PATH}/lib/networking/rndis_reports.c
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-conversion -Wno-sign-conversion")
|
||||
|
||||
if (TARGET tinyusb_pico_pio_usb)
|
||||
set_source_files_properties(
|
||||
${PICO_TINYUSB_PATH}/hw/mcu/raspberry_pi/Pico-PIO-USB/src/pio_usb_device.c
|
||||
${PICO_TINYUSB_PATH}/hw/mcu/raspberry_pi/Pico-PIO-USB/src/pio_usb.c
|
||||
${PICO_TINYUSB_PATH}/hw/mcu/raspberry_pi/Pico-PIO-USB/src/pio_usb_host.c
|
||||
${PICO_TINYUSB_PATH}/src/portable/raspberrypi/pio_usb/hcd_pio_usb.c
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-conversion -Wno-cast-qual -Wno-attributes")
|
||||
endif()
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
set_source_files_properties(
|
||||
${PICO_TINYUSB_PATH}/src/class/cdc/cdc_device.c
|
||||
COMPILE_FLAGS "-Wno-unreachable-code")
|
||||
set_source_files_properties(
|
||||
${PICO_TINYUSB_PATH}/src/class/cdc/cdc_host.c
|
||||
COMPILE_FLAGS "-Wno-unreachable-code-fallthrough")
|
||||
set_source_files_properties(
|
||||
${PICO_TINYUSB_PATH}/lib/fatfs/source/ff.c
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-Wno-cast-qual")
|
||||
endif()
|
||||
endfunction()
|
18
pico-sdk/lib/tinyusb/hw/bsp/rp2040/family.mk
Normal file
18
pico-sdk/lib/tinyusb/hw/bsp/rp2040/family.mk
Normal file
@@ -0,0 +1,18 @@
|
||||
JLINK_DEVICE = rp2040_m0_0
|
||||
PYOCD_TARGET = rp2040
|
||||
|
||||
DEPS_SUBMODULES += hw/mcu/raspberry_pi/Pico-PIO-USB
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
CMAKE_DEFSYM += -DCMAKE_BUILD_TYPE=Debug
|
||||
endif
|
||||
|
||||
$(BUILD):
|
||||
cmake -S . -B $(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) -DPICO_BUILD_DOCS=0 $(CMAKE_DEFSYM)
|
||||
|
||||
all: $(BUILD)
|
||||
$(MAKE) -C $(BUILD)
|
||||
|
||||
flash: flash-pyocd
|
||||
flash-uf2:
|
||||
@$(CP) $(BUILD)/$(PROJECT).uf2 /media/$(USER)/RPI-RP2
|
62
pico-sdk/lib/tinyusb/hw/bsp/rp2040/pico_sdk_import.cmake
Normal file
62
pico-sdk/lib/tinyusb/hw/bsp/rp2040/pico_sdk_import.cmake
Normal file
@@ -0,0 +1,62 @@
|
||||
# This is a copy of <PICO_SDK_PATH>/external/pico_sdk_import.cmake
|
||||
|
||||
# This can be dropped into an external project to help locate this SDK
|
||||
# It should be include()ed prior to project()
|
||||
|
||||
if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
|
||||
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
|
||||
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
|
||||
endif ()
|
||||
|
||||
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT} AND (NOT PICO_SDK_FETCH_FROM_GIT))
|
||||
set(PICO_SDK_FETCH_FROM_GIT $ENV{PICO_SDK_FETCH_FROM_GIT})
|
||||
message("Using PICO_SDK_FETCH_FROM_GIT from environment ('${PICO_SDK_FETCH_FROM_GIT}')")
|
||||
endif ()
|
||||
|
||||
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_PATH))
|
||||
set(PICO_SDK_FETCH_FROM_GIT_PATH $ENV{PICO_SDK_FETCH_FROM_GIT_PATH})
|
||||
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
|
||||
endif ()
|
||||
|
||||
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
|
||||
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable")
|
||||
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
|
||||
|
||||
if (NOT PICO_SDK_PATH)
|
||||
if (PICO_SDK_FETCH_FROM_GIT)
|
||||
include(FetchContent)
|
||||
set(FETCHCONTENT_BASE_DIR_SAVE ${FETCHCONTENT_BASE_DIR})
|
||||
if (PICO_SDK_FETCH_FROM_GIT_PATH)
|
||||
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
|
||||
endif ()
|
||||
FetchContent_Declare(
|
||||
pico_sdk
|
||||
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
||||
GIT_TAG master
|
||||
)
|
||||
if (NOT pico_sdk)
|
||||
message("Downloading Raspberry Pi Pico SDK")
|
||||
FetchContent_Populate(pico_sdk)
|
||||
set(PICO_SDK_PATH ${pico_sdk_SOURCE_DIR})
|
||||
endif ()
|
||||
set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE})
|
||||
else ()
|
||||
message(FATAL_ERROR
|
||||
"SDK location was not specified. Please set PICO_SDK_PATH or set PICO_SDK_FETCH_FROM_GIT to on to fetch from git."
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
get_filename_component(PICO_SDK_PATH "${PICO_SDK_PATH}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
|
||||
if (NOT EXISTS ${PICO_SDK_PATH})
|
||||
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' not found")
|
||||
endif ()
|
||||
|
||||
set(PICO_SDK_INIT_CMAKE_FILE ${PICO_SDK_PATH}/pico_sdk_init.cmake)
|
||||
if (NOT EXISTS ${PICO_SDK_INIT_CMAKE_FILE})
|
||||
message(FATAL_ERROR "Directory '${PICO_SDK_PATH}' does not appear to contain the Raspberry Pi Pico SDK")
|
||||
endif ()
|
||||
|
||||
set(PICO_SDK_PATH ${PICO_SDK_PATH} CACHE PATH "Path to the Raspberry Pi Pico SDK" FORCE)
|
||||
|
||||
include(${PICO_SDK_INIT_CMAKE_FILE})
|
3
pico-sdk/lib/tinyusb/hw/bsp/rp2040/rp2040-openocd.cfg
Normal file
3
pico-sdk/lib/tinyusb/hw/bsp/rp2040/rp2040-openocd.cfg
Normal file
@@ -0,0 +1,3 @@
|
||||
source [find interface/cmsis-dap.cfg]
|
||||
adapter speed 5000
|
||||
source [find target/rp2040.cfg]
|
Reference in New Issue
Block a user