board(rp23xx): add Raspberry Pi Pico 2

This commit is contained in:
Marco Casaroli 2024-09-05 22:44:21 +02:00 committed by Alan C. Assis
parent 7c55890247
commit 566f31f14c
41 changed files with 5419 additions and 0 deletions

View file

@ -1950,6 +1950,15 @@ config ARCH_BOARD_ADAFRUIT_QT_PY_RP2040
This is a port to the Adafruit QT Py RP2040 board.
Support is derived from Raspberry Pi Pico support.
config ARCH_BOARD_RASPBERRYPI_PICO_2
bool "Raspberry Pi Pico 2 board (not Pico, not W)"
depends on ARCH_CHIP_RP23XX
select ARCH_HAVE_LEDS
select ARCH_HAVE_BUTTONS
select ARCH_HAVE_IRQBUTTONS
---help---
This is a port to the Raspberry Pi Pico 2 board.
config ARCH_BOARD_WAVESHARE_RP2040_LCD_1_28
bool "Waveshare RP2040 LCD 1.28 board"
depends on ARCH_CHIP_RP2040
@ -3452,6 +3461,7 @@ config ARCH_BOARD
default "adafruit-kb2040" if ARCH_BOARD_ADAFRUIT_KB2040
default "adafruit-qt-py-rp2040" if ARCH_BOARD_ADAFRUIT_QT_PY_RP2040
default "waveshare-rp2040-lcd-1.28" if ARCH_BOARD_WAVESHARE_RP2040_LCD_1_28
default "raspberrypi-pico-2" if ARCH_BOARD_RASPBERRYPI_PICO_2
default "w5500-evb-pico" if ARCH_BOARD_W5500_EVB_PICO
default "waveshare-rp2040-zero" if ARCH_BOARD_WAVESHARE_RP2040_ZERO
default "rx65n" if ARCH_BOARD_RX65N
@ -3918,6 +3928,9 @@ endif
if ARCH_BOARD_WAVESHARE_RP2040_ZERO
source "boards/arm/rp2040/waveshare-rp2040-zero/Kconfig"
endif
if ARCH_BOARD_RASPBERRYPI_PICO_2
source "boards/arm/rp23xx/raspberrypi-pico-2/Kconfig"
endif
if ARCH_BOARD_ARDUINO_DUE
source "boards/arm/sam34/arduino-due/Kconfig"
endif
@ -4654,6 +4667,9 @@ endif
if ARCH_CHIP_RP2040
source "boards/arm/rp2040/common/Kconfig"
endif
if ARCH_CHIP_RP23XX
source "boards/arm/rp23xx/common/Kconfig"
endif
if ARCH_CHIP_NRF52
source "boards/arm/nrf52/common/Kconfig"
endif

View file

@ -0,0 +1,502 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
#####################################################################
# Build Configuration
#####################################################################
config RP23XX_UF2_BINARY
bool "uf2 binary format"
default y
---help---
Create nuttx.uf2 binary format used on RP23XX based arch.
#####################################################################
# PSRAM Configuration
#####################################################################
if RP23XX_PSRAM
config RP23XX_PSRAM_CS1_GPIO
int "GPIO pin for the PSRAM (0, 8, 19, or 47)"
default 47
range 0 47
---help---
The PSRAM shares the same QPI signals with the flash, but
with a separate CS pin. Refer to board datasheet for more
information
endif
#####################################################################
# UART Configuration
#####################################################################
if RP23XX_UART0
config RP23XX_UART0_TX_GPIO
int "GPIO pin for UART0 TX (0, 12, 16, or 28)"
default 0
range 0 28
---help---
RP23XX UART0 TX pin number used for data transmitted
from the RP23XX. Refer to board documentation to see
which pins are available.
config RP23XX_UART0_RX_GPIO
int "GPIO pin for UART0 RX (1, 13, 17, or 29)"
default 1
range 1 29
---help---
RP23XX UART0 RX pin number used for data received by the
RP23XX. Refer to board documentation to see which pins
are available.
if SERIAL_IFLOWCONTROL
config RP23XX_UART0_CTS_GPIO
int "GPIO pin for UART0 CTS (2, 14, or 18)"
default 2
range 2 18
---help---
RP23XX UART0 CTS pin number an output pin that reflects the
UARTs ability to receive data. This pin will be asserted when
the UART is able to receive another character. Refer to board
documentation to see which pins are available.
endif # SERIAL_IFLOWCONTROL
if SERIAL_OFLOWCONTROL
config RP23XX_UART0_RTS_GPIO
int "GPIO pin for UART0 RTS (3, 15, or 19)"
default 3
range 2 19
---help---
RP23XX UART0 RTS pin number an input pin used to control
transmission by the UART. If output flow control is
enabled this pin must be asserted before data will be
transmitted. Refer to board documentation to see which
pins are available.
endif # SERIAL_OFLOWCONTROL
endif # RP23XX_UART0
#####################################################################
if RP23XX_UART1
config RP23XX_UART1_TX_GPIO
int "GPIO pin for UART1 TX (4, 8, 20, or 24)"
default 20
range 4 24
---help---
RP23XX UART1 TX pin number. Refer to board documentation
to see which pins are available.
config RP23XX_UART1_RX_GPIO
int "GPIO pin for UART1 RX (5, 9, 21, or 25)"
default 21
range 5 25
---help---
RP23XX UART1 RX pin number. Refer to board documentation
to see which pins are available.
if SERIAL_IFLOWCONTROL
config RP23XX_UART1_CTS_GPIO
int "GPIO pin for UART1 CTS (6, 10, 22, or 26)"
default 22
range 6 26
---help---
RP23XX UART1 CTS pin number an output pin that reflects the
UARTs ability to receive data. This pin will be asserted when
the UART is able to receive another character. Refer to board
documentation to see which pins are available.
endif # SERIAL_IFLOWCONTROL
if SERIAL_OFLOWCONTROL
config RP23XX_UART1_RTS_GPIO
int "GPIO pin for UART1 RTS (7, 11, 23, or 27)"
default 23
range 7 27
---help---
RP23XX UART01 RTS pin number an input pin used to control
transmission by the UART. If output flow control is
enabled this pin must be asserted before data will be
transmitted. Refer to board documentation to see which
pins are available.
endif # SERIAL_OFLOWCONTROL
endif # RP23XX_UART1
#####################################################################
# SPI Configuration
#####################################################################
if RP23XX_SPI0
config RP23XX_SPI0_RX_GPIO
int "GPIO pin for SPI0 RX (0, 4, 16, or 20)"
default 16
range 0 20
---help---
Refer to board documentation to see which pins are available.
This line is also known as MISO when we are configured in
SPI master mode.
config RP23XX_SPI0_CS_GPIO
int "GPIO pin for SPI0 CSn (1, 5, 17, or 21)"
default 17
range 1 21
---help---
Refer to board documentation to see which pins are available.
config RP23XX_SPI0_SCK_GPIO
int "GPIO pin for SPI0 SCK (2, 6, 18, or 22)"
default 18
range 2 22
---help---
Refer to board documentation to see which pins are available.
config RP23XX_SPI0_TX_GPIO
int "GPIO pin for SPI0 TX (3, 7, 19, or 23)"
default 19
range 3 23
---help---
Refer to board documentation to see which pins are available.
This line is also known as MOSI when we are configured in
SPI master mode.
endif # RP23XX_SPI0
#####################################################################
if RP23XX_SPI1
config RP23XX_SPI1_RX_GPIO
int "GPIO pin for SPI1 RX (8, 12, 24, or 28)"
default 8
range 8 28
---help---
Refer to board documentation to see which pins are available.
This line is also known as MISO when we are configured in
SPI master mode, or MOSI when slave mode is configured.
config RP23XX_SPI1_CS_GPIO
int "GPIO pin for SPI1 CSn (9, 13, 25, or 29)"
default 9
range 9 29
---help---
Refer to board documentation to see which pins are available.
config RP23XX_SPI1_SCK_GPIO
int "GPIO pin for SPI1 SCK (10, 14, or 26)"
default 10
range 10 26
---help---
Refer to board documentation to see which pins are available.
config RP23XX_SPI1_TX_GPIO
int "GPIO pin for SPI1 TX (11, 15, or 27)"
default 11
range 11 27
---help---
Refer to board documentation to see which pins are available.
This line is also known as MOSI when we are configured in
SPI master mode, or MISO when slave mode is configured.
endif # RP23XX_SPI1
#####################################################################
# I2C Configuration
#####################################################################
if RP23XX_I2C0 || RP23XX_I2C0_SLAVE
config RP23XX_I2C0_SDA_GPIO
int "GPIO pin for I2C0 SDA (0, 4, 8, 12, 16, 20, 24, or 28)"
default 4
range 0 28
---help---
Refer to board documentation to see which pins are available.
config RP23XX_I2C0_SCL_GPIO
int "GPIO pin for I2C0 SCL (1, 5, 9, 13, 17, 21, 25, or 29)"
default 5
range 1 29
---help---
Refer to board documentation to see which pins are available.
endif # RP23XX_I2C0 || RP23XX_I2C0_SLAVE
#####################################################################
if RP23XX_I2C1 || RP23XX_I2C1_SLAVE
config RP23XX_I2C1_SDA_GPIO
int "GPIO pin for I2C1 SDA (2, 6, 10, 14, 18, 22, or 26)"
default 6
range 2 26
---help---
Refer to board documentation to see which pins are available.
config RP23XX_I2C1_SCL_GPIO
int "GPIO pin for I2C1 SCL (3, 7, 11, 15, 19, 23, or 27)"
default 7
range 3 27
---help---
Refer to board documentation to see which pins are available.
endif # RP23XX_I2C1 || RP23XX_I2C1_SLAVE
#####################################################################
# PWM Configuration
#####################################################################
if RP23XX_PWM0
config RP23XX_PWM0A_GPIO
int "GPIO pin for PWM0 channel 1 (0, 16 or -1:no assign)"
default 0
range -1 16
---help---
This sets the GPIO pin to use for the A channel it must be
either 0 or 16, any other value disables the output.
Refer to board documentation to see which pins are available.
if PWM_MULTICHAN && PWM_NCHANNELS > 1
config RP23XX_PWM0B_GPIO
int "GPIO pin for PWM0 channel 2 (1, 17 or -1:no assign)"
default 1
range -1 29
---help---
This sets the GPIO pin to use for the B channel it must be
either 1 or 17, any other value disables the output.
Refer to board documentation to see which pins are available.
endif # PWM_MULTICHAN && PWM_NCHANNELS > 1
endif # RP23XX_PWM0
#####################################################################
if RP23XX_PWM1
config RP23XX_PWM1A_GPIO
int "GPIO pin for PWM1 channel 1 (2, 18 or -1:no assign)"
default 2
range -1 29
---help---
This sets the GPIO pin to use for the A channel it must be
either 2 or 18, any other value disables the output.
Refer to board documentation to see which pins are available.
if PWM_MULTICHAN && PWM_NCHANNELS > 1
config RP23XX_PWM1B_GPIO
int "GPIO pin for PWM1 channel 2 (3, 19 or -1:no assign)"
default 3
range -1 29
---help---
This sets the GPIO pin to use for the B channel it must be
either 3 or 19, any other value disables the output.
Refer to board documentation to see which pins are available.
endif # PWM_MULTICHAN && PWM_NCHANNELS > 1
endif # RP23XX_PWM1
#####################################################################
if RP23XX_PWM2
config RP23XX_PWM2A_GPIO
int "GPIO pin for PWM2 channel 1 (4, 20 or -1:no assign)"
default 4
range -1 29
---help---
This sets the GPIO pin to use for the A channel it must be
either 4 or 20, any other value disables the output.
Refer to board documentation to see which pins are available.
if PWM_MULTICHAN && PWM_NCHANNELS > 1
config RP23XX_PWM2B_GPIO
int "GPIO pin for PWM2 channel 2 (5, 21 or -1:no assign)"
default 5
range -1 29
---help---
This sets the GPIO pin to use for the B channel it must be
either 5 or 21, any other value disables the output.
Refer to board documentation to see which pins are available.
endif # PWM_MULTICHAN && PWM_NCHANNELS > 1
endif # RP23XX_PWM2
#####################################################################
if RP23XX_PWM3
config RP23XX_PWM3A_GPIO
int "GPIO pin for PWM3 channel 1 (6, 22 or -1:no assign)"
default 6
range -1 29
---help---
This sets the GPIO pin to use for the A channel it must be
either 6 or 22, any other value disables the output.
Refer to board documentation to see which pins are available.
if PWM_MULTICHAN && PWM_NCHANNELS > 1
config RP23XX_PWM3B_GPIO
int "GPIO pin for PWM3 channel 2 (7, 23 or -1:no assign)"
default 7
range -1 29
---help---
This sets the GPIO pin to use for the B channel it must be
either 7 or 23, any other value disables the output.
Refer to board documentation to see which pins are available.
endif # PWM_MULTICHAN && PWM_NCHANNELS > 1
endif # RP23XX_PWM3
#####################################################################
if RP23XX_PWM4
config RP23XX_PWM4A_GPIO
int "GPIO pin for PWM4 channel 1 (8, 24 or -1:no assign)"
default 8
range -1 29
---help---
This sets the GPIO pin to use for the A channel it must be
either 8 or 24, any other value disables the output.
Refer to board documentation to see which pins are available.
if PWM_MULTICHAN && PWM_NCHANNELS > 1
config RP23XX_PWM4B_GPIO
int "GPIO pin for PWM4 channel 2 (9, 25 or -1:no assign)"
default 9
range -1 29
---help---
This sets the GPIO pin to use for the B channel it must be
either 9 or 25, any other value disables the output.
Refer to board documentation to see which pins are available.
endif # PWM_MULTICHAN && PWM_NCHANNELS > 1
endif # RP23XX_PWM4
#####################################################################
if RP23XX_PWM5
config RP23XX_PWM5A_GPIO
int "GPIO pin for PWM5 channel 1 (10, 26 or -1:no assign)"
default 10
range -1 29
---help---
This sets the GPIO pin to use for the A channel it must be
either 10 or 26, any other value disables the output.
Refer to board documentation to see which pins are available.
if PWM_MULTICHAN && PWM_NCHANNELS > 1
config RP23XX_PWM5B_GPIO
int "GPIO pin for PWM5 channel 2 (11, 27 or -1:no assign)"
default 11
range -1 29
---help---
This sets the GPIO pin to use for the B channel it must be
either 11 or 27, any other value disables the output.
Refer to board documentation to see which pins are available.
endif # PWM_MULTICHAN && PWM_NCHANNELS > 1
endif # RP23XX_PWM5
#####################################################################
if RP23XX_PWM6
config RP23XX_PWM6A_GPIO
int "GPIO pin for PWM6 channel 1 (12, 28 or -1:no assign)"
default 12
range -1 29
---help---
This sets the GPIO pin to use for the A channel it must be
either 12 or 28, any other value disables the output.
Refer to board documentation to see which pins are available.
if PWM_MULTICHAN && PWM_NCHANNELS > 1
config RP23XX_PWM6B_GPIO
int "GPIO pin for PWM6 channel 2 (13, 29 or -1:no assign)"
default 13
range -1 29
---help---
This sets the GPIO pin to use for the B channel it must be
either 13 or 29, any other value disables the output.
Refer to board documentation to see which pins are available.
endif # PWM_MULTICHAN && PWM_NCHANNELS > 1
endif # RP23XX_PWM6
#####################################################################
if RP23XX_PWM7
config RP23XX_PWM7A_GPIO
int "GPIO pin for PWM7 channel 1 (14 or -1:no assign)"
default 14
range -1 29
---help---
This sets the GPIO pin to use for the A channel it must be
either 14, any other value disables the output.
Refer to board documentation to see if pin 14 is available.
if PWM_MULTICHAN && PWM_NCHANNELS > 1
config RP23XX_PWM7B_GPIO
int "GPIO pin for PWM7 channel 2 (15 or -1:no assign)"
default 15
range -1 29
---help---
This sets the GPIO pin to use for the B channel it must be
either 15, any other value disables the output.
Refer to board documentation to see if pin 15 is available.
endif # PWM_MULTICHAN && PWM_NCHANNELS > 1
endif # RP23XX_PWM7
#####################################################################
# I2S Configuration
#####################################################################
if RP23XX_I2S
config RP23XX_I2S_DATA
int "GPIO pin for I2S DATA (0-29)"
default 9
range 0 29
config RP23XX_I2S_CLOCK
int "GPIO pin for I2S CLOCK (0-29)"
default 10
range 0 29
endif # RP23XX_I2S

