[BSP]add BSP for Winner Micro W60X devices。

This commit is contained in:
Wenlong.Fan
2019-03-27 16:49:26 +08:00
parent d7f849c879
commit 7b7ca405b0
61 changed files with 12519 additions and 0 deletions

490
bsp/w60x/.config Normal file
View File

@@ -0,0 +1,490 @@
#
# Automatically generated file; DO NOT EDIT.
# RT-Thread Configuration
#
#
# RT-Thread Kernel
#
CONFIG_RT_NAME_MAX=8
# CONFIG_RT_USING_SMP is not set
CONFIG_RT_ALIGN_SIZE=4
# CONFIG_RT_THREAD_PRIORITY_8 is not set
CONFIG_RT_THREAD_PRIORITY_32=y
# CONFIG_RT_THREAD_PRIORITY_256 is not set
CONFIG_RT_THREAD_PRIORITY_MAX=32
CONFIG_RT_TICK_PER_SECOND=1000
CONFIG_RT_USING_OVERFLOW_CHECK=y
CONFIG_RT_USING_HOOK=y
CONFIG_RT_USING_IDLE_HOOK=y
CONFIG_RT_IDEL_HOOK_LIST_SIZE=4
CONFIG_IDLE_THREAD_STACK_SIZE=256
CONFIG_RT_USING_TIMER_SOFT=y
CONFIG_RT_TIMER_THREAD_PRIO=4
CONFIG_RT_TIMER_THREAD_STACK_SIZE=512
CONFIG_RT_DEBUG=y
CONFIG_RT_DEBUG_COLOR=y
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
# CONFIG_RT_DEBUG_THREAD_CONFIG is not set
# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set
# CONFIG_RT_DEBUG_IPC_CONFIG is not set
# CONFIG_RT_DEBUG_TIMER_CONFIG is not set
# CONFIG_RT_DEBUG_IRQ_CONFIG is not set
# CONFIG_RT_DEBUG_MEM_CONFIG is not set
# CONFIG_RT_DEBUG_SLAB_CONFIG is not set
# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set
# CONFIG_RT_DEBUG_MODULE_CONFIG is not set
#
# Inter-Thread communication
#
CONFIG_RT_USING_SEMAPHORE=y
CONFIG_RT_USING_MUTEX=y
CONFIG_RT_USING_EVENT=y
CONFIG_RT_USING_MAILBOX=y
CONFIG_RT_USING_MESSAGEQUEUE=y
# CONFIG_RT_USING_SIGNALS is not set
#
# Memory Management
#
CONFIG_RT_USING_MEMPOOL=y
# CONFIG_RT_USING_MEMHEAP is not set
# CONFIG_RT_USING_NOHEAP is not set
CONFIG_RT_USING_SMALL_MEM=y
# CONFIG_RT_USING_SLAB is not set
# CONFIG_RT_USING_MEMTRACE is not set
CONFIG_RT_USING_HEAP=y
#
# Kernel Device Object
#
CONFIG_RT_USING_DEVICE=y
# CONFIG_RT_USING_DEVICE_OPS is not set
# CONFIG_RT_USING_INTERRUPT_INFO is not set
CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128
CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
CONFIG_RT_VER_NUM=0x40001
# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
#
# RT-Thread Components
#
CONFIG_RT_USING_COMPONENTS_INIT=y
CONFIG_RT_USING_USER_MAIN=y
CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048
CONFIG_RT_MAIN_THREAD_PRIORITY=10
#
# C++ features
#
# CONFIG_RT_USING_CPLUSPLUS is not set
#
# Command shell
#
CONFIG_RT_USING_FINSH=y
CONFIG_FINSH_THREAD_NAME="tshell"
CONFIG_FINSH_USING_HISTORY=y
CONFIG_FINSH_HISTORY_LINES=5
CONFIG_FINSH_USING_SYMTAB=y
CONFIG_FINSH_USING_DESCRIPTION=y
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
CONFIG_FINSH_THREAD_PRIORITY=20
CONFIG_FINSH_THREAD_STACK_SIZE=4096
CONFIG_FINSH_CMD_SIZE=80
# CONFIG_FINSH_USING_AUTH is not set
CONFIG_FINSH_USING_MSH=y
CONFIG_FINSH_USING_MSH_DEFAULT=y
CONFIG_FINSH_USING_MSH_ONLY=y
CONFIG_FINSH_ARG_MAX=10
#
# Device virtual file system
#
CONFIG_RT_USING_DFS=y
CONFIG_DFS_USING_WORKDIR=y
CONFIG_DFS_FILESYSTEMS_MAX=4
CONFIG_DFS_FILESYSTEM_TYPES_MAX=4
CONFIG_DFS_FD_MAX=16
# CONFIG_RT_USING_DFS_MNTTABLE is not set
# CONFIG_RT_USING_DFS_ELMFAT is not set
CONFIG_RT_USING_DFS_DEVFS=y
# CONFIG_RT_USING_DFS_ROMFS is not set
# CONFIG_RT_USING_DFS_RAMFS is not set
# CONFIG_RT_USING_DFS_UFFS is not set
# CONFIG_RT_USING_DFS_JFFS2 is not set
# CONFIG_RT_USING_DFS_NFS is not set
#
# Device Drivers
#
CONFIG_RT_USING_DEVICE_IPC=y
CONFIG_RT_PIPE_BUFSZ=512
CONFIG_RT_USING_SERIAL=y
CONFIG_RT_SERIAL_USING_DMA=y
CONFIG_RT_SERIAL_RB_BUFSZ=64
# CONFIG_RT_USING_CAN is not set
# CONFIG_RT_USING_HWTIMER is not set
# CONFIG_RT_USING_CPUTIME is not set
# CONFIG_RT_USING_I2C is not set
CONFIG_RT_USING_PIN=y
# CONFIG_RT_USING_ADC is not set
# CONFIG_RT_USING_PWM is not set
# CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NAND is not set
# CONFIG_RT_USING_MTD is not set
# CONFIG_RT_USING_PM is not set
# CONFIG_RT_USING_RTC is not set
# CONFIG_RT_USING_SDIO is not set
# CONFIG_RT_USING_SPI is not set
# CONFIG_RT_USING_WDT is not set
# CONFIG_RT_USING_AUDIO is not set
# CONFIG_RT_USING_SENSOR is not set
#
# Using WiFi
#
CONFIG_RT_USING_WIFI=y
CONFIG_RT_WLAN_DEVICE_STA_NAME="wlan0"
CONFIG_RT_WLAN_DEVICE_AP_NAME="wlan1"
CONFIG_RT_WLAN_DEFAULT_PROT="lwip"
CONFIG_RT_WLAN_SCAN_WAIT_MS=10000
CONFIG_RT_WLAN_CONNECT_WAIT_MS=10000
CONFIG_RT_WLAN_SSID_MAX_LENGTH=32
CONFIG_RT_WLAN_PASSWORD_MAX_LENGTH=32
CONFIG_RT_WLAN_SCAN_SORT=y
CONFIG_RT_WLAN_CFG_INFO_MAX=3
CONFIG_RT_WLAN_WORKQUEUE_THREAD_NAME="wlan_job"
CONFIG_RT_WLAN_WORKQUEUE_THREAD_SIZE=2048
CONFIG_RT_WLAN_WORKQUEUE_THREAD_PRIO=22
CONFIG_RT_WLAN_DEV_EVENT_NUM=2
# CONFIG_RT_WLAN_PROT_LWIP_PBUF_FORCE is not set
# CONFIG_RT_WLAN_DEBUG is not set
#
# Using USB
#
# CONFIG_RT_USING_USB_HOST is not set
# CONFIG_RT_USING_USB_DEVICE is not set
#
# POSIX layer and C standard library
#
CONFIG_RT_USING_LIBC=y
# CONFIG_RT_USING_PTHREADS is not set
CONFIG_RT_USING_POSIX=y
# CONFIG_RT_USING_POSIX_MMAP is not set
# CONFIG_RT_USING_POSIX_TERMIOS is not set
# CONFIG_RT_USING_POSIX_AIO is not set
# CONFIG_RT_USING_MODULE is not set
#
# Network
#
#
# Socket abstraction layer
#
CONFIG_RT_USING_SAL=y
#
# protocol stack implement
#
CONFIG_SAL_USING_LWIP=y
CONFIG_SAL_USING_POSIX=y
CONFIG_SAL_PROTO_FAMILIES_NUM=4
#
# light weight TCP/IP stack
#
CONFIG_RT_USING_LWIP=y
# CONFIG_RT_USING_LWIP141 is not set
CONFIG_RT_USING_LWIP202=y
# CONFIG_RT_USING_LWIP210 is not set
# CONFIG_RT_USING_LWIP_IPV6 is not set
CONFIG_RT_LWIP_IGMP=y
CONFIG_RT_LWIP_ICMP=y
# CONFIG_RT_LWIP_SNMP is not set
CONFIG_RT_LWIP_DNS=y
CONFIG_RT_LWIP_DHCP=y
CONFIG_IP_SOF_BROADCAST=1
CONFIG_IP_SOF_BROADCAST_RECV=1
#
# Static IPv4 Address
#
CONFIG_RT_LWIP_IPADDR="192.168.1.30"
CONFIG_RT_LWIP_GWADDR="192.168.1.1"
CONFIG_RT_LWIP_MSKADDR="255.255.255.0"
CONFIG_RT_LWIP_UDP=y
CONFIG_RT_LWIP_TCP=y
CONFIG_RT_LWIP_RAW=y
# CONFIG_RT_LWIP_PPP is not set
CONFIG_RT_MEMP_NUM_NETCONN=8
CONFIG_RT_LWIP_PBUF_NUM=16
CONFIG_RT_LWIP_RAW_PCB_NUM=4
CONFIG_RT_LWIP_UDP_PCB_NUM=4
CONFIG_RT_LWIP_TCP_PCB_NUM=4
CONFIG_RT_LWIP_TCP_SEG_NUM=40
CONFIG_RT_LWIP_TCP_SND_BUF=10240
CONFIG_RT_LWIP_TCP_WND=10240
CONFIG_RT_LWIP_TCPTHREAD_PRIORITY=10
CONFIG_RT_LWIP_TCPTHREAD_MBOX_SIZE=8
CONFIG_RT_LWIP_TCPTHREAD_STACKSIZE=1024
CONFIG_LWIP_NO_RX_THREAD=y
CONFIG_LWIP_NO_TX_THREAD=y
CONFIG_RT_LWIP_ETHTHREAD_PRIORITY=12
CONFIG_RT_LWIP_ETHTHREAD_STACKSIZE=1024
CONFIG_RT_LWIP_ETHTHREAD_MBOX_SIZE=8
# CONFIG_RT_LWIP_REASSEMBLY_FRAG is not set
CONFIG_LWIP_NETIF_STATUS_CALLBACK=1
CONFIG_SO_REUSE=1
CONFIG_LWIP_SO_RCVTIMEO=1
CONFIG_LWIP_SO_SNDTIMEO=1
CONFIG_LWIP_SO_RCVBUF=1
# CONFIG_RT_LWIP_NETIF_LOOPBACK is not set
CONFIG_LWIP_NETIF_LOOPBACK=0
# CONFIG_RT_LWIP_STATS is not set
# CONFIG_RT_LWIP_USING_HW_CHECKSUM is not set
# CONFIG_RT_LWIP_DEBUG is not set
#
# Modbus master and slave stack
#
# CONFIG_RT_USING_MODBUS is not set
#
# AT commands
#
# CONFIG_RT_USING_AT is not set
CONFIG_LWIP_USING_DHCPD=y
CONFIG_DHCPD_SERVER_IP="192.168.169.1"
# CONFIG_DHCPD_USING_ROUTER is not set
# CONFIG_LWIP_USING_CUSTOMER_DNS_SERVER is not set
#
# VBUS(Virtual Software BUS)
#
# CONFIG_RT_USING_VBUS is not set
#
# Utilities
#
# CONFIG_RT_USING_LOGTRACE is not set
# CONFIG_RT_USING_RYM is not set
CONFIG_RT_USING_ULOG=y
# CONFIG_ULOG_OUTPUT_LVL_A is not set
# CONFIG_ULOG_OUTPUT_LVL_E is not set
# CONFIG_ULOG_OUTPUT_LVL_W is not set
CONFIG_ULOG_OUTPUT_LVL_I=y
# CONFIG_ULOG_OUTPUT_LVL_D is not set
CONFIG_ULOG_OUTPUT_LVL=6
CONFIG_ULOG_USING_ISR_LOG=y
CONFIG_ULOG_ASSERT_ENABLE=y
CONFIG_ULOG_LINE_BUF_SIZE=128
# CONFIG_ULOG_USING_ASYNC_OUTPUT is not set
#
# log format
#
# CONFIG_ULOG_OUTPUT_FLOAT is not set
CONFIG_ULOG_USING_COLOR=y
CONFIG_ULOG_OUTPUT_TIME=y
# CONFIG_ULOG_TIME_USING_TIMESTAMP is not set
CONFIG_ULOG_OUTPUT_LEVEL=y
CONFIG_ULOG_OUTPUT_TAG=y
# CONFIG_ULOG_OUTPUT_THREAD_NAME is not set
CONFIG_ULOG_BACKEND_USING_CONSOLE=y
# CONFIG_ULOG_USING_FILTER is not set
# CONFIG_ULOG_USING_SYSLOG is not set
# CONFIG_RT_USING_UTEST is not set
#
# RT-Thread online packages
#
#
# IoT - internet of things
#
# CONFIG_PKG_USING_PAHOMQTT 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_WEBTERMINAL 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_EZXML is not set
# CONFIG_PKG_USING_NANOPB is not set
#
# Wi-Fi
#
#
# Marvell WiFi
#
# CONFIG_PKG_USING_WLANMARVELL is not set
#
# Wiced WiFi
#
# 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_NOPOLL 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
#
# CONFIG_PKG_USING_MBEDTLS is not set
# CONFIG_PKG_USING_libsodium is not set
# CONFIG_PKG_USING_TINYCRYPT is not set
#
# language packages
#
# CONFIG_PKG_USING_LUA is not set
# CONFIG_PKG_USING_JERRYSCRIPT is not set
# CONFIG_PKG_USING_MICROPYTHON is not set
#
# multimedia packages
#
# CONFIG_PKG_USING_OPENMV is not set
# CONFIG_PKG_USING_MUPDF is not set
# CONFIG_PKG_USING_STEMWIN is not set
#
# tools packages
#
# CONFIG_PKG_USING_CMBACKTRACE is not set
# CONFIG_PKG_USING_EASYFLASH is not set
# CONFIG_PKG_USING_EASYLOGGER is not set
# CONFIG_PKG_USING_SYSTEMVIEW 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
#
# CONFIG_PKG_USING_SENSORS_DRIVERS 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_WM_LIBRARIES=y
CONFIG_PKG_WM_LIBRARIES_PATH="/packages/peripherals/wm_libraries"
# CONFIG_PKG_USING_WM_LIBRARIES_V100 is not set
CONFIG_PKG_USING_WM_LIBRARIES_LATEST_VERSION=y
CONFIG_PKG_WM_LIBRARIES_VER="latest"
# CONFIG_PKG_USING_KENDRYTE_SDK is not set
#
# 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_MINILZO is not set
# CONFIG_PKG_USING_QUICKLZ 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
#
# 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_VI is not set
# CONFIG_PKG_USING_NNOM is not set
#
# Env config
#
# CONFIG_SYS_AUTO_UPDATE_PKGS is not set
# CONFIG_SYS_CREATE_MDK_IAR_PROJECT is not set
CONFIG_SYS_PKGS_DOWNLOAD_ACCELERATE=y
CONFIG_BSP_USING_WM_LIBRARIES=y
#
# W60x Device config
#
CONFIG_SOC_W600_A8xx=y
# CONFIG_SOC_W601_A8xx is not set
#
# Hardware Drivers Config
#
#
# On-chip Peripheral Drivers
#
CONFIG_BSP_USING_UART=y
CONFIG_BSP_USING_UART0=y
# CONFIG_BSP_USING_UART1 is not set
# CONFIG_BSP_USING_UART2 is not set
CONFIG_BSP_USING_PIN=y
CONFIG_BSP_USING_WIFI=y
# CONFIG_BSP_USING_HWTIMER is not set
# CONFIG_BSP_USING_PWM is not set
# CONFIG_BSP_USING_I2C is not set
# CONFIG_BSP_USING_SPI is not set
# CONFIG_BSP_USING_WDT is not set
# CONFIG_BSP_USING_RTC is not set
# CONFIG_BSP_USING_STANDBY is not set
#
# Offboard Peripheral Drivers
#
# CONFIG_BSP_USING_FLASH is not set

