Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/rpx0xx: implement periph_spi #19440

Merged
merged 2 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boards/rpi-pico/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ config BOARD_RPI_PICO
select CPU_MODEL_RP2040
select HAS_PERIPH_ADC
select HAS_PERIPH_UART
select HAS_PERIPH_SPI

select HAVE_SAUL_GPIO
1 change: 1 addition & 0 deletions boards/rpi-pico/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ CPU := rpx0xx

# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_adc
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart
17 changes: 17 additions & 0 deletions boards/rpi-pico/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ static const uart_conf_t uart_config[] = {

#define UART_NUMOF ARRAY_SIZE(uart_config)

static const spi_conf_t spi_config[] = {
{
.dev = SPI0,
.miso_pin = GPIO_PIN(0, 4),
.mosi_pin = GPIO_PIN(0, 3),
.clk_pin = GPIO_PIN(0, 2)
},
{
.dev = SPI1,
.miso_pin = GPIO_PIN(0, 12),
.mosi_pin = GPIO_PIN(0, 11),
.clk_pin = GPIO_PIN(0, 10)
}
};

#define SPI_NUMOF ARRAY_SIZE(spi_config)

static const timer_channel_conf_t timer0_channel_config[] = {
{
.irqn = TIMER_IRQ_0_IRQn
Expand Down
33 changes: 33 additions & 0 deletions cpu/rpx0xx/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,39 @@ void rosc_stop(void);

/** @} */

/**
* @brief Override SPI clock speed values
* @{
*/
#define HAVE_SPI_CLK_T
enum {
SPI_CLK_100KHZ = KHZ(100), /**< drive the SPI bus with 100KHz */
SPI_CLK_400KHZ = KHZ(400), /**< drive the SPI bus with 400KHz */
SPI_CLK_1MHZ = MHZ(1), /**< drive the SPI bus with 1MHz */
SPI_CLK_5MHZ = MHZ(5), /**< drive the SPI bus with 5MHz */
SPI_CLK_10MHZ = MHZ(10), /**< drive the SPI bus with 10MHz */
};

/**
* @brief SPI clock type
*/
typedef uint32_t spi_clk_t;
/** @} */

/**
* @brief Configuration details for an SPI interface needed by the RPX0XX peripheral
*/
typedef struct {
SPI0_Type *dev; /**< Base address of the I/O registers of the device */
gpio_t miso_pin; /**< GPIO pin to use for MISO */
gpio_t mosi_pin; /**< GPIO pin to use for MOSI */
gpio_t clk_pin; /**< GPIO pin to use for CLK */
} spi_conf_t;

#define PERIPH_SPI_NEEDS_TRANSFER_REG
#define PERIPH_SPI_NEEDS_TRANSFER_REGS
#define PERIPH_SPI_NEEDS_TRANSFER_BYTE

#ifdef __cplusplus
}
#endif
Expand Down
Loading