View file

@ -0,0 +1,33 @@
#############################################################################
# boards/arm/rp23xx/common/Makefile
#
# 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
include board/Make.defs
include src/Make.defs
DEPPATH += --dep-path board
DEPPATH += --dep-path src
include $(TOPDIR)/boards/Board.mk
ARCHSRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src
BOARDDIR = $(ARCHSRCDIR)$(DELIM)board
CFLAGS += ${INCDIR_PREFIX}$(BOARDDIR)$(DELIM)include

View file

@ -0,0 +1,47 @@
/****************************************************************************
* boards/arm/rp23xx/common/include/rp23xx_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_RP23XX_COMMON_INCLUDE_RP23XX_COMMON_BRINGUP_H
#define __BOARDS_ARM_RP23XX_COMMON_INCLUDE_RP23XX_COMMON_BRINGUP_H
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: rp23xx_common_bringup
****************************************************************************/
int rp23xx_common_bringup(void);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __BOARDS_ARM_RP23XX_COMMON_INCLUDE_RP23XX_COMMON_BRINGUP_H */

View file

@ -0,0 +1,60 @@
/****************************************************************************
* boards/arm/rp23xx/common/include/rp23xx_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_RP23XX_COMMON_INCLUDE_RP23XX_COMMON_INITIALIZE_H
#define __BOARDS_ARM_RP23XX_COMMON_INCLUDE_RP23XX_COMMON_INITIALIZE_H
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: rp23xx_common_earlyinitialize
*
* This is the early initialization common to all RP23XX boards.
* It configures the GPIO, SPI, and I2C pins.
****************************************************************************/
int rp23xx_common_earlyinitialize(void);
/****************************************************************************
* Name: rp23xx_common_initialize
*
* Description:
* It configures the pin assignments that were not done in the early
* initialization.
****************************************************************************/
void rp23xx_common_initialize(void);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __BOARDS_ARM_RP23XX_COMMON_INCLUDE_RP23XX_COMMON_INITIALIZE_H */

View file

@ -0,0 +1,78 @@
/****************************************************************************
* boards/arm/rp23xx/common/include/rp23xx_pwmdev.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_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_RP23XX_PWMDEV_H
#define __BOARDS_ARM_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_RP23XX_PWMDEV_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* 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: rp23xx_pwmdev_initialize
*
* Description:
* Initialize pwm driver and register the /dev/pwm device.
*
****************************************************************************/
#if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2
int rp23xx_pwmdev_initialize(int slice,
int pin_a,
int pin_b,
uint32_t flags);
#else
int rp23xx_pwmdev_initialize(int slice,
int pin,
uint32_t flags);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_RP23XX_PWMDEV_H */

View file

@ -0,0 +1,64 @@
/****************************************************************************
* boards/arm/rp23xx/common/include/rp23xx_uniqueid.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_RP23XX_COMMON_INCLUDE_RP23XX_UNIQUEID_H
#define __BOARDS_ARM_RP23XX_COMMON_INCLUDE_RP23XX_UNIQUEID_H
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef __cplusplus
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: rp23xx_uniqueid_initialize
*
* Description:
* The RP23XX doesn't have a unique ID, so we load the ID from the
* connected flash chip. We use the flash ID to seed a simple xorshift
* PRNG. The PRNG then generates CONFIG_BOARDCTL_UNIQUEID_SIZE bytes,
* which we will use as the board's unique ID.
*
* Retrieving the flash id is somewhat slow and complex, so we only do
* this during initialization and store the result for later use.
*
* Assumptions/Limitations:
* This uniqueid implementation requires a flash chip. It should not be
* used on boards without flash.
*
****************************************************************************/
void rp23xx_uniqueid_initialize(void);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __BOARDS_ARM_RP23XX_COMMON_INCLUDE_RP23XX_UNIQUEID_H */

View file

@ -0,0 +1 @@
*.image

View file

@ -0,0 +1,117 @@
#############################################################################
# boards/arm/rp23xx/common/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.
#
#############################################################################
ifeq ($(CONFIG_ARCH_BOARD_COMMON),y)
CFLAGS += -DPICO_RP2040=0\
-DPICO_RP2350=1\
-DLIB_PICO_BINARY_INFO=0\
-DPICO_SECURE=1\
-D__ARM_ARCH_6M__=0
CSRCS += rp23xx_common_bringup.c
CSRCS += rp23xx_common_initialize.c
ifeq ($(CONFIG_BOARDCTL_RESET),y)
CSRCS += rp23xx_reset.c
endif
#ifeq ($(CONFIG_SPI),y)
#CSRCS += rp23xx_spi.c
#endif
#
#ifeq ($(CONFIG_RP23XX_I2C_DRIVER),y)
#CSRCS += rp23xx_i2cdev.c
#endif
#
#ifeq ($(CONFIG_RP23XX_PWM),y)
#CSRCS += rp23xx_pwmdev.c
#endif
#
#ifeq ($(CONFIG_RP23XX_SPI_DRIVER),y)
#CSRCS += rp23xx_spidev.c
#endif
#
#ifeq ($(CONFIG_RP23XX_I2S),y)
#CSRCS += rp23xx_i2sdev.c
#endif
#
#ifeq ($(CONFIG_LCD_SSD1306),y)
#CSRCS += rp23xx_ssd1306.c
#endif
#
#ifeq ($(CONFIG_LCD_ST7789),y)
#CSRCS += rp23xx_st7789.c
#endif
#
#ifeq ($(CONFIG_LCD_ST7735),y)
#CSRCS += rp23xx_st7735.c
#endif
#
#ifeq ($(CONFIG_LCD_GC9A01),y)
#CSRCS += rp23xx_gc9a01.c
#endif
#
#ifeq ($(CONFIG_USBMSC),y)
#CSRCS += rp23xx_usbmsc.c
#endif
#
#ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
#CSRCS += rp23xx_composite.c
#endif
#
#ifeq ($(CONFIG_RP23XX_SPISD),y)
# CSRCS += rp23xx_spisd.c
#endif
#
#
#ifeq ($(CONFIG_SENSORS_BMP280),y)
# CSRCS += rp23xx_bmp280.c
#endif
#
#ifeq ($(CONFIG_SENSORS_INA219),y)
# CSRCS += rp23xx_ina219.c
#endif
#
#ifeq ($(CONFIG_ENC28J60),y)
# CSRCS += rp23xx_enc28j60.c
#endif
#
#ifeq ($(CONFIG_LCD_BACKPACK),y)
# CSRCS += rp23xx_lcd_backpack.c
#endif
ifeq ($(CONFIG_BOARDCTL_UNIQUEID),y)
CSRCS += rp23xx_uniqueid.c
endif
#ifeq ($(CONFIG_NET_W5500),y)
#CSRCS += rp23xx_w5500.c
#endif
#
#ifeq ($(CONFIG_SENSORS_MAX6675),y)
# CSRCS += rp23xx_max6675.c
#endif
DEPPATH += --dep-path src
VPATH += :src
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src
endif

View file