41
bsp/w60x/.gitignore vendored Normal file
View File

@@ -0,0 +1,41 @@
*.pyc
*.map
*.dblite
*.elf
*.bin
*.hex
*.axf
*.pdb
*.idb
*.ilk
*.old
build
Debug
documentation/html
packages/
*~
*.o
*.obj
*.out
*.bak
*.dep
*.lib
*.i
*.d
.DS_Stor*
.config 3
.config 4
.config 5
Midea-X1
*.uimg
GPATH
GRTAGS
GTAGS
.vscode
JLinkLog.txt
JLinkSettings.ini
DebugConfig/
RTE/
settings/
*.uvguix*
cconfig.h

29
bsp/w60x/Kconfig Normal file
View File

@@ -0,0 +1,29 @@
mainmenu "RT-Thread Configuration"
config BSP_DIR
string
option env="BSP_ROOT"
default "."
config RTT_DIR
string
option env="RTT_ROOT"
default "../.."
# you can change the RTT_ROOT default "../.." to your rtthread_root,
# example : default "F:/git_repositories/rt-thread"
config PKGS_DIR
string
option env="PKGS_ROOT"
default "packages"
config ENV_DIR
string
option env="ENV_ROOT"
default "/"
source "$RTT_DIR/Kconfig"
source "$PKGS_DIR/Kconfig"
source "$ENV_DIR/tools/scripts/cmds/Kconfig"
source "$BSP_DIR/drivers/Kconfig"

103
bsp/w60x/README.md Normal file
View File

