diff --git a/Documentation/platforms/arm/rp2040/boards/raspberrypi-pico-w/RaspberryPiPicoW.png b/Documentation/platforms/arm/rp2040/boards/raspberrypi-pico-w/RaspberryPiPicoW.png new file mode 100644 index 00000000000..c261236a8b6 Binary files /dev/null and b/Documentation/platforms/arm/rp2040/boards/raspberrypi-pico-w/RaspberryPiPicoW.png differ diff --git a/Documentation/platforms/arm/rp2040/boards/raspberrypi-pico-w/index.rst b/Documentation/platforms/arm/rp2040/boards/raspberrypi-pico-w/index.rst new file mode 100644 index 00000000000..b72b96b42d1 --- /dev/null +++ b/Documentation/platforms/arm/rp2040/boards/raspberrypi-pico-w/index.rst @@ -0,0 +1,233 @@ +=============================== +Raspberry Pi Pico +=============================== + +The `Raspberry Pi Pico `_ is a general purpose board supplied by +the Raspberry Pi Foundation. The W variant adds built in WiFi communications. + +.. figure:: RaspberryPiPicoW.png + :align: center + +Features +======== + +* RP2040 microcontroller chip +* Dual-core ARM Cortex M0+ processor, flexible clock running up to 133 MHz +* 264kB of SRAM, and 2MB of on-board Flash memory +* Castellated module allows soldering direct to carrier boards +* USB 1.1 Host and Device support +* Low-power sleep and dormant modes +* Drag & drop programming using mass storage over USB +* 26 multi-function GPIO pins +* 2× SPI, 2× I2C, 2× UART, 3× 12-bit ADC, 16× controllable PWM channels +* Accurate clock and timer on-chip +* Temperature sensor +* Accelerated floating point libraries on-chip +* 8 × Programmable IO (PIO) state machines for custom peripheral support +* Built in WiFi radio (Infineon CYW43439) + +Serial Console +============== + +By default a serial console appears on pins 1 (TX GPIO0) and pin 2 +(RX GPIO1). This console runs a 115200-8N1. + +The board can be configured to use the USB connection as the serial console. + +Buttons and LEDs +================ + +LED controlled by GPIO0 of the wireless chip (not the RP2040 processor). + +A BOOTSEL button, which if held down when power is first +applied to the board, will cause the RP2040 to boot into programming +mode and appear as a storage device to a computer connected via USB. +Saving a .UF2 file to this device will replace the Flash ROM contents +on the RP2040. + +Wireless Communication +====================== + +The on board Infineon CYW43439 supports 2.4 GHz WiFi 4 communications +(802.11n), WPS3 and SoftAP with up to four clients. + +Pin Mapping +=========== + +===== ========== ========== +Pin Signal Notes +===== ========== ========== +1 GPIO0 Default TX for UART0 serial console +2 GPIO1 Default RX for UART1 serial console +3 Ground +4 GPIO2 +5 GPIO3 +6 GPIO4 +7 GPIO5 +8 Ground +9 GPIO6 +10 GPIO7 +11 GPIO8 +12 GPIO9 +13 Ground +14 GPIO10 +15 GPIO11 +16 GPIO12 +17 GPIO13 +18 Ground +19 GPIO14 +20 GPIO15 +21 GPIO16 +22 GPIO17 +23 Ground +24 GPIO18 +25 GPIO19 +26 GPIO20 +27 GPIO21 +28 Ground +29 GPIO22 +30 Run +31 GPIO26 ADC0 +32 GPIO27 ADC1 +33 AGND Analog Ground +34 GPIO28 ADC2 +35 ADC_VREF +36 3V3 Power output to peripherals +37 3V3_EN Pull to ground to turn off. +38 Ground +39 VSYS +5V Supply to board +40 VBUS Connected to USB +5V +===== ========== ========== + +Other RP2040 Pins +================= + +GPIO23 Output - WiFi controller enable. +GPIO24 I/O - WiFi controller data line. +GPIO25 Output - WiFi controller chip select line. +GPIO29 Output - WiFi controller clock line. +ADC3 Input - Analog voltage equal to one third of VSys voltage. + +Note: ADC3 and GPIO29 share the same pin on the RP2040. If the +GPIO25 line is held high (Wifi controller NOT selected) then a voltage +equal to one third of the VSys voltage with appear on this line and +can be read with ADC3. When the WiFi chip is selected this voltage +will be removed so the line can be used as a clock for data exchange +with the WiFi controller. + +Separate pins for the Serial Debug Port (SDB) are available + +WiFi Controller GPIO +==================== + +GPIO0 - Output - On board LED. +GPIO1 - Output - Power supply control. +GPIO2 - Input - High if USB port or Pad 40 supplying power. + +Power Supply +============ + +The Raspberry Pi Pico can be powered via the USB connector, +or by supplying +5V to pin 39. The board had a diode that prevents +power from pin 39 from flowing back to the USB socket, although +the socket can be power via pin 30. + +The Raspberry Pi Pico chip run on 3.3 volts. This is supplied +by an onboard voltage regulator. This regulator can be disabled +by pulling pin 37 to ground. + +The regulator can run in two modes. By default the regulator runs +in PFM mode which provides the best efficiency, but may be +switched to PWM mode for improved ripple by outputting a one +on the wireless chip's GPIO1 (not the RP2040's GPIO1). + +Configurations +============== + +audiopack +--------- + +NuttShell configuration (console enabled in UART0, at 115200 bps) with +support for NSPlayer audio player. + +composite +--------- + +NuttShell configuration (console enabled in UART0, at 115200 bps) with support for +CDC/ACM with MSC USB composite driver. + +displaypack +----------- + +NuttShell configuration (console enabled in USB Port, at 115200 bps) supporting +ST7789 video display. + +enc28j60 +-------- + +NuttShell configuration (console enabled in UART0, at 115200 bps) with support for +NC28J60. + +lcd1602 +------- + +NuttShell configuration (console enabled in UART0, at 115200 bps) with support for +LCD1602. + +nsh +--- + +Basic NuttShell configuration (console enabled in UART0, at 115200 bps). + +nshsram +------- + +NuttShell configuration (console enabled in UART0, at 115200 bps) with interrupt +vectors in RAM. + +smp +--- + +Basic NuttShell configuration (console enabled in UART0, at 115200 bps) with +both ARM cores enabled. + +spisd +----- + +NuttShell configuration (console enabled in UART0, at 115200 bps) with SPI configured. + +ssd1306 +------- + +NuttShell configuration (console enabled in UART0, at 115200 bps) with support for +ssd1306. + +st7735 +------ + +NuttShell configuration (console enabled in UART0, at 115200 bps) with support for +st7735. + +usbmsc +------ + +NuttShell configuration (console enabled in UART0, at 115200 bps) with support for +usbmsc. + +usbnsh +------ + +Basic NuttShell configuration (console enabled in USB Port, at 115200 bps). + +waveshare-lcd-1.14 +------------------ + +NuttShell configuration (console enabled in UART0, at 115200 bps) with support for +st7789. + +waveshare-lcd-1.3 +----------------- + +NuttShell configuration (console enabled in UART0, at 115200 bps) with support for +usbmsc. + diff --git a/Documentation/platforms/arm/rp2040/boards/raspberrypi-pico/index.rst b/Documentation/platforms/arm/rp2040/boards/raspberrypi-pico/index.rst index 69aed30a0df..f4585c6e669 100644 --- a/Documentation/platforms/arm/rp2040/boards/raspberrypi-pico/index.rst +++ b/Documentation/platforms/arm/rp2040/boards/raspberrypi-pico/index.rst @@ -39,9 +39,9 @@ Buttons and LEDs User LED controlled by GPIO25. A BOOTSEL button, which if held down when power is first -applied to the board, the cause the RP2040 to boot programming mode -and appear to a computer connected via USB as a storage device. -Saving a .UF2 file to this device will replace the Flash ROM contents +applied to the board, will cause the RP2040 to boot into programming +mode and appear as a storage device to a computer connected via USB . +Saving a .UF2 file to this device will replace the Flash ROM contents on the RP2040. Pin Mapping @@ -83,19 +83,27 @@ Pad Signal Notes 30 Run 31 GPIO26 ADC0 32 GPIO27 ADC1 -33 AGND Analog Ground +33 AGND Analog Ground 34 GPIO28 ADC2 35 ADC_VREF 36 3V3 Power output to peripherals -37 3V3_EN Pull to ground to turn off. +37 3V3_EN Pull to ground to turn off. 38 Ground 39 VSYS +5V Supply to board 40 VBUS Connected to USB +5V ===== ========== ========== +Other RP2040 Pins +================= + +GPIO23 Output - Power supply control. +GPIO24 Input - High if USB port or Pad 40 supplying power. +GPIO25 Output - On board LED. +ADC3 Input - Analog voltage equal to one third of VSys voltage. + Separate pins for the Serial Debug Port (SDB) are available -Power Supply +Power Supply ============ The Raspberry Pi Pico can be powered via the USB connector, @@ -108,9 +116,9 @@ by an onboard voltage regulator. This regulator can be disabled by pulling pin 37 to ground. The regulator can run in two modes. By default the regulator runs -in PFM mode which provides the best efficiency, but may be +in PFM mode which provides the best efficiency, but may be switched to PWM mode for improved ripple by outputting a one -on GPIO23. +on GPIO23. Configurations ============== diff --git a/arch/arm/src/rp2040/Kconfig b/arch/arm/src/rp2040/Kconfig index 00380ea4302..8e19f13aa0b 100644 --- a/arch/arm/src/rp2040/Kconfig +++ b/arch/arm/src/rp2040/Kconfig @@ -392,7 +392,7 @@ if RP2040_PWM if RP2040_PWM3 config RP2040_PWM3A_GPIO - + config RP2040_PWM3A_INVERT bool "PWM3 channel 1 invert" default n @@ -425,7 +425,7 @@ if RP2040_PWM See the Board Selection menu to configure the pins used by I2C0. if RP2040_PWM4 - + config RP2040_PWM4A_INVERT bool "PWM4 channel 1 invert" default n @@ -458,7 +458,7 @@ if RP2040_PWM See the Board Selection menu to configure the pins used by I2C0. if RP2040_PWM5 - + config RP2040_PWM5A_INVERT bool "PWM5 channel 1 invert" default n @@ -491,7 +491,7 @@ if RP2040_PWM See the Board Selection menu to configure the pins used by I2C0. if RP2040_PWM6 - + config RP2040_PWM6A_INVERT bool "PWM6 channel 1 invert" default n @@ -524,7 +524,7 @@ if RP2040_PWM See the Board Selection menu to configure the pins used by I2C0. if RP2040_PWM7 - + config RP2040_PWM7A_INVERT bool "PWM7 channel 1 invert" default n @@ -550,7 +550,7 @@ if RP2040_PWM default n endif # RP2040_PWM7 - + endif # RP2040_PWM ##################################################################### @@ -591,7 +591,7 @@ if RP2040_I2S range 0 3 endif - + ##################################################################### # I2S Configuration ##################################################################### @@ -672,11 +672,11 @@ if RP2040_ADC ---help--- If y, then the ADC chip temperature will be read. - + endif # ADC endif # RP2040_ADC - + ##################################################################### # WS2812 Configuration ##################################################################### @@ -685,6 +685,7 @@ config RP2040_BOARD_HAS_WS2812 bool "Has ws2812 pixels" default n depends on WS2812 + select WS2812_NON_SPI_DRIVER ---help--- See the Board Selection menu to configure the pins used by ws2812. diff --git a/arch/arm/src/rp2040/Make.defs b/arch/arm/src/rp2040/Make.defs index f3533f00770..e950476ed3c 100644 --- a/arch/arm/src/rp2040/Make.defs +++ b/arch/arm/src/rp2040/Make.defs @@ -82,4 +82,9 @@ ifeq ($(CONFIG_RP2040_FLASH_BOOT),y) ifneq ($(PICO_SDK_PATH),) include chip/boot2/Make.defs endif + +ifeq ($(CONFIG_IEEE80211_INFINEON_CYW43439),y) +CHIP_CSRCS += rp2040_cyw43439.c +endif + endif diff --git a/arch/arm/src/rp2040/hardware/rp2040_pads_bank0.h b/arch/arm/src/rp2040/hardware/rp2040_pads_bank0.h index 588abd6a2af..1e3b068ea30 100644 --- a/arch/arm/src/rp2040/hardware/rp2040_pads_bank0.h +++ b/arch/arm/src/rp2040/hardware/rp2040_pads_bank0.h @@ -69,11 +69,11 @@ #define RP2040_PADS_BANK0_GPIO_OD (1 << 7) /* Output disable. Has priority over output enable from peripherals */ #define RP2040_PADS_BANK0_GPIO_IE (1 << 6) /* Input enable */ #define RP2040_PADS_BANK0_GPIO_DRIVE_SHIFT (4) /* Drive strength. */ -#define RP2040_PADS_BANK0_GPIO_DRIVE_MASK (0x03 << RP2040_PADS_BANK0_GPIO0_DRIVE_SHIFT) -#define RP2040_PADS_BANK0_GPIO_DRIVE_2MA (0x0 << RP2040_PADS_BANK0_GPIO0_DRIVE_SHIFT) -#define RP2040_PADS_BANK0_GPIO_DRIVE_4MA (0x1 << RP2040_PADS_BANK0_GPIO0_DRIVE_SHIFT) -#define RP2040_PADS_BANK0_GPIO_DRIVE_8MA (0x2 << RP2040_PADS_BANK0_GPIO0_DRIVE_SHIFT) -#define RP2040_PADS_BANK0_GPIO_DRIVE_12MA (0x3 << RP2040_PADS_BANK0_GPIO0_DRIVE_SHIFT) +#define RP2040_PADS_BANK0_GPIO_DRIVE_MASK (0x03 << RP2040_PADS_BANK0_GPIO_DRIVE_SHIFT) +#define RP2040_PADS_BANK0_GPIO_DRIVE_2MA (0x0 << RP2040_PADS_BANK0_GPIO_DRIVE_SHIFT) +#define RP2040_PADS_BANK0_GPIO_DRIVE_4MA (0x1 << RP2040_PADS_BANK0_GPIO_DRIVE_SHIFT) +#define RP2040_PADS_BANK0_GPIO_DRIVE_8MA (0x2 << RP2040_PADS_BANK0_GPIO_DRIVE_SHIFT) +#define RP2040_PADS_BANK0_GPIO_DRIVE_12MA (0x3 << RP2040_PADS_BANK0_GPIO_DRIVE_SHIFT) #define RP2040_PADS_BANK0_GPIO_PUE (1 << 3) /* Pull up enable */ #define RP2040_PADS_BANK0_GPIO_PDE (1 << 2) /* Pull down enable */ #define RP2040_PADS_BANK0_GPIO_SCHMITT (1 << 1) /* Enable schmitt trigger */ diff --git a/arch/arm/src/rp2040/hardware/rp2040_pio.h b/arch/arm/src/rp2040/hardware/rp2040_pio.h index 7e9a5234905..f797e2ad1ba 100644 --- a/arch/arm/src/rp2040/hardware/rp2040_pio.h +++ b/arch/arm/src/rp2040/hardware/rp2040_pio.h @@ -207,6 +207,9 @@ #define RP2040_PIO_FLEVEL_TX0_SHIFT (0) #define RP2040_PIO_FLEVEL_TX0_MASK (0x0f) +#define RP2040_PIO_FLEVEL_TX_MASK(n) (0x0f << 8*n) +#define RP2040_PIO_FLEVEL_RX_MASK(n) (0xf0 << 8*n) + #define RP2040_PIO_IRQ_MASK (0xff) #define RP2040_PIO_IRQ_FORCE_MASK (0xff) diff --git a/arch/arm/src/rp2040/rp2040_cyw43439.c b/arch/arm/src/rp2040/rp2040_cyw43439.c new file mode 100644 index 00000000000..3c95f5444dc --- /dev/null +++ b/arch/arm/src/rp2040/rp2040_cyw43439.c @@ -0,0 +1,832 @@ +/**************************************************************************** + * arch/arm/src/rp2040/rp2040_cyw43439.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "rp2040_cyw43439.h" +#include "rp2040_pio.h" +#include "rp2040_pio_instructions.h" + +#ifdef CONFIG_NDEBUG +# define PRINT_GSPI(block) +#else +void bcmf_hexdump(uint8_t *data, unsigned int len, unsigned long offset); +bool g_print_gspi = false; +# define PRINT_GSPI(block) if (g_print_gspi) { block } +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define GSPI_CLOCK_FREQ 31250000 /* Hz (Max: 50MHz) */ + +#define PIO_WRAP_TARGET 0 +#define PIO_WRAP 5 + +#define TX_FIFO_SIZE 4 + +/**************************************************************************** + * Private Type Definitions + ****************************************************************************/ + +typedef struct dma_info_s +{ + sem_t sem; + uint8_t status; +} dma_info_t; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* This is the PIO program to write and then read from the data pin. + * + * The X register is the output bit count register. It should be set + * to one less than the total number of BITS to be transmitted. + * + * The Y register is the input bit count register. It too must be set + * to one less thant the total number of bits to be read. + * + * The PIO's state machine is set up to auto-pull data from the input + * fifo whenever the output shift register is empty. This happens at + * the start and every 32 bits thereafter. + * + * The state machine also auto-pushes whenever we have a full 32 bits + * in the input shift register. To make sure we receive all the data, + * we need to make sure that the read bit count is a multiple of 32. + * (Y = 32*N - 1 for some integer N) + */ + +static const uint16_t cyw_program_instructions[] = +{ + 0x6001, /* 0: out pins, 1 side 0 # Write one bit */ + 0x1040, /* 1: jmp x--, 0 side 1 # Loop until write count is zero */ + 0xe080, /* 2: set pindirs, 0 side 0 # Make data pin an input */ + 0xb042, /* 3: nop side 1 # Keep clock in sync */ + 0x4001, /* 4: in pins, 1 side 0 # Read 1 bit */ + 0x1084, /* 5: jmp y--, 4 side 1 # Loop until read count is zero */ +}; + +static const rp2040_pio_program_t pio_program = +{ + .instructions = cyw_program_instructions, + .length = 6, /* Six, count 'em, six. */ + .origin = -1, /* Put it wherever it fits */ +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: dma_complete + * + * Description: + * Called on completion of the DMA transfer. + * + * Input Parameters: + * handle - handle to our DMA channel + * status - status of the transfer + * arg - Pointer to dma info structure. + * + ****************************************************************************/ + +static void dma_complete(DMA_HANDLE handle, uint8_t status, void *arg) +{ + FAR dma_info_t *dma_info = arg; + + /* Remember the status and post the dma complete event. */ + + dma_info->status = status; + nxsem_post(&(dma_info->sem)); +} + +/**************************************************************************** + * Name: my_init + * + * Description: + * Connect to and initialize the cyw43439. + * + ****************************************************************************/ + +static int my_init(FAR gspi_dev_t *gspi) +{ + FAR rp2040_gspi_t *rp_io = (FAR rp2040_gspi_t *)(gspi->io_dev); + + uint32_t divisor; + irqstate_t flags; + rp2040_pio_sm_config config = + { + 0 + }; + + /* Make sure the cyw43439 chip is deselected, and off. + * so we know it is reset + */ + + rp2040_gpio_put(rp_io->gpio_select, true); /* deselect */ + rp2040_gpio_put(rp_io->gpio_on, false); /* power off */ + + /* Pull the data line low so that we initialise to gSPI mode */ + + rp2040_gpio_init(rp_io->gpio_data); + rp2040_gpio_setdir(rp_io->gpio_data, true); + rp2040_gpio_put(rp_io->gpio_data, false); + + usleep(50000); /* Leave off for at least 50ms. */ + + rp2040_gpio_put(rp_io->gpio_on, true); /* power on */ + + usleep(50000); /* Wait a bit to let the power come up. */ + + /* Don't let anyone else grab a PIO while we are doing so. */ + + flags = enter_critical_section(); + + /* Find a PIO instance and load program. */ + + for (rp_io->pio = 0; rp_io->pio < RP2040_PIO_NUM; ++rp_io->pio) + { + /* Try to claim a state machine. */ + + rp_io->pio_sm = rp2040_pio_claim_unused_sm(rp_io->pio, false); + + /* If we did not get one try the next pio block, if any. */ + + if (rp_io->pio_sm < 0) continue; + + /* See if we have space in this block to load our program. */ + + if (rp2040_pio_can_add_program(rp_io->pio, &pio_program)) + { + /* Great! load the program and exit the pio choice loop. */ + + rp_io->pio_location = rp2040_pio_add_program(rp_io->pio, + &pio_program); + + break; + } + + /* Oops -- no room at the inn! Release sm and try next pio. */ + + rp2040_pio_sm_unclaim(rp_io->pio, rp_io->pio_sm); + } + + if (rp_io->pio >= RP2040_PIO_NUM) + { + leave_critical_section(flags); + return -ENOMEM; + } + + leave_critical_section(flags); + + /* ==== Configure the PIO State Machine ==== */ + + /* Configure pins that are used by PIO. */ + + rp2040_pio_gpio_init(rp_io->pio, rp_io->gpio_data); + rp2040_pio_gpio_init(rp_io->pio, rp_io->gpio_clock); + + rp2040_gpio_set_input_hysteresis_enabled(rp_io->gpio_data, true); + + rp2040_gpio_set_slew_fast(rp_io->gpio_clock, true); + rp2040_gpio_set_drive_strength(rp_io->gpio_clock, + RP2040_PADS_BANK0_GPIO_DRIVE_12MA); + + /* Set the clock divisor as appropriate for our system clock + * speed, so the pio clock runs the requested bit clock rate. + */ + + divisor = ((uint64_t)BOARD_SYS_FREQ << 8) / (2 * GSPI_CLOCK_FREQ); + + rp2040_sm_config_set_clkdiv_int_frac(&config, + divisor >> 8, + divisor & 0xff); + + /* Set the wrap points as required by the program. */ + + rp2040_sm_config_set_wrap(&config, + rp_io->pio_location + PIO_WRAP_TARGET, + rp_io->pio_location + PIO_WRAP); + + /* set to shift left, 32 bits, with autopull/push */ + + rp2040_sm_config_set_in_shift(&config, false, true, 32); + rp2040_sm_config_set_out_shift(&config, false, true, 32); + + /* Configure a single mandatory side-set pin. */ + + rp2040_sm_config_set_sideset(&config, 1, false, false); + + /* Configure our GPIO clock pin as side-set output. */ + + rp2040_sm_config_set_sideset_pins(&config, rp_io->gpio_clock); + + /* Configure out GPIO data pin as an OUT pin, SET pin, and IN pin */ + + rp2040_sm_config_set_out_pins(&config, rp_io->gpio_data, 1); + rp2040_sm_config_set_set_pins(&config, rp_io->gpio_data, 1); + rp2040_sm_config_set_in_pins (&config, rp_io->gpio_data); + + /* Load the configuration into the state machine. */ + + rp2040_pio_sm_init(rp_io->pio, + rp_io->pio_sm, + rp_io->pio_location, + &config); + + /* Disable the input synchronizers on the data pin */ + + rp2040_pio_set_input_sync_bypass(rp_io->pio, rp_io->gpio_data, true); + + wlinfo("finished\n"); + + return OK; +} + +/**************************************************************************** + * Name: my_set_isr + * + * Description: + * Setup the data line interrupt service routine. + * + ****************************************************************************/ + +static int my_set_isr(FAR gspi_dev_t *gspi, + xcpt_t thread_isr, + FAR void *thread_isr_arg) +{ + FAR rp2040_gspi_t *rp_io = (FAR rp2040_gspi_t *)(gspi->io_dev); + + /* Set up, but do not enable, interrupt service for the data pin */ + + rp2040_gpio_irq_attach(rp_io->gpio_intr, + RP2040_GPIO_INTR_LEVEL_HIGH, + thread_isr, + thread_isr_arg); + + wlinfo("attached\n"); + + return OK; +} + +/**************************************************************************** + * Name: my_interrupt_enable + * + * Description: + * Setup the data line isr. + * + ****************************************************************************/ + +static int my_interrupt_enable(FAR gspi_dev_t *gspi, + bool enable) +{ + FAR rp2040_gspi_t *rp_io = (FAR rp2040_gspi_t *)(gspi->io_dev); + static int disable_count = 0; + + if (enable) + { + if (--disable_count <= 0) rp2040_gpio_enable_irq(rp_io->gpio_intr); + } + else + { + rp2040_gpio_disable_irq(rp_io->gpio_intr); + ++disable_count; + } + + return OK; +} + +/**************************************************************************** + * Name: my_deinit + * + * Description: + * Disconnect from cyw43439 and cleanup. + * + ****************************************************************************/ + +static int my_deinit(FAR gspi_dev_t *gspi) +{ + FAR rp2040_gspi_t *rp_io = (FAR rp2040_gspi_t *)(gspi->io_dev); + + rp2040_gpio_irq_attach(rp_io->gpio_data, + RP2040_GPIO_INTR_EDGE_LOW, + NULL, + NULL); + + rp2040_pio_sm_set_enabled(rp_io->pio, rp_io->pio_sm, false); + rp2040_pio_remove_program(rp_io->pio, &pio_program, rp_io->pio_location); + rp2040_pio_sm_unclaim(rp_io->pio, rp_io->pio_sm); + + /* Turn the power off to the cyw43439. */ + + rp2040_gpio_put(rp_io->gpio_on, false); + + return OK; +} + +/**************************************************************************** + * Name: my_write + * + * Description: + * write data to the cyw43439 + * + ****************************************************************************/ + +static int my_write(FAR struct gspi_dev_s *gspi, + bool increment, + enum gspi_cmd_func_e function, + uint32_t address, + uint16_t length, + FAR const uint32_t *data) +{ + FAR rp2040_gspi_t *rp_io = (FAR rp2040_gspi_t *)(gspi->io_dev); + dma_info_t dma_info; + DMA_HANDLE xfer_dma = rp2040_dmachannel(); + uint32_t command = (0x1 << 31) + | ((increment ? 1 : 0) << 30) + | ((function & 0x3) << 28) + | ((address & 0x1ffff) << 11) + | (length & 0x7ff); + + dma_config_t dma_config = + { + .size = RP2040_DMA_SIZE_WORD, + .noincr = false, + .dreq = rp2040_pio_get_dreq(rp_io->pio, + rp_io->pio_sm, + true), + }; + + PRINT_GSPI( + printf("------ cmd: 0x%08lx [W %d %d 0x%05lX %d]\n", command, + increment, + function, + address, + length); + bcmf_hexdump((void *)data, length, (uint32_t)data); + ) + + /* Claim the exclusive lock */ + + nxsem_wait(&gspi->exclsem); + + /* Reset the PIO state machine just to be sure. */ + + rp2040_pio_sm_set_enabled(rp_io->pio, rp_io->pio_sm, false); + + rp2040_pio_sm_clear_fifos(rp_io->pio, rp_io->pio_sm); + + rp2040_pio_sm_restart(rp_io->pio, rp_io->pio_sm); + + rp2040_pio_sm_clkdiv_restart(rp_io->pio, rp_io->pio_sm); + + rp2040_pio_sm_exec(rp_io->pio, + rp_io->pio_sm, + pio_encode_jmp(rp_io->pio_location)); + + /* Set the PIO X (tx bit len) and Y (rx bit len) registers. + * This is slightly magical. The way we load the X is to first + * push the the number of bits to transmit onto the transmit fifo. + * Then we force the PIO state machine to execute the instruction + * "out x, 32" which transfers the word from the output shift + * register (OSR) to the X register. When this instruction executes + * the PIO will notice the the OSR is empty, so will automatically + * pull a value (the one we just added) from the input fifo. + * + * Loading the Y works the same way, except we round the number of + * bits up to a multiple of 32, so the pio program will be sure to + * autopush the final data to the output fifo. + */ + + rp2040_pio_sm_put(rp_io->pio, rp_io->pio_sm, 32 * ((length + 3) / 4) + 31); + rp2040_pio_sm_exec(rp_io->pio, rp_io->pio_sm, pio_encode_out(pio_x, 32)); + + rp2040_pio_sm_put(rp_io->pio, rp_io->pio_sm, 0); + rp2040_pio_sm_exec(rp_io->pio, rp_io->pio_sm, pio_encode_out(pio_y, 32)); + + /* Disable interrupts so data won't trigger interrupt. */ + + my_interrupt_enable(gspi, false); + + /* Make sure the clock and data pins direction set to output. */ + + rp2040_pio_sm_set_pindirs_with_mask(rp_io->pio, + rp_io->pio_sm, + (1 << rp_io->gpio_data) + | (1 << rp_io->gpio_clock), + (1 << rp_io->gpio_data) + | (1 << rp_io->gpio_clock)); + + /* Make sure there is nothing in the fifos before starting DMA. */ + + rp2040_pio_sm_clear_fifos(rp_io->pio, rp_io->pio_sm); + + /* Load the command into the transmit fifo. */ + + if (function == gspi_f0_bus_rev16) + { + __asm ("rev16 %0, %0" : "+l" (command) : :); + } + + __asm ("rev %0, %0" : "+l" (command) : :); + + putreg32(command, RP2040_PIO_TXF(rp_io->pio, rp_io->pio_sm)); + + /* Initialize and start the transmit DMA. It will + * keep adding data to the TX_FIFO until all data is sent. + */ + + nxsem_init(&dma_info.sem, 0, 0); + + rp2040_dmastop(xfer_dma); + + rp2040_txdmasetup(xfer_dma, + (uintptr_t) RP2040_PIO_TXF(rp_io->pio, + rp_io->pio_sm), + (uintptr_t) data, + (length + 3) & 0xfffffffc, + dma_config); + + modifyreg32(rp2040_dma_register(xfer_dma, + RP2040_DMA_CTRL_TRIG_OFFSET), + RP2040_DMA_CTRL_TRIG_BSWAP, + RP2040_DMA_CTRL_TRIG_BSWAP); + + rp2040_dmastart(xfer_dma, dma_complete, &dma_info); + + /* Assert gpio_select by pulling line low */ + + rp2040_gpio_put(rp_io->gpio_select, false); + + /* Enable the state machine. This starts the pio program running */ + + rp2040_pio_sm_set_enabled(rp_io->pio, rp_io->pio_sm, true); + + /* Wait for transfer to complete */ + + nxsem_wait(&dma_info.sem); + + /* Un-assert select by pulling line high. */ + + rp2040_gpio_put(rp_io->gpio_select, true); + + /* Free the DMA controller */ + + rp2040_dmafree(xfer_dma); + nxsem_destroy(&dma_info.sem); + + /* Disable the PIO */ + + rp2040_pio_sm_set_enabled(rp_io->pio, rp_io->pio_sm, false); + + /* At this point the data pin is input so it should be pulled high */ + + my_interrupt_enable(gspi, true); + + /* Release the exclusive lock */ + + nxsem_post(&gspi->exclsem); + + return dma_info.status; +} + +/**************************************************************************** + * Name: my_read + * + * Description: + * read data to the cyw43439 + * + ****************************************************************************/ + +static int my_read(FAR struct gspi_dev_s *gspi, + bool increment, + enum gspi_cmd_func_e function, + uint32_t address, + uint16_t length, + FAR uint32_t *buffer) +{ + FAR rp2040_gspi_t *rp_io = (FAR rp2040_gspi_t *)(gspi->io_dev); + dma_info_t dma_info; + DMA_HANDLE xfer_dma = rp2040_dmachannel(); + DMA_HANDLE ctrl_dma = rp2040_dmachannel(); + uint32_t temp_word; + uint32_t bit_length; + uint32_t command = ((increment ? 1 : 0) << 30) + | ((function & 0x3) << 28) + | ((address & 0x1ffff) << 11) + | (length & 0x7ff); + + uint32_t pacing = rp2040_pio_get_dreq(rp_io->pio, + rp_io->pio_sm, + false); + + dma_control_block_t ctrl_blks[] = + { + /* For F1 transfers we read 1 word that we throw away */ + + { + rp2040_dma_ctrl_blk_ctrl(ctrl_dma, + RP2040_DMA_SIZE_WORD, + pacing, + 0), + (uintptr_t) RP2040_PIO_RXF(rp_io->pio, rp_io->pio_sm), + (uintptr_t) &temp_word, + 1, + }, + + /* Read requested data into output buffer */ + + { + rp2040_dma_ctrl_blk_ctrl(ctrl_dma, + RP2040_DMA_SIZE_WORD, + pacing, + RP2040_DMA_CTRL_TRIG_INCR_WRITE + | RP2040_DMA_CTRL_TRIG_BSWAP), + (uintptr_t) RP2040_PIO_RXF(rp_io->pio, rp_io->pio_sm), + (uintptr_t) buffer, + (length + 3) / 4, + }, + + RP2040_DMA_CTRL_BLOCK_END + }; + + PRINT_GSPI( + printf("------ cmd: 0x%08lx [R %d %d 0x%05lX %d]\n", command, + increment, + function, + address, + length); + ) + + /* Claim the exclusive lock */ + + nxsem_wait(&gspi->exclsem); + + /* Reset the PIO state machine just to be sure. */ + + rp2040_pio_sm_set_enabled(rp_io->pio, rp_io->pio_sm, false); + + rp2040_pio_sm_clear_fifos(rp_io->pio, rp_io->pio_sm); + + rp2040_pio_sm_restart(rp_io->pio, rp_io->pio_sm); + + rp2040_pio_sm_clkdiv_restart(rp_io->pio, rp_io->pio_sm); + + rp2040_pio_sm_exec(rp_io->pio, + rp_io->pio_sm, + pio_encode_jmp(rp_io->pio_location)); + + /* Set the PIO X (tx bit len) and Y (rx bit len) registers. + * This is slightly magical. The way we load the X is to first + * push the the number of bits to transmit onto the transmit fifo. + * Then we force the PIO state machine to execute the instruction + * "out x, 32" which transfers the word from the output shift + * register (OSR) to the X register. When this instruction executes + * the PIO will notice the the OSR is empty, so will automatically + * pull a value (the one we just added) from the input fifo. + * + * Loading the Y works the same way, except we round the number of + * bits up to a multiple of 32, so the pio program will be sure to + * autopush the final data to the output fifo. + */ + + rp2040_pio_sm_put(rp_io->pio, rp_io->pio_sm, 31); + rp2040_pio_sm_exec(rp_io->pio, rp_io->pio_sm, pio_encode_out(pio_x, 32)); + + /* RX bit length is 32 bits for each 4 bytes requested + * plus 32 bits for status + */ + + bit_length = 32 * ((length + 3) / 4); + + /* For F1 reads and 32 bits for delay */ + + if (function == gspi_f1_backplane) bit_length += 32; + + rp2040_pio_sm_put(rp_io->pio, rp_io->pio_sm, bit_length); + rp2040_pio_sm_exec(rp_io->pio, rp_io->pio_sm, pio_encode_out(pio_y, 32)); + + /* Disable interrupts so data won't trigger interrupt. */ + + my_interrupt_enable(gspi, false); + + /* Make sure the clock and data pins direction set to output. */ + + rp2040_pio_sm_set_pindirs_with_mask(rp_io->pio, + rp_io->pio_sm, + (1 << rp_io->gpio_data) + | (1 << rp_io->gpio_clock), + (1 << rp_io->gpio_data) + | (1 << rp_io->gpio_clock)); + + /* Make sure there is nothing in the fifos before starting DMA. */ + + rp2040_pio_sm_clear_fifos(rp_io->pio, rp_io->pio_sm); + + /* Load the command into the transmit fifo. */ + + if (function == gspi_f0_bus_rev16) + { + __asm ("rev16 %0, %0" : "+l" (command) : :); + } + + __asm ("rev %0, %0" : "+l" (command) : :); + + putreg32(command, RP2040_PIO_TXF(rp_io->pio, rp_io->pio_sm)); + + /* Initialize and start the control DMA. It will + * use the xfer_dma to transfer data from the chip. + */ + + nxsem_init(&dma_info.sem, 0, 0); + + rp2040_dmastop(ctrl_dma); + rp2040_dmastop(xfer_dma); + + /* Check the function bits if the command word to see if + * this is an F1 read. If it is we throw away the first + * four bytes read as this is a delay word. + */ + + rp2040_ctrl_dmasetup(ctrl_dma, + xfer_dma, + &ctrl_blks[function == 1 ? 0 : 1], + dma_complete, + &dma_info); + + rp2040_dmastart(ctrl_dma, NULL, NULL); + + /* Assert gpio_select by pulling line low */ + + rp2040_gpio_put(rp_io->gpio_select, false); + + /* Enable the state machine. This starts the pio program running */ + + rp2040_pio_sm_set_enabled(rp_io->pio, rp_io->pio_sm, true); + + /* Wait for transfer to complete */ + + nxsem_wait(&dma_info.sem); + + PRINT_GSPI( + bcmf_hexdump((void *)buffer, length, (uint32_t)buffer); + ) + + /* Un-assert select by pulling line high. */ + + rp2040_gpio_put(rp_io->gpio_select, true); + + /* Free the DMA controllers */ + + rp2040_dmafree(ctrl_dma); + rp2040_dmafree(xfer_dma); + + nxsem_destroy(&dma_info.sem); + + /* Disable the PIO */ + + rp2040_pio_sm_set_enabled(rp_io->pio, rp_io->pio_sm, false); + + /* At this point the data pin is input so it should be pulled high */ + + my_interrupt_enable(gspi, true); + + /* Release the exclusive lock */ + + nxsem_post(&gspi->exclsem); + + return dma_info.status; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_cyw_setup + * + * Description: + * Initialize the cyw43439 private data and PIO communication. + ****************************************************************************/ + +gspi_dev_t *rp2040_cyw_setup(uint8_t gpio_on, + uint8_t gpio_select, + uint8_t gpio_data, + uint8_t gpio_clock, + uint8_t gpio_intr) +{ + FAR gspi_dev_t *gspi; + FAR rp2040_gspi_t *rp_io; + int err; + + wlinfo("entered.\n"); + + gspi = kmm_zalloc(sizeof(gspi_dev_t)); + + if (gspi == NULL) + { + set_errno(ENOMEM); + return NULL; + } + + rp_io = kmm_zalloc(sizeof(rp2040_gspi_t)); + + if (rp_io == NULL) + { + kmm_free(gspi); + set_errno(ENOMEM); + return NULL; + } + + gspi->init = my_init; + gspi->deinit = my_deinit; + gspi->set_isr = my_set_isr; + gspi->interrupt_enable = my_interrupt_enable; + gspi->write = my_write; + gspi->read = my_read; + gspi->io_dev = rp_io; + + rp_io->gpio_on = gpio_on; + rp_io->gpio_select = gpio_select; + rp_io->gpio_data = gpio_data; + rp_io->gpio_clock = gpio_clock; + rp_io->gpio_intr = gpio_intr; + + nxsem_init(&gspi->exclsem, 0, 1); + + /* Initialize the cyw43439 power-on and chip select lines. */ + + rp2040_gpio_init(gpio_on); + rp2040_gpio_setdir(gpio_on, true); + rp2040_gpio_put(gpio_on, false); /* set low to turn wifi chip off */ + + rp2040_gpio_init(gpio_select); + rp2040_gpio_setdir(gpio_select, true); + rp2040_gpio_put(gpio_select, true); /* set high to deselect chip */ + + err = bcmf_gspi_initialize(gspi); + + if (err != OK) + { + kmm_free(gspi); + kmm_free(rp_io); + + set_errno(err); + return NULL; + } + + wlinfo("setup complete. gspi = 0x%08lX\n", (uint32_t) gspi); + + return (FAR void *) gspi; +} + +/**************************************************************************** + * Name: rp2040_cyw_remove + * + * Description: + * Deinitialize the cyw43439 PIO communication. + ****************************************************************************/ + +void rp2040_cyw_remove(gspi_dev_t *gspi) +{ + /* gspi_deregister((FAR gspi_dev_t *)gspi); */ +} + +/**************************************************************************** + * Name: bcmf_board_etheraddr + ****************************************************************************/ + +bool bcmf_board_etheraddr(struct ether_addr *ethaddr) +{ + return false; +} diff --git a/arch/arm/src/rp2040/rp2040_cyw43439.h b/arch/arm/src/rp2040/rp2040_cyw43439.h new file mode 100644 index 00000000000..8cbf7932cf7 --- /dev/null +++ b/arch/arm/src/rp2040/rp2040_cyw43439.h @@ -0,0 +1,115 @@ +/**************************************************************************** + * arch/arm/src/rp2040/rp2040_cyw43439.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_COMMON_INCLUDE_RP2040_CYW43439_H +#define __BOARDS_ARM_RP2040_COMMON_INCLUDE_RP2040_CYW43439_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +typedef struct rp2040_gspi_s +{ + uint32_t pio; /* The pio instance we are using. */ + uint32_t pio_sm; /* The state machine we are using. */ + uint32_t pio_location; /* the program location in the pio. */ + uint8_t gpio_on; /* Set high to power chip on */ + uint8_t gpio_select; /* Pull low to select chip */ + uint8_t gpio_data; /* Data line -- idle high */ + uint8_t gpio_clock; /* Clock line -- idle low */ + uint8_t gpio_intr; /* May be shared with data */ +} rp2040_gspi_t; + +typedef struct cyw_pio_program_s +{ + const uint16_t *instructions; + uint8_t length; + int8_t origin; /* required instruction memory origin or -1 */ +} cyw_pio_program_t; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_cyw_setup + * + * Description: + * Initialize the cyw43439 device. + * + * Returns: + * A pointer to the cyw43439 device + * + ****************************************************************************/ + +gspi_dev_t *rp2040_cyw_setup(uint8_t gpio_on, + uint8_t gpio_select, + uint8_t gpio_data, + uint8_t gpio_clock, + uint8_t gpio_intr); + +/**************************************************************************** + * Name: rp2040_cyw_remove + * + * Description: + * Deinitialize the cyw43439 device. + * + * Parameters: + * A pointer (as returned by rp2040_cyw_setup) to the device to remove. + * + ****************************************************************************/ + +void rp2040_cyw_remove(FAR gspi_dev_t *dev); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RP2040_COMMON_INCLUDE_RP2040_CYW43439_H */ diff --git a/arch/arm/src/rp2040/rp2040_dmac.c b/arch/arm/src/rp2040/rp2040_dmac.c index d43d3787dc1..3d22127229c 100644 --- a/arch/arm/src/rp2040/rp2040_dmac.c +++ b/arch/arm/src/rp2040/rp2040_dmac.c @@ -53,7 +53,6 @@ struct dma_channel_s { uint8_t chan; /* DMA channel number (0-RP2040_DMA_NCHANNELS) */ bool inuse; /* TRUE: The DMA channel is in use */ - dma_config_t config; /* Current configuration */ dma_callback_t callback; /* Callback invoked when the DMA completes */ void *arg; /* Argument passed to callback function */ }; @@ -334,10 +333,6 @@ void rp2040_rxdmasetup(DMA_HANDLE handle, uintptr_t paddr, uintptr_t maddr, DEBUGASSERT(dmach != NULL && dmach->inuse); ch = dmach->chan; - /* Save the configuration (for rp2040_dmastart()). */ - - dmach->config = config; - DEBUGASSERT(config.size >= RP2040_DMA_SIZE_BYTE && config.size <= RP2040_DMA_SIZE_WORD); @@ -395,10 +390,6 @@ void rp2040_txdmasetup(DMA_HANDLE handle, uintptr_t paddr, uintptr_t maddr, DEBUGASSERT(dmach != NULL && dmach->inuse); ch = dmach->chan; - /* Save the configuration (for rp2040_dmastart()). */ - - dmach->config = config; - DEBUGASSERT(config.size >= RP2040_DMA_SIZE_BYTE && config.size <= RP2040_DMA_SIZE_WORD); @@ -429,6 +420,115 @@ void rp2040_txdmasetup(DMA_HANDLE handle, uintptr_t paddr, uintptr_t maddr, putreg32(ctrl, RP2040_DMA_CTRL_TRIG(ch)); } +/**************************************************************************** + * Name: rp2040_ctrl_dmasetup + * + * Description: + * Configure a dma channel to send a list of channel control blocks to + * a second dma channel.. + * + * Input Parameters: + * control - the DMA handle that reads the control blocks. This is + * the one that should be started. + * transfer - the DMA handle the transfers data to the peripheral. + * ctrl_blks - the array of control blocks to used. Terminate this + * list with an all zero control block. + * callback - callback when last transfer completes + * arg - arg to pass to callback + * + ****************************************************************************/ + +void rp2040_ctrl_dmasetup(DMA_HANDLE control, + DMA_HANDLE transfer, + dma_control_block_t *ctrl_blks, + dma_callback_t callback, + void *arg) +{ + struct dma_channel_s *ctrl_dmach = (struct dma_channel_s *)control; + struct dma_channel_s *xfer_dmach = (struct dma_channel_s *)transfer; + uint32_t ctrl_ch; + uint32_t xfer_ch; + uint32_t xfer_reg_addr; + uint32_t ctrl; + + DEBUGASSERT(ctrl_dmach && ctrl_dmach->inuse); + DEBUGASSERT(xfer_dmach && xfer_dmach->inuse); + + ctrl_ch = ctrl_dmach->chan; + xfer_ch = xfer_dmach->chan; + + xfer_dmach->callback = callback; + xfer_dmach->arg = arg; + + xfer_reg_addr = RP2040_DMA_AL1_CTRL(xfer_ch); + + /* Set DMA registers */ + + putreg32((uint32_t)ctrl_blks, RP2040_DMA_READ_ADDR(ctrl_ch)); + putreg32(xfer_reg_addr, RP2040_DMA_WRITE_ADDR(ctrl_ch)); + putreg32(4, RP2040_DMA_TRANS_COUNT(ctrl_ch)); + + /* Configure the xfer dma channel as follows: + * clear read and write error flags + * set increment on both read and write + * set 32-bit (word) transfer size + * run the ctrl at high priority + * RING_SIZE applies to write + * set RING_SIZE to wrap every 16 bytes + * don't chain to another dma (chain set to ourself) + * use un-paced transfer mode TREQ_SEL = 0x3f + */ + + ctrl = RP2040_DMA_CTRL_TRIG_READ_ERROR + | RP2040_DMA_CTRL_TRIG_WRITE_ERROR + | RP2040_DMA_CTRL_TRIG_INCR_READ + | RP2040_DMA_CTRL_TRIG_INCR_WRITE + | RP2040_DMA_CTRL_TRIG_HIGH_PRIORITY + | RP2040_DMA_CTRL_TRIG_RING_SEL + | (4 << RP2040_DMA_CTRL_TRIG_RING_SIZE_SHIFT) + | (RP2040_DMA_SIZE_WORD << RP2040_DMA_CTRL_TRIG_DATA_SIZE_SHIFT) + | (ctrl_ch << RP2040_DMA_CTRL_TRIG_CHAIN_TO_SHIFT) + | (0x3f << RP2040_DMA_CTRL_TRIG_TREQ_SEL_SHIFT); + + putreg32(ctrl, RP2040_DMA_CTRL_TRIG(ctrl_ch)); +} + +/**************************************************************************** + * Name: rp2040_ctrl_dmasetup + * + * Description: + * Configure a dma channel to send a list of channel control blocks to + * a second dma channel.. + * + * Input Parameters: + * control - the DMA handle that reads the control blocks. This is + * the one that should be started. + * size - transfer size for this block + * pacing - dma pacing register for this block + * ctrl - Additional bits to set in CTRL_TRIG for this block. + * + ****************************************************************************/ + +uint32_t rp2040_dma_ctrl_blk_ctrl(DMA_HANDLE control, + int size, + uint32_t pacing, + uint32_t ctrl) +{ + struct dma_channel_s *ctrl_dmach = (struct dma_channel_s *)control; + uint32_t ctrl_ch; + + DEBUGASSERT(ctrl_dmach && ctrl_dmach->inuse); + + ctrl_ch = ctrl_dmach->chan; + + return RP2040_DMA_CTRL_TRIG_EN + | RP2040_DMA_CTRL_TRIG_IRQ_QUIET + | (ctrl_ch << RP2040_DMA_CTRL_TRIG_CHAIN_TO_SHIFT) + | (size << RP2040_DMA_CTRL_TRIG_DATA_SIZE_SHIFT) + | (pacing << RP2040_DMA_CTRL_TRIG_TREQ_SEL_SHIFT) + | ctrl; +} + /**************************************************************************** * Name: rp2040_dmastart * @@ -491,3 +591,26 @@ void rp2040_dmastop(DMA_HANDLE handle) } while (stat & bit); } + +/**************************************************************************** + * Name: rp2040_dma_register + * + * Description: + * Get the address of a DMA register based on the given dma handle that + * can be used in the various putreg, getreg and modifyreg functions. + * + * This allows other configuration options not normally supplied. + * + * Assumptions: + * - DMA handle allocated by rp2040_dmachannel() + * + ****************************************************************************/ + +uintptr_t rp2040_dma_register(DMA_HANDLE handle, uint16_t offset) +{ + struct dma_channel_s *dmach = (struct dma_channel_s *)handle; + + DEBUGASSERT(dmach && dmach->inuse); + + return RP2040_DMA_CH(dmach->chan) + offset; +} diff --git a/arch/arm/src/rp2040/rp2040_dmac.h b/arch/arm/src/rp2040/rp2040_dmac.h index a56ce325a0b..0169546a5ae 100644 --- a/arch/arm/src/rp2040/rp2040_dmac.h +++ b/arch/arm/src/rp2040/rp2040_dmac.h @@ -84,6 +84,16 @@ #define RP2040_DMA_SIZE_HALFWORD 1 #define RP2040_DMA_SIZE_WORD 2 +/* Use this as last item in a DMA control block chain */ + +#define RP2040_DMA_CTRL_BLOCK_END \ + { \ + RP2040_DMA_CTRL_TRIG_IRQ_QUIET, \ + 0, \ + 0, \ + 0 \ + } + #ifndef __ASSEMBLY__ #undef EXTERN @@ -129,6 +139,18 @@ typedef struct uint8_t noincr; } dma_config_t; +/* Type of items in the array items to 'ctrl_blks' argument for + * rp2040_ctrl_dmasetup(). + */ + +typedef struct + { + uint32_t ctrl_trig; + uintptr_t read_addr; + uintptr_t write_addr; + uint32_t xfer_count; + } dma_control_block_t; + /**************************************************************************** * Public Data ****************************************************************************/ @@ -221,6 +243,52 @@ void rp2040_rxdmasetup(DMA_HANDLE handle, uintptr_t paddr, uintptr_t maddr, void rp2040_txdmasetup(DMA_HANDLE handle, uintptr_t paddr, uintptr_t maddr, size_t nbytes, dma_config_t config); +/**************************************************************************** + * Name: rp2040_ctrl_dmasetup + * + * Description: + * Configure a dma channel to send a list of channel control blocks to + * a second dma channel.. + * + * Input Parameters: + * control - the DMA handle that reads the control blocks. This is + * the one that should be started. + * transfer - the DMA handle the transfers data to the peripheral. No + * setup of this handle is required by the caller. + * ctrl_blks - the array of control blocks to used. Terminate this + * list with an all zero control block. + * callback - callback when last transfer completes + * arg - arg to pass to callback + * + ****************************************************************************/ + +void rp2040_ctrl_dmasetup(DMA_HANDLE control, + DMA_HANDLE transfer, + dma_control_block_t *ctrl_blks, + dma_callback_t callback, + void *arg); + +/**************************************************************************** + * Name: rp2040_ctrl_dmasetup + * + * Description: + * Configure a dma channel to send a list of channel control blocks to + * a second dma channel.. + * + * Input Parameters: + * control - the DMA handle that reads the control blocks. This is + * the one that should be started. + * size - transfer size for this block + * pacing - dma pacing register for this block + * ctrl - Additional bits to set in CTRL_TRIG for this block. + * + ****************************************************************************/ + +uint32_t rp2040_dma_ctrl_blk_ctrl(DMA_HANDLE control, + int size, + uint32_t pacing, + uint32_t ctrl); + /**************************************************************************** * Name: rp2040_dmastart * @@ -250,6 +318,22 @@ void rp2040_dmastart(DMA_HANDLE handle, dma_callback_t callback, void *arg); void rp2040_dmastop(DMA_HANDLE handle); +/**************************************************************************** + * Name: rp2040_dma_register + * + * Description: + * Get the address of a DMA register based on the given DMA handle that + * can be used in the various putreg, getreg and modifyreg functions. + * + * This allows other configuration options not normally supplied. + * + * Assumptions: + * - DMA handle allocated by rp2040_dmachannel() + * + ****************************************************************************/ + +uintptr_t rp2040_dma_register(DMA_HANDLE handle, uint16_t offset); + #undef EXTERN #if defined(__cplusplus) } diff --git a/arch/arm/src/rp2040/rp2040_gpio.c b/arch/arm/src/rp2040/rp2040_gpio.c index a29b29c665e..666aa153c69 100644 --- a/arch/arm/src/rp2040/rp2040_gpio.c +++ b/arch/arm/src/rp2040/rp2040_gpio.c @@ -361,6 +361,31 @@ void rp2040_gpio_disable_irq(uint32_t gpio) } } +/**************************************************************************** + * Name: rp2040_gpio_clear_interrupt + * + * Description: + * Clear the interrupt flags for a gpio pin. + * + ****************************************************************************/ + +void rp2040_gpio_clear_interrupt(uint32_t gpio, + bool edge_low, + bool edge_high) +{ + uint32_t reg; + uint32_t bits = 0; + + DEBUGASSERT(gpio < RP2040_GPIO_NUM); + + reg = RP2040_IO_BANK0_INTR(gpio); + + if (edge_low) bits |= 0x04 << (gpio % 8); + if (edge_high) bits |= 0x08 << (gpio % 8); + + clrbits_reg32(bits, reg); +} + /**************************************************************************** * Name: r2040_gpio_initialize * diff --git a/arch/arm/src/rp2040/rp2040_gpio.h b/arch/arm/src/rp2040/rp2040_gpio.h index 68dd9f6fdf0..7d6aa14898c 100644 --- a/arch/arm/src/rp2040/rp2040_gpio.h +++ b/arch/arm/src/rp2040/rp2040_gpio.h @@ -126,6 +126,60 @@ static inline void rp2040_gpio_setdir(uint32_t gpio, int out) } } +/**************************************************************************** + * Name: rp2040_gpio_set_input_hysteresis_enabled + * + * Description: + * Set whether the pin's input hysteresis will be enabled. + * + ****************************************************************************/ + +static inline void rp2040_gpio_set_input_hysteresis_enabled(uint32_t gpio, + bool enabled) +{ + DEBUGASSERT(gpio < RP2040_GPIO_NUM); + + modbits_reg32(enabled ? RP2040_PADS_BANK0_GPIO_SCHMITT : 0, + RP2040_PADS_BANK0_GPIO_SCHMITT, + RP2040_PADS_BANK0_GPIO(gpio)); +} + +/**************************************************************************** + * Name: rp2040_gpio_set_slew_fast + * + * Description: + * Set whether the pin's fast slew rate will be enabled. + * + ****************************************************************************/ + +static inline void rp2040_gpio_set_slew_fast(uint32_t gpio, + bool enabled) +{ + DEBUGASSERT(gpio < RP2040_GPIO_NUM); + + modbits_reg32(enabled ? RP2040_PADS_BANK0_GPIO_SLEWFAST : 0, + RP2040_PADS_BANK0_GPIO_SLEWFAST, + RP2040_PADS_BANK0_GPIO(gpio)); +} + +/**************************************************************************** + * Name: rp2040_gpio_set_drive_strength + * + * Description: + * Set the pin's drive strength. + * + ****************************************************************************/ + +static inline void rp2040_gpio_set_drive_strength(uint32_t gpio, + uint32_t drive_strength) +{ + DEBUGASSERT(gpio < RP2040_GPIO_NUM); + + modbits_reg32(drive_strength, + RP2040_PADS_BANK0_GPIO_DRIVE_MASK, + RP2040_PADS_BANK0_GPIO(gpio)); +} + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ @@ -201,6 +255,18 @@ void rp2040_gpio_enable_irq(uint32_t gpio); void rp2040_gpio_disable_irq(uint32_t gpio); +/**************************************************************************** + * Name: rp2040_gpio_clear_interrupt + * + * Description: + * Clear the interrupt flags for a gpio pin. + * + ****************************************************************************/ + +void rp2040_gpio_clear_interrupt(uint32_t gpio, + bool edge_low, + bool edge_high); + /**************************************************************************** * Name: r2040_gpio_initialize * diff --git a/arch/arm/src/rp2040/rp2040_pio.h b/arch/arm/src/rp2040/rp2040_pio.h index e1812106669..835cc512a9d 100644 --- a/arch/arm/src/rp2040/rp2040_pio.h +++ b/arch/arm/src/rp2040/rp2040_pio.h @@ -1960,6 +1960,30 @@ void rp2040_pio_sm_unclaim(uint32_t pio, uint32_t sm); int rp2040_pio_claim_unused_sm(uint32_t pio, bool required); +/**************************************************************************** + * Name: rp2040_pio_set_input_sync_bypass + * + * Description: + * Set the input synchronizer bypess bit for a GPIO pin + * + * Input Parameters: + * pio - PIO index (0..1) + * pin - GPIO pin number (0-29) + * bypass - bypass set true to bypass the synchronizer. + * + ****************************************************************************/ + +static inline void rp2040_pio_set_input_sync_bypass(uint32_t pio, + uint32_t pin, + bool bypass) +{ + DEBUGASSERT(pin < RP2040_GPIO_NUM); + + modbits_reg32(bypass ? (1 << pin) : 0, + (1 << pin), + RP2040_PIO_INPUT_SYNC_BYPASS(pio)); +} + #undef EXTERN #if defined(__cplusplus) } diff --git a/arch/arm/src/rp2040/rp2040_ws2812.c b/arch/arm/src/rp2040/rp2040_ws2812.c index 7e0837354a6..eb472a55335 100644 --- a/arch/arm/src/rp2040/rp2040_ws2812.c +++ b/arch/arm/src/rp2040/rp2040_ws2812.c @@ -174,8 +174,9 @@ static int my_open(FAR struct file *filep) rp2040_pio_sm_config config; int divisor; int ret; + irqstate_t flags; - nxsem_wait(&dev_data->exclsem); + flags = enter_critical_section(); priv->open_count += 1; @@ -213,7 +214,7 @@ static int my_open(FAR struct file *filep) priv->pio_sm = rp2040_pio_claim_unused_sm(priv->pio, false); - /* If we did not get one try the nest pio block, if any */ + /* If we did not get one try the next pio block, if any */ if (priv->pio_sm < 0) continue; @@ -322,7 +323,7 @@ static int my_open(FAR struct file *filep) ret = OK; post_and_return: - nxsem_post(&dev_data->exclsem); + leave_critical_section(flags); return ret; } diff --git a/boards/Kconfig b/boards/Kconfig index 22302dd4d7c..527447a51f1 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -1489,11 +1489,17 @@ config ARCH_BOARD_INTEL64_QEMU generic Intel64 hardware. config ARCH_BOARD_RASPBERRYPI_PICO - bool "Raspberry Pi Pico board" + bool "Raspberry Pi Pico board (not W)" depends on ARCH_CHIP_RP2040 ---help--- This is a port to the Raspberry Pi Pico board. +config ARCH_BOARD_RASPBERRYPI_PICO_W + bool "Raspberry Pi Pico W board" + depends on ARCH_CHIP_RP2040 + ---help--- + This is a port to the Raspberry Pi Pico W board. + config ARCH_BOARD_PIMORONI_TINY2040 bool "Pimoroni Tiny2040 board" depends on ARCH_CHIP_RP2040 @@ -2706,6 +2712,7 @@ config ARCH_BOARD default "qemu-i486" if ARCH_BOARD_QEMU_I486 default "intel64-qemu" if ARCH_BOARD_INTEL64_QEMU default "raspberrypi-pico" if ARCH_BOARD_RASPBERRYPI_PICO + default "raspberrypi-pico-w" if ARCH_BOARD_RASPBERRYPI_PICO_W default "pimoroni-tiny2040" if ARCH_BOARD_PIMORONI_TINY2040 default "adafruit-feather-rp2040" if ARCH_BOARD_ADAFRUIT_FEATHER_RP2040 default "adafruit-kb2040" if ARCH_BOARD_ADAFRUIT_KB2040 @@ -3059,6 +3066,9 @@ endif if ARCH_BOARD_RASPBERRYPI_PICO source "boards/arm/rp2040/raspberrypi-pico/Kconfig" endif +if ARCH_BOARD_RASPBERRYPI_PICO_W +source "boards/arm/rp2040/raspberrypi-pico-w/Kconfig" +endif if ARCH_BOARD_PIMORONI_TINY2040 source "boards/arm/rp2040/pimoroni-tiny2040/Kconfig" endif diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/audiopack/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/audiopack/defconfig index da306fb9a64..90f39aec344 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/audiopack/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/audiopack/defconfig @@ -75,4 +75,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/composite/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/composite/defconfig index f7147bcb393..f03efa86687 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/composite/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/composite/defconfig @@ -78,4 +78,3 @@ CONFIG_USBMSC=y CONFIG_USBMSC_COMPOSITE=y CONFIG_USBMSC_NOT_STALL_BULKEP=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/displaypack/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/displaypack/defconfig index 92d150608c5..adf03d81b37 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/displaypack/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/displaypack/defconfig @@ -102,4 +102,3 @@ CONFIG_USBDEV=y CONFIG_USBDEV_BUSPOWERED=y CONFIG_VIDEO_FB=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/enc28j60/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/enc28j60/defconfig index 2a8f1a72af8..7f10af2ddf8 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/enc28j60/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/enc28j60/defconfig @@ -86,4 +86,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WQUEUE_NOTIFIER=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/lcd1602/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/lcd1602/defconfig index 247debdc39c..111f34fc9a7 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/lcd1602/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/lcd1602/defconfig @@ -58,4 +58,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/nsh/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/nsh/defconfig index ad2f8095727..7258991252b 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/nsh/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/nsh/defconfig @@ -49,4 +49,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/nshsram/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/nshsram/defconfig index a623a027930..b801df30dee 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/nshsram/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/nshsram/defconfig @@ -49,4 +49,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/smp/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/smp/defconfig index b67fa9c1af3..11696335fea 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/smp/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/smp/defconfig @@ -55,4 +55,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_TESTING_SMP=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/spisd/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/spisd/defconfig index 1b0e4fe46d5..52e44eff4c1 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/spisd/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/spisd/defconfig @@ -60,4 +60,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/ssd1306/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/ssd1306/defconfig index 0ba16157d87..da2d2073365 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/ssd1306/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/ssd1306/defconfig @@ -77,4 +77,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/st7735/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/st7735/defconfig index 157b1429e89..f3644b3ce5f 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/st7735/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/st7735/defconfig @@ -59,4 +59,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_VIDEO_FB=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/usbmsc/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/usbmsc/defconfig index 3c4d5a8364d..1843a4fe7fc 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/usbmsc/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/usbmsc/defconfig @@ -71,4 +71,3 @@ CONFIG_USBDEV_BUSPOWERED=y CONFIG_USBMSC=y CONFIG_USBMSC_NOT_STALL_BULKEP=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/usbnsh/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/usbnsh/defconfig index 267862e6573..a4036a0a018 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/usbnsh/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/usbnsh/defconfig @@ -53,4 +53,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_USBDEV=y CONFIG_USBDEV_BUSPOWERED=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/waveshare-lcd-1.14/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/waveshare-lcd-1.14/defconfig index f67c250c9a1..ba6bab2b449 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/waveshare-lcd-1.14/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/waveshare-lcd-1.14/defconfig @@ -95,4 +95,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_VIDEO_FB=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/configs/waveshare-lcd-1.3/defconfig b/boards/arm/rp2040/adafruit-feather-rp2040/configs/waveshare-lcd-1.3/defconfig index 9e028c47e6f..7c687b27ecd 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/configs/waveshare-lcd-1.3/defconfig +++ b/boards/arm/rp2040/adafruit-feather-rp2040/configs/waveshare-lcd-1.3/defconfig @@ -92,4 +92,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_VIDEO_FB=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/src/rp2040_boardinitialize.c b/boards/arm/rp2040/adafruit-feather-rp2040/src/rp2040_boardinitialize.c index febd6800712..2ec9864b662 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/src/rp2040_boardinitialize.c +++ b/boards/arm/rp2040/adafruit-feather-rp2040/src/rp2040_boardinitialize.c @@ -32,6 +32,10 @@ #include "arm_internal.h" #include "rp2040_gpio.h" +#ifdef CONFIG_ARCH_BOARD_COMMON +#include "rp2040_common_initialize.h" +#endif /* CONFIG_ARCH_BOARD_COMMON */ + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -53,52 +57,17 @@ void rp2040_boardearlyinitialize(void) { - rp2040_gpio_initialize(); + #ifdef CONFIG_ARCH_BOARD_COMMON + rp2040_common_earlyinitialize(); + #endif - /* Disable IE on GPIO 26-29 */ - - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(26)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(27)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(28)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(29)); + /* --- Place any board specific early initialization here --- */ /* Set board LED pin */ rp2040_gpio_init(BOARD_GPIO_LED_PIN); rp2040_gpio_setdir(BOARD_GPIO_LED_PIN, true); rp2040_gpio_put(BOARD_GPIO_LED_PIN, true); - - /* Set default UART pin */ - -#ifdef CONFIG_RP2040_UART0 - rp2040_gpio_set_function(CONFIG_RP2040_UART0_TX_GPIO, - RP2040_GPIO_FUNC_UART); /* TX */ - rp2040_gpio_set_function(CONFIG_RP2040_UART0_RX_GPIO, - RP2040_GPIO_FUNC_UART); /* RX */ -#ifdef CONFIG_SERIAL_OFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART0_CTS_GPIO, - RP2040_GPIO_FUNC_UART); /* CTS */ -#endif -#ifdef CONFIG_SERIAL_IFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART0_RTS_GPIO, - RP2040_GPIO_FUNC_UART); /* RTS */ -#endif -#endif - -#ifdef CONFIG_RP2040_UART1 - rp2040_gpio_set_function(CONFIG_RP2040_UART1_TX_GPIO, - RP2040_GPIO_FUNC_UART); /* TX */ - rp2040_gpio_set_function(CONFIG_RP2040_UART1_RX_GPIO, - RP2040_GPIO_FUNC_UART); /* RX */ -#ifdef CONFIG_SERIAL_OFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART1_CTS_GPIO, - RP2040_GPIO_FUNC_UART); /* CTS */ -#endif -#ifdef CONFIG_SERIAL_IFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART1_RTS_GPIO, - RP2040_GPIO_FUNC_UART); /* RTS */ -#endif -#endif } /**************************************************************************** @@ -110,57 +79,9 @@ void rp2040_boardearlyinitialize(void) void rp2040_boardinitialize(void) { - /* Set default I2C pin */ + #ifdef CONFIG_ARCH_BOARD_COMMON + rp2040_common_initialize(); + #endif -#ifdef CONFIG_RP2040_I2C0 - rp2040_gpio_set_function(CONFIG_RP2040_I2C0_SDA_GPIO, - RP2040_GPIO_FUNC_I2C); /* SDA */ - rp2040_gpio_set_function(CONFIG_RP2040_I2C0_SCL_GPIO, - RP2040_GPIO_FUNC_I2C); /* SCL */ - - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_SDA_GPIO, true, false); /* Pull up */ - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_SCL_GPIO, true, false); -#endif - -#ifdef CONFIG_RP2040_I2C1 - rp2040_gpio_set_function(CONFIG_RP2040_I2C1_SDA_GPIO, - RP2040_GPIO_FUNC_I2C); /* SDA */ - rp2040_gpio_set_function(CONFIG_RP2040_I2C1_SCL_GPIO, - RP2040_GPIO_FUNC_I2C); /* SCL */ - - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_SDA_GPIO, true, false); /* Pull up */ - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_SCL_GPIO, true, false); -#endif - - /* Set default SPI pin */ - -#ifdef CONFIG_RP2040_SPI0 - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_RX_GPIO, - RP2040_GPIO_FUNC_SPI); /* RX */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_SCK_GPIO, - RP2040_GPIO_FUNC_SPI); /* SCK */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_TX_GPIO, - RP2040_GPIO_FUNC_SPI); /* TX */ - - /* CSn is controlled by board-specific logic */ - - rp2040_gpio_init(CONFIG_RP2040_SPI0_CS_GPIO); /* CSn */ - rp2040_gpio_setdir(CONFIG_RP2040_SPI0_CS_GPIO, true); - rp2040_gpio_put(CONFIG_RP2040_SPI0_CS_GPIO, true); -#endif - -#ifdef CONFIG_RP2040_SPI1 - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_RX_GPIO, - RP2040_GPIO_FUNC_SPI); /* RX */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_SCK_GPIO, - RP2040_GPIO_FUNC_SPI); /* SCK */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_TX_GPIO, - RP2040_GPIO_FUNC_SPI); /* TX */ - - /* CSn is controlled by board-specific logic */ - - rp2040_gpio_init(CONFIG_RP2040_SPI1_CS_GPIO); /* CSn */ - rp2040_gpio_setdir(CONFIG_RP2040_SPI1_CS_GPIO, true); - rp2040_gpio_put(CONFIG_RP2040_SPI1_CS_GPIO, true); -#endif + /* --- Place any board specific initialization here --- */ } diff --git a/boards/arm/rp2040/adafruit-feather-rp2040/src/rp2040_bringup.c b/boards/arm/rp2040/adafruit-feather-rp2040/src/rp2040_bringup.c index 6c678ac86aa..98c96d90154 100644 --- a/boards/arm/rp2040/adafruit-feather-rp2040/src/rp2040_bringup.c +++ b/boards/arm/rp2040/adafruit-feather-rp2040/src/rp2040_bringup.c @@ -33,50 +33,9 @@ #include "rp2040_pico.h" -#ifdef CONFIG_LCD_BACKPACK -#include "rp2040_lcd_backpack.h" -#endif - -#ifdef CONFIG_LCD -#include -#endif - -#ifdef CONFIG_LCD_DEV -#include -#endif - -#ifdef CONFIG_VIDEO_FB -#include -#endif - -#ifdef CONFIG_SENSORS_INA219 -#include -#include "rp2040_ina219.h" -#endif - -#ifdef CONFIG_SENSORS_BMP180 -#include -#include "rp2040_bmp180.h" -#endif - -#ifdef CONFIG_RP2040_PWM -#include "rp2040_pwm.h" -#include "rp2040_pwmdev.h" -#endif - -#if defined(CONFIG_RP2040_BOARD_HAS_WS2812) && defined(CONFIG_WS2812) -#include "rp2040_ws2812.h" -#endif - -#ifdef CONFIG_WS2812_HAS_WHITE -#define HAS_WHITE true -#else /* CONFIG_WS2812_HAS_WHITE */ -#define HAS_WHITE false -#endif /* CONFIG_WS2812_HAS_WHITE */ - -#if defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) -#include "rp2040_adc.h" -#endif +#ifdef CONFIG_ARCH_BOARD_COMMON +#include "rp2040_common_bringup.h" +#endif /* CONFIG_ARCH_BOARD_COMMON */ /**************************************************************************** * Public Functions @@ -88,425 +47,17 @@ int rp2040_bringup(void) { - int ret = 0; +#ifdef CONFIG_ARCH_BOARD_COMMON -#ifdef CONFIG_RP2040_I2C_DRIVER - #ifdef CONFIG_RP2040_I2C0 - ret = board_i2cdev_initialize(0); + int ret = rp2040_common_bringup(); if (ret < 0) { - _err("ERROR: Failed to initialize I2C0.\n"); - } - #endif - - #ifdef CONFIG_RP2040_I2C1 - ret = board_i2cdev_initialize(1); - if (ret < 0) - { - _err("ERROR: Failed to initialize I2C1.\n"); - } - #endif -#endif - -#ifdef CONFIG_RP2040_SPI_DRIVER - #ifdef CONFIG_RP2040_SPI0 - ret = board_spidev_initialize(0); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI0.\n"); - } - #endif - - #ifdef CONFIG_RP2040_SPI1 - ret = board_spidev_initialize(1); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI1.\n"); - } - #endif -#endif - -#ifdef CONFIG_RP2040_PWM -# ifdef CONFIG_RP2040_PWM0 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(0, - CONFIG_RP2040_PWM0A_GPIO, - CONFIG_RP2040_PWM0B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM0A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM0B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM0_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(0, - CONFIG_RP2040_PWM0A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM0A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM0_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM0.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM1 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(1, - CONFIG_RP2040_PWM1A_GPIO, - CONFIG_RP2040_PWM1B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM1A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM1B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM1_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(1, - CONFIG_RP2040_PWM1A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM1A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM1_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM1.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM2 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(2, - CONFIG_RP2040_PWM2A_GPIO, - CONFIG_RP2040_PWM2B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM2A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM2B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM2_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(2, - CONFIG_RP2040_PWM2A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM2A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM2_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM2.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM3 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(3, - CONFIG_RP2040_PWM3A_GPIO, - CONFIG_RP2040_PWM3B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM3A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM3B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM3_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(3, - CONFIG_RP2040_PWM3A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM3A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM3_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM3.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM4 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(4, - CONFIG_RP2040_PWM4A_GPIO, - CONFIG_RP2040_PWM4B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM4A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM4B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM4_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(4, - CONFIG_RP2040_PWM4A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM4A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM4_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM4.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM5 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(5, - CONFIG_RP2040_PWM5A_GPIO, - CONFIG_RP2040_PWM5B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM5A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM5B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM5_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(5, - CONFIG_RP2040_PWM5A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM5A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM5_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM5.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM6 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(6, - CONFIG_RP2040_PWM6A_GPIO, - CONFIG_RP2040_PWM6B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM6A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM6B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM6_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(6, - CONFIG_RP2040_PWM6A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM6A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM6_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM6.\n"); - } -# endif -#endif - -#ifdef CONFIG_RP2040_SPISD - /* Mount the SPI-based MMC/SD block driver */ - - ret = board_spisd_initialize(0, CONFIG_RP2040_SPISD_SPI_CH); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI device to MMC/SD: %d\n", - ret); - } -#endif - -#ifdef CONFIG_FS_PROCFS - /* Mount the procfs file system */ - - ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); - if (ret < 0) - { - serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret); - } -#endif - -#ifdef CONFIG_SENSORS_BMP180 - /* Try to register BMP180 device in I2C0 */ - - ret = board_bmp180_initialize(0); - if (ret < 0) - { - syslog(LOG_ERR, "Failed to initialize BMP180 driver: %d\n", ret); - } -#endif - -#ifdef CONFIG_SENSORS_INA219 - /* Configure and initialize the INA219 sensor in I2C0 */ - - ret = board_ina219_initialize(0); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: rp2040_ina219_initialize() failed: %d\n", ret); - } -#endif - -#ifdef CONFIG_VIDEO_FB - ret = fb_register(0, 0); - if (ret < 0) - { - _err("ERROR: Failed to initialize Frame Buffer Driver.\n"); - } -#elif defined(CONFIG_LCD) - ret = board_lcd_initialize(); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: Failed to initialize LCD.\n"); - } -#endif - -#ifdef CONFIG_LCD_DEV - ret = lcddev_register(0); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: lcddev_register() failed: %d\n", ret); - } -#endif - -#ifdef CONFIG_LCD_BACKPACK - /* slcd:0, i2c:0, rows=2, cols=16 */ - - ret = board_lcd_backpack_init(0, 0, 2, 16); - if (ret < 0) - { - syslog(LOG_ERR, "Failed to initialize PCF8574 LCD, error %d\n", ret); - return ret; - } -#endif - -#ifdef CONFIG_RP2040_I2S - ret = board_i2sdev_initialize(0); - if (ret < 0) - { - _err("ERROR: Failed to initialize I2S.\n"); - } -#endif - -#ifdef CONFIG_DEV_GPIO - ret = rp2040_dev_gpio_init(); - if (ret < 0) - { - syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret); - return ret; - } -#endif - - /* Initialize board neo-pixel */ - -#if defined(CONFIG_RP2040_BOARD_HAS_WS2812) && defined(CONFIG_WS2812) - rp2040_ws2812_setup("/dev/leds0", - CONFIG_RP2040_WS2812_GPIO_PIN, - CONFIG_RP2040_WS2812_PWR_GPIO, - CONFIG_WS2812_LED_COUNT, - HAS_WHITE); -#endif - -#if defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) - -# ifdef CONFIG_RPC2040_ADC_CHANNEL0 -# define ADC_0 true -# else -# define ADC_0 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL1 -# define ADC_1 true -# else -# define ADC_1 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL2 -# define ADC_2 true -# else -# define ADC_2 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL3 -# define ADC_3 true -# else -# define ADC_3 false -# endif - -# ifdef CONFIG_RPC2040_ADC_TEMPERATURE -# define ADC_TEMP true -# else -# define ADC_TEMP false -# endif - - ret = rp2040_adc_setup("/dev/adc0", ADC_0, ADC_1, ADC_2, ADC_3, ADC_TEMP); - if (ret != OK) - { - syslog(LOG_ERR, "Failed to initialize ADC Driver: %d\n", ret); return ret; } -#endif /* defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) */ +#endif /* CONFIG_ARCH_BOARD_COMMON */ - return ret; + /* --- Place any board specific bringup code here --- */ + + return OK; } diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/audiopack/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/audiopack/defconfig index bcc9163ce54..2b0201e14d4 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/audiopack/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/audiopack/defconfig @@ -75,4 +75,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/composite/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/composite/defconfig index c33f3151cba..1dfd904cec9 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/composite/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/composite/defconfig @@ -78,4 +78,3 @@ CONFIG_USBMSC=y CONFIG_USBMSC_COMPOSITE=y CONFIG_USBMSC_NOT_STALL_BULKEP=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/displaypack/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/displaypack/defconfig index bfc1e73539b..2a1867e4334 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/displaypack/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/displaypack/defconfig @@ -102,4 +102,3 @@ CONFIG_USBDEV=y CONFIG_USBDEV_BUSPOWERED=y CONFIG_VIDEO_FB=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/enc28j60/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/enc28j60/defconfig index 94ecec1693f..14ce655231f 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/enc28j60/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/enc28j60/defconfig @@ -87,4 +87,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WQUEUE_NOTIFIER=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/lcd1602/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/lcd1602/defconfig index 1b537cd666e..b8813119928 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/lcd1602/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/lcd1602/defconfig @@ -56,4 +56,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/nsh/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/nsh/defconfig index 6c914106941..c71ca48ea16 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/nsh/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/nsh/defconfig @@ -49,4 +49,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/nshsram/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/nshsram/defconfig index a968c49a487..2e40af9f399 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/nshsram/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/nshsram/defconfig @@ -49,4 +49,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/smp/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/smp/defconfig index 19dba9bc356..48a2a1f8370 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/smp/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/smp/defconfig @@ -55,4 +55,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_TESTING_SMP=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/spisd/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/spisd/defconfig index ddd189112d4..1709ce0dd72 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/spisd/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/spisd/defconfig @@ -64,4 +64,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/ssd1306/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/ssd1306/defconfig index a9c7afa1ccc..8c6d05849bc 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/ssd1306/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/ssd1306/defconfig @@ -75,4 +75,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/st7735/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/st7735/defconfig index 84c8330fc9b..7f6c7139064 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/st7735/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/st7735/defconfig @@ -60,4 +60,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_VIDEO_FB=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/usbmsc/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/usbmsc/defconfig index d03f3a032b1..8fc2feac30e 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/usbmsc/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/usbmsc/defconfig @@ -71,4 +71,3 @@ CONFIG_USBDEV_BUSPOWERED=y CONFIG_USBMSC=y CONFIG_USBMSC_NOT_STALL_BULKEP=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/usbnsh/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/usbnsh/defconfig index 0fe5e5c8270..ffa7bb6a1d5 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/usbnsh/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/usbnsh/defconfig @@ -53,4 +53,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_USBDEV=y CONFIG_USBDEV_BUSPOWERED=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/waveshare-lcd-1.14/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/waveshare-lcd-1.14/defconfig index 6d9edec8e7d..aeefc71ce25 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/waveshare-lcd-1.14/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/waveshare-lcd-1.14/defconfig @@ -95,4 +95,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_VIDEO_FB=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/configs/waveshare-lcd-1.3/defconfig b/boards/arm/rp2040/adafruit-kb2040/configs/waveshare-lcd-1.3/defconfig index f7697810997..9c290f19248 100644 --- a/boards/arm/rp2040/adafruit-kb2040/configs/waveshare-lcd-1.3/defconfig +++ b/boards/arm/rp2040/adafruit-kb2040/configs/waveshare-lcd-1.3/defconfig @@ -92,4 +92,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_UART0_SERIAL_CONSOLE=y CONFIG_VIDEO_FB=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-kb2040/src/rp2040_boardinitialize.c b/boards/arm/rp2040/adafruit-kb2040/src/rp2040_boardinitialize.c index a34ab089105..f11ea5cad10 100644 --- a/boards/arm/rp2040/adafruit-kb2040/src/rp2040_boardinitialize.c +++ b/boards/arm/rp2040/adafruit-kb2040/src/rp2040_boardinitialize.c @@ -32,6 +32,10 @@ #include "arm_internal.h" #include "rp2040_gpio.h" +#ifdef CONFIG_ARCH_BOARD_COMMON +#include "rp2040_common_initialize.h" +#endif /* CONFIG_ARCH_BOARD_COMMON */ + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -53,46 +57,11 @@ void rp2040_boardearlyinitialize(void) { - rp2040_gpio_initialize(); + #ifdef CONFIG_ARCH_BOARD_COMMON + rp2040_common_earlyinitialize(); + #endif - /* Disable IE on GPIO 26-29 */ - - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(26)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(27)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(28)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(29)); - - /* Set default UART pin */ - -#ifdef CONFIG_RP2040_UART0 - rp2040_gpio_set_function(CONFIG_RP2040_UART0_TX_GPIO, - RP2040_GPIO_FUNC_UART); /* TX */ - rp2040_gpio_set_function(CONFIG_RP2040_UART0_RX_GPIO, - RP2040_GPIO_FUNC_UART); /* RX */ -#ifdef CONFIG_SERIAL_OFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART0_CTS_GPIO, - RP2040_GPIO_FUNC_UART); /* CTS */ -#endif -#ifdef CONFIG_SERIAL_IFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART0_RTS_GPIO, - RP2040_GPIO_FUNC_UART); /* RTS */ -#endif -#endif - -#ifdef CONFIG_RP2040_UART1 - rp2040_gpio_set_function(CONFIG_RP2040_UART1_TX_GPIO, - RP2040_GPIO_FUNC_UART); /* TX */ - rp2040_gpio_set_function(CONFIG_RP2040_UART1_RX_GPIO, - RP2040_GPIO_FUNC_UART); /* RX */ -#ifdef CONFIG_SERIAL_OFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART1_CTS_GPIO, - RP2040_GPIO_FUNC_UART); /* CTS */ -#endif -#ifdef CONFIG_SERIAL_IFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART1_RTS_GPIO, - RP2040_GPIO_FUNC_UART); /* RTS */ -#endif -#endif + /* --- Place any board specific early initialization here --- */ } /**************************************************************************** @@ -104,57 +73,9 @@ void rp2040_boardearlyinitialize(void) void rp2040_boardinitialize(void) { - /* Set default I2C pin */ + #ifdef CONFIG_ARCH_BOARD_COMMON + rp2040_common_initialize(); + #endif -#ifdef CONFIG_RP2040_I2C0 - rp2040_gpio_set_function(CONFIG_RP2040_I2C0_SDA_GPIO, - RP2040_GPIO_FUNC_I2C); /* SDA */ - rp2040_gpio_set_function(CONFIG_RP2040_I2C0_SCL_GPIO, - RP2040_GPIO_FUNC_I2C); /* SCL */ - - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_SDA_GPIO, true, false); /* Pull up */ - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_SCL_GPIO, true, false); -#endif - -#ifdef CONFIG_RP2040_I2C1 - rp2040_gpio_set_function(CONFIG_RP2040_I2C1_SDA_GPIO, - RP2040_GPIO_FUNC_I2C); /* SDA */ - rp2040_gpio_set_function(CONFIG_RP2040_I2C1_SCL_GPIO, - RP2040_GPIO_FUNC_I2C); /* SCL */ - - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_SDA_GPIO, true, false); /* Pull up */ - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_SCL_GPIO, true, false); -#endif - - /* Set default SPI pin */ - -#ifdef CONFIG_RP2040_SPI0 - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_RX_GPIO, - RP2040_GPIO_FUNC_SPI); /* RX */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_SCK_GPIO, - RP2040_GPIO_FUNC_SPI); /* SCK */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_TX_GPIO, - RP2040_GPIO_FUNC_SPI); /* TX */ - - /* CSn is controlled by board-specific logic */ - - rp2040_gpio_init(CONFIG_RP2040_SPI0_CS_GPIO); /* CSn */ - rp2040_gpio_setdir(CONFIG_RP2040_SPI0_CS_GPIO, true); - rp2040_gpio_put(CONFIG_RP2040_SPI0_CS_GPIO, true); -#endif - -#ifdef CONFIG_RP2040_SPI1 - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_RX_GPIO, - RP2040_GPIO_FUNC_SPI); /* RX */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_SCK_GPIO, - RP2040_GPIO_FUNC_SPI); /* SCK */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_TX_GPIO, - RP2040_GPIO_FUNC_SPI); /* TX */ - - /* CSn is controlled by board-specific logic */ - - rp2040_gpio_init(CONFIG_RP2040_SPI1_CS_GPIO); /* CSn */ - rp2040_gpio_setdir(CONFIG_RP2040_SPI1_CS_GPIO, true); - rp2040_gpio_put(CONFIG_RP2040_SPI1_CS_GPIO, true); -#endif + /* --- Place any board specific initialization here --- */ } diff --git a/boards/arm/rp2040/adafruit-kb2040/src/rp2040_bringup.c b/boards/arm/rp2040/adafruit-kb2040/src/rp2040_bringup.c index 5bc59fdee2e..b3fefade4a8 100644 --- a/boards/arm/rp2040/adafruit-kb2040/src/rp2040_bringup.c +++ b/boards/arm/rp2040/adafruit-kb2040/src/rp2040_bringup.c @@ -33,50 +33,9 @@ #include "rp2040_pico.h" -#ifdef CONFIG_LCD_BACKPACK -#include "rp2040_lcd_backpack.h" -#endif - -#ifdef CONFIG_LCD -#include -#endif - -#ifdef CONFIG_LCD_DEV -#include -#endif - -#ifdef CONFIG_VIDEO_FB -#include -#endif - -#ifdef CONFIG_SENSORS_INA219 -#include -#include "rp2040_ina219.h" -#endif - -#ifdef CONFIG_SENSORS_BMP180 -#include -#include "rp2040_bmp180.h" -#endif - -#ifdef CONFIG_RP2040_PWM -#include "rp2040_pwm.h" -#include "rp2040_pwmdev.h" -#endif - -#if defined(CONFIG_RP2040_BOARD_HAS_WS2812) && defined(CONFIG_WS2812) -#include "rp2040_ws2812.h" -#endif - -#ifdef CONFIG_WS2812_HAS_WHITE -#define HAS_WHITE true -#else /* CONFIG_WS2812_HAS_WHITE */ -#define HAS_WHITE false -#endif /* CONFIG_WS2812_HAS_WHITE */ - -#if defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) -#include "rp2040_adc.h" -#endif +#ifdef CONFIG_ARCH_BOARD_COMMON +#include "rp2040_common_bringup.h" +#endif /* CONFIG_ARCH_BOARD_COMMON */ /**************************************************************************** * Public Functions @@ -88,425 +47,17 @@ int rp2040_bringup(void) { - int ret = 0; +#ifdef CONFIG_ARCH_BOARD_COMMON -#ifdef CONFIG_RP2040_I2C_DRIVER - #ifdef CONFIG_RP2040_I2C0 - ret = board_i2cdev_initialize(0); + int ret = rp2040_common_bringup(); if (ret < 0) { - _err("ERROR: Failed to initialize I2C0.\n"); - } - #endif - - #ifdef CONFIG_RP2040_I2C1 - ret = board_i2cdev_initialize(1); - if (ret < 0) - { - _err("ERROR: Failed to initialize I2C1.\n"); - } - #endif -#endif - -#ifdef CONFIG_RP2040_SPI_DRIVER - #ifdef CONFIG_RP2040_SPI0 - ret = board_spidev_initialize(0); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI0.\n"); - } - #endif - - #ifdef CONFIG_RP2040_SPI1 - ret = board_spidev_initialize(1); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI1.\n"); - } - #endif -#endif - -#ifdef CONFIG_RP2040_PWM -# ifdef CONFIG_RP2040_PWM0 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(0, - CONFIG_RP2040_PWM0A_GPIO, - CONFIG_RP2040_PWM0B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM0A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM0B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM0_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(0, - CONFIG_RP2040_PWM0A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM0A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM0_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM0.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM1 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(1, - CONFIG_RP2040_PWM1A_GPIO, - CONFIG_RP2040_PWM1B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM1A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM1B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM1_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(1, - CONFIG_RP2040_PWM1A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM1A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM1_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM1.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM2 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(2, - CONFIG_RP2040_PWM2A_GPIO, - CONFIG_RP2040_PWM2B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM2A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM2B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM2_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(2, - CONFIG_RP2040_PWM2A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM2A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM2_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM2.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM3 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(3, - CONFIG_RP2040_PWM3A_GPIO, - CONFIG_RP2040_PWM3B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM3A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM3B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM3_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(3, - CONFIG_RP2040_PWM3A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM3A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM3_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM3.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM4 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(4, - CONFIG_RP2040_PWM4A_GPIO, - CONFIG_RP2040_PWM4B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM4A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM4B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM4_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(4, - CONFIG_RP2040_PWM4A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM4A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM4_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM4.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM5 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(5, - CONFIG_RP2040_PWM5A_GPIO, - CONFIG_RP2040_PWM5B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM5A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM5B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM5_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(5, - CONFIG_RP2040_PWM5A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM5A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM5_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM5.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM6 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(6, - CONFIG_RP2040_PWM6A_GPIO, - CONFIG_RP2040_PWM6B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM6A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM6B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM6_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(6, - CONFIG_RP2040_PWM6A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM6A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM6_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM6.\n"); - } -# endif -#endif - -#ifdef CONFIG_RP2040_SPISD - /* Mount the SPI-based MMC/SD block driver */ - - ret = board_spisd_initialize(0, CONFIG_RP2040_SPISD_SPI_CH); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI device to MMC/SD: %d\n", - ret); - } -#endif - -#ifdef CONFIG_FS_PROCFS - /* Mount the procfs file system */ - - ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); - if (ret < 0) - { - serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret); - } -#endif - -#ifdef CONFIG_SENSORS_BMP180 - /* Try to register BMP180 device in I2C0 */ - - ret = board_bmp180_initialize(0); - if (ret < 0) - { - syslog(LOG_ERR, "Failed to initialize BMP180 driver: %d\n", ret); - } -#endif - -#ifdef CONFIG_SENSORS_INA219 - /* Configure and initialize the INA219 sensor in I2C0 */ - - ret = board_ina219_initialize(0); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: rp2040_ina219_initialize() failed: %d\n", ret); - } -#endif - -#ifdef CONFIG_VIDEO_FB - ret = fb_register(0, 0); - if (ret < 0) - { - _err("ERROR: Failed to initialize Frame Buffer Driver.\n"); - } -#elif defined(CONFIG_LCD) - ret = board_lcd_initialize(); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: Failed to initialize LCD.\n"); - } -#endif - -#ifdef CONFIG_LCD_DEV - ret = lcddev_register(0); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: lcddev_register() failed: %d\n", ret); - } -#endif - -#ifdef CONFIG_LCD_BACKPACK - /* slcd:0, i2c:0, rows=2, cols=16 */ - - ret = board_lcd_backpack_init(0, 0, 2, 16); - if (ret < 0) - { - syslog(LOG_ERR, "Failed to initialize PCF8574 LCD, error %d\n", ret); - return ret; - } -#endif - -#ifdef CONFIG_RP2040_I2S - ret = board_i2sdev_initialize(0); - if (ret < 0) - { - _err("ERROR: Failed to initialize I2S.\n"); - } -#endif - -#ifdef CONFIG_DEV_GPIO - ret = rp2040_dev_gpio_init(); - if (ret < 0) - { - syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret); - return ret; - } -#endif - - /* Initialize board neo-pixel */ - -#if defined(CONFIG_RP2040_BOARD_HAS_WS2812) && defined(CONFIG_WS2812) - rp2040_ws2812_setup("/dev/leds0", - CONFIG_RP2040_WS2812_GPIO_PIN, - CONFIG_RP2040_WS2812_PWR_GPIO, - CONFIG_WS2812_LED_COUNT, - HAS_WHITE); -#endif - -#if defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) - -# ifdef CONFIG_RPC2040_ADC_CHANNEL0 -# define ADC_0 true -# else -# define ADC_0 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL1 -# define ADC_1 true -# else -# define ADC_1 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL2 -# define ADC_2 true -# else -# define ADC_2 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL3 -# define ADC_3 true -# else -# define ADC_3 false -# endif - -# ifdef CONFIG_RPC2040_ADC_TEMPERATURE -# define ADC_TEMP true -# else -# define ADC_TEMP false -# endif - - ret = rp2040_adc_setup("/dev/adc0", ADC_0, ADC_1, ADC_2, ADC_3, ADC_TEMP); - if (ret != OK) - { - syslog(LOG_ERR, "Failed to initialize ADC Driver: %d\n", ret); return ret; } -#endif /* defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) */ +#endif /* CONFIG_ARCH_BOARD_COMMON */ - return ret; + /* --- Place any board specific bringup code here --- */ + + return OK; } diff --git a/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/gpio/defconfig b/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/gpio/defconfig index f5362d78c5d..e5f6b58d17f 100644 --- a/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/gpio/defconfig +++ b/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/gpio/defconfig @@ -54,4 +54,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART1_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/nsh/defconfig b/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/nsh/defconfig index 084cb978f0d..6de7d7eb775 100644 --- a/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/nsh/defconfig +++ b/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/nsh/defconfig @@ -52,4 +52,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART1_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/nshsram/defconfig b/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/nshsram/defconfig index 4dce15a1518..35cdedead4c 100644 --- a/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/nshsram/defconfig +++ b/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/nshsram/defconfig @@ -51,4 +51,3 @@ CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y CONFIG_UART1_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/smp/defconfig b/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/smp/defconfig index 0df779d086c..9b4c708b01f 100644 --- a/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/smp/defconfig +++ b/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/smp/defconfig @@ -58,4 +58,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_TESTING_SMP=y CONFIG_UART1_SERIAL_CONSOLE=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/usbnsh/defconfig b/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/usbnsh/defconfig index 0edc888649d..760c1136485 100644 --- a/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/usbnsh/defconfig +++ b/boards/arm/rp2040/adafruit-qt-py-rp2040/configs/usbnsh/defconfig @@ -53,4 +53,3 @@ CONFIG_TESTING_OSTEST=y CONFIG_USBDEV=y CONFIG_USBDEV_BUSPOWERED=y CONFIG_WS2812=y -CONFIG_WS2812_NON_SPI_DRIVER=y diff --git a/boards/arm/rp2040/adafruit-qt-py-rp2040/src/rp2040_boardinitialize.c b/boards/arm/rp2040/adafruit-qt-py-rp2040/src/rp2040_boardinitialize.c index e2935b3e46c..4d3010f8f48 100644 --- a/boards/arm/rp2040/adafruit-qt-py-rp2040/src/rp2040_boardinitialize.c +++ b/boards/arm/rp2040/adafruit-qt-py-rp2040/src/rp2040_boardinitialize.c @@ -32,6 +32,10 @@ #include "arm_internal.h" #include "rp2040_gpio.h" +#ifdef CONFIG_ARCH_BOARD_COMMON +#include "rp2040_common_initialize.h" +#endif /* CONFIG_ARCH_BOARD_COMMON */ + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -53,46 +57,11 @@ void rp2040_boardearlyinitialize(void) { - rp2040_gpio_initialize(); + #ifdef CONFIG_ARCH_BOARD_COMMON + rp2040_common_earlyinitialize(); + #endif - /* Disable IE on GPIO 26-29 */ - - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(26)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(27)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(28)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(29)); - - /* Set default UART pin */ - -#ifdef CONFIG_RP2040_UART0 - rp2040_gpio_set_function(CONFIG_RP2040_UART0_TX_GPIO, - RP2040_GPIO_FUNC_UART); /* TX */ - rp2040_gpio_set_function(CONFIG_RP2040_UART0_RX_GPIO, - RP2040_GPIO_FUNC_UART); /* RX */ -#ifdef CONFIG_SERIAL_OFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART0_CTS_GPIO, - RP2040_GPIO_FUNC_UART); /* CTS */ -#endif -#ifdef CONFIG_SERIAL_IFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART0_RTS_GPIO, - RP2040_GPIO_FUNC_UART); /* RTS */ -#endif -#endif - -#ifdef CONFIG_RP2040_UART1 - rp2040_gpio_set_function(CONFIG_RP2040_UART1_TX_GPIO, - RP2040_GPIO_FUNC_UART); /* TX */ - rp2040_gpio_set_function(CONFIG_RP2040_UART1_RX_GPIO, - RP2040_GPIO_FUNC_UART); /* RX */ -#ifdef CONFIG_SERIAL_OFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART1_CTS_GPIO, - RP2040_GPIO_FUNC_UART); /* CTS */ -#endif -#ifdef CONFIG_SERIAL_IFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART1_RTS_GPIO, - RP2040_GPIO_FUNC_UART); /* RTS */ -#endif -#endif + /* --- Place any board specific early initialization here --- */ } /**************************************************************************** @@ -104,57 +73,9 @@ void rp2040_boardearlyinitialize(void) void rp2040_boardinitialize(void) { - /* Set default I2C pin */ + #ifdef CONFIG_ARCH_BOARD_COMMON + rp2040_common_initialize(); + #endif -#ifdef CONFIG_RP2040_I2C0 - rp2040_gpio_set_function(CONFIG_RP2040_I2C0_SDA_GPIO, - RP2040_GPIO_FUNC_I2C); /* SDA */ - rp2040_gpio_set_function(CONFIG_RP2040_I2C0_SCL_GPIO, - RP2040_GPIO_FUNC_I2C); /* SCL */ - - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_SDA_GPIO, true, false); /* Pull up */ - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_SCL_GPIO, true, false); -#endif - -#ifdef CONFIG_RP2040_I2C1 - rp2040_gpio_set_function(CONFIG_RP2040_I2C1_SDA_GPIO, - RP2040_GPIO_FUNC_I2C); /* SDA */ - rp2040_gpio_set_function(CONFIG_RP2040_I2C1_SCL_GPIO, - RP2040_GPIO_FUNC_I2C); /* SCL */ - - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_SDA_GPIO, true, false); /* Pull up */ - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_SCL_GPIO, true, false); -#endif - - /* Set default SPI pin */ - -#ifdef CONFIG_RP2040_SPI0 - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_RX_GPIO, - RP2040_GPIO_FUNC_SPI); /* RX */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_SCK_GPIO, - RP2040_GPIO_FUNC_SPI); /* SCK */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_TX_GPIO, - RP2040_GPIO_FUNC_SPI); /* TX */ - - /* CSn is controlled by board-specific logic */ - - rp2040_gpio_init(CONFIG_RP2040_SPI0_CS_GPIO); /* CSn */ - rp2040_gpio_setdir(CONFIG_RP2040_SPI0_CS_GPIO, true); - rp2040_gpio_put(CONFIG_RP2040_SPI0_CS_GPIO, true); -#endif - -#ifdef CONFIG_RP2040_SPI1 - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_RX_GPIO, - RP2040_GPIO_FUNC_SPI); /* RX */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_SCK_GPIO, - RP2040_GPIO_FUNC_SPI); /* SCK */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_TX_GPIO, - RP2040_GPIO_FUNC_SPI); /* TX */ - - /* CSn is controlled by board-specific logic */ - - rp2040_gpio_init(CONFIG_RP2040_SPI1_CS_GPIO); /* CSn */ - rp2040_gpio_setdir(CONFIG_RP2040_SPI1_CS_GPIO, true); - rp2040_gpio_put(CONFIG_RP2040_SPI1_CS_GPIO, true); -#endif + /* --- Place any board specific initialization here --- */ } diff --git a/boards/arm/rp2040/adafruit-qt-py-rp2040/src/rp2040_bringup.c b/boards/arm/rp2040/adafruit-qt-py-rp2040/src/rp2040_bringup.c index 3814acd7277..83d4679ba78 100644 --- a/boards/arm/rp2040/adafruit-qt-py-rp2040/src/rp2040_bringup.c +++ b/boards/arm/rp2040/adafruit-qt-py-rp2040/src/rp2040_bringup.c @@ -27,56 +27,9 @@ #include #include -#include - -#include - -#include "rp2040_pico.h" - -#ifdef CONFIG_LCD_BACKPACK -#include "rp2040_lcd_backpack.h" -#endif - -#ifdef CONFIG_LCD -#include -#endif - -#ifdef CONFIG_LCD_DEV -#include -#endif - -#ifdef CONFIG_VIDEO_FB -#include -#endif - -#ifdef CONFIG_SENSORS_INA219 -#include -#include "rp2040_ina219.h" -#endif - -#ifdef CONFIG_SENSORS_BMP180 -#include -#include "rp2040_bmp180.h" -#endif - -#ifdef CONFIG_RP2040_PWM -#include "rp2040_pwm.h" -#include "rp2040_pwmdev.h" -#endif - -#if defined(CONFIG_RP2040_BOARD_HAS_WS2812) && defined(CONFIG_WS2812) -#include "rp2040_ws2812.h" -#endif - -#ifdef CONFIG_WS2812_HAS_WHITE -#define HAS_WHITE true -#else /* CONFIG_WS2812_HAS_WHITE */ -#define HAS_WHITE false -#endif /* CONFIG_WS2812_HAS_WHITE */ - -#if defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) -#include "rp2040_adc.h" -#endif +#ifdef CONFIG_ARCH_BOARD_COMMON +#include "rp2040_common_bringup.h" +#endif /* CONFIG_ARCH_BOARD_COMMON */ /**************************************************************************** * Public Functions @@ -88,425 +41,17 @@ int rp2040_bringup(void) { - int ret = 0; +#ifdef CONFIG_ARCH_BOARD_COMMON -#ifdef CONFIG_RP2040_I2C_DRIVER - #ifdef CONFIG_RP2040_I2C0 - ret = board_i2cdev_initialize(0); + int ret = rp2040_common_bringup(); if (ret < 0) { - _err("ERROR: Failed to initialize I2C0.\n"); - } - #endif - - #ifdef CONFIG_RP2040_I2C1 - ret = board_i2cdev_initialize(1); - if (ret < 0) - { - _err("ERROR: Failed to initialize I2C1.\n"); - } - #endif -#endif - -#ifdef CONFIG_RP2040_SPI_DRIVER - #ifdef CONFIG_RP2040_SPI0 - ret = board_spidev_initialize(0); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI0.\n"); - } - #endif - - #ifdef CONFIG_RP2040_SPI1 - ret = board_spidev_initialize(1); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI1.\n"); - } - #endif -#endif - -#ifdef CONFIG_RP2040_PWM -# ifdef CONFIG_RP2040_PWM0 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(0, - CONFIG_RP2040_PWM0A_GPIO, - CONFIG_RP2040_PWM0B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM0A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM0B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM0_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(0, - CONFIG_RP2040_PWM0A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM0A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM0_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM0.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM1 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(1, - CONFIG_RP2040_PWM1A_GPIO, - CONFIG_RP2040_PWM1B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM1A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM1B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM1_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(1, - CONFIG_RP2040_PWM1A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM1A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM1_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM1.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM2 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(2, - CONFIG_RP2040_PWM2A_GPIO, - CONFIG_RP2040_PWM2B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM2A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM2B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM2_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(2, - CONFIG_RP2040_PWM2A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM2A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM2_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM2.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM3 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(3, - CONFIG_RP2040_PWM3A_GPIO, - CONFIG_RP2040_PWM3B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM3A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM3B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM3_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(3, - CONFIG_RP2040_PWM3A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM3A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM3_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM3.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM4 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(4, - CONFIG_RP2040_PWM4A_GPIO, - CONFIG_RP2040_PWM4B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM4A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM4B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM4_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(4, - CONFIG_RP2040_PWM4A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM4A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM4_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM4.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM5 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(5, - CONFIG_RP2040_PWM5A_GPIO, - CONFIG_RP2040_PWM5B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM5A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM5B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM5_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(5, - CONFIG_RP2040_PWM5A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM5A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM5_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM5.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM6 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(6, - CONFIG_RP2040_PWM6A_GPIO, - CONFIG_RP2040_PWM6B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM6A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM6B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM6_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(6, - CONFIG_RP2040_PWM6A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM6A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM6_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM6.\n"); - } -# endif -#endif - -#ifdef CONFIG_RP2040_SPISD - /* Mount the SPI-based MMC/SD block driver */ - - ret = board_spisd_initialize(0, CONFIG_RP2040_SPISD_SPI_CH); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI device to MMC/SD: %d\n", - ret); - } -#endif - -#ifdef CONFIG_FS_PROCFS - /* Mount the procfs file system */ - - ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); - if (ret < 0) - { - serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret); - } -#endif - -#ifdef CONFIG_SENSORS_BMP180 - /* Try to register BMP180 device in I2C0 */ - - ret = board_bmp180_initialize(0); - if (ret < 0) - { - syslog(LOG_ERR, "Failed to initialize BMP180 driver: %d\n", ret); - } -#endif - -#ifdef CONFIG_SENSORS_INA219 - /* Configure and initialize the INA219 sensor in I2C0 */ - - ret = board_ina219_initialize(0); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: rp2040_ina219_initialize() failed: %d\n", ret); - } -#endif - -#ifdef CONFIG_VIDEO_FB - ret = fb_register(0, 0); - if (ret < 0) - { - _err("ERROR: Failed to initialize Frame Buffer Driver.\n"); - } -#elif defined(CONFIG_LCD) - ret = board_lcd_initialize(); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: Failed to initialize LCD.\n"); - } -#endif - -#ifdef CONFIG_LCD_DEV - ret = lcddev_register(0); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: lcddev_register() failed: %d\n", ret); - } -#endif - -#ifdef CONFIG_LCD_BACKPACK - /* slcd:0, i2c:0, rows=2, cols=16 */ - - ret = board_lcd_backpack_init(0, 0, 2, 16); - if (ret < 0) - { - syslog(LOG_ERR, "Failed to initialize PCF8574 LCD, error %d\n", ret); - return ret; - } -#endif - -#ifdef CONFIG_RP2040_I2S - ret = board_i2sdev_initialize(0); - if (ret < 0) - { - _err("ERROR: Failed to initialize I2S.\n"); - } -#endif - -#ifdef CONFIG_DEV_GPIO - ret = rp2040_dev_gpio_init(); - if (ret < 0) - { - syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret); - return ret; - } -#endif - - /* Initialize board neo-pixel */ - -#if defined(CONFIG_RP2040_BOARD_HAS_WS2812) && defined(CONFIG_WS2812) - rp2040_ws2812_setup("/dev/leds0", - CONFIG_RP2040_WS2812_GPIO_PIN, - CONFIG_RP2040_WS2812_PWR_GPIO, - CONFIG_WS2812_LED_COUNT, - HAS_WHITE); -#endif - -#if defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) - -# ifdef CONFIG_RPC2040_ADC_CHANNEL0 -# define ADC_0 true -# else -# define ADC_0 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL1 -# define ADC_1 true -# else -# define ADC_1 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL2 -# define ADC_2 true -# else -# define ADC_2 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL3 -# define ADC_3 true -# else -# define ADC_3 false -# endif - -# ifdef CONFIG_RPC2040_ADC_TEMPERATURE -# define ADC_TEMP true -# else -# define ADC_TEMP false -# endif - - ret = rp2040_adc_setup("/dev/adc0", ADC_0, ADC_1, ADC_2, ADC_3, ADC_TEMP); - if (ret != OK) - { - syslog(LOG_ERR, "Failed to initialize ADC Driver: %d\n", ret); return ret; } -#endif /* defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) */ +#endif /* CONFIG_ARCH_BOARD_COMMON */ - return ret; + /* --- Place any board specific bringup code here --- */ + + return OK; } diff --git a/boards/arm/rp2040/common/include/rp2040_common_bringup.h b/boards/arm/rp2040/common/include/rp2040_common_bringup.h new file mode 100644 index 00000000000..d1c3483d195 --- /dev/null +++ b/boards/arm/rp2040/common/include/rp2040_common_bringup.h @@ -0,0 +1,47 @@ +/**************************************************************************** + * boards/arm/rp2040/common/include/rp2040_common_bringup.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_COMMON_INCLUDE_RP2040_COMMON_BRINGUP_H +#define __BOARDS_ARM_RP2040_COMMON_INCLUDE_RP2040_COMMON_BRINGUP_H + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_common_bringup + ****************************************************************************/ + +int rp2040_common_bringup(void); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __BOARDS_ARM_RP2040_COMMON_INCLUDE_RP2040_COMMON_BRINGUP_H */ \ No newline at end of file diff --git a/boards/arm/rp2040/common/include/rp2040_common_initialize.h b/boards/arm/rp2040/common/include/rp2040_common_initialize.h new file mode 100644 index 00000000000..d8bb654f78e --- /dev/null +++ b/boards/arm/rp2040/common/include/rp2040_common_initialize.h @@ -0,0 +1,60 @@ +/**************************************************************************** + * boards/arm/rp2040/common/include/rp2040_common_initialize.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_COMMON_INCLUDE_RP2040_COMMON_INITIALIZE_H +#define __BOARDS_ARM_RP2040_COMMON_INCLUDE_RP2040_COMMON_INITIALIZE_H + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_common_earlyinitialize + * + * This is the early initialization common to all RP2040 boards. + * It configures the GPIO, SPI, and I2C pins. + ****************************************************************************/ + +int rp2040_common_earlyinitialize(void); + +/**************************************************************************** + * Name: rp2040_common_initialize + * + * Description: + * It configures the pin assignments that were not done in the early + * initialization. + ****************************************************************************/ + +void rp2040_common_initialize(void); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __BOARDS_ARM_RP2040_COMMON_INCLUDE_RP2040_COMMON_INITIALIZE_H */ \ No newline at end of file diff --git a/boards/arm/rp2040/common/src/.gitignore b/boards/arm/rp2040/common/src/.gitignore new file mode 100644 index 00000000000..608fca90dbf --- /dev/null +++ b/boards/arm/rp2040/common/src/.gitignore @@ -0,0 +1 @@ +*.image diff --git a/boards/arm/rp2040/common/src/Make.defs b/boards/arm/rp2040/common/src/Make.defs index 0f6c36cfec9..3c93e2c1f77 100644 --- a/boards/arm/rp2040/common/src/Make.defs +++ b/boards/arm/rp2040/common/src/Make.defs @@ -20,6 +20,9 @@ ifeq ($(CONFIG_ARCH_BOARD_COMMON),y) +CSRCS += rp2040_common_bringup.c +CSRCS += rp2040_common_initialize.c + ifeq ($(CONFIG_RP2040_I2C_DRIVER),y) CSRCS += rp2040_i2cdev.c endif diff --git a/boards/arm/rp2040/common/src/rp2040_common_bringup.c b/boards/arm/rp2040/common/src/rp2040_common_bringup.c new file mode 100644 index 00000000000..15d40a0f785 --- /dev/null +++ b/boards/arm/rp2040/common/src/rp2040_common_bringup.c @@ -0,0 +1,574 @@ +/**************************************************************************** + * boards/arm/rp2040/common/src/rp2040_common_bringup.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include + +#include "rp2040_pico.h" +#include "rp2040_common_bringup.h" + +#ifdef CONFIG_LCD_BACKPACK +#include "rp2040_lcd_backpack.h" +#endif + +#ifdef CONFIG_LCD +#include +#endif + +#ifdef CONFIG_LCD_DEV +#include +#endif + +#ifdef CONFIG_VIDEO_FB +#include +#endif + +#ifdef CONFIG_SENSORS_INA219 +#include +#include "rp2040_ina219.h" +#endif + +#ifdef CONFIG_SENSORS_BMP180 +#include +#include "rp2040_bmp180.h" +#endif + +#ifdef CONFIG_RP2040_PWM +#include "rp2040_pwm.h" +#include "rp2040_pwmdev.h" +#endif + +#if defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) +#include "rp2040_adc.h" +#endif + +#if defined(CONFIG_RP2040_BOARD_HAS_WS2812) && defined(CONFIG_WS2812) +#include "rp2040_ws2812.h" +#endif + +#ifdef CONFIG_WS2812_HAS_WHITE +#define HAS_WHITE true +#else /* CONFIG_WS2812_HAS_WHITE */ +#define HAS_WHITE false +#endif /* CONFIG_WS2812_HAS_WHITE */ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_common_bringup + ****************************************************************************/ + +int rp2040_common_bringup(void) +{ + int ret = 0; + +#ifdef CONFIG_RP2040_I2C_DRIVER + #ifdef CONFIG_RP2040_I2C0 + ret = board_i2cdev_initialize(0); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize I2C0.\n"); + return ret; + } + #endif + + #ifdef CONFIG_RP2040_I2C1 + ret = board_i2cdev_initialize(1); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize I2C1.\n"); + return ret; + } + #endif +#endif + +#ifdef CONFIG_RP2040_SPI_DRIVER + #ifdef CONFIG_RP2040_SPI0 + ret = board_spidev_initialize(0); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize SPI0.\n"); + return ret; + } + #endif + + #ifdef CONFIG_RP2040_SPI1 + ret = board_spidev_initialize(1); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize SPI1.\n"); + return ret; + } + #endif +#endif + +#ifdef CONFIG_RP2040_PWM +# ifdef CONFIG_RP2040_PWM0 +# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 + ret = rp2040_pwmdev_initialize(0, + CONFIG_RP2040_PWM0A_GPIO, + CONFIG_RP2040_PWM0B_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM0A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM0B_INVERT + | RP2040_PWM_CSR_B_INV +# endif +# ifdef CONFIG_RP2040_PWM0_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# else + ret = rp2040_pwmdev_initialize(0, + CONFIG_RP2040_PWM0A_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM0A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM0_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# endif + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize PWM0.\n"); + return ret; + } +# endif + +# ifdef CONFIG_RP2040_PWM1 +# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 + ret = rp2040_pwmdev_initialize(1, + CONFIG_RP2040_PWM1A_GPIO, + CONFIG_RP2040_PWM1B_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM1A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM1B_INVERT + | RP2040_PWM_CSR_B_INV +# endif +# ifdef CONFIG_RP2040_PWM1_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# else + ret = rp2040_pwmdev_initialize(1, + CONFIG_RP2040_PWM1A_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM1A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM1_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# endif + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize PWM1.\n"); + return ret; + } +# endif + +# ifdef CONFIG_RP2040_PWM2 +# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 + ret = rp2040_pwmdev_initialize(2, + CONFIG_RP2040_PWM2A_GPIO, + CONFIG_RP2040_PWM2B_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM2A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM2B_INVERT + | RP2040_PWM_CSR_B_INV +# endif +# ifdef CONFIG_RP2040_PWM2_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# else + ret = rp2040_pwmdev_initialize(2, + CONFIG_RP2040_PWM2A_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM2A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM2_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# endif + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize PWM2.\n"); + return ret; + } +# endif + +# ifdef CONFIG_RP2040_PWM3 +# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 + ret = rp2040_pwmdev_initialize(3, + CONFIG_RP2040_PWM3A_GPIO, + CONFIG_RP2040_PWM3B_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM3A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM3B_INVERT + | RP2040_PWM_CSR_B_INV +# endif +# ifdef CONFIG_RP2040_PWM3_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# else + ret = rp2040_pwmdev_initialize(3, + CONFIG_RP2040_PWM3A_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM3A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM3_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# endif + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize PWM3.\n"); + return ret; + } +# endif + +# ifdef CONFIG_RP2040_PWM4 +# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 + ret = rp2040_pwmdev_initialize(4, + CONFIG_RP2040_PWM4A_GPIO, + CONFIG_RP2040_PWM4B_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM4A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM4B_INVERT + | RP2040_PWM_CSR_B_INV +# endif +# ifdef CONFIG_RP2040_PWM4_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# else + ret = rp2040_pwmdev_initialize(4, + CONFIG_RP2040_PWM4A_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM4A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM4_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# endif + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize PWM4.\n"); + return ret; + } +# endif + +# ifdef CONFIG_RP2040_PWM5 +# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 + ret = rp2040_pwmdev_initialize(5, + CONFIG_RP2040_PWM5A_GPIO, + CONFIG_RP2040_PWM5B_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM5A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM5B_INVERT + | RP2040_PWM_CSR_B_INV +# endif +# ifdef CONFIG_RP2040_PWM5_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# else + ret = rp2040_pwmdev_initialize(5, + CONFIG_RP2040_PWM5A_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM5A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM5_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# endif + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize PWM5.\n"); + return ret; + } +# endif + +# ifdef CONFIG_RP2040_PWM6 +# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 + ret = rp2040_pwmdev_initialize(6, + CONFIG_RP2040_PWM6A_GPIO, + CONFIG_RP2040_PWM6B_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM6A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM6B_INVERT + | RP2040_PWM_CSR_B_INV +# endif +# ifdef CONFIG_RP2040_PWM6_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# else + ret = rp2040_pwmdev_initialize(6, + CONFIG_RP2040_PWM6A_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM6A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM6_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# endif + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize PWM6.\n"); + return ret; + } +# endif + +# ifdef CONFIG_RP2040_PWM7 +# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 + ret = rp2040_pwmdev_initialize(7, + CONFIG_RP2040_PWM7A_GPIO, + CONFIG_RP2040_PWM7B_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM7A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM7B_INVERT + | RP2040_PWM_CSR_B_INV +# endif +# ifdef CONFIG_RP2040_PWM7_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# else + ret = rp2040_pwmdev_initialize(7, + CONFIG_RP2040_PWM7A_GPIO, + (0 +# ifdef CONFIG_RP2040_PWM7A_INVERT + | RP2040_PWM_CSR_A_INV +# endif +# ifdef CONFIG_RP2040_PWM7_PHASE_CORRECT + | RP2040_PWM_CSR_PH_CORRECT +# endif + )); +# endif + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize PWM7.\n"); + return ret; + } +# endif +#endif + +#ifdef CONFIG_RP2040_SPISD + /* Mount the SPI-based MMC/SD block driver */ + + ret = board_spisd_initialize(0, CONFIG_RP2040_SPISD_SPI_CH); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize SPI device to MMC/SD: %d\n", + ret); + } +#endif + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); + if (ret < 0) + { + serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret); + } +#endif + +#ifdef CONFIG_SENSORS_BMP180 + /* Try to register BMP180 device in I2C0 */ + + ret = board_bmp180_initialize(0); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize BMP180 driver: %d\n", ret); + return ret; + } +#endif + +#ifdef CONFIG_SENSORS_INA219 + /* Configure and initialize the INA219 sensor in I2C0 */ + + ret = board_ina219_initialize(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: rp2040_ina219_initialize() failed: %d\n", ret); + return ret; + } +#endif + +#ifdef CONFIG_VIDEO_FB + ret = fb_register(0, 0); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize Frame Buffer Driver.\n"); + return ret; + } +#elif defined(CONFIG_LCD) + ret = board_lcd_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize LCD.\n"); + return ret; + } +#endif + +#ifdef CONFIG_LCD_DEV + ret = lcddev_register(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: lcddev_register() failed: %d\n", ret); + return ret; + } +#endif + +#ifdef CONFIG_LCD_BACKPACK + /* slcd:0, i2c:0, rows=2, cols=16 */ + + ret = board_lcd_backpack_init(0, 0, 2, 16); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize PCF8574 LCD, error %d\n", ret); + return ret; + return ret; + } +#endif + +#ifdef CONFIG_RP2040_I2S + ret = board_i2sdev_initialize(0); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize I2S.\n"); + return ret; + } +#endif + +#ifdef CONFIG_DEV_GPIO + ret = rp2040_dev_gpio_init(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret); + return ret; + } +#endif + + /* Initialize ADC */ + +#if defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) + +# ifdef CONFIG_RPC2040_ADC_CHANNEL0 +# define ADC_0 true +# else +# define ADC_0 false +# endif + +# ifdef CONFIG_RPC2040_ADC_CHANNEL1 +# define ADC_1 true +# else +# define ADC_1 false +# endif + +# ifdef CONFIG_RPC2040_ADC_CHANNEL2 +# define ADC_2 true +# else +# define ADC_2 false +# endif + +# ifdef CONFIG_RPC2040_ADC_CHANNEL3 +# define ADC_3 true +# else +# define ADC_3 false +# endif + +# ifdef CONFIG_RPC2040_ADC_TEMPERATURE +# define ADC_TEMP true +# else +# define ADC_TEMP false +# endif + + ret = rp2040_adc_setup("/dev/adc0", ADC_0, ADC_1, ADC_2, ADC_3, ADC_TEMP); + if (ret != OK) + { + syslog(LOG_ERR, "Failed to initialize ADC Driver: %d\n", ret); + return ret; + } + +#endif /* defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) */ + + /* Initialize board neo-pixel */ + +#if defined(CONFIG_RP2040_BOARD_HAS_WS2812) && defined(CONFIG_WS2812) + + if (rp2040_ws2812_setup("/dev/leds0", + CONFIG_RP2040_WS2812_GPIO_PIN, + CONFIG_RP2040_WS2812_PWR_GPIO, + CONFIG_WS2812_LED_COUNT, + HAS_WHITE) == NULL) + { + syslog(LOG_ERR, "Failed to initialize WS2812: %d\n", errno); + return -errno; + } +#endif + + return OK; +} diff --git a/boards/arm/rp2040/common/src/rp2040_common_initialize.c b/boards/arm/rp2040/common/src/rp2040_common_initialize.c new file mode 100644 index 00000000000..6e86c52986a --- /dev/null +++ b/boards/arm/rp2040/common/src/rp2040_common_initialize.c @@ -0,0 +1,162 @@ +/**************************************************************************** + * boards/arm/rp2040/common/src/rp2040_common_initialize.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include + +#include "arm_internal.h" +#include "rp2040_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_common_earlyinitialize + * + * Description: + * This is the early initialization common to all RP2040 boards. + * It configures the UART pins so the system console can be used. + ****************************************************************************/ + +void rp2040_common_earlyinitialize(void) +{ + rp2040_gpio_initialize(); + + /* Disable IE on GPIO 26-29 */ + + clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(26)); + clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(27)); + clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(28)); + clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(29)); + + /* Set default UART pin */ + +#ifdef CONFIG_RP2040_UART0 + rp2040_gpio_set_function(CONFIG_RP2040_UART0_TX_GPIO, + RP2040_GPIO_FUNC_UART); /* TX */ + rp2040_gpio_set_function(CONFIG_RP2040_UART0_RX_GPIO, + RP2040_GPIO_FUNC_UART); /* RX */ +#ifdef CONFIG_SERIAL_OFLOWCONTROL + rp2040_gpio_set_function(CONFIG_RP2040_UART0_CTS_GPIO, + RP2040_GPIO_FUNC_UART); /* CTS */ +#endif +#ifdef CONFIG_SERIAL_IFLOWCONTROL + rp2040_gpio_set_function(CONFIG_RP2040_UART0_RTS_GPIO, + RP2040_GPIO_FUNC_UART); /* RTS */ +#endif +#endif + +#ifdef CONFIG_RP2040_UART1 + rp2040_gpio_set_function(CONFIG_RP2040_UART1_TX_GPIO, + RP2040_GPIO_FUNC_UART); /* TX */ + rp2040_gpio_set_function(CONFIG_RP2040_UART1_RX_GPIO, + RP2040_GPIO_FUNC_UART); /* RX */ +#ifdef CONFIG_SERIAL_OFLOWCONTROL + rp2040_gpio_set_function(CONFIG_RP2040_UART1_CTS_GPIO, + RP2040_GPIO_FUNC_UART); /* CTS */ +#endif +#ifdef CONFIG_SERIAL_IFLOWCONTROL + rp2040_gpio_set_function(CONFIG_RP2040_UART1_RTS_GPIO, + RP2040_GPIO_FUNC_UART); /* RTS */ +#endif +#endif +} + +/**************************************************************************** + * Name: rp2040_common_initialize + * + * Description: + * It configures the pin assignments that were not done in the early + * initialization. + ****************************************************************************/ + +void rp2040_common_initialize(void) +{ + /* Set default I2C pin */ + +#ifdef CONFIG_RP2040_I2C0 + rp2040_gpio_set_function(CONFIG_RP2040_I2C0_SDA_GPIO, + RP2040_GPIO_FUNC_I2C); /* SDA */ + rp2040_gpio_set_function(CONFIG_RP2040_I2C0_SCL_GPIO, + RP2040_GPIO_FUNC_I2C); /* SCL */ + + rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_SDA_GPIO, true, false); /* Pull up */ + rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_SCL_GPIO, true, false); +#endif + +#ifdef CONFIG_RP2040_I2C1 + rp2040_gpio_set_function(CONFIG_RP2040_I2C1_SDA_GPIO, + RP2040_GPIO_FUNC_I2C); /* SDA */ + rp2040_gpio_set_function(CONFIG_RP2040_I2C1_SCL_GPIO, + RP2040_GPIO_FUNC_I2C); /* SCL */ + + rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_SDA_GPIO, true, false); /* Pull up */ + rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_SCL_GPIO, true, false); +#endif + + /* Set default SPI pin */ + +#ifdef CONFIG_RP2040_SPI0 + rp2040_gpio_set_function(CONFIG_RP2040_SPI0_RX_GPIO, + RP2040_GPIO_FUNC_SPI); /* RX */ + rp2040_gpio_set_function(CONFIG_RP2040_SPI0_SCK_GPIO, + RP2040_GPIO_FUNC_SPI); /* SCK */ + rp2040_gpio_set_function(CONFIG_RP2040_SPI0_TX_GPIO, + RP2040_GPIO_FUNC_SPI); /* TX */ + + /* CSn is controlled by board-specific logic */ + + rp2040_gpio_init(CONFIG_RP2040_SPI0_CS_GPIO); /* CSn */ + rp2040_gpio_setdir(CONFIG_RP2040_SPI0_CS_GPIO, true); + rp2040_gpio_put(CONFIG_RP2040_SPI0_CS_GPIO, true); +#endif + +#ifdef CONFIG_RP2040_SPI1 + rp2040_gpio_set_function(CONFIG_RP2040_SPI1_RX_GPIO, + RP2040_GPIO_FUNC_SPI); /* RX */ + rp2040_gpio_set_function(CONFIG_RP2040_SPI1_SCK_GPIO, + RP2040_GPIO_FUNC_SPI); /* SCK */ + rp2040_gpio_set_function(CONFIG_RP2040_SPI1_TX_GPIO, + RP2040_GPIO_FUNC_SPI); /* TX */ + + /* CSn is controlled by board-specific logic */ + + rp2040_gpio_init(CONFIG_RP2040_SPI1_CS_GPIO); /* CSn */ + rp2040_gpio_setdir(CONFIG_RP2040_SPI1_CS_GPIO, true); + rp2040_gpio_put(CONFIG_RP2040_SPI1_CS_GPIO, true); +#endif +} diff --git a/boards/arm/rp2040/common/src/rp2040_firmware.c b/boards/arm/rp2040/common/src/rp2040_firmware.c new file mode 100644 index 00000000000..74148893fc4 --- /dev/null +++ b/boards/arm/rp2040/common/src/rp2040_firmware.c @@ -0,0 +1,158 @@ +/**************************************************************************** + * boards/arm/rp2040/common/src/rp2040_firmware.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define _STR(x) #x +#define STR(x) _STR(x) + +#define ROUNDED_FIRMWARE_LEN ((CONFIG_CYW43439_FIRMWARE_LEN + 0xff) & ~0xff) + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef CONFIG_IEEE80211_INFINEON_CYW43439 + +/**************************************************************************** + * Character array of NVRAM image + * Generated from cyw943439wlpth_rev1_0.txt + * $ Copyright Broadcom Corporation $ + ****************************************************************************/ + +const uint8_t g_cyw43439_nvram_image[] __attribute__((aligned(4))) = + "NVRAMRev=$Rev$" "\x00" + "manfid=0x2d0" "\x00" + "prodid=0x0727" "\x00" + "vendid=0x14e4" "\x00" + "devid=0x43e2" "\x00" + "boardtype=0x0887" "\x00" + "boardrev=0x1100" "\x00" + "boardnum=22" "\x00" + "macaddr=00:A0:50:b5:59:5e" "\x00" + "sromrev=11" "\x00" + "boardflags=0x00404001" "\x00" + "boardflags3=0x04000000" "\x00" + "xtalfreq=37400" "\x00" + "nocrc=1" "\x00" + "ag0=255" "\x00" + "aa2g=1" "\x00" + "ccode=ALL" "\x00" + "pa0itssit=0x20" "\x00" + "extpagain2g=0" "\x00" + "pa2ga0=-168,6649,-778" "\x00" + "AvVmid_c0=0x0,0xc8" "\x00" + "cckpwroffset0=5" "\x00" + "maxp2ga0=84" "\x00" + "txpwrbckof=6" "\x00" + "cckbw202gpo=0" "\x00" + "legofdmbw202gpo=0x66111111" "\x00" + "mcsbw202gpo=0x77711111" "\x00" + "propbw202gpo=0xdd" "\x00" + "ofdmdigfilttype=18" "\x00" + "ofdmdigfilttypebe=18" "\x00" + "papdmode=1" "\x00" + "papdvalidtest=1" "\x00" + "pacalidx2g=45" "\x00" + "papdepsoffset=-30" "\x00" + "papdendidx=58" "\x00" + "ltecxmux=0" "\x00" + "ltecxpadnum=0x0102" "\x00" + "ltecxfnsel=0x44" "\x00" + "ltecxgcigpio=0x01" "\x00" + "il0macaddr=00:90:4c:c5:12:38" "\x00" + "wl0id=0x431b" "\x00" + "deadman_to=0xffffffff" "\x00" + "muxenab=0x100" "\x00" + "spurconfig=0x3" "\x00" + "glitch_based_crsmin=1" "\x00" + "btc_mode=1" "\x00" + "\x00\x00"; + +const unsigned int g_cyw43439_nvram_len = sizeof(g_cyw43439_nvram_image); + +/**************************************************************************** + * Include the firmware blob. This assembly code defines the global + * symbol g_cyw43439_firmware_image as the address of this included + * blob. This is similar in effect to the C statement: + * const uint8_t g_cyw43439_firmware_image[] = {...}; + * const uint8_t ng_cyw43439_clm_blob_image[] = {...}; + ****************************************************************************/ + +/* These are defined as array because the symbols name an actual address + * not a pointer to an address. This is not one of the many cases where + * pointers and arrays are interchangable in C. + */ + +extern const uint8_t g_cyw43439_firmware_image[]; +extern const uint8_t g_cyw43439_clm_blob_image[]; +extern const unsigned int g_cyw43439_clm_blob_len; + +/* This assembly code does the following: + * - Force 16-byte alignment + * - Defines g_cyw43439_firmware_image as a location in memory + * - Copies the firmware image file data to that location. + * - Defines g_cyw43439_firmware_end as the location directly beyond + * that data. + * - Defines g_cyw43439_clm_blob_image as a location withing that + * data where the clm_blob begins. + * - Force 4-byte alignment + * - Allocates an integer named g_cyw43439_clm_blob_len that + * contains the length of the clm_blob. + */ + +__asm__("\n .balign 16" + "\n .globl g_cyw43439_firmware_image" + "\n .globl g_cyw43439_clm_blob_image" + "\n .globl g_cyw43439_clm_blob_len" + "\n g_cyw43439_firmware_image:" + "\n .incbin \"cyw43439.firmware.image\"" + "\n firmware_end:" + "\n g_cyw43439_clm_blob_image=g_cyw43439_firmware_image+" + STR(ROUNDED_FIRMWARE_LEN) + "\n .balign 4" + "\n g_cyw43439_clm_blob_len:" + "\n .word firmware_end-g_cyw43439_clm_blob_image" + "\n"); + +/**************************************************************************** + * Other CYW43439 Firmware global definitions + ****************************************************************************/ + +#ifndef CONFIG_IEEE80211_BROADCOM_FWFILES + +const unsigned int g_cyw43439_firmware_len = CONFIG_CYW43439_FIRMWARE_LEN; + +#endif /* CONFIG_IEEE80211_BROADCOM_FWFILES */ + +#endif /* CONFIG_IEEE80211_INFINEON_CYW43439 */ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ diff --git a/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_boardinitialize.c b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_boardinitialize.c index 882dcf32fce..05986e662f6 100644 --- a/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_boardinitialize.c +++ b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_boardinitialize.c @@ -29,8 +29,13 @@ #include #include +#include "arm_internal.h" #include "rp2040_gpio.h" +#ifdef CONFIG_ARCH_BOARD_COMMON +#include "rp2040_common_initialize.h" +#endif /* CONFIG_ARCH_BOARD_COMMON */ + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -52,14 +57,11 @@ void rp2040_boardearlyinitialize(void) { - rp2040_gpio_initialize(); + #ifdef CONFIG_ARCH_BOARD_COMMON + rp2040_common_earlyinitialize(); + #endif - /* Disable IE on GPIO 26-29 */ - - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(26)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(27)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(28)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(29)); + /* --- Place any board specific early initialization here --- */ /* Set all board RGB LED pins to HIGH: * LEDs turned off (driven from external pull-up) @@ -76,38 +78,6 @@ void rp2040_boardearlyinitialize(void) rp2040_gpio_init(BOARD_GPIO_LED_PIN_B); rp2040_gpio_setdir(BOARD_GPIO_LED_PIN_B, true); rp2040_gpio_put(BOARD_GPIO_LED_PIN_B, true); - - /* Set default UART pin */ - -#ifdef CONFIG_RP2040_UART0 - rp2040_gpio_set_function(CONFIG_RP2040_UART0_TX_GPIO, - RP2040_GPIO_FUNC_UART); /* TX */ - rp2040_gpio_set_function(CONFIG_RP2040_UART0_RX_GPIO, - RP2040_GPIO_FUNC_UART); /* RX */ -#ifdef CONFIG_SERIAL_OFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART0_CTS_GPIO, - RP2040_GPIO_FUNC_UART); /* CTS */ -#endif -#ifdef CONFIG_SERIAL_IFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART0_RTS_GPIO, - RP2040_GPIO_FUNC_UART); /* RTS */ -#endif -#endif - -#ifdef CONFIG_RP2040_UART1 - rp2040_gpio_set_function(CONFIG_RP2040_UART1_TX_GPIO, - RP2040_GPIO_FUNC_UART); /* TX */ - rp2040_gpio_set_function(CONFIG_RP2040_UART1_RX_GPIO, - RP2040_GPIO_FUNC_UART); /* RX */ -#ifdef CONFIG_SERIAL_OFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART1_CTS_GPIO, - RP2040_GPIO_FUNC_UART); /* CTS */ -#endif -#ifdef CONFIG_SERIAL_IFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART1_RTS_GPIO, - RP2040_GPIO_FUNC_UART); /* RTS */ -#endif -#endif } /**************************************************************************** @@ -119,57 +89,9 @@ void rp2040_boardearlyinitialize(void) void rp2040_boardinitialize(void) { - /* Set default I2C pin */ + #ifdef CONFIG_ARCH_BOARD_COMMON + rp2040_common_initialize(); + #endif -#ifdef CONFIG_RP2040_I2C0 - rp2040_gpio_set_function(CONFIG_RP2040_I2C0_SDA_GPIO, - RP2040_GPIO_FUNC_I2C); /* SDA */ - rp2040_gpio_set_function(CONFIG_RP2040_I2C0_SCL_GPIO, - RP2040_GPIO_FUNC_I2C); /* SCL */ - - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_SDA_GPIO, true, false); /* Pull up */ - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_SCL_GPIO, true, false); -#endif - -#ifdef CONFIG_RP2040_I2C1 - rp2040_gpio_set_function(CONFIG_RP2040_I2C1_SDA_GPIO, - RP2040_GPIO_FUNC_I2C); /* SDA */ - rp2040_gpio_set_function(CONFIG_RP2040_I2C1_SCL_GPIO, - RP2040_GPIO_FUNC_I2C); /* SCL */ - - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_SDA_GPIO, true, false); /* Pull up */ - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_SCL_GPIO, true, false); -#endif - - /* Set default SPI pin */ - -#ifdef CONFIG_RP2040_SPI0 - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_RX_GPIO, - RP2040_GPIO_FUNC_SPI); /* RX */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_SCK_GPIO, - RP2040_GPIO_FUNC_SPI); /* SCK */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_TX_GPIO, - RP2040_GPIO_FUNC_SPI); /* TX */ - - /* CSn is controlled by board-specific logic */ - - rp2040_gpio_init(CONFIG_RP2040_SPI0_CS_GPIO); /* CSn */ - rp2040_gpio_setdir(CONFIG_RP2040_SPI0_CS_GPIO, true); - rp2040_gpio_put(CONFIG_RP2040_SPI0_CS_GPIO, true); -#endif - -#ifdef CONFIG_RP2040_SPI1 - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_RX_GPIO, - RP2040_GPIO_FUNC_SPI); /* RX */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_SCK_GPIO, - RP2040_GPIO_FUNC_SPI); /* SCK */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_TX_GPIO, - RP2040_GPIO_FUNC_SPI); /* TX */ - - /* CSn is controlled by board-specific logic */ - - rp2040_gpio_init(CONFIG_RP2040_SPI1_CS_GPIO); /* CSn */ - rp2040_gpio_setdir(CONFIG_RP2040_SPI1_CS_GPIO, true); - rp2040_gpio_put(CONFIG_RP2040_SPI1_CS_GPIO, true); -#endif + /* --- Place any board specific initialization here --- */ } diff --git a/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_bringup.c b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_bringup.c index a43aa219374..30173915c29 100644 --- a/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_bringup.c +++ b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_bringup.c @@ -31,26 +31,11 @@ #include -#include "rp2040_tiny2040.h" +#include "rp2040_pico.h" -#ifdef CONFIG_RP2040_PWM -#include "rp2040_pwm.h" -#include "rp2040_pwmdev.h" -#endif - -#if defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) -#include "rp2040_adc.h" -#endif - -#if defined(CONFIG_RP2040_BOARD_HAS_WS2812) && defined(CONFIG_WS2812) -#include "rp2040_ws2812.h" -#endif - -#ifdef CONFIG_WS2812_HAS_WHITE -#define HAS_WHITE true -#else /* CONFIG_WS2812_HAS_WHITE */ -#define HAS_WHITE false -#endif /* CONFIG_WS2812_HAS_WHITE */ +#ifdef CONFIG_ARCH_BOARD_COMMON +#include "rp2040_common_bringup.h" +#endif /* CONFIG_ARCH_BOARD_COMMON */ /**************************************************************************** * Public Functions @@ -62,408 +47,17 @@ int rp2040_bringup(void) { - int ret = 0; +#ifdef CONFIG_ARCH_BOARD_COMMON -#ifdef CONFIG_RP2040_I2C_DRIVER - #ifdef CONFIG_RP2040_I2C0 - ret = board_i2cdev_initialize(0); + int ret = rp2040_common_bringup(); if (ret < 0) { - _err("ERROR: Failed to initialize I2C0.\n"); - } - #endif - - #ifdef CONFIG_RP2040_I2C1 - ret = board_i2cdev_initialize(1); - if (ret < 0) - { - _err("ERROR: Failed to initialize I2C1.\n"); - } - #endif -#endif - -#ifdef CONFIG_RP2040_SPI_DRIVER - #ifdef CONFIG_RP2040_SPI0 - ret = board_spidev_initialize(0); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI0.\n"); - } - #endif - - #ifdef CONFIG_RP2040_SPI1 - ret = board_spidev_initialize(1); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI1.\n"); - } - #endif -#endif - -#ifdef CONFIG_RP2040_SPISD - /* Mount the SPI-based MMC/SD block driver */ - - ret = board_spisd_initialize(0, CONFIG_RP2040_SPISD_SPI_CH); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI device to MMC/SD: %d\n", - ret); - } -#endif - -#ifdef CONFIG_FS_PROCFS - /* Mount the procfs file system */ - - ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); - if (ret < 0) - { - serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret); - } -#endif - -#ifdef CONFIG_RP2040_I2S - ret = board_i2sdev_initialize(0); - if (ret < 0) - { - _err("ERROR: Failed to initialize I2S.\n"); - } -#endif - -#ifdef CONFIG_DEV_GPIO - ret = rp2040_dev_gpio_init(); - if (ret < 0) - { - syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret); - return ret; - } -#endif - -#ifdef CONFIG_RP2040_PWM -# ifdef CONFIG_RP2040_PWM0 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(0, - CONFIG_RP2040_PWM0A_GPIO, - CONFIG_RP2040_PWM0B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM0A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM0B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM0_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(0, - CONFIG_RP2040_PWM0A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM0A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM0_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM0.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM1 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(1, - CONFIG_RP2040_PWM1A_GPIO, - CONFIG_RP2040_PWM1B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM1A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM1B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM1_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(1, - CONFIG_RP2040_PWM1A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM1A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM1_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM1.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM2 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(2, - CONFIG_RP2040_PWM2A_GPIO, - CONFIG_RP2040_PWM2B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM2A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM2B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM2_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(2, - CONFIG_RP2040_PWM2A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM2A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM2_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM2.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM3 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(3, - CONFIG_RP2040_PWM3A_GPIO, - CONFIG_RP2040_PWM3B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM3A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM3B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM3_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(3, - CONFIG_RP2040_PWM3A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM3A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM3_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM3.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM4 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(4, - CONFIG_RP2040_PWM4A_GPIO, - CONFIG_RP2040_PWM4B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM4A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM4B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM4_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(4, - CONFIG_RP2040_PWM4A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM4A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM4_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM4.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM5 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(5, - CONFIG_RP2040_PWM5A_GPIO, - CONFIG_RP2040_PWM5B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM5A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM5B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM5_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(5, - CONFIG_RP2040_PWM5A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM5A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM5_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM5.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM6 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(6, - CONFIG_RP2040_PWM6A_GPIO, - CONFIG_RP2040_PWM6B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM6A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM6B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM6_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(6, - CONFIG_RP2040_PWM6A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM6A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM6_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM6.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM7 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(7, - CONFIG_RP2040_PWM7A_GPIO, - CONFIG_RP2040_PWM7B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM7A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM7B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM7_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(7, - CONFIG_RP2040_PWM7A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM7A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM7_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM7.\n"); - } -# endif -#endif - - /* Initialize ADC */ - -#if defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) - -# ifdef CONFIG_RPC2040_ADC_CHANNEL0 -# define ADC_0 true -# else -# define ADC_0 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL1 -# define ADC_1 true -# else -# define ADC_1 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL2 -# define ADC_2 true -# else -# define ADC_2 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL3 -# define ADC_3 true -# else -# define ADC_3 false -# endif - -# ifdef CONFIG_RPC2040_ADC_TEMPERATURE -# define ADC_TEMP true -# else -# define ADC_TEMP false -# endif - - ret = rp2040_adc_setup("/dev/adc0", ADC_0, ADC_1, ADC_2, ADC_3, ADC_TEMP); - if (ret != OK) - { - syslog(LOG_ERR, "Failed to initialize ADC Driver: %d\n", ret); return ret; } -#endif /* defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) */ +#endif /* CONFIG_ARCH_BOARD_COMMON */ - /* Initialize board neo-pixel */ + /* --- Place any board specific bringup code here --- */ -#if defined(CONFIG_RP2040_BOARD_HAS_WS2812) && defined(CONFIG_WS2812) - rp2040_ws2812_setup("/dev/leds0", - CONFIG_RP2040_WS2812_GPIO_PIN, - CONFIG_RP2040_WS2812_PWR_GPIO, - CONFIG_WS2812_LED_COUNT, - HAS_WHITE); -#endif - - return ret; + return OK; } diff --git a/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_pico.h b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_pico.h new file mode 100644 index 00000000000..43f0e41b3d8 --- /dev/null +++ b/boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_pico.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_pico.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_ADAFRUIT_FEATHER_RP2040_PICO_H +#define __BOARDS_ARM_RP2040_ADAFRUIT_FEATHER_RP2040_PICO_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +int rp2040_bringup(void); + +#ifdef CONFIG_DEV_GPIO +int rp2040_dev_gpio_init(void); +#endif + +#endif /* __BOARDS_ARM_RP2040_ADAFRUIT_FEATHER_RP2040_PICO_H */ diff --git a/boards/arm/rp2040/raspberrypi-pico-w/Kconfig b/boards/arm/rp2040/raspberrypi-pico-w/Kconfig new file mode 100644 index 00000000000..47cb9b80130 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/Kconfig @@ -0,0 +1,89 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_RASPBERRYPI_PICO_W + +config RP2040_FLASH_BOOT + bool "flash boot" + default y + ---help--- + If y, the built binary can be used for flash boot. + If not, the binary is for SRAM boot. + +config RP2040_FLASH_CHIP + string "Second stage boot loader" + default "w25q080" + ---help--- + This is the name of the Pico-SDK second stage boot loader + to use for this board. This board using a Q16 flash chip + which is compatible with the w25q080 boot loader. + Basically this option should not be changed. + +config RP2040_UF2_BINARY + bool "uf2 binary format" + default y + ---help--- + Create nuttx.uf2 binary format used on RP2040 based arch. + +config RP2040_LCD_SPI_CH + int "RP2040 LCD SPI channel number" + default 0 + range 0 1 + depends on LCD + ---help--- + Select SPI channel number to use LCD display. + +config RP2040_ENC28J60_SPI_CH + int "ENC28J60 SPI channel number" + default 1 + range 0 1 + depends on ENC28J60 + ---help--- + Select SPI channel number to use ENC28J60 ethernet. + +config RP2040_ENC28J60_INTR_GPIO + int "ENC28J60 interrupt GPIO pin assign" + default -1 + range -1 29 + depends on ENC28J60 + +config RP2040_ENC28J60_RESET_GPIO + int "ENC28J60 reset GPIO pin assign (optional)" + default -1 + range -1 29 + depends on ENC28J60 + +menuconfig RP2040_INFINEON_CYW43439 + bool "Has Infineon cyw43439 WiFi chip" + depends on IEEE80211_INFINEON_CYW43439 + default y +endif + +if RP2040_INFINEON_CYW43439 + + config CYW43439_FIRMWARE_BIN_PATH + string "Path to Infineon 43439 firmware file" + default "${PICO_SDK_PATH}/lib/cyw43-driver/firmware/43439A0-7.95.49.00.combined" + ---help--- + This should be a path to a file containing both the cyw43439 firmware and + the CLB blob. The firmware should be padded to a 256 byte boundary and + then the CLM blob should be appended. + + If this file is updated, check the CYW43439_FIRMWARE_LEN below to make sure + it reflects the un-padded length of the firmware part. + + config CYW43439_FIRMWARE_LEN + int "Infineon 43439 firmware length (bytes)" + default 224190 + ---help--- + This is the length of just the base firmware in the firmware file specified + by the "Path to Infineon 43439 firmware file" configuration option. + + This length does not include the length of any padding nor the length of + the appended clm_blob. If a clm_blob is present in the firmware file, this + length will be less than the length of the whole file. + + +endif diff --git a/boards/arm/rp2040/raspberrypi-pico-w/README.txt b/boards/arm/rp2040/raspberrypi-pico-w/README.txt new file mode 100644 index 00000000000..b0a96277ee9 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/README.txt @@ -0,0 +1,182 @@ +README +====== + +This directory contains the port of NuttX to the Raspberry Pi Pico. +See https://www.raspberrypi.org/products/raspberry-pi-pico/ for information +about Raspberry Pi Pico W + +Currently only the following devices are supported. + + Supported: + - UART (console port) + - GPIO 0 (UART0 TX) and GPIO 1 (UART0 RX) are used for the console. + - I2C + - SPI + - DMAC + - PWM + - ADC + - USB device + - MSC, CDC/ACM serial and these composite device are supported. + - CDC/ACM serial device can be used for the console. + - PIO (RP2040 Programmable I/O) + - Flash ROM Boot + - SRAM Boot + - If Pico SDK is available, nuttx.uf2 file which can be used in + BOOTSEL mode will be created. + - WiFi wireless communication + - BMP180 sensor at I2C0 (don't forget to define I2C0 GPIOs at "I2C0 GPIO pin assign" in Board Selection menu) + - INA219 sensor / module (don't forget to define I2C0 GPIOs at "I2C0 GPIO pin assign" in Board Selection menu) + - Pico Display Pack (ST7789 LCD) + - RGB leds and buttons are not supported yet. + - Pico Audio Pack (PCM5100A I2S DAC) + - I2S interface is realized by PIO. + + Not supported: + - All other devices + +Installation +============ + +1. Download Raspberry Pi Pico SDK + + $ git clone -b 1.1.2 https://github.com/raspberrypi/pico-sdk.git + +2. Set PICO_SDK_PATH environment variable + + $ export PICO_SDK_PATH= + +3. Configure and build NuttX + + $ git clone https://github.com/apache/incubator-nuttx.git nuttx + $ git clone https://github.com/apache/incubator-nuttx-apps.git apps + $ cd nuttx + $ make distclean + $ ./tools/configure.sh raspberrypi-pico:nsh + $ make V=1 + +4. Connect Raspberry Pi Pico board to USB port while pressing BOOTSEL. + The board will be detected as USB Mass Storage Device. + Then copy "nuttx.uf2" into the device. + (Same manner as the standard Pico SDK applications installation.) + +5. To access the console, GPIO 0 and 1 pins must be connected to the + device such as USB-serial converter. + + `usbnsh` configuration provides the console access by USB CDC/ACM serial + devcice. The console is available by using a terminal software on the USB + host. + +Defconfigs +========== + +- nsh + Minimum configuration with NuttShell + +- nshsram + Load NuttX binary to SRAM + +- smp + Enable SMP mode. Both Core 0 and Core 1 are used by NuttX. + +- ssd1306 + SSD1306 OLED display (I2C) test configuration + Connection: + SSD1306 Raspberry Pi Pico + GND ----- GND (Pin 3 or 38 or ...) + VCC ----- 3V3 OUT (Pin 36) + SDA ----- GP4 (I2C0 SDA) (Pin 6) + SCL ----- GP5 (I2C0 SCL) (Pin 7) + +- lcd1602 + LCD 1602 Segment LCD Disaply (I2C) + Connection: + PCF8574 BackPack Raspberry Pi Pico + GND ----- GND (Pin 3 or 38 or ...) + VCC ----- 5V Vbus (Pin 40) + SDA ----- GP4 (I2C0 SDA) (Pin 6) + SCL ----- GP5 (I2C0 SCL) (Pin 7) +- spisd + SD card support (SPI connection) + Connection: + SD card slot Raspberry Pi Pico + DAT2 (NC) + DAT3/CS ----- GP17 (SPI0 CSn) (Pin 22) + CMD /DI ----- GP19 (SPI0 TX) (Pin 25) + VDD ----- 3V3 OUT (Pin 36) + CLK/SCK ----- GP18 (SPI0 SCK) (Pin 24) + VSS ----- GND (Pin 3 or 38 or ...) + DAT0/DO ----- GP16 (SPI0 RX) (Pin 21) + DAT1 (NC) + * Card hot swapping is not supported. + +- st7735 + st7735 SPI LCD support + Connection: + st7735 Raspberry Pi Pico + GND ----- GND (Pin 3 or 38 or ...) + VCC ----- 5V Vbus (Pin 40) + SDA ----- GP15 (SPI1 TX) (Pin 20) + SCK ----- GP14 (SPI1 SCK) (Pin 19) + CS ----- GP13 (SPI1 CSn) (Pin 17) + AO(D/C) ----- GP12 (SPI1 RX) (Pin 16) + BL ----- GP11 (Pin 15) + RESET ----- GP10 (Pin 14) + +- enc28j60 + ENC28J60 SPI ethernet controller support + - IP address is configured by DHCP. + - DNS address is 8.8.8.8 (CONFIG_NETINIT_DNSIPADDR) + - NTP client is enabled. + Connection: + ENC28J60 Raspberry Pi Pico + GND ----- GND (Pin 3 or 38 or ...) + 3.3 ----- 3V3 OUT (Pin 36) + SI ----- GP15 (SPI1 TX) (Pin 20) + SCK ----- GP14 (SPI1 SCK) (Pin 19) + CS ----- GP13 (SPI1 CSn) (Pin 17) + SO ----- GP12 (SPI1 RX) (Pin 16) + INT ----- GP11 (Pin 15) + RESET ----- GP10 (Pin 14) + +- displaypack + Pico Display Pack support + See the following page for connection: + https://shop.pimoroni.com/products/pico-display-pack + +- audiopack + Pico Audio Pack support + See the following page for connection: + https://shop.pimoroni.com/products/pico-audio-pack + SD card interface is also enabled. + +- usbnsh + USB CDC/ACM serial console with NuttShell + +- usbmsc + USB MSC and CDC/ACM support + `msconn` and `sercon` commands enable the MSC and CDC/ACM devices. + The MSC support provides the interface to the SD card with SPI, + so the SD card slot connection like spisd configuration is required. + +- composite + USB composite device (MSC + CDC/ACM) support + `conn` command enables the composite device. + +License exceptions +================== + +The following files are originated from the files in Pico SDK. +So, the files are licensed under 3-Clause BSD same as Pico SDK. + +- arch/arm/src/rp2040/rp2040_clock.c +- arch/arm/src/rp2040/rp2040_pll.c +- arch/arm/src/rp2040/rp2040_xosc.c + - These are created by referring the Pico SDK clock initialization. + +- arch/arm/src/rp2040/rp2040_pio.c +- arch/arm/src/rp2040/rp2040_pio.h +- arch/arm/src/rp2040/rp2040_pio_instructions.h + - These provide the similar APIs to Pico SDK's hardware_pio APIs. + +- arch/arm/src/rp2040/hardware/*.h + - These are generated from rp2040.svd originally provided in Pico SDK. diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/audiopack/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/audiopack/defconfig new file mode 100644 index 00000000000..5c6a3712ffb --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/audiopack/defconfig @@ -0,0 +1,70 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_AUDIO_FORMAT_MP3 is not set +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_MMCSD_HAVE_CARDDETECT is not set +# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_NSH_DISABLE_MB is not set +# CONFIG_NSH_DISABLE_MH is not set +# CONFIG_NSH_DISABLE_MW is not set +# CONFIG_SPI_CALLBACK is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_AUDIO=y +CONFIG_AUDIO_I2S=y +CONFIG_AUDIO_I2SCHAR=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_DRIVERS_AUDIO=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_MMCSD=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_NXPLAYER_DEFAULT_MEDIADIR="/mnt/sd0" +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_I2S=y +CONFIG_RP2040_SPI0=y +CONFIG_RP2040_SPI=y +CONFIG_RP2040_SPISD=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NXPLAYER=y +CONFIG_SYSTEM_SPITOOL=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/composite/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/composite/defconfig new file mode 100644 index 00000000000..aed31c2b63c --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/composite/defconfig @@ -0,0 +1,73 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_MMCSD_HAVE_CARDDETECT is not set +# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_SPI_CALLBACK is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_CDCACM=y +CONFIG_CDCACM_COMPOSITE=y +CONFIG_COMPOSITE_IAD=y +CONFIG_COMPOSITE_MSFT_OS_DESCRIPTORS=y +CONFIG_COMPOSITE_PRODUCTID=0x2022 +CONFIG_COMPOSITE_SERIALSTR="12345" +CONFIG_COMPOSITE_VENDORID=0x03eb +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_USBSERIAL=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_MMCSD=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_SPI0=y +CONFIG_RP2040_SPI=y +CONFIG_RP2040_SPISD=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSTEM_COMPOSITE=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SPITOOL=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_USBDEV=y +CONFIG_USBDEV_BUSPOWERED=y +CONFIG_USBDEV_COMPOSITE=y +CONFIG_USBMSC=y +CONFIG_USBMSC_COMPOSITE=y +CONFIG_USBMSC_NOT_STALL_BULKEP=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/displaypack/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/displaypack/defconfig new file mode 100644 index 00000000000..23040836d68 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/displaypack/defconfig @@ -0,0 +1,97 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_DEV_CONSOLE is not set +# CONFIG_EXAMPLES_NXLINES_DEFAULT_COLORS is not set +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_NXFONTS_DISABLE_16BPP is not set +# CONFIG_NX_DISABLE_16BPP is not set +# CONFIG_NX_PACKEDMSFIRST is not set +# CONFIG_NX_WRITEONLY is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_CDCACM=y +CONFIG_CDCACM_CONSOLE=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_DRIVERS_VIDEO=y +CONFIG_EXAMPLES_FB=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_NX=y +CONFIG_EXAMPLES_NXDEMO=y +CONFIG_EXAMPLES_NXDEMO_BPP=16 +CONFIG_EXAMPLES_NXHELLO=y +CONFIG_EXAMPLES_NXHELLO_BPP=16 +CONFIG_EXAMPLES_NXLINES=y +CONFIG_EXAMPLES_NXLINES_BGCOLOR=0x0320 +CONFIG_EXAMPLES_NXLINES_BORDERCOLOR=0xffe0 +CONFIG_EXAMPLES_NXLINES_BORDERWIDTH=4 +CONFIG_EXAMPLES_NXLINES_BPP=16 +CONFIG_EXAMPLES_NXLINES_CIRCLECOLOR=0xf7bb +CONFIG_EXAMPLES_NXLINES_LINECOLOR=0xffe0 +CONFIG_EXAMPLES_NX_BPP=16 +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_I2C=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_LCD=y +CONFIG_LCD_DEV=y +CONFIG_LCD_FRAMEBUFFER=y +CONFIG_LCD_MAXCONTRAST=255 +CONFIG_LCD_NOGETRUN=y +CONFIG_LCD_ST7789=y +CONFIG_LCD_ST7789_FREQUENCY=64000000 +CONFIG_LCD_ST7789_XOFFSET=53 +CONFIG_LCD_ST7789_XRES=135 +CONFIG_LCD_ST7789_YOFFSET=40 +CONFIG_LCD_ST7789_YRES=240 +CONFIG_MQ_MAXMSGSIZE=64 +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_NSH_USBCONSOLE=y +CONFIG_NX=y +CONFIG_NXFONTS_PACKEDMSFIRST=y +CONFIG_NXFONT_SANS40X49B=y +CONFIG_NX_BLOCKING=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_SPI0=y +CONFIG_RP2040_SPI=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SPI_CMDDATA=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSTEM_I2CTOOL=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SPITOOL=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_USBDEV=y +CONFIG_USBDEV_BUSPOWERED=y +CONFIG_VIDEO_FB=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/enc28j60/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/enc28j60/defconfig new file mode 100644 index 00000000000..733ffaeed0f --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/enc28j60/defconfig @@ -0,0 +1,81 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEV_ZERO=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_ENC28J60=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDB_DNSSERVER_NOADDR=y +CONFIG_NETDEVICES=y +CONFIG_NETDEV_PHY_IOCTL=y +CONFIG_NETINIT_DHCPC=y +CONFIG_NETINIT_DNS=y +CONFIG_NETINIT_DNSIPADDR=0x08080808 +CONFIG_NETINIT_NOMAC=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_ICMP=y +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_LOOPBACK=y +CONFIG_NET_ROUTE=y +CONFIG_NET_TCP=y +CONFIG_NET_UDP=y +CONFIG_NET_UDP_CHECKSUMS=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_ENC28J60_INTR_GPIO=11 +CONFIG_RP2040_ENC28J60_RESET_GPIO=10 +CONFIG_RP2040_SPI0=y +CONFIG_RP2040_SPI1=y +CONFIG_RP2040_SPI=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_DHCPC_RENEW=y +CONFIG_SYSTEM_NETDB=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NTPC=y +CONFIG_SYSTEM_PING=y +CONFIG_SYSTEM_SPITOOL=y +CONFIG_SYSTEM_SYSTEM=y +CONFIG_SYSTEM_TELNET_CLIENT=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_WQUEUE_NOTIFIER=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/lcd1602/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/lcd1602/defconfig new file mode 100644 index 00000000000..45590c8d278 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/lcd1602/defconfig @@ -0,0 +1,55 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_SLCD=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_LCD_BACKPACK=y +CONFIG_LCD_LCD1602=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_I2C0=y +CONFIG_RP2040_I2C=y +CONFIG_RP2040_I2C_DRIVER=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SLCD=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/nsh/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/nsh/defconfig new file mode 100644 index 00000000000..d034b5a9237 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/nsh/defconfig @@ -0,0 +1,48 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/nshsram/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/nshsram/defconfig new file mode 100644 index 00000000000..5829c9c774c --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/nshsram/defconfig @@ -0,0 +1,48 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_RP2040_FLASH_BOOT is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/smp/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/smp/defconfig new file mode 100644 index 00000000000..a77882e92c5 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/smp/defconfig @@ -0,0 +1,54 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SMP=y +CONFIG_SMP_NCPUS=2 +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SYSTEM=y +CONFIG_SYSTEM_TASKSET=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_TESTING_SMP=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/spisd/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/spisd/defconfig new file mode 100644 index 00000000000..30c226754ed --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/spisd/defconfig @@ -0,0 +1,59 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_MMCSD_HAVE_CARDDETECT is not set +# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_SPI_CALLBACK is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_MMCSD=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_SPI0=y +CONFIG_RP2040_SPI=y +CONFIG_RP2040_SPISD=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SPITOOL=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/ssd1306/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/ssd1306/defconfig new file mode 100644 index 00000000000..33ae9703654 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/ssd1306/defconfig @@ -0,0 +1,74 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_EXAMPLES_NXLINES_DEFAULT_COLORS is not set +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_NX_DISABLE_1BPP is not set +# CONFIG_NX_PACKEDMSFIRST is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_NX=y +CONFIG_EXAMPLES_NXDEMO=y +CONFIG_EXAMPLES_NXHELLO=y +CONFIG_EXAMPLES_NXHELLO_BPP=1 +CONFIG_EXAMPLES_NXLINES=y +CONFIG_EXAMPLES_NXLINES_BORDERWIDTH=1 +CONFIG_EXAMPLES_NXLINES_BPP=1 +CONFIG_EXAMPLES_NXLINES_LINECOLOR=0xff +CONFIG_EXAMPLES_NXLINES_LINEWIDTH=1 +CONFIG_EXAMPLES_NX_BPP=1 +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_LCD=y +CONFIG_LCD_DEV=y +CONFIG_LCD_FRAMEBUFFER=y +CONFIG_LCD_MAXCONTRAST=255 +CONFIG_LCD_SH1106_OLED_132=y +CONFIG_LCD_SSD1306_I2C=y +CONFIG_MQ_MAXMSGSIZE=64 +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_NX=y +CONFIG_NXFONTS_PACKEDMSFIRST=y +CONFIG_NXFONT_SANS20X26=y +CONFIG_NX_BLOCKING=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_I2C0=y +CONFIG_RP2040_I2C=y +CONFIG_RP2040_I2C_DRIVER=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_I2CTOOL=y +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/st7735/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/st7735/defconfig new file mode 100644 index 00000000000..1bd1f5820f1 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/st7735/defconfig @@ -0,0 +1,58 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_DRIVERS_VIDEO=y +CONFIG_EXAMPLES_FB=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_LCD=y +CONFIG_LCD_FRAMEBUFFER=y +CONFIG_LCD_PORTRAIT=y +CONFIG_LCD_ST7735=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_SPI1=y +CONFIG_RP2040_SPI=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SPI_CMDDATA=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_VIDEO_FB=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/usbmsc/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/usbmsc/defconfig new file mode 100644 index 00000000000..b8e65f6d2c8 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/usbmsc/defconfig @@ -0,0 +1,66 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_MMCSD_HAVE_CARDDETECT is not set +# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_SPI_CALLBACK is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_CDCACM=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_USBSERIAL=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_MMCSD=y +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_SPI0=y +CONFIG_RP2040_SPI=y +CONFIG_RP2040_SPISD=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSTEM_CDCACM=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SPITOOL=y +CONFIG_SYSTEM_USBMSC=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_USBDEV=y +CONFIG_USBDEV_BUSPOWERED=y +CONFIG_USBMSC=y +CONFIG_USBMSC_NOT_STALL_BULKEP=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/usbnsh/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/usbnsh/defconfig new file mode 100644 index 00000000000..37f64e3e635 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/usbnsh/defconfig @@ -0,0 +1,52 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_DEV_CONSOLE is not set +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_RP2040_UART0 is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_CDCACM=y +CONFIG_CDCACM_CONSOLE=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_NSH_USBCONSOLE=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSTEM_NSH=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_USBDEV=y +CONFIG_USBDEV_BUSPOWERED=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/waveshare-lcd-1.14/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/waveshare-lcd-1.14/defconfig new file mode 100644 index 00000000000..38e81878f36 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/waveshare-lcd-1.14/defconfig @@ -0,0 +1,94 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_EXAMPLES_NXLINES_DEFAULT_COLORS is not set +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_NXFONTS_DISABLE_16BPP is not set +# CONFIG_NX_DISABLE_16BPP is not set +# CONFIG_NX_PACKEDMSFIRST is not set +# CONFIG_NX_WRITEONLY is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_DRIVERS_VIDEO=y +CONFIG_EXAMPLES_FB=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_NX=y +CONFIG_EXAMPLES_NXDEMO=y +CONFIG_EXAMPLES_NXDEMO_BPP=16 +CONFIG_EXAMPLES_NXHELLO=y +CONFIG_EXAMPLES_NXHELLO_BPP=16 +CONFIG_EXAMPLES_NXLINES=y +CONFIG_EXAMPLES_NXLINES_BGCOLOR=0x0320 +CONFIG_EXAMPLES_NXLINES_BORDERCOLOR=0xffe0 +CONFIG_EXAMPLES_NXLINES_BORDERWIDTH=4 +CONFIG_EXAMPLES_NXLINES_BPP=16 +CONFIG_EXAMPLES_NXLINES_CIRCLECOLOR=0xf7bb +CONFIG_EXAMPLES_NXLINES_LINECOLOR=0xffe0 +CONFIG_EXAMPLES_NX_BPP=16 +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_I2C=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_LCD=y +CONFIG_LCD_DEV=y +CONFIG_LCD_FRAMEBUFFER=y +CONFIG_LCD_MAXCONTRAST=255 +CONFIG_LCD_NOGETRUN=y +CONFIG_LCD_ST7789=y +CONFIG_LCD_ST7789_FREQUENCY=64000000 +CONFIG_LCD_ST7789_XOFFSET=53 +CONFIG_LCD_ST7789_XRES=135 +CONFIG_LCD_ST7789_YOFFSET=40 +CONFIG_LCD_ST7789_YRES=240 +CONFIG_MQ_MAXMSGSIZE=64 +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_NX=y +CONFIG_NXFONTS_PACKEDMSFIRST=y +CONFIG_NXFONT_SANS40X49B=y +CONFIG_NX_BLOCKING=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_LCD_SPI_CH=1 +CONFIG_RP2040_SPI1=y +CONFIG_RP2040_SPI=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SPI_CMDDATA=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_I2CTOOL=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SPITOOL=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_VIDEO_FB=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/configs/waveshare-lcd-1.3/defconfig b/boards/arm/rp2040/raspberrypi-pico-w/configs/waveshare-lcd-1.3/defconfig new file mode 100644 index 00000000000..664b062c3a6 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/configs/waveshare-lcd-1.3/defconfig @@ -0,0 +1,91 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_EXAMPLES_NXLINES_DEFAULT_COLORS is not set +# CONFIG_FS_PROCFS_EXCLUDE_ENVIRON is not set +# CONFIG_LIBC_LONG_LONG is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_DISABLE_DATE is not set +# CONFIG_NSH_DISABLE_LOSMART is not set +# CONFIG_NXFONTS_DISABLE_16BPP is not set +# CONFIG_NX_DISABLE_16BPP is not set +# CONFIG_NX_PACKEDMSFIRST is not set +# CONFIG_NX_WRITEONLY is not set +# CONFIG_STANDARD_SERIAL is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y +CONFIG_ARCH_CHIP="rp2040" +CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_RAMVECTORS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=10450 +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DISABLE_POSIX_TIMERS=y +CONFIG_DRIVERS_VIDEO=y +CONFIG_EXAMPLES_FB=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_NX=y +CONFIG_EXAMPLES_NXDEMO=y +CONFIG_EXAMPLES_NXDEMO_BPP=16 +CONFIG_EXAMPLES_NXHELLO=y +CONFIG_EXAMPLES_NXHELLO_BPP=16 +CONFIG_EXAMPLES_NXLINES=y +CONFIG_EXAMPLES_NXLINES_BGCOLOR=0x0320 +CONFIG_EXAMPLES_NXLINES_BORDERCOLOR=0xffe0 +CONFIG_EXAMPLES_NXLINES_BORDERWIDTH=4 +CONFIG_EXAMPLES_NXLINES_BPP=16 +CONFIG_EXAMPLES_NXLINES_CIRCLECOLOR=0xf7bb +CONFIG_EXAMPLES_NXLINES_LINECOLOR=0xffe0 +CONFIG_EXAMPLES_NX_BPP=16 +CONFIG_FS_PROCFS=y +CONFIG_FS_PROCFS_REGISTER=y +CONFIG_I2C=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_LCD=y +CONFIG_LCD_DEV=y +CONFIG_LCD_FRAMEBUFFER=y +CONFIG_LCD_MAXCONTRAST=255 +CONFIG_LCD_NOGETRUN=y +CONFIG_LCD_ST7789=y +CONFIG_LCD_ST7789_FREQUENCY=64000000 +CONFIG_LCD_ST7789_YRES=240 +CONFIG_MQ_MAXMSGSIZE=64 +CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_NX=y +CONFIG_NXFONTS_PACKEDMSFIRST=y +CONFIG_NXFONT_SANS40X49B=y +CONFIG_NX_BLOCKING=y +CONFIG_RAM_SIZE=270336 +CONFIG_RAM_START=0x20000000 +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RP2040_LCD_SPI_CH=1 +CONFIG_RP2040_SPI1=y +CONFIG_RP2040_SPI=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SPI_CMDDATA=y +CONFIG_START_DAY=9 +CONFIG_START_MONTH=2 +CONFIG_START_YEAR=2021 +CONFIG_SYSLOG_CONSOLE=y +CONFIG_SYSTEM_I2CTOOL=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SPITOOL=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_VIDEO_FB=y diff --git a/boards/arm/rp2040/raspberrypi-pico-w/include/board.h b/boards/arm/rp2040/raspberrypi-pico-w/include/board.h new file mode 100644 index 00000000000..83c516eb740 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/include/board.h @@ -0,0 +1,116 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico-w/include/board.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_BOARD_H +#define __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_BOARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include "rp2040_i2cdev.h" +#include "rp2040_spidev.h" +#include "rp2040_i2sdev.h" + +#include "rp2040_spisd.h" + +#ifndef __ASSEMBLY__ +# include +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +#define MHZ 1000000 + +#define BOARD_XOSC_FREQ (12 * MHZ) +#define BOARD_PLL_SYS_FREQ (125 * MHZ) +#define BOARD_PLL_USB_FREQ (48 * MHZ) + +#define BOARD_REF_FREQ (12 * MHZ) +#define BOARD_SYS_FREQ (125 * MHZ) +#define BOARD_PERI_FREQ (125 * MHZ) +#define BOARD_USB_FREQ (48 * MHZ) +#define BOARD_ADC_FREQ (48 * MHZ) +#define BOARD_RTC_FREQ 46875 + +#define BOARD_UART_BASEFREQ BOARD_PERI_FREQ + +#define BOARD_TICK_CLOCK (1 * MHZ) + +/* GPIO definitions *********************************************************/ + +#undef BOARD_GPIO_LED_PIN +#define BOARD_NGPIOOUT 1 +#define BOARD_NGPIOIN 1 +#define BOARD_NGPIOINT 1 + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_boardearlyinitialize + * + * Description: + * + ****************************************************************************/ + +void rp2040_boardearlyinitialize(void); + +/**************************************************************************** + * Name: rp2040_boardinitialize + * + * Description: + * + ****************************************************************************/ + +void rp2040_boardinitialize(void); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_BOARD_H */ diff --git a/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_extra_gpio.h b/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_extra_gpio.h new file mode 100644 index 00000000000..e097105001b --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_extra_gpio.h @@ -0,0 +1,132 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_extra_gpio.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_EXTRA_GPIO_H +#define __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_EXTRA_GPIO_H + +/**************************************************************************** + * These functions control the gpio pins on the CYW43439 not the RP2040. + * The pin assignments for the Raspberry Pi Pico W are: + * + * GPIO 0 - output - controls the onboard LED + * GPIO 1 - output - controls the onboard voltage regulator mode. + * GPIO 2 - input - Reads as non-zero if power supplied by USB or VBUS pin. + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include + +#include +#include + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +extern gspi_dev_t *g_cyw43439; + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define RP2040_EXTRA_GPIO_NUM 3 /* Number of extra GPIO pins */ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_extra_gpio_put + * + * Description: + * Change the state of the GPIO pins on the CYW43439 + ****************************************************************************/ + +static inline void rp2040_extra_gpio_put(uint32_t gpio, int val) +{ + DEBUGASSERT(gpio < RP2040_EXTRA_GPIO_NUM); + + bcmf_set_gpio(g_cyw43439->priv, gpio, val); +} + +/**************************************************************************** + * Name: rp2040_extra_gpio_get + * + * Description: + * Get the state of the GPIO pins on the CYW43439 + ****************************************************************************/ + +static inline bool rp2040_extra_gpio_get(uint32_t gpio) +{ + bool value; + + DEBUGASSERT(gpio < RP2040_EXTRA_GPIO_NUM); + + bcmf_get_gpio(g_cyw43439->priv, gpio, &value); + + return value; +} + +/**************************************************************************** + * Name: rp2040_extra_gpio_setdir + * + * Description: + * Change the direction of the GPIO pins on the CYW43439 + * + * Note -- I added this function as a placeholder in case other boards + * implement extra GPIO pins where controlling the direction + * makes sense. + ****************************************************************************/ + +static inline void rp2040_extra_gpio_setdir(uint32_t gpio, int out) +{ + DEBUGASSERT(gpio < RP2040_EXTRA_GPIO_NUM); + + DEBUGPANIC(); /* Function not yet implemented. */ +} + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif \ No newline at end of file diff --git a/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_i2cdev.h b/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_i2cdev.h new file mode 100644 index 00000000000..f626e8195bf --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_i2cdev.h @@ -0,0 +1,72 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_i2cdev.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_I2CDEV_H +#define __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_I2CDEV_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: board_i2cdev_initialize + * + * Description: + * Initialize i2c driver and register the /dev/i2c device. + * + ****************************************************************************/ + +#ifdef CONFIG_RP2040_I2C_DRIVER +int board_i2cdev_initialize(int bus); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_I2CDEV_H */ diff --git a/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_i2sdev.h b/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_i2sdev.h new file mode 100644 index 00000000000..ec26956d06e --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_i2sdev.h @@ -0,0 +1,72 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_i2sdev.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_I2SDEV_H +#define __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_I2SDEV_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: board_i2sdev_initialize + * + * Description: + * Initialize i2s driver and register the /dev/audio/pcm0 device. + * + ****************************************************************************/ + +#ifdef CONFIG_RP2040_I2S +int board_i2sdev_initialize(int bus); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_I2SDEV_H */ diff --git a/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_spidev.h b/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_spidev.h new file mode 100644 index 00000000000..27161905ba0 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_spidev.h @@ -0,0 +1,69 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_spidev.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_SPIDEV_H +#define __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_SPIDEV_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: board_spidev_initialize + * + * Description: + * Initialize spi driver and register the /dev/spi device. + * + ****************************************************************************/ + +int board_spidev_initialize(int bus); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_SPIDEV_H */ diff --git a/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_spisd.h b/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_spisd.h new file mode 100644 index 00000000000..e5fcc42d4db --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_spisd.h @@ -0,0 +1,83 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico-w/include/rp2040_spisd.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_SPISD_H +#define __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_SPISD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: board_spisd_initialize + * + * Description: + * Initialize the SPI-based SD card. + * + ****************************************************************************/ + +#ifdef CONFIG_RP2040_SPISD +int board_spisd_initialize(int minor, int bus); +#endif + +/**************************************************************************** + * Name: board_spisd_status + * + * Description: + * Get the status whether SD Card is present or not. + * + ****************************************************************************/ + +#ifdef CONFIG_RP2040_SPISD +uint8_t board_spisd_status(struct spi_dev_s *dev, uint32_t devid); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_W_INCLUDE_RP2040_SPISD_H */ diff --git a/boards/arm/rp2040/raspberrypi-pico-w/scripts/Make.defs b/boards/arm/rp2040/raspberrypi-pico-w/scripts/Make.defs new file mode 100644 index 00000000000..1fa4a91047f --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/scripts/Make.defs @@ -0,0 +1,45 @@ +############################################################################ +# boards/arm/rp2040/raspberrypi-pico-w/scripts/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/tools/rp2040/Config.mk +include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs + +ifeq ($(CONFIG_RP2040_FLASH_BOOT),y) + LDSCRIPT = raspberrypi-pico-flash.ld +else + LDSCRIPT = raspberrypi-pico-sram.ld +endif + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 diff --git a/boards/arm/rp2040/raspberrypi-pico-w/scripts/raspberrypi-pico-flash.ld b/boards/arm/rp2040/raspberrypi-pico-w/scripts/raspberrypi-pico-flash.ld new file mode 100644 index 00000000000..f370cca326c --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/scripts/raspberrypi-pico-flash.ld @@ -0,0 +1,112 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico/scripts/raspberrypi-pico-flash.ld + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +MEMORY +{ + flash (rx) : ORIGIN = 0x10000000, LENGTH = 2048K + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 264K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +ENTRY(_stext) + +SECTIONS +{ + .flash_begin : { + __flash_binary_start = .; + } > flash + + .boot2 : { + __boot2_start__ = .; + KEEP (*(.boot2)) + __boot2_end__ = .; + } > flash + + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + .init_section : { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > flash + + .ARM.extab : { + *(.ARM.extab*) + } > flash + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > flash + __exidx_end = ABSOLUTE(.); + + _eronly = ABSOLUTE(.); + + .ram_vectors (COPY) : { + *(.ram_vectors) + } > sram + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram AT > flash + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/rp2040/raspberrypi-pico-w/scripts/raspberrypi-pico-sram.ld b/boards/arm/rp2040/raspberrypi-pico-w/scripts/raspberrypi-pico-sram.ld new file mode 100644 index 00000000000..d9278950cfa --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/scripts/raspberrypi-pico-sram.ld @@ -0,0 +1,97 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico/scripts/raspberrypi-pico-sram.ld + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +MEMORY +{ + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 264K +} + +OUTPUT_ARCH(arm) +EXTERN(_vectors) +ENTRY(_stext) + +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + rp2040_start.o(.text) + . = ALIGN(256); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > sram + + .init_section : { + _sinit = ABSOLUTE(.); + *(.init_array .init_array.*) + _einit = ABSOLUTE(.); + } > sram + + .ARM.extab : { + *(.ARM.extab*) + } > sram + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } > sram + __exidx_end = ABSOLUTE(.); + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + . = ALIGN(4); + _edata = ABSOLUTE(.); + } > sram + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/boards/arm/rp2040/raspberrypi-pico-w/src/Make.defs b/boards/arm/rp2040/raspberrypi-pico-w/src/Make.defs new file mode 100644 index 00000000000..ddddef17c25 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/src/Make.defs @@ -0,0 +1,65 @@ +############################################################################ +# boards/arm/rp2040/raspberrypi-pico/src/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(TOPDIR)/Make.defs + +CSRCS = rp2040_boardinitialize.c +CSRCS += rp2040_appinit.c +CSRCS += rp2040_bringup.c + +ifeq ($(CONFIG_BOARDCTL_RESET),y) +CSRCS += rp2040_reset.c +endif + +ifeq ($(CONFIG_SPI),y) +CSRCS += rp2040_spi.c +endif + +ifeq ($(CONFIG_DEV_GPIO),y) +CSRCS += rp2040_gpio.c +endif + +CSRCS += rp2040_firmware.c + +DEPPATH += --dep-path board +VPATH += :board +CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board) + +############################################################################ +# The rules below copy the cyw43439 blob from pico_sdk +############################################################################ + +ifeq ($(CONFIG_IEEE80211_INFINEON_CYW43439),y) + +FIRMWARE = src$(DELIM)cyw43439.firmware.image + +FIRMWARE_SRC := $(patsubst "%",%,$(CONFIG_CYW43439_FIRMWARE_BIN_PATH)) + +src$(DELIM)cyw43439.firmware.image: $(FIRMWARE_SRC) + $(call CATFILE, src$(DELIM)cyw43439.firmware.image, $(FIRMWARE_SRC)) + +src$(DELIM)rp2040_firmware.c: $(FIRMWARE) + +#depend: $(FIRMWARE) + +distclean:: + $(call DELFILE, src$(DELIM)cyw43439.firmware.image) + +endif diff --git a/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_appinit.c b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_appinit.c new file mode 100644 index 00000000000..7588accca03 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_appinit.c @@ -0,0 +1,78 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_appinit.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include "rp2040_pico.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef OK +# define OK 0 +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ +#ifdef CONFIG_BOARD_LATE_INITIALIZE + /* Board initialization already performed by board_late_initialize() */ + + return OK; +#else + /* Perform board-specific initialization */ + + return rp2040_bringup(); +#endif +} diff --git a/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_boardinitialize.c b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_boardinitialize.c new file mode 100644 index 00000000000..b9b582589dc --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_boardinitialize.c @@ -0,0 +1,81 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_boardinitialize.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include + +#include "arm_internal.h" +#include "rp2040_gpio.h" + +#ifdef CONFIG_ARCH_BOARD_COMMON +#include "rp2040_common_initialize.h" +#endif /* CONFIG_ARCH_BOARD_COMMON */ + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_boardearlyinitialize + * + * Description: + * + ****************************************************************************/ + +void rp2040_boardearlyinitialize(void) +{ + #ifdef CONFIG_ARCH_BOARD_COMMON + rp2040_common_earlyinitialize(); + #endif + + /* --- Place any board specific early initialization here --- */ +} + +/**************************************************************************** + * Name: rp2040_boardinitialize + * + * Description: + * + ****************************************************************************/ + +void rp2040_boardinitialize(void) +{ + #ifdef CONFIG_ARCH_BOARD_COMMON + rp2040_common_initialize(); + #endif + + /* --- Place any board specific initialization here --- */ +} diff --git a/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_bringup.c b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_bringup.c new file mode 100644 index 00000000000..e99e43c196b --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_bringup.c @@ -0,0 +1,102 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_bringup.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include + +#include "rp2040_pico.h" + +#ifdef CONFIG_ARCH_BOARD_COMMON +#include "rp2040_common_bringup.h" +#endif /* CONFIG_ARCH_BOARD_COMMON */ + +#ifdef CONFIG_RP2040_INFINEON_CYW43439 +#include "rp2040_cyw43439.h" +#endif + +/**************************************************************************** + * Global Data + ****************************************************************************/ + +#ifdef CONFIG_RP2040_INFINEON_CYW43439 +gspi_dev_t *g_cyw43439 = NULL; +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_bringup + ****************************************************************************/ + +int rp2040_bringup(void) +{ +#ifdef CONFIG_ARCH_BOARD_COMMON + + int ret = rp2040_common_bringup(); + if (ret < 0) + { + return ret; + } + +#endif /* CONFIG_ARCH_BOARD_COMMON */ + + /* --- Place any board specific bringup code here --- */ + +#define CYW43439_POWER_ON_GPIO 23 +#define CYW43439_CHIP_SELECT_GPIO 25 +#define CYW43439_DATA_GPIO 24 +#define CYW43439_CLOCK_GPIO 29 + +#ifdef CONFIG_RP2040_INFINEON_CYW43439 + + g_cyw43439 = rp2040_cyw_setup(CYW43439_POWER_ON_GPIO, + CYW43439_CHIP_SELECT_GPIO, + CYW43439_DATA_GPIO, + CYW43439_CLOCK_GPIO, + CYW43439_DATA_GPIO); + + if (g_cyw43439 == NULL) + { + ret = errno; + + syslog(LOG_ERR, + "Failed to initialize cyw43439 (WiFi chip): %d\n", + ret); + + return ret; + } + +#endif + + return OK; +} diff --git a/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_gpio.c b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_gpio.c new file mode 100644 index 00000000000..816136c2521 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_gpio.c @@ -0,0 +1,392 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_gpio.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "arm_internal.h" +#include "chip.h" +#include "rp2040_gpio.h" + +#if defined(CONFIG_DEV_GPIO) && !defined(CONFIG_GPIO_LOWER_HALF) + +/* Output pins. GPIO25 is onboard LED any other outputs could be used. + */ + +#define GPIO_OUT1 25 + +/* Input pins. + */ + +#define GPIO_IN1 6 + +/* Interrupt pins. + */ + +#define GPIO_IRQPIN1 14 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct rp2040gpio_dev_s +{ + struct gpio_dev_s gpio; + uint8_t id; +}; + +struct rp2040gpint_dev_s +{ + struct rp2040gpio_dev_s rp2040gpio; + pin_interrupt_t callback; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +#if BOARD_NGPIOOUT > 0 +static int gpout_read(struct gpio_dev_s *dev, bool *value); +static int gpout_write(struct gpio_dev_s *dev, bool value); +#endif + +#if BOARD_NGPIOIN > 0 +static int gpin_read(struct gpio_dev_s *dev, bool *value); +#endif + +#if BOARD_NGPIOINT > 0 +static int gpint_read(struct gpio_dev_s *dev, bool *value); +static int gpint_attach(struct gpio_dev_s *dev, + pin_interrupt_t callback); +static int gpint_enable(struct gpio_dev_s *dev, bool enable); +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if BOARD_NGPIOOUT > 0 +static const struct gpio_operations_s gpout_ops = +{ + .go_read = gpout_read, + .go_write = gpout_write, + .go_attach = NULL, + .go_enable = NULL, +}; + +/* This array maps the GPIO pins used as OUTPUT */ + +static const uint32_t g_gpiooutputs[BOARD_NGPIOOUT] = +{ + GPIO_OUT1 +}; + +static struct rp2040gpio_dev_s g_gpout[BOARD_NGPIOOUT]; +#endif + +#if BOARD_NGPIOIN > 0 +static const struct gpio_operations_s gpin_ops = +{ + .go_read = gpin_read, + .go_write = NULL, + .go_attach = NULL, + .go_enable = NULL, +}; + +/* This array maps the GPIO pins used as INTERRUPT INPUTS */ + +static const uint32_t g_gpioinputs[BOARD_NGPIOIN] = +{ + GPIO_IN1 +}; + +static struct rp2040gpio_dev_s g_gpin[BOARD_NGPIOIN]; +#endif + +#if BOARD_NGPIOINT > 0 +static const struct gpio_operations_s gpint_ops = +{ + .go_read = gpint_read, + .go_write = NULL, + .go_attach = gpint_attach, + .go_enable = gpint_enable, +}; + +/* This array maps the GPIO pins used as INTERRUPT INPUTS */ + +static const uint32_t g_gpiointinputs[BOARD_NGPIOINT] = +{ + GPIO_IRQPIN1, +}; + +static struct rp2040gpint_dev_s g_gpint[BOARD_NGPIOINT]; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: gpout_read + ****************************************************************************/ + +#if BOARD_NGPIOOUT > 0 +static int gpout_read(struct gpio_dev_s *dev, bool *value) +{ + struct rp2040gpio_dev_s *rp2040gpio = + (struct rp2040gpio_dev_s *)dev; + + DEBUGASSERT(rp2040gpio != NULL && value != NULL); + DEBUGASSERT(rp2040gpio->id < BOARD_NGPIOOUT); + gpioinfo("Reading...\n"); + + *value = rp2040_gpio_get(g_gpiooutputs[rp2040gpio->id]); + return OK; +} + +/**************************************************************************** + * Name: gpout_write + ****************************************************************************/ + +static int gpout_write(struct gpio_dev_s *dev, bool value) +{ + struct rp2040gpio_dev_s *rp2040gpio = + (struct rp2040gpio_dev_s *)dev; + + DEBUGASSERT(rp2040gpio != NULL); + DEBUGASSERT(rp2040gpio->id < BOARD_NGPIOOUT); + gpioinfo("Writing %d\n", (int)value); + + rp2040_gpio_put(g_gpiooutputs[rp2040gpio->id], value); + return OK; +} +#endif + +/**************************************************************************** + * Name: gpin_read + ****************************************************************************/ + +#if BOARD_NGPIOIN > 0 +static int gpin_read(struct gpio_dev_s *dev, bool *value) +{ + struct rp2040gpio_dev_s *rp2040gpio = + (struct rp2040gpio_dev_s *)dev; + + DEBUGASSERT(rp2040gpio != NULL && value != NULL); + DEBUGASSERT(rp2040gpio->id < BOARD_NGPIOIN); + gpioinfo("Reading... pin %d\n", (int)g_gpioinputs[rp2040gpio->id]); + + *value = rp2040_gpio_get(g_gpioinputs[rp2040gpio->id]); + return OK; +} +#endif + +/**************************************************************************** + * Name: rp2040gpio_interrupt + ****************************************************************************/ + +#if BOARD_NGPIOINT > 0 +static int rp2040gpio_interrupt(int irq, void *context, void *arg) +{ + struct rp2040gpint_dev_s *rp2040gpint = + (struct rp2040gpint_dev_s *)arg; + + DEBUGASSERT(rp2040gpint != NULL && rp2040gpint->callback != NULL); + gpioinfo("Interrupt! callback=%p\n", rp2040gpint->callback); + + rp2040gpint->callback(&rp2040gpint->rp2040gpio.gpio, + rp2040gpint->rp2040gpio.id); + return OK; +} + +/**************************************************************************** + * Name: gpint_read + ****************************************************************************/ + +static int gpint_read(struct gpio_dev_s *dev, bool *value) +{ + struct rp2040gpint_dev_s *rp2040gpint = + (struct rp2040gpint_dev_s *)dev; + + DEBUGASSERT(rp2040gpint != NULL && value != NULL); + DEBUGASSERT(rp2040gpint->rp2040gpio.id < BOARD_NGPIOINT); + gpioinfo("Reading int pin...\n"); + + *value = rp2040_gpio_get(g_gpiointinputs[rp2040gpint->rp2040gpio.id]); + return OK; +} + +/**************************************************************************** + * Name: gpint_attach + ****************************************************************************/ + +static int gpint_attach(struct gpio_dev_s *dev, + pin_interrupt_t callback) +{ + struct rp2040gpint_dev_s *rp2040gpint = + (struct rp2040gpint_dev_s *)dev; + int irq = g_gpiointinputs[rp2040gpint->rp2040gpio.id]; + int ret; + + gpioinfo("Attaching the callback\n"); + + /* Make sure the interrupt is disabled */ + + rp2040_gpio_disable_irq(irq); + ret = rp2040_gpio_irq_attach(irq, + RP2040_GPIO_INTR_EDGE_LOW, + rp2040gpio_interrupt, + &g_gpint[rp2040gpint->rp2040gpio.id]); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: gpint_attach() failed: %d\n", ret); + return ret; + } + + gpioinfo("Attach %p\n", callback); + rp2040gpint->callback = callback; + return OK; +} + +/**************************************************************************** + * Name: gpint_enable + ****************************************************************************/ + +static int gpint_enable(struct gpio_dev_s *dev, bool enable) +{ + struct rp2040gpint_dev_s *rp2040gpint = + (struct rp2040gpint_dev_s *)dev; + int irq = g_gpiointinputs[rp2040gpint->rp2040gpio.id]; + + if (enable) + { + if (rp2040gpint->callback != NULL) + { + gpioinfo("Enabling the interrupt\n"); + + /* Configure the interrupt for rising edge */ + + rp2040_gpio_enable_irq(irq); + } + } + else + { + gpioinfo("Disable the interrupt\n"); + rp2040_gpio_disable_irq(irq); + } + + return OK; +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_dev_gpio_init + ****************************************************************************/ + +int rp2040_dev_gpio_init(void) +{ + int i; + int pincount = 0; + +#if BOARD_NGPIOOUT > 0 + for (i = 0; i < BOARD_NGPIOOUT; i++) + { + /* Setup and register the GPIO pin */ + + g_gpout[i].gpio.gp_pintype = GPIO_OUTPUT_PIN; + g_gpout[i].gpio.gp_ops = &gpout_ops; + g_gpout[i].id = i; + gpio_pin_register(&g_gpout[i].gpio, g_gpiooutputs[i]); + + /* Configure the pins that will be used as output */ + + rp2040_gpio_init(g_gpiooutputs[i]); + rp2040_gpio_setdir(g_gpiooutputs[i], true); + rp2040_gpio_put(g_gpiooutputs[i], false); + + pincount++; + } +#endif + + pincount = 0; + +#if BOARD_NGPIOIN > 0 + for (i = 0; i < BOARD_NGPIOIN; i++) + { + /* Setup and register the GPIO pin */ + + g_gpin[i].gpio.gp_pintype = GPIO_INPUT_PIN; + g_gpin[i].gpio.gp_ops = &gpin_ops; + g_gpin[i].id = i; + gpio_pin_register(&g_gpin[i].gpio, g_gpioinputs[i]); + + /* Configure the pins that will be used as INPUT */ + + rp2040_gpio_init(g_gpioinputs[i]); + + pincount++; + } +#endif + + pincount = 0; + +#if BOARD_NGPIOINT > 0 + for (i = 0; i < BOARD_NGPIOINT; i++) + { + /* Setup and register the GPIO pin */ + + g_gpint[i].rp2040gpio.gpio.gp_pintype = GPIO_INTERRUPT_PIN; + g_gpint[i].rp2040gpio.gpio.gp_ops = &gpint_ops; + g_gpint[i].rp2040gpio.id = i; + gpio_pin_register(&g_gpint[i].rp2040gpio.gpio, g_gpiointinputs[i]); + + /* Configure the pins that will be used as interrupt input */ + + rp2040_gpio_init(g_gpiointinputs[i]); + + /* pull-up = false : pull-down = true */ + + rp2040_gpio_set_pulls(g_gpiointinputs[i], false, true); + + pincount++; + } +#endif + + return OK; +} +#endif /* CONFIG_DEV_GPIO && !CONFIG_GPIO_LOWER_HALF */ diff --git a/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_pico.h b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_pico.h new file mode 100644 index 00000000000..0475e3506d2 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_pico.h @@ -0,0 +1,36 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_pico.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_SRC_RP2040_PICO_H +#define __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_SRC_RP2040_PICO_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +int rp2040_bringup(void); + +#ifdef CONFIG_DEV_GPIO +int rp2040_dev_gpio_init(void); +#endif + +#endif /* __BOARDS_ARM_RP2040_RASPBERRYPI_PICO_SRC_RP2040_PICO_H */ diff --git a/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_reset.c b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_reset.c new file mode 100644 index 00000000000..15bc3779b35 --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_reset.c @@ -0,0 +1,61 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_reset.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +int board_reset(int status) +{ + up_systemreset(); + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */ diff --git a/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_spi.c b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_spi.c new file mode 100644 index 00000000000..36af5597c3b --- /dev/null +++ b/boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_spi.c @@ -0,0 +1,150 @@ +/**************************************************************************** + * boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_spi.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include "arm_internal.h" +#include "chip.h" +#include "rp2040_gpio.h" +#include "hardware/rp2040_spi.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: rp2040_spi0/1select and rp2040_spi0/1status + * + * Description: + * The external functions, rp2040_spi0/1select and rp2040_spi0/1status + * must be provided by board-specific logic. + * They are implementations of the select and status methods of the SPI + * interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h). + * All other methods (including rp2040_spibus_initialize()) are provided by + * common RP2040 logic. To use this common SPI logic on your board: + * + * 1. Provide logic in rp2040_boardinitialize() to configure SPI chip + * select pins. + * 2. Provide rp2040_spi0/1select() and rp2040_spi0/1status() + * functions in your board-specific logic. + * These functions will perform chip selection and status operations + * using GPIOs in the way your board is configured. + * 3. Add a calls to rp2040_spibus_initialize() in your low level + * application initialization logic + * 4. The handle returned by rp2040_spibus_initialize() may then be used to + * bind the SPI driver to higher level logic (e.g., calling + * mmcsd_spislotinitialize(), for example, will bind the SPI driver to + * the SPI MMC/SD driver). + * + ****************************************************************************/ + +#ifdef CONFIG_RP2040_SPI0 +void rp2040_spi0select(struct spi_dev_s *dev, uint32_t devid, + bool selected) +{ + spiinfo("devid: %d CS: %s\n", (int)devid, + selected ? "assert" : "de-assert"); + + rp2040_gpio_put(CONFIG_RP2040_SPI0_CS_GPIO, !selected); +} + +uint8_t rp2040_spi0status(struct spi_dev_s *dev, uint32_t devid) +{ + uint8_t ret = 0; + +# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 0) + ret = board_spisd_status(dev, devid); +# endif + return ret; +} + +#ifdef CONFIG_SPI_CMDDATA +int rp2040_spi0cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) +{ +#ifdef CONFIG_LCD_ST7789 + if (devid == SPIDEV_DISPLAY(0)) + { + /* This is the Data/Command control pad which determines whether the + * data bits are data or a command. + */ + + rp2040_gpio_put(CONFIG_RP2040_SPI0_RX_GPIO, !cmd); + + return OK; + } +#endif + + return -ENODEV; +} +#endif +#endif + +#ifdef CONFIG_RP2040_SPI1 +void rp2040_spi1select(struct spi_dev_s *dev, uint32_t devid, + bool selected) +{ + spiinfo("devid: %d CS: %s\n", (int)devid, + selected ? "assert" : "de-assert"); + + rp2040_gpio_put(CONFIG_RP2040_SPI1_CS_GPIO, !selected); +} + +uint8_t rp2040_spi1status(struct spi_dev_s *dev, uint32_t devid) +{ + uint8_t ret = 0; + +# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 1) + ret = board_spisd_status(dev, devid); +# endif + return ret; +} + +#ifdef CONFIG_SPI_CMDDATA +int rp2040_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) +{ +#if defined (CONFIG_LCD_ST7789) || (CONFIG_LCD_ST7735) + if (devid == SPIDEV_DISPLAY(0)) + { + /* This is the Data/Command control pad which determines whether the + * data bits are data or a command. + */ + + rp2040_gpio_put(CONFIG_RP2040_SPI1_RX_GPIO, !cmd); + + return OK; + } +#endif + + return -ENODEV; +} +#endif +#endif diff --git a/boards/arm/rp2040/raspberrypi-pico/configs/lcd1602/defconfig b/boards/arm/rp2040/raspberrypi-pico/configs/lcd1602/defconfig index 7767f6443a4..a77882e92c5 100644 --- a/boards/arm/rp2040/raspberrypi-pico/configs/lcd1602/defconfig +++ b/boards/arm/rp2040/raspberrypi-pico/configs/lcd1602/defconfig @@ -13,10 +13,11 @@ # CONFIG_NSH_DISABLE_LOSMART is not set # CONFIG_STANDARD_SERIAL is not set CONFIG_ARCH="arm" -CONFIG_ARCH_BOARD="raspberrypi-pico" -CONFIG_ARCH_BOARD_RASPBERRYPI_PICO=y +CONFIG_ARCH_BOARD="raspberrypi-pico-w" +CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_W=y CONFIG_ARCH_CHIP="rp2040" CONFIG_ARCH_CHIP_RP2040=y +CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_RAMVECTORS=y CONFIG_ARCH_STACKDUMP=y CONFIG_BOARDCTL_RESET=y @@ -26,12 +27,9 @@ CONFIG_DEBUG_FULLOPT=y CONFIG_DEBUG_SYMBOLS=y CONFIG_DISABLE_POSIX_TIMERS=y CONFIG_EXAMPLES_HELLO=y -CONFIG_EXAMPLES_SLCD=y CONFIG_FS_PROCFS=y CONFIG_FS_PROCFS_REGISTER=y CONFIG_INIT_ENTRYPOINT="nsh_main" -CONFIG_LCD_BACKPACK=y -CONFIG_LCD_LCD1602=y CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 CONFIG_NSH_ARCHINIT=y CONFIG_NSH_BUILTIN_APPS=y @@ -39,17 +37,18 @@ CONFIG_NSH_READLINE=y CONFIG_RAM_SIZE=270336 CONFIG_RAM_START=0x20000000 CONFIG_READLINE_CMD_HISTORY=y -CONFIG_RP2040_I2C0=y -CONFIG_RP2040_I2C=y -CONFIG_RP2040_I2C_DRIVER=y CONFIG_RR_INTERVAL=200 -CONFIG_SCHED_WAITPID=y -CONFIG_SLCD=y +CONFIG_SMP=y +CONFIG_SMP_NCPUS=2 +CONFIG_STACK_COLORATION=y CONFIG_START_DAY=9 CONFIG_START_MONTH=2 CONFIG_START_YEAR=2021 CONFIG_SYSLOG_CONSOLE=y CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SYSTEM=y +CONFIG_SYSTEM_TASKSET=y CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y +CONFIG_TESTING_SMP=y CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/arm/rp2040/raspberrypi-pico/src/rp2040_boardinitialize.c b/boards/arm/rp2040/raspberrypi-pico/src/rp2040_boardinitialize.c index a3eba93eae4..c35e85fd133 100644 --- a/boards/arm/rp2040/raspberrypi-pico/src/rp2040_boardinitialize.c +++ b/boards/arm/rp2040/raspberrypi-pico/src/rp2040_boardinitialize.c @@ -32,6 +32,10 @@ #include "arm_internal.h" #include "rp2040_gpio.h" +#ifdef CONFIG_ARCH_BOARD_COMMON +#include "rp2040_common_initialize.h" +#endif /* CONFIG_ARCH_BOARD_COMMON */ + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -53,52 +57,17 @@ void rp2040_boardearlyinitialize(void) { - rp2040_gpio_initialize(); + #ifdef CONFIG_ARCH_BOARD_COMMON + rp2040_common_earlyinitialize(); + #endif - /* Disable IE on GPIO 26-29 */ - - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(26)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(27)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(28)); - clrbits_reg32(RP2040_PADS_BANK0_GPIO_IE, RP2040_PADS_BANK0_GPIO(29)); + /* --- Place any board specific early initialization here --- */ /* Set board LED pin */ rp2040_gpio_init(BOARD_GPIO_LED_PIN); rp2040_gpio_setdir(BOARD_GPIO_LED_PIN, true); rp2040_gpio_put(BOARD_GPIO_LED_PIN, true); - - /* Set default UART pin */ - -#ifdef CONFIG_RP2040_UART0 - rp2040_gpio_set_function(CONFIG_RP2040_UART0_TX_GPIO, - RP2040_GPIO_FUNC_UART); /* TX */ - rp2040_gpio_set_function(CONFIG_RP2040_UART0_RX_GPIO, - RP2040_GPIO_FUNC_UART); /* RX */ -#ifdef CONFIG_SERIAL_OFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART0_CTS_GPIO, - RP2040_GPIO_FUNC_UART); /* CTS */ -#endif -#ifdef CONFIG_SERIAL_IFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART0_RTS_GPIO, - RP2040_GPIO_FUNC_UART); /* RTS */ -#endif -#endif - -#ifdef CONFIG_RP2040_UART1 - rp2040_gpio_set_function(CONFIG_RP2040_UART1_TX_GPIO, - RP2040_GPIO_FUNC_UART); /* TX */ - rp2040_gpio_set_function(CONFIG_RP2040_UART1_RX_GPIO, - RP2040_GPIO_FUNC_UART); /* RX */ -#ifdef CONFIG_SERIAL_OFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART1_CTS_GPIO, - RP2040_GPIO_FUNC_UART); /* CTS */ -#endif -#ifdef CONFIG_SERIAL_IFLOWCONTROL - rp2040_gpio_set_function(CONFIG_RP2040_UART1_RTS_GPIO, - RP2040_GPIO_FUNC_UART); /* RTS */ -#endif -#endif } /**************************************************************************** @@ -110,57 +79,9 @@ void rp2040_boardearlyinitialize(void) void rp2040_boardinitialize(void) { - /* Set default I2C pin */ + #ifdef CONFIG_ARCH_BOARD_COMMON + rp2040_common_initialize(); + #endif -#ifdef CONFIG_RP2040_I2C0 - rp2040_gpio_set_function(CONFIG_RP2040_I2C0_SDA_GPIO, - RP2040_GPIO_FUNC_I2C); /* SDA */ - rp2040_gpio_set_function(CONFIG_RP2040_I2C0_SCL_GPIO, - RP2040_GPIO_FUNC_I2C); /* SCL */ - - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_SDA_GPIO, true, false); /* Pull up */ - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C0_SCL_GPIO, true, false); -#endif - -#ifdef CONFIG_RP2040_I2C1 - rp2040_gpio_set_function(CONFIG_RP2040_I2C1_SDA_GPIO, - RP2040_GPIO_FUNC_I2C); /* SDA */ - rp2040_gpio_set_function(CONFIG_RP2040_I2C1_SCL_GPIO, - RP2040_GPIO_FUNC_I2C); /* SCL */ - - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_SDA_GPIO, true, false); /* Pull up */ - rp2040_gpio_set_pulls(CONFIG_RP2040_I2C1_SCL_GPIO, true, false); -#endif - - /* Set default SPI pin */ - -#ifdef CONFIG_RP2040_SPI0 - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_RX_GPIO, - RP2040_GPIO_FUNC_SPI); /* RX */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_SCK_GPIO, - RP2040_GPIO_FUNC_SPI); /* SCK */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI0_TX_GPIO, - RP2040_GPIO_FUNC_SPI); /* TX */ - - /* CSn is controlled by board-specific logic */ - - rp2040_gpio_init(CONFIG_RP2040_SPI0_CS_GPIO); /* CSn */ - rp2040_gpio_setdir(CONFIG_RP2040_SPI0_CS_GPIO, true); - rp2040_gpio_put(CONFIG_RP2040_SPI0_CS_GPIO, true); -#endif - -#ifdef CONFIG_RP2040_SPI1 - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_RX_GPIO, - RP2040_GPIO_FUNC_SPI); /* RX */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_SCK_GPIO, - RP2040_GPIO_FUNC_SPI); /* SCK */ - rp2040_gpio_set_function(CONFIG_RP2040_SPI1_TX_GPIO, - RP2040_GPIO_FUNC_SPI); /* TX */ - - /* CSn is controlled by board-specific logic */ - - rp2040_gpio_init(CONFIG_RP2040_SPI1_CS_GPIO); /* CSn */ - rp2040_gpio_setdir(CONFIG_RP2040_SPI1_CS_GPIO, true); - rp2040_gpio_put(CONFIG_RP2040_SPI1_CS_GPIO, true); -#endif + /* --- Place any board specific initialization here --- */ } diff --git a/boards/arm/rp2040/raspberrypi-pico/src/rp2040_bringup.c b/boards/arm/rp2040/raspberrypi-pico/src/rp2040_bringup.c index 2e5ae58070d..a20a397c007 100644 --- a/boards/arm/rp2040/raspberrypi-pico/src/rp2040_bringup.c +++ b/boards/arm/rp2040/raspberrypi-pico/src/rp2040_bringup.c @@ -33,50 +33,9 @@ #include "rp2040_pico.h" -#ifdef CONFIG_LCD_BACKPACK -#include "rp2040_lcd_backpack.h" -#endif - -#ifdef CONFIG_LCD -#include -#endif - -#ifdef CONFIG_LCD_DEV -#include -#endif - -#ifdef CONFIG_VIDEO_FB -#include -#endif - -#ifdef CONFIG_SENSORS_INA219 -#include -#include "rp2040_ina219.h" -#endif - -#ifdef CONFIG_SENSORS_BMP180 -#include -#include "rp2040_bmp180.h" -#endif - -#ifdef CONFIG_RP2040_PWM -#include "rp2040_pwm.h" -#include "rp2040_pwmdev.h" -#endif - -#if defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) -#include "rp2040_adc.h" -#endif - -#if defined(CONFIG_RP2040_BOARD_HAS_WS2812) && defined(CONFIG_WS2812) -#include "rp2040_ws2812.h" -#endif - -#ifdef CONFIG_WS2812_HAS_WHITE -#define HAS_WHITE true -#else /* CONFIG_WS2812_HAS_WHITE */ -#define HAS_WHITE false -#endif /* CONFIG_WS2812_HAS_WHITE */ +#ifdef CONFIG_ARCH_BOARD_COMMON +#include "rp2040_common_bringup.h" +#endif /* CONFIG_ARCH_BOARD_COMMON */ /**************************************************************************** * Public Functions @@ -88,461 +47,17 @@ int rp2040_bringup(void) { - int ret = 0; +#ifdef CONFIG_ARCH_BOARD_COMMON -#ifdef CONFIG_RP2040_I2C_DRIVER - #ifdef CONFIG_RP2040_I2C0 - ret = board_i2cdev_initialize(0); + int ret = rp2040_common_bringup(); if (ret < 0) { - _err("ERROR: Failed to initialize I2C0.\n"); - } - #endif - - #ifdef CONFIG_RP2040_I2C1 - ret = board_i2cdev_initialize(1); - if (ret < 0) - { - _err("ERROR: Failed to initialize I2C1.\n"); - } - #endif -#endif - -#ifdef CONFIG_RP2040_SPI_DRIVER - #ifdef CONFIG_RP2040_SPI0 - ret = board_spidev_initialize(0); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI0.\n"); - } - #endif - - #ifdef CONFIG_RP2040_SPI1 - ret = board_spidev_initialize(1); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI1.\n"); - } - #endif -#endif - -#ifdef CONFIG_RP2040_PWM -# ifdef CONFIG_RP2040_PWM0 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(0, - CONFIG_RP2040_PWM0A_GPIO, - CONFIG_RP2040_PWM0B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM0A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM0B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM0_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(0, - CONFIG_RP2040_PWM0A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM0A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM0_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM0.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM1 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(1, - CONFIG_RP2040_PWM1A_GPIO, - CONFIG_RP2040_PWM1B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM1A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM1B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM1_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(1, - CONFIG_RP2040_PWM1A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM1A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM1_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM1.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM2 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(2, - CONFIG_RP2040_PWM2A_GPIO, - CONFIG_RP2040_PWM2B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM2A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM2B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM2_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(2, - CONFIG_RP2040_PWM2A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM2A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM2_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM2.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM3 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(3, - CONFIG_RP2040_PWM3A_GPIO, - CONFIG_RP2040_PWM3B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM3A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM3B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM3_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(3, - CONFIG_RP2040_PWM3A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM3A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM3_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM3.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM4 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(4, - CONFIG_RP2040_PWM4A_GPIO, - CONFIG_RP2040_PWM4B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM4A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM4B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM4_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(4, - CONFIG_RP2040_PWM4A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM4A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM4_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM4.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM5 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(5, - CONFIG_RP2040_PWM5A_GPIO, - CONFIG_RP2040_PWM5B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM5A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM5B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM5_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(5, - CONFIG_RP2040_PWM5A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM5A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM5_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM5.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM6 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(6, - CONFIG_RP2040_PWM6A_GPIO, - CONFIG_RP2040_PWM6B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM6A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM6B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM6_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(6, - CONFIG_RP2040_PWM6A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM6A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM6_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM6.\n"); - } -# endif - -# ifdef CONFIG_RP2040_PWM7 -# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2 - ret = rp2040_pwmdev_initialize(7, - CONFIG_RP2040_PWM7A_GPIO, - CONFIG_RP2040_PWM7B_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM7A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM7B_INVERT - | RP2040_PWM_CSR_B_INV -# endif -# ifdef CONFIG_RP2040_PWM7_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# else - ret = rp2040_pwmdev_initialize(7, - CONFIG_RP2040_PWM7A_GPIO, - (0 -# ifdef CONFIG_RP2040_PWM7A_INVERT - | RP2040_PWM_CSR_A_INV -# endif -# ifdef CONFIG_RP2040_PWM7_PHASE_CORRECT - | RP2040_PWM_CSR_PH_CORRECT -# endif - )); -# endif - if (ret < 0) - { - _err("ERROR: Failed to initialize PWM7.\n"); - } -# endif -#endif - -#ifdef CONFIG_RP2040_SPISD - /* Mount the SPI-based MMC/SD block driver */ - - ret = board_spisd_initialize(0, CONFIG_RP2040_SPISD_SPI_CH); - if (ret < 0) - { - _err("ERROR: Failed to initialize SPI device to MMC/SD: %d\n", - ret); - } -#endif - -#ifdef CONFIG_FS_PROCFS - /* Mount the procfs file system */ - - ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); - if (ret < 0) - { - serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret); - } -#endif - -#ifdef CONFIG_SENSORS_BMP180 - /* Try to register BMP180 device in I2C0 */ - - ret = board_bmp180_initialize(0); - if (ret < 0) - { - syslog(LOG_ERR, "Failed to initialize BMP180 driver: %d\n", ret); - } -#endif - -#ifdef CONFIG_SENSORS_INA219 - /* Configure and initialize the INA219 sensor in I2C0 */ - - ret = board_ina219_initialize(0); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: rp2040_ina219_initialize() failed: %d\n", ret); - } -#endif - -#ifdef CONFIG_VIDEO_FB - ret = fb_register(0, 0); - if (ret < 0) - { - _err("ERROR: Failed to initialize Frame Buffer Driver.\n"); - } -#elif defined(CONFIG_LCD) - ret = board_lcd_initialize(); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: Failed to initialize LCD.\n"); - } -#endif - -#ifdef CONFIG_LCD_DEV - ret = lcddev_register(0); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: lcddev_register() failed: %d\n", ret); - } -#endif - -#ifdef CONFIG_LCD_BACKPACK - /* slcd:0, i2c:0, rows=2, cols=16 */ - - ret = board_lcd_backpack_init(0, 0, 2, 16); - if (ret < 0) - { - syslog(LOG_ERR, "Failed to initialize PCF8574 LCD, error %d\n", ret); - return ret; - } -#endif - -#ifdef CONFIG_RP2040_I2S - ret = board_i2sdev_initialize(0); - if (ret < 0) - { - _err("ERROR: Failed to initialize I2S.\n"); - } -#endif - -#ifdef CONFIG_DEV_GPIO - ret = rp2040_dev_gpio_init(); - if (ret < 0) - { - syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret); - return ret; - } -#endif - - /* Initialize ADC */ - -#if defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) - -# ifdef CONFIG_RPC2040_ADC_CHANNEL0 -# define ADC_0 true -# else -# define ADC_0 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL1 -# define ADC_1 true -# else -# define ADC_1 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL2 -# define ADC_2 true -# else -# define ADC_2 false -# endif - -# ifdef CONFIG_RPC2040_ADC_CHANNEL3 -# define ADC_3 true -# else -# define ADC_3 false -# endif - -# ifdef CONFIG_RPC2040_ADC_TEMPERATURE -# define ADC_TEMP true -# else -# define ADC_TEMP false -# endif - - ret = rp2040_adc_setup("/dev/adc0", ADC_0, ADC_1, ADC_2, ADC_3, ADC_TEMP); - if (ret != OK) - { - syslog(LOG_ERR, "Failed to initialize ADC Driver: %d\n", ret); return ret; } -#endif /* defined(CONFIG_ADC) && defined(CONFIG_RP2040_ADC) */ +#endif /* CONFIG_ARCH_BOARD_COMMON */ - /* Initialize board neo-pixel */ + /* --- Place any board specific bringup code here --- */ -#if defined(CONFIG_RP2040_BOARD_HAS_WS2812) && defined(CONFIG_WS2812) - rp2040_ws2812_setup("/dev/leds0", - CONFIG_RP2040_WS2812_GPIO_PIN, - CONFIG_RP2040_WS2812_PWR_GPIO, - CONFIG_WS2812_LED_COUNT, - HAS_WHITE); -#endif - - return ret; + return OK; } diff --git a/boards/boardctl.c b/boards/boardctl.c index d01cf0467ab..0027cdbb2bb 100644 --- a/boards/boardctl.c +++ b/boards/boardctl.c @@ -383,7 +383,7 @@ int boardctl(unsigned int cmd, uintptr_t arg) #ifdef CONFIG_PM /* CMD: BOARDIOC_PM_CONTROL - * DESCRIPTION: anage power state transition and query + * DESCRIPTION: manage power state transition and query * ARG: A pointer to an instance of struct boardioc_pm_ctrl_s * CONFIGURATION: CONFIG_PM * DEPENDENCIES: None diff --git a/drivers/wireless/ieee80211/bcm43xxx/bcmf_cdc.c b/drivers/wireless/ieee80211/bcm43xxx/bcmf_cdc.c index e0bb2917857..1c2fc7fb2ce 100644 --- a/drivers/wireless/ieee80211/bcm43xxx/bcmf_cdc.c +++ b/drivers/wireless/ieee80211/bcm43xxx/bcmf_cdc.c @@ -48,7 +48,7 @@ #define BCMF_CONTROL_INTERFACE_SHIFT 12 #define BCMF_CONTROL_REQID_SHIFT 16 -#define BCMF_CONTROL_TIMEOUT_MS 2000 +#define BCMF_CONTROL_TIMEOUT_MS 10000 /**************************************************************************** * Private Types diff --git a/drivers/wireless/ieee80211/bcm43xxx/bcmf_gspi.c b/drivers/wireless/ieee80211/bcm43xxx/bcmf_gspi.c index 8e640258747..db3f5168781 100644 --- a/drivers/wireless/ieee80211/bcm43xxx/bcmf_gspi.c +++ b/drivers/wireless/ieee80211/bcm43xxx/bcmf_gspi.c @@ -61,7 +61,7 @@ #define BCMF_GSPI_LOWPOWER_TIMEOUT_TICK SEC2TICK(2) #ifdef CONFIG_IEEE80211_INFINEON_CYW43439 -extern const struct bcmf_chip_data cyw43439_config_data; +extern const struct bcmf_chip_data g_cyw43439_config_data; #endif #define REV16(x) (((x & 0x000000ff) << 8) \ @@ -634,7 +634,7 @@ static int bcmf_gspi_probe_chip(FAR bcmf_gspi_dev_t *gbus) #ifdef CONFIG_IEEE80211_INFINEON_CYW43439 case SDIO_DEVICE_ID_INFINEON_CYW43439: wlinfo("cyw%d chip detected\n", chipid); - gbus->chip = (struct bcmf_chip_data *)&cyw43439_config_data; + gbus->chip = (struct bcmf_chip_data *)&g_cyw43439_config_data; break; #endif diff --git a/drivers/wireless/ieee80211/bcm43xxx/cyw_chip_43439.c b/drivers/wireless/ieee80211/bcm43xxx/cyw_chip_43439.c index 529b5c5f968..828e72e5bf1 100644 --- a/drivers/wireless/ieee80211/bcm43xxx/cyw_chip_43439.c +++ b/drivers/wireless/ieee80211/bcm43xxx/cyw_chip_43439.c @@ -37,18 +37,23 @@ * Public Data ****************************************************************************/ -extern const char cyw43439_nvram_image[]; -extern const unsigned int cyw43439_nvram_image_len; +extern const uint8_t g_cyw43439_nvram_image[]; +extern unsigned int g_cyw43439_nvram_len; #ifndef CONFIG_IEEE80211_BROADCOM_FWFILES -extern const uint8_t cyw43439_firmware_image[]; -extern const unsigned int cyw43439_firmware_len; -extern const uint8_t cyw43439_clm_blob_image[]; -extern const unsigned int cyw43439_clm_blob_len; +extern const uint8_t g_cyw43439_firmware_image[]; +extern const unsigned int g_cyw43439_firmware_len; + +#ifdef CONFIG_IEEE80211_BROADCOM_HAVE_CLM + +extern const uint8_t g_cyw43439_clm_blob_image[]; +extern const unsigned int g_cyw43439_clm_blob_len; + +#endif #endif -const struct bcmf_chip_data cyw43439_config_data = +const struct bcmf_chip_data g_cyw43439_config_data = { /* General chip stats */ @@ -70,18 +75,16 @@ const struct bcmf_chip_data cyw43439_config_data = /* Firmware images */ - /* TODO find something smarter than using image_len references */ - - .nvram_image = (FAR uint8_t *)cyw43439_nvram_image, - .nvram_image_size = (FAR unsigned int *)&cyw43439_nvram_image_len, + .nvram_image = (FAR uint8_t *)g_cyw43439_nvram_image, + .nvram_image_size = (FAR unsigned int *)&g_cyw43439_nvram_len, #ifndef CONFIG_IEEE80211_BROADCOM_FWFILES - .firmware_image = (FAR uint8_t *)cyw43439_firmware_image, - .firmware_image_size = (FAR unsigned int *)&cyw43439_firmware_len, + .firmware_image = (FAR uint8_t *)g_cyw43439_firmware_image, + .firmware_image_size = (FAR unsigned int *)&g_cyw43439_firmware_len, #ifdef CONFIG_IEEE80211_BROADCOM_HAVE_CLM - .clm_blob_image = (FAR uint8_t *)cyw43439_clm_blob_image, - .clm_blob_image_size = (FAR unsigned int *)&cyw43439_clm_blob_len + .clm_blob_image = (FAR uint8_t *)g_cyw43439_clm_blob_image, + .clm_blob_image_size = (FAR unsigned int *)&g_cyw43439_clm_blob_len #endif #endif };