@ -0,0 +1,505 @@
/****************************************************************************
* boards/arm/rp23xx/common/src/rp23xx_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 <nuttx/config.h>
#include <debug.h>
#include <stddef.h>
#include <string.h>
#include <sys/stat.h>
#include <nuttx/fs/fs.h>
#include <arch/board/board.h>
#include "rp23xx_pico.h"
#include "rp23xx_common_bringup.h"
#ifdef CONFIG_RP23XX_PWM
#include "rp23xx_pwm.h"
#include "rp23xx_pwmdev.h"
#endif
#if defined(CONFIG_ADC) && defined(CONFIG_RP23XX_ADC)
#include "rp23xx_adc.h"
#endif
#ifdef CONFIG_WATCHDOG
# include "rp23xx_wdt.h"
#endif
#if defined(CONFIG_RP23XX_ROMFS_ROMDISK_DEVNAME)
# include <rp23xx_romfsimg.h>
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp23xx_common_bringup
****************************************************************************/
int rp23xx_common_bringup(void)
{
int ret = 0;
#ifdef CONFIG_RP23XX_FLASH_FILE_SYSTEM
struct mtd_dev_s *mtd_dev;
#endif
#ifdef CONFIG_RP23XX_I2C_DRIVER
#ifdef CONFIG_RP23XX_I2C0
ret = board_i2cdev_initialize(0);
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize I2C0.\n");
}
#endif
#ifdef CONFIG_RP23XX_I2C1
ret = board_i2cdev_initialize(1);
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize I2C1.\n");
}
#endif
#endif
#ifdef CONFIG_RP23XX_SPI_DRIVER
#ifdef CONFIG_RP23XX_SPI0
ret = board_spidev_initialize(0);
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize SPI0.\n");
}
#endif
#ifdef CONFIG_RP23XX_SPI1
ret = board_spidev_initialize(1);
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize SPI1.\n");
}
#endif
#endif
#ifdef CONFIG_RP23XX_PWM
# ifdef CONFIG_RP23XX_PWM0
# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2
ret = rp23xx_pwmdev_initialize(0,
CONFIG_RP23XX_PWM0A_GPIO,
CONFIG_RP23XX_PWM0B_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM0A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM0B_INVERT
| RP23XX_PWM_CSR_B_INV
# endif
# ifdef CONFIG_RP23XX_PWM0_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# else
ret = rp23xx_pwmdev_initialize(0,
CONFIG_RP23XX_PWM0A_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM0A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM0_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# endif
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize PWM0.\n");
}
# endif
# ifdef CONFIG_RP23XX_PWM1
# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2
ret = rp23xx_pwmdev_initialize(1,
CONFIG_RP23XX_PWM1A_GPIO,
CONFIG_RP23XX_PWM1B_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM1A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM1B_INVERT
| RP23XX_PWM_CSR_B_INV
# endif
# ifdef CONFIG_RP23XX_PWM1_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# else
ret = rp23xx_pwmdev_initialize(1,
CONFIG_RP23XX_PWM1A_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM1A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM1_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# endif
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize PWM1.\n");
}
# endif
# ifdef CONFIG_RP23XX_PWM2
# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2
ret = rp23xx_pwmdev_initialize(2,
CONFIG_RP23XX_PWM2A_GPIO,
CONFIG_RP23XX_PWM2B_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM2A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM2B_INVERT
| RP23XX_PWM_CSR_B_INV
# endif
# ifdef CONFIG_RP23XX_PWM2_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# else
ret = rp23xx_pwmdev_initialize(2,
CONFIG_RP23XX_PWM2A_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM2A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM2_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# endif
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize PWM2.\n");
}
# endif
# ifdef CONFIG_RP23XX_PWM3
# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2
ret = rp23xx_pwmdev_initialize(3,
CONFIG_RP23XX_PWM3A_GPIO,
CONFIG_RP23XX_PWM3B_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM3A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM3B_INVERT
| RP23XX_PWM_CSR_B_INV
# endif
# ifdef CONFIG_RP23XX_PWM3_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# else
ret = rp23xx_pwmdev_initialize(3,
CONFIG_RP23XX_PWM3A_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM3A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM3_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# endif
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize PWM3.\n");
}
# endif
# ifdef CONFIG_RP23XX_PWM4
# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2
ret = rp23xx_pwmdev_initialize(4,
CONFIG_RP23XX_PWM4A_GPIO,
CONFIG_RP23XX_PWM4B_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM4A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM4B_INVERT
| RP23XX_PWM_CSR_B_INV
# endif
# ifdef CONFIG_RP23XX_PWM4_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# else
ret = rp23xx_pwmdev_initialize(4,
CONFIG_RP23XX_PWM4A_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM4A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM4_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# endif
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize PWM4.\n");
}
# endif
# ifdef CONFIG_RP23XX_PWM5
# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2
ret = rp23xx_pwmdev_initialize(5,
CONFIG_RP23XX_PWM5A_GPIO,
CONFIG_RP23XX_PWM5B_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM5A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM5B_INVERT
| RP23XX_PWM_CSR_B_INV
# endif
# ifdef CONFIG_RP23XX_PWM5_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# else
ret = rp23xx_pwmdev_initialize(5,
CONFIG_RP23XX_PWM5A_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM5A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM5_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# endif
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize PWM5.\n");
}
# endif
# ifdef CONFIG_RP23XX_PWM6
# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2
ret = rp23xx_pwmdev_initialize(6,
CONFIG_RP23XX_PWM6A_GPIO,
CONFIG_RP23XX_PWM6B_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM6A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM6B_INVERT
| RP23XX_PWM_CSR_B_INV
# endif
# ifdef CONFIG_RP23XX_PWM6_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# else
ret = rp23xx_pwmdev_initialize(6,
CONFIG_RP23XX_PWM6A_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM6A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM6_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# endif
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize PWM6.\n");
}
# endif
# ifdef CONFIG_RP23XX_PWM7
# if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2
ret = rp23xx_pwmdev_initialize(7,
CONFIG_RP23XX_PWM7A_GPIO,
CONFIG_RP23XX_PWM7B_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM7A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM7B_INVERT
| RP23XX_PWM_CSR_B_INV
# endif
# ifdef CONFIG_RP23XX_PWM7_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# else
ret = rp23xx_pwmdev_initialize(7,
CONFIG_RP23XX_PWM7A_GPIO,
(0
# ifdef CONFIG_RP23XX_PWM7A_INVERT
| RP23XX_PWM_CSR_A_INV
# endif
# ifdef CONFIG_RP23XX_PWM7_PHASE_CORRECT
| RP23XX_PWM_CSR_PH_CORRECT
# endif
));
# endif
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize PWM7.\n");
}
# endif
#endif
#ifdef CONFIG_RP23XX_SPISD
/* Mount the SPI-based MMC/SD block driver */
ret = board_spisd_initialize(0, CONFIG_RP23XX_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_RP23XX_I2S
ret = board_i2sdev_initialize(0);
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize I2S.\n");
}
#endif
#ifdef CONFIG_DEV_GPIO
ret = rp23xx_dev_gpio_init();
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret);
}
#endif
/* Initialize ADC */
#if defined(CONFIG_ADC) && defined(CONFIG_RP23XX_ADC)
# ifdef CONFIG_RP23XX_ADC_CHANNEL0
# define ADC_0 true
# else
# define ADC_0 false
# endif
# ifdef CONFIG_RP23XX_ADC_CHANNEL1
# define ADC_1 true
# else
# define ADC_1 false
# endif
# ifdef CONFIG_RP23XX_ADC_CHANNEL2
# define ADC_2 true
# else
# define ADC_2 false
# endif
# ifdef CONFIG_RP23XX_ADC_CHANNEL3
# define ADC_3 true
# else
# define ADC_3 false
# endif
# ifdef CONFIG_RP23XX_ADC_TEMPERATURE
# define ADC_TEMP true
# else
# define ADC_TEMP false
# endif
ret = rp23xx_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);
}
#endif /* defined(CONFIG_ADC) && defined(CONFIG_RP23XX_ADC) */
#ifdef CONFIG_WATCHDOG
/* Configure watchdog timer */
ret = rp23xx_wdt_init();
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: Failed to initialize watchdog drivers: %d\n",
ret);
}
#endif
#if defined(CONFIG_RP23XX_ROMFS_ROMDISK_DEVNAME)
/* Register the ROM disk */
ret = romdisk_register(CONFIG_RP23XX_ROMFS_ROMDISK_MINOR,
rp23xx_romfs_img,
NSECTORS(rp23xx_romfs_img_len),
CONFIG_RP23XX_ROMFS_ROMDISK_SECTSIZE);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: romdisk_register failed: %d\n", -ret);
}
else
{
/* Mount the file system */
ret = nx_mount(CONFIG_RP23XX_ROMFS_ROMDISK_DEVNAME,
CONFIG_RP23XX_ROMFS_MOUNT_MOUNTPOINT,
"romfs",
MS_RDONLY,
NULL);
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: nx_mount(%s,%s,romfs) failed: %d\n",
CONFIG_RP23XX_ROMFS_ROMDISK_DEVNAME,
CONFIG_RP23XX_ROMFS_MOUNT_MOUNTPOINT,
ret);
}
}
#endif
return ret;
}

View file

@ -0,0 +1,192 @@
/****************************************************************************
* boards/arm/rp23xx/common/src/23xx_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 <nuttx/config.h>
#include <debug.h>
#include <nuttx/mm/mm.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "rp23xx_gpio.h"
#include "rp23xx_uniqueid.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_MM_KERNEL_HEAP
# define MM_ADDREGION kmm_addregion
#else
# define MM_ADDREGION umm_addregion
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp23xx_common_earlyinitialize
*
* Description:
* This is the early initialization common to all RP23XX boards.
* It configures the UART pins so the system console can be used.
****************************************************************************/
void rp23xx_common_earlyinitialize(void)
{
rp23xx_gpio_initialize();
/* Disable IE on GPIO 26-29 */
hw_clear_bits(&pads_bank0_hw->io[26], PADS_BANK0_GPIO0_IE_BITS);
hw_clear_bits(&pads_bank0_hw->io[27], PADS_BANK0_GPIO0_IE_BITS);
hw_clear_bits(&pads_bank0_hw->io[28], PADS_BANK0_GPIO0_IE_BITS);
hw_clear_bits(&pads_bank0_hw->io[29], PADS_BANK0_GPIO0_IE_BITS);
/* Set default UART pin */
#ifdef CONFIG_RP23XX_UART0
rp23xx_gpio_set_function(CONFIG_RP23XX_UART0_TX_GPIO,
GPIO_FUNC_UART); /* TX */
rp23xx_gpio_set_function(CONFIG_RP23XX_UART0_RX_GPIO,
GPIO_FUNC_UART); /* RX */
#ifdef CONFIG_SERIAL_OFLOWCONTROL
rp23xx_gpio_set_function(CONFIG_RP23XX_UART0_CTS_GPIO,
GPIO_FUNC_UART); /* CTS */
#endif
#ifdef CONFIG_SERIAL_IFLOWCONTROL
rp23xx_gpio_set_function(CONFIG_RP23XX_UART0_RTS_GPIO,
GPIO_FUNC_UART); /* RTS */
#endif
#endif
#ifdef CONFIG_RP23XX_UART1
rp23xx_gpio_set_function(CONFIG_RP23XX_UART1_TX_GPIO,
GPIO_FUNC_UART); /* TX */
rp23xx_gpio_set_function(CONFIG_RP23XX_UART1_RX_GPIO,
GPIO_FUNC_UART); /* RX */
#ifdef CONFIG_SERIAL_OFLOWCONTROL
rp23xx_gpio_set_function(CONFIG_RP23XX_UART1_CTS_GPIO,
GPIO_FUNC_UART); /* CTS */
#endif
#ifdef CONFIG_SERIAL_IFLOWCONTROL
rp23xx_gpio_set_function(CONFIG_RP23XX_UART1_RTS_GPIO,
GPIO_FUNC_UART); /* RTS */
#endif
#endif
#if defined(CONFIG_RP23XX_CLK_GPOUT0)
rp23xx_gpio_set_function(RP23XX_GPIO_PIN_CLK_GPOUT0,
GPIO_FUNC_CLOCKS);
#endif
#if defined(CONFIG_RP23XX_CLK_GPOUT1)
rp23xx_gpio_set_function(RP23XX_GPIO_PIN_CLK_GPOUT1,
GPIO_FUNC_CLOCKS);
#endif
#if defined(CONFIG_RP23XX_CLK_GPOUT2)
rp23xx_gpio_set_function(RP23XX_GPIO_PIN_CLK_GPOUT2,
GPIO_FUNC_CLOCKS);
#endif
#if defined(CONFIG_RP23XX_CLK_GPOUT3)
rp23xx_gpio_set_function(RP23XX_GPIO_PIN_CLK_GPOUT3,
GPIO_FUNC_CLOCKS);
#endif
}
/****************************************************************************
* Name: rp23xx_common_initialize
*
* Description:
* It configures the pin assignments that were not done in the early
* initialization.
****************************************************************************/
void rp23xx_common_initialize(void)
{
#ifdef CONFIG_BOARDCTL_UNIQUEID
rp23xx_uniqueid_initialize();
#endif
/* Set default I2C pin */
#ifdef CONFIG_RP23XX_I2C0
rp23xx_gpio_set_function(CONFIG_RP23XX_I2C0_SDA_GPIO,
RP23XX_GPIO_FUNC_I2C); /* SDA */
rp23xx_gpio_set_function(CONFIG_RP23XX_I2C0_SCL_GPIO,
RP23XX_GPIO_FUNC_I2C); /* SCL */
rp23xx_gpio_set_pulls(CONFIG_RP23XX_I2C0_SDA_GPIO, true, false); /* Pull up */
rp23xx_gpio_set_pulls(CONFIG_RP23XX_I2C0_SCL_GPIO, true, false);
#endif
#ifdef CONFIG_RP23XX_I2C1
rp23xx_gpio_set_function(CONFIG_RP23XX_I2C1_SDA_GPIO,
RP23XX_GPIO_FUNC_I2C); /* SDA */
rp23xx_gpio_set_function(CONFIG_RP23XX_I2C1_SCL_GPIO,
RP23XX_GPIO_FUNC_I2C); /* SCL */
rp23xx_gpio_set_pulls(CONFIG_RP23XX_I2C1_SDA_GPIO, true, false); /* Pull up */
rp23xx_gpio_set_pulls(CONFIG_RP23XX_I2C1_SCL_GPIO, true, false);
#endif
/* Set default SPI pin */
#ifdef CONFIG_RP23XX_SPI0
rp23xx_gpio_set_function(CONFIG_RP23XX_SPI0_RX_GPIO,
RP23XX_GPIO_FUNC_SPI); /* RX */
rp23xx_gpio_set_function(CONFIG_RP23XX_SPI0_SCK_GPIO,
RP23XX_GPIO_FUNC_SPI); /* SCK */
rp23xx_gpio_set_function(CONFIG_RP23XX_SPI0_TX_GPIO,
RP23XX_GPIO_FUNC_SPI); /* TX */
/* CSn is controlled by board-specific logic */
rp23xx_gpio_init(CONFIG_RP23XX_SPI0_CS_GPIO); /* CSn */
rp23xx_gpio_setdir(CONFIG_RP23XX_SPI0_CS_GPIO, true);
rp23xx_gpio_put(CONFIG_RP23XX_SPI0_CS_GPIO, true);
#endif
#ifdef CONFIG_RP23XX_SPI1
rp23xx_gpio_set_function(CONFIG_RP23XX_SPI1_RX_GPIO,
RP23XX_GPIO_FUNC_SPI); /* RX */
rp23xx_gpio_set_function(CONFIG_RP23XX_SPI1_SCK_GPIO,
RP23XX_GPIO_FUNC_SPI); /* SCK */
rp23xx_gpio_set_function(CONFIG_RP23XX_SPI1_TX_GPIO,
RP23XX_GPIO_FUNC_SPI); /* TX */
/* CSn is controlled by board-specific logic */
rp23xx_gpio_init(CONFIG_RP23XX_SPI1_CS_GPIO); /* CSn */
rp23xx_gpio_setdir(CONFIG_RP23XX_SPI1_CS_GPIO, true);
rp23xx_gpio_put(CONFIG_RP23XX_SPI1_CS_GPIO, true);
#endif
}