@@ -0,0 +1,103 @@
# Winner Micro W60X 板级支持包
## 简介
W60X 芯片是[联盛德微电子](http://www.winnermicro.com)推出的一款嵌入式 Wi-Fi SoC 芯片。该芯片集成度高,所需外围器件少,性价比高。适用于 IoT智能家庭领域各种智能产品。高度集成的 Wi-Fi 功能是其主要功能;另外,该芯片集成 Cortex-M3 内核,内置 QFlashSDIO、SPI、UART、GPIO、I²C、PWM、I²S、7816 等接口, 支持多种硬件加解密算法。
更多信息请查看`packages/wm_libraries/DOC 中的寄存器手册`
## 外设支持
| 驱动 | 支持情况 | 备注 |
| ---------- | :------: | :---------------------------------------------: |
| UART | 支持 | UART0/UART1/UART2 |
| GPIO | 支持 | 自动根据芯片型号选择引脚布局 |
| SPI | 支持 | 低速 SPI支持 SPI BUS8/32bit 主机模式 |
| SPI Flash | 支持 | 支持 W25QXX、SFUD |
| WDT | 支持 | 支持 |
| I2C | 支持 | 硬件 I2C |
| RTC | 支持 | 支持 ntp 同步、支持 Alarm |
| ADC | 支持 | 8 channel ADC 采集 CPU 温度采集W601 支持) |
| PWM | 支持 | 5 channel PWM 输出 |
| Timer | 支持 | 5个Timers 独立工作 |
| WiFi | 支持 | 支持 IEEE802.11b/g/n支持 sta、ap、ap+sta 模式 |
| 低功耗 | 支持 | 支持 WiFi 协议节电,支持 standby 深度节电 |
## 使用说明
使用说明分为如下两个章节:
- 快速上手
本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。
- 进阶使用
本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多板载资源,实现更多高级功能。
### 快速上手
本 BSP 为开发者提供 MDK5 和 IAR 工程,并且支持 GCC 开发环境。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。
#### 编译
1. env 工具中使用 `pkgs --update` 命令下载必要的软件包。
2. env 工具中使用 `scons --target=mdk5` 命令生成工程
2. 双击 project.uvprojx 文件,打开 MDK5 工程,完成程序的编译工作。
#### 下载
目前支持两种下载方式,下面将分别说明:
- JLink下载
将 JLink 连接到开发板,然后点击 MDK5 中的下载按钮即可下载程序到开发板。JLink 下载之前 **务必参考** `packages/wm_libraries/DOC` 目录下的 `《WM_W60X_SWD调试配置指南》`
- 串口下载
程序编译正确无误后,会在 `Bin` 文件夹中生成 `.img` 固件,使用带有 Xmodem 协议的串口工具对固件进行下载(默认 UART0-115200。串口下载参考 `packages/wm_libraries/DOC` 目录下的 `《WM_W60X_固件升级指导》`
#### 运行结果
下载程序成功之后,系统会自动运行,会在`UART0`上看到 RT-Thread 的启动 logo 信息:
```bash
\ | /
- RT - Thread Operating System
/ | \ 4.0.1 build Mar 21 2019
2006 - 2019 Copyright by rt-thread team
```
- 默认串口`UART0` 波特率`115200`
### 进阶使用
此 BSP 默认只开启了 GPIO 和 UART0 的功能,如果需使用其他外设,需要利用 ENV 工具对 BSP 进行配置,步骤如下:
1. 在 bsp 下打开 env 工具。
2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
3. 输入`pkgs --update`命令更新软件包。
4. 输入`scons --target=mdk5``scons --target=iar` 命令重新生成工程。
## 注意事项
> 使用 W600 芯片时,请注意芯片 Flash 的大小,区分 2M Flash 和 1M Flash。更多信息请查看 `packages/wm_libraries/DOC` 的文档:
- 《WM_W60X_2M_Flash布局说明》
- 《WM_W60X_2M_Flash参数区使用说明》
- 《WM_W60X_2M_Flash固件生成说明》
## 联系人信息
[RT_Thread](https://github.com/RT-Thread/rt-thread)
[WinnerMicro](https://github.com/WinnerMicro)
## 感谢
[flyingcys](https://github.com/flyingcys) < [294102238@qq.com](mailto:294102238@qq.com) >

8
bsp/w60x/ROM.ini Normal file
View File

@@ -0,0 +1,8 @@
FUNC void Setup (void) {
SP = _RDWORD(0x8010100); // Setup Stack Pointer
PC = _RDWORD(0x8010104); // Setup Program Counter
_WDWORD(0xE000ED08, 0x8010100); // Setup VTOR
}
LOAD %L INCREMENTAL // load the application
Setup(); // Setup for Running
g, _main

14
bsp/w60x/SConscript Normal file
View File

@@ -0,0 +1,14 @@
# for module compiling
import os
Import('RTT_ROOT')
cwd = str(Dir('#'))
objs = []
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
Return('objs')

39
bsp/w60x/SConstruct Normal file
View File

@@ -0,0 +1,39 @@
import os
import sys
import rtconfig
if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
try:
from building import *
except:
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
print(RTT_ROOT)
exit(-1)
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
env = Environment(tools = ['mingw'],
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
if rtconfig.PLATFORM == 'iar':
env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
env.Replace(ARFLAGS = [''])
env.Replace(LINKCOM = env["LINKCOM"] + ' --map project.map')
Export('RTT_ROOT')
Export('rtconfig')
# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
# make a building
DoBuilding(TARGET, objs)

View File

@@ -0,0 +1,11 @@
Import('RTT_ROOT')
Import('rtconfig')
from building import *
cwd = os.path.join(str(Dir('#')), 'applications')
src = Glob('*.c')
CPPPATH = [cwd, str(Dir('#'))]
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
Return('group')

View File

@@ -0,0 +1,21 @@
/*
* Copyright (c) 2006-2019, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-02-13 tyx first implementation
*/
#include <rtthread.h>
#include <rtdevice.h>
int main(void)
{
/* set wifi work mode */
rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION);
rt_wlan_set_mode(RT_WLAN_DEVICE_AP_NAME, RT_WLAN_AP);
return 0;
}

243
bsp/w60x/drivers/Kconfig Normal file
View File

@@ -0,0 +1,243 @@
config BSP_USING_WM_LIBRARIES
bool
select PKG_USING_WM_LIBRARIES
default y
menu "W60x Device config"
choice
prompt "Device type"
default SOC_W600-A8xx
config SOC_W600_A8xx
bool "W600-A8xx"
config SOC_W601_A8xx
bool "W601-A8xx"
endchoice
endmenu
menu "Hardware Drivers Config"
menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_UART
bool "Using UART"
select RT_USING_SERIAL
default y
if BSP_USING_UART
config BSP_USING_UART0
bool "Enabel UART 0"
default y
config BSP_USING_UART1
bool "Enabel UART 1"
default n
if BSP_USING_UART1
config WM_UART1_BAUDRATE
int "UART1 baudrate"
default 115200
config WM_UART1_RX_PIN
int "UART1 RX pin number"
default 31
config WM_UART1_TX_PIN
int "UART1 TX pin number"
default 32
endif
config BSP_USING_UART2
bool "Enabel UART 2"
default n
if BSP_USING_UART2
config WM_UART2_BAUDRATE
int "UART2 baudrate"
default 115200
config WM_UART2_RX_PIN
int "UART2 RX pin number"
default 13
config WM_UART2_TX_PIN
int "UART2 TX pin number"
default 14
endif
endif
config BSP_USING_PIN
bool "Using PIN"
select RT_USING_PIN
default y
config BSP_USING_WIFI
bool "Using WIFI"
select RT_USING_WIFI
select RT_USING_LWIP
default y
if SOC_W601_A8xx
menuconfig BSP_USING_ADC
bool "Enable ADC"
select RT_USING_ADC
default n
if BSP_USING_ADC
config USING_CPU_TEMP
bool "Enable CPU Temperature"
config USING_ADC_CH1
bool "Enable ADC Channel 1"
config USING_ADC_CH2
bool "Enable ADC Channel 2"
config USING_ADC_CH3
bool "Enable ADC Channel 3"
config USING_ADC_CH4
bool "Enable ADC Channel 4"
config USING_ADC_CH5
bool "Enable ADC Channel 5"
config USING_ADC_CH6
bool "Enable ADC Channel 6"
config USING_ADC_CH7
bool "Enable ADC Channel 7"
config USING_ADC_CH8
bool "Enable ADC Channel 8"
endif
endif
menuconfig BSP_USING_HWTIMER
bool "Enable HWTIMER"
select RT_USING_HWTIMER
default n
if BSP_USING_HWTIMER
config USING_HW_TIMER1
bool "Enable hw timer1"
config USING_HW_TIMER2
bool "Enable hw timer2"
config USING_HW_TIMER3
bool "Enable hw timer3"
config USING_HW_TIMER4
bool "Enable hw timer4"
config USING_HW_TIMER5
bool "Enable hw timer5"
endif
menuconfig BSP_USING_PWM
bool "Enable PWM"
select RT_USING_PWM
default n
if BSP_USING_PWM
config USING_PWM_CH1
bool "Enable pwm channel 1"
default n
if USING_PWM_CH1
config WM_PWM_CH1_PIN
int "wm pwm channel 1 pin number"
default 23
endif
config USING_PWM_CH2
bool "Enable pwm channel 2"
default n
if USING_PWM_CH2
config WM_PWM_CH2_PIN
int "wm pwm channel 2 pin number"
default 22
endif
config USING_PWM_CH3
bool "Enable pwm channel 3"
default n
if USING_PWM_CH3
config WM_PWM_CH3_PIN
int "wm pwm channel 3 pin number"
default 21
endif
config USING_PWM_CH4
bool "Enable pwm channel 4"
default n
if USING_PWM_CH4
config WM_PWM_CH4_PIN
int "wm pwm channel 4 pin number"
default 20
endif
config USING_PWM_CH5
bool "Enable pwm channel 5"
default n
if USING_PWM_CH5
config WM_PWM_CH5_PIN
int "wm pwm channel 5 pin number"
default 19
endif
endif
menuconfig BSP_USING_I2C
bool "Enable I2C"
select RT_USING_I2C
default n
if BSP_USING_I2C
config WM_HW_I2C_FREQ
int "wm hardware I2C frequency(HZ)"
default 200000
config WM_I2C_DAT_PIN
int "wm I2C DAT pin number"
default 19
config WM_I2C_SCL_PIN
int "wm I2C SCL pin number"
default 18
endif
menuconfig BSP_USING_SPI
bool "Enable SPI"
select RT_USING_SPI
default n
if BSP_USING_SPI
config WM_SPI_CK_PIN
int "wm SPI CK pin number"
default 21
config WM_SPI_DO_PIN
int "wm SPI DO pin number"
default 23
config WM_SPI_DI_PIN
int "wm SPI DI pin number"
default 22
endif
config BSP_USING_WDT
bool "Enable WDT"
select RT_USING_WDT
default n
menuconfig BSP_USING_RTC
bool "Enable RTC"
select RT_USING_RTC
default n
if BSP_USING_RTC
config BSP_USING_ALARM
bool "Enable Alarm"
select RT_USING_ALARM
default n
endif
config BSP_USING_STANDBY
bool "Enable standby"
default n
endmenu
menu "Offboard Peripheral Drivers"
menuconfig BSP_USING_FLASH
bool "Enable Flash"
select RT_USING_SFUD
select BSP_USING_SPI
default n
if BSP_USING_FLASH
config SPI_Flash_BUS_NAME
string "SPI BUS Name"
default "spi0"
config SPI_Flash_CS_PIN
int "SPI Flash CS pin number"
default 20
endif
endmenu
endmenu

View File

@@ -0,0 +1,67 @@
from building import *
cwd = GetCurrentDir()
list = os.listdir(cwd)
objs = []
src = Split('''
board.c
drv_uart.c
pin_map.c
''')
if GetDepend(['BSP_USING_ADC']):
src += ['drv_adc.c']
if GetDepend(['BSP_USING_WIFI']):
src += ['drv_wifi.c']
if GetDepend('BSP_USING_PIN'):
src += ['drv_pin.c']
if GetDepend('BSP_USING_SDIO'):
src += ['drv_sdio.c']
if GetDepend('BSP_USING_CAN'):
src += ['drv_can.c']
if GetDepend('BSP_USING_HWTIMER'):
src += ['drv_hw_timer.c']
if GetDepend('BSP_USING_CPUTIME'):
src += ['drv_cputime.c']
if GetDepend('BSP_USING_I2C'):
src += ['drv_i2c.c']
if GetDepend('BSP_USING_SPI'):
src += ['drv_spi.c']
if GetDepend(['BSP_USING_FLASH']):
src += ['drv_spiflash.c']
if GetDepend('BSP_USING_LCD'):
src += ['drv_lcd.c']
if GetDepend('BSP_USING_PWM'):
src += ['drv_pwm.c']
if GetDepend('BSP_USING_RTC'):
src += ['drv_rtc.c']
if GetDepend('BSP_USING_WDT'):
src += ['drv_wdt.c']
if GetDepend('BSP_USING_STANDBY'):
src += ['drv_standby.c']
CPPPATH = [cwd]
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
objs = objs + group
Return('objs')

206
bsp/w60x/drivers/board.c Normal file
View File

@@ -0,0 +1,206 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-09-15 flyingcys add w600
*/
#include <rthw.h>
#include <rtthread.h>
#include "wm_type_def.h"
#include "misc.h"
#include "wm_cpu.h"
#include "wm_debug.h"
#include "wm_io.h"
#include "wm_gpio_afsel.h"
#include "wm_crypto_hard.h"
#include "wm_hostspi.h"
#include "wm_flash.h"
#include "wm_internal_flash.h"
#include "wm_fwup.h"
#include "wm_pmu.h"
#include "drv_uart.h"
#include "board.h"
#define FW_MAJOR_VER 0x03
#define FW_MINOR_VER 0x00
#define FW_PATCH_VER 0x00
const char FirmWareVer[4] =
{
'G',
FW_MAJOR_VER, /* Main version */
FW_MINOR_VER, /* Subversion */
FW_PATCH_VER /* Internal version */
};
const char HwVer[6] =
{
'H',
0x1,
0x0,
0x0,
0x0,
0x0
};
const unsigned int HZ = RT_TICK_PER_SECOND;
struct tls_ethif *tls_netif_get_ethif(void)
{
rt_kprintf("===============%s %d\r\n", __FUNCTION__, __LINE__);
return RT_NULL;
}
int tls_os_get_type(void)
{
rt_kprintf("===============%s %d\r\n", __FUNCTION__, __LINE__);
return 0;
}
err_t tls_dhcp_stop(void)
{
rt_kprintf("===============%s %d\r\n", __FUNCTION__, __LINE__);
return 0;
}
u8 tls_get_isr_count(void)
{
rt_kprintf("===============%s %d\r\n", __FUNCTION__, __LINE__);
return 0;
}
void *mem_alloc_debug(u32 size)
{
return rt_malloc(size);
}
void mem_free_debug(void *p)
{
rt_free(p);
}
void disp_version_info(void)
{
extern const char WiFiVer[];
TLS_DBGPRT_INFO("\n\n");
TLS_DBGPRT_INFO("****************************************************************\n");
TLS_DBGPRT_INFO("* *\n");
TLS_DBGPRT_INFO("* Copyright (C) 2014 WinnerMicro Co. Ltd. *\n");
TLS_DBGPRT_INFO("* All rights reserved. *\n");
TLS_DBGPRT_INFO("* WinnerMicro Firmware Version: %x.%x.%X *\n",
FirmWareVer[1], FirmWareVer[2], FirmWareVer[3]);
TLS_DBGPRT_INFO("* WinnerMicro Hardware Version: %x.%x.%x.%x.%x *\n",
HwVer[1], HwVer[2], HwVer[3], HwVer[4], HwVer[5]);
TLS_DBGPRT_INFO("* *\n");
TLS_DBGPRT_INFO("* WinnerMicro Wi-Fi Lib Version: %x.%x.%x *\n",
WiFiVer[0], WiFiVer[1], WiFiVer[2]);
TLS_DBGPRT_INFO("****************************************************************\n");
}
void wm_gpio_config(void)
{
/* must call first */
wm_gpio_af_disable();
/*MASTER SPI configuratioin*/
wm_spi_cs_config(WM_IO_PA_02);
wm_spi_ck_config(WM_IO_PA_11);
wm_spi_di_config(WM_IO_PA_03);
wm_spi_do_config(WM_IO_PA_09);
}
static int wm_infsl_init(void)
{
tls_spi_init();
tls_spifls_init();
tls_fls_init();
/*initialize flash layout parameter according to image type*/
tls_fls_layout_init();
return 0;
}
INIT_DEVICE_EXPORT(wm_infsl_init);
static void _idle_hook_callback(void)
{
#if !defined(__CC_ARM)
__asm volatile ("wfi");
#else
__asm
{
WFI;
}
#endif
}
void wm_sys_clk_config(void)
{
tls_sys_clk sysclk;
tls_sys_clk_set(CPU_CLK_80M);
tls_sys_clk_get(&sysclk);
SysTick_Config(sysclk.cpuclk * UNIT_MHZ / RT_TICK_PER_SECOND);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
tls_pmu_clk_select(0);
}
/**
* This is the timer interrupt service routine.
*
*/
void OS_CPU_SysTickHandler(void)
{
/* enter interrupt */
rt_interrupt_enter();
rt_tick_increase();
/* leave interrupt */
rt_interrupt_leave();
}
/**
* This function will initial board.
*/
void rt_hw_board_init(void)
{
/* must call first to configure gpio Alternate functions according the hardware design */
wm_gpio_config();
wm_sys_clk_config();
#ifdef RT_USING_HEAP
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
#endif
#ifdef RT_USING_COMPONENTS_INIT
rt_components_board_init();
#endif
#ifdef RT_USING_CONSOLE
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
#if TLS_CONFIG_HARD_CRYPTO
tls_crypto_init();
#endif
NVIC_SystemLPConfig(NVIC_LP_SLEEPDEEP, ENABLE);
rt_thread_idle_sethook(_idle_hook_callback);
}
#ifdef RT_USING_FINSH
#include <finsh.h>
static void reboot(uint8_t argc, char **argv)
{
rt_hw_cpu_reset();
}
FINSH_FUNCTION_EXPORT_ALIAS(reboot, __cmd_reboot, Reboot System);
#endif /* RT_USING_FINSH */
/*@}*/

29
bsp/w60x/drivers/board.h Normal file
View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-09-15 flyingcys add w600
*/
#ifndef __BOARD_H__
#define __BOARD_H__
#ifdef __CC_ARM
extern int Image$$RW_IRAM1$$ZI$$Limit;
#define HEAP_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit)
#elif __ICCARM__
#pragma section="CSTACK"
#define HEAP_BEGIN (__segment_end("CSTACK"))
#else
extern int __bss_end__;
#define HEAP_BEGIN (&__bss_end__)
#endif
#define HEAP_END (0x20038000UL)
void rt_hw_board_init(void);
#endif

129
bsp/w60x/drivers/drv_adc.c Normal file
View File

@@ -0,0 +1,129 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-23 fanwenl 1st version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include "wm_io.h"
#include "wm_adc.h"
#include "wm_gpio_afsel.h"
#include "drv_adc.h"
#ifdef BSP_USING_ADC
#if defined(USING_ADC_CH1) || defined(USING_ADC_CH2) || defined(USING_ADC_CH3) || defined(USING_ADC_CH4) || \
defined(USING_ADC_CH5) || defined(USING_ADC_CH6) || defined(USING_ADC_CH7) || defined(USING_ADC_CH8)
static rt_err_t wm_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled)
{
if (channel < 1 || channel > 8)
return RT_ERROR;
if (enabled == RT_TRUE)
{
tls_adc_start_with_cpu(channel - 1);
}
else
{
tls_adc_stop(0);
}
return RT_EOK;
}
static rt_err_t wm_adc_convert(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value)
{
if (channel < 1 || channel > 8)
return RT_ERROR;
*value = adc_get_inputVolt(channel - 1) ;
return RT_EOK;
}
static struct rt_adc_ops wm_adc_ops =
{
wm_adc_enabled,
wm_adc_convert,
};
static struct rt_adc_device wm_adc;
#endif
#ifdef USING_CPU_TEMP
static rt_err_t wm_cpu_temp_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled)
{
if (enabled == RT_FALSE)
{
tls_adc_stop(0);
}
return RT_EOK;
}
static rt_err_t wm_cpu_temp_convert(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value)
{
*value = (rt_uint32_t)adc_temp();
/**
sprintf(temperature, "%d.%d", *value/1000, (*value%1000)/100);
printf("tem: %s", temperature);
*/
return RT_EOK;
}
static struct rt_adc_ops wm_cpu_temp_ops =
{
wm_cpu_temp_enabled,
wm_cpu_temp_convert,
};
static struct rt_adc_device wm_cpu_temp;
#endif
int wm_hw_adc_init(void)
{
/*adc io config*/
#ifdef USING_ADC_CH1
wm_adc_config(0);
#endif
#ifdef USING_ADC_CH2
wm_adc_config(1);
#endif
#ifdef USING_ADC_CH3
wm_adc_config(2);
#endif
#ifdef USING_ADC_CH4
wm_adc_config(3);
#endif
#ifdef USING_ADC_CH5
wm_adc_config(4);
#endif
#ifdef USING_ADC_CH6
wm_adc_config(5);
#endif
#ifdef USING_ADC_CH7
wm_adc_config(6);
#endif
#ifdef USING_ADC_CH8
wm_adc_config(7);
#endif
#if defined(USING_ADC_CH1) || defined(USING_ADC_CH2) || defined(USING_ADC_CH3) || defined(USING_ADC_CH4) || \
defined(USING_ADC_CH5) || defined(USING_ADC_CH6) || defined(USING_ADC_CH7) || defined(USING_ADC_CH8)
rt_hw_adc_register(&wm_adc, "adc", &wm_adc_ops, 0);
#endif
#ifdef USING_CPU_TEMP
rt_hw_adc_register(&wm_cpu_temp, "cputemp", &wm_cpu_temp_ops, 0);
#endif
return RT_EOK;
}
INIT_DEVICE_EXPORT(wm_hw_adc_init);
#endif /* BSP_USING_ADC */

View File

@@ -0,0 +1,16 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-22 fanwenl 1st version
*/
#ifndef __DRV_ADC_H__
#define __DRV_ADC_H__
int wm_hw_adc_init(void);
#endif /* __DRV_ADC_H__ */

View File

@@ -0,0 +1,207 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-19 fanwenl 1st version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include "wm_type_def.h"
#include "wm_timer.h"
#include "drv_hw_timer.h"
#ifdef BSP_USING_HWTIMER
struct wm_timer_Type
{
enum tls_timer_unit unit;
enum tls_timer_id id;
};
static void wm_timer_init(rt_hwtimer_t *timer, rt_uint32_t state)
{
struct tls_timer_cfg timer_cfg;
struct wm_timer_Type *wm_timer = (struct wm_timer_Type *)timer->parent.user_data;
timer_cfg.unit = wm_timer->unit;
timer_cfg.timeout = 0xFFFFFFFF;
timer_cfg.is_repeat = 0;
timer_cfg.callback = NULL;
timer_cfg.arg = NULL;
if (state == 1)
{
tls_timer_create(&timer_cfg, wm_timer->id);
}
else if (state == 0)
{
tls_timer_destroy(wm_timer->id);
}
}
static rt_err_t wm_timer_start(rt_hwtimer_t *timer, rt_uint32_t t, rt_hwtimer_mode_t opmode)
{
struct wm_timer_Type *wm_timer = (struct wm_timer_Type *)timer->parent.user_data;
uint8_t m;
tls_timer_change(wm_timer->id, t);
m = (opmode == HWTIMER_MODE_ONESHOT) ? 0 : 1;
tls_timer_set_mode(wm_timer->id, m);
tls_timer_start(wm_timer->id);
return RT_EOK;
}
static void wm_timer_stop(rt_hwtimer_t *timer)
{
struct wm_timer_Type *wm_timer = (struct wm_timer_Type *)timer->parent.user_data;
tls_timer_stop(wm_timer->id);
}
static rt_err_t wm_timer_ctrl(rt_hwtimer_t *timer, rt_uint32_t cmd, void *arg)
{
/* The frequency value is an immutable value. */
if (cmd != HWTIMER_CTRL_FREQ_SET)
{
return -RT_ENOSYS;
}
if ( *(rt_uint32_t*)arg == 1000000)
{
return RT_EOK;
}
else
{
return -RT_ENOSYS;
}
}
static const struct rt_hwtimer_info _info =
{
1000000, /* the maximum count frequency can be set */
1000000, /* the minimum count frequency can be set */
0xFFFFFFFF, /* the maximum counter value */
HWTIMER_CNTMODE_DW, /* Increment or Decreasing count mode */
};
static const struct rt_hwtimer_ops _ops =
{
wm_timer_init,
wm_timer_start,
wm_timer_stop,
RT_NULL,
wm_timer_ctrl,
};
#ifdef USING_HW_TIMER1
static rt_hwtimer_t _timer1;
static struct wm_timer_Type wm_timer1;
#endif
#ifdef USING_HW_TIMER2
static rt_hwtimer_t _timer2;
static struct wm_timer_Type wm_timer2;
#endif
#ifdef USING_HW_TIMER3
static rt_hwtimer_t _timer3;
static struct wm_timer_Type wm_timer3;
#endif
#ifdef USING_HW_TIMER4
static rt_hwtimer_t _timer4;
static struct wm_timer_Type wm_timer4;
#endif
#ifdef USING_HW_TIMER5
static rt_hwtimer_t _timer5;
static struct wm_timer_Type wm_timer5;
#endif
int wm_hw_timer_init(void)
{
#ifdef USING_HW_TIMER1
wm_timer1.id = TLS_TIMER_ID_1;
wm_timer1.unit = TLS_TIMER_UNIT_US;
_timer1.info = &_info;
_timer1.ops = &_ops;
rt_device_hwtimer_register(&_timer1, "timer1", &wm_timer1);
#endif
#ifdef USING_HW_TIMER2
wm_timer2.id = TLS_TIMER_ID_2;
wm_timer2.unit = TLS_TIMER_UNIT_US;
_timer2.info = &_info;
_timer2.ops = &_ops;
rt_device_hwtimer_register(&_timer2, "timer2", &wm_timer2);
#endif
#ifdef USING_HW_TIMER3
wm_timer3.id = TLS_TIMER_ID_3;
wm_timer3.unit = TLS_TIMER_UNIT_US;
_timer3.info = &_info;
_timer3.ops = &_ops;
rt_device_hwtimer_register(&_timer3, "timer3", &wm_timer3);
#endif
#ifdef USING_HW_TIMER4
wm_timer4.id = TLS_TIMER_ID_4;
wm_timer4.unit = TLS_TIMER_UNIT_US;
_timer4.info = &_info;
_timer4.ops = &_ops;
rt_device_hwtimer_register(&_timer4, "timer4", &wm_timer4);
#endif
#ifdef USING_HW_TIMER5
wm_timer5.id = TLS_TIMER_ID_5;
wm_timer5.unit = TLS_TIMER_UNIT_US;
_timer5.info = &_info;
_timer5.ops = &_ops;
rt_device_hwtimer_register(&_timer5, "timer5", &wm_timer5);
#endif
return 0;
}
INIT_BOARD_EXPORT(wm_hw_timer_init);
void TIM1_IRQHandler(void)
{
timer_clear_irq(1);
#ifdef USING_HW_TIMER1
rt_device_hwtimer_isr(&_timer1);
#endif
}
void TIM2_IRQHandler(void)
{
timer_clear_irq(2);
#ifdef USING_HW_TIMER2
rt_device_hwtimer_isr(&_timer2);
#endif
}
void TIM3_IRQHandler(void)
{
timer_clear_irq(3);
#ifdef USING_HW_TIMER3
rt_device_hwtimer_isr(&_timer3);
#endif
}
void TIM4_IRQHandler(void)
{
timer_clear_irq(4);
#ifdef USING_HW_TIMER4
rt_device_hwtimer_isr(&_timer4);
#endif
}
void TIM5_IRQHandler(void)
{
timer_clear_irq(5);
#ifdef USING_HW_TIMER5
rt_device_hwtimer_isr(&_timer5);
#endif
}
#endif /* BSP_USING_HWTIMER */

View File

@@ -0,0 +1,16 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-19 fanwenl 1st version
*/
#ifndef __DRV_HWTIMER_H__
#define __DRV_HWTIMER_H__
int wm_hw_timer_init(void);
#endif

176
bsp/w60x/drivers/drv_i2c.c Normal file
View File

@@ -0,0 +1,176 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-9 fanwenl 1st version
*/
#include <rtdevice.h>
#include <rtthread.h>
#include "wm_i2c.h"
#include "wm_io.h"
#include "wm_gpio_afsel.h"
#include "pin_map.h"
#include "drv_i2c.h"
#ifdef BSP_USING_I2C
struct wm_i2c_bus
{
struct rt_i2c_bus_device parent;
struct rt_i2c_msg *msg;
rt_uint32_t msg_cnt;
volatile rt_uint32_t msg_ptr;
volatile rt_uint32_t dptr;
};
static struct wm_i2c_bus wm_i2c;
static rt_size_t wm_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
struct rt_i2c_msg msgs[],
rt_uint32_t num);
static rt_size_t wm_i2c_slv_xfer(struct rt_i2c_bus_device *bus,
struct rt_i2c_msg msgs[],
rt_uint32_t num);
static rt_err_t wm_i2c_bus_control(struct rt_i2c_bus_device *bus,
rt_uint32_t,
rt_uint32_t);
static const struct rt_i2c_bus_device_ops wm_i2c_ops =
{
wm_i2c_mst_xfer,
wm_i2c_slv_xfer,
wm_i2c_bus_control,
};
static rt_err_t wm_i2c_send_address(struct rt_i2c_bus_device *bus,
struct rt_i2c_msg *msg)
{
uint8_t addr_msb, addr_lsb;
if (msg->flags & RT_I2C_ADDR_10BIT)
{
addr_msb = 0xf0 | ((msg->addr >> 7) & 0x06);
addr_lsb = msg->addr & 0xff;
if (msg->flags & RT_I2C_RD)
{
addr_msb |= 0x01;
}
tls_i2c_write_byte(addr_msb, 1);
tls_i2c_wait_ack();
tls_i2c_write_byte(addr_lsb, 0);
tls_i2c_wait_ack();
}
else
{
tls_i2c_write_byte((msg->addr << 1) | msg->flags, 1);
tls_i2c_wait_ack();
}
return RT_EOK;
}
static rt_size_t wm_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
struct rt_i2c_msg msgs[],
rt_uint32_t num)
{
struct wm_i2c_bus *wm_i2c;
rt_size_t i;
RT_ASSERT(bus != RT_NULL);
wm_i2c = (struct wm_i2c_bus *)bus;
wm_i2c->msg = msgs;
wm_i2c->msg_ptr = 0;
wm_i2c->msg_cnt = num;
wm_i2c->dptr = 0;
for (i = 0; i < wm_i2c->msg_cnt; i++)
{
if (!(wm_i2c->msg[i].flags & RT_I2C_NO_START))
{
wm_i2c_send_address(bus, &(wm_i2c->msg[i]));
}
if (wm_i2c->msg[i].flags & RT_I2C_RD)
{
while (wm_i2c->msg[i].len > 1)
{
*wm_i2c->msg[i].buf++ = tls_i2c_read_byte(1, 0);
wm_i2c->msg[i].len--;
}
*wm_i2c->msg[i].buf = tls_i2c_read_byte(0, 0);
}
else
{
while (wm_i2c->msg[i].len > 0)
{
tls_i2c_write_byte(*wm_i2c->msg[i].buf, 0);
tls_i2c_wait_ack();
wm_i2c->msg[i].len--;
wm_i2c->msg[i].buf++;
}
}
}
wm_i2c->msg = RT_NULL;
wm_i2c->msg_ptr = 0;
wm_i2c->msg_cnt = 0;
wm_i2c->dptr = 0;
tls_i2c_stop();
for (int j = 0; j < 3000; j++);
return i;
}
static rt_size_t wm_i2c_slv_xfer(struct rt_i2c_bus_device *bus,
struct rt_i2c_msg msgs[],
rt_uint32_t num)
{
return 0;
}
static rt_err_t wm_i2c_bus_control(struct rt_i2c_bus_device *bus,
rt_uint32_t cmd,
rt_uint32_t arg)
{
return RT_ERROR;
}
void WM_I2C_IRQHandler(void)
{
extern void I2C_IRQHandler(void);
/* enter interrupt */
rt_interrupt_enter();
I2C_IRQHandler();
/* leave interrupt */
rt_interrupt_leave();
}
int wm_hw_i2c_init(void)
{
rt_int16_t gpio_pin;
gpio_pin = wm_get_pin(WM_I2C_SCL_PIN);
if (gpio_pin >= 0)
{
wm_i2c_scl_config((enum tls_io_name)gpio_pin);
}
gpio_pin = wm_get_pin(WM_I2C_DAT_PIN);
if (gpio_pin >= 0)
{
wm_i2c_sda_config((enum tls_io_name)gpio_pin);
}
tls_i2c_init(WM_HW_I2C_FREQ);
wm_i2c.parent.ops = &wm_i2c_ops;
rt_i2c_bus_device_register(&wm_i2c.parent, "i2c");
return 0;
}
INIT_DEVICE_EXPORT(wm_hw_i2c_init);
#endif /* BSP_USING_I2C */

