move things around a bit
This commit is contained in:
parent
4c93827bed
commit
b5e29c1dd7
|
@ -44,8 +44,11 @@ if(FAMILY STREQUAL "rp2040")
|
|||
pico_enable_stdio_uart(${PROJECT} 1)
|
||||
endif()
|
||||
pico_enable_stdio_usb(${PROJECT} 0)
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid FAMILY '${FAMILY}' specified")
|
||||
endif()
|
||||
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libco/libco.S
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Source/DAP.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Source/JTAG_DP.c
|
||||
|
@ -54,30 +57,33 @@ if(FAMILY STREQUAL "rp2040")
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Source/SW_DP.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bsp/${FAMILY}/cdc_uart.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bsp/${FAMILY}/spi_serprog.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bsp/${FAMILY}/unique.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/cdc_serprog.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/i2ctinyusb.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/rtconf.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
|
||||
)
|
||||
if(USE_USBCDC_FOR_STDIO)
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bsp/${FAMILY}/cdc_stdio.c
|
||||
)
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
endif()
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libco/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Include/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/Core/Include/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bsp/${FAMILY}/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bsp/default/
|
||||
)
|
||||
)
|
||||
|
||||
if(FAMILY STREQUAL "rp2040")
|
||||
target_link_libraries(${PROJECT} pico_stdlib pico_unique_id hardware_spi
|
||||
pico_fix_rp2040_usb_device_enumeration
|
||||
tinyusb_device tinyusb_board tinyusb_additions)
|
||||
|
||||
if(USE_USBCDC_FOR_STDIO)
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bsp/${FAMILY}/cdc_stdio.c
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
${PICO_SDK_PATH}/src/rp2_common/pico_stdio_usb/include/
|
||||
)
|
||||
|
|
|
@ -52,7 +52,7 @@ This information includes:
|
|||
#include "bsp/board.h"
|
||||
|
||||
#include "protos.h"
|
||||
#include "unique.h"
|
||||
#include "util.h"
|
||||
|
||||
/// Processor Clock of the Cortex-M MCU used in the Debug Unit.
|
||||
/// This value is used to calculate the SWD/JTAG clock speed.
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#include <stdint.h>
|
||||
#include "tusb.h"
|
||||
|
||||
#include "util.h"
|
||||
|
||||
/* in the absence of the board-specific directory providing a unique ID, we provide a canned one */
|
||||
|
||||
static uint8_t get_unique_id_u8(uint8_t *desc_str) {
|
||||
__attribute__((__weak__)) uint8_t get_unique_id_u8(uint8_t *desc_str) {
|
||||
static const char canned[] = "123456";
|
||||
|
||||
for (int i=0; i<TU_ARRAY_SIZE(canned); i++) {
|
||||
|
@ -13,7 +15,7 @@ static uint8_t get_unique_id_u8(uint8_t *desc_str) {
|
|||
return i;
|
||||
}
|
||||
|
||||
static uint8_t get_unique_id_u16(uint16_t *desc_str) {
|
||||
__attribute__((__weak__)) uint8_t get_unique_id_u16(uint16_t *desc_str) {
|
||||
static const char canned[] = "123456";
|
||||
|
||||
for (int i=0; i<TU_ARRAY_SIZE(canned); i++) {
|
|
@ -59,21 +59,24 @@ This information includes:
|
|||
#include <hardware/gpio.h>
|
||||
#include <pico/binary_info.h>
|
||||
|
||||
#include "picoprobe_config.h"
|
||||
#include "pinout.h"
|
||||
#include "protos.h"
|
||||
#include "unique.h"
|
||||
#include "util.h"
|
||||
|
||||
#define PROBE_PIN_SWCLK_MASK (1UL << (PROBE_PIN_SWCLK))
|
||||
#define PROBE_PIN_SWDIO_MASK (1UL << (PROBE_PIN_SWDIO))
|
||||
#define PINOUT_SWCLK PINOUT_JTAG_TCK
|
||||
#define PINOUT_SWDIO PINOUT_JTAG_TMS
|
||||
|
||||
#define PROBE_PIN_TCK_MASK (1UL << PROBE_PIN_JTAG_TCK)
|
||||
#define PROBE_PIN_TMS_MASK (1UL << PROBE_PIN_JTAG_TMS)
|
||||
#define PROBE_PIN_TDI_MASK (1UL << PROBE_PIN_JTAG_TDI)
|
||||
#define PROBE_PIN_TDO_MASK (1UL << PROBE_PIN_JTAG_TDO)
|
||||
#define PROBE_PIN_nTRST_MASK (1UL << PROBE_PIN_JTAG_nTRST)
|
||||
#define PROBE_PIN_nRESET_MASK (1UL << PROBE_PIN_JTAG_nRESET)
|
||||
#define PINOUT_SWCLK_MASK (1UL << PINOUT_SWCLK)
|
||||
#define PINOUT_SWDIO_MASK (1UL << PINOUT_SWDIO)
|
||||
|
||||
#define PICOPROBE_LED_MASK (1UL << PICOPROBE_LED)
|
||||
#define PINOUT_TCK_MASK (1UL << PINOUT_JTAG_TCK)
|
||||
#define PINOUT_TMS_MASK (1UL << PINOUT_JTAG_TMS)
|
||||
#define PINOUT_TDI_MASK (1UL << PINOUT_JTAG_TDI)
|
||||
#define PINOUT_TDO_MASK (1UL << PINOUT_JTAG_TDO)
|
||||
#define PINOUT_nTRST_MASK (1UL << PINOUT_JTAG_nTRST)
|
||||
#define PINOUT_nRESET_MASK (1UL << PINOUT_JTAG_nRESET)
|
||||
|
||||
#define PINOUT_LED_MASK (1UL << PINOUT_LED)
|
||||
|
||||
/// Processor Clock of the Cortex-M MCU used in the Debug Unit.
|
||||
/// This value is used to calculate the SWD/JTAG clock speed.
|
||||
|
@ -231,27 +234,27 @@ __STATIC_INLINE void PORT_JTAG_SETUP (void) {
|
|||
resets_hw->reset &= ~(RESETS_RESET_IO_BANK0_BITS | RESETS_RESET_PADS_BANK0_BITS);
|
||||
|
||||
/* set to default high level */
|
||||
sio_hw->gpio_oe_set = PROBE_PIN_TCK_MASK | PROBE_PIN_TMS_MASK | PROBE_PIN_TDI_MASK | PROBE_PIN_nTRST_MASK | PROBE_PIN_nRESET_MASK;
|
||||
sio_hw->gpio_set = PROBE_PIN_TCK_MASK | PROBE_PIN_TMS_MASK | PROBE_PIN_TDI_MASK | PROBE_PIN_nTRST_MASK | PROBE_PIN_nRESET_MASK;
|
||||
sio_hw->gpio_oe_set = PINOUT_TCK_MASK | PINOUT_TMS_MASK | PINOUT_TDI_MASK | PINOUT_nTRST_MASK | PINOUT_nRESET_MASK;
|
||||
sio_hw->gpio_set = PINOUT_TCK_MASK | PINOUT_TMS_MASK | PINOUT_TDI_MASK | PINOUT_nTRST_MASK | PINOUT_nRESET_MASK;
|
||||
/* TDO needs to be an input */
|
||||
sio_hw->gpio_oe_clr = PROBE_PIN_TDO_MASK;
|
||||
sio_hw->gpio_oe_clr = PINOUT_TDO_MASK;
|
||||
|
||||
hw_write_masked(&padsbank0_hw->io[PROBE_PIN_JTAG_TCK],
|
||||
hw_write_masked(&padsbank0_hw->io[PINOUT_JTAG_TCK],
|
||||
PADS_BANK0_GPIO0_IE_BITS, // bits to set: input enable
|
||||
PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS); // bits to mask out: input enable, output disable
|
||||
hw_write_masked(&padsbank0_hw->io[PROBE_PIN_JTAG_TMS],
|
||||
hw_write_masked(&padsbank0_hw->io[PINOUT_JTAG_TMS],
|
||||
PADS_BANK0_GPIO0_IE_BITS,
|
||||
PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS);
|
||||
hw_write_masked(&padsbank0_hw->io[PROBE_PIN_JTAG_TDI],
|
||||
hw_write_masked(&padsbank0_hw->io[PINOUT_JTAG_TDI],
|
||||
PADS_BANK0_GPIO0_IE_BITS,
|
||||
PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS);
|
||||
hw_write_masked(&padsbank0_hw->io[PROBE_PIN_JTAG_TDO],
|
||||
hw_write_masked(&padsbank0_hw->io[PINOUT_JTAG_TDO],
|
||||
PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS, // TDO needs to have its output disabled
|
||||
PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS);
|
||||
hw_write_masked(&padsbank0_hw->io[PROBE_PIN_JTAG_nTRST],
|
||||
hw_write_masked(&padsbank0_hw->io[PINOUT_JTAG_nTRST],
|
||||
PADS_BANK0_GPIO0_IE_BITS,
|
||||
PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS);
|
||||
hw_write_masked(&padsbank0_hw->io[PROBE_PIN_JTAG_nRESET],
|
||||
hw_write_masked(&padsbank0_hw->io[PINOUT_JTAG_nRESET],
|
||||
PADS_BANK0_GPIO0_IE_BITS,
|
||||
PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS);
|
||||
|
||||
|
@ -259,13 +262,13 @@ __STATIC_INLINE void PORT_JTAG_SETUP (void) {
|
|||
// normal == 0, low == 2
|
||||
|
||||
// set pin modes to general IO (SIO)
|
||||
iobank0_hw->io[PROBE_PIN_JTAG_TCK].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
iobank0_hw->io[PROBE_PIN_JTAG_TMS].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
iobank0_hw->io[PROBE_PIN_JTAG_TDI].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
iobank0_hw->io[PROBE_PIN_JTAG_TDO].ctrl = (GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB)
|
||||
iobank0_hw->io[PINOUT_JTAG_TCK].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
iobank0_hw->io[PINOUT_JTAG_TMS].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
iobank0_hw->io[PINOUT_JTAG_TDI].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
iobank0_hw->io[PINOUT_JTAG_TDO].ctrl = (GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB)
|
||||
/*| (GPIO_OVERRIDE_LOW << IO_BANK0_GPIO0_CTRL_OEOVER_LSB)*/;
|
||||
iobank0_hw->io[PROBE_PIN_JTAG_nTRST].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
iobank0_hw->io[PROBE_PIN_JTAG_nRESET].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
iobank0_hw->io[PINOUT_JTAG_nTRST].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
iobank0_hw->io[PINOUT_JTAG_nRESET].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
}
|
||||
|
||||
/** Setup SWD I/O pins: SWCLK, SWDIO, and nRESET.
|
||||
|
@ -277,13 +280,13 @@ __STATIC_INLINE void PORT_SWD_SETUP (void) {
|
|||
resets_hw->reset &= ~(RESETS_RESET_IO_BANK0_BITS | RESETS_RESET_PADS_BANK0_BITS);
|
||||
|
||||
/* set to default high level */
|
||||
sio_hw->gpio_oe_set = PROBE_PIN_SWCLK_MASK | PROBE_PIN_SWDIO_MASK;
|
||||
sio_hw->gpio_set = PROBE_PIN_SWCLK_MASK | PROBE_PIN_SWDIO_MASK;
|
||||
sio_hw->gpio_oe_set = PINOUT_SWCLK_MASK | PINOUT_SWDIO_MASK;
|
||||
sio_hw->gpio_set = PINOUT_SWCLK_MASK | PINOUT_SWDIO_MASK;
|
||||
|
||||
hw_write_masked(&padsbank0_hw->io[PROBE_PIN_SWCLK], PADS_BANK0_GPIO0_IE_BITS, PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS);
|
||||
hw_write_masked(&padsbank0_hw->io[PROBE_PIN_SWDIO], PADS_BANK0_GPIO0_IE_BITS, PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS);
|
||||
iobank0_hw->io[PROBE_PIN_SWCLK].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
iobank0_hw->io[PROBE_PIN_SWDIO].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
hw_write_masked(&padsbank0_hw->io[PINOUT_SWCLK], PADS_BANK0_GPIO0_IE_BITS, PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS);
|
||||
hw_write_masked(&padsbank0_hw->io[PINOUT_SWDIO], PADS_BANK0_GPIO0_IE_BITS, PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS);
|
||||
iobank0_hw->io[PINOUT_SWCLK].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
iobank0_hw->io[PINOUT_SWDIO].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
}
|
||||
|
||||
/** Disable JTAG/SWD I/O Pins.
|
||||
|
@ -291,9 +294,9 @@ Disables the DAP Hardware I/O pins which configures:
|
|||
- TCK/SWCLK, TMS/SWDIO, TDI, TDO, nTRST, nRESET to High-Z mode.
|
||||
*/
|
||||
__STATIC_INLINE void PORT_OFF (void) {
|
||||
sio_hw->gpio_oe_clr = PROBE_PIN_SWCLK_MASK | PROBE_PIN_SWDIO_MASK
|
||||
| PROBE_PIN_TDI_MASK //| PROBE_PIN_TDO_MASK
|
||||
| PROBE_PIN_nTRST_MASK | PROBE_PIN_nRESET_MASK;
|
||||
sio_hw->gpio_oe_clr = PINOUT_SWCLK_MASK | PINOUT_SWDIO_MASK
|
||||
| PINOUT_TDI_MASK //| PINOUT_TDO_MASK
|
||||
| PINOUT_nTRST_MASK | PINOUT_nRESET_MASK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -303,21 +306,21 @@ __STATIC_INLINE void PORT_OFF (void) {
|
|||
\return Current status of the SWCLK/TCK DAP hardware I/O pin.
|
||||
*/
|
||||
__STATIC_FORCEINLINE uint32_t PIN_SWCLK_TCK_IN (void) {
|
||||
return (sio_hw->gpio_in & PROBE_PIN_SWCLK_MASK) >> PROBE_PIN_SWCLK;
|
||||
return (sio_hw->gpio_in & PINOUT_SWCLK_MASK) >> PINOUT_SWCLK;
|
||||
}
|
||||
|
||||
/** SWCLK/TCK I/O pin: Set Output to High.
|
||||
Set the SWCLK/TCK DAP hardware I/O pin to high level.
|
||||
*/
|
||||
__STATIC_FORCEINLINE void PIN_SWCLK_TCK_SET (void) {
|
||||
sio_hw->gpio_set = PROBE_PIN_SWCLK_MASK;
|
||||
sio_hw->gpio_set = PINOUT_SWCLK_MASK;
|
||||
}
|
||||
|
||||
/** SWCLK/TCK I/O pin: Set Output to Low.
|
||||
Set the SWCLK/TCK DAP hardware I/O pin to low level.
|
||||
*/
|
||||
__STATIC_FORCEINLINE void PIN_SWCLK_TCK_CLR (void) {
|
||||
sio_hw->gpio_clr = PROBE_PIN_SWCLK_MASK;
|
||||
sio_hw->gpio_clr = PINOUT_SWCLK_MASK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -327,7 +330,7 @@ __STATIC_FORCEINLINE void PIN_SWCLK_TCK_CLR (void) {
|
|||
\return Current status of the SWDIO/TMS DAP hardware I/O pin.
|
||||
*/
|
||||
__STATIC_FORCEINLINE uint32_t PIN_SWDIO_TMS_IN (void) {
|
||||
return (sio_hw->gpio_in & PROBE_PIN_SWDIO_MASK) >> PROBE_PIN_SWDIO;
|
||||
return (sio_hw->gpio_in & PINOUT_SWDIO_MASK) >> PINOUT_SWDIO;
|
||||
}
|
||||
|
||||
/* PIN_SWDIO_TMS_SET and PIN_SWDIO_TMS_CLR are used by SWJ_Sequence */
|
||||
|
@ -336,21 +339,21 @@ __STATIC_FORCEINLINE uint32_t PIN_SWDIO_TMS_IN (void) {
|
|||
Set the SWDIO/TMS DAP hardware I/O pin to high level.
|
||||
*/
|
||||
__STATIC_FORCEINLINE void PIN_SWDIO_TMS_SET (void) {
|
||||
sio_hw->gpio_set = PROBE_PIN_SWDIO_MASK;
|
||||
sio_hw->gpio_set = PINOUT_SWDIO_MASK;
|
||||
}
|
||||
|
||||
/** SWDIO/TMS I/O pin: Set Output to Low.
|
||||
Set the SWDIO/TMS DAP hardware I/O pin to low level.
|
||||
*/
|
||||
__STATIC_FORCEINLINE void PIN_SWDIO_TMS_CLR (void) {
|
||||
sio_hw->gpio_clr = PROBE_PIN_SWDIO_MASK;
|
||||
sio_hw->gpio_clr = PINOUT_SWDIO_MASK;
|
||||
}
|
||||
|
||||
/** SWDIO I/O pin: Get Input (used in SWD mode only).
|
||||
\return Current status of the SWDIO DAP hardware I/O pin.
|
||||
*/
|
||||
__STATIC_FORCEINLINE uint32_t PIN_SWDIO_IN (void) {
|
||||
return (sio_hw->gpio_in & PROBE_PIN_SWDIO_MASK) ? 1U : 0U;
|
||||
return (sio_hw->gpio_in & PINOUT_SWDIO_MASK) ? 1U : 0U;
|
||||
}
|
||||
|
||||
/** SWDIO I/O pin: Set Output (used in SWD mode only).
|
||||
|
@ -358,9 +361,9 @@ __STATIC_FORCEINLINE uint32_t PIN_SWDIO_IN (void) {
|
|||
*/
|
||||
__STATIC_FORCEINLINE void PIN_SWDIO_OUT (uint32_t bit) {
|
||||
if (bit & 1)
|
||||
sio_hw->gpio_set = PROBE_PIN_SWDIO_MASK;
|
||||
sio_hw->gpio_set = PINOUT_SWDIO_MASK;
|
||||
else
|
||||
sio_hw->gpio_clr = PROBE_PIN_SWDIO_MASK;
|
||||
sio_hw->gpio_clr = PINOUT_SWDIO_MASK;
|
||||
}
|
||||
|
||||
/** SWDIO I/O pin: Switch to Output mode (used in SWD mode only).
|
||||
|
@ -368,7 +371,7 @@ Configure the SWDIO DAP hardware I/O pin to output mode. This function is
|
|||
called prior \ref PIN_SWDIO_OUT function calls.
|
||||
*/
|
||||
__STATIC_FORCEINLINE void PIN_SWDIO_OUT_ENABLE (void) {
|
||||
sio_hw->gpio_oe_set = PROBE_PIN_SWDIO_MASK;
|
||||
sio_hw->gpio_oe_set = PINOUT_SWDIO_MASK;
|
||||
}
|
||||
|
||||
/** SWDIO I/O pin: Switch to Input mode (used in SWD mode only).
|
||||
|
@ -376,7 +379,7 @@ Configure the SWDIO DAP hardware I/O pin to input mode. This function is
|
|||
called prior \ref PIN_SWDIO_IN function calls.
|
||||
*/
|
||||
__STATIC_FORCEINLINE void PIN_SWDIO_OUT_DISABLE (void) {
|
||||
sio_hw->gpio_oe_clr = PROBE_PIN_SWDIO_MASK;
|
||||
sio_hw->gpio_oe_clr = PINOUT_SWDIO_MASK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -386,7 +389,7 @@ __STATIC_FORCEINLINE void PIN_SWDIO_OUT_DISABLE (void) {
|
|||
\return Current status of the TDI DAP hardware I/O pin.
|
||||
*/
|
||||
__STATIC_FORCEINLINE uint32_t PIN_TDI_IN (void) {
|
||||
return (sio_hw->gpio_in & PROBE_PIN_TDI_MASK) >> PROBE_PIN_JTAG_TDI;
|
||||
return (sio_hw->gpio_in & PINOUT_TDI_MASK) >> PINOUT_JTAG_TDI;
|
||||
}
|
||||
|
||||
/** TDI I/O pin: Set Output.
|
||||
|
@ -394,9 +397,9 @@ __STATIC_FORCEINLINE uint32_t PIN_TDI_IN (void) {
|
|||
*/
|
||||
__STATIC_FORCEINLINE void PIN_TDI_OUT (uint32_t bit) {
|
||||
if (bit & 1)
|
||||
sio_hw->gpio_set = PROBE_PIN_TDI_MASK;
|
||||
sio_hw->gpio_set = PINOUT_TDI_MASK;
|
||||
else
|
||||
sio_hw->gpio_clr = PROBE_PIN_TDI_MASK;
|
||||
sio_hw->gpio_clr = PINOUT_TDI_MASK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -406,7 +409,7 @@ __STATIC_FORCEINLINE void PIN_TDI_OUT (uint32_t bit) {
|
|||
\return Current status of the TDO DAP hardware I/O pin.
|
||||
*/
|
||||
__STATIC_FORCEINLINE uint32_t PIN_TDO_IN (void) {
|
||||
return (sio_hw->gpio_in & PROBE_PIN_TDO_MASK) >> PROBE_PIN_JTAG_TDO;
|
||||
return (sio_hw->gpio_in & PINOUT_TDO_MASK) >> PINOUT_JTAG_TDO;
|
||||
}
|
||||
|
||||
|
||||
|
@ -416,7 +419,7 @@ __STATIC_FORCEINLINE uint32_t PIN_TDO_IN (void) {
|
|||
\return Current status of the nTRST DAP hardware I/O pin.
|
||||
*/
|
||||
__STATIC_FORCEINLINE uint32_t PIN_nTRST_IN (void) {
|
||||
return (sio_hw->gpio_in & PROBE_PIN_nTRST_MASK) >> PROBE_PIN_JTAG_nTRST;
|
||||
return (sio_hw->gpio_in & PINOUT_nTRST_MASK) >> PINOUT_JTAG_nTRST;
|
||||
}
|
||||
|
||||
/** nTRST I/O pin: Set Output.
|
||||
|
@ -426,9 +429,9 @@ __STATIC_FORCEINLINE uint32_t PIN_nTRST_IN (void) {
|
|||
*/
|
||||
__STATIC_FORCEINLINE void PIN_nTRST_OUT (uint32_t bit) {
|
||||
if (bit & 1)
|
||||
sio_hw->gpio_set = PROBE_PIN_nTRST_MASK;
|
||||
sio_hw->gpio_set = PINOUT_nTRST_MASK;
|
||||
else
|
||||
sio_hw->gpio_clr = PROBE_PIN_nTRST_MASK;
|
||||
sio_hw->gpio_clr = PINOUT_nTRST_MASK;
|
||||
}
|
||||
|
||||
// nRESET Pin I/O------------------------------------------
|
||||
|
@ -437,7 +440,7 @@ __STATIC_FORCEINLINE void PIN_nTRST_OUT (uint32_t bit) {
|
|||
\return Current status of the nRESET DAP hardware I/O pin.
|
||||
*/
|
||||
__STATIC_FORCEINLINE uint32_t PIN_nRESET_IN (void) {
|
||||
return (sio_hw->gpio_in & PROBE_PIN_nRESET_MASK) >> PROBE_PIN_JTAG_nRESET;
|
||||
return (sio_hw->gpio_in & PINOUT_nRESET_MASK) >> PINOUT_JTAG_nRESET;
|
||||
}
|
||||
|
||||
/** nRESET I/O pin: Set Output.
|
||||
|
@ -447,9 +450,9 @@ __STATIC_FORCEINLINE uint32_t PIN_nRESET_IN (void) {
|
|||
*/
|
||||
__STATIC_FORCEINLINE void PIN_nRESET_OUT (uint32_t bit) {
|
||||
if (bit & 1)
|
||||
sio_hw->gpio_set = PROBE_PIN_nRESET_MASK;
|
||||
sio_hw->gpio_set = PINOUT_nRESET_MASK;
|
||||
else
|
||||
sio_hw->gpio_clr = PROBE_PIN_nRESET_MASK;
|
||||
sio_hw->gpio_clr = PINOUT_nRESET_MASK;
|
||||
}
|
||||
|
||||
///@}
|
||||
|
@ -474,11 +477,11 @@ It is recommended to provide the following LEDs for status indication:
|
|||
- 0: Connect LED OFF: debugger is not connected to CMSIS-DAP Debug Unit.
|
||||
*/
|
||||
__STATIC_INLINE void LED_CONNECTED_OUT (uint32_t bit) {
|
||||
#if PICOPROBE_LED_CONNECTED
|
||||
#if PINOUT_LED_CONNECTED
|
||||
if (bit & 1)
|
||||
sio_hw->gpio_set = PICOPROBE_LED_MASK;
|
||||
sio_hw->gpio_set = PINOUT_LED_MASK;
|
||||
else
|
||||
sio_hw->gpio_clr = PICOPROBE_LED_MASK;
|
||||
sio_hw->gpio_clr = PINOUT_LED_MASK;
|
||||
#else
|
||||
(void)bit;
|
||||
#endif
|
||||
|
@ -490,11 +493,11 @@ __STATIC_INLINE void LED_CONNECTED_OUT (uint32_t bit) {
|
|||
- 0: Target Running LED OFF: program execution in target stopped.
|
||||
*/
|
||||
__STATIC_INLINE void LED_RUNNING_OUT (uint32_t bit) {
|
||||
#if PICOPROBE_LED_RUNNING
|
||||
#if PINOUT_LED_RUNNING
|
||||
if (bit & 1)
|
||||
sio_hw->gpio_set = PICOPROBE_LED_MASK;
|
||||
sio_hw->gpio_set = PINOUT_LED_MASK;
|
||||
else
|
||||
sio_hw->gpio_clr = PICOPROBE_LED_MASK;
|
||||
sio_hw->gpio_clr = PINOUT_LED_MASK;
|
||||
#else
|
||||
(void)bit;
|
||||
#endif
|
||||
|
@ -547,21 +550,21 @@ Status LEDs. In detail the operation of Hardware I/O and LED pins are enabled an
|
|||
- LED output pins are enabled and LEDs are turned off.
|
||||
*/
|
||||
__STATIC_INLINE void DAP_SETUP (void) {
|
||||
sio_hw->gpio_oe_set = PICOPROBE_LED_MASK;
|
||||
sio_hw->gpio_clr = PICOPROBE_LED_MASK;
|
||||
sio_hw->gpio_oe_set = PINOUT_LED_MASK;
|
||||
sio_hw->gpio_clr = PINOUT_LED_MASK;
|
||||
|
||||
hw_write_masked(&padsbank0_hw->io[PICOPROBE_LED], 0, PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS);
|
||||
iobank0_hw->io[PICOPROBE_LED].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
hw_write_masked(&padsbank0_hw->io[PINOUT_LED], 0, PADS_BANK0_GPIO0_IE_BITS | PADS_BANK0_GPIO0_OD_BITS);
|
||||
iobank0_hw->io[PINOUT_LED].ctrl = GPIO_FUNC_SIO << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
|
||||
|
||||
bi_decl(bi_2pins_with_names(
|
||||
PROBE_PIN_JTAG_TCK, "TCK / SWCLK",
|
||||
PROBE_PIN_JTAG_TMS, "TMS / SWDIO"
|
||||
PINOUT_JTAG_TCK, "TCK / SWCLK",
|
||||
PINOUT_JTAG_TMS, "TMS / SWDIO"
|
||||
));
|
||||
bi_decl(bi_4pins_with_names(
|
||||
PROBE_PIN_JTAG_TDI , "TDI",
|
||||
PROBE_PIN_JTAG_TDO , "TDO",
|
||||
PROBE_PIN_JTAG_nTRST , "nTRST",
|
||||
PROBE_PIN_JTAG_nRESET, "nRESET"
|
||||
PINOUT_JTAG_TDI , "TDI",
|
||||
PINOUT_JTAG_TDO , "TDO",
|
||||
PINOUT_JTAG_nTRST , "nTRST",
|
||||
PINOUT_JTAG_nRESET, "nRESET"
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "tusb.h"
|
||||
|
||||
#include "pinout.h"
|
||||
#include "protocfg.h"
|
||||
|
||||
#ifndef PICO_STDIO_USB_STDOUT_TIMEOUT_US
|
||||
|
|
|
@ -28,26 +28,25 @@
|
|||
|
||||
#include "tusb.h"
|
||||
|
||||
#include "picoprobe_config.h"
|
||||
#include "protocfg.h"
|
||||
#include "pinout.h"
|
||||
#include "protos.h"
|
||||
|
||||
static uint8_t rx_buf[CFG_TUD_CDC_RX_BUFSIZE];
|
||||
static uint8_t tx_buf[CFG_TUD_CDC_TX_BUFSIZE];
|
||||
|
||||
void cdc_uart_init(void) {
|
||||
gpio_set_function(PICOPROBE_UART_TX, GPIO_FUNC_UART);
|
||||
gpio_set_function(PICOPROBE_UART_RX, GPIO_FUNC_UART);
|
||||
uart_init(PICOPROBE_UART_INTERFACE, PICOPROBE_UART_BAUDRATE);
|
||||
gpio_set_function(PINOUT_UART_TX, GPIO_FUNC_UART);
|
||||
gpio_set_function(PINOUT_UART_RX, GPIO_FUNC_UART);
|
||||
uart_init(PINOUT_UART_INTERFACE, PINOUT_UART_BAUDRATE);
|
||||
|
||||
bi_decl(bi_2pins_with_func(PICOPROBE_UART_TX, PICOPROBE_UART_RX, GPIO_FUNC_UART));
|
||||
bi_decl(bi_2pins_with_func(PINOUT_UART_TX, PINOUT_UART_RX, GPIO_FUNC_UART));
|
||||
}
|
||||
|
||||
void cdc_uart_task(void) {
|
||||
// Consume uart fifo regardless even if not connected
|
||||
uint rx_len = 0;
|
||||
while (uart_is_readable(PICOPROBE_UART_INTERFACE) && (rx_len < sizeof(rx_buf))) {
|
||||
rx_buf[rx_len++] = uart_getc(PICOPROBE_UART_INTERFACE);
|
||||
while (uart_is_readable(PINOUT_UART_INTERFACE) && (rx_len < sizeof(rx_buf))) {
|
||||
rx_buf[rx_len++] = uart_getc(PINOUT_UART_INTERFACE);
|
||||
}
|
||||
|
||||
if (tud_cdc_n_connected(CDC_N_UART)) {
|
||||
|
@ -62,17 +61,17 @@ void cdc_uart_task(void) {
|
|||
if (tud_cdc_n_available(CDC_N_UART)) {
|
||||
// Is there any data from the host for us to tx
|
||||
uint tx_len = tud_cdc_n_read(CDC_N_UART, tx_buf, sizeof(tx_buf));
|
||||
uart_write_blocking(PICOPROBE_UART_INTERFACE, tx_buf, tx_len);
|
||||
uart_write_blocking(PINOUT_UART_INTERFACE, tx_buf, tx_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cdc_uart_set_hwflow(bool enable) {
|
||||
uart_set_hw_flow(PICOPROBE_UART_INTERFACE, enable, enable);
|
||||
uart_set_hw_flow(PINOUT_UART_INTERFACE, enable, enable);
|
||||
}
|
||||
|
||||
void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* line_coding) {
|
||||
picoprobe_info("New baud rate %d\n", line_coding->bit_rate);
|
||||
uart_init(PICOPROBE_UART_INTERFACE, line_coding->bit_rate);
|
||||
//picoprobe_info("New baud rate %d\n", line_coding->bit_rate);
|
||||
uart_init(PINOUT_UART_INTERFACE, line_coding->bit_rate);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PICOPROBE_H_
|
||||
#define PICOPROBE_H_
|
||||
|
||||
#if false
|
||||
#define picoprobe_info(format,args...) printf(format, ## args)
|
||||
#else
|
||||
#define picoprobe_info(format,...) ((void)0)
|
||||
#endif
|
||||
|
||||
|
||||
#if false
|
||||
#define picoprobe_debug(format,args...) printf(format, ## args)
|
||||
#else
|
||||
#define picoprobe_debug(format,...) ((void)0)
|
||||
#endif
|
||||
|
||||
#if false
|
||||
#define picoprobe_dump(format,args...) printf(format, ## args)
|
||||
#else
|
||||
#define picoprobe_dump(format,...) ((void)0)
|
||||
#endif
|
||||
|
||||
|
||||
// PIO config
|
||||
#define PROBE_SM 0
|
||||
#define PROBE_PIN_OFFSET 2
|
||||
#define PROBE_PIN_SWCLK PROBE_PIN_OFFSET + 0 // 2
|
||||
#define PROBE_PIN_SWDIO PROBE_PIN_OFFSET + 1 // 3
|
||||
|
||||
// UART config
|
||||
#define PICOPROBE_UART_TX 4
|
||||
#define PICOPROBE_UART_RX 5
|
||||
#define PICOPROBE_UART_CTS 10
|
||||
#define PICOPROBE_UART_RTS 11
|
||||
#define PICOPROBE_UART_INTERFACE uart1
|
||||
#define PICOPROBE_UART_BAUDRATE 115200
|
||||
|
||||
// JTAG config
|
||||
#define PROBE_PIN_JTAG_TCK 2 // == SWCLK
|
||||
#define PROBE_PIN_JTAG_TMS 3 // == SWDIO
|
||||
#define PROBE_PIN_JTAG_TDI 6
|
||||
#define PROBE_PIN_JTAG_TDO 7
|
||||
#define PROBE_PIN_JTAG_nTRST 8
|
||||
#define PROBE_PIN_JTAG_nRESET 9
|
||||
|
||||
// SPI config
|
||||
#define PROBE_SPI_DEV spi1
|
||||
#define PROBE_SPI_SCLK 14
|
||||
#define PROBE_SPI_MOSI 15
|
||||
#define PROBE_SPI_MISO 12
|
||||
#define PROBE_SPI_nCS 13
|
||||
|
||||
// LED config
|
||||
|
||||
// you can change these two as you like
|
||||
#define PICOPROBE_LED_CONNECTED 1
|
||||
#define PICOPROBE_LED_RUNNING 0
|
||||
|
||||
#ifndef PICOPROBE_LED
|
||||
|
||||
#ifndef PICO_DEFAULT_LED_PIN
|
||||
#error PICO_DEFAULT_LED_PIN is not defined, run PICOPROBE_LED=<led_pin> cmake
|
||||
#elif PICO_DEFAULT_LED_PIN == -1
|
||||
#error PICO_DEFAULT_LED_PIN is defined as -1, run PICOPROBE_LED=<led_pin> cmake
|
||||
#else
|
||||
#define PICOPROBE_LED PICO_DEFAULT_LED_PIN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
#ifndef PINOUT_H_
|
||||
#define PINOUT_H_
|
||||
|
||||
// UART config
|
||||
#define PINOUT_UART_TX 4
|
||||
#define PINOUT_UART_RX 5
|
||||
#define PINOUT_UART_CTS 10
|
||||
#define PINOUT_UART_RTS 11
|
||||
#define PINOUT_UART_INTERFACE uart1
|
||||
#define PINOUT_UART_BAUDRATE 115200
|
||||
|
||||
// JTAG config
|
||||
#define PINOUT_JTAG_TCK 2 // == SWCLK
|
||||
#define PINOUT_JTAG_TMS 3 // == SWDIO
|
||||
#define PINOUT_JTAG_TDI 6
|
||||
#define PINOUT_JTAG_TDO 7
|
||||
#define PINOUT_JTAG_nTRST 8
|
||||
#define PINOUT_JTAG_nRESET 9
|
||||
|
||||
// SPI config
|
||||
#define PINOUT_SPI_DEV spi1
|
||||
#define PINOUT_SPI_SCLK 14
|
||||
#define PINOUT_SPI_MOSI 15
|
||||
#define PINOUT_SPI_MISO 12
|
||||
#define PINOUT_SPI_nCS 13
|
||||
|
||||
// LED config
|
||||
|
||||
// you can change these two as you like
|
||||
#define PINOUT_LED_CONNECTED 1
|
||||
#define PINOUT_LED_RUNNING 0
|
||||
|
||||
#ifndef PINOUT_LED
|
||||
#ifndef PICO_DEFAULT_LED_PIN
|
||||
#error "PICO_DEFAULT_LED_PIN is not defined, run PICOPROBE_LED=<led_pin> cmake"
|
||||
#elif PICO_DEFAULT_LED_PIN == -1
|
||||
#error "PICO_DEFAULT_LED_PIN is defined as -1, run PICOPROBE_LED=<led_pin> cmake"
|
||||
#else
|
||||
#define PINOUT_LED PICO_DEFAULT_LED_PIN
|
||||
#endif
|
||||
#endif /* PICOPROBE_LED */
|
||||
|
||||
#endif
|
||||
|
|
@ -5,13 +5,11 @@
|
|||
#include <pico/binary_info.h>
|
||||
#include <hardware/spi.h>
|
||||
|
||||
#include "protocfg.h"
|
||||
#include "pinout.h"
|
||||
#include "protos.h"
|
||||
|
||||
#include "serprog.h"
|
||||
|
||||
#include "picoprobe_config.h"
|
||||
|
||||
static bool cs_asserted;
|
||||
|
||||
void sp_spi_init(void) {
|
||||
|
@ -19,32 +17,32 @@ void sp_spi_init(void) {
|
|||
|
||||
cs_asserted = false;
|
||||
|
||||
spi_init(PROBE_SPI_DEV, 512*1000); // default to 512 kHz
|
||||
spi_init(PINOUT_SPI_DEV, 512*1000); // default to 512 kHz
|
||||
|
||||
gpio_set_function(PROBE_SPI_MISO, GPIO_FUNC_SPI);
|
||||
gpio_set_function(PROBE_SPI_MOSI, GPIO_FUNC_SPI);
|
||||
gpio_set_function(PROBE_SPI_SCLK, GPIO_FUNC_SPI);
|
||||
gpio_set_function(PINOUT_SPI_MISO, GPIO_FUNC_SPI);
|
||||
gpio_set_function(PINOUT_SPI_MOSI, GPIO_FUNC_SPI);
|
||||
gpio_set_function(PINOUT_SPI_SCLK, GPIO_FUNC_SPI);
|
||||
|
||||
//gpio_set_function(PROBE_SPI_nCS, GPIO_FUNC_SIO);
|
||||
gpio_init(PROBE_SPI_nCS);
|
||||
gpio_put(PROBE_SPI_nCS, 1);
|
||||
gpio_set_dir(PROBE_SPI_nCS, GPIO_OUT);
|
||||
//gpio_set_function(PINOUT_SPI_nCS, GPIO_FUNC_SIO);
|
||||
gpio_init(PINOUT_SPI_nCS);
|
||||
gpio_put(PINOUT_SPI_nCS, 1);
|
||||
gpio_set_dir(PINOUT_SPI_nCS, GPIO_OUT);
|
||||
|
||||
bi_decl(bi_3pins_with_func(PROBE_SPI_MISO, PROBE_SPI_MOSI, PROBE_SPI_SCLK, GPIO_FUNC_SPI));
|
||||
bi_decl(bi_1pin_with_name(PROBE_SPI_nCS, "SPI #CS"));
|
||||
bi_decl(bi_3pins_with_func(PINOUT_SPI_MISO, PINOUT_SPI_MOSI, PINOUT_SPI_SCLK, GPIO_FUNC_SPI));
|
||||
bi_decl(bi_1pin_with_name(PINOUT_SPI_nCS, "SPI #CS"));
|
||||
}
|
||||
uint32_t __not_in_flash_func(sp_spi_set_freq)(uint32_t freq_wanted) {
|
||||
return spi_set_baudrate(PROBE_SPI_DEV, freq_wanted);
|
||||
return spi_set_baudrate(PINOUT_SPI_DEV, freq_wanted);
|
||||
}
|
||||
void __not_in_flash_func(sp_spi_cs_deselect)(void) {
|
||||
asm volatile("nop\nnop\nnop"); // idk if this is needed
|
||||
gpio_put(PROBE_SPI_nCS, 1);
|
||||
gpio_put(PINOUT_SPI_nCS, 1);
|
||||
asm volatile("nop\nnop\nnop"); // idk if this is needed
|
||||
cs_asserted = false;
|
||||
}
|
||||
void __not_in_flash_func(sp_spi_cs_select)(void) {
|
||||
asm volatile("nop\nnop\nnop"); // idk if this is needed
|
||||
gpio_put(PROBE_SPI_nCS, 0);
|
||||
gpio_put(PINOUT_SPI_nCS, 0);
|
||||
asm volatile("nop\nnop\nnop"); // idk if this is needed
|
||||
cs_asserted = true;
|
||||
}
|
||||
|
@ -53,7 +51,7 @@ void __not_in_flash_func(sp_spi_op_begin)(void) {
|
|||
//sp_spi_cs_select();
|
||||
if (!cs_asserted) {
|
||||
asm volatile("nop\nnop\nnop"); // idk if this is needed
|
||||
gpio_put(PROBE_SPI_nCS, 0);
|
||||
gpio_put(PINOUT_SPI_nCS, 0);
|
||||
asm volatile("nop\nnop\nnop"); // idk if this is needed
|
||||
}
|
||||
}
|
||||
|
@ -61,16 +59,16 @@ void __not_in_flash_func(sp_spi_op_end)(void) {
|
|||
//sp_spi_cs_deselect();
|
||||
if (!cs_asserted) { // YES, this condition is the intended one!
|
||||
asm volatile("nop\nnop\nnop"); // idk if this is needed
|
||||
gpio_put(PROBE_SPI_nCS, 1);
|
||||
gpio_put(PINOUT_SPI_nCS, 1);
|
||||
asm volatile("nop\nnop\nnop"); // idk if this is needed
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: use dma?
|
||||
void __not_in_flash_func(sp_spi_op_write)(uint32_t write_len, const uint8_t* write_data) {
|
||||
spi_write_blocking(PROBE_SPI_DEV, write_data, write_len);
|
||||
spi_write_blocking(PINOUT_SPI_DEV, write_data, write_len);
|
||||
}
|
||||
void __not_in_flash_func(sp_spi_op_read)(uint32_t read_len, uint8_t* read_data) {
|
||||
spi_read_blocking(PROBE_SPI_DEV, 0, read_data, read_len);
|
||||
spi_read_blocking(PINOUT_SPI_DEV, 0, read_data, read_len);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,9 @@
|
|||
#include <pico/unique_id.h>
|
||||
#include "tusb.h"
|
||||
|
||||
static inline char nyb2hex(int x) {
|
||||
if (x < 0xa) return '0'+x;
|
||||
else return 'A'+x;
|
||||
}
|
||||
#include "util.h"
|
||||
|
||||
static uint8_t get_unique_id_u8(uint8_t *desc_str) {
|
||||
uint8_t get_unique_id_u8(uint8_t *desc_str) {
|
||||
pico_unique_board_id_t uid;
|
||||
uint8_t chr_count = 0;
|
||||
|
||||
|
@ -25,7 +22,7 @@ static uint8_t get_unique_id_u8(uint8_t *desc_str) {
|
|||
return chr_count;
|
||||
}
|
||||
|
||||
static uint8_t get_unique_id_u16(uint16_t *desc_str) {
|
||||
uint8_t get_unique_id_u16(uint16_t *desc_str) {
|
||||
pico_unique_board_id_t uid;
|
||||
uint8_t chr_count = 0;
|
||||
|
|
@ -1,12 +1,9 @@
|
|||
#include <stdint.h>
|
||||
#include "tusb.h"
|
||||
|
||||
static inline char nyb2hex(int x) {
|
||||
if (x < 0xa) return '0'+x;
|
||||
else return 'A'+x;
|
||||
}
|
||||
#include "util.h"
|
||||
|
||||
static uint8_t get_unique_id_u8(uint8_t *desc_str) {
|
||||
uint8_t get_unique_id_u8(uint8_t *desc_str) {
|
||||
const uint32_t *idpnt = (uint32_t*)(0x1FFFF7AC); /*DEVICE_ID1*/
|
||||
uint32_t tmp = 0;
|
||||
uint8_t chr_count = 0;
|
||||
|
@ -20,7 +17,7 @@ static uint8_t get_unique_id_u8(uint8_t *desc_str) {
|
|||
return chr_count;
|
||||
}
|
||||
|
||||
static uint8_t get_unique_id_u16(uint16_t *desc_str) {
|
||||
uint8_t get_unique_id_u16(uint16_t *desc_str) {
|
||||
const uint32_t *idpnt = (uint32_t*)(0x1FFFF7AC); /*DEVICE_ID1*/
|
||||
uint32_t tmp = 0;
|
||||
uint8_t chr_count = 0;
|
|
@ -160,7 +160,7 @@ static const struct i2c_algorithm usb_algorithm = {
|
|||
static const struct usb_device_id i2c_tiny_usb_table[] = {
|
||||
{ USB_DEVICE(0x0403, 0xc631) }, /* FTDI */
|
||||
{ USB_DEVICE(0x1c40, 0x0534) }, /* EZPrototypes */
|
||||
{ USB_DEVICE_INTERFACE_CLASS(0x2e8a, 0x6043, 0/*255*/) }, /* TinyUSB DapperMime: we want the Vendor interface */
|
||||
{ USB_DEVICE_INTERFACE_CLASS(0xcafe, 0x6043, 0/*255*/) }, /* TinyUSB DapperMime: we want the Vendor interface */
|
||||
{ } /* Terminating entry */
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifdef DBOARD_HAS_SERPROG
|
||||
|
||||
#include "protos.h"
|
||||
#include "thread.h"
|
||||
#include "util.h"
|
||||
#include "rtconf.h"
|
||||
|
||||
#include "serprog.h"
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "device/usbd_pvt.h"
|
||||
|
||||
#include "protos.h"
|
||||
#include "thread.h"
|
||||
|
||||
static uint8_t itf_num;
|
||||
|
||||
|
|
|
@ -35,11 +35,10 @@
|
|||
#include "DAP_config.h" /* ARM code *assumes* this is included prior to DAP.h */
|
||||
#include "DAP.h"
|
||||
|
||||
#include "util.h"
|
||||
#include "protocfg.h"
|
||||
#include "protos.h"
|
||||
|
||||
#include "libco.h"
|
||||
#include "thread.h"
|
||||
|
||||
#ifdef PICO_BOARD
|
||||
#include <pico/binary_info.h>
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
|
||||
#ifndef THREAD_H_
|
||||
#define THREAD_H_
|
||||
|
||||
void thread_yield(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "tusb.h"
|
||||
#include "unique.h"
|
||||
#include "util.h"
|
||||
#include "protos.h"
|
||||
|
||||
/* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug.
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
#ifndef UTIL_H_
|
||||
#define UTIL_H_
|
||||
|
||||
static inline char nyb2hex(int x) {
|
||||
if (x < 0xa) return '0'+x;
|
||||
else return 'A'+x;
|
||||
}
|
||||
|
||||
void thread_yield(void);
|
||||
|
||||
uint8_t get_unique_id_u8 (uint8_t * desc_str);
|
||||
uint8_t get_unique_id_u16(uint16_t* desc_str);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue