RP2040 Code Cleanup

This commit is contained in:
curuvar 2022-09-08 21:47:58 -04:00 committed by Xiang Xiao
parent 9b56bb86da
commit e8f4d74ad0
27 changed files with 39 additions and 1213 deletions

View File

@ -76,7 +76,7 @@
#define RP2040_WATCHDOG_SCRATCH5 (RP2040_WATCHDOG_BASE + RP2040_WATCHDOG_SCRATCH5_OFFSET)
#define RP2040_WATCHDOG_SCRATCH6 (RP2040_WATCHDOG_BASE + RP2040_WATCHDOG_SCRATCH6_OFFSET)
#define RP2040_WATCHDOG_SCRATCH7 (RP2040_WATCHDOG_BASE + RP2040_WATCHDOG_SCRATCH7_OFFSET)
#define RP2040_WATCHDOG_SCRATCH(n) (RP2040_WATCHDOG_BASE + RP2040_WATCHDOG_SCRATCH0_OFFSET + 4 * n)
#define RP2040_WATCHDOG_SCRATCH(n) (RP2040_WATCHDOG_BASE + RP2040_WATCHDOG_SCRATCH0_OFFSET + 4 * (n))
#define RP2040_WATCHDOG_TICK (RP2040_WATCHDOG_BASE + RP2040_WATCHDOG_TICK_OFFSET)
/* Register bit definitions *************************************************/

View File

@ -5,28 +5,6 @@
if ARCH_BOARD_ADAFRUIT_FEATHER_RP2040
config RP2040_FLASH_BOOT
bool "flash boot"
default y
---help---
If y, the built binary can be used for flash boot.
If not, the binary is for SRAM boot.
config RP2040_FLASH_CHIP
string "Second stage boot loader"
default "w25q080"
---help---
This is the name of the Pico-SDK second stage boot loader
to use for this board. This board using a Q64 flash chip
which is compatible with the w25q080 boot loader.
Basically this option should not be changed.
config RP2040_UF2_BINARY
bool "uf2 binary format"
default y
---help---
Create nuttx.uf2 binary format used on RP2040 based arch.
config RP2040_LCD_SPI_CH
int "RP2040 LCD SPI channel number"
default 0

View File

@ -24,14 +24,6 @@ CSRCS = rp2040_boardinitialize.c
CSRCS += rp2040_appinit.c
CSRCS += rp2040_bringup.c
ifeq ($(CONFIG_BOARDCTL_RESET),y)
CSRCS += rp2040_reset.c
endif
ifeq ($(CONFIG_SPI),y)
CSRCS += rp2040_spi.c
endif
ifeq ($(CONFIG_DEV_GPIO),y)
CSRCS += rp2040_gpio.c
endif

View File

@ -1,61 +0,0 @@
/****************************************************************************
* boards/arm/rp2040/adafruit-feather-rp2040/src/rp2040_reset.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <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

@ -1,150 +0,0 @@
/****************************************************************************
* boards/arm/rp2040/adafruit-feather-rp2040/src/rp2040_spi.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <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 "rp2040_gpio.h"
#include "hardware/rp2040_spi.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp2040_spi0/1select and rp2040_spi0/1status
*
* Description:
* The external functions, rp2040_spi0/1select and rp2040_spi0/1status
* must be provided by board-specific logic.
* They are implementations of the select and status methods of the SPI
* interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
* All other methods (including rp2040_spibus_initialize()) are provided by
* common RP2040 logic. To use this common SPI logic on your board:
*
* 1. Provide logic in rp2040_boardinitialize() to configure SPI chip
* select pins.
* 2. Provide rp2040_spi0/1select() and rp2040_spi0/1status()
* functions in your board-specific logic.
* These functions will perform chip selection and status operations
* using GPIOs in the way your board is configured.
* 3. Add a calls to rp2040_spibus_initialize() in your low level
* application initialization logic
* 4. The handle returned by rp2040_spibus_initialize() may then be used to
* bind the SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
*
****************************************************************************/
#ifdef CONFIG_RP2040_SPI0
void rp2040_spi0select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
rp2040_gpio_put(CONFIG_RP2040_SPI0_CS_GPIO, !selected);
}
uint8_t rp2040_spi0status(struct spi_dev_s *dev, uint32_t devid)
{
uint8_t ret = 0;
# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 0)
ret = board_spisd_status(dev, devid);
# endif
return ret;
}
#ifdef CONFIG_SPI_CMDDATA
int rp2040_spi0cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
#ifdef CONFIG_LCD_ST7789
if (devid == SPIDEV_DISPLAY(0))
{
/* This is the Data/Command control pad which determines whether the
* data bits are data or a command.
*/
rp2040_gpio_put(CONFIG_RP2040_SPI0_RX_GPIO, !cmd);
return OK;
}
#endif
return -ENODEV;
}
#endif
#endif
#ifdef CONFIG_RP2040_SPI1
void rp2040_spi1select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
rp2040_gpio_put(CONFIG_RP2040_SPI1_CS_GPIO, !selected);
}
uint8_t rp2040_spi1status(struct spi_dev_s *dev, uint32_t devid)
{
uint8_t ret = 0;
# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 1)
ret = board_spisd_status(dev, devid);
# endif
return ret;
}
#ifdef CONFIG_SPI_CMDDATA
int rp2040_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
#if defined (CONFIG_LCD_ST7789) || (CONFIG_LCD_ST7735)
if (devid == SPIDEV_DISPLAY(0))
{
/* This is the Data/Command control pad which determines whether the
* data bits are data or a command.
*/
rp2040_gpio_put(CONFIG_RP2040_SPI1_RX_GPIO, !cmd);
return OK;
}
#endif
return -ENODEV;
}
#endif
#endif

View File

@ -5,28 +5,6 @@
if ARCH_BOARD_ADAFRUIT_KB2040
config RP2040_FLASH_BOOT
bool "flash boot"
default y
---help---
If y, the built binary can be used for flash boot.
If not, the binary is for SRAM boot.
config RP2040_FLASH_CHIP
string "Second stage boot loader"
default "w25q080"
---help---
This is the name of the Pico-SDK second stage boot loader
to use for this board. This board using a Q64 flash chip
which is compatible with the w25q080 boot loader.
Basically this option should not be changed.
config RP2040_UF2_BINARY
bool "uf2 binary format"
default y
---help---
Create nuttx.uf2 binary format used on RP2040 based arch.
config RP2040_LCD_SPI_CH
int "RP2040 LCD SPI channel number"
default 0

View File

@ -24,14 +24,6 @@ CSRCS = rp2040_boardinitialize.c
CSRCS += rp2040_appinit.c
CSRCS += rp2040_bringup.c
ifeq ($(CONFIG_BOARDCTL_RESET),y)
CSRCS += rp2040_reset.c
endif
ifeq ($(CONFIG_SPI),y)
CSRCS += rp2040_spi.c
endif
ifeq ($(CONFIG_DEV_GPIO),y)
CSRCS += rp2040_gpio.c
endif

View File

@ -5,26 +5,4 @@
if ARCH_BOARD_ADAFRUIT_QT_PY_RP2040
config RP2040_FLASH_BOOT
bool "flash boot"
default y
---help---
If y, the built binary can be used for flash boot.
If not, the binary is for SRAM boot.
config RP2040_FLASH_CHIP
string "Second stage boot loader"
default "w25q080"
---help---
This is the name of the Pico-SDK second stage boot loader
to use for this board. This board using a Q64 flash chip
which is compatible with the w25q080 boot loader.
Basically this option should not be changed.
config RP2040_UF2_BINARY
bool "uf2 binary format"
default y
---help---
Create nuttx.uf2 binary format used on RP2040 based arch.
endif

View File

@ -24,14 +24,6 @@ CSRCS = rp2040_boardinitialize.c
CSRCS += rp2040_appinit.c
CSRCS += rp2040_bringup.c
ifeq ($(CONFIG_BOARDCTL_RESET),y)
CSRCS += rp2040_reset.c
endif
ifeq ($(CONFIG_SPI),y)
CSRCS += rp2040_spi.c
endif
ifeq ($(CONFIG_DEV_GPIO),y)
CSRCS += rp2040_gpio.c
endif

View File

@ -1,61 +0,0 @@
/****************************************************************************
* boards/arm/rp2040/adafruit-qt-py-rp2040/src/rp2040_reset.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <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

@ -1,150 +0,0 @@
/****************************************************************************
* boards/arm/rp2040/adafruit-qt-py-rp2040/src/rp2040_spi.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <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 "rp2040_gpio.h"
#include "hardware/rp2040_spi.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp2040_spi0/1select and rp2040_spi0/1status
*
* Description:
* The external functions, rp2040_spi0/1select and rp2040_spi0/1status
* must be provided by board-specific logic.
* They are implementations of the select and status methods of the SPI
* interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
* All other methods (including rp2040_spibus_initialize()) are provided by
* common RP2040 logic. To use this common SPI logic on your board:
*
* 1. Provide logic in rp2040_boardinitialize() to configure SPI chip
* select pins.
* 2. Provide rp2040_spi0/1select() and rp2040_spi0/1status()
* functions in your board-specific logic.
* These functions will perform chip selection and status operations
* using GPIOs in the way your board is configured.
* 3. Add a calls to rp2040_spibus_initialize() in your low level
* application initialization logic
* 4. The handle returned by rp2040_spibus_initialize() may then be used to
* bind the SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
*
****************************************************************************/
#ifdef CONFIG_RP2040_SPI0
void rp2040_spi0select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
rp2040_gpio_put(CONFIG_RP2040_SPI0_CS_GPIO, !selected);
}
uint8_t rp2040_spi0status(struct spi_dev_s *dev, uint32_t devid)
{
uint8_t ret = 0;
# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 0)
ret = board_spisd_status(dev, devid);
# endif
return ret;
}
#ifdef CONFIG_SPI_CMDDATA
int rp2040_spi0cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
#ifdef CONFIG_LCD_ST7789
if (devid == SPIDEV_DISPLAY(0))
{
/* This is the Data/Command control pad which determines whether the
* data bits are data or a command.
*/
rp2040_gpio_put(CONFIG_RP2040_SPI0_RX_GPIO, !cmd);
return OK;
}
#endif
return -ENODEV;
}
#endif
#endif
#ifdef CONFIG_RP2040_SPI1
void rp2040_spi1select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
rp2040_gpio_put(CONFIG_RP2040_SPI1_CS_GPIO, !selected);
}
uint8_t rp2040_spi1status(struct spi_dev_s *dev, uint32_t devid)
{
uint8_t ret = 0;
# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 1)
ret = board_spisd_status(dev, devid);
# endif
return ret;
}
#ifdef CONFIG_SPI_CMDDATA
int rp2040_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
#if defined (CONFIG_LCD_ST7789) || (CONFIG_LCD_ST7735)
if (devid == SPIDEV_DISPLAY(0))
{
/* This is the Data/Command control pad which determines whether the
* data bits are data or a command.
*/
rp2040_gpio_put(CONFIG_RP2040_SPI1_RX_GPIO, !cmd);
return OK;
}
#endif
return -ENODEV;
}
#endif
#endif

View File

@ -3,6 +3,32 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
#####################################################################
# Build Configuration
#####################################################################
config RP2040_FLASH_BOOT
bool "flash boot"
default y
---help---
If y, the built binary can be used for flash boot.
If not, the binary is for SRAM boot.
config RP2040_FLASH_CHIP
string "Second stage boot loader"
default "w25q080"
---help---
This is the name of the Pico-SDK second stage boot loader
to use for this board. This board using a Q16 flash chip
which is compatible with the w25q080 boot loader.
Basically this option should not be changed.
config RP2040_UF2_BINARY
bool "uf2 binary format"
default y
---help---
Create nuttx.uf2 binary format used on RP2040 based arch.
#####################################################################
# UART Configuration
#####################################################################
@ -212,7 +238,7 @@ endif # RP2040_I2C0 || RP2040_I2C0_SLAVE
#####################################################################
if RP2040_I2C1 || RP2040_I2C0_SLAVE
if RP2040_I2C1 || RP2040_I2C1_SLAVE
config RP2040_I2C1_SDA_GPIO
int "GPIO pin for I2C1 SDA (2, 6, 10, 14, 18, 22, or 26)"
@ -228,7 +254,7 @@ if RP2040_I2C1 || RP2040_I2C0_SLAVE
---help---
Refer to board documentation to see which pins are available.
endif # RP2040_I2C1 || RP2040_I2C0_SLAVE
endif # RP2040_I2C1 || RP2040_I2C1_SLAVE
#####################################################################
# PWM Configuration

View File

@ -23,6 +23,14 @@ ifeq ($(CONFIG_ARCH_BOARD_COMMON),y)
CSRCS += rp2040_common_bringup.c
CSRCS += rp2040_common_initialize.c
ifeq ($(CONFIG_BOARDCTL_RESET),y)
CSRCS += rp2040_reset.c
endif
ifeq ($(CONFIG_SPI),y)
CSRCS += rp2040_spi.c
endif
ifeq ($(CONFIG_RP2040_I2C_DRIVER),y)
CSRCS += rp2040_i2cdev.c
endif

View File

@ -1,5 +1,5 @@
/****************************************************************************
* boards/arm/rp2040/adafruit-kb2040/src/rp2040_reset.c
* boards/arm/rp2040/common/src/rp2040_reset.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/****************************************************************************
* boards/arm/rp2040/adafruit-kb2040/src/rp2040_spi.c
* boards/arm/rp2040/common/src/rp2040_spi.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with

View File

@ -5,26 +5,5 @@
if ARCH_BOARD_PIMORONI_TINY2040
config RP2040_FLASH_BOOT
bool "flash boot"
default y
---help---
If y, the built binary can be used for flash boot.
If not, the binary is for SRAM boot.
config RP2040_FLASH_CHIP
string "Second stage boot loader"
default "w25q080"
---help---
This is the name of the Pico-SDK second stage boot loader
to use for this board. This board using a Q16 flash chip
which is compatible with the w25q080 boot loader.
Basically this option should not be changed.
config RP2040_UF2_BINARY
bool "uf2 binary format"
default y
---help---
Create nuttx.uf2 binary format used on RP2040 based arch.
endif

View File

@ -24,14 +24,6 @@ CSRCS = rp2040_boardinitialize.c
CSRCS += rp2040_appinit.c
CSRCS += rp2040_bringup.c
ifeq ($(CONFIG_BOARDCTL_RESET),y)
CSRCS += rp2040_reset.c
endif
ifeq ($(CONFIG_SPI),y)
CSRCS += rp2040_spi.c
endif
ifeq ($(CONFIG_DEV_GPIO),y)
CSRCS += rp2040_gpio.c
endif

View File

@ -1,61 +0,0 @@
/****************************************************************************
* boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_reset.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <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

@ -1,124 +0,0 @@
/****************************************************************************
* boards/arm/rp2040/pimoroni-tiny2040/src/rp2040_spi.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <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 "rp2040_gpio.h"
#include "hardware/rp2040_spi.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp2040_spi0/1select and rp2040_spi0/1status
*
* Description:
* The external functions, rp2040_spi0/1select and rp2040_spi0/1status
* must be provided by board-specific logic.
* They are implementations of the select and status methods of the SPI
* interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
* All other methods (including rp2040_spibus_initialize()) are provided by
* common RP2040 logic. To use this common SPI logic on your board:
*
* 1. Provide logic in rp2040_boardinitialize() to configure SPI chip
* select pins.
* 2. Provide rp2040_spi0/1select() and rp2040_spi0/1status()
* functions in your board-specific logic.
* These functions will perform chip selection and status operations
* using GPIOs in the way your board is configured.
* 3. Add a calls to rp2040_spibus_initialize() in your low level
* application initialization logic
* 4. The handle returned by rp2040_spibus_initialize() may then be used to
* bind the SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
*
****************************************************************************/
#ifdef CONFIG_RP2040_SPI0
void rp2040_spi0select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
rp2040_gpio_put(CONFIG_RP2040_SPI0_CS_GPIO, !selected);
}
uint8_t rp2040_spi0status(struct spi_dev_s *dev, uint32_t devid)
{
uint8_t ret = 0;
# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 0)
ret = board_spisd_status(dev, devid);
# endif
return ret;
}
#ifdef CONFIG_SPI_CMDDATA
int rp2040_spi0cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
return -ENODEV;
}
#endif
#endif
#ifdef CONFIG_RP2040_SPI1
void rp2040_spi1select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
rp2040_gpio_put(CONFIG_RP2040_SPI1_CS_GPIO, !selected);
}
uint8_t rp2040_spi1status(struct spi_dev_s *dev, uint32_t devid)
{
uint8_t ret = 0;
# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 1)
ret = board_spisd_status(dev, devid);
# endif
return ret;
}
#ifdef CONFIG_SPI_CMDDATA
int rp2040_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
return -ENODEV;
}
#endif
#endif

View File