View file

@ -0,0 +1,276 @@
/****************************************************************************
* boards/arm/rp23xx/common/src/rp23xx_composite.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 <nuttx/config.h>
#include <sys/types.h>
#include <debug.h>
#include <assert.h>
#include <nuttx/usb/usbdev.h>
#include <nuttx/usb/cdcacm.h>
#include <nuttx/usb/usbmsc.h>
#include <nuttx/usb/composite.h>
#if defined(CONFIG_BOARDCTL_USBDEVCTRL) && defined(CONFIG_USBDEV_COMPOSITE)
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef CONFIG_USBMSC_COMPOSITE
static void *g_mschandle;
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: board_mscclassobject
*
* Description:
* If the mass storage class driver is part of composite device, then
* its instantiation and configuration is a multi-step, board-specific,
* process (See comments for usbmsc_configure below). In this case,
* board-specific logic must provide board_mscclassobject().
*
* board_mscclassobject() is called from the composite driver. It must
* encapsulate the instantiation and configuration of the mass storage
* class and the return the mass storage device's class driver instance
* to the composite driver.
*
* Input Parameters:
* classdev - The location to return the mass storage class' device
* instance.
*
* Returned Value:
* 0 on success; a negated errno on failure
*
****************************************************************************/
#ifdef CONFIG_USBMSC_COMPOSITE
static int board_mscclassobject(int minor,
struct usbdev_devinfo_s *devinfo,
struct usbdevclass_driver_s **classdev)
{
int ret;
DEBUGASSERT(g_mschandle == NULL);
/* Configure the mass storage device */
uinfo("Configuring with NLUNS=1\n");
ret = usbmsc_configure(1, &g_mschandle);
if (ret < 0)
{
uerr("ERROR: usbmsc_configure failed: %d\n", -ret);
return ret;
}
uinfo("MSC handle=%p\n", g_mschandle);
/* Bind the LUN(s) */
uinfo("Bind LUN=0 to /dev/mmcsd0\n");
ret = usbmsc_bindlun(g_mschandle, "/dev/mmcsd0", 0, 0, 0, false);
if (ret < 0)
{
uerr("ERROR: usbmsc_bindlun failed for LUN 1 at /dev/mmcsd0: %d\n",
ret);
usbmsc_uninitialize(g_mschandle);
g_mschandle = NULL;
return ret;
}
/* Get the mass storage device's class object */
ret = usbmsc_classobject(g_mschandle, devinfo, classdev);
if (ret < 0)
{
uerr("ERROR: usbmsc_classobject failed: %d\n", -ret);
usbmsc_uninitialize(g_mschandle);
g_mschandle = NULL;
}
return ret;
}
#endif
/****************************************************************************
* Name: board_mscuninitialize
*
* Description:
* Un-initialize the USB storage class driver.
* This is just an application specific wrapper for usbmsc_unitialize()
* that is called form the composite device logic.
*
* Input Parameters:
* classdev - The class driver instrance previously give to the composite
* driver by board_mscclassobject().
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_USBMSC_COMPOSITE
static void board_mscuninitialize(struct usbdevclass_driver_s *classdev)
{
if (g_mschandle)
{
usbmsc_uninitialize(g_mschandle);
}
g_mschandle = NULL;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_composite_initialize
*
* Description:
* Perform architecture specific initialization of a composite USB device.
*
****************************************************************************/
int board_composite_initialize(int port)
{
return OK;
}
/****************************************************************************
* Name: board_composite_connect
*
* Description:
* Connect the USB composite device on the specified USB device port using
* the specified configuration. The interpretation of the configid is
* board specific.
*
* Input Parameters:
* port - The USB device port.
* configid - The USB composite configuration
*
* Returned Value:
* A non-NULL handle value is returned on success. NULL is returned on
* any failure.
*
****************************************************************************/
void *board_composite_connect(int port, int configid)
{
/* Here we are composing the configuration of the usb composite device.
*
* The standard is to use one CDC/ACM and one USB mass storage device.
*/
if (configid == 0)
{
struct composite_devdesc_s dev[2];
int ifnobase = 0;
int strbase = COMPOSITE_NSTRIDS;
int n = 0;
#ifdef CONFIG_USBMSC_COMPOSITE
/* Configure the mass storage device device */
/* Ask the usbmsc driver to fill in the constants we didn't
* know here.
*/
usbmsc_get_composite_devdesc(&dev[n]);
/* Overwrite and correct some values... */
/* The callback functions for the USBMSC class */
dev[n].classobject = board_mscclassobject;
dev[n].uninitialize = board_mscuninitialize;
/* Interfaces */
dev[n].devinfo.ifnobase = ifnobase; /* Offset to Interface-IDs */
dev[n].minor = 0; /* The minor interface number */
/* Strings */
dev[n].devinfo.strbase = strbase; /* Offset to String Numbers */
/* Endpoints */
dev[n].devinfo.epno[USBMSC_EP_BULKIN_IDX] = 1;
dev[n].devinfo.epno[USBMSC_EP_BULKOUT_IDX] = 2;
/* Count up the base numbers */
ifnobase += dev[n].devinfo.ninterfaces;
strbase += dev[n].devinfo.nstrings;
n++;
#endif
#ifdef CONFIG_CDCACM_COMPOSITE
/* Configure the CDC/ACM device */
/* Ask the cdcacm driver to fill in the constants we didn't
* know here.
*/
cdcacm_get_composite_devdesc(&dev[n]);
/* Overwrite and correct some values... */
/* The callback functions for the CDC/ACM class */
dev[n].classobject = cdcacm_classobject;
dev[n].uninitialize = cdcacm_uninitialize;
/* Interfaces */
dev[n].devinfo.ifnobase = ifnobase; /* Offset to Interface-IDs */
dev[n].minor = 0; /* The minor interface number */
/* Strings */
dev[n].devinfo.strbase = strbase; /* Offset to String Numbers */
/* Endpoints */
dev[n].devinfo.epno[CDCACM_EP_INTIN_IDX] = 3;
dev[n].devinfo.epno[CDCACM_EP_BULKIN_IDX] = 4;
dev[n].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = 5;
n++;
#endif
return composite_initialize(composite_getdevdescs(), dev, n);
}
else
{
return NULL;
}
}
#endif /* CONFIG_BOARDCTL_USBDEVCTRL && CONFIG_USBDEV_COMPOSITE */

View file

@ -0,0 +1,68 @@
/****************************************************************************
* boards/arm/rp23xx/common/src/rp23xx_i2cdev.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 <nuttx/config.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include "rp23xx_i2c.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_i2cdev_initialize
*
* Description:
* Initialize and register i2c driver for the specified i2c port
*
****************************************************************************/
int board_i2cdev_initialize(int port)
{
int ret;
struct i2c_master_s *i2c;
i2cinfo("Initializing /dev/i2c%d..\n", port);
/* Initialize i2c device */
i2c = rp23xx_i2cbus_initialize(port);
if (!i2c)
{
i2cerr("ERROR: Failed to initialize i2c%d.\n", port);
return -ENODEV;
}
ret = i2c_register(i2c, port);
if (ret < 0)
{
i2cerr("ERROR: Failed to register i2c%d: %d\n", port, ret);
}
return ret;
}

View file

@ -0,0 +1,95 @@
/****************************************************************************
* boards/arm/rp23xx/common/src/rp23xx_i2sdev.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 <nuttx/config.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/audio/audio.h>
#include <nuttx/audio/audio_i2s.h>
#include <nuttx/audio/i2s.h>
#include <nuttx/audio/pcm.h>
#include <arch/board/board.h>
#include "arm_internal.h"
#include "rp23xx_i2s.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_i2sdev_initialize
*
* Description:
* Initialize i2s driver and register the /dev/audio/pcm0 device.
*
****************************************************************************/
int board_i2sdev_initialize(int port)
{
struct audio_lowerhalf_s *audio_i2s;
struct audio_lowerhalf_s *pcm;
struct i2s_dev_s *i2s;
char devname[12];
int ret;
ainfo("Initializing I2S\n");
i2s = rp23xx_i2sbus_initialize(port);
#ifdef CONFIG_AUDIO_I2SCHAR
i2schar_register(i2s, 0);
#endif
audio_i2s = audio_i2s_initialize(i2s, true);
if (!audio_i2s)
{
auderr("ERROR: Failed to initialize I2S\n");
return -ENODEV;
}
pcm = pcm_decode_initialize(audio_i2s);
if (!pcm)
{
auderr("ERROR: Failed create the PCM decoder\n");
return -ENODEV;
}
snprintf(devname, 12, "pcm%d", port);
ret = audio_register(devname, pcm);
if (ret < 0)
{
auderr("ERROR: Failed to register /dev/%s device: %d\n", devname, ret);
}
return 0;
}

View file

@ -0,0 +1,101 @@
/****************************************************************************
* boards/arm/rp23xx/common/src/rp23xx_pwmdev.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 <nuttx/config.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include "rp23xx_pwm.h"
#ifdef CONFIG_RP23XX_PWM
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp23xx_pwmdev_initialize
*
* Description:
* Initialize and register spi driver for the specified pwm port
*
****************************************************************************/
#if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2
int rp23xx_pwmdev_initialize(int slice,
int pin_a,
int pin_b,
uint32_t flags)
#else
int rp23xx_pwmdev_initialize(int slice,
int pin,
uint32_t flags)
#endif
{
int ret;
struct rp23xx_pwm_lowerhalf_s *pwm_lowerhalf;
#if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2
pwminfo("Initializing /dev/pwm%d a %d b %d f 0x%08lX..\n",
slice,
pin_a,
pin_b,
flags);
#else
pwminfo("Initializing /dev/pwm%d %d 0x%08lX..\n",
slice,
pin,
flags);
#endif
/* Initialize spi device */
#if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2
pwm_lowerhalf = rp23xx_pwm_initialize(slice, pin_a, pin_b, flags);
#else
pwm_lowerhalf = rp23xx_pwm_initialize(slice, pin, flags);
#endif
if (!pwm_lowerhalf)
{
pwmerr("ERROR: Failed to initialize pwm%d.\n", slice);
return -ENODEV;
}
char path[10] = "/dev/pwmN";
path[8] = '0' + slice; /* replace "N" with slice number. */
ret = pwm_register(path, (struct pwm_lowerhalf_s *) pwm_lowerhalf);
if (ret < 0)
{
pwmerr("ERROR: Failed to register pwm%d: %d\n", slice, ret);
return -ENODEV;
}
return OK;
}
#endif /* CONFIG_RP23XX_PWM */

View file

@ -0,0 +1,61 @@
/****************************************************************************
* boards/arm/rp23xx/common/src/rp23xx_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 <nuttx/config.h>
#include <nuttx/board.h>
#include <nuttx/arch.h>
#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 */

View file

@ -0,0 +1,150 @@
/****************************************************************************
* boards/arm/rp23xx/common/src/rp23xx_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 <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/spi/spi.h>
#include <arch/board/board.h>
#include "arm_internal.h"
#include "chip.h"
#include "rp23xx_gpio.h"
#include "hardware/rp23xx_spi.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp23xx_spi0/1select and rp23xx_spi0/1status
*
* Description:
* The external functions, rp23xx_spi0/1select and rp23xx_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 rp23xx_spibus_initialize()) are provided by
* common RP23XX logic. To use this common SPI logic on your board:
*
* 1. Provide logic in rp23xx_boardinitialize() to configure SPI chip
* select pins.
* 2. Provide rp23xx_spi0/1select() and rp23xx_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 rp23xx_spibus_initialize() in your low level
* application initialization logic
* 4. The handle returned by rp23xx_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_RP23XX_SPI0
void rp23xx_spi0select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
rp23xx_gpio_put(CONFIG_RP23XX_SPI0_CS_GPIO, !selected);
}
uint8_t rp23xx_spi0status(struct spi_dev_s *dev, uint32_t devid)
{
uint8_t ret = 0;
# if defined(CONFIG_RP23XX_SPISD) && (CONFIG_RP23XX_SPISD_SPI_CH == 0)
ret = board_spisd_status(dev, devid);
# endif
return ret;
}
#ifdef CONFIG_SPI_CMDDATA
int rp23xx_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.
*/
rp23xx_gpio_put(CONFIG_RP23XX_SPI0_RX_GPIO, !cmd);
return OK;
}
#endif
return -ENODEV;
}
#endif
#endif
#ifdef CONFIG_RP23XX_SPI1
void rp23xx_spi1select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
rp23xx_gpio_put(CONFIG_RP23XX_SPI1_CS_GPIO, !selected);
}
uint8_t rp23xx_spi1status(struct spi_dev_s *dev, uint32_t devid)
{
uint8_t ret = 0;
# if defined(CONFIG_RP23XX_SPISD) && (CONFIG_RP23XX_SPISD_SPI_CH == 1)
ret = board_spisd_status(dev, devid);
# endif
return ret;
}
#ifdef CONFIG_SPI_CMDDATA
int rp23xx_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
#if defined (CONFIG_LCD_ST7789) || defined (CONFIG_LCD_ST7735) || defined (CONFIG_LCD_GC9A01)
if (devid == SPIDEV_DISPLAY(0))
{
/* This is the Data/Command control pad which determines whether the
* data bits are data or a command.
*/
rp23xx_gpio_put(CONFIG_RP23XX_SPI1_RX_GPIO, !cmd);
return OK;
}
#endif
return -ENODEV;
}
#endif
#endif