View File

@@ -0,0 +1,16 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-9 fanwenl 1st version
*/
#ifndef __DRV_I2C_H__
#define __DRV_I2C_H__
int wm_hw_i2c_init(void);
#endif

179
bsp/w60x/drivers/drv_pin.c Normal file
View File

@@ -0,0 +1,179 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-09-15 flyingcys 1st version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <rthw.h>
#include "wm_type_def.h"
#include "wm_io.h"
#include "wm_gpio.h"
#include "pin_map.h"
#include "drv_pin.h"
#ifdef BSP_USING_PIN
static void wm_pin_mode(struct rt_device *device, rt_base_t pin, rt_base_t mode)
{
rt_int16_t gpio_pin;
gpio_pin = wm_get_pin(pin);
if (gpio_pin < 0)
{
return;
}
if (mode == PIN_MODE_INPUT)
{
tls_gpio_cfg((enum tls_io_name)gpio_pin, WM_GPIO_DIR_INPUT, WM_GPIO_ATTR_FLOATING);
}
else if (mode == PIN_MODE_INPUT_PULLUP)
{
tls_gpio_cfg((enum tls_io_name)gpio_pin, WM_GPIO_DIR_INPUT, WM_GPIO_ATTR_PULLHIGH);
}
else if (mode == PIN_MODE_INPUT_PULLDOWN)
{
tls_gpio_cfg((enum tls_io_name)gpio_pin, WM_GPIO_DIR_INPUT, WM_GPIO_ATTR_PULLLOW);
}
else if (mode == PIN_MODE_OUTPUT)
{
tls_gpio_cfg((enum tls_io_name)gpio_pin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_PULLHIGH);
}
return;
}
static void wm_pin_write(struct rt_device *device, rt_base_t pin, rt_base_t value)
{
rt_int16_t gpio_pin;
gpio_pin = wm_get_pin(pin);
if (gpio_pin < 0)
{
return;
}
tls_gpio_write((enum tls_io_name)gpio_pin, value);
return;
}
static int wm_pin_read(struct rt_device *device, rt_base_t pin)
{
rt_int16_t gpio_pin;
gpio_pin = wm_get_pin(pin);
if (gpio_pin < 0)
{
return PIN_LOW;
}
return tls_gpio_read((enum tls_io_name)gpio_pin);
}
static rt_err_t wm_pin_attach_irq(struct rt_device *device, rt_int32_t pin,
rt_uint32_t mode, void (*hdr)(void *args), void *args)
{
rt_int16_t gpio_pin;
rt_base_t level;
gpio_pin = wm_get_pin(pin);
if (gpio_pin < 0)
{
return RT_ENOSYS;
}
level = rt_hw_interrupt_disable();
/*irq mode set*/
switch (mode)
{
case PIN_IRQ_MODE_RISING:
tls_gpio_irq_cfg((enum tls_io_name)gpio_pin, WM_GPIO_IRQ_TRIG_RISING_EDGE);
break;
case PIN_IRQ_MODE_FALLING:
tls_gpio_irq_cfg((enum tls_io_name)gpio_pin, WM_GPIO_IRQ_TRIG_FALLING_EDGE);
break;
case PIN_IRQ_MODE_RISING_FALLING:
tls_gpio_irq_cfg((enum tls_io_name)gpio_pin, WM_GPIO_IRQ_TRIG_DOUBLE_EDGE);
break;
case PIN_IRQ_MODE_HIGH_LEVEL:
tls_gpio_irq_cfg((enum tls_io_name)gpio_pin, WM_GPIO_IRQ_TRIG_HIGH_LEVEL);
break;
case PIN_IRQ_MODE_LOW_LEVEL:
tls_gpio_irq_cfg((enum tls_io_name)gpio_pin, WM_GPIO_IRQ_TRIG_LOW_LEVEL);
break;
default:
rt_hw_interrupt_enable(level);
return RT_ENOSYS;
}
tls_gpio_isr_register((enum tls_io_name)gpio_pin, hdr, args);
rt_hw_interrupt_enable(level);
return RT_EOK;
}
static rt_err_t wm_pin_detach_irq(struct rt_device *device, rt_int32_t pin)
{
return RT_EOK;
}
static rt_err_t wm_pin_irq_enable(struct rt_device *device, rt_base_t pin, rt_uint32_t enabled)
{
rt_int16_t gpio_pin;
rt_base_t level;
gpio_pin = wm_get_pin(pin);
if (gpio_pin < 0)
{
return RT_ENOSYS;
}
level = rt_hw_interrupt_disable();
if (enabled == PIN_IRQ_ENABLE)
{
tls_clr_gpio_irq_status((enum tls_io_name)gpio_pin);
tls_gpio_irq_enable((enum tls_io_name)gpio_pin);
rt_hw_interrupt_enable(level);
return RT_EOK;
}
else if (enabled == PIN_IRQ_DISABLE)
{
tls_gpio_irq_disable((enum tls_io_name)gpio_pin);
rt_hw_interrupt_enable(level);
return RT_EOK;
}
else
{
rt_hw_interrupt_enable(level);
return RT_ENOSYS;
}
}
struct rt_pin_ops _wm_pin_ops =
{
wm_pin_mode,
wm_pin_write,
wm_pin_read,
wm_pin_attach_irq,
wm_pin_detach_irq,
wm_pin_irq_enable
};
int wm_hw_pin_init(void)
{
int ret = rt_device_pin_register("pin", &_wm_pin_ops, RT_NULL);
return ret;
}
INIT_BOARD_EXPORT(wm_hw_pin_init);
void WM_GPIOA_IRQHandler(void)
{
rt_interrupt_enter();
GPIOA_IRQHandler();
rt_interrupt_leave();
}
void WM_GPIOB_IRQHandler(void)
{
rt_interrupt_enter();
GPIOB_IRQHandler();
rt_interrupt_leave();
}
#endif /* BSP_USING_PIN */

View File

@@ -0,0 +1,17 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-09-15 flyingcys 1st version
*/
#ifndef DRV_GPIO_H__
#define DRV_GPIO_H__
int wm_hw_pin_init(void);
#endif

194
bsp/w60x/drivers/drv_pwm.c Normal file
View File

@@ -0,0 +1,194 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-22 fanwenl 1st version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include "wm_type_def.h"
#include "wm_cpu.h"
#include "wm_pwm.h"
#include "wm_gpio_afsel.h"
#include "drv_pwm.h"
#include "pin_map.h"
#ifdef BSP_USING_PWM
#define MAX_PERIOD 255
#define MIN_PERIOD 2
#define MIN_PULSE 1
#define MAX_CLKDIV 65535
static rt_err_t wm_pwm_set(rt_uint8_t channel, struct rt_pwm_configuration *configuration)
{
rt_uint32_t period, pulse;
rt_uint32_t psc;
pwm_init_param pwm_param;
int ret = WM_FAILED;
tls_sys_clk sysclk;
tls_sys_clk_get(&sysclk);
rt_memset(&pwm_param, 0, sizeof(pwm_init_param));
pwm_param.channel = channel;
pwm_param.cnt_type = WM_PWM_CNT_TYPE_EDGE_ALIGN_OUT;
pwm_param.loop_type = WM_PWM_LOOP_TYPE_LOOP;
pwm_param.mode = WM_PWM_OUT_MODE_INDPT;
pwm_param.inverse_en = DISABLE;
pwm_param.pnum = 0;
pwm_param.pnum_int = DISABLE;
period = (unsigned long long)configuration->period * sysclk.apbclk / 1000ULL;
psc = period / MAX_PERIOD + 1;
if (psc > MAX_CLKDIV)
{
psc = MAX_CLKDIV;
}
pwm_param.clkdiv = psc;
period = period / psc;
if (period < MIN_PERIOD)
{
period = MIN_PERIOD;
}
else if (period > MAX_PERIOD)
{
period = MAX_PERIOD;
}
pwm_param.period = period - 1;
pulse = (unsigned long long)configuration->pulse * sysclk.apbclk / psc / 1000ULL;
if (pulse < MIN_PULSE)
{
pulse = MIN_PULSE;
}
else if (pulse > period)
{
pulse = period;
}
pwm_param.duty = pulse - 1;
ret = tls_pwm_out_init(pwm_param);
if (ret == WM_SUCCESS)
{
return RT_EOK;
}
else
{
return RT_ERROR;
}
}
static rt_err_t wm_pwm_get(rt_uint8_t channel, struct rt_pwm_configuration *configuration)
{
tls_sys_clk sysclk;
uint32_t clkdiv;
uint8_t duty, period;
tls_sys_clk_get(&sysclk);
tls_pwm_get_info(channel, &clkdiv, &duty, &period);
configuration->period = (period + 1) * clkdiv * 1000UL / sysclk.apbclk;
configuration->pulse = (duty + 1) * clkdiv * 1000UL / sysclk.apbclk;
return RT_EOK;
}
static rt_err_t wm_pwm_control(struct rt_device_pwm *device, int cmd, void *arg)
{
struct rt_pwm_configuration *configuration = (struct rt_pwm_configuration *)arg;
int ret = WM_FAILED;
rt_uint32_t channel = 0;
channel = configuration->channel - 1;
if (channel > 4)
return RT_EINVAL;
switch (cmd)
{
case PWM_CMD_ENABLE:
ret = tls_pwm_start(channel);
if (ret == WM_SUCCESS)
return RT_EOK;
else
return RT_ERROR;
case PWM_CMD_DISABLE:
ret = tls_pwm_stop(channel);
if (ret == WM_SUCCESS)
return RT_EOK;
else
return RT_ERROR;
case PWM_CMD_SET:
return wm_pwm_set(channel, configuration);
case PWM_CMD_GET:
return wm_pwm_get(channel, configuration);
default:
return RT_EINVAL;
}
}
static struct rt_pwm_ops drv_ops =
{
wm_pwm_control
};
static struct rt_device_pwm wm_pwm;
int wm_hw_pwm_init(void)
{
rt_int16_t gpio_pin;
/*io config*/
#ifdef USING_PWM_CH1
gpio_pin = wm_get_pin(WM_PWM_CH1_PIN);
if (gpio_pin >= 0)
{
wm_pwm1_config((enum tls_io_name)gpio_pin);
}
#endif
#ifdef USING_PWM_CH2
gpio_pin = wm_get_pin(WM_PWM_CH2_PIN);
if (gpio_pin >= 0)
{
wm_pwm2_config((enum tls_io_name)gpio_pin);
}
#endif
#ifdef USING_PWM_CH3
gpio_pin = wm_get_pin(WM_PWM_CH3_PIN);
if (gpio_pin >= 0)
{
wm_pwm3_config((enum tls_io_name)gpio_pin);
}
#endif
#ifdef USING_PWM_CH4
gpio_pin = wm_get_pin(WM_PWM_CH4_PIN);
if (gpio_pin >= 0)
{
wm_pwm4_config((enum tls_io_name)gpio_pin);
}
#endif
#ifdef USING_PWM_CH5
gpio_pin = wm_get_pin(WM_PWM_CH5_PIN);
if (gpio_pin >= 0)
{
wm_pwm5_config((enum tls_io_name)gpio_pin);
}
#endif
#if defined(USING_PWM_CH1) || defined(USING_PWM_CH2) || defined(USING_PWM_CH3) || \
defined(USING_PWM_CH4) || defined(USING_PWM_CH5)
rt_device_pwm_register(&wm_pwm, "pwm", &drv_ops, 0);
#endif
return RT_EOK;
}
INIT_DEVICE_EXPORT(wm_hw_pwm_init);
#endif /* BSP_USING_PWM */

