Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
SummerGao.
rt-thread
提交
7ff64c1c
R
rt-thread
项目概览
SummerGao.
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7ff64c1c
编写于
1月 18, 2023
作者:
L
liYangYang
提交者:
GitHub
1月 18, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[stm32][spi] spi attach函数问题解决方案 (#6864)
attach #6819
上级
65f18040
变更
29
隐藏空白更改
内联
并排
Showing
29 changed file
with
45 addition
and
42 deletion
+45
-42
bsp/stm32/libraries/HAL_Drivers/drv_spi.c
bsp/stm32/libraries/HAL_Drivers/drv_spi.c
+14
-12
bsp/stm32/libraries/HAL_Drivers/drv_spi.h
bsp/stm32/libraries/HAL_Drivers/drv_spi.h
+1
-1
bsp/stm32/stm32f103-100ask-pro/board/ports/spi_flash_init.c
bsp/stm32/stm32f103-100ask-pro/board/ports/spi_flash_init.c
+1
-1
bsp/stm32/stm32f103-atk-nano/board/ports/spi_flash_init.c
bsp/stm32/stm32f103-atk-nano/board/ports/spi_flash_init.c
+1
-1
bsp/stm32/stm32f103-dofly-M3S/applications/nrf24l01_init.c
bsp/stm32/stm32f103-dofly-M3S/applications/nrf24l01_init.c
+1
-1
bsp/stm32/stm32f103-dofly-M3S/board/ports/drv_sdcard.c
bsp/stm32/stm32f103-dofly-M3S/board/ports/drv_sdcard.c
+1
-1
bsp/stm32/stm32f103-dofly-M3S/board/ports/spi_flash_init.c
bsp/stm32/stm32f103-dofly-M3S/board/ports/spi_flash_init.c
+1
-1
bsp/stm32/stm32f103-fire-arbitrary/board/ports/spi_flash_init.c
...m32/stm32f103-fire-arbitrary/board/ports/spi_flash_init.c
+1
-1
bsp/stm32/stm32f103-fire-arbitrary/board/ports/w5500_device.c
...stm32/stm32f103-fire-arbitrary/board/ports/w5500_device.c
+1
-1
bsp/stm32/stm32f103-hw100k-ibox/board/ports/w5500_device.c
bsp/stm32/stm32f103-hw100k-ibox/board/ports/w5500_device.c
+1
-1
bsp/stm32/stm32f407-armfly-v5/board/ports/spi_flash_init.c
bsp/stm32/stm32f407-armfly-v5/board/ports/spi_flash_init.c
+1
-1
bsp/stm32/stm32f407-atk-explorer/board/ports/spi_flash_init.c
...stm32/stm32f407-atk-explorer/board/ports/spi_flash_init.c
+1
-1
bsp/stm32/stm32f411-atk-nano/board/ports/spi_flash_init.c
bsp/stm32/stm32f411-atk-nano/board/ports/spi_flash_init.c
+1
-1
bsp/stm32/stm32f429-armfly-v6/board/ports/spi_flash_init.c
bsp/stm32/stm32f429-armfly-v6/board/ports/spi_flash_init.c
+1
-1
bsp/stm32/stm32f429-atk-apollo/board/ports/spi_flash_init.c
bsp/stm32/stm32f429-atk-apollo/board/ports/spi_flash_init.c
+1
-1
bsp/stm32/stm32f429-fire-challenger/board/ports/spi_flash_init.c
...32/stm32f429-fire-challenger/board/ports/spi_flash_init.c
+1
-1
bsp/stm32/stm32h750-artpi/board/port/drv_spi_ili9488.c
bsp/stm32/stm32h750-artpi/board/port/drv_spi_ili9488.c
+1
-1
bsp/stm32/stm32h750-artpi/board/port/spi_flash_init.c
bsp/stm32/stm32h750-artpi/board/port/spi_flash_init.c
+1
-1
bsp/stm32/stm32h750-weact-ministm32h7xx/board/port/drv_spi_flash.c
.../stm32h750-weact-ministm32h7xx/board/port/drv_spi_flash.c
+1
-1
bsp/stm32/stm32l431-BearPi/board/ports/lcd/drv_lcd.c
bsp/stm32/stm32l431-BearPi/board/ports/lcd/drv_lcd.c
+2
-2
bsp/stm32/stm32l475-atk-pandora/applications/nrf24l01_init.c
bsp/stm32/stm32l475-atk-pandora/applications/nrf24l01_init.c
+1
-1
bsp/stm32/stm32l475-atk-pandora/board/ports/drv_filesystem.c
bsp/stm32/stm32l475-atk-pandora/board/ports/drv_filesystem.c
+1
-1
bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/drv_lcd.c
bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/drv_lcd.c
+1
-1
bsp/stm32/stm32l496-ali-developer/board/ports/drv_spi_lcd.c
bsp/stm32/stm32l496-ali-developer/board/ports/drv_spi_lcd.c
+1
-1
bsp/stm32/stm32mp157a-st-discovery/board/ports/spi_sample.c
bsp/stm32/stm32mp157a-st-discovery/board/ports/spi_sample.c
+1
-1
bsp/stm32/stm32mp157a-st-ev1/board/ports/spi_sample.c
bsp/stm32/stm32mp157a-st-ev1/board/ports/spi_sample.c
+1
-1
components/drivers/include/drivers/pin.h
components/drivers/include/drivers/pin.h
+3
-1
components/drivers/include/drivers/spi.h
components/drivers/include/drivers/spi.h
+2
-2
components/drivers/spi/spi_core.c
components/drivers/spi/spi_core.c
+0
-1
未找到文件。
bsp/stm32/libraries/HAL_Drivers/drv_spi.c
浏览文件 @
7ff64c1c
...
...
@@ -85,9 +85,6 @@ static rt_err_t stm32_spi_init(struct stm32_spi *spi_drv, struct rt_spi_configur
RT_ASSERT
(
spi_drv
!=
RT_NULL
);
RT_ASSERT
(
cfg
!=
RT_NULL
);
rt_pin_mode
(
cfg
->
cs_pin
,
PIN_MODE_OUTPUT
);
rt_pin_write
(
cfg
->
cs_pin
,
PIN_HIGH
);
SPI_HandleTypeDef
*
spi_handle
=
&
spi_drv
->
handle
;
if
(
cfg
->
mode
&
RT_SPI_SLAVE
)
...
...
@@ -299,12 +296,12 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
struct
stm32_spi
*
spi_drv
=
rt_container_of
(
device
->
bus
,
struct
stm32_spi
,
spi_bus
);
SPI_HandleTypeDef
*
spi_handle
=
&
spi_drv
->
handle
;
if
(
message
->
cs_take
&&
!
(
device
->
config
.
mode
&
RT_SPI_NO_CS
))
if
(
message
->
cs_take
&&
!
(
device
->
config
.
mode
&
RT_SPI_NO_CS
)
&&
(
device
->
cs_pin
!=
PIN_NONE
)
)
{
if
(
device
->
config
.
mode
&
RT_SPI_CS_HIGH
)
rt_pin_write
(
device
->
c
onfig
.
c
s_pin
,
PIN_HIGH
);
rt_pin_write
(
device
->
cs_pin
,
PIN_HIGH
);
else
rt_pin_write
(
device
->
c
onfig
.
c
s_pin
,
PIN_LOW
);
rt_pin_write
(
device
->
cs_pin
,
PIN_LOW
);
}
LOG_D
(
"%s transfer prepare and start"
,
spi_drv
->
config
->
bus_name
);
...
...
@@ -433,12 +430,12 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
#endif
/* SOC_SERIES_STM32H7 || SOC_SERIES_STM32F7 */
}
if
(
message
->
cs_release
&&
!
(
device
->
config
.
mode
&
RT_SPI_NO_CS
))
if
(
message
->
cs_release
&&
!
(
device
->
config
.
mode
&
RT_SPI_NO_CS
)
&&
(
device
->
cs_pin
!=
PIN_NONE
)
)
{
if
(
device
->
config
.
mode
&
RT_SPI_CS_HIGH
)
rt_pin_write
(
device
->
c
onfig
.
c
s_pin
,
PIN_LOW
);
rt_pin_write
(
device
->
cs_pin
,
PIN_LOW
);
else
rt_pin_write
(
device
->
c
onfig
.
c
s_pin
,
PIN_HIGH
);
rt_pin_write
(
device
->
cs_pin
,
PIN_HIGH
);
}
return
message
->
length
;
...
...
@@ -571,7 +568,7 @@ static int rt_hw_spi_bus_init(void)
/**
* Attach the spi device to SPI bus, this function must be used after initialization.
*/
rt_err_t
rt_hw_spi_device_attach
(
const
char
*
bus_name
,
const
char
*
device_name
,
struct
rt_spi_configuration
*
cfg
)
rt_err_t
rt_hw_spi_device_attach
(
const
char
*
bus_name
,
const
char
*
device_name
,
rt_base_t
cs_pin
)
{
RT_ASSERT
(
bus_name
!=
RT_NULL
);
RT_ASSERT
(
device_name
!=
RT_NULL
);
...
...
@@ -583,9 +580,14 @@ rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name,
spi_device
=
(
struct
rt_spi_device
*
)
rt_malloc
(
sizeof
(
struct
rt_spi_device
));
RT_ASSERT
(
spi_device
!=
RT_NULL
);
result
=
rt_spi_bus_attach_device
(
spi_device
,
device_name
,
bus_name
,
RT_NULL
);
spi_device
->
cs_pin
=
cs_pin
;
if
(
cs_pin
!=
PIN_NONE
)
{
rt_pin_mode
(
cs_pin
,
PIN_MODE_OUTPUT
);
rt_pin_write
(
cs_pin
,
PIN_HIGH
);
}
result
=
rt_spi_
configure
(
spi_device
,
cfg
);
result
=
rt_spi_
bus_attach_device
(
spi_device
,
device_name
,
bus_name
,
RT_NULL
);
if
(
result
!=
RT_EOK
)
{
...
...
bsp/stm32/libraries/HAL_Drivers/drv_spi.h
浏览文件 @
7ff64c1c
...
...
@@ -22,7 +22,7 @@
extern
"C"
{
#endif
rt_err_t
rt_hw_spi_device_attach
(
const
char
*
bus_name
,
const
char
*
device_name
,
struct
rt_spi_configuration
*
cfg
);
rt_err_t
rt_hw_spi_device_attach
(
const
char
*
bus_name
,
const
char
*
device_name
,
rt_base_t
cs_pin
);
#ifdef __cplusplus
}
...
...
bsp/stm32/stm32f103-100ask-pro/board/ports/spi_flash_init.c
浏览文件 @
7ff64c1c
...
...
@@ -17,7 +17,7 @@
static
int
rt_hw_spi_flash_init
(
void
)
{
__HAL_RCC_GPIOA_CLK_ENABLE
();
rt_hw_spi_device_attach
(
"spi1"
,
"spi10"
,
G
PIOA
,
GPIO_PIN_4
);
rt_hw_spi_device_attach
(
"spi1"
,
"spi10"
,
G
ET_PIN
(
A
,
4
)
);
if
(
RT_NULL
==
rt_sfud_flash_probe
(
"W25Q64"
,
"spi10"
))
{
...
...
bsp/stm32/stm32f103-atk-nano/board/ports/spi_flash_init.c
浏览文件 @
7ff64c1c
...
...
@@ -17,7 +17,7 @@
static
int
rt_hw_spi_flash_init
(
void
)
{
__HAL_RCC_GPIOB_CLK_ENABLE
();
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
PIOB
,
GPIO_PIN_12
);
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
ET_PIN
(
B
,
12
)
);
if
(
RT_NULL
==
rt_sfud_flash_probe
(
"W25Q16"
,
"spi20"
))
{
...
...
bsp/stm32/stm32f103-dofly-M3S/applications/nrf24l01_init.c
浏览文件 @
7ff64c1c
...
...
@@ -15,7 +15,7 @@
#include "drv_spi.h"
static
int
rt_hw_nrf24l01_init
(
void
)
{
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
PIOG
,
GPIO_PIN_7
);
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
ET_PIN
(
G
,
7
)
);
return
RT_EOK
;
}
INIT_COMPONENT_EXPORT
(
rt_hw_nrf24l01_init
);
...
...
bsp/stm32/stm32f103-dofly-M3S/board/ports/drv_sdcard.c
浏览文件 @
7ff64c1c
...
...
@@ -70,7 +70,7 @@ INIT_APP_EXPORT(stm32_sdcard_mount);
static
int
rt_hw_spi2_tfcard
(
void
)
{
__HAL_RCC_GPIOC_CLK_ENABLE
();
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
PIOD
,
GPIO_PIN_2
);
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
ET_PIN
(
D
,
2
)
);
return
msd_init
(
"sd0"
,
"spi20"
);
}
INIT_DEVICE_EXPORT
(
rt_hw_spi2_tfcard
);
...
...
bsp/stm32/stm32f103-dofly-M3S/board/ports/spi_flash_init.c
浏览文件 @
7ff64c1c
...
...
@@ -17,7 +17,7 @@
static
int
rt_hw_spi_flash_init
(
void
)
{
__HAL_RCC_GPIOA_CLK_ENABLE
();
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
PIOB
,
GPIO_PIN_12
);
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
ET_PIN
(
B
,
12
)
);
if
(
RT_NULL
==
rt_sfud_flash_probe
(
"W25Q64"
,
"spi20"
))
{
...
...
bsp/stm32/stm32f103-fire-arbitrary/board/ports/spi_flash_init.c
浏览文件 @
7ff64c1c
...
...
@@ -17,7 +17,7 @@
static
int
rt_hw_spi_flash_init
(
void
)
{
__HAL_RCC_GPIOA_CLK_ENABLE
();
rt_hw_spi_device_attach
(
"spi1"
,
"spi10"
,
G
PIOA
,
GPIO_PIN_4
);
rt_hw_spi_device_attach
(
"spi1"
,
"spi10"
,
G
ET_PIN
(
A
,
4
)
);
if
(
RT_NULL
==
rt_sfud_flash_probe
(
"W25Q64"
,
"spi10"
))
{
...
...
bsp/stm32/stm32f103-fire-arbitrary/board/ports/w5500_device.c
浏览文件 @
7ff64c1c
...
...
@@ -13,6 +13,6 @@
int
w5500_spi_device_init
()
{
__HAL_RCC_GPIOG_CLK_ENABLE
();
return
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
PIOG
,
GPIO_PIN_9
);
return
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
ET_PIN
(
G
,
9
)
);
}
INIT_DEVICE_EXPORT
(
w5500_spi_device_init
);
bsp/stm32/stm32f103-hw100k-ibox/board/ports/w5500_device.c
浏览文件 @
7ff64c1c
...
...
@@ -14,6 +14,6 @@
int
w5500_spi_device_init
()
{
__HAL_RCC_GPIOB_CLK_ENABLE
();
return
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
GPIOB
,
GPIO_PIN_12
);
return
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
GET_PIN
(
B
,
12
)
);
}
INIT_DEVICE_EXPORT
(
w5500_spi_device_init
);
bsp/stm32/stm32f407-armfly-v5/board/ports/spi_flash_init.c
浏览文件 @
7ff64c1c
...
...
@@ -17,7 +17,7 @@
static
int
rt_hw_spi_flash_init
(
void
)
{
__HAL_RCC_GPIOF_CLK_ENABLE
();
rt_hw_spi_device_attach
(
"spi3"
,
"spi30"
,
G
PIOF
,
GPIO_PIN_8
);
rt_hw_spi_device_attach
(
"spi3"
,
"spi30"
,
G
ET_PIN
(
F
,
8
)
);
if
(
RT_NULL
==
rt_sfud_flash_probe
(
"W25Q64"
,
"spi30"
))
{
...
...
bsp/stm32/stm32f407-atk-explorer/board/ports/spi_flash_init.c
浏览文件 @
7ff64c1c
...
...
@@ -18,7 +18,7 @@
static
int
rt_hw_spi_flash_init
(
void
)
{
__HAL_RCC_GPIOB_CLK_ENABLE
();
rt_hw_spi_device_attach
(
"spi1"
,
"spi10"
,
G
PIOB
,
GPIO_PIN_14
);
rt_hw_spi_device_attach
(
"spi1"
,
"spi10"
,
G
ET_PIN
(
B
,
14
)
);
if
(
RT_NULL
==
rt_sfud_flash_probe
(
"W25Q128"
,
"spi10"
))
{
...
...
bsp/stm32/stm32f411-atk-nano/board/ports/spi_flash_init.c
浏览文件 @
7ff64c1c
...
...
@@ -17,7 +17,7 @@
static
int
rt_hw_spi_flash_init
(
void
)
{
__HAL_RCC_GPIOB_CLK_ENABLE
();
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
PIOB
,
GPIO_PIN_12
);
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
ET_PIN
(
B
,
12
)
);
if
(
RT_NULL
==
rt_sfud_flash_probe
(
"W25Q16"
,
"spi20"
))
{
...
...
bsp/stm32/stm32f429-armfly-v6/board/ports/spi_flash_init.c
浏览文件 @
7ff64c1c
...
...
@@ -17,7 +17,7 @@
static
int
rt_hw_spi_flash_init
(
void
)
{
__HAL_RCC_GPIOF_CLK_ENABLE
();
rt_hw_spi_device_attach
(
"spi3"
,
"spi30"
,
G
PIOD
,
GPIO_PIN_13
);
rt_hw_spi_device_attach
(
"spi3"
,
"spi30"
,
G
ET_PIN
(
D
,
13
)
);
if
(
RT_NULL
==
rt_sfud_flash_probe
(
"W25Q64"
,
"spi30"
))
{
...
...
bsp/stm32/stm32f429-atk-apollo/board/ports/spi_flash_init.c
浏览文件 @
7ff64c1c
...
...
@@ -17,7 +17,7 @@
static
int
rt_hw_spi_flash_init
(
void
)
{
__HAL_RCC_GPIOF_CLK_ENABLE
();
rt_hw_spi_device_attach
(
"spi5"
,
"spi50"
,
G
PIOF
,
GPIO_PIN_6
);
rt_hw_spi_device_attach
(
"spi5"
,
"spi50"
,
G
ET_PIN
(
F
,
6
)
);
if
(
RT_NULL
==
rt_sfud_flash_probe
(
"W25Q256"
,
"spi50"
))
{
...
...
bsp/stm32/stm32f429-fire-challenger/board/ports/spi_flash_init.c
浏览文件 @
7ff64c1c
...
...
@@ -17,7 +17,7 @@
static
int
rt_hw_spi_flash_init
(
void
)
{
__HAL_RCC_GPIOF_CLK_ENABLE
();
rt_hw_spi_device_attach
(
"spi5"
,
"spi50"
,
G
PIOF
,
GPIO_PIN_6
);
rt_hw_spi_device_attach
(
"spi5"
,
"spi50"
,
G
ET_PIN
(
F
,
6
)
);
if
(
RT_NULL
==
rt_sfud_flash_probe
(
"W25Q128"
,
"spi50"
))
{
...
...
bsp/stm32/stm32h750-artpi/board/port/drv_spi_ili9488.c
浏览文件 @
7ff64c1c
...
...
@@ -149,7 +149,7 @@ 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"
,
G
PIOI
,
GPIO_PIN_0
);
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
ET_PIN
(
I
,
0
)
);
lcd_gpio_init
();
rt_pin_write
(
LCD_RES_PIN
,
PIN_HIGH
);
...
...
bsp/stm32/stm32h750-artpi/board/port/spi_flash_init.c
浏览文件 @
7ff64c1c
...
...
@@ -18,7 +18,7 @@ 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"
,
G
PIOA
,
GPIO_PIN_4
);
rt_hw_spi_device_attach
(
"spi1"
,
"spi10"
,
G
ET_PIN
(
A
,
4
)
);
/* initialize SPI Flash device */
rt_sfud_flash_probe
(
"norflash0"
,
"spi10"
);
...
...
bsp/stm32/stm32h750-weact-ministm32h7xx/board/port/drv_spi_flash.c
浏览文件 @
7ff64c1c
...
...
@@ -27,7 +27,7 @@
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
);
rt_hw_spi_device_attach
(
"spi1"
,
"spi10"
,
GET_PIN
(
D
,
6
)
);
/* init W25Q16 , And register as a block device */
if
(
RT_NULL
==
rt_sfud_flash_probe
(
FAL_USING_NOR_FLASH_DEV_NAME
,
"spi10"
))
...
...
bsp/stm32/stm32l431-BearPi/board/ports/lcd/drv_lcd.c
浏览文件 @
7ff64c1c
...
...
@@ -37,7 +37,7 @@ static int rt_hw_lcd_config(void)
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
.
max_hz
=
42
*
1000
*
1000
;
/* 42M,
SPI max 42MHz,
lcd 4-wire spi */
rt_spi_configure
(
spi_dev_lcd
,
&
cfg
);
}
...
...
@@ -122,7 +122,7 @@ static void lcd_gpio_init(void)
static
int
rt_hw_lcd_init
(
void
)
{
rt_hw_spi_device_attach
(
"spi2"
,
"lcd"
,
G
PIOC
,
GPIO_PIN_3
);
rt_hw_spi_device_attach
(
"spi2"
,
"lcd"
,
G
ET_PIN
(
C
,
3
)
);
lcd_gpio_init
();
/* Memory Data Access Control */
lcd_write_cmd
(
0x36
);
...
...
bsp/stm32/stm32l475-atk-pandora/applications/nrf24l01_init.c
浏览文件 @
7ff64c1c
...
...
@@ -14,7 +14,7 @@
#include "drv_spi.h"
static
int
rt_hw_nrf24l01_init
(
void
)
{
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
PIOD
,
GPIO_PIN_5
);
rt_hw_spi_device_attach
(
"spi2"
,
"spi20"
,
G
ET_PIN
(
D
,
5
)
);
return
RT_EOK
;
}
INIT_COMPONENT_EXPORT
(
rt_hw_nrf24l01_init
);
...
...
bsp/stm32/stm32l475-atk-pandora/board/ports/drv_filesystem.c
浏览文件 @
7ff64c1c
...
...
@@ -32,7 +32,7 @@
static
int
rt_hw_spi1_tfcard
(
void
)
{
__HAL_RCC_GPIOC_CLK_ENABLE
();
rt_hw_spi_device_attach
(
"spi1"
,
"spi10"
,
G
PIOC
,
GPIO_PIN_3
);
rt_hw_spi_device_attach
(
"spi1"
,
"spi10"
,
G
ET_PIN
(
C
,
3
)
);
return
msd_init
(
"sd0"
,
"spi10"
);
}
INIT_DEVICE_EXPORT
(
rt_hw_spi1_tfcard
);
...
...
bsp/stm32/stm32l475-atk-pandora/board/ports/lcd/drv_lcd.c
浏览文件 @
7ff64c1c
...
...
@@ -130,7 +130,7 @@ static int rt_hw_lcd_init(void)
{
__HAL_RCC_GPIOD_CLK_ENABLE
();
rt_hw_spi_device_attach
(
"spi3"
,
"spi30"
,
G
PIOD
,
GPIO_PIN_7
);
rt_hw_spi_device_attach
(
"spi3"
,
"spi30"
,
G
ET_PIN
(
D
,
7
)
);
lcd_gpio_init
();
/* Memory Data Access Control */
...
...
bsp/stm32/stm32l496-ali-developer/board/ports/drv_spi_lcd.c
浏览文件 @
7ff64c1c
...
...
@@ -18,7 +18,7 @@
static
int
rt_hw_spi_lcd_init
(
void
)
{
rt_hw_spi_device_attach
(
"spi1"
,
"spi10"
,
G
PIOA
,
GPIO_PIN_4
);
rt_hw_spi_device_attach
(
"spi1"
,
"spi10"
,
G
ET_PIN
(
A
,
4
)
);
return
RT_EOK
;
}
...
...
bsp/stm32/stm32mp157a-st-discovery/board/ports/spi_sample.c
浏览文件 @
7ff64c1c
...
...
@@ -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"
,
PIN_NONE
);
cfg
.
data_width
=
8
;
cfg
.
mode
=
RT_SPI_MASTER
|
RT_SPI_MODE_0
|
RT_SPI_MSB
|
RT_SPI_NO_CS
;
...
...
bsp/stm32/stm32mp157a-st-ev1/board/ports/spi_sample.c
浏览文件 @
7ff64c1c
...
...
@@ -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
,
PIN_NONE
);
cfg
.
data_width
=
8
;
cfg
.
mode
=
RT_SPI_MASTER
|
RT_SPI_MODE_0
|
RT_SPI_MSB
|
RT_SPI_NO_CS
;
...
...
components/drivers/include/drivers/pin.h
浏览文件 @
7ff64c1c
...
...
@@ -25,6 +25,8 @@ struct rt_device_pin
const
struct
rt_pin_ops
*
ops
;
};
#define PIN_NONE (-1)
#define PIN_LOW 0x00
#define PIN_HIGH 0x01
...
...
@@ -43,7 +45,7 @@ struct rt_device_pin
#define PIN_IRQ_DISABLE 0x00
#define PIN_IRQ_ENABLE 0x01
#define PIN_IRQ_PIN_NONE
-1
#define PIN_IRQ_PIN_NONE
PIN_NONE
struct
rt_device_pin_mode
{
...
...
components/drivers/include/drivers/spi.h
浏览文件 @
7ff64c1c
...
...
@@ -15,7 +15,7 @@
#include <stdlib.h>
#include <rtthread.h>
#include <
rtdevice
.h>
#include <
drivers/pin
.h>
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -79,7 +79,6 @@ struct rt_spi_configuration
rt_uint8_t
mode
;
rt_uint8_t
data_width
;
rt_uint16_t
reserved
;
rt_base_t
cs_pin
;
rt_uint32_t
max_hz
;
};
...
...
@@ -113,6 +112,7 @@ struct rt_spi_device
struct
rt_spi_bus
*
bus
;
struct
rt_spi_configuration
config
;
rt_base_t
cs_pin
;
void
*
user_data
;
};
...
...
components/drivers/spi/spi_core.c
浏览文件 @
7ff64c1c
...
...
@@ -80,7 +80,6 @@ rt_err_t rt_spi_configure(struct rt_spi_device *device,
device
->
config
.
data_width
=
cfg
->
data_width
;
device
->
config
.
mode
=
cfg
->
mode
&
RT_SPI_MODE_MASK
;
device
->
config
.
max_hz
=
cfg
->
max_hz
;
device
->
config
.
cs_pin
=
cfg
->
cs_pin
;
if
(
device
->
bus
!=
RT_NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录