View file

@ -0,0 +1,69 @@
/****************************************************************************
* boards/arm/rp23xx/common/src/rp23xx_spidev.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 <nuttx/config.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/spi/spi_transfer.h>
#include "rp23xx_spi.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_spidev_initialize
*
* Description:
* Initialize and register spi driver for the specified spi port
*
****************************************************************************/
int board_spidev_initialize(int port)
{
int ret;
struct spi_dev_s *spi;
spiinfo("Initializing /dev/spi%d..\n", port);
/* Initialize spi device */
spi = rp23xx_spibus_initialize(port);
if (!spi)
{
spierr("ERROR: Failed to initialize spi%d.\n", port);
return -ENODEV;
}
ret = spi_register(spi, port);
if (ret < 0)
{
spierr("ERROR: Failed to register spi%d: %d\n", port, ret);
}
return ret;
}

View file

@ -0,0 +1,141 @@
/****************************************************************************
* boards/arm/rp23xx/common/src/rp23xx_uniqueid.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 <assert.h>
#include <nuttx/config.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include "pico.h"
#include "rp23xx_uniqueid.h"
#include "rp23xx_rom.h"
// #include "pico/bootrom_constants.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define SYS_INFO_CHIP_INFO 0x0001
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
static uint8_t g_uniqueid[CONFIG_BOARDCTL_UNIQUEID_SIZE];
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp23xx_uniqueid_initialize
*
* Description:
* The RP23XX doesn't have a unique ID, so we load the ID from the
* connected flash chip. We use the flash ID to seed a simple xorshift
* PRNG. The PRNG then generates CONFIG_BOARDCTL_UNIQUEID_SIZE bytes,
* which we will use as the board's unique ID.
*
* Retrieving the flash id is somewhat slow and complex, so we only do
* this during initialization and store the result for later use.
*
* Assumptions/Limitations:
* This uniqueid implementation requires a flash chip. It should not be
* used on boards without flash.
*
****************************************************************************/
void rp23xx_uniqueid_initialize(void)
{
uint64_t x;
typedef int (*rom_get_sys_info_fn)(uint32_t *out_buffer, uint32_t out_buffer_word_size, uint32_t flags);
rom_get_sys_info_fn func = (rom_get_sys_info_fn) rom_func_lookup(ROM_FUNC_GET_SYS_INFO);
union
{
uint32_t words[9];
uint8_t bytes[9 * 4];
} out;
memset(out.bytes, 0x00, 9*4);
int rc = func(out.words, 9, SYS_INFO_CHIP_INFO);
if (rc != 4)
{
PANIC();
}
/* xorshift PRNG: */
x = *(uint64_t *)(out.bytes);
for (int i = 0; i < CONFIG_BOARDCTL_UNIQUEID_SIZE; i++)
{
x ^= x >> 12;
x ^= x << 25;
x ^= x >> 27;
g_uniqueid[i] = (uint8_t)((x * 0x2545f4914f6cdd1dull) >> 32);
}
}
/****************************************************************************
* Name: board_uniqueid
*
* Description:
* Return a unique ID associated with the board.
*
* Input Parameters:
* uniqueid - A reference to a writable memory location provided by the
* caller to receive the board unique ID. The memory memory referenced
* by this pointer must be at least CONFIG_BOARDCTL_UNIQUEID_SIZE in
* length.
*
* Returned Value:
* Zero (OK) is returned on success. Otherwize a negated errno value is
* returned indicating the nature of the failure.
*
****************************************************************************/
int board_uniqueid(FAR uint8_t *uniqueid)
{
memcpy(uniqueid, g_uniqueid, CONFIG_BOARDCTL_UNIQUEID_SIZE);
return OK;
}

View file

@ -0,0 +1,61 @@
/****************************************************************************
* boards/arm/rp23xx/common/src/rp23xx_usbmsc.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 <nuttx/config.h>
#include <stdio.h>
#include <syslog.h>
#include <errno.h>
#include <nuttx/board.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_usbmsc_initialize
*
* Description:
* Perform architecture specific initialization as needed to establish
* the mass storage device that will be exported by the USB MSC device.
*
****************************************************************************/
int board_usbmsc_initialize(int port)
{
/* If system/usbmsc is built as an NSH command, then SD slot should
* already have been initialized in board_app_initialize()
* (see stm32_appinit.c).
* In this case, there is nothing further to be done here.
*/
return OK;
}

View file

@ -0,0 +1,8 @@
#
# 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_2_2
endif

View file

@ -0,0 +1,47 @@
#
# 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_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-2"
CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_2=y
CONFIG_ARCH_CHIP="rp23xx"
CONFIG_ARCH_CHIP_RP23XX=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=532480
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

View file

@ -0,0 +1,51 @@
#
# 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_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_RP23XX_UART0 is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="raspberrypi-pico-2"
CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_2=y
CONFIG_ARCH_CHIP="rp23xx"
CONFIG_ARCH_CHIP_RP23XX=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=532480
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

View file

@ -0,0 +1,51 @@
#
# 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_ARCH_LEDS 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-2"
CONFIG_ARCH_BOARD_RASPBERRYPI_PICO_2=y
CONFIG_ARCH_CHIP="rp23xx"
CONFIG_ARCH_CHIP_RP23XX=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_LEDS=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=532480
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
CONFIG_USERLED=y
CONFIG_USERLED_LOWER=y

View file

@ -0,0 +1,170 @@
/****************************************************************************
* boards/arm/rp23xx/raspberrypi-pico-2/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_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_BOARD_H
#define __BOARDS_ARM_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_BOARD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "rp23xx_i2cdev.h"
#include "rp23xx_spidev.h"
#include "rp23xx_i2sdev.h"
#ifndef __ASSEMBLY__
# include <stdint.h>
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Clocking *****************************************************************/
#define MHZ 1000000
#define BOARD_XOSC_FREQ (12 * MHZ)
#define BOARD_PLL_SYS_FREQ (150 * MHZ)
#define BOARD_PLL_USB_FREQ (48 * MHZ)
#define BOARD_REF_FREQ (12 * MHZ)
#define BOARD_SYS_FREQ (150 * MHZ)
#define BOARD_PERI_FREQ (150 * MHZ)
#define BOARD_USB_FREQ (48 * MHZ)
#define BOARD_ADC_FREQ (48 * MHZ)
#define BOARD_UART_BASEFREQ BOARD_PERI_FREQ
#define BOARD_TICK_CLOCK (1 * MHZ)
/* definitions for pico-sdk */
/* QFN-60 package */
#define PICO_RP2350A 1
/* GPIO definitions *********************************************************/
#define BOARD_GPIO_LED_PIN 25
#define BOARD_NGPIOOUT 1
#define BOARD_NGPIOIN 1
#define BOARD_NGPIOINT 1
/* LED definitions **********************************************************/
/* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs
* in any way. The following definitions are used to access individual LEDs.
*/
/* LED index values for use with board_userled() */
#define BOARD_LED1 0
#define BOARD_NLEDS 1
#define BOARD_LED_GREEN BOARD_LED1
/* LED bits for use with board_userled_all() */
#define BOARD_LED1_BIT (1 << BOARD_LED1)
/* This LED is not used by the board port unless CONFIG_ARCH_LEDS is
* defined. In that case, the usage by the board port is defined in
* include/board.h and src/rp23xx_autoleds.c. The LED is used to encode
* OS-related events as follows:
*
* -------------------- ----------------------------- ------
* SYMBOL Meaning LED
* -------------------- ----------------------------- ------
*/
#define LED_STARTED 0 /* NuttX has been started OFF */
#define LED_HEAPALLOCATE 0 /* Heap has been allocated OFF */
#define LED_IRQSENABLED 0 /* Interrupts enabled OFF */
#define LED_STACKCREATED 1 /* Idle stack created ON */
#define LED_INIRQ 2 /* In an interrupt N/C */
#define LED_SIGNAL 2 /* In a signal handler N/C */
#define LED_ASSERTION 2 /* An assertion failed N/C */
#define LED_PANIC 3 /* The system has crashed FLASH */
#undef LED_IDLE /* Not used */
/* Thus if the LED is statically on, NuttX has successfully booted and is,
* apparently, running normally. If the LED is flashing at approximately
* 2Hz, then a fatal error has been detected and the system has halted.
*/
/* BUTTON definitions *******************************************************/
#define NUM_BUTTONS 0
#define BUTTON_USER1 0
#define BUTTON_USER2 1
#define BUTTON_USER1_BIT (1 << BUTTON_USER1)
#define BUTTON_USER2_BIT (1 << BUTTON_USER2)
/****************************************************************************
* 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: rp23xx_boardearlyinitialize
*
* Description:
*
****************************************************************************/
void rp23xx_boardearlyinitialize(void);
/****************************************************************************
* Name: rp23xx_boardinitialize
*
* Description:
*
****************************************************************************/
void rp23xx_boardinitialize(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_BOARD_H */

View file

@ -0,0 +1,72 @@
/****************************************************************************
* boards/arm/rp23xx/raspberrypi-pico-2/include/rp23xx_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_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_RP23XX_I2CDEV_H
#define __BOARDS_ARM_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_RP23XX_I2CDEV_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
/****************************************************************************
* 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_RP23XX_I2C_DRIVER
int board_i2cdev_initialize(int bus);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_RP23XX_I2CDEV_H */

View file

@ -0,0 +1,72 @@
/****************************************************************************
* boards/arm/rp23xx/raspberrypi-pico-2/include/rp23xx_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_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_RP23XX_I2SDEV_H
#define __BOARDS_ARM_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_RP23XX_I2SDEV_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
/****************************************************************************
* 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_RP23XX_I2S
int board_i2sdev_initialize(int bus);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_RP23XX_I2SDEV_H */

View file

@ -0,0 +1,69 @@
/****************************************************************************
* boards/arm/rp23xx/raspberrypi-pico-2/include/rp23xx_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_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_RP23XX_SPIDEV_H
#define __BOARDS_ARM_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_RP23XX_SPIDEV_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* 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_RP23XX_RASPBERRYPI_PICO_2_INCLUDE_RP23XX_SPIDEV_H */

View file

@ -0,0 +1,46 @@
############################################################################
# boards/arm/rp23xx/raspberrypi-pico-2/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)/arch/arm/src/armv8-m/Toolchain.defs
ifeq ($(CONFIG_BOOT_RUNFROMFLASH),y)
LDSCRIPT = memmap_default.ld
else ifeq ($(CONFIG_BOOT_COPYTORAM),y)
LDSCRIPT = memmap_copy_to_ram.ld
else
LDSCRIPT = memmap_no_flash.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

View file

@ -0,0 +1,309 @@
/* Based on GCC ARM embedded samples.
Defines the following symbols for use by code:
__exidx_start
__exidx_end
__etext
__data_start__
__preinit_array_start
__preinit_array_end
__init_array_start
__init_array_end
__fini_array_start
__fini_array_end
__data_end__
__bss_start__
__bss_end__
__end__
end
__HeapLimit
__StackLimit
__StackTop
__stack (== StackTop)
*/
MEMORY
{
FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 4096k
RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 512k
SCRATCH_X(rwx) : ORIGIN = 0x20080000, LENGTH = 4k
SCRATCH_Y(rwx) : ORIGIN = 0x20081000, LENGTH = 4k
}
ENTRY(_entry_point)
SECTIONS
{
/* Second stage bootloader is prepended to the image. It must be 256 bytes big
and checksummed. It is usually built by the boot_stage2 target
in the Raspberry Pi Pico SDK
*/
.flash_begin : {
__flash_binary_start = .;
} > FLASH
/* The bootrom will enter the image at the point indicated in your
IMAGE_DEF, which is usually the reset handler of your vector table.
The debugger will use the ELF entry point, which is the _entry_point
symbol, and in our case is *different from the bootrom's entry point.*
This is used to go back through the bootrom on debugger launches only,
to perform the same initial flash setup that would be performed on a
cold boot.
*/
.flashtext : {
__logical_binary_start = .;
KEEP (*(.vectors))
KEEP (*(.binary_info_header))
__binary_info_header_end = .;
KEEP (*(.embedded_block))
__embedded_block_end = .;
KEEP (*(.reset))
. = ALIGN(4);
} > FLASH
/* Note the boot2 section is optional, and should be discarded if there is
no reference to it *inside* the binary, as it is not called by the
bootrom. (The bootrom performs a simple best-effort XIP setup and
leaves it to the binary to do anything more sophisticated.) However
there is still a size limit of 256 bytes, to ensure the boot2 can be
stored in boot RAM.
Really this is a "XIP setup function" -- the name boot2 is historic and
refers to its dual-purpose on RP2040, where it also handled vectoring
from the bootrom into the user image.
*/
.boot2 : {
__boot2_start__ = .;
*(.boot2)
__boot2_end__ = .;
} > FLASH
ASSERT(__boot2_end__ - __boot2_start__ <= 256,
"ERROR: Pico second stage bootloader must be no more than 256 bytes in size")
.rodata : {
/* segments not marked as .flashdata are instead pulled into .data (in RAM) to avoid accidental flash accesses */
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*)))
. = ALIGN(4);
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
/* Machine inspectable binary information */
. = ALIGN(4);
__binary_info_start = .;
.binary_info :
{
KEEP(*(.binary_info.keep.*))
*(.binary_info.*)
} > FLASH
__binary_info_end = .;
. = ALIGN(4);
/* Vector table goes first in RAM, to avoid large alignment hole */
.ram_vector_table (NOLOAD): {
*(.ram_vector_table)
} > RAM
.uninitialized_data (NOLOAD): {
. = ALIGN(4);
*(.uninitialized_data*)
} > RAM
.text : {
__ram_text_start__ = .;
*(.init)
*(.text*)
*(.fini)
/* Pull all c'tors into .text */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* Followed by destructors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.eh_frame*)
. = ALIGN(4);
__ram_text_end__ = .;
} > RAM AT> FLASH
__ram_text_source__ = LOADADDR(.text);
. = ALIGN(4);
.data : {
__data_start__ = .;
*(vtable)
*(.time_critical*)
. = ALIGN(4);
*(.rodata*)
*(.srodata*)
. = ALIGN(4);
*(.data*)
*(.sdata*)
. = ALIGN(4);
*(.after_data.*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__mutex_array_start = .);
KEEP(*(SORT(.mutex_array.*)))
KEEP(*(.mutex_array))
PROVIDE_HIDDEN (__mutex_array_end = .);
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(SORT(.preinit_array.*)))
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
*(SORT(.fini_array.*))
*(.fini_array)
PROVIDE_HIDDEN (__fini_array_end = .);
*(.jcr)
. = ALIGN(4);
} > RAM AT> FLASH
.tdata : {
. = ALIGN(4);
*(.tdata .tdata.* .gnu.linkonce.td.*)
/* All data end */
__tdata_end = .;
} > RAM AT> FLASH
PROVIDE(__data_end__ = .);
/* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */
__etext = LOADADDR(.data);
.tbss (NOLOAD) : {
. = ALIGN(4);
__bss_start__ = .;
__tls_base = .;
*(.tbss .tbss.* .gnu.linkonce.tb.*)
*(.tcommon)
__tls_end = .;
} > RAM
.bss : {
. = ALIGN(4);
__tbss_end = .;
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)))
*(COMMON)
PROVIDE(__global_pointer$ = . + 2K);
*(.sbss*)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
.heap (NOLOAD):
{
__end__ = .;
end = __end__;
KEEP(*(.heap*))
/* historically on GCC sbrk was growing past __HeapLimit to __StackLimit, however
to be more compatible, we now set __HeapLimit explicitly to where the end of the heap is */
. = ORIGIN(RAM) + LENGTH(RAM);
__HeapLimit = .;
} > RAM
/* Start and end symbols must be word-aligned */
.scratch_x : {
__scratch_x_start__ = .;
*(.scratch_x.*)
. = ALIGN(4);
__scratch_x_end__ = .;
} > SCRATCH_X AT > FLASH
__scratch_x_source__ = LOADADDR(.scratch_x);
.scratch_y : {
__scratch_y_start__ = .;
*(.scratch_y.*)
. = ALIGN(4);
__scratch_y_end__ = .;
} > SCRATCH_Y AT > FLASH
__scratch_y_source__ = LOADADDR(.scratch_y);
/* .stack*_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later
*
* stack1 section may be empty/missing if platform_launch_core1 is not used */
/* by default we put core 0 stack at the end of scratch Y, so that if core 1
* stack is not used then all of SCRATCH_X is free.
*/
.stack1_dummy (NOLOAD):
{
*(.stack1*)
} > SCRATCH_X
.stack_dummy (NOLOAD):
{
KEEP(*(.stack*))
} > SCRATCH_Y
.flash_end : {
KEEP(*(.embedded_end_block*))
PROVIDE(__flash_binary_end = .);
} > FLASH =0xaa
/* stack limit is poorly named, but historically is maximum heap ptr */
__StackLimit = ORIGIN(RAM) + LENGTH(RAM);
__StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X);
__StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y);
__StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy);
__StackBottom = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* picolibc and LLVM */
PROVIDE (__heap_start = __end__);
PROVIDE (__heap_end = __HeapLimit);
PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) );
PROVIDE( __tls_size_align = (__tls_size + __tls_align - 1) & ~(__tls_align - 1));
PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) );
/* llvm-libc */
PROVIDE (_end = __end__);
PROVIDE (__llvm_libc_heap_limit = __HeapLimit);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed")
ASSERT( __binary_info_header_end - __logical_binary_start <= 1024, "Binary info must be in first 1024 bytes of the binary")
ASSERT( __embedded_block_end - __logical_binary_start <= 4096, "Embedded block must be in first 4096 bytes of the binary")
/* todo assert on extra code */
}