View File

@@ -0,0 +1,16 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-22 fanwenl 1st version
*/
#ifndef __DRV_PWM_H__
#define __DRV_PWM_H__
int wm_hw_pwm_init(void);
#endif

208
bsp/w60x/drivers/drv_rtc.c Normal file
View File

@@ -0,0 +1,208 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-09-15 flyingcys 1st version
* 2019-03-01 fanwenl add alarm
*/
#include <rtdevice.h>
#include <rtthread.h>
#include <time.h>
#include "wm_regs.h"
#include "wm_irq.h"
#include "tls_common.h"
#include "wm_rtc.h"
#include "drv_rtc.h"
#ifdef BSP_USING_RTC
static struct rt_rtc_device rtc_device;
static time_t wm_get_timestamp(void)
{
struct tm tm_new = {0};
int ctrl1 = 0;
int ctrl2 = 0;
ctrl1 = tls_reg_read32(HR_PMU_RTC_CTRL1);
ctrl2 = tls_reg_read32(HR_PMU_RTC_CTRL2);
tm_new.tm_year = ((int)((int)ctrl2 & 0x00007f00) >> 8);
tm_new.tm_mon = (ctrl2 & 0x0000000f);
tm_new.tm_mday = (ctrl1 & 0x1f000000) >> 24;
tm_new.tm_hour = (ctrl1 & 0x001f0000) >> 16;
tm_new.tm_min = (ctrl1 & 0x00003f00) >> 8;
tm_new.tm_sec = ctrl1 & 0x0000003f;
return mktime(&tm_new);
}
static int wm_set_timestamp(time_t timestamp)
{
int ctrl1 = 0;
int ctrl2 = 0;
struct tm *tblock;
tblock = localtime(&timestamp);
ctrl2 = tls_reg_read32(HR_PMU_RTC_CTRL2); /* disable */
ctrl2 &= ~(1 << 16);
tls_reg_write32(HR_PMU_RTC_CTRL2, ctrl2);
ctrl1 |= tblock->tm_sec;
ctrl1 |= tblock->tm_min << 8;
ctrl1 |= tblock->tm_hour << 16;
ctrl1 |= tblock->tm_mday << 24;
tls_reg_write32(HR_PMU_RTC_CTRL1, ctrl1);
ctrl2 = 0;
ctrl2 |= tblock->tm_mon;
ctrl2 |= tblock->tm_year << 8;
tls_reg_write32(HR_PMU_RTC_CTRL2, ctrl2);
ctrl2 = tls_reg_read32(HR_PMU_RTC_CTRL2);/* enable */
ctrl2 |= (1 << 16);
tls_reg_write32(HR_PMU_RTC_CTRL2, ctrl2);
return RT_EOK;
}
#ifdef BSP_USING_ALARM
static int wm_alarm_set_timestamp(struct rt_rtc_wkalarm *wkalarm)
{
int ctrl1 = 0;
int ctrl2 = 0;
struct tm *tblock;
time_t timestamp = 0;
timestamp = wm_get_timestamp();
tblock = localtime(&timestamp);
tls_irq_enable(PMU_RTC_INT);
ctrl1 |= wkalarm->tm_sec;
ctrl1 |= wkalarm->tm_min << 8;
ctrl1 |= wkalarm->tm_hour << 16;
ctrl1 |= tblock->tm_mday << 24;
ctrl2 |= tblock->tm_mon;
ctrl2 |= tblock->tm_year << 8;
tls_reg_write32(HR_PMU_RTC_CTRL2, ctrl2 | BIT(16));
tls_reg_write32(HR_PMU_RTC_CTRL1, ctrl1 | BIT(31));/* must set the enable */
return RT_EOK;
}
static void wm_rtc_alarm_callback(void *arg)
{
rt_alarm_update(0, 0);
}
#endif
static rt_err_t wm_rtc_init(rt_device_t dev)
{
wm_set_timestamp((time_t)0);
#ifdef BSP_USING_ALARM
tls_rtc_isr_register(wm_rtc_alarm_callback, (void *)0);
#endif
return RT_EOK;
}
static rt_err_t wm_rtc_open(rt_device_t dev, rt_uint16_t oflag)
{
return RT_EOK;
}
static rt_err_t wm_rtc_close(rt_device_t dev)
{
return RT_EOK;
}
static rt_err_t wm_rtc_control(rt_device_t dev, int cmd, void *args)
{
#ifdef BSP_USING_ALARM
struct rt_rtc_device* rtc_device;
rtc_device = (struct rt_rtc_device* )dev;
#endif
RT_ASSERT(dev != RT_NULL);
switch (cmd)
{
case RT_DEVICE_CTRL_RTC_GET_TIME:
*(rt_uint32_t *)args = wm_get_timestamp();
break;
case RT_DEVICE_CTRL_RTC_SET_TIME:
wm_set_timestamp(*(time_t *)args);
break;
#ifdef BSP_USING_ALARM
case RT_DEVICE_CTRL_RTC_GET_ALARM:
*(struct rt_rtc_wkalarm *)args = rtc_device->wkalarm;
return RT_EOK;
case RT_DEVICE_CTRL_RTC_SET_ALARM:
rtc_device->wkalarm = *(struct rt_rtc_wkalarm *)args;
wm_alarm_set_timestamp(&rtc_device->wkalarm);
break;
#endif
default:
return RT_EINVAL;
}
return RT_EOK;
}
static rt_size_t wm_rtc_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
{
wm_rtc_control(dev, RT_DEVICE_CTRL_RTC_GET_TIME, buffer);
return size;
}
static rt_size_t wm_rtc_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
{
wm_rtc_control(dev, RT_DEVICE_CTRL_RTC_SET_TIME, (void *)buffer);
return size;
}
#ifdef RT_USING_DEVICE_OPS
const static struct rt_device_ops _ops =
{
.init = wm_rtc_init,
.open = wm_rtc_open,
.close = wm_rtc_close,
.read = wm_rtc_read,
.write = wm_rtc_write,
.control = wm_rtc_control
};
#endif
int wm_hw_rtc_init(void)
{
rt_memset(&rtc_device, 0, sizeof(rtc_device));
rtc_device.device.type = RT_Device_Class_RTC;
rtc_device.device.rx_indicate = RT_NULL;
rtc_device.device.tx_complete = RT_NULL;
#ifdef RT_USING_DEVICE_OPS
rtc_device.ops = &_ops;
#else
rtc_device.device.init = wm_rtc_init;
rtc_device.device.open = wm_rtc_open;
rtc_device.device.close = wm_rtc_close;
rtc_device.device.read = wm_rtc_read;
rtc_device.device.write = wm_rtc_write;
rtc_device.device.control = wm_rtc_control;
#endif
rtc_device.device.user_data = RT_NULL;
/* register a rtc device */
rt_device_register(&rtc_device.device, "rtc", RT_DEVICE_FLAG_RDWR);
return 0;
}
INIT_DEVICE_EXPORT(wm_hw_rtc_init);
#endif /* BSP_USING_RTC */

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-09-15 flyingcys 1st version
*/
#ifndef DRV_RTC_H__
#define DRV_RTC_H__
#include <rtdevice.h>
#ifdef RT_USING_ALARM
#include <alarm.h>
#endif
struct rt_rtc_device
{
struct rt_device device;
#ifdef RT_USING_ALARM
struct rt_rtc_wkalarm wkalarm;
#endif
};
int wm_hw_rtc_init(void);
#endif

202
bsp/w60x/drivers/drv_spi.c Normal file
View File

@@ -0,0 +1,202 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-12 fanwenl 1st version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include "wm_hostspi.h"
#include "wm_spi_hal.h"
#include "wm_io.h"
#include "wm_gpio_afsel.h"
#include "pin_map.h"
#include "drv_spi.h"
#ifdef BSP_USING_SPI
#define BSP_SPI_MAX_HZ (20* 1000 *1000)
struct wm_sw_spi_cs
{
rt_int16_t pin;
};
struct wm_spi
{
struct rt_spi_configuration *cfg;
};
static rt_err_t wm_hostspi_init(struct rt_spi_configuration *cfg)
{
spi_clear_fifo();
spi_set_endian(1);
if (cfg->data_width == 8)
{
tls_spi_trans_type(SPI_BYTE_TRANSFER);
}
if (cfg->data_width == 16)
{
tls_spi_trans_type(SPI_WORD_TRANSFER);
}
spi_set_mode(cfg->mode);
spi_set_chipselect_mode(SPI_CS_INACTIVE_MODE);
spi_force_cs_out(1);
if(cfg->max_hz > BSP_SPI_MAX_HZ)
{
cfg->max_hz = BSP_SPI_MAX_HZ;
}
spi_set_sclk(cfg->max_hz);
spi_set_tx_trigger_level(0);
spi_set_rx_trigger_level(7);
spi_set_rx_channel(1);
spi_set_tx_channel(1);
return RT_EOK;
}
static rt_err_t spi_configure(struct rt_spi_device *device, struct rt_spi_configuration *cfg)
{
RT_ASSERT(cfg != RT_NULL);
RT_ASSERT(device != RT_NULL);
/*将cfg参数放到device中*/
struct wm_spi *hspi = (struct wm_spi *)device->bus->parent.user_data;
hspi->cfg = cfg;
wm_hostspi_init(cfg);
return RT_EOK;
}
static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *message)
{
RT_ASSERT(device != RT_NULL);
RT_ASSERT(device->bus != RT_NULL);
RT_ASSERT(device->bus->parent.user_data != RT_NULL);
struct wm_sw_spi_cs *cs = device->parent.user_data;
struct tls_spi_transfer tls_transfer;
tls_transfer.tx_buf = message->send_buf;
tls_transfer.rx_buf = message->recv_buf;
tls_transfer.len = message->length;
rt_int32_t length = 0;
rt_int32_t remain_length = message->length;
length = spi_fill_txfifo(&tls_transfer, remain_length);
spi_set_sclk_length(length * 8, 0);
if (message->cs_take)
{
tls_gpio_write((enum tls_io_name)cs->pin, 0);
}
spi_sclk_start();
while (remain_length > 0)
{
while (spi_i2s_get_busy_status() == 1)
;
length = spi_get_rxfifo(&tls_transfer, remain_length);
remain_length -= length;
if (remain_length == 0)
{
while (spi_i2s_get_busy_status() == 1)
;
if (message->cs_release)
{
tls_gpio_write((enum tls_io_name)cs->pin, 1);
}
}
while (spi_i2s_get_busy_status() == 1)
;
length = spi_fill_txfifo(&tls_transfer, remain_length);
if (length)
{
spi_set_sclk_length(length * 8, 0);
spi_sclk_start();
}
}
while (spi_i2s_get_busy_status() == 1)
;
if (message->cs_release)
{
tls_gpio_write((enum tls_io_name)cs->pin, 1);
}
return message->length - remain_length;
}
rt_err_t wm_spi_bus_attach_device(const char *bus_name, const char *device_name, rt_uint32_t pin)
{
rt_err_t ret;
rt_int16_t gpio_pin;
struct rt_spi_device *spi_device;
struct wm_sw_spi_cs *cs_pin;
gpio_pin = wm_get_pin(pin);
if (gpio_pin == WM_PIN_DEFAULT)
{
return -RT_ERROR;
}
spi_device = (struct rt_spi_device *)rt_malloc(sizeof(struct rt_spi_device));
RT_ASSERT(spi_device != RT_NULL);
cs_pin = (struct wm_sw_spi_cs *)rt_malloc(sizeof(struct wm_sw_spi_cs));
RT_ASSERT(cs_pin != RT_NULL);
cs_pin->pin = gpio_pin;
tls_gpio_cfg((enum tls_io_name)gpio_pin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_PULLHIGH);
tls_gpio_write((enum tls_io_name)gpio_pin, 1);
ret = rt_spi_bus_attach_device(spi_device, device_name, bus_name, (void *)cs_pin);
return ret;
}
static struct rt_spi_ops wm_spi_ops =
{
.configure = spi_configure,
.xfer = spixfer
};
struct wm_spi spi;
struct rt_spi_bus wm_spi_bus;
int wm_hw_spi_bus_init(void)
{
rt_int16_t gpio_pin;
gpio_pin = wm_get_pin(WM_SPI_CK_PIN);
if (gpio_pin >= 0)
{
wm_spi_ck_config((enum tls_io_name)gpio_pin);
}
gpio_pin = wm_get_pin(WM_SPI_DI_PIN);
if (gpio_pin >= 0)
{
wm_spi_di_config((enum tls_io_name)gpio_pin);
}
gpio_pin = wm_get_pin(WM_SPI_DO_PIN);
if (gpio_pin >= 0)
{
wm_spi_do_config((enum tls_io_name)gpio_pin);
}
wm_spi_bus.parent.user_data = &spi;
rt_spi_bus_register(&wm_spi_bus, "spi0", &wm_spi_ops);
return RT_EOK;
}
INIT_PREV_EXPORT(wm_hw_spi_bus_init);
#endif /* BSP_USING_SPI */

View File

@@ -0,0 +1,19 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-12 fanwenl 1st version
*/
#ifndef __DRV_SPI_BUS_H__
#define __DRV_SPI_BUS_H__
#include <rtthread.h>
int wm_hw_spi_bus_init(void);
rt_err_t wm_spi_bus_attach_device(const char *bus_name, const char *device_name, rt_uint32_t pin);
#endif

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-12 fanwenl 1st version
*/
#include <rtthread.h>
#include <rtdevice.h>
#ifdef BSP_USING_FLASH
#include "drv_spi.h"
#include "string.h"
#include "spi_flash.h"
#include "spi_flash_sfud.h"
int wm_nor_flash_init(void)
{
rt_spi_flash_device_t spi_device;
wm_spi_bus_attach_device(SPI_Flash_BUS_NAME, "norspi", SPI_Flash_CS_PIN);
spi_device = rt_sfud_flash_probe("flash0", "norspi");
if (spi_device == RT_NULL)
{
return -RT_ERROR;
}
return 0;
}
INIT_DEVICE_EXPORT(wm_nor_flash_init);
#endif

View File

@@ -0,0 +1,16 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-12 fanwenl 1st version
*/
#ifndef __DRV_SPI_FLASH_H_
#define __DRV_SPI_FLASH_H_
int wm_nor_flash_init(void);
#endif /* __DRV_SPI_FLASH_H_ */

View File

@@ -0,0 +1,103 @@
/*
* Copyright (c) 2006-2019, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-03-13 tyx first version
*/
#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>
#include "drv_standby.h"
#ifdef BSP_USING_STANDBY
#include "wm_type_def.h"
#include "wm_cpu.h"
#include "wm_pmu.h"
#include "wm_irq.h"
#include "wm_regs.h"
typedef volatile unsigned long vu32;
#define M32(adr) (*((vu32*) (adr)))
typedef void (*rom_standby_func)(void);
static const rom_standby_func pm_standby = (rom_standby_func)0x499;
#ifdef __ICCARM__
extern void standby_idr(void);
#endif
#if (1 == GCC_COMPILE)
void wm_pm_standby(void)
{
__asm volatile (
" cpsid i \n" /* disable irq*/
" dsb \n"
" ldr r0, =0X499 \n"
" bx r0 \n"
" movs r0, #0x00 \n"
" isb \n"
);
}
#endif
/**
* This function will put w60x into run/shutdown mode.
*
* @param timeout How many OS Ticks that MCU can sleep
*/
void sys_start_standby(int ms)
{
rt_uint32_t val;
int timeout = ms;
RT_ASSERT(timeout > 0);
tls_pmu_clk_select(0);
if (timeout <= 65535)
{
/* Enter PM_TIMER_MODE */
tls_irq_enable(PMU_TIMER1_INT);
tls_pmu_timer1_stop();
tls_pmu_timer1_start(timeout);
}
else if(timeout <= 65535000)
{
timeout /= 1000;
tls_irq_enable(PMU_TIMER0_INT);
tls_pmu_timer0_stop();
tls_pmu_timer0_start(timeout);
}
else
{
return;
}
tls_irq_enable(PMU_GPIO_WAKEUP_INT); //Open interrupt by default to clear the interrupt flag for IO wake-up
val = tls_reg_read32(HR_PMU_PS_CR);
val |= 0x01;
tls_reg_write32(HR_PMU_PS_CR, val);
}
#ifdef RT_USING_FINSH
#include <finsh.h>
#include <stdlib.h>
static void standby(uint8_t argc, char **argv)
{
if (argc != 2)
{
rt_kprintf("Usage: standby timeout(ms)\n");
rt_kprintf("eg : standby 5000\n");
}
else
{
sys_start_standby(atoi(argv[1]));
}
}
FINSH_FUNCTION_EXPORT_ALIAS(standby, __cmd_standby, sleep System);
#endif /* RT_USING_FINSH */
#endif /* BSP_USING_STANDBY */

