Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
AdRainty
rt-thread
提交
3ac00d4c
R
rt-thread
项目概览
AdRainty
/
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,发现更多精彩内容 >>
提交
3ac00d4c
编写于
4月 17, 2019
作者:
B
bluebear233
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp][nuvoton_m487]Add SPI drive
上级
adc6dd5d
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
477 addition
and
33 deletion
+477
-33
bsp/nuvoton_m487/.config
bsp/nuvoton_m487/.config
+118
-21
bsp/nuvoton_m487/README.md
bsp/nuvoton_m487/README.md
+7
-2
bsp/nuvoton_m487/applications/main.c
bsp/nuvoton_m487/applications/main.c
+12
-3
bsp/nuvoton_m487/driver/SConscript
bsp/nuvoton_m487/driver/SConscript
+2
-0
bsp/nuvoton_m487/driver/drv_qspi.c
bsp/nuvoton_m487/driver/drv_qspi.c
+270
-0
bsp/nuvoton_m487/driver/drv_spiflash.c
bsp/nuvoton_m487/driver/drv_spiflash.c
+45
-0
bsp/nuvoton_m487/driver/drv_uart.c
bsp/nuvoton_m487/driver/drv_uart.c
+0
-2
bsp/nuvoton_m487/libraries/StdDriver/inc/spi.h
bsp/nuvoton_m487/libraries/StdDriver/inc/spi.h
+2
-2
bsp/nuvoton_m487/rtconfig.h
bsp/nuvoton_m487/rtconfig.h
+21
-3
未找到文件。
bsp/nuvoton_m487/.config
浏览文件 @
3ac00d4c
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
# RT-Thread Kernel
# RT-Thread Kernel
#
#
CONFIG_RT_NAME_MAX
=
8
CONFIG_RT_NAME_MAX
=
8
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set
# CONFIG_RT_USING_SMP is not set
CONFIG_RT_ALIGN_SIZE
=
4
CONFIG_RT_ALIGN_SIZE
=
4
# CONFIG_RT_THREAD_PRIORITY_8 is not set
# CONFIG_RT_THREAD_PRIORITY_8 is not set
CONFIG_RT_THREAD_PRIORITY_32
=
y
CONFIG_RT_THREAD_PRIORITY_32
=
y
...
@@ -62,6 +64,7 @@ CONFIG_RT_USING_DEVICE=y
...
@@ -62,6 +64,7 @@ CONFIG_RT_USING_DEVICE=y
CONFIG_RT_USING_CONSOLE
=
y
CONFIG_RT_USING_CONSOLE
=
y
CONFIG_RT_CONSOLEBUF_SIZE
=
128
CONFIG_RT_CONSOLEBUF_SIZE
=
128
CONFIG_RT_CONSOLE_DEVICE_NAME
=
"uart0"
CONFIG_RT_CONSOLE_DEVICE_NAME
=
"uart0"
CONFIG_RT_VER_NUM
=
0
x40001
# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
#
#
...
@@ -88,7 +91,7 @@ CONFIG_FINSH_USING_SYMTAB=y
...
@@ -88,7 +91,7 @@ CONFIG_FINSH_USING_SYMTAB=y
CONFIG_FINSH_USING_DESCRIPTION
=
y
CONFIG_FINSH_USING_DESCRIPTION
=
y
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
CONFIG_FINSH_THREAD_PRIORITY
=
20
CONFIG_FINSH_THREAD_PRIORITY
=
20
CONFIG_FINSH_THREAD_STACK_SIZE
=
1024
CONFIG_FINSH_THREAD_STACK_SIZE
=
2048
CONFIG_FINSH_CMD_SIZE
=
80
CONFIG_FINSH_CMD_SIZE
=
80
# CONFIG_FINSH_USING_AUTH is not set
# CONFIG_FINSH_USING_AUTH is not set
CONFIG_FINSH_USING_MSH
=
y
CONFIG_FINSH_USING_MSH
=
y
...
@@ -100,12 +103,28 @@ CONFIG_FINSH_ARG_MAX=10
...
@@ -100,12 +103,28 @@ CONFIG_FINSH_ARG_MAX=10
# Device virtual file system
# Device virtual file system
#
#
CONFIG_RT_USING_DFS
=
y
CONFIG_RT_USING_DFS
=
y
# CONFIG_DFS_USING_WORKDIR is not set
CONFIG_DFS_USING_WORKDIR
=
y
CONFIG_DFS_FILESYSTEMS_MAX
=
1
CONFIG_DFS_FILESYSTEMS_MAX
=
2
CONFIG_DFS_FILESYSTEM_TYPES_MAX
=
2
CONFIG_DFS_FILESYSTEM_TYPES_MAX
=
2
CONFIG_DFS_FD_MAX
=
32
CONFIG_DFS_FD_MAX
=
32
# CONFIG_RT_USING_DFS_MNTTABLE is not set
# CONFIG_RT_USING_DFS_MNTTABLE is not set
# CONFIG_RT_USING_DFS_ELMFAT is not set
CONFIG_RT_USING_DFS_ELMFAT
=
y
#
# elm-chan's FatFs, Generic FAT Filesystem Module
#
CONFIG_RT_DFS_ELM_CODE_PAGE
=
437
CONFIG_RT_DFS_ELM_WORD_ACCESS
=
y
# CONFIG_RT_DFS_ELM_USE_LFN_0 is not set
# CONFIG_RT_DFS_ELM_USE_LFN_1 is not set
# CONFIG_RT_DFS_ELM_USE_LFN_2 is not set
CONFIG_RT_DFS_ELM_USE_LFN_3
=
y
CONFIG_RT_DFS_ELM_USE_LFN
=
3
CONFIG_RT_DFS_ELM_MAX_LFN
=
255
CONFIG_RT_DFS_ELM_DRIVES
=
2
CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE
=
4096
# CONFIG_RT_DFS_ELM_USE_ERASE is not set
CONFIG_RT_DFS_ELM_REENTRANT
=
y
CONFIG_RT_USING_DFS_DEVFS
=
y
CONFIG_RT_USING_DFS_DEVFS
=
y
# CONFIG_RT_USING_DFS_ROMFS is not set
# CONFIG_RT_USING_DFS_ROMFS is not set
# CONFIG_RT_USING_DFS_RAMFS is not set
# CONFIG_RT_USING_DFS_RAMFS is not set
...
@@ -120,11 +139,13 @@ CONFIG_RT_USING_DEVICE_IPC=y
...
@@ -120,11 +139,13 @@ CONFIG_RT_USING_DEVICE_IPC=y
CONFIG_RT_PIPE_BUFSZ
=
64
CONFIG_RT_PIPE_BUFSZ
=
64
CONFIG_RT_USING_SERIAL
=
y
CONFIG_RT_USING_SERIAL
=
y
CONFIG_RT_SERIAL_USING_DMA
=
y
CONFIG_RT_SERIAL_USING_DMA
=
y
CONFIG_RT_SERIAL_RB_BUFSZ
=
64
# CONFIG_RT_USING_CAN is not set
# CONFIG_RT_USING_CAN is not set
# CONFIG_RT_USING_HWTIMER is not set
# CONFIG_RT_USING_HWTIMER is not set
# CONFIG_RT_USING_CPUTIME is not set
# CONFIG_RT_USING_CPUTIME is not set
# CONFIG_RT_USING_I2C is not set
# CONFIG_RT_USING_I2C is not set
# CONFIG_RT_USING_PIN is not set
# CONFIG_RT_USING_PIN is not set
# CONFIG_RT_USING_ADC is not set
# CONFIG_RT_USING_PWM is not set
# CONFIG_RT_USING_PWM is not set
# CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NAND is not set
# CONFIG_RT_USING_MTD_NAND is not set
...
@@ -132,9 +153,17 @@ CONFIG_RT_SERIAL_USING_DMA=y
...
@@ -132,9 +153,17 @@ CONFIG_RT_SERIAL_USING_DMA=y
# CONFIG_RT_USING_PM is not set
# CONFIG_RT_USING_PM is not set
# CONFIG_RT_USING_RTC is not set
# CONFIG_RT_USING_RTC is not set
# CONFIG_RT_USING_SDIO is not set
# CONFIG_RT_USING_SDIO is not set
# CONFIG_RT_USING_SPI is not set
CONFIG_RT_USING_SPI
=
y
# CONFIG_RT_USING_QSPI is not set
# CONFIG_RT_USING_SPI_MSD is not set
# CONFIG_RT_USING_SFUD is not set
CONFIG_RT_USING_W25QXX
=
y
# CONFIG_RT_USING_GD is not set
# CONFIG_RT_USING_ENC28J60 is not set
# CONFIG_RT_USING_SPI_WIFI is not set
# CONFIG_RT_USING_WDT is not set
# CONFIG_RT_USING_WDT is not set
# CONFIG_RT_USING_AUDIO is not set
# CONFIG_RT_USING_AUDIO is not set
# CONFIG_RT_USING_SENSOR is not set
#
#
# Using WiFi
# Using WiFi
...
@@ -218,6 +247,7 @@ CONFIG_LWIP_SO_RCVBUF=1
...
@@ -218,6 +247,7 @@ CONFIG_LWIP_SO_RCVBUF=1
# CONFIG_RT_LWIP_NETIF_LOOPBACK is not set
# CONFIG_RT_LWIP_NETIF_LOOPBACK is not set
CONFIG_LWIP_NETIF_LOOPBACK
=
0
CONFIG_LWIP_NETIF_LOOPBACK
=
0
# CONFIG_RT_LWIP_STATS is not set
# CONFIG_RT_LWIP_STATS is not set
# CONFIG_RT_LWIP_USING_HW_CHECKSUM is not set
# CONFIG_RT_LWIP_DEBUG is not set
# CONFIG_RT_LWIP_DEBUG is not set
#
#
...
@@ -242,36 +272,26 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
...
@@ -242,36 +272,26 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
# CONFIG_RT_USING_LOGTRACE is not set
# CONFIG_RT_USING_LOGTRACE is not set
# CONFIG_RT_USING_RYM is not set
# CONFIG_RT_USING_RYM is not set
# CONFIG_RT_USING_ULOG is not set
# CONFIG_RT_USING_ULOG is not set
# CONFIG_RT_USING_UTEST is not set
#
#
# RT-Thread online packages
# RT-Thread online packages
#
#
#
# system packages
#
#
# RT-Thread GUI Engine
#
# CONFIG_PKG_USING_GUIENGINE is not set
# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_PARTITION is not set
# CONFIG_PKG_USING_SQLITE is not set
# CONFIG_PKG_USING_RTI is not set
#
#
# IoT - internet of things
# IoT - internet of things
#
#
# CONFIG_PKG_USING_PAHOMQTT is not set
# CONFIG_PKG_USING_PAHOMQTT is not set
# CONFIG_PKG_USING_WEBCLIENT is not set
# CONFIG_PKG_USING_WEBCLIENT is not set
# CONFIG_PKG_USING_WEBNET is not set
# CONFIG_PKG_USING_MONGOOSE is not set
# CONFIG_PKG_USING_MONGOOSE is not set
# CONFIG_PKG_USING_WEBTERMINAL is not set
# CONFIG_PKG_USING_WEBTERMINAL is not set
# CONFIG_PKG_USING_CJSON is not set
# CONFIG_PKG_USING_CJSON is not set
# CONFIG_PKG_USING_JSMN is not set
# CONFIG_PKG_USING_LIBMODBUS is not set
# CONFIG_PKG_USING_LJSON is not set
# CONFIG_PKG_USING_LJSON is not set
# CONFIG_PKG_USING_EZXML is not set
# CONFIG_PKG_USING_EZXML is not set
# CONFIG_PKG_USING_NANOPB is not set
# CONFIG_PKG_USING_NANOPB is not set
# CONFIG_PKG_USING_GAGENT_CLOUD is not set
#
#
# Wi-Fi
# Wi-Fi
...
@@ -286,9 +306,23 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
...
@@ -286,9 +306,23 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
# Wiced WiFi
# Wiced WiFi
#
#
# CONFIG_PKG_USING_WLAN_WICED is not set
# CONFIG_PKG_USING_WLAN_WICED is not set
# CONFIG_PKG_USING_RW007 is not set
# CONFIG_PKG_USING_COAP is not set
# CONFIG_PKG_USING_COAP is not set
# CONFIG_PKG_USING_NOPOLL is not set
# CONFIG_PKG_USING_NOPOLL is not set
# CONFIG_PKG_USING_NETUTILS is not set
# CONFIG_PKG_USING_NETUTILS is not set
# CONFIG_PKG_USING_AT_DEVICE is not set
# CONFIG_PKG_USING_WIZNET is not set
#
# IoT Cloud
#
# CONFIG_PKG_USING_ONENET is not set
# CONFIG_PKG_USING_GAGENT_CLOUD is not set
# CONFIG_PKG_USING_ALI_IOTKIT is not set
# CONFIG_PKG_USING_AZURE is not set
# CONFIG_PKG_USING_TENCENT_IOTKIT is not set
# CONFIG_PKG_USING_NIMBLE is not set
# CONFIG_PKG_USING_OTA_DOWNLOADER is not set
#
#
# security packages
# security packages
...
@@ -300,6 +334,7 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
...
@@ -300,6 +334,7 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
#
#
# language packages
# language packages
#
#
# CONFIG_PKG_USING_LUA is not set
# CONFIG_PKG_USING_JERRYSCRIPT is not set
# CONFIG_PKG_USING_JERRYSCRIPT is not set
# CONFIG_PKG_USING_MICROPYTHON is not set
# CONFIG_PKG_USING_MICROPYTHON is not set
...
@@ -307,24 +342,86 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
...
@@ -307,24 +342,86 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
# multimedia packages
# multimedia packages
#
#
# CONFIG_PKG_USING_OPENMV is not set
# CONFIG_PKG_USING_OPENMV is not set
# CONFIG_PKG_USING_MUPDF is not set
#
#
# tools packages
# tools packages
#
#
# CONFIG_PKG_USING_CMBACKTRACE is not set
# CONFIG_PKG_USING_CMBACKTRACE is not set
# CONFIG_PKG_USING_EASYFLASH is not set
# CONFIG_PKG_USING_EASYLOGGER is not set
# CONFIG_PKG_USING_EASYLOGGER is not set
# CONFIG_PKG_USING_SYSTEMVIEW is not set
# CONFIG_PKG_USING_SYSTEMVIEW is not set
# CONFIG_PKG_USING_IPERF is not set
# CONFIG_PKG_USING_RDB is not set
# CONFIG_PKG_USING_QRCODE is not set
# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
# CONFIG_PKG_USING_ADBD is not set
#
# system packages
#
# CONFIG_PKG_USING_GUIENGINE is not set
# CONFIG_PKG_USING_CAIRO is not set
# CONFIG_PKG_USING_PIXMAN is not set
# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_PARTITION is not set
# CONFIG_PKG_USING_FAL is not set
# CONFIG_PKG_USING_SQLITE is not set
# CONFIG_PKG_USING_RTI is not set
# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
# CONFIG_PKG_USING_CMSIS is not set
# CONFIG_PKG_USING_DFS_YAFFS is not set
# CONFIG_PKG_USING_LITTLEFS is not set
#
# peripheral libraries and drivers
#
#
# sensors drivers
#
# CONFIG_PKG_USING_LSM6DSL is not set
# CONFIG_PKG_USING_LPS22HB is not set
# CONFIG_PKG_USING_HTS221 is not set
# CONFIG_PKG_USING_LSM303AGR is not set
# CONFIG_PKG_USING_BME280 is not set
# CONFIG_PKG_USING_BMA400 is not set
# CONFIG_PKG_USING_BMI160_BMX160 is not set
# CONFIG_PKG_USING_SPL0601 is not set
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
# CONFIG_PKG_USING_SHT2X is not set
# CONFIG_PKG_USING_AHT10 is not set
# CONFIG_PKG_USING_AP3216C is not set
# CONFIG_PKG_USING_STM32_SDIO is not set
# CONFIG_PKG_USING_ICM20608 is not set
# CONFIG_PKG_USING_U8G2 is not set
# CONFIG_PKG_USING_BUTTON is not set
# CONFIG_PKG_USING_MPU6XXX is not set
# CONFIG_PKG_USING_PCF8574 is not set
# CONFIG_PKG_USING_SX12XX is not set
# CONFIG_PKG_USING_SIGNAL_LED is not set
# CONFIG_PKG_USING_KENDRYTE_SDK is not set
#
#
# miscellaneous packages
# miscellaneous packages
#
#
# CONFIG_PKG_USING_LIBCSV is not set
# CONFIG_PKG_USING_OPTPARSE is not set
# CONFIG_PKG_USING_FASTLZ is not set
# CONFIG_PKG_USING_FASTLZ is not set
# CONFIG_PKG_USING_MINILZO is not set
# CONFIG_PKG_USING_MINILZO is not set
# CONFIG_PKG_USING_QUICKLZ is not set
# CONFIG_PKG_USING_QUICKLZ is not set
# CONFIG_PKG_USING_MULTIBUTTON is not set
# CONFIG_PKG_USING_MULTIBUTTON is not set
# CONFIG_PKG_USING_CANFESTIVAL is not set
# CONFIG_PKG_USING_ZLIB is not set
# CONFIG_PKG_USING_DSTR is not set
# CONFIG_PKG_USING_TINYFRAME is not set
# CONFIG_PKG_USING_KENDRYTE_DEMO is not set
#
#
#
example package: hello
#
samples: kernel and components samples
#
#
# CONFIG_PKG_USING_KERNEL_SAMPLES is not set
# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set
# CONFIG_PKG_USING_NETWORK_SAMPLES is not set
# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
# CONFIG_PKG_USING_HELLO is not set
# CONFIG_PKG_USING_HELLO is not set
# CONFIG_PKG_USING_VI is not set
bsp/nuvoton_m487/README.md
浏览文件 @
3ac00d4c
...
@@ -31,11 +31,13 @@
...
@@ -31,11 +31,13 @@
连接好串口,可以使用115200-N-8-1的配置方式连接到设备上。设备使用的串口引脚是:
`[Tx:PB13 Rx:PB12]`
连接好串口,可以使用115200-N-8-1的配置方式连接到设备上。设备使用的串口引脚是:
`[Tx:PB13 Rx:PB12]`
当正确编译产生出rtthread.bin映像文件后,可以使用N
U
-link或者JLINK下载
当正确编译产生出rtthread.bin映像文件后,可以使用N
u
-link或者JLINK下载
### 3.1 运行结果
### 3.1 运行结果
如果编译 & 烧写无误,当复位设备后,会在串口上看到RT-Thread的启动logo信息:
如果编译 & 烧写无误,当复位设备后,会在串口上看到RT-Thread的启动logo信息
如挂载根目录失败,需要格式化SPI FLASH,请输入
`mkfs -t elm flash0`
## 4. 驱动支持情况及计划
## 4. 驱动支持情况及计划
...
@@ -43,6 +45,9 @@
...
@@ -43,6 +45,9 @@
| ------ | ---- | :------: |
| ------ | ---- | :------: |
| UART | 支持 | UART0|
| UART | 支持 | UART0|
| EMAC | 支持 | EH0|
| EMAC | 支持 | EH0|
| QSPI | 支持 | QSPI0|
| SPIFLASH | 支持 | W25Q32 |
### 4.1 IO在板级支持包中的映射情况
### 4.1 IO在板级支持包中的映射情况
...
...
bsp/nuvoton_m487/applications/main.c
浏览文件 @
3ac00d4c
...
@@ -9,10 +9,19 @@
...
@@ -9,10 +9,19 @@
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <dfs_fs.h>
#include <rtthread.h>
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
printf
(
"Hello RT-Thread!
\n
"
);
#ifdef RT_USING_DFS
if
(
dfs_mount
(
"flash0"
,
"/"
,
"efm"
,
0
,
0
)
==
0
)
return
0
;
{
rt_kprintf
(
"mount efm ok
\n
"
);
}
else
{
rt_kprintf
(
"mount efm fail
\n
"
);
}
#endif
}
}
bsp/nuvoton_m487/driver/SConscript
浏览文件 @
3ac00d4c
...
@@ -7,6 +7,8 @@ src = Split('''
...
@@ -7,6 +7,8 @@ src = Split('''
board.c
board.c
drv_uart.c
drv_uart.c
drv_emac.c
drv_emac.c
drv_qspi.c
drv_spiflash.c
'''
)
'''
)
CPPPATH
=
[
cwd
]
CPPPATH
=
[
cwd
]
...
...
bsp/nuvoton_m487/driver/drv_qspi.c
0 → 100644
浏览文件 @
3ac00d4c
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-3-30 bluebear233 first version
*/
#include "NuMicro.h"
#include <rtdevice.h>
#ifdef RT_USING_SPI
/* Private Define ---------------------------------------------------------------*/
#define USEING_QSPI0
/* Private Typedef --------------------------------------------------------------*/
struct
m487_qspi
{
struct
rt_spi_bus
dev
;
struct
rt_spi_configuration
configuration
;
QSPI_T
*
spi_base
;
rt_uint8_t
init_gpio
:
1
;
};
/* Private functions ------------------------------------------------------------*/
static
rt_err_t
m487_qspi_bus_configure
(
struct
rt_spi_device
*
device
,
struct
rt_spi_configuration
*
configuration
);
static
rt_uint32_t
m487_qspi_bus_xfer
(
struct
rt_spi_device
*
device
,
struct
rt_spi_message
*
message
);
/* Private Variables ------------------------------------------------------------*/
struct
rt_spi_ops
m487_spi_poll_ops
=
{
.
configure
=
m487_qspi_bus_configure
,
.
xfer
=
m487_qspi_bus_xfer
,
};
#ifdef USEING_QSPI0
static
struct
m487_qspi
qspi0
=
{
.
spi_base
=
QSPI0
,
};
#endif
static
rt_err_t
m487_qspi_bus_configure
(
struct
rt_spi_device
*
device
,
struct
rt_spi_configuration
*
configuration
)
{
struct
m487_qspi
*
spi
;
uint32_t
u32QSPIMode
;
uint32_t
u32BusClock
;
rt_uint8_t
init_bus
;
spi
=
(
struct
m487_qspi
*
)
device
->
bus
;
init_bus
=
0
;
if
(
!
spi
->
init_gpio
)
{
spi
->
init_gpio
=
1
;
init_bus
=
1
;
if
(
spi
->
spi_base
==
QSPI0
)
{
/* Select PCLK0 as the clock source of QSPI0 */
CLK_SetModuleClock
(
QSPI0_MODULE
,
CLK_CLKSEL2_QSPI0SEL_PLL
,
MODULE_NoMsk
);
/* Enable QSPI0 peripheral clock */
CLK_EnableModuleClock
(
QSPI0_MODULE
);
/* Setup QSPI0 multi-function pins */
SYS
->
GPC_MFPL
&=
~
(
SYS_GPC_MFPL_PC0MFP_Msk
|
SYS_GPC_MFPL_PC1MFP_Msk
|
SYS_GPC_MFPL_PC2MFP_Msk
|
SYS_GPC_MFPL_PC3MFP_Msk
);
SYS
->
GPC_MFPL
|=
SYS_GPC_MFPL_PC0MFP_QSPI0_MOSI0
|
SYS_GPC_MFPL_PC1MFP_QSPI0_MISO0
|
SYS_GPC_MFPL_PC2MFP_QSPI0_CLK
|
SYS_GPC_MFPL_PC3MFP_QSPI0_SS
;
/* Enable SPI0 clock pin (PC2) schmitt trigger */
PC
->
SMTEN
|=
GPIO_SMTEN_SMTEN2_Msk
;
}
}
if
(
rt_memcmp
(
configuration
,
&
spi
->
configuration
,
sizeof
(
*
configuration
))
!=
0
)
{
rt_memcpy
(
&
spi
->
configuration
,
configuration
,
sizeof
(
*
configuration
));
init_bus
=
1
;
}
if
(
init_bus
)
{
switch
(
configuration
->
mode
&
RT_SPI_MODE_3
)
{
case
RT_SPI_MODE_0
:
u32QSPIMode
=
QSPI_MODE_0
;
break
;
case
RT_SPI_MODE_1
:
u32QSPIMode
=
QSPI_MODE_1
;
break
;
case
RT_SPI_MODE_2
:
u32QSPIMode
=
QSPI_MODE_2
;
break
;
case
RT_SPI_MODE_3
:
u32QSPIMode
=
QSPI_MODE_3
;
break
;
default:
RT_ASSERT
(
0
);
}
u32BusClock
=
configuration
->
max_hz
;
if
(
u32BusClock
>
50
*
1000
*
1000
)
{
u32BusClock
=
50
*
1000
*
1000
;
}
QSPI_Open
(
spi
->
spi_base
,
QSPI_MASTER
,
u32QSPIMode
,
configuration
->
data_width
,
u32BusClock
);
QSPI_EnableAutoSS
(
spi
->
spi_base
,
QSPI_SS
,
QSPI_SS_ACTIVE_LOW
);
if
(
configuration
->
mode
&
RT_SPI_MSB
)
{
QSPI_SET_MSB_FIRST
(
spi
->
spi_base
);
}
else
{
QSPI_SET_LSB_FIRST
(
spi
->
spi_base
);
}
}
return
RT_EOK
;
}
/**
* @brief SPI bus 轮询
* @param dev : SPI总线设备结构体指针
* @param send_addr : 发送缓冲区地址
* @param recv_addr : 接收缓冲区地址
* @param length : 数据长度
*/
static
void
qspi_transmission_with_poll
(
struct
m487_qspi
*
spi_bus
,
const
uint8_t
*
send_addr
,
uint8_t
*
recv_addr
,
int
length
)
{
QSPI_T
*
spi_base
=
spi_bus
->
spi_base
;
// 写
if
(
send_addr
!=
RT_NULL
&&
recv_addr
==
RT_NULL
)
{
while
(
length
--
)
{
// 等待TX FIFO 为空
while
(
QSPI_GET_TX_FIFO_FULL_FLAG
(
spi_base
));
// 输入数据
QSPI_WRITE_TX
(
spi_base
,
*
send_addr
++
);
}
// 等待SPI空闲
while
(
QSPI_IS_BUSY
(
spi_base
));
}
// 读写
else
if
(
send_addr
!=
RT_NULL
&&
recv_addr
!=
RT_NULL
)
{
// 清空读FIFO
if
(
!
QSPI_GET_RX_FIFO_EMPTY_FLAG
(
spi_base
))
{
QSPI_ClearRxFIFO
(
spi_base
);
while
(
!
QSPI_GET_RX_FIFO_EMPTY_FLAG
(
spi_base
));
}
while
(
length
--
)
{
// 等待TX FIFO 为空
while
(
QSPI_GET_TX_FIFO_FULL_FLAG
(
spi_base
));
// 输入数据
QSPI_WRITE_TX
(
spi_base
,
*
send_addr
++
);
// 读取RX FIFO
while
(
!
QSPI_GET_RX_FIFO_EMPTY_FLAG
(
spi_base
))
{
*
recv_addr
++
=
QSPI_READ_RX
(
spi_base
);
}
}
// 等待SPI空闲
while
(
QSPI_IS_BUSY
(
spi_base
))
{
while
(
!
QSPI_GET_RX_FIFO_EMPTY_FLAG
(
spi_base
))
{
*
recv_addr
++
=
QSPI_READ_RX
(
spi_base
);
}
}
}
//读
else
{
// 清空读FIFO
if
(
!
QSPI_GET_RX_FIFO_EMPTY_FLAG
(
spi_base
))
{
QSPI_ClearRxFIFO
(
spi_base
);
while
(
!
QSPI_GET_RX_FIFO_EMPTY_FLAG
(
spi_base
));
}
while
(
length
--
)
{
// 等待TX FIFO 为空
while
(
QSPI_GET_TX_FIFO_FULL_FLAG
(
spi_base
));
// 输入数据
QSPI_WRITE_TX
(
spi_base
,
0x00
);
// 读取RX FIFO
while
(
!
QSPI_GET_RX_FIFO_EMPTY_FLAG
(
spi_base
))
{
*
recv_addr
++
=
QSPI_READ_RX
(
spi_base
);
}
}
// 等待SPI空闲
while
(
QSPI_IS_BUSY
(
spi_base
))
{
while
(
!
QSPI_GET_RX_FIFO_EMPTY_FLAG
(
spi_base
))
{
*
recv_addr
++
=
QSPI_READ_RX
(
spi_base
);
}
}
while
(
!
QSPI_GET_RX_FIFO_EMPTY_FLAG
(
spi_base
))
{
*
recv_addr
++
=
QSPI_READ_RX
(
spi_base
);
}
}
}
static
rt_uint32_t
m487_qspi_bus_xfer
(
struct
rt_spi_device
*
device
,
struct
rt_spi_message
*
message
)
{
struct
m487_qspi
*
spi
;
spi
=
(
struct
m487_qspi
*
)
device
->
bus
;
if
(
message
->
cs_take
)
{
QSPI_SET_SS_LOW
(
spi
->
spi_base
);
}
if
(
message
->
length
>
0
)
{
qspi_transmission_with_poll
(
spi
,
message
->
send_buf
,
message
->
recv_buf
,
message
->
length
);
}
if
(
message
->
cs_release
)
{
QSPI_SET_SS_HIGH
(
spi
->
spi_base
);
}
return
message
->
length
;
}
static
int
m487_qspi_register_bus
(
struct
m487_qspi
*
spi_bus
,
const
char
*
name
)
{
return
rt_spi_bus_register
(
&
spi_bus
->
dev
,
name
,
&
m487_spi_poll_ops
);
}
/**
* 硬件QSPI注册
*/
static
int
rt_hw_qspi_init
(
void
)
{
#ifdef USEING_QSPI0
m487_qspi_register_bus
(
&
qspi0
,
"qspi0"
);
#endif
return
0
;
}
INIT_DEVICE_EXPORT
(
rt_hw_qspi_init
);
#endif
bsp/nuvoton_m487/driver/drv_spiflash.c
0 → 100644
浏览文件 @
3ac00d4c
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-3-30 bluebear233 first version
*/
#include <rtdevice.h>
#ifdef RT_USING_SPI
#if defined(RT_USING_W25QXX) || defined(RT_USING_SFUD)
static
struct
rt_spi_device
spi_device
;
#ifdef RT_USING_W25QXX
#include "spi_flash_w25qxx.h"
#elif defined(RT_USING_SFUD)
#include "spi_flash.h"
#include "spi_flash_sfud.h"
#endif
static
int
rt_hw_spi_flash_init
(
void
)
{
rt_spi_bus_attach_device
(
&
spi_device
,
"qspi01"
,
"qspi0"
,
RT_NULL
);
#ifdef RT_USING_W25QXX
return
w25qxx_init
(
"flash0"
,
"qspi01"
);
#elif defined(RT_USING_SFUD)
if
(
rt_sfud_flash_probe
(
"flash0"
,
"qspi01"
)
==
RT_NULL
)
{
return
-
RT_ERROR
;
}
#endif
return
0
;
}
INIT_COMPONENT_EXPORT
(
rt_hw_spi_flash_init
);
#endif
#endif
bsp/nuvoton_m487/driver/drv_uart.c
浏览文件 @
3ac00d4c
...
@@ -26,8 +26,6 @@ struct usart
...
@@ -26,8 +26,6 @@ struct usart
typedef
struct
usart
*
usart_t
;
typedef
struct
usart
*
usart_t
;
/* Private functions ------------------------------------------------------------*/
/* Private functions ------------------------------------------------------------*/
static
rt_err_t
usart_gpio_configure
(
struct
rt_serial_device
*
serial
);
static
rt_err_t
usart_gpio_configure
(
struct
rt_serial_device
*
serial
);
static
rt_err_t
usart_configure
(
struct
rt_serial_device
*
serial
,
struct
serial_configure
*
cfg
);
static
rt_err_t
usart_configure
(
struct
rt_serial_device
*
serial
,
struct
serial_configure
*
cfg
);
static
rt_err_t
usart_control
(
struct
rt_serial_device
*
serial
,
int
cmd
,
void
*
arg
);
static
rt_err_t
usart_control
(
struct
rt_serial_device
*
serial
,
int
cmd
,
void
*
arg
);
...
...
bsp/nuvoton_m487/libraries/StdDriver/inc/spi.h
浏览文件 @
3ac00d4c
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
*
*
* @copyright (C) 2016 Nuvoton Technology Corp. All rights reserved.
* @copyright (C) 2016 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/
*****************************************************************************/
#ifndef __SPI_H__
#ifndef __
_
SPI_H__
#define __SPI_H__
#define __
_
SPI_H__
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
extern
"C"
...
...
bsp/nuvoton_m487/rtconfig.h
浏览文件 @
3ac00d4c
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
#define RT_USING_CONSOLE
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart0"
#define RT_CONSOLE_DEVICE_NAME "uart0"
#define RT_VER_NUM 0x4000
0
#define RT_VER_NUM 0x4000
1
/* RT-Thread Components */
/* RT-Thread Components */
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
#define FINSH_USING_SYMTAB
#define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION
#define FINSH_USING_DESCRIPTION
#define FINSH_THREAD_PRIORITY 20
#define FINSH_THREAD_PRIORITY 20
#define FINSH_THREAD_STACK_SIZE
1024
#define FINSH_THREAD_STACK_SIZE
2048
#define FINSH_CMD_SIZE 80
#define FINSH_CMD_SIZE 80
#define FINSH_USING_MSH
#define FINSH_USING_MSH
#define FINSH_USING_MSH_DEFAULT
#define FINSH_USING_MSH_DEFAULT
...
@@ -67,9 +67,22 @@
...
@@ -67,9 +67,22 @@
/* Device virtual file system */
/* Device virtual file system */
#define RT_USING_DFS
#define RT_USING_DFS
#define DFS_FILESYSTEMS_MAX 1
#define DFS_USING_WORKDIR
#define DFS_FILESYSTEMS_MAX 2
#define DFS_FILESYSTEM_TYPES_MAX 2
#define DFS_FILESYSTEM_TYPES_MAX 2
#define DFS_FD_MAX 32
#define DFS_FD_MAX 32
#define RT_USING_DFS_ELMFAT
/* elm-chan's FatFs, Generic FAT Filesystem Module */
#define RT_DFS_ELM_CODE_PAGE 437
#define RT_DFS_ELM_WORD_ACCESS
#define RT_DFS_ELM_USE_LFN_3
#define RT_DFS_ELM_USE_LFN 3
#define RT_DFS_ELM_MAX_LFN 255
#define RT_DFS_ELM_DRIVES 2
#define RT_DFS_ELM_MAX_SECTOR_SIZE 4096
#define RT_DFS_ELM_REENTRANT
#define RT_USING_DFS_DEVFS
#define RT_USING_DFS_DEVFS
/* Device Drivers */
/* Device Drivers */
...
@@ -78,6 +91,9 @@
...
@@ -78,6 +91,9 @@
#define RT_PIPE_BUFSZ 64
#define RT_PIPE_BUFSZ 64
#define RT_USING_SERIAL
#define RT_USING_SERIAL
#define RT_SERIAL_USING_DMA
#define RT_SERIAL_USING_DMA
#define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_SPI
#define RT_USING_W25QXX
/* Using WiFi */
/* Using WiFi */
...
@@ -180,6 +196,8 @@
...
@@ -180,6 +196,8 @@
/* peripheral libraries and drivers */
/* peripheral libraries and drivers */
/* sensors drivers */
/* miscellaneous packages */
/* miscellaneous packages */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录