Skip to content
Closed
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
5 changes: 3 additions & 2 deletions bsp/stm32/stm32f103-100ask-pro/board/ports/spi_flash_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#if defined(BSP_USING_SPI_FLASH)
static int rt_hw_spi_flash_init(void)
{
__HAL_RCC_GPIOA_CLK_ENABLE();
rt_hw_spi_device_attach("spi1", "spi10", GPIOA, GPIO_PIN_4);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(A, 4);
rt_hw_spi_device_attach("spi1", "spi10", &cfg);

if (RT_NULL == rt_sfud_flash_probe("W25Q64", "spi10"))
{
Expand Down
5 changes: 3 additions & 2 deletions bsp/stm32/stm32f103-atk-nano/board/ports/spi_flash_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#if defined(BSP_USING_SPI_FLASH)
static int rt_hw_spi_flash_init(void)
{
__HAL_RCC_GPIOB_CLK_ENABLE();
rt_hw_spi_device_attach("spi2", "spi20", GPIOB, GPIO_PIN_12);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(B, 12);
rt_hw_spi_device_attach("spi2", "spi20", &cfg);

if (RT_NULL == rt_sfud_flash_probe("W25Q16", "spi20"))
{
Expand Down
4 changes: 3 additions & 1 deletion bsp/stm32/stm32f103-dofly-M3S/applications/nrf24l01_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#include "drv_spi.h"
static int rt_hw_nrf24l01_init(void)
{
rt_hw_spi_device_attach("spi2", "spi20", GPIOG, GPIO_PIN_7);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(G, 7);
rt_hw_spi_device_attach("spi2", "spi20", &cfg);
return RT_EOK;
}
INIT_COMPONENT_EXPORT(rt_hw_nrf24l01_init);
Expand Down
6 changes: 4 additions & 2 deletions bsp/stm32/stm32f103-dofly-M3S/board/ports/drv_sdcard.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ INIT_APP_EXPORT(stm32_sdcard_mount);
#include "spi_msd.h"
static int rt_hw_spi2_tfcard(void)
{
__HAL_RCC_GPIOC_CLK_ENABLE();
rt_hw_spi_device_attach("spi2", "spi20", GPIOD, GPIO_PIN_2);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(D, 2);
rt_hw_spi_device_attach("spi2", "spi20", &cfg);

return msd_init("sd0", "spi20");
}
INIT_DEVICE_EXPORT(rt_hw_spi2_tfcard);
Expand Down
5 changes: 3 additions & 2 deletions bsp/stm32/stm32f103-dofly-M3S/board/ports/spi_flash_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#if defined(BSP_USING_SPI_FLASH)
static int rt_hw_spi_flash_init(void)
{
__HAL_RCC_GPIOA_CLK_ENABLE();
rt_hw_spi_device_attach("spi2", "spi20", GPIOB, GPIO_PIN_12);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(B, 12);
rt_hw_spi_device_attach("spi2", "spi20", &cfg);

if (RT_NULL == rt_sfud_flash_probe("W25Q64", "spi20"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#if defined(BSP_USING_SPI_FLASH)
static int rt_hw_spi_flash_init(void)
{
__HAL_RCC_GPIOA_CLK_ENABLE();
rt_hw_spi_device_attach("spi1", "spi10", GPIOA, GPIO_PIN_4);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(A, 4);
rt_hw_spi_device_attach("spi1", "spi10", &cfg);

if (RT_NULL == rt_sfud_flash_probe("W25Q64", "spi10"))
{
Expand Down
5 changes: 3 additions & 2 deletions bsp/stm32/stm32f103-fire-arbitrary/board/ports/w5500_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

int w5500_spi_device_init()
{
__HAL_RCC_GPIOG_CLK_ENABLE();
return rt_hw_spi_device_attach("spi2","spi20",GPIOG,GPIO_PIN_9);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(G, 9);
return rt_hw_spi_device_attach("spi2", "spi20", &cfg);
}
INIT_DEVICE_EXPORT(w5500_spi_device_init);
5 changes: 3 additions & 2 deletions bsp/stm32/stm32f103-hw100k-ibox/board/ports/w5500_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include "drv_gpio.h"
int w5500_spi_device_init()
{
__HAL_RCC_GPIOB_CLK_ENABLE();
return rt_hw_spi_device_attach("spi2","spi20",GPIOB,GPIO_PIN_12);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(B, 12);
return rt_hw_spi_device_attach("spi2", "spi20", &cfg);
}
INIT_DEVICE_EXPORT(w5500_spi_device_init);
5 changes: 3 additions & 2 deletions bsp/stm32/stm32f407-armfly-v5/board/ports/spi_flash_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#if defined(BSP_USING_SPI_FLASH)
static int rt_hw_spi_flash_init(void)
{
__HAL_RCC_GPIOF_CLK_ENABLE();
rt_hw_spi_device_attach("spi3", "spi30", GPIOF, GPIO_PIN_8);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(F, 8);
rt_hw_spi_device_attach("spi3", "spi30", &cfg);

if (RT_NULL == rt_sfud_flash_probe("W25Q64", "spi30"))
{
Expand Down
5 changes: 3 additions & 2 deletions bsp/stm32/stm32f407-atk-explorer/board/ports/spi_flash_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

static int rt_hw_spi_flash_init(void)
{
__HAL_RCC_GPIOB_CLK_ENABLE();
rt_hw_spi_device_attach("spi1", "spi10", GPIOB, GPIO_PIN_14);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(B, 14);
rt_hw_spi_device_attach("spi1", "spi10", &cfg);

if (RT_NULL == rt_sfud_flash_probe("W25Q128", "spi10"))
{
Expand Down
5 changes: 3 additions & 2 deletions bsp/stm32/stm32f411-atk-nano/board/ports/spi_flash_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#if defined(BSP_USING_SPI_FLASH)
static int rt_hw_spi_flash_init(void)
{
__HAL_RCC_GPIOB_CLK_ENABLE();
rt_hw_spi_device_attach("spi2", "spi20", GPIOB, GPIO_PIN_12);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(B, 12);
rt_hw_spi_device_attach("spi2", "spi20", &cfg);

if (RT_NULL == rt_sfud_flash_probe("W25Q16", "spi20"))
{
Expand Down
5 changes: 3 additions & 2 deletions bsp/stm32/stm32f429-armfly-v6/board/ports/spi_flash_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#if defined(BSP_USING_SPI_FLASH)
static int rt_hw_spi_flash_init(void)
{
__HAL_RCC_GPIOF_CLK_ENABLE();
rt_hw_spi_device_attach("spi3", "spi30", GPIOD, GPIO_PIN_13);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(D, 13);
rt_hw_spi_device_attach("spi3", "spi30", &cfg);

if (RT_NULL == rt_sfud_flash_probe("W25Q64", "spi30"))
{
Expand Down
5 changes: 3 additions & 2 deletions bsp/stm32/stm32f429-atk-apollo/board/ports/spi_flash_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#if defined(BSP_USING_SPI_FLASH)
static int rt_hw_spi_flash_init(void)
{
__HAL_RCC_GPIOF_CLK_ENABLE();
rt_hw_spi_device_attach("spi5", "spi50", GPIOF, GPIO_PIN_6);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(F, 6);
rt_hw_spi_device_attach("spi5", "spi50", &cfg);

if (RT_NULL == rt_sfud_flash_probe("W25Q256", "spi50"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#if defined(BSP_USING_SPI_FLASH)
static int rt_hw_spi_flash_init(void)
{
__HAL_RCC_GPIOF_CLK_ENABLE();
rt_hw_spi_device_attach("spi5", "spi50", GPIOF, GPIO_PIN_6);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(F, 6);
rt_hw_spi_device_attach("spi5", "spi50", &cfg);

if (RT_NULL == rt_sfud_flash_probe("W25Q128", "spi50"))
{
Expand Down
6 changes: 4 additions & 2 deletions bsp/stm32/stm32h750-artpi/board/port/drv_spi_ili9488.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ static void lcd_gpio_init(void)

int rt_hw_spi_lcd_init(void)
{
__HAL_RCC_GPIOI_CLK_ENABLE();
rt_hw_spi_device_attach("spi2", "spi20", GPIOI, GPIO_PIN_0);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(I, 0);
rt_hw_spi_device_attach("spi2", "spi20", &cfg);

lcd_gpio_init();

rt_pin_write(LCD_RES_PIN, PIN_HIGH);
Expand Down
4 changes: 3 additions & 1 deletion bsp/stm32/stm32h750-artpi/board/port/spi_flash_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ static int rt_flash_init(void)
extern rt_spi_flash_device_t rt_sfud_flash_probe(const char *spi_flash_dev_name, const char *spi_dev_name);
extern int fal_init(void);

rt_hw_spi_device_attach("spi1", "spi10", GPIOA, GPIO_PIN_4);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(A, 4);
rt_hw_spi_device_attach("spi1", "spi10", &cfg);

/* initialize SPI Flash device */
rt_sfud_flash_probe("norflash0", "spi10");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
static int rt_hw_spi_flash_with_sfud_init(void)
{
rt_err_t err = RT_EOK;
rt_hw_spi_device_attach("spi1", "spi10", SPI_CS_GPIO, SPI_CS_PIN);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(D, 6);
rt_hw_spi_device_attach("spi1", "spi10", &cfg);

/* init W25Q16 , And register as a block device */
if (RT_NULL == rt_sfud_flash_probe(FAL_USING_NOR_FLASH_DEV_NAME, "spi10"))
Expand Down
31 changes: 10 additions & 21 deletions bsp/stm32/stm32l431-BearPi/board/ports/lcd/drv_lcd.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -28,23 +28,6 @@ rt_uint16_t BACK_COLOR = WHITE, FORE_COLOR = BLACK;

static struct rt_spi_device *spi_dev_lcd;

static int rt_hw_lcd_config(void)
{
spi_dev_lcd = (struct rt_spi_device *)rt_device_find("lcd");

/* config spi */
{
struct rt_spi_configuration cfg;
cfg.data_width = 8;
cfg.mode = RT_SPI_MASTER | RT_SPI_MODE_3 | RT_SPI_MSB;
cfg.max_hz = 42 * 1000 * 1000; /* 42M,SPI max 42MHz,lcd 4-wire spi */

rt_spi_configure(spi_dev_lcd, &cfg);
}

return RT_EOK;
}

static rt_err_t lcd_write_cmd(const rt_uint8_t cmd)
{
rt_size_t len;
Expand Down Expand Up @@ -106,8 +89,6 @@ static rt_err_t lcd_write_half_word(const rt_uint16_t da)

static void lcd_gpio_init(void)
{
rt_hw_lcd_config();

rt_pin_mode(LCD_DC_PIN, PIN_MODE_OUTPUT);
rt_pin_mode(LCD_RES_PIN, PIN_MODE_OUTPUT);

Expand All @@ -122,7 +103,15 @@ static void lcd_gpio_init(void)

static int rt_hw_lcd_init(void)
{
rt_hw_spi_device_attach("spi2", "lcd", GPIOC, GPIO_PIN_3);
struct rt_spi_configuration cfg;
cfg.data_width = 8;
cfg.mode = RT_SPI_MASTER | RT_SPI_MODE_3 | RT_SPI_MSB;
cfg.max_hz = 42 * 1000 * 1000; /* 42M,SPI max 42MHz,lcd 4-wire spi */
cfg.cs_pin = GET_PIN(C, 3);
rt_hw_spi_device_attach("spi2", "lcd", &cfg);

spi_dev_lcd = (struct rt_spi_device *)rt_device_find("lcd");

lcd_gpio_init();
/* Memory Data Access Control */
lcd_write_cmd(0x36);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
#include "drv_spi.h"
static int rt_hw_nrf24l01_init(void)
{
rt_hw_spi_device_attach("spi2", "spi20", GPIOD, GPIO_PIN_5);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(D, 5);
rt_hw_spi_device_attach("spi2", "spi20", &cfg);

return RT_EOK;
}
INIT_COMPONENT_EXPORT(rt_hw_nrf24l01_init);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
#include <spi_msd.h>
static int rt_hw_spi1_tfcard(void)
{
__HAL_RCC_GPIOC_CLK_ENABLE();
rt_hw_spi_device_attach("spi1", "spi10", GPIOC, GPIO_PIN_3);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(C, 3);
rt_hw_spi_device_attach("spi1", "spi10", &cfg);

return msd_init("sd0", "spi10");
}
INIT_DEVICE_EXPORT(rt_hw_spi1_tfcard);
Expand Down
5 changes: 3 additions & 2 deletions bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/drv_lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ static void lcd_gpio_init(void)

static int rt_hw_lcd_init(void)
{
__HAL_RCC_GPIOD_CLK_ENABLE();
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(D, 7);
rt_hw_spi_device_attach("spi3", "spi30", &cfg);

rt_hw_spi_device_attach("spi3", "spi30", GPIOD, GPIO_PIN_7);
lcd_gpio_init();

/* Memory Data Access Control */
Expand Down
4 changes: 3 additions & 1 deletion bsp/stm32/stm32l496-ali-developer/board/ports/drv_spi_lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

static int rt_hw_spi_lcd_init(void)
{
rt_hw_spi_device_attach("spi1", "spi10", GPIOA, GPIO_PIN_4);
struct rt_spi_configuration cfg;
cfg.cs_pin = GET_PIN(A, 4);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不能只赋值cfg成员变量,其他变量都是垃圾直

rt_hw_spi_device_attach("spi1", "spi10", &cfg);

return RT_EOK;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static int rt_spi_device_init(void)
{
struct rt_spi_configuration cfg;

rt_hw_spi_device_attach("spi5", "spi50", NULL, NULL);
rt_hw_spi_device_attach("spi5", "spi50", RT_NULL);

cfg.data_width = 8;
cfg.mode = RT_SPI_MASTER | RT_SPI_MODE_0 | RT_SPI_MSB | RT_SPI_NO_CS;
Expand Down
2 changes: 1 addition & 1 deletion bsp/stm32/stm32mp157a-st-ev1/board/ports/spi_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static int rt_spi_device_init(void)
{
struct rt_spi_configuration cfg;

rt_hw_spi_device_attach(SPI_NAME, SPI_DEVICE_NAME, NULL, NULL);
rt_hw_spi_device_attach(SPI_NAME, SPI_DEVICE_NAME, RT_NULL);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RT_NULL 传进去 以目前的代码 要出问题


cfg.data_width = 8;
cfg.mode = RT_SPI_MASTER | RT_SPI_MODE_0 | RT_SPI_MSB | RT_SPI_NO_CS;
Expand Down
2 changes: 2 additions & 0 deletions components/drivers/spi/spi_flash_sfud.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ rt_spi_flash_device_t rt_sfud_flash_probe_ex(const char *spi_flash_dev_name, con
rt_spi_flash_device_t rt_sfud_flash_probe(const char *spi_flash_dev_name, const char *spi_dev_name)
{
struct rt_spi_configuration cfg = RT_SFUD_DEFAULT_SPI_CFG;
cfg.cs_pin = ((struct rt_spi_device *)rt_device_find(spi_dev_name))->config.cs_pin;

#ifndef SFUD_USING_QSPI
return rt_sfud_flash_probe_ex(spi_flash_dev_name, spi_dev_name, &cfg, RT_NULL);
#else
Expand Down