View File

@@ -0,0 +1,16 @@
/*
* Copyright (c) 2006-2019, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-03-25 tyx add file
*/
#ifndef __DRV_STANDBY_H__
#define __DRV_STANDBY_H__
void sys_start_standby(int ms);
#endif

560
bsp/w60x/drivers/drv_uart.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,16 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-09-15 flyingcys add w600 uart drvice
*/
#ifndef __DRV_UART_H__
#define __DRV_UART_H__
int wm_hw_uart_init(void);
#endif /* __DRV_UART_H__ */

View File

@@ -0,0 +1,75 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-9 fanwenl 1st version
*/
#include <rtdevice.h>
#include "wm_watchdog.h"
#ifdef BSP_USING_WDT
static rt_err_t wm_wdg_init(rt_watchdog_t *wdt)
{
/*init for 10S*/
tls_watchdog_init(1000000);
tls_watchdog_stop();
return RT_EOK;
}
static rt_err_t wm_wdg_control(rt_watchdog_t *wdt, int cmd, void *arg)
{
uint64_t timeout_us = 0;
switch (cmd)
{
case RT_DEVICE_CTRL_WDT_SET_TIMEOUT:
timeout_us = *((rt_uint32_t *)arg) * 1000000;
if (timeout_us >= 0xFFFFFFFF)
timeout_us = 0xFFFFFFFF;
tls_watchdog_set_timeout((rt_uint32_t)timeout_us);
break;
case RT_DEVICE_CTRL_WDT_GET_TIMEOUT:
timeout_us = tls_watchdog_get_timeout();
*((rt_uint32_t *)arg) = timeout_us / 1000000;
break;
case RT_DEVICE_CTRL_WDT_GET_TIMELEFT:
timeout_us = tls_watchdog_get_timeleft();
*((rt_uint32_t *)arg) = timeout_us / 1000000;
break;
case RT_DEVICE_CTRL_WDT_KEEPALIVE:
tls_watchdog_clr();
break;
case RT_DEVICE_CTRL_WDT_START:
tls_watchdog_start();
break;
case RT_DEVICE_CTRL_WDT_STOP:
tls_watchdog_stop();
break;
default:
return RT_EIO;
}
return RT_EOK;
}
static const struct rt_watchdog_ops wm_wdg_pos =
{
wm_wdg_init,
wm_wdg_control,
};
static rt_watchdog_t wm_wdg;
int wm_hw_wdg_init(void)
{
wm_wdg.ops = &wm_wdg_pos;
rt_hw_watchdog_register(&wm_wdg, "wdg", 0, RT_NULL);
return RT_EOK;
}
INIT_DEVICE_EXPORT(wm_hw_wdg_init);
#endif /*BSP_USING_WDT */

630
bsp/w60x/drivers/drv_wifi.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,16 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-09-15 flyingcys add w600 wifi driver
*/
#ifndef __DRV_WIFI_H__
#define __DRV_WIFI_H__
int wm_hw_wifi_init(void);
#endif /* __DRV_WIFI_H__ */

View File

@@ -0,0 +1,30 @@
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x08010100;
/*-Memory Regions-*/
/* rom 959K */
define symbol __ICFEDIT_region_ROM_start__ = 0x08010100;
define symbol __ICFEDIT_region_ROM_end__ = 0x080FFFFF;
/* ram 224k */
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x2003C000;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0xc00;
define symbol __ICFEDIT_size_heap__ = 0x1A000;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
initialize by copy { readwrite };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite, last block CSTACK};

View File

@@ -0,0 +1,172 @@
/* Linker script to configure memory regions.
* Need modifying for a specific board.
* FLASH.ORIGIN: starting address of flash
* FLASH.LENGTH: length of flash
* RAM.ORIGIN: starting address of RAM bank 0
* RAM.LENGTH: length of RAM bank 0
*/
MEMORY
{
FLASH (rx) : ORIGIN = 0x8010100, LENGTH = 959K /* 960K-256B */
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x3C000 /* 240K */
}
/* Linker script to place sections and symbol values. Should be used together
* with other linker script that defines memory regions FLASH and RAM.
* It references following symbols, which must be defined in code:
* Reset_Handler : Entry of reset handler
*
* It defines following symbols, which code can use without definition:
* __exidx_start
* __exidx_end
* __copy_table_start__
* __copy_table_end__
* __zero_table_start__
* __zero_table_end__
* __etext
* __data_start__
* __preinit_array_start
* __preinit_array_end
* __init_array_start
* __init_array_end
* __fini_array_start
* __fini_array_end
* __data_end__
* __bss_start__
* __bss_end__
* __end__
* end
* __HeapLimit
* __StackLimit
* __StackTop
* __stack
*/
ENTRY(Reset_Handler)
SECTIONS
{
.text :
{
. = ALIGN(4);
_stext = .;
KEEP(*(.isr_vector))
. = ALIGN(4);
*(.text) /* remaining code */
*(.text.*) /* remaining code */
*(.rodata) /* read-only data (constants) */
*(.rodata*)
*(.glue_7)
*(.glue_7t)
*(.gnu.linkonce.t*)
/* section information for finsh shell */
. = ALIGN(4);
__fsymtab_start = .;
KEEP(*(FSymTab))
__fsymtab_end = .;
. = ALIGN(4);
__vsymtab_start = .;
KEEP(*(VSymTab))
__vsymtab_end = .;
/* section information for initial. */
. = ALIGN(4);
__rt_init_start = .;
KEEP(*(SORT(.rti_fn*)))
__rt_init_end = .;
. = ALIGN(4);
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
} > FLASH
__exidx_end = .;
__etext = .;
.data : AT (__etext)
{
. = ALIGN(4);
__data_start__ = .;
*(vtable)
*(.data*)
. = ALIGN(4);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
/* All data end */
__data_end__ = .;
} > RAM
.stack_dummy (COPY):
{
. = ALIGN(8);
__stack_start__ = .;
*(.stack*)
__stack_end__ = .;
} > RAM
.bss __stack_end__ :
{
. = ALIGN(4);
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
} > RAM
ASSERT(__StackTop <= 0x20028000, "stack address error")
}

View File