View file

@ -0,0 +1,322 @@
/* Based on GCC ARM embedded samples.
Defines the following symbols for use by code:
__exidx_start
__exidx_end
__etext
__data_start__
__preinit_array_start
__preinit_array_end
__init_array_start
__init_array_end
__fini_array_start
__fini_array_end
__data_end__
__bss_start__
__bss_end__
__end__
end
__HeapLimit
__StackLimit
__StackTop
__stack (== StackTop)
*/
MEMORY
{
FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 4096k
RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 512k
SCRATCH_X(rwx) : ORIGIN = 0x20080000, LENGTH = 4k
SCRATCH_Y(rwx) : ORIGIN = 0x20081000, LENGTH = 4k
}
ENTRY(_entry_point)
SECTIONS
{
.flash_begin : {
__flash_binary_start = .;
} > FLASH
/* The bootrom will enter the image at the point indicated in your
IMAGE_DEF, which is usually the reset handler of your vector table.
The debugger will use the ELF entry point, which is the _entry_point
symbol, and in our case is *different from the bootrom's entry point.*
This is used to go back through the bootrom on debugger launches only,
to perform the same initial flash setup that would be performed on a
cold boot.
*/
.text : {
__logical_binary_start = .;
_stext = ABSOLUTE(.);
KEEP (*(.vectors))
LONG(0xffffded3)
LONG(0x10210142)
LONG(0x000001ff)
LONG(0x00000000)
LONG(0xab123579)
KEEP (*(.binary_info_header))
__binary_info_header_end = .;
KEEP (*(.embedded_block))
__embedded_block_end = .;
KEEP (*(.reset))
/* TODO revisit this now memset/memcpy/float in ROM */
/* bit of a hack right now to exclude all floating point and time critical (e.g. memset, memcpy) code from
* FLASH ... we will include any thing excluded here in .data below by default */
*(.init)
*libgcc.a:cmse_nonsecure_call.o
*(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .text*)
*(.fini)
/* Pull all c'tors into .text */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* Followed by destructors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(SORT(.preinit_array.*)))
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
*(SORT(.fini_array.*))
*(.fini_array)
PROVIDE_HIDDEN (__fini_array_end = .);
*(.eh_frame*)
. = ALIGN(4);
_etext = ABSOLUTE(.);
} > FLASH
/* Note the boot2 section is optional, and should be discarded if there is
no reference to it *inside* the binary, as it is not called by the
bootrom. (The bootrom performs a simple best-effort XIP setup and
leaves it to the binary to do anything more sophisticated.) However
there is still a size limit of 256 bytes, to ensure the boot2 can be
stored in boot RAM.
Really this is a "XIP setup function" -- the name boot2 is historic and
refers to its dual-purpose on RP2040, where it also handled vectoring
from the bootrom into the user image.
*/
.boot2 : {
__boot2_start__ = .;
*(.boot2)
__boot2_end__ = .;
} > FLASH
ASSERT(__boot2_end__ - __boot2_start__ <= 256,
"ERROR: Pico second stage bootloader must be no more than 256 bytes in size")
.rodata : {
*(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .rodata*)
*(.srodata*)
. = ALIGN(4);
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*)))
. = ALIGN(4);
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
/* Machine inspectable binary information */
. = ALIGN(4);
__binary_info_start = .;
.binary_info :
{
KEEP(*(.binary_info.keep.*))
*(.binary_info.*)
} > FLASH
_eronly = ABSOLUTE(.);
__binary_info_end = .;
. = ALIGN(4);
.ram_vector_table (NOLOAD): {
*(.ram_vector_table)
} > RAM
.uninitialized_data (NOLOAD): {
. = ALIGN(4);
*(.uninitialized_data*)
} > RAM
.data : {
__data_start__ = .;
_sdata = ABSOLUTE(.);
*(vtable)
*(.time_critical*)
/* remaining .text and .rodata; i.e. stuff we exclude above because we want it in RAM */
*(.text*)
. = ALIGN(4);
*(.rodata*)
. = ALIGN(4);
*(.data*)
*(.sdata*)
. = ALIGN(4);
*(.after_data.*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__mutex_array_start = .);
KEEP(*(SORT(.mutex_array.*)))
KEEP(*(.mutex_array))
PROVIDE_HIDDEN (__mutex_array_end = .);
*(.jcr)
. = ALIGN(4);
_edata = ABSOLUTE(.);
} > RAM AT> FLASH
.tdata : {
_stdata = ABSOLUTE(.);
. = ALIGN(4);
*(.tdata .tdata.* .gnu.linkonce.td.*)
/* All data end */
__tdata_end = .;
_etdata = ABSOLUTE(.);
} > RAM AT> FLASH
PROVIDE(__data_end__ = .);
/* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */
__etext = LOADADDR(.data);
.tbss (NOLOAD) : {
_stbss = ABSOLUTE(.);
. = ALIGN(4);
__bss_start__ = .;
_sbss = ABSOLUTE(.);
__tls_base = .;
*(.tbss .tbss.* .gnu.linkonce.tb.*)
*(.tcommon)
__tls_end = .;
_etbss = ABSOLUTE(.);
} > RAM
.bss (NOLOAD) : {
. = ALIGN(4);
__tbss_end = .;
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)))
*(COMMON)
PROVIDE(__global_pointer$ = . + 2K);
*(.sbss*)
. = ALIGN(4);
__bss_end__ = .;
_ebss = ABSOLUTE(.);
} > RAM
.heap (NOLOAD):
{
__end__ = .;
end = __end__;
KEEP(*(.heap*))
/* historically on GCC sbrk was growing past __HeapLimit to __StackLimit, however
to be more compatible, we now set __HeapLimit explicitly to where the end of the heap is */
. = ORIGIN(RAM) + LENGTH(RAM);
__HeapLimit = .;
} > RAM
/* Start and end symbols must be word-aligned */
.scratch_x : {
__scratch_x_start__ = .;
*(.scratch_x.*)
. = ALIGN(4);
__scratch_x_end__ = .;
} > SCRATCH_X AT > FLASH
__scratch_x_source__ = LOADADDR(.scratch_x);
.scratch_y : {
__scratch_y_start__ = .;
*(.scratch_y.*)
. = ALIGN(4);
__scratch_y_end__ = .;
} > SCRATCH_Y AT > FLASH
__scratch_y_source__ = LOADADDR(.scratch_y);
/* .stack*_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later
*
* stack1 section may be empty/missing if platform_launch_core1 is not used */
/* by default we put core 0 stack at the end of scratch Y, so that if core 1
* stack is not used then all of SCRATCH_X is free.
*/
.stack1_dummy (NOLOAD):
{
*(.stack1*)
} > SCRATCH_X
.stack_dummy (NOLOAD):
{
KEEP(*(.stack*))
} > SCRATCH_Y
.flash_end : {
KEEP(*(.embedded_end_block*))
PROVIDE(__flash_binary_end = .);
} > FLASH =0xaa
/* stack limit is poorly named, but historically is maximum heap ptr */
__StackLimit = ORIGIN(RAM) + LENGTH(RAM);
__StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X);
__StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y);
__StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy);
__StackBottom = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* picolibc and LLVM */
PROVIDE (__heap_start = __end__);
PROVIDE (__heap_end = __HeapLimit);
PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) );
PROVIDE( __tls_size_align = (__tls_size + __tls_align - 1) & ~(__tls_align - 1));
PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) );
/* llvm-libc */
PROVIDE (_end = __end__);
PROVIDE (__llvm_libc_heap_limit = __HeapLimit);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed")
ASSERT( __binary_info_header_end - __logical_binary_start <= 1024, "Binary info must be in first 1024 bytes of the binary")
ASSERT( __embedded_block_end - __logical_binary_start <= 4096, "Embedded block must be in first 4096 bytes of the binary")
/* todo assert on extra code */
}

View file

