From e28f9182b4d843658cd3add4f8280b042da4c338 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Thu, 22 Apr 2021 11:57:25 +0000 Subject: [PATCH] Added some SPI test code, temporary. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14260 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- demos/RP/RT-RP2040-PICO/main.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/demos/RP/RT-RP2040-PICO/main.c b/demos/RP/RT-RP2040-PICO/main.c index 4ab48018d..36fc71d72 100644 --- a/demos/RP/RT-RP2040-PICO/main.c +++ b/demos/RP/RT-RP2040-PICO/main.c @@ -22,13 +22,6 @@ void spi_cb(SPIDriver *spip) { (void)spip; } -SPIConfig spicfg1 = { - .end_cb = spi_cb, - .ssline = 4U, - .SSPCR0 = 0U, - .SSPCPSR = 0U -}; - semaphore_t blinker_sem; /* @@ -71,9 +64,23 @@ int main(void) { palSetLineMode(25U, PAL_MODE_OUTPUT_PUSHPULL | PAL_RP_PAD_DRIVE12); /* - * Settin up SPI0. + * Setting up SPI0. */ - spiStart(&SPID0, &spicfg1); + { + static SPIConfig spicfg1 = { + .end_cb = spi_cb, + .ssline = 4U, + .SSPCR0 = SPI_SSPCR0_FRF_MOTOROLA | SPI_SSPCR0_DSS_8BIT, + .SSPCPSR = 0U + }; + spicfg1.SSPCPSR = hal_lld_get_clock(clk_peri) / 1000000U; + spiStart(&SPID0, &spicfg1); + + static const uint16_t txbuf[16] = {0, 1, 2, 3, 4, 5, 6, 7, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF}; + static uint16_t rxbuf[16]; + spiExchange(&SPID0, 16U, txbuf, rxbuf); + } /* * Creates the blinker thread.