@ -5,28 +5,6 @@
if ARCH_BOARD_RASPBERRYPI_PICO_W
config RP2040_FLASH_BOOT
bool "flash boot"
default y
---help---
If y, the built binary can be used for flash boot.
If not, the binary is for SRAM boot.
config RP2040_FLASH_CHIP
string "Second stage boot loader"
default "w25q080"
---help---
This is the name of the Pico-SDK second stage boot loader
to use for this board. This board using a Q16 flash chip
which is compatible with the w25q080 boot loader.
Basically this option should not be changed.
config RP2040_UF2_BINARY
bool "uf2 binary format"
default y
---help---
Create nuttx.uf2 binary format used on RP2040 based arch.
config RP2040_LCD_SPI_CH
int "RP2040 LCD SPI channel number"
default 0

View File

@ -24,14 +24,6 @@ CSRCS = rp2040_boardinitialize.c
CSRCS += rp2040_appinit.c
CSRCS += rp2040_bringup.c
ifeq ($(CONFIG_BOARDCTL_RESET),y)
CSRCS += rp2040_reset.c
endif
ifeq ($(CONFIG_SPI),y)
CSRCS += rp2040_spi.c
endif
ifeq ($(CONFIG_DEV_GPIO),y)
CSRCS += rp2040_gpio.c
endif

View File

@ -1,61 +0,0 @@
/****************************************************************************
* boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_reset.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <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

@ -1,150 +0,0 @@
/****************************************************************************
* boards/arm/rp2040/raspberrypi-pico-w/src/rp2040_spi.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <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 "rp2040_gpio.h"
#include "hardware/rp2040_spi.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp2040_spi0/1select and rp2040_spi0/1status
*
* Description:
* The external functions, rp2040_spi0/1select and rp2040_spi0/1status
* must be provided by board-specific logic.
* They are implementations of the select and status methods of the SPI
* interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
* All other methods (including rp2040_spibus_initialize()) are provided by
* common RP2040 logic. To use this common SPI logic on your board:
*
* 1. Provide logic in rp2040_boardinitialize() to configure SPI chip
* select pins.
* 2. Provide rp2040_spi0/1select() and rp2040_spi0/1status()
* functions in your board-specific logic.
* These functions will perform chip selection and status operations
* using GPIOs in the way your board is configured.
* 3. Add a calls to rp2040_spibus_initialize() in your low level
* application initialization logic
* 4. The handle returned by rp2040_spibus_initialize() may then be used to
* bind the SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
*
****************************************************************************/
#ifdef CONFIG_RP2040_SPI0
void rp2040_spi0select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
rp2040_gpio_put(CONFIG_RP2040_SPI0_CS_GPIO, !selected);
}
uint8_t rp2040_spi0status(struct spi_dev_s *dev, uint32_t devid)
{
uint8_t ret = 0;
# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 0)
ret = board_spisd_status(dev, devid);
# endif
return ret;
}
#ifdef CONFIG_SPI_CMDDATA
int rp2040_spi0cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
#ifdef CONFIG_LCD_ST7789
if (devid == SPIDEV_DISPLAY(0))
{
/* This is the Data/Command control pad which determines whether the
* data bits are data or a command.
*/
rp2040_gpio_put(CONFIG_RP2040_SPI0_RX_GPIO, !cmd);
return OK;
}
#endif
return -ENODEV;
}
#endif
#endif
#ifdef CONFIG_RP2040_SPI1
void rp2040_spi1select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
rp2040_gpio_put(CONFIG_RP2040_SPI1_CS_GPIO, !selected);
}
uint8_t rp2040_spi1status(struct spi_dev_s *dev, uint32_t devid)
{
uint8_t ret = 0;
# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 1)
ret = board_spisd_status(dev, devid);
# endif
return ret;
}
#ifdef CONFIG_SPI_CMDDATA
int rp2040_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
#if defined (CONFIG_LCD_ST7789) || (CONFIG_LCD_ST7735)
if (devid == SPIDEV_DISPLAY(0))
{
/* This is the Data/Command control pad which determines whether the
* data bits are data or a command.
*/
rp2040_gpio_put(CONFIG_RP2040_SPI1_RX_GPIO, !cmd);
return OK;
}
#endif
return -ENODEV;
}
#endif
#endif

View File