@ -0,0 +1,263 @@
/* Based on GCC ARM embedded samples.
Defines the following symbols for use by code:
__exidx_start
__exidx_end
__etext
__data_start__
__preinit_array_start
__preinit_array_end
__init_array_start
__init_array_end
__fini_array_start
__fini_array_end
__data_end__
__bss_start__
__bss_end__
__end__
end
__HeapLimit
__StackLimit
__StackTop
__stack (== StackTop)
*/
MEMORY
{
RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 512k
SCRATCH_X(rwx) : ORIGIN = 0x20080000, LENGTH = 4k
SCRATCH_Y(rwx) : ORIGIN = 0x20081000, LENGTH = 4k
}
ENTRY(_entry_point)
SECTIONS
{
/* Note unlike RP2040, we start the image with a vector table even for
NO_FLASH builds. On Arm, the bootrom expects a VT at the start of the
image by default; on RISC-V, the default is to enter the image at its
lowest address, so an IMAGEDEF item is required to specify the
nondefault entry point. */
.text : {
__logical_binary_start = .;
_stext = ABSOLUTE(.);
/* Vectors require 512-byte alignment on v8-M when >48 IRQs are used,
so we would waste RAM if the vector table were not at the
start. */
KEEP (*(.vectors))
KEEP (*(.binary_info_header))
__binary_info_header_end = .;
KEEP (*(.embedded_block))
__embedded_block_end = .;
__reset_start = .;
KEEP (*(.reset))
__reset_end = .;
*(.time_critical*)
*(.text*)
. = ALIGN(4);
*(.init)
*(.fini)
/* Pull all c'tors into .text */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* Followed by destructors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.eh_frame*)
} > RAM
.rodata : {
. = ALIGN(4);
*(.rodata*)
*(.srodata*)
. = ALIGN(4);
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*)))
. = ALIGN(4);
} > RAM
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > RAM
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > RAM
__exidx_end = .;
/* Machine inspectable binary information */
. = ALIGN(4);
__binary_info_start = .;
.binary_info :
{
KEEP(*(.binary_info.keep.*))
*(.binary_info.*)
} > RAM
__binary_info_end = .;
. = ALIGN(4);
.data : {
__data_start__ = .;
*(vtable)
*(.data*)
*(.sdata*)
. = ALIGN(4);
*(.after_data.*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__mutex_array_start = .);
KEEP(*(SORT(.mutex_array.*)))
KEEP(*(.mutex_array))
PROVIDE_HIDDEN (__mutex_array_end = .);
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(SORT(.preinit_array.*)))
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
*(SORT(.fini_array.*))
*(.fini_array)
PROVIDE_HIDDEN (__fini_array_end = .);
*(.jcr)
. = ALIGN(4);
} > RAM
.tdata : {
. = ALIGN(4);
*(.tdata .tdata.* .gnu.linkonce.td.*)
/* All data end */
__tdata_end = .;
} > RAM
PROVIDE(__data_end__ = .);
.uninitialized_data (NOLOAD): {
. = ALIGN(4);
*(.uninitialized_data*)
} > RAM
/* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */
__etext = LOADADDR(.data);
_etext = LOADADDR(.data);
.tbss (NOLOAD) : {
. = ALIGN(4);
__bss_start__ = .;
_stbss = ABSOLUTE(.);
__tls_base = .;
*(.tbss .tbss.* .gnu.linkonce.tb.*)
*(.tcommon)
__tls_end = .;
_etbss = ABSOLUTE(.);
} > RAM
.bss (NOLOAD) : {
. = ALIGN(4);
_sbss = ABSOLUTE(.);
__tbss_end = .;
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)))
*(COMMON)
PROVIDE(__global_pointer$ = . + 2K);
*(.sbss*)
. = ALIGN(4);
__bss_end__ = .;
_ebss = ABSOLUTE(.);
} > RAM
.heap (NOLOAD):
{
__end__ = .;
end = __end__;
KEEP(*(.heap*))
/* historically on GCC sbrk was growing past __HeapLimit to __StackLimit, however
to be more compatible, we now set __HeapLimit explicitly to where the end of the heap is */
. = ORIGIN(RAM) + LENGTH(RAM);
__HeapLimit = .;
} > RAM
/* Start and end symbols must be word-aligned */
.scratch_x : {
__scratch_x_start__ = .;
*(.scratch_x.*)
. = ALIGN(4);
__scratch_x_end__ = .;
} > SCRATCH_X
__scratch_x_source__ = LOADADDR(.scratch_x);
.scratch_y : {
__scratch_y_start__ = .;
*(.scratch_y.*)
. = ALIGN(4);
__scratch_y_end__ = .;
} > SCRATCH_Y
__scratch_y_source__ = LOADADDR(.scratch_y);
/* .stack*_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later
*
* stack1 section may be empty/missing if platform_launch_core1 is not used */
/* by default we put core 0 stack at the end of scratch Y, so that if core 1
* stack is not used then all of SCRATCH_X is free.
*/
.stack1_dummy (NOLOAD):
{
*(.stack1*)
} > SCRATCH_X
.stack_dummy (NOLOAD):
{
KEEP(*(.stack*))
} > SCRATCH_Y
/* stack limit is poorly named, but historically is maximum heap ptr */
__StackLimit = ORIGIN(RAM) + LENGTH(RAM);
__StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X);
__StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y);
__StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy);
__StackBottom = __StackTop - SIZEOF(.stack_dummy);
PROVIDE(__stack = __StackTop);
/* picolibc and LLVM */
PROVIDE (__heap_start = __end__);
PROVIDE (__heap_end = __HeapLimit);
PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) );
PROVIDE( __tls_size_align = (__tls_size + __tls_align - 1) & ~(__tls_align - 1));
PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) );
/* llvm-libc */
PROVIDE (_end = __end__);
PROVIDE (__llvm_libc_heap_limit = __HeapLimit);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed")
ASSERT( __binary_info_header_end - __logical_binary_start <= 1024, "Binary info must be in first 1024 bytes of the binary")
ASSERT( __embedded_block_end - __logical_binary_start <= 4096, "Embedded block must be in first 4096 bytes of the binary")
/* todo assert on extra code */
}

View file

@ -0,0 +1,43 @@
############################################################################
# boards/arm/rp23xx/raspberrypi-pico-2/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 = rp23xx_boardinitialize.c
CSRCS += rp23xx_appinit.c
CSRCS += rp23xx_bringup.c
ifeq ($(CONFIG_DEV_GPIO),y)
CSRCS += rp23xx_gpio.c
endif
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += rp23xx_autoleds.c
else
CSRCS += rp23xx_userleds.c
endif
ifeq ($(CONFIG_ARCH_BUTTONS),y)
CSRCS += rp23xx_buttons.c
endif
DEPPATH += --dep-path board
VPATH += :board
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board

View file

@ -0,0 +1,76 @@
/****************************************************************************
* boards/arm/rp23xx/raspberrypi-pico-2/src/rp23xx_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 <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/board.h>
#include "rp23xx_pico.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* 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 rp23xx_bringup();
#endif
}

View file

@ -0,0 +1,165 @@
/****************************************************************************
* boards/arm/rp23xx/raspberrypi-pico-2/src/rp23xx_autoleds.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.
*
****************************************************************************/
/* There are four LED status indicators located on the EVK Board. The
* functions of these LEDs include:
*
* - Main Power Supply(D3)
* Green: DC 5V main supply is normal.
* Red: J2 input voltage is over 5.6V.
* Off: The board is not powered.
* - Reset RED LED(D15)
* - OpenSDA LED(D16)
* - USER LED(D18)
*
* Only a single LED, D18, is under software control.
*
* This LED is not used by the board port unless CONFIG_ARCH_LEDS is
* defined. In that case, the usage by the board port is defined in
* include/board.h and src/rp23xx_autoleds.c. The LED is used to encode
* OS-related events as follows:
*
* -------------------- ----------------------- ------
* SYMBOL Meaning LED
* -------------------- ----------------------- ------
*
* LED_STARTED 0 NuttX has been started OFF
* LED_HEAPALLOCATE 0 Heap has been allocated OFF
* LED_IRQSENABLED 0 Interrupts enabled OFF
* LED_STACKCREATED 1 Idle stack created ON
* LED_INIRQ 2 In an interrupt N/C
* LED_SIGNAL 2 In a signal handler N/C
* LED_ASSERTION 2 An assertion failed N/C
* LED_PANIC 3 The system has crashed FLASH
* LED_IDLE Not used
*
* Thus if the LED is statically on, NuttX has successfully booted and is,
* apparently, running normally. If the LED is flashing at approximately
* 2Hz, then a fatal error has been detected and the system has halted.
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "rp23xx_gpio.h"
#include "rp23xx_pico.h"
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp23xx_autoled_initialize
*
* Description:
* Initialize NuttX-controlled LED logic
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
void board_autoled_initialize(void)
{
/* Configure LED GPIO for output */
rp23xx_gpio_init(GPIO_LED1);
rp23xx_gpio_setdir(GPIO_LED1, true);
}
/****************************************************************************
* Name: board_autoled_on
*
* Description:
* Turn on the "logical" LED state
*
* Input Parameters:
* led - Identifies the "logical" LED state (see definitions in
* include/board.h)
*
* Returned Value:
* None
*
****************************************************************************/
void board_autoled_on(int led)
{
bool ledon = true;
switch (led)
{
case 0: /* LED Off */
ledon = false;
break;
case 2: /* LED No change */
return;
case 1: /* LED On */
case 3: /* LED On */
break;
}
rp23xx_gpio_put(GPIO_LED1, ledon); /* High illuminates */
}
/****************************************************************************
* Name: board_autoled_off
*
* Description:
* Turn off the "logical" LED state
*
* Input Parameters:
* led - Identifies the "logical" LED state (see definitions in
* include/board.h)
*
* Returned Value:
* None
*
****************************************************************************/
void board_autoled_off(int led)
{
switch (led)
{
case 0: /* LED Off */
case 1: /* LED Off */
case 3: /* LED Off */
break;
case 2: /* LED No change */
return;
}
rp23xx_gpio_put(GPIO_LED1, false); /* High illuminates */
}
#endif /* CONFIG_ARCH_LEDS */

View file

@ -0,0 +1,94 @@
/****************************************************************************
* boards/arm/rp23xx/raspberrypi-pico-2/src/rp23xx_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 <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "rp23xx_gpio.h"
#ifdef CONFIG_RP23XX_PSRAM
#include "rp23xx_psram.h"
#endif
#ifdef CONFIG_ARCH_BOARD_COMMON
#include "rp23xx_common_initialize.h"
#endif /* CONFIG_ARCH_BOARD_COMMON */
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp23xx_boardearlyinitialize
*
* Description:
*
****************************************************************************/
void rp23xx_boardearlyinitialize(void)
{
#ifdef CONFIG_ARCH_BOARD_COMMON
rp23xx_common_earlyinitialize();
#endif
/* --- Place any board specific early initialization here --- */
/* Set board LED pin */
rp23xx_gpio_init(BOARD_GPIO_LED_PIN);
rp23xx_gpio_setdir(BOARD_GPIO_LED_PIN, true);
rp23xx_gpio_put(BOARD_GPIO_LED_PIN, true);
}
/****************************************************************************
* Name: rp23xx_boardinitialize
*
* Description:
*
****************************************************************************/
void rp23xx_boardinitialize(void)
{
#ifdef CONFIG_ARCH_BOARD_COMMON
rp23xx_common_initialize();
#endif
#ifdef CONFIG_RP23XX_PSRAM
rp23xx_psramconfig();
#endif
/* --- Place any board specific initialization here --- */
}

View file

@ -0,0 +1,88 @@
/****************************************************************************
* boards/arm/rp23xx/raspberrypi-pico-2/src/rp23xx_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 <nuttx/config.h>
#include <debug.h>
#include <stddef.h>
#include <nuttx/fs/fs.h>
#include <arch/board/board.h>
#include "rp23xx_pico.h"
#ifdef CONFIG_ARCH_BOARD_COMMON
#include "rp23xx_common_bringup.h"
#endif /* CONFIG_ARCH_BOARD_COMMON */
#ifdef CONFIG_USERLED
# include <nuttx/leds/userled.h>
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp23xx_bringup
****************************************************************************/
int rp23xx_bringup(void)
{
#ifdef CONFIG_ARCH_BOARD_COMMON
int ret = rp23xx_common_bringup();
if (ret < 0)
{
return ret;
}
#endif /* CONFIG_ARCH_BOARD_COMMON */
/* --- Place any board specific bringup code here --- */
#ifdef CONFIG_USERLED
/* Register the LED driver */
ret = userled_lower_initialize("/dev/userleds");
if (ret < 0)
{
syslog(LOG_ERR, \
"ERROR: userled_lower_initialize() failed: %d\n", ret);
}
#endif
#ifdef CONFIG_INPUT_BUTTONS
/* Register the BUTTON driver */
ret = btn_lower_initialize("/dev/buttons");
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret);
}
#endif
return OK;
}

View file