@@ -0,0 +1,14 @@
; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
LR_IROM1 0x08010100 0x000EFEFF { ; load region size_region
ER_IROM1 0x08010100 0x000EFEFF { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x20000000 0x0003C000 { ; RW data
.ANY (+RW +ZI)
}
}

143
bsp/w60x/drivers/pin_map.c Normal file
View File

@@ -0,0 +1,143 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-21 fanwenl first version
*/
#include <rtthread.h>
#include "wm_io.h"
#include "pin_map.h"
#if defined(SOC_W600_A8xx)
#define WM60X_PIN_NUMBERS 33
#elif defined(SOC_W601_A8xx)
#define WM60X_PIN_NUMBERS 69
#endif
#define __WM_PIN(index, gpio_index) (gpio_index)
#define WM_PIN_NUM(items) (sizeof(items) / sizeof(items[0]))
/* WM chip GPIO map*/
static const rt_int16_t pins[] =
{
__WM_PIN(0, WM_PIN_DEFAULT),
#if (WM60X_PIN_NUMBERS == 33)
__WM_PIN(1, WM_PIN_DEFAULT),
__WM_PIN(2, WM_PIN_DEFAULT),
__WM_PIN(3, WM_PIN_DEFAULT),
__WM_PIN(4, WM_PIN_DEFAULT),
__WM_PIN(5, WM_PIN_DEFAULT),
__WM_PIN(6, WM_PIN_DEFAULT),
__WM_PIN(7, WM_PIN_DEFAULT),
__WM_PIN(8, WM_PIN_DEFAULT),
__WM_PIN(9, WM_PIN_DEFAULT),
__WM_PIN(10, WM_PIN_DEFAULT),
__WM_PIN(11, WM_PIN_DEFAULT),
__WM_PIN(12, WM_PIN_DEFAULT),
__WM_PIN(13, WM_IO_PA_00),
__WM_PIN(14, WM_IO_PA_01),
__WM_PIN(15, WM_IO_PA_04),
__WM_PIN(16, WM_PIN_DEFAULT),
__WM_PIN(17, WM_IO_PA_05),
__WM_PIN(18, WM_IO_PB_13),
__WM_PIN(19, WM_IO_PB_14),
__WM_PIN(20, WM_IO_PB_15),
__WM_PIN(21, WM_IO_PB_16),
__WM_PIN(22, WM_IO_PB_17),
__WM_PIN(23, WM_IO_PB_18),
__WM_PIN(24, WM_PIN_DEFAULT),
__WM_PIN(25, WM_PIN_DEFAULT),
__WM_PIN(26, WM_IO_PB_06),
__WM_PIN(27, WM_IO_PB_07),
__WM_PIN(28, WM_IO_PB_08),
__WM_PIN(29, WM_IO_PB_09),
__WM_PIN(30, WM_IO_PB_10),
__WM_PIN(31, WM_IO_PB_11),
__WM_PIN(32, WM_IO_PB_12),
__WM_PIN(33, WM_PIN_DEFAULT),
#elif (WM60X_PIN_NUMBERS == 69)
__WM_PIN(1, WM_IO_PB_19),
__WM_PIN(2, WM_IO_PB_20),
__WM_PIN(3, WM_IO_PB_21),
__WM_PIN(4, WM_IO_PB_22),
__WM_PIN(5, WM_IO_PB_23),
__WM_PIN(6, WM_IO_PB_24),
__WM_PIN(7, WM_IO_PB_25),
__WM_PIN(8, WM_IO_PB_26),
__WM_PIN(9, WM_PIN_DEFAULT),
__WM_PIN(10, WM_PIN_DEFAULT),
__WM_PIN(11, WM_PIN_DEFAULT),
__WM_PIN(12, WM_PIN_DEFAULT),
__WM_PIN(13, WM_PIN_DEFAULT),
__WM_PIN(14, WM_PIN_DEFAULT),
__WM_PIN(15, WM_PIN_DEFAULT),
__WM_PIN(16, WM_PIN_DEFAULT),
__WM_PIN(17, WM_PIN_DEFAULT),
__WM_PIN(18, WM_PIN_DEFAULT),
__WM_PIN(19, WM_PIN_DEFAULT),
__WM_PIN(20, WM_PIN_DEFAULT),
__WM_PIN(21, WM_PIN_DEFAULT),
__WM_PIN(22, WM_PIN_DEFAULT),
__WM_PIN(23, WM_IO_PA_00),
__WM_PIN(24, WM_IO_PA_01),
__WM_PIN(25, WM_IO_PA_02),
__WM_PIN(26, WM_IO_PA_03),
__WM_PIN(27, WM_IO_PA_04),
__WM_PIN(28, WM_PIN_DEFAULT),
__WM_PIN(29, WM_IO_PA_05),
__WM_PIN(30, WM_IO_PA_13),
__WM_PIN(31, WM_IO_PA_14),
__WM_PIN(32, WM_IO_PA_15),
__WM_PIN(33, WM_IO_PA_06),
__WM_PIN(34, WM_PIN_DEFAULT),
__WM_PIN(35, WM_IO_PA_07),
__WM_PIN(36, WM_IO_PA_08),
__WM_PIN(37, WM_IO_PA_09),
__WM_PIN(38, WM_IO_PA_10),
__WM_PIN(39, WM_IO_PA_11),
__WM_PIN(40, WM_IO_PA_12),
__WM_PIN(41, WM_IO_PB_28),
__WM_PIN(42, WM_PIN_DEFAULT),
__WM_PIN(43, WM_IO_PB_13),
__WM_PIN(44, WM_IO_PB_14),
__WM_PIN(45, WM_IO_PB_15),
__WM_PIN(46, WM_PIN_DEFAULT),
__WM_PIN(47, WM_IO_PB_16),
__WM_PIN(48, WM_IO_PB_17),
__WM_PIN(49, WM_IO_PB_18),
__WM_PIN(50, WM_PIN_DEFAULT),
__WM_PIN(51, WM_IO_PB_30),
__WM_PIN(52, WM_IO_PB_31),
__WM_PIN(53, WM_IO_PB_27),
__WM_PIN(54, WM_IO_PB_00),
__WM_PIN(55, WM_IO_PB_01),
__WM_PIN(56, WM_IO_PB_02),
__WM_PIN(57, WM_IO_PB_03),
__WM_PIN(58, WM_PIN_DEFAULT),
__WM_PIN(59, WM_IO_PB_04),
__WM_PIN(60, WM_IO_PB_05),
__WM_PIN(61, WM_IO_PB_06),
__WM_PIN(62, WM_IO_PB_07),
__WM_PIN(63, WM_IO_PB_08),
__WM_PIN(64, WM_IO_PB_09),
__WM_PIN(65, WM_IO_PB_10),
__WM_PIN(66, WM_IO_PB_11),
__WM_PIN(67, WM_IO_PB_12),
__WM_PIN(68, WM_PIN_DEFAULT),
__WM_PIN(69, WM_PIN_DEFAULT),
#endif
};
rt_int16_t wm_get_pin(rt_base_t pin_index)
{
rt_int16_t gpio_pin = WM_PIN_DEFAULT;
if (pin_index < WM_PIN_NUM(pins))
{
gpio_pin = pins[pin_index];
}
return gpio_pin;
}

View File

@@ -0,0 +1,20 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-21 fanwenl first version
*/
#ifndef __PIN_MAP_H__
#define __PIN_MAP_H__
#include <rtthread.h>
#define WM_PIN_DEFAULT (-1)
rt_int16_t wm_get_pin(rt_base_t pin_index);
#endif

124
bsp/w60x/makeimg.bat Normal file
View File

@@ -0,0 +1,124 @@
@rem 参数0: exe
@rem 参数1: 输入bin文件 ,原始文件或者压缩档文件
@rem 参数2: 输出文件(目标生成文件)
@rem 参数3: 输入文件类型,0是旧参数布局的image文件3是新参数布局的image文件
@rem 参数4: 是否压缩文件0plain文件1压缩类型文件
@rem 参数5: 版本号文件
@rem 参数6升级文件再FLASH里的存放位置相对位置
@rem 参数7升级后的文件启动位置相对位置
@rem 参数8原始bin文件
@echo off
@rem if debug_info=1, Debugging Print Information will be turned on
set debug_info=0
@rem Setting firmware output directory
set out_path=.\Bin
@rem Setting the bin file path
set bin_file=.\rtthread.bin
@rem Setting the version.txt file path
set version_file=.\tools\version.txt
@rem Setting the secboot.img file path
set secboot_file=.\tools\secboot.img
@rem Setting the wm_gzip.exe file path
set wm_gzip_file=.\tools\wm_gzip.exe
@rem Setting the makeimg.exe file path
set makeimg_file=.\tools\makeimg.exe
@rem Setting the makeimg_all.exe file path
set makeimg_all_file=.\tools\makeimg_all.exe
@rem Prepare to generate firmware
if "%out_path:~0,1%" == "." (set out_path=%~dp0%out_path%)
if "%bin_file:~0,1%" == "." (set bin_file=%~dp0%bin_file%)
if "%version_file:~0,1%" == "." (set version_file=%~dp0%version_file%)
if "%secboot_file:~0,1%" == "." (set secboot_file=%~dp0%secboot_file%)
if "%wm_gzip_file:~0,1%" == "." (set wm_gzip_file=%~dp0%wm_gzip_file%)
if "%makeimg_file:~0,1%" == "." (set makeimg_file=%~dp0%makeimg_file%)
if "%makeimg_all_file:~0,1%" == "." (set makeimg_all_file=%~dp0%makeimg_all_file%)
@rem Create output folder
if not exist "%out_path%" (md "%out_path%")
@rem Copy the required files
if exist "%bin_file%" (copy "%bin_file%" "%out_path%") else (echo makeimg err! No bin file found: %bin_file% & goto end)
if exist "%version_file%" (copy "%version_file%" "%out_path%") else (echo makeimg err! No version file found: %version_file% & goto end)
if exist "%secboot_file%" (copy "%secboot_file%" "%out_path%") else (echo makeimg err! No secboot file found: %secboot_file% & goto end)
@rem Check the existence of firmware generation tools
if not exist "%wm_gzip_file%" (echo makeimg err! No wm_gzip file found: "%wm_gzip_file%" & goto end)
if not exist "%makeimg_file%" (echo makeimg err! No makeimg file found: "%makeimg_file%" & goto end)
if not exist "%makeimg_all_file%" (echo makeimg err! No makeimg_all file found: "%makeimg_all_file%" & goto end)
@rem Get File Names and File Extensions
for /f "delims=" %%A in ('dir /b %bin_file%') do set "bin_file_name=%%A"
for /f "delims=." %%A in ('dir /b %bin_file%') do set bin_name=%%A
for /f "delims=%bin_name%" %%A in ('dir /b %bin_file%') do set bin_extend=%%A
for /f "delims=" %%A in ('dir /b %version_file%') do set "version_file_name=%%A"
for /f "delims=" %%A in ('dir /b %secboot_file%') do set "secboot_file_name=%%A"
@rem Print Debug Information
if not "%debug_info%"=="0" (echo bin_file_name:%bin_file_name% & echo bin_name:%bin_name% & echo bin_extend:%bin_extend% & echo version_file_name:%version_file_name% & echo secboot_file_name:%secboot_file_name%)
echo makeimg 1M Flash...
@rem Start making 1M flash firmware
set file_pos=_1M
@rem Create command parameters
set wm_gzip_cmd="%out_path%\%bin_file_name%"
set makeimg_img_cmd="%out_path%\%bin_file_name%" "%out_path%\%bin_name%%file_pos%.img" 0 0 "%out_path%\%version_file_name%" 90000 10100
set makeimg_gz_img_cmd="%out_path%\%bin_file_name%.gz" "%out_path%\%bin_name%_GZ%file_pos%.img" 0 1 "%out_path%\%version_file_name%" 90000 10100 "%out_path%\%bin_file_name%"
set makeimg_sec_img_cmd="%out_path%\%bin_file_name%" "%out_path%\%bin_name%_SEC%file_pos%.img" 0 0 "%out_path%\%version_file_name%" 90000 10100
set makeimg_all_cmd="%out_path%\%secboot_file_name%" "%out_path%\%bin_name%%file_pos%.img" "%out_path%\%bin_name%%file_pos%.FLS"
@rem Print command Information
if not "%debug_info%"=="0" (echo wm_gzip %wm_gzip_cmd%)
if not "%debug_info%"=="0" (echo makeimg %makeimg_img_cmd%)
if not "%debug_info%"=="0" (echo makeimg %makeimg_gz_img_cmd%)
if not "%debug_info%"=="0" (echo makeimg %makeimg_sec_img_cmd%)
if not "%debug_info%"=="0" (echo makeimg_all %makeimg_all_cmd%)
@rem Execute firmware generation commands
"%wm_gzip_file%" %wm_gzip_cmd%
"%makeimg_file%" %makeimg_img_cmd%
"%makeimg_file%" %makeimg_gz_img_cmd%
"%makeimg_file%" %makeimg_sec_img_cmd%
"%makeimg_all_file%" %makeimg_all_cmd%
@rem Delete temporary files
if exist "%out_path%\%bin_name%%file_pos%.img" (del "%out_path%\%bin_name%%file_pos%.img")
if exist "%out_path%\%bin_file_name%.gz" (del "%out_path%\%bin_file_name%.gz")
@rem Start making 2M flash firmware
echo makeimg 2M Flash...
set file_pos=_2M
@rem Create command parameters
set wm_gzip_cmd="%out_path%\%bin_file_name%"
set makeimg_img_cmd="%out_path%\%bin_file_name%" "%out_path%\%bin_name%%file_pos%.img" 3 0 "%out_path%\%version_file_name%" 90000 10100
set makeimg_gz_img_cmd="%out_path%\%bin_file_name%.gz" "%out_path%\%bin_name%_GZ%file_pos%.img" 3 1 "%out_path%\%version_file_name%" 90000 10100 "%out_path%\%bin_file_name%"
set makeimg_sec_img_cmd="%out_path%\%bin_file_name%" "%out_path%\%bin_name%_SEC%file_pos%.img" 3 0 "%out_path%\%version_file_name%" 90000 10100
set makeimg_all_cmd="%out_path%\%secboot_file_name%" "%out_path%\%bin_name%%file_pos%.img" "%out_path%\%bin_name%%file_pos%.FLS"
@rem Print command Information
if not "%debug_info%"=="0" (echo wm_gzip %wm_gzip_cmd%)
if not "%debug_info%"=="0" (echo makeimg %makeimg_img_cmd%)
if not "%debug_info%"=="0" (echo makeimg %makeimg_gz_img_cmd%)
if not "%debug_info%"=="0" (echo makeimg %makeimg_sec_img_cmd%)
if not "%debug_info%"=="0" (echo makeimg_all %makeimg_all_cmd%)
@rem Execute firmware generation commands
"%wm_gzip_file%" %wm_gzip_cmd%
"%makeimg_file%" %makeimg_img_cmd%
"%makeimg_file%" %makeimg_gz_img_cmd%
"%makeimg_file%" %makeimg_sec_img_cmd%
"%makeimg_all_file%" %makeimg_all_cmd%
@rem Delete temporary files
if exist "%out_path%\%bin_name%%file_pos%.img" (del "%out_path%\%bin_name%%file_pos%.img")
if exist "%out_path%\%bin_file_name%.gz" (del "%out_path%\%bin_file_name%.gz")
:end
echo end

178
bsp/w60x/makeimg.py Normal file
View File

@@ -0,0 +1,178 @@
# -*- coding: utf-8 -*-
import os
import sys
import shutil
import subprocess
import time
import platform
# if debug_info=True, Debugging Print Information will be turned on
debug_info=False
# Setting firmware output directory
out_path='./Bin'
# Setting the bin file path
bin_file='./rtthread.bin'
# Setting the version.txt file path
version_file='./tools' + '/version.txt'
# Setting the secboot.img file path
secboot_file='./tools' + '/secboot.img'
# Setting the wm_gzip.exe file path
wm_gzip_file='./tools' + '/wm_gzip.exe'
# Setting the makeimg.exe file path
makeimg_file='./tools' + '/makeimg.exe'
# Setting the makeimg_all.exe file path
makeimg_all_file='./tools' + '/makeimg_all.exe'
def execute_command(cmdstring, cwd=None, shell=True):
"""Execute the system command at the specified address."""
if shell:
cmdstring_list = cmdstring
sub = subprocess.Popen(cmdstring_list, cwd=cwd, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=shell, bufsize=8192)
stdout_str = ""
while sub.poll() is None:
stdout_str += str(sub.stdout.read())
time.sleep(0.1)
return stdout_str
def copy_file(name, path):
res = True
if os.path.exists(path):
shutil.copy(path, out_path)
else:
print('makeimg err! No ' + name + ' file found: ' + path)
res = False
return res
def is_exists(name, path):
res = True
if not os.path.exists(path):
print('makeimg err! No ' + name + ' file found: ' + path)
res = False
return res
def get_exec_path(path):
(file_path, file_name) = os.path.split(path)
(name, extend) = os.path.splitext(file_name)
exec_path = ''
if (platform.system() == "Windows"):
exec_path = os.path.abspath(file_path + '/' + name + '.exe')
elif (platform.system() == "Linux"):
exec_path = os.path.abspath(file_path + '/' + name)
if debug_info:
print('file_path: ' + file_path)
print('file_name: ' + file_name)
print('name: ' + name)
print('extend: ' + extend)
return exec_path
def do_makeimg(tool_path, param):
str = "\"" + tool_path + "\"" + ' ' + param
if debug_info:
print('exec cmd: ' + str);
execute_command(str)
if __name__=='__main__':
# Get the execution file name
wm_gzip_file = get_exec_path(wm_gzip_file)
makeimg_file = get_exec_path(makeimg_file)
makeimg_all_file = get_exec_path(makeimg_all_file)
# Get absolute path
out_path = os.path.abspath(out_path).replace('\\', '/');
bin_file = os.path.abspath(bin_file).replace('\\', '/');
version_file = os.path.abspath(version_file).replace('\\', '/');
secboot_file = os.path.abspath(secboot_file).replace('\\', '/');
wm_gzip_file = os.path.abspath(wm_gzip_file).replace('\\', '/');
makeimg_file = os.path.abspath(makeimg_file).replace('\\', '/');
makeimg_all_file = os.path.abspath(makeimg_all_file).replace('\\', '/');
# Create the output directory
if not os.path.exists(out_path): os.mkdir(out_path)
# Copy file
if not copy_file('bin', bin_file): exit(0)
if not copy_file('version', version_file): exit(0)
if not copy_file('secboot', secboot_file): exit(0)
# Check the existence of packaging tools
if not is_exists('wm_gzip', wm_gzip_file): exit(0)
if not is_exists('makeimg', makeimg_file): exit(0)
if not is_exists('makeimg_all', makeimg_all_file): exit(0)
# Get File Names and File Extensions
(bin_file_path,bin_file_name) = os.path.split(bin_file)
(bin_name,bin_extend) = os.path.splitext(bin_file_name)
(version_file_path,version_file_name) = os.path.split(version_file)
(secboot_file_path,secboot_file_name) = os.path.split(secboot_file)
# print debug Information
if debug_info: print('bin_file_name:' + bin_file_name + 'bin_name:' + bin_name + 'bin_extend:' + bin_extend + 'version_file_name:' + version_file_name + 'secboot_file_name:' + secboot_file_name)
print('makeimg 1M Flash...')
file_pos='_1M'
gzip_param = "\"" + out_path + '/' + bin_file_name + "\""
make_img_param = "\"" + out_path + '/' + bin_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos + '.img' + "\"" + ' 0' + ' 0' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100'
make_GZ_param = "\"" + out_path + '/' + bin_file_name + '.gz' + "\"" + ' ' + "\"" + out_path + '/' + bin_name + '_GZ' + file_pos + '.img' +"\"" + ' 0' + ' 1' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100' + ' ' + "\"" + out_path + '/' + bin_file_name + "\""
make_SEC_param = "\"" + out_path + '/' + bin_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + '_SEC' + file_pos + '.img' + "\"" + ' 0' + ' 0' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100'
make_FLS_param = "\"" + out_path + '/' + secboot_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos + '.img' + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos + '.FLS' + "\""
if debug_info:
print('gzip_param' + gzip_param)
print('make_img_param' + make_img_param)
print('make_GZ_param' + make_GZ_param)
print('make_SEC_param' + make_SEC_param)
print('make_FLS_param' + make_FLS_param)
do_makeimg(wm_gzip_file, gzip_param)
do_makeimg(makeimg_file, make_img_param)
do_makeimg(makeimg_file, make_GZ_param)
do_makeimg(makeimg_file, make_SEC_param)
do_makeimg(makeimg_all_file, make_FLS_param)
rm_file = out_path + '/' + bin_name + file_pos + '.img'
if os.path.exists(rm_file):
os.remove(rm_file)
rm_file = out_path + '/' + bin_file_name + '.gz'
if os.path.exists(rm_file):
os.remove(rm_file)
print('makeimg 2M Flash...')
file_pos='_2M'
gzip_param = "\"" + out_path + '/' + bin_file_name + "\""
make_img_param = "\"" + out_path + '/' + bin_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos + '.img' + "\"" + ' 3' + ' 0' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100'
make_GZ_param = "\"" + out_path + '/' + bin_file_name + '.gz' + "\"" + ' ' + "\"" + out_path + '/' + bin_name + '_GZ' + file_pos + '.img' +"\"" + ' 3' + ' 1' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100' + ' ' + "\"" + out_path + '/' + bin_file_name + "\""
make_SEC_param = "\"" + out_path + '/' + bin_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + '_SEC' + file_pos + '.img' + "\"" + ' 3' + ' 0' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100'
make_FLS_param = "\"" + out_path + '/' + secboot_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos + '.img' + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos + '.FLS' + "\""
if debug_info:
print('gzip_param' + gzip_param)
print('make_img_param' + make_img_param)
print('make_GZ_param' + make_GZ_param)
print('make_SEC_param' + make_SEC_param)
print('make_FLS_param' + make_FLS_param)
do_makeimg(wm_gzip_file, gzip_param)
do_makeimg(makeimg_file, make_img_param)
do_makeimg(makeimg_file, make_GZ_param)
do_makeimg(makeimg_file, make_SEC_param)
do_makeimg(makeimg_all_file, make_FLS_param)
rm_file = out_path + '/' + bin_name + file_pos + '.img'
if os.path.exists(rm_file):
os.remove(rm_file)
rm_file = out_path + '/' + bin_file_name + '.gz'
if os.path.exists(rm_file):
os.remove(rm_file)
print('end')

2646
bsp/w60x/project.ewp Normal file

File diff suppressed because it is too large Load Diff

10
bsp/w60x/project.eww Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<workspace>
<project>
<path>$WS_DIR$\project.ewp</path>
</project>
<batchBuild/>
</workspace>

177
bsp/w60x/project.uvoptx Normal file
View File

@@ -0,0 +1,177 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
<SchemaVersion>1.0</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<Extensions>
<cExt>*.c</cExt>
<aExt>*.s*; *.src; *.a*</aExt>
<oExt>*.obj; *.o</oExt>
<lExt>*.lib</lExt>
<tExt>*.txt; *.h; *.inc</tExt>
<pExt>*.plm</pExt>
<CppX>*.cpp</CppX>
<nMigrate>0</nMigrate>
</Extensions>
<DaveTm>
<dwLowDateTime>0</dwLowDateTime>
<dwHighDateTime>0</dwHighDateTime>
</DaveTm>
<Target>
<TargetName>rt-thread</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<TargetOption>
<CLKADS>12000000</CLKADS>
<OPTTT>
<gFlags>1</gFlags>
<BeepAtEnd>1</BeepAtEnd>
<RunSim>0</RunSim>
<RunTarget>1</RunTarget>
<RunAbUc>0</RunAbUc>
</OPTTT>
<OPTHX>
<HexSelection>1</HexSelection>
<FlashByte>65535</FlashByte>
<HexRangeLowAddress>0</HexRangeLowAddress>
<HexRangeHighAddress>0</HexRangeHighAddress>
<HexOffset>0</HexOffset>
</OPTHX>
<OPTLEX>
<PageWidth>79</PageWidth>
<PageLength>66</PageLength>
<TabStop>8</TabStop>
<ListingPath>.\build\keil\List\</ListingPath>
</OPTLEX>
<ListingPage>
<CreateCListing>1</CreateCListing>
<CreateAListing>1</CreateAListing>
<CreateLListing>1</CreateLListing>
<CreateIListing>0</CreateIListing>
<AsmCond>1</AsmCond>
<AsmSymb>1</AsmSymb>
<AsmXref>0</AsmXref>
<CCond>1</CCond>
<CCode>0</CCode>
<CListInc>0</CListInc>
<CSymb>0</CSymb>
<LinkerCodeListing>0</LinkerCodeListing>
</ListingPage>
<OPTXL>
<LMap>1</LMap>
<LComments>1</LComments>
<LGenerateSymbols>1</LGenerateSymbols>
<LLibSym>1</LLibSym>
<LLines>1</LLines>
<LLocSym>1</LLocSym>
<LPubSym>1</LPubSym>
<LXref>0</LXref>
<LExpSel>0</LExpSel>
</OPTXL>
<OPTFL>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>7</CpuCode>
<DebugOpt>
<uSim>0</uSim>
<uTrg>1</uTrg>
<sLdApp>1</sLdApp>
<sGomain>1</sGomain>
<sRbreak>1</sRbreak>
<sRwatch>1</sRwatch>
<sRmem>1</sRmem>
<sRfunc>1</sRfunc>
<sRbox>1</sRbox>
<tLdApp>1</tLdApp>
<tGomain>1</tGomain>
<tRbreak>1</tRbreak>
<tRwatch>1</tRwatch>
<tRmem>1</tRmem>
<tRfunc>0</tRfunc>
<tRbox>1</tRbox>
<tRtrace>1</tRtrace>
<sRSysVw>1</sRSysVw>
<tRSysVw>1</tRSysVw>
<sRunDeb>0</sRunDeb>
<sLrtime>0</sLrtime>
<bEvRecOn>1</bEvRecOn>
<bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf>
<nTsel>4</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
<sDlgPa></sDlgPa>
<sIfile></sIfile>
<tDll></tDll>
<tDllPa></tDllPa>
<tDlgDll></tDlgDll>
<tDlgPa></tDlgPa>
<tIfile>.\ROM.ini</tIfile>
<pMon>Segger\JL2CM3.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>JL2CM3</Key>
<Name>-U20090928 -O78 -S8 -ZTIFSpeedSel50000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC2000 -FN1 -FF0W600_QFlash -FS08000000 -FL0100000</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>UL2CM3</Key>
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000)</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
<DebugFlag>
<trace>0</trace>
<periodic>0</periodic>
<aLwin>0</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
<aPa>0</aPa>
<viewmode>0</viewmode>
<vrSel>0</vrSel>
<aSym>0</aSym>
<aTbox>0</aTbox>
<AscS1>0</AscS1>
<AscS2>0</AscS2>
<AscS3>0</AscS3>
<aSer3>0</aSer3>
<eProf>0</eProf>
<aLa>0</aLa>
<aPa1>0</aPa1>
<AscS4>0</AscS4>
<aSer4>0</aSer4>
<StkLoc>0</StkLoc>
<TrcWin>0</TrcWin>
<newCpu>0</newCpu>
<uProt>0</uProt>
</DebugFlag>
<LintExecutable></LintExecutable>
<LintConfigFile></LintConfigFile>
<bLintAuto>0</bLintAuto>
<bAutoGenD>0</bAutoGenD>
<LntExFlags>0</LntExFlags>
<pMisraName></pMisraName>
<pszMrule></pszMrule>
<pSingCmds></pSingCmds>
<pMultCmds></pMultCmds>
<pMisraNamep></pMisraNamep>
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
</TargetOption>
</Target>
</ProjectOpt>

