Rationalize board header pin defines, and add partner board headers (#192)

* Board definition header files for the iniital set of SparkFun rp2040 boards

* Add default PICO_DEFAULT_I2C*, allow no PICO_DEFAULT_LED_PIN, no PICO_DEFAULT_UART* (instead of -1)
Fixup SparkFun headers

* Pimoroni board headers

* Add LED related board defines PICO_CONFIGs (to pico_stdlib for now)

* more board config changes

* add Adafruit feather, itsybitsy, qtpy board headers

* add PICO_DEFAULT_WS2812_POWER_PIN define

* MOSI/MISO -> TX/RX, some UART cleanup.. make vgaboard.h defines take preference over pico.h ones

* local change to tinyusb to cope with no default LED or UART

* fix review issues

Co-authored-by: Kirk Benell <github-stuff@accvec.com>
Co-authored-by: ZodiusInfuser <christopher.parrott2@gmail.com>
Co-authored-by: hathach <thach@tinyusb.org>
This commit is contained in:
Graham Sanderson
2021-03-01 09:59:05 -06:00
committed by graham sanderson
parent 839224c2a3
commit 7ee36e3328
17 changed files with 952 additions and 74 deletions

View File

@ -18,11 +18,12 @@ static uart_inst_t *uart_instance;
#endif
void stdio_uart_init() {
#ifdef uart_default
int tx_pin = -1;
int rx_pin = -1;
#if defined(PICO_DEFAULT_UART_TX_PIN) && PICO_DEFAULT_UART_TX_PIN != -1
#ifdef PICO_DEFAULT_UART_TX_PIN
tx_pin = PICO_DEFAULT_UART_TX_PIN;
#if defined(PICO_DEFAULT_UART_RX_PIN) && PICO_DEFAULT_UART_RX_PIN != -1
#ifdef PICO_DEFAULT_UART_RX_PIN
rx_pin = PICO_DEFAULT_UART_RX_PIN;
stdio_bi_decl_if_func_used(bi_program_feature("UART stdin / stdout"));
bi_decl_if_func_used(bi_2pins_with_func(PICO_DEFAULT_UART_RX_PIN, PICO_DEFAULT_UART_TX_PIN, GPIO_FUNC_UART));
@ -30,22 +31,23 @@ void stdio_uart_init() {
stdio_bi_decl_if_func_used(bi_program_feature("UART stdout"));
bi_decl_if_func_used(bi_1pin_with_func(PICO_DEFAULT_UART_TX_PIN, GPIO_FUNC_UART));
#endif
#elif defined(PICO_DEFAULT_UART_RX_PIN) && PICO_DEFAULT_UART_RX_PIN != -1
#elif defined(PICO_DEFAULT_UART_RX_PIN)
rx_pin = PICO_DEFAULT_UART_RX_PIN;
stdio_bi_decl_if_func_used(bi_program_feature("UART stdin"));
bi_decl_if_func_used(bi_1pin_with_func(PICO_DEFAULT_UART_RX_PIN, GPIO_FUNC_UART));
#endif
#if !defined(PICO_DEFAULT_UART_BAUD_RATE) || !defined(uart_default)
#if !defined(PICO_DEFAULT_UART_BAUD_RATE)
panic("UART baud rate undefined");
#else
stdio_uart_init_full(uart_default, PICO_DEFAULT_UART_BAUD_RATE, tx_pin, rx_pin);
#endif
#endif
}
void stdout_uart_init() {
#ifdef PICO_DEFAULT_UART_TX_PIN
#if defined(uart_default) && defined(PICO_DEFAULT_UART_TX_PIN)
bi_decl_if_func_used(bi_1pin_with_func(PICO_DEFAULT_UART_TX_PIN, GPIO_FUNC_UART));
#if !defined(PICO_DEFAULT_UART_BAUD_RATE) || !defined(uart_default)
#if !defined(PICO_DEFAULT_UART_BAUD_RATE)
panic("UART baud rate undefined");
#else
stdio_bi_decl_if_func_used(bi_program_feature("UART stdout"));
@ -55,9 +57,9 @@ void stdout_uart_init() {
}
void stdin_uart_init() {
#ifdef PICO_DEFAULT_UART_RX_PIN
#if defined(uart_default) && defined(PICO_DEFAULT_UART_RX_PIN)
bi_decl_if_func_used(bi_1pin_with_func(PICO_DEFAULT_UART_RX_PIN, GPIO_FUNC_UART));
#if !defined(PICO_DEFAULT_UART_BAUD_RATE) || !defined(uart_default)
#if !defined(PICO_DEFAULT_UART_BAUD_RATE)
panic("UART baud rate undefined");
#else
stdio_bi_decl_if_func_used(bi_program_feature("UART stdin"));
@ -76,14 +78,14 @@ void stdio_uart_init_full(struct uart_inst *uart, uint baud_rate, int tx_pin, in
static void stdio_uart_out_chars(const char *buf, int length) {
for (int i = 0; i <length; i++) {
uart_putc(uart_default, buf[i]);
uart_putc(uart_instance, buf[i]);
}
}
int stdio_uart_in_chars(char *buf, int length) {
int i=0;
while (i<length && uart_is_readable(uart_default)) {
buf[i++] = uart_getc(uart_default);
while (i<length && uart_is_readable(uart_instance)) {
buf[i++] = uart_getc(uart_instance);
}
return i ? i : PICO_ERROR_NO_DATA;
}