@ -0,0 +1,177 @@
/****************************************************************************
* boards/arm/rp23xx/raspberrypi-pico-2/src/rp23xx_buttons.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 <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "rp23xx_gpio.h"
#include "rp23xx_pico.h"
#if defined(CONFIG_ARCH_BUTTONS)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#if defined(CONFIG_INPUT_BUTTONS) && !defined(CONFIG_ARCH_IRQBUTTONS)
# error "The NuttX Buttons Driver depends on IRQ support to work!\n"
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/* Pin configuration for external raspberrypi-pico-2 buttons. */
static const uint32_t g_buttons[NUM_BUTTONS] =
{
GPIO_BTN_USER1, GPIO_BTN_USER2
};
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_button_initialize
*
* Description:
* board_button_initialize() must be called to initialize button resources.
* After that, board_buttons() may be called to collect the current state
* of all buttons or board_button_irq() may be called to register button
* interrupt handlers.
*
****************************************************************************/
uint32_t board_button_initialize(void)
{
int i;
/* Configure the GPIO pins as inputs. And we will use interrupts */
for (i = 0; i < NUM_BUTTONS; i++)
{
/* Initialize input pin */
rp23xx_gpio_init(g_buttons[i]);
/* pull-up = false : pull-down = false */
rp23xx_gpio_set_pulls(g_buttons[i], false, false);
}
return NUM_BUTTONS;
}
/****************************************************************************
* Name: board_buttons
****************************************************************************/
uint32_t board_buttons(void)
{
uint32_t ret = 0;
int i;
/* Check that state of each key */
for (i = 0; i < NUM_BUTTONS; i++)
{
/* A LOW value means that the key is pressed. */
bool released = rp23xx_gpio_get(g_buttons[i]);
/* Accumulate the set of depressed (not released) keys */
if (!released)
{
ret |= (1 << i);
}
}
return ret;
}
/****************************************************************************
* Button support.
*
* Description:
* board_button_initialize() must be called to initialize button resources.
* After that, board_buttons() may be called to collect the current state
* of all buttons or board_button_irq() may be called to register button
* interrupt handlers.
*
* After board_button_initialize() has been called, board_buttons() may be
* called to collect the state of all buttons. board_buttons() returns
* an 32-bit bit set with each bit associated with a button. See the
* BUTTON_*_BIT definitions in board.h for the meaning of each bit.
*
* board_button_irq() may be called to register an interrupt handler that
* will be called when a button is depressed or released. The ID value is
* a button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* definitions in board.h for the meaning of enumeration
* value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, void *arg)
{
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
/* Make sure the interrupt is disabled */
rp23xx_gpio_disable_irq(g_buttons[id]);
/* Attach the interrupt handler */
ret = rp23xx_gpio_irq_attach(g_buttons[id],
RP23XX_GPIO_INTR_EDGE_LOW,
irqhandler,
arg);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: irq_attach() failed: %d\n", ret);
return ret;
}
/* Enable interruption for this pin */
rp23xx_gpio_enable_irq(g_buttons[id]);
}
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View file

@ -0,0 +1,392 @@
/****************************************************************************
* boards/arm/rp23xx/raspberrypi-pico-2/src/rp23xx_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 <nuttx/config.h>
#include <sys/types.h>
#include <syslog.h>
#include <nuttx/irq.h>
#include <arch/irq.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/ioexpander/gpio.h>
#include <arch/board/board.h>
#include "arm_internal.h"
#include "chip.h"
#include "rp23xx_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 rp23xxgpio_dev_s
{
struct gpio_dev_s gpio;
uint8_t id;
};
struct rp23xxgpint_dev_s
{
struct rp23xxgpio_dev_s rp23xxgpio;
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 rp23xxgpio_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 rp23xxgpio_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 rp23xxgpint_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 rp23xxgpio_dev_s *rp23xxgpio =
(struct rp23xxgpio_dev_s *)dev;
DEBUGASSERT(rp23xxgpio != NULL && value != NULL);
DEBUGASSERT(rp23xxgpio->id < BOARD_NGPIOOUT);
gpioinfo("Reading...\n");
*value = rp23xx_gpio_get(g_gpiooutputs[rp23xxgpio->id]);
return OK;
}
/****************************************************************************
* Name: gpout_write
****************************************************************************/
static int gpout_write(struct gpio_dev_s *dev, bool value)
{
struct rp23xxgpio_dev_s *rp23xxgpio =
(struct rp23xxgpio_dev_s *)dev;
DEBUGASSERT(rp23xxgpio != NULL);
DEBUGASSERT(rp23xxgpio->id < BOARD_NGPIOOUT);
gpioinfo("Writing %d\n", (int)value);
rp23xx_gpio_put(g_gpiooutputs[rp23xxgpio->id], value);
return OK;
}
#endif
/****************************************************************************
* Name: gpin_read
****************************************************************************/
#if BOARD_NGPIOIN > 0
static int gpin_read(struct gpio_dev_s *dev, bool *value)
{
struct rp23xxgpio_dev_s *rp23xxgpio =
(struct rp23xxgpio_dev_s *)dev;
DEBUGASSERT(rp23xxgpio != NULL && value != NULL);
DEBUGASSERT(rp23xxgpio->id < BOARD_NGPIOIN);
gpioinfo("Reading... pin %d\n", (int)g_gpioinputs[rp23xxgpio->id]);
*value = rp23xx_gpio_get(g_gpioinputs[rp23xxgpio->id]);
return OK;
}
#endif
/****************************************************************************
* Name: rp23xxgpio_interrupt
****************************************************************************/
#if BOARD_NGPIOINT > 0
static int rp23xxgpio_interrupt(int irq, void *context, void *arg)
{
struct rp23xxgpint_dev_s *rp23xxgpint =
(struct rp23xxgpint_dev_s *)arg;
DEBUGASSERT(rp23xxgpint != NULL && rp23xxgpint->callback != NULL);
gpioinfo("Interrupt! callback=%p\n", rp23xxgpint->callback);
rp23xxgpint->callback(&rp23xxgpint->rp23xxgpio.gpio,
rp23xxgpint->rp23xxgpio.id);
return OK;
}
/****************************************************************************
* Name: gpint_read
****************************************************************************/
static int gpint_read(struct gpio_dev_s *dev, bool *value)
{
struct rp23xxgpint_dev_s *rp23xxgpint =
(struct rp23xxgpint_dev_s *)dev;
DEBUGASSERT(rp23xxgpint != NULL && value != NULL);
DEBUGASSERT(rp23xxgpint->rp23xxgpio.id < BOARD_NGPIOINT);
gpioinfo("Reading int pin...\n");
*value = rp23xx_gpio_get(g_gpiointinputs[rp23xxgpint->rp23xxgpio.id]);
return OK;
}
/****************************************************************************
* Name: gpint_attach
****************************************************************************/
static int gpint_attach(struct gpio_dev_s *dev,
pin_interrupt_t callback)
{
struct rp23xxgpint_dev_s *rp23xxgpint =
(struct rp23xxgpint_dev_s *)dev;
int irq = g_gpiointinputs[rp23xxgpint->rp23xxgpio.id];
int ret;
gpioinfo("Attaching the callback\n");
/* Make sure the interrupt is disabled */
rp23xx_gpio_disable_irq(irq);
ret = rp23xx_gpio_irq_attach(irq,
RP23XX_GPIO_INTR_EDGE_LOW,
rp23xxgpio_interrupt,
&g_gpint[rp23xxgpint->rp23xxgpio.id]);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: gpint_attach() failed: %d\n", ret);
return ret;
}
gpioinfo("Attach %p\n", callback);
rp23xxgpint->callback = callback;
return OK;
}
/****************************************************************************
* Name: gpint_enable
****************************************************************************/
static int gpint_enable(struct gpio_dev_s *dev, bool enable)
{
struct rp23xxgpint_dev_s *rp23xxgpint =
(struct rp23xxgpint_dev_s *)dev;
int irq = g_gpiointinputs[rp23xxgpint->rp23xxgpio.id];
if (enable)
{
if (rp23xxgpint->callback != NULL)
{
gpioinfo("Enabling the interrupt\n");
/* Configure the interrupt for rising edge */
rp23xx_gpio_enable_irq(irq);
}
}
else
{
gpioinfo("Disable the interrupt\n");
rp23xx_gpio_disable_irq(irq);
}
return OK;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp23xx_dev_gpio_init
****************************************************************************/
int rp23xx_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 */
rp23xx_gpio_init(g_gpiooutputs[i]);
rp23xx_gpio_setdir(g_gpiooutputs[i], true);
rp23xx_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 */
rp23xx_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].rp23xxgpio.gpio.gp_pintype = GPIO_INTERRUPT_PIN;
g_gpint[i].rp23xxgpio.gpio.gp_ops = &gpint_ops;
g_gpint[i].rp23xxgpio.id = i;
gpio_pin_register(&g_gpint[i].rp23xxgpio.gpio, g_gpiointinputs[i]);
/* Configure the pins that will be used as interrupt input */
rp23xx_gpio_init(g_gpiointinputs[i]);
/* pull-up = false : pull-down = true */
rp23xx_gpio_set_pulls(g_gpiointinputs[i], false, true);
pincount++;
}
#endif
return OK;
}
#endif /* CONFIG_DEV_GPIO && !CONFIG_GPIO_LOWER_HALF */

View file

@ -0,0 +1,53 @@
/****************************************************************************
* boards/arm/rp23xx/raspberrypi-pico-2/src/rp23xx_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_RP23XX_RASPBERRYPI_PICO_2_SRC_RP23XX_PICO_H
#define __BOARDS_ARM_RP23XX_RASPBERRYPI_PICO_2_SRC_RP23XX_PICO_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/* LEDs */
#define GPIO_LED1 25 /* The board's LED is connected to this pin */
/* Buttons */
/* Buttons GPIO pins definition */
#define GPIO_BTN_USER1 16
#define GPIO_BTN_USER2 17
/* Buttons IRQ definitions */
#define MIN_IRQBUTTON BUTTON_USER1
#define MAX_IRQBUTTON BUTTON_USER2
#define NUM_IRQBUTTONS (BUTTON_USER1 - BUTTON_USER2 + 1)
int rp23xx_bringup(void);
#ifdef CONFIG_DEV_GPIO
int rp23xx_dev_gpio_init(void);
#endif
#endif /* __BOARDS_ARM_RP23XX_RASPBERRYPI_PICO_2_SRC_RP23XX_PICO_H */

View file

@ -0,0 +1,214 @@
/****************************************************************************
* boards/arm/rp23xx/raspberrypi-pico-2/src/rp23xx_userleds.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 <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/power/pm.h>
#include <arch/board/board.h>
#include "chip.h"
#include "rp23xx_gpio.h"
#include "rp23xx_pico.h"
#ifndef CONFIG_ARCH_LEDS
/****************************************************************************
* Private Data
****************************************************************************/
/* This array maps an LED number to GPIO pin configuration */
static uint32_t g_ledcfg[BOARD_NLEDS] =
{
GPIO_LED1,
};
/****************************************************************************
* Private Function Protototypes
****************************************************************************/
/* LED Power Management */
#ifdef CONFIG_PM
static void led_pm_notify(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate);
static int led_pm_prepare(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate);
#endif
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef CONFIG_PM
static struct pm_callback_s g_ledscb =
{
.notify = led_pm_notify,
.prepare = led_pm_prepare,
};
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: led_pm_notify
*
* Description:
* Notify the driver of new power state. This callback is called after
* all drivers have had the opportunity to prepare for the new power state.
*
****************************************************************************/
#ifdef CONFIG_PM
static void led_pm_notify(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate)
{
switch (pmstate)
{
case(PM_NORMAL):
{
/* Restore normal LEDs operation */
board_userled(BOARD_LED, true);
}
break;
case(PM_IDLE):
{
/* Entering IDLE mode - Turn leds off */
board_userled(BOARD_LED, false);
}
break;
case(PM_STANDBY):
{
/* Entering STANDBY mode - Logic for PM_STANDBY goes here */
}
break;
case(PM_SLEEP):
{
/* Entering SLEEP mode - Logic for PM_SLEEP goes here */
}
break;
default:
{
/* Should not get here */
}
break;
}
}
#endif
/****************************************************************************
* Name: led_pm_prepare
*
* Description:
* Request the driver to prepare for a new power state. This is a warning
* that the system is about to enter into a new power state. The driver
* should begin whatever operations that may be required to enter power
* state. The driver may abort the state change mode by returning a
* non-zero value from the callback function.
*
****************************************************************************/
#ifdef CONFIG_PM
static int led_pm_prepare(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate)
{
/* No preparation to change power modes is required by the LEDs driver.
* We always accept the state change by returning OK.
*/
return OK;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_userled_initialize
****************************************************************************/
uint32_t board_userled_initialize(void)
{
/* Configure LED GPIO for output */
rp23xx_gpio_init(GPIO_LED1);
rp23xx_gpio_setdir(GPIO_LED1, true);
return BOARD_NLEDS;
}
/****************************************************************************
* Name: board_userled
****************************************************************************/
void board_userled(int led, bool ledon)
{
if ((unsigned)led < BOARD_NLEDS)
{
rp23xx_gpio_put(g_ledcfg[led], ledon);
}
}
/****************************************************************************
* Name: board_userled_all
****************************************************************************/
void board_userled_all(uint32_t ledset)
{
rp23xx_gpio_put(GPIO_LED1, (ledset & BOARD_LED1_BIT));
}
/****************************************************************************
* Name: rp23xx_led_pminitialize
****************************************************************************/
#ifdef CONFIG_PM
void rp23xx_led_pminitialize(void)
{
/* Register to receive power management callbacks */
int ret = pm_register(&g_ledscb);
if (ret != OK)
{
board_autoled_on(LED_ASSERTION);
}
}
#endif /* CONFIG_PM */
#endif /* !CONFIG_ARCH_LEDS */