1508
bsp/w60x/project.uvprojx Normal file

File diff suppressed because it is too large Load Diff

261
bsp/w60x/rtconfig.h Normal file
View File

@@ -0,0 +1,261 @@
#ifndef RT_CONFIG_H__
#define RT_CONFIG_H__
/* Automatically generated file; DO NOT EDIT. */
/* RT-Thread Configuration */
/* RT-Thread Kernel */
#define RT_NAME_MAX 8
#define RT_ALIGN_SIZE 4
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
#define RT_TICK_PER_SECOND 1000
#define RT_USING_OVERFLOW_CHECK
#define RT_USING_HOOK
#define RT_USING_IDLE_HOOK
#define RT_IDEL_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 256
#define RT_USING_TIMER_SOFT
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512
#define RT_DEBUG
#define RT_DEBUG_COLOR
/* Inter-Thread communication */
#define RT_USING_SEMAPHORE
#define RT_USING_MUTEX
#define RT_USING_EVENT
#define RT_USING_MAILBOX
#define RT_USING_MESSAGEQUEUE
/* Memory Management */
#define RT_USING_MEMPOOL
#define RT_USING_SMALL_MEM
#define RT_USING_HEAP
/* Kernel Device Object */
#define RT_USING_DEVICE
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart0"
#define RT_VER_NUM 0x40001
/* RT-Thread Components */
#define RT_USING_COMPONENTS_INIT
#define RT_USING_USER_MAIN
#define RT_MAIN_THREAD_STACK_SIZE 2048
#define RT_MAIN_THREAD_PRIORITY 10
/* C++ features */
/* Command shell */
#define RT_USING_FINSH
#define FINSH_THREAD_NAME "tshell"
#define FINSH_USING_HISTORY
#define FINSH_HISTORY_LINES 5
#define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION
#define FINSH_THREAD_PRIORITY 20
#define FINSH_THREAD_STACK_SIZE 4096
#define FINSH_CMD_SIZE 80
#define FINSH_USING_MSH
#define FINSH_USING_MSH_DEFAULT
#define FINSH_USING_MSH_ONLY
#define FINSH_ARG_MAX 10
/* Device virtual file system */
#define RT_USING_DFS
#define DFS_USING_WORKDIR
#define DFS_FILESYSTEMS_MAX 4
#define DFS_FILESYSTEM_TYPES_MAX 4
#define DFS_FD_MAX 16
#define RT_USING_DFS_DEVFS
/* Device Drivers */
#define RT_USING_DEVICE_IPC
#define RT_PIPE_BUFSZ 512
#define RT_USING_SERIAL
#define RT_SERIAL_USING_DMA
#define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_PIN
/* Using WiFi */
#define RT_USING_WIFI
#define RT_WLAN_DEVICE_STA_NAME "wlan0"
#define RT_WLAN_DEVICE_AP_NAME "wlan1"
#define RT_WLAN_DEFAULT_PROT "lwip"
#define RT_WLAN_SCAN_WAIT_MS 10000
#define RT_WLAN_CONNECT_WAIT_MS 10000
#define RT_WLAN_SSID_MAX_LENGTH 32
#define RT_WLAN_PASSWORD_MAX_LENGTH 32
#define RT_WLAN_SCAN_SORT
#define RT_WLAN_CFG_INFO_MAX 3
#define RT_WLAN_WORKQUEUE_THREAD_NAME "wlan_job"
#define RT_WLAN_WORKQUEUE_THREAD_SIZE 2048
#define RT_WLAN_WORKQUEUE_THREAD_PRIO 22
#define RT_WLAN_DEV_EVENT_NUM 2
/* Using USB */
/* POSIX layer and C standard library */
#define RT_USING_LIBC
#define RT_USING_POSIX
/* Network */
/* Socket abstraction layer */
#define RT_USING_SAL
/* protocol stack implement */
#define SAL_USING_LWIP
#define SAL_USING_POSIX
#define SAL_PROTO_FAMILIES_NUM 4
/* light weight TCP/IP stack */
#define RT_USING_LWIP
#define RT_USING_LWIP202
#define RT_LWIP_IGMP
#define RT_LWIP_ICMP
#define RT_LWIP_DNS
#define RT_LWIP_DHCP
#define IP_SOF_BROADCAST 1
#define IP_SOF_BROADCAST_RECV 1
/* Static IPv4 Address */
#define RT_LWIP_IPADDR "192.168.1.30"
#define RT_LWIP_GWADDR "192.168.1.1"
#define RT_LWIP_MSKADDR "255.255.255.0"
#define RT_LWIP_UDP
#define RT_LWIP_TCP
#define RT_LWIP_RAW
#define RT_MEMP_NUM_NETCONN 8
#define RT_LWIP_PBUF_NUM 16
#define RT_LWIP_RAW_PCB_NUM 4
#define RT_LWIP_UDP_PCB_NUM 4
#define RT_LWIP_TCP_PCB_NUM 4
#define RT_LWIP_TCP_SEG_NUM 40
#define RT_LWIP_TCP_SND_BUF 10240
#define RT_LWIP_TCP_WND 10240
#define RT_LWIP_TCPTHREAD_PRIORITY 10
#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8
#define RT_LWIP_TCPTHREAD_STACKSIZE 1024
#define LWIP_NO_RX_THREAD
#define LWIP_NO_TX_THREAD
#define RT_LWIP_ETHTHREAD_PRIORITY 12
#define RT_LWIP_ETHTHREAD_STACKSIZE 1024
#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8
#define LWIP_NETIF_STATUS_CALLBACK 1
#define SO_REUSE 1
#define LWIP_SO_RCVTIMEO 1
#define LWIP_SO_SNDTIMEO 1
#define LWIP_SO_RCVBUF 1
#define LWIP_NETIF_LOOPBACK 0
/* Modbus master and slave stack */
/* AT commands */
#define LWIP_USING_DHCPD
#define DHCPD_SERVER_IP "192.168.169.1"
/* VBUS(Virtual Software BUS) */
/* Utilities */
#define RT_USING_ULOG
#define ULOG_OUTPUT_LVL_I
#define ULOG_OUTPUT_LVL 6
#define ULOG_USING_ISR_LOG
#define ULOG_ASSERT_ENABLE
#define ULOG_LINE_BUF_SIZE 128
/* log format */
#define ULOG_USING_COLOR
#define ULOG_OUTPUT_TIME
#define ULOG_OUTPUT_LEVEL
#define ULOG_OUTPUT_TAG
#define ULOG_BACKEND_USING_CONSOLE
/* RT-Thread online packages */
/* IoT - internet of things */
/* Wi-Fi */
/* Marvell WiFi */
/* Wiced WiFi */
/* IoT Cloud */
/* security packages */
/* language packages */
/* multimedia packages */
/* tools packages */
/* system packages */
/* peripheral libraries and drivers */
#define PKG_USING_WM_LIBRARIES
#define PKG_USING_WM_LIBRARIES_LATEST_VERSION
/* miscellaneous packages */
/* samples: kernel and components samples */
/* Env config */
#define SYS_PKGS_DOWNLOAD_ACCELERATE
#define BSP_USING_WM_LIBRARIES
/* W60x Device config */
#define SOC_W600_A8xx
/* Hardware Drivers Config */
/* On-chip Peripheral Drivers */
#define BSP_USING_UART
#define BSP_USING_UART0
#define BSP_USING_PIN
#define BSP_USING_WIFI
/* Offboard Peripheral Drivers */
#endif

131
bsp/w60x/rtconfig.py Normal file
View File

@@ -0,0 +1,131 @@
import os
# toolchains options
ARCH='arm'
CPU='cortex-m3'
CROSS_TOOL='gcc'
if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC')
if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
# cross_tool provides the cross compiler
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
EXEC_PATH = 'E:/tool/env/tools/gnu_gcc/arm_gcc/mingw/bin'
elif CROSS_TOOL == 'keil':
PLATFORM = 'armcc'
EXEC_PATH = 'C:/Keil'
elif CROSS_TOOL == 'iar':
PLATFORM = 'iar'
EXEC_PATH = 'C:/Program Files/IAR Systems/Embedded Workbench 6.0 Evaluation'
if os.getenv('RTT_EXEC_PATH'):
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
BUILD = 'debug'
if PLATFORM == 'gcc':
# toolchains
PREFIX = 'arm-none-eabi-'
CC = PREFIX + 'gcc'
AS = PREFIX + 'gcc'
AR = PREFIX + 'ar'
CXX = PREFIX + 'g++'
LINK = PREFIX + 'gcc'
TARGET_EXT = 'elf'
SIZE = PREFIX + 'size'
OBJDUMP = PREFIX + 'objdump'
OBJCPY = PREFIX + 'objcopy'
NM = PREFIX + 'nm'
DEVICE = ' -mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections'
CFLAGS = DEVICE + ' -std=gnu99 -w -fno-common -fomit-frame-pointer -fno-short-enums -fsigned-char'
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb '
LFLAGS = DEVICE + ' -lm -lgcc -lc' + ' -g --specs=nano.specs -nostartfiles -Wl,-Map=rtthread-w60x.map -Os -Wl,--gc-sections -Wl,--cref -Wl,--entry=Reset_Handler -Wl,--no-enum-size-warning -Wl,--no-wchar-size-warning -T ./drivers/linker_scripts/link.lds'
CPATH = ''
LPATH = ''
if BUILD == 'debug':
CFLAGS += ' -O0 -gdwarf-2 -g -Wall'
AFLAGS += ' -gdwarf-2'
else:
CFLAGS += ' -O2'
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
POST_ACTION += 'python ./makeimg.py'
elif PLATFORM == 'armcc':
# toolchains
CC = 'armcc'
AS = 'armasm'
AR = 'armar'
LINK = 'armlink'
TARGET_EXT = 'axf'
DEVICE = ' --cpu=Cortex-M3'
CFLAGS = DEVICE + ' --apcs=interwork --c99 --gnu'
AFLAGS = DEVICE + ' --apcs=interwork '
LFLAGS = DEVICE + ' --scatter "./drivers/linker_scripts/link.sct" --info sizes --info totals --info unused --info veneers --list rt-thread.map --strict'
LFLAGS += ' --libpath=' + EXEC_PATH + '/ARM/ARMCC/lib'
EXEC_PATH += '/ARM/ARMCC/bin/'
if BUILD == 'debug':
CFLAGS += ' -g -O0'
AFLAGS += ' -g'
else:
CFLAGS += ' -O2'
POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET \n'
POST_ACTION += 'python ./makeimg.py'
elif PLATFORM == 'iar':
# toolchains
CC = 'iccarm'
AS = 'iasmarm'
AR = 'iarchive'
LINK = 'ilinkarm'
TARGET_EXT = 'out'
DEVICE = '-Dewarm'
CFLAGS = DEVICE
CFLAGS += ' --diag_suppress Pa050'
CFLAGS += ' --no_cse'
CFLAGS += ' --no_unroll'
CFLAGS += ' --no_inline'
CFLAGS += ' --no_code_motion'
CFLAGS += ' --no_tbaa'
CFLAGS += ' --no_clustering'
CFLAGS += ' --no_scheduling'
CFLAGS += ' --endian=little'
CFLAGS += ' --cpu=Cortex-M3'
CFLAGS += ' -e'
CFLAGS += ' --fpu=None'
CFLAGS += ' --dlib_config "' + EXEC_PATH + '/arm/INC/c/DLib_Config_Normal.h"'
CFLAGS += ' --silent'
AFLAGS = DEVICE
AFLAGS += ' -s+'
AFLAGS += ' -w+'
AFLAGS += ' -r'
AFLAGS += ' --cpu Cortex-M3'
AFLAGS += ' --fpu None'
AFLAGS += ' -S'
if BUILD == 'debug':
CFLAGS += ' --debug'
CFLAGS += ' -On'
else:
CFLAGS += ' -Oh'
LFLAGS = ' --config ./drivers/linker_scripts/link.icf'
LFLAGS += ' --entry __iar_program_start'
EXEC_PATH = EXEC_PATH + '/arm/bin/'
POST_ACTION = 'ielftool --bin $TARGET rtthread.bin \n'
POST_ACTION += 'python ./makeimg.py'

2034
bsp/w60x/template.ewp Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More