@ -5,28 +5,6 @@
if ARCH_BOARD_RASPBERRYPI_PICO
config RP2040_FLASH_BOOT
bool "flash boot"
default y
---help---
If y, the built binary can be used for flash boot.
If not, the binary is for SRAM boot.
config RP2040_FLASH_CHIP
string "Second stage boot loader"
default "w25q080"
---help---
This is the name of the Pico-SDK second stage boot loader
to use for this board. This board using a Q16 flash chip
which is compatible with the w25q080 boot loader.
Basically this option should not be changed.
config RP2040_UF2_BINARY
bool "uf2 binary format"
default y
---help---
Create nuttx.uf2 binary format used on RP2040 based arch.
config RP2040_LCD_SPI_CH
int "RP2040 LCD SPI channel number"
default 0

View File

@ -24,14 +24,6 @@ CSRCS = rp2040_boardinitialize.c
CSRCS += rp2040_appinit.c
CSRCS += rp2040_bringup.c
ifeq ($(CONFIG_BOARDCTL_RESET),y)
CSRCS += rp2040_reset.c
endif
ifeq ($(CONFIG_SPI),y)
CSRCS += rp2040_spi.c
endif
ifeq ($(CONFIG_DEV_GPIO),y)
CSRCS += rp2040_gpio.c
endif

View File

@ -1,61 +0,0 @@
/****************************************************************************
* boards/arm/rp2040/raspberrypi-pico/src/rp2040_reset.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <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

@ -1,150 +0,0 @@
/****************************************************************************
* boards/arm/rp2040/raspberrypi-pico/src/rp2040_spi.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <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 "rp2040_gpio.h"
#include "hardware/rp2040_spi.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: rp2040_spi0/1select and rp2040_spi0/1status
*
* Description:
* The external functions, rp2040_spi0/1select and rp2040_spi0/1status
* must be provided by board-specific logic.
* They are implementations of the select and status methods of the SPI
* interface defined by struct spi_ops_s (see include/nuttx/spi/spi.h).
* All other methods (including rp2040_spibus_initialize()) are provided by
* common RP2040 logic. To use this common SPI logic on your board:
*
* 1. Provide logic in rp2040_boardinitialize() to configure SPI chip
* select pins.
* 2. Provide rp2040_spi0/1select() and rp2040_spi0/1status()
* functions in your board-specific logic.
* These functions will perform chip selection and status operations
* using GPIOs in the way your board is configured.
* 3. Add a calls to rp2040_spibus_initialize() in your low level
* application initialization logic
* 4. The handle returned by rp2040_spibus_initialize() may then be used to
* bind the SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver).
*
****************************************************************************/
#ifdef CONFIG_RP2040_SPI0
void rp2040_spi0select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
rp2040_gpio_put(CONFIG_RP2040_SPI0_CS_GPIO, !selected);
}
uint8_t rp2040_spi0status(struct spi_dev_s *dev, uint32_t devid)
{
uint8_t ret = 0;
# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 0)
ret = board_spisd_status(dev, devid);
# endif
return ret;
}
#ifdef CONFIG_SPI_CMDDATA
int rp2040_spi0cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
#ifdef CONFIG_LCD_ST7789
if (devid == SPIDEV_DISPLAY(0))
{
/* This is the Data/Command control pad which determines whether the
* data bits are data or a command.
*/
rp2040_gpio_put(CONFIG_RP2040_SPI0_RX_GPIO, !cmd);
return OK;
}
#endif
return -ENODEV;
}
#endif
#endif
#ifdef CONFIG_RP2040_SPI1
void rp2040_spi1select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid,
selected ? "assert" : "de-assert");
rp2040_gpio_put(CONFIG_RP2040_SPI1_CS_GPIO, !selected);
}
uint8_t rp2040_spi1status(struct spi_dev_s *dev, uint32_t devid)
{
uint8_t ret = 0;
# if defined(CONFIG_RP2040_SPISD) && (CONFIG_RP2040_SPISD_SPI_CH == 1)
ret = board_spisd_status(dev, devid);
# endif
return ret;
}
#ifdef CONFIG_SPI_CMDDATA
int rp2040_spi1cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd)
{
#if defined (CONFIG_LCD_ST7789) || (CONFIG_LCD_ST7735)
if (devid == SPIDEV_DISPLAY(0))
{
/* This is the Data/Command control pad which determines whether the
* data bits are data or a command.
*/
rp2040_gpio_put(CONFIG_RP2040_SPI1_RX_GPIO, !cmd);
return OK;
}
#endif
return -ENODEV;
}
#endif
#endif