[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
View File

@ -0,0 +1,560 @@
/*
* 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
*/
#include <rtthread.h>
#include <rtdevice.h>
#include "wm_io.h"
#include "wm_uart.h"
#include "wm_gpio_afsel.h"
#include "wm_type_def.h"
#include "wm_cpu.h"
#include "drv_uart.h"
#include "pin_map.h"
#define WM600_UART0 (TLS_UART_REGS_T *) HR_UART0_BASE_ADDR
#define WM600_UART1 (TLS_UART_REGS_T *) HR_UART1_BASE_ADDR
#define WM600_UART2 (TLS_UART_REGS_T *) HR_UART2_BASE_ADDR
static void wm_uart_reg_init(TLS_UART_REGS_T *UARTx)
{
RT_ASSERT(UARTx == WM600_UART0 || UARTx == WM600_UART1 || UARTx == WM600_UART2);
if (UARTx == WM600_UART0)
{
/* disable auto flow control */
tls_reg_write32(HR_UART0_FLOW_CTRL, 0);
/* disable dma */
tls_reg_write32(HR_UART0_DMA_CTRL, 0);
/* one byte tx */
tls_reg_write32(HR_UART0_FIFO_CTRL, 0);
/* disable interrupt */
tls_reg_write32(HR_UART0_INT_MASK, 0xFF);
/* enable rx/timeout interrupt */
tls_reg_write32(HR_UART0_INT_MASK, ~(3 << 2));
}
else if (UARTx == WM600_UART1)
{
/* 4 byte tx, 8 bytes rx */
tls_reg_write32(HR_UART1_FIFO_CTRL, (0x01 << 2) | (0x02 << 4));
/* enable rx timeout, disable rx dma, disable tx dma */
tls_reg_write32(HR_UART1_DMA_CTRL, (8 << 3) | (1 << 2));
/* enable rx/timeout interrupt */
tls_reg_write32(HR_UART1_INT_MASK, ~(3 << 2));
}
else if (UARTx == WM600_UART2)
{
/* 4 byte tx, 8 bytes rx */
tls_reg_write32(HR_UART2_FIFO_CTRL, (0x01 << 2) | (0x02 << 4));
/* enable rx timeout, disable rx dma, disable tx dma */
tls_reg_write32(HR_UART2_DMA_CTRL, (8 << 3) | (1 << 2));
/* enable rx/timeout interrupt */
tls_reg_write32(HR_UART2_INT_MASK, ~(3 << 2));
UARTx->UR_LC &= ~(0x1000000);
}
}
static void wm_uart_gpio_config(TLS_UART_REGS_T *UARTx)
{
#if defined(BSP_USING_UART1) || defined(BSP_USING_UART2)
rt_int16_t gpio_pin;
#endif
RT_ASSERT(UARTx == WM600_UART0 || UARTx == WM600_UART1 || UARTx == WM600_UART2);
if (UARTx == WM600_UART0)
{
/* UART0_TX-PA04 UART0_RX-PA05 */
wm_uart0_tx_config(WM_IO_PA_04);
wm_uart0_rx_config(WM_IO_PA_05);
}
#ifdef BSP_USING_UART1
else if (UARTx == WM600_UART1)
{
gpio_pin = wm_get_pin(WM_UART1_RX_PIN);
if (gpio_pin >= 0)
{
wm_uart1_rx_config((enum tls_io_name)gpio_pin);
}
gpio_pin = wm_get_pin(WM_UART1_TX_PIN);
if (gpio_pin >= 0)
{
wm_uart1_tx_config((enum tls_io_name)gpio_pin);
}
}
#endif
#ifdef BSP_USING_UART2
else if (UARTx == WM600_UART2)
{
gpio_pin = wm_get_pin(WM_UART2_RX_PIN);
if (gpio_pin >= 0)
{
wm_uart2_rx_config((enum tls_io_name)gpio_pin);
}
gpio_pin = wm_get_pin(WM_UART2_TX_PIN);
if (gpio_pin >= 0)
{
wm_uart2_tx_scio_config((enum tls_io_name)gpio_pin);
}
}
#endif
}
static void wm_uart_irq_config(TLS_UART_REGS_T *UARTx)
{
RT_ASSERT(UARTx == WM600_UART0 || UARTx == WM600_UART1 || UARTx == WM600_UART2);
/* config uart interrupt register */
/* clear interrupt */
UARTx->UR_INTS = 0xFFFFFFFF;
/* enable interupt */
UARTx->UR_INTM = 0x0;
UARTx->UR_DMAC = (4UL << UDMA_RX_FIFO_TIMEOUT_SHIFT) | UDMA_RX_FIFO_TIMEOUT;
/* config FIFO control */
UARTx->UR_FIFOC = UFC_TX_FIFO_LVL_16_BYTE | UFC_RX_FIFO_LVL_16_BYTE | UFC_TX_FIFO_RESET | UFC_RX_FIFO_RESET;
UARTx->UR_LC &= ~(ULCON_TX_EN | ULCON_RX_EN);
UARTx->UR_LC |= ULCON_TX_EN | ULCON_RX_EN;
}
static int wm_uart_baudrate_set(TLS_UART_REGS_T *UARTx, u32 baudrate)
{
u32 value;
u32 apbclk;
tls_sys_clk sysclk;
RT_ASSERT(UARTx == WM600_UART0 || UARTx == WM600_UART1 || UARTx == WM600_UART2);
tls_sys_clk_get(&sysclk);
apbclk = sysclk.apbclk * 1000000;
value = (apbclk / (16 * baudrate) - 1) |
(((apbclk % (baudrate * 16)) * 16 / (baudrate * 16)) << 16);
UARTx->UR_BD = value;
return WM_SUCCESS;
}
static int wm_uart_parity_set(TLS_UART_REGS_T *UARTx, TLS_UART_PMODE_T paritytype)
{
RT_ASSERT(UARTx == WM600_UART0 || UARTx == WM600_UART1 || UARTx == WM600_UART2);
if (paritytype == TLS_UART_PMODE_DISABLED)
UARTx->UR_LC &= ~ULCON_PMD_EN;
else if (paritytype == TLS_UART_PMODE_EVEN)
{
UARTx->UR_LC &= ~ULCON_PMD_MASK;
UARTx->UR_LC |= ULCON_PMD_EVEN;
}
else if (paritytype == TLS_UART_PMODE_ODD)
{
UARTx->UR_LC &= ~ULCON_PMD_MASK;
UARTx->UR_LC |= ULCON_PMD_ODD;
}
else
return WM_FAILED;
return WM_SUCCESS;
}
static int wm_uart_stopbits_set(TLS_UART_REGS_T *UARTx, TLS_UART_STOPBITS_T stopbits)
{
RT_ASSERT(UARTx == WM600_UART0 || UARTx == WM600_UART1 || UARTx == WM600_UART2);
if (stopbits == TLS_UART_TWO_STOPBITS)
UARTx->UR_LC |= ULCON_STOP_2;
else
UARTx->UR_LC &= ~ULCON_STOP_2;
return WM_SUCCESS;
}
static int wm_uart_databits_set(TLS_UART_REGS_T *UARTx, TLS_UART_CHSIZE_T charlength)
{
RT_ASSERT(UARTx == WM600_UART0 || UARTx == WM600_UART1 || UARTx == WM600_UART2);
UARTx->UR_LC &= ~ULCON_WL_MASK;
if (charlength == TLS_UART_CHSIZE_5BIT)
UARTx->UR_LC |= ULCON_WL5;
else if (charlength == TLS_UART_CHSIZE_6BIT)
UARTx->UR_LC |= ULCON_WL6;
else if (charlength == TLS_UART_CHSIZE_7BIT)
UARTx->UR_LC |= ULCON_WL7;
else if (charlength == TLS_UART_CHSIZE_8BIT)
UARTx->UR_LC |= ULCON_WL8;
else
return WM_FAILED;
return WM_SUCCESS;
}
static int wm_uart_flow_ctrl_set(TLS_UART_REGS_T *UARTx, TLS_UART_FLOW_CTRL_MODE_T flow_ctrl)
{
RT_ASSERT(UARTx == WM600_UART0 || UARTx == WM600_UART1 || UARTx == WM600_UART2);
switch (flow_ctrl)
{
case TLS_UART_FLOW_CTRL_NONE:
UARTx->UR_FC = 0;
break;
case TLS_UART_FLOW_CTRL_HARDWARE:
UARTx->UR_FC = (1UL << 0) | (6UL << 2);
break;
default:
break;
}
return WM_SUCCESS;
}
struct device_uart
{
TLS_UART_REGS_T volatile *uart_device;
rt_uint32_t uart_irq_no;
};
static rt_err_t drv_uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg);
static rt_err_t drv_uart_control(struct rt_serial_device *serial, int cmd, void *arg);
static int drv_uart_putc(struct rt_serial_device *serial, char c);
static int drv_uart_getc(struct rt_serial_device *serial);
static rt_size_t drv_uart_dma_transmit(struct rt_serial_device *serial, rt_uint8_t *buf, rt_size_t size, int direction);
const struct rt_uart_ops _uart_ops =
{
drv_uart_configure,
drv_uart_control,
drv_uart_putc,
drv_uart_getc,
drv_uart_dma_transmit
};
/*
* UART interface
*/
static rt_err_t drv_uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
{
struct device_uart *uart;
u32 baud_rate;
TLS_UART_PMODE_T parity;
TLS_UART_STOPBITS_T stop_bits;
TLS_UART_CHSIZE_T data_bits;
RT_ASSERT(serial != RT_NULL && cfg != RT_NULL);
serial->config = *cfg;
uart = (struct device_uart *)serial->parent.user_data;
RT_ASSERT(uart != RT_NULL);
switch (cfg->baud_rate)
{
case BAUD_RATE_2000000:
case BAUD_RATE_921600:
case BAUD_RATE_460800:
case BAUD_RATE_230400:
case BAUD_RATE_115200:
case BAUD_RATE_57600:
case BAUD_RATE_38400:
case BAUD_RATE_19200:
case BAUD_RATE_9600:
case BAUD_RATE_4800:
case BAUD_RATE_2400:
baud_rate = cfg->baud_rate;
break;
default:
rt_kprintf("baudrate set failed... default rate:115200\r\n");
baud_rate = BAUD_RATE_115200;
break;
}
wm_uart_baudrate_set((TLS_UART_REGS_T *)uart->uart_device, baud_rate);
switch (cfg->parity)
{
case PARITY_ODD:
parity = TLS_UART_PMODE_ODD;
break;
case PARITY_EVEN:
parity = TLS_UART_PMODE_EVEN;
break;
case PARITY_NONE:
default:
parity = TLS_UART_PMODE_DISABLED;
break;
}
wm_uart_parity_set((TLS_UART_REGS_T *)uart->uart_device, parity);
switch (cfg->stop_bits)
{
case STOP_BITS_2:
stop_bits = TLS_UART_TWO_STOPBITS;
break;
case STOP_BITS_1:
default:
stop_bits = TLS_UART_ONE_STOPBITS;
break;
}
wm_uart_stopbits_set((TLS_UART_REGS_T *)uart->uart_device, stop_bits);
switch (cfg->data_bits)
{
case DATA_BITS_5:
data_bits = TLS_UART_CHSIZE_5BIT;
break;
case DATA_BITS_6:
data_bits = TLS_UART_CHSIZE_6BIT;
break;
case DATA_BITS_7:
data_bits = TLS_UART_CHSIZE_7BIT;
break;
case DATA_BITS_8:
default:
data_bits = TLS_UART_CHSIZE_8BIT;
break;
}
wm_uart_databits_set((TLS_UART_REGS_T *)uart->uart_device, data_bits);
wm_uart_flow_ctrl_set((TLS_UART_REGS_T *)uart->uart_device, TLS_UART_FLOW_CTRL_NONE);
return (RT_EOK);
}
static rt_err_t drv_uart_control(struct rt_serial_device *serial, int cmd, void *arg)
{
struct device_uart *uart;
RT_ASSERT(serial != RT_NULL);
uart = (struct device_uart *)serial->parent.user_data;
RT_ASSERT(uart != RT_NULL);
switch (cmd)
{
case RT_DEVICE_CTRL_CLR_INT:
/* Disable the UART Interrupt */
tls_irq_disable(uart->uart_irq_no);
break;
case RT_DEVICE_CTRL_SET_INT:
/* Enable the UART Interrupt */
tls_irq_enable(uart->uart_irq_no);
break;
}
return (RT_EOK);
}
static int drv_uart_putc(struct rt_serial_device *serial, char c)
{
struct device_uart *uart;
RT_ASSERT(serial != RT_NULL);
uart = (struct device_uart *)serial->parent.user_data;
RT_ASSERT(uart != RT_NULL);
while (uart->uart_device->UR_FIFOS & 0x3F); /* wait THR is empty */
uart->uart_device->UR_TXW = (char)c;
return (1);
}
static int drv_uart_getc(struct rt_serial_device *serial)
{
int ch;
struct device_uart *uart;
RT_ASSERT(serial != RT_NULL);
uart = (struct device_uart *)serial->parent.user_data;
RT_ASSERT(uart != RT_NULL);
ch = -1;
if (uart->uart_device->UR_FIFOS & UFS_RX_FIFO_CNT_MASK)
ch = (int)uart->uart_device->UR_RXW;
return ch;
}
static rt_size_t drv_uart_dma_transmit(struct rt_serial_device *serial, rt_uint8_t *buf, rt_size_t size, int direction)
{
return (0);
}
static void drv_uart_irq_handler(struct rt_serial_device *serial)
{
u32 intr_src;
struct device_uart *uart;
RT_ASSERT(serial != RT_NULL);
uart = (struct device_uart *)serial->parent.user_data;
RT_ASSERT(uart != RT_NULL);
/* check interrupt status */
intr_src = uart->uart_device->UR_INTS;
uart->uart_device->UR_INTS = intr_src;
if ((intr_src & UART_RX_INT_FLAG) && (0 == (uart->uart_device->UR_INTM & UIS_RX_FIFO)))
{
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
}
if (intr_src & UART_TX_INT_FLAG)
{
}
if (intr_src & UIS_CTS_CHNG)
{
}
}
#ifdef BSP_USING_UART0
static struct rt_serial_device serial0;
static struct device_uart uart0 =
{
WM600_UART0,
UART0_INT,
};
void UART0_IRQHandler(void)
{
/* enter interrupt */
rt_interrupt_enter();
drv_uart_irq_handler(&serial0);
/* leave interrupt */
rt_interrupt_leave();
}
#endif
#ifdef BSP_USING_UART1
static struct rt_serial_device serial1;
static struct device_uart uart1 =
{
WM600_UART1,
UART1_INT,
};
void UART1_IRQHandler(void)
{
/* enter interrupt */
rt_interrupt_enter();
drv_uart_irq_handler(&serial1);
/* leave interrupt */
rt_interrupt_leave();
}
#endif
#ifdef BSP_USING_UART2
static struct rt_serial_device serial2;
static struct device_uart uart2 =
{
WM600_UART2,
UART2_INT,
};
void UART2_IRQHandler(void)
{
/* enter interrupt */
rt_interrupt_enter();
drv_uart_irq_handler(&serial2);
/* leave interrupt */
rt_interrupt_leave();
}
#endif
/*
* UART Initiation
*/
int wm_hw_uart_init(void)
{
struct rt_serial_device *serial;
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
struct device_uart *uart;
#ifdef BSP_USING_UART0
{
serial = &serial0;
uart = &uart0;
/* Init UART Hardware */
wm_uart_gpio_config((TLS_UART_REGS_T *)uart->uart_device);
wm_uart_reg_init((TLS_UART_REGS_T *)uart->uart_device);
wm_uart_irq_config((TLS_UART_REGS_T *)uart->uart_device);
serial->ops = &_uart_ops;
serial->config = config;
serial->config.baud_rate = 115200;
rt_hw_serial_register(serial,
"uart0",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart);
}
#endif /* BSP_USING_UART0 */
#ifdef BSP_USING_UART1
{
serial = &serial1;
uart = &uart1;
/* Init UART Hardware */
wm_uart_gpio_config((TLS_UART_REGS_T *)uart->uart_device);
wm_uart_reg_init((TLS_UART_REGS_T *)uart->uart_device);
wm_uart_irq_config((TLS_UART_REGS_T *)uart->uart_device);
serial->ops = &_uart_ops;
serial->config = config;
serial->config.baud_rate = WM_UART1_BAUDRATE;
rt_hw_serial_register(serial,
"uart1",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart);
}
#endif /* BSP_USING_UART1 */
#ifdef BSP_USING_UART2
{
serial = &serial2;
uart = &uart2;
/* Init UART Hardware */
wm_uart_gpio_config((TLS_UART_REGS_T *)uart->uart_device);
wm_uart_reg_init((TLS_UART_REGS_T *)uart->uart_device);
wm_uart_irq_config((TLS_UART_REGS_T *)uart->uart_device);
serial->ops = &_uart_ops;
serial->config = config;
serial->config.baud_rate = WM_UART2_BAUDRATE;
rt_hw_serial_register(serial,
"uart2",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart);
}
#endif /* BSP_USING_UART2 */
return 0;
}
INIT_BOARD_EXPORT(wm_hw_uart_init);

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
View File

@ -0,0 +1,630 @@
/*
* 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
*/
#include <rtthread.h>
#include <wlan_dev.h>
#include "wm_type_def.h"
#include "wm_wifi.h"
#include "drv_wifi.h"
#define DBG_ENABLE
#define DBG_LEVEL DBG_INFO
#define DBG_SECTION_NAME "WIFI"
#define DBG_COLOR
#include <rtdbg.h>
#include "wm_ram_config.h"
#include "wm_efuse.h"
#include "wm_params.h"
#include "wm_debug.h"
#include "tls_ieee80211.h"
//#define ETH_RX_DUMP
//#define ETH_TX_DUMP
//#define MINI_DUMP
#define MAX_ADDR_LEN (6)
struct drv_wifi
{
struct rt_wlan_device *wlan;
rt_uint8_t dev_addr[MAX_ADDR_LEN];
};
static const struct rt_wlan_dev_ops ops;
static struct drv_wifi wifi_sta;
static struct drv_wifi wifi_ap;
extern int hed_rf_current_channel;
extern u8 *wpa_supplicant_get_mac(void);
extern u8 *hostapd_get_mac(void);
extern uint8_t* tls_wifi_buffer_acquire(int total_len);
extern void *tls_wl_init(u8 *tx_gain, u8* mac_addr, u8 *hwver);
extern int wpa_supplicant_init(u8 *mac_addr);
extern void wpa_supplicant_set_mac(u8 *mac);
extern void tls_wifi_buffer_release(rt_bool_t is_apsta, rt_uint8_t* buffer);
#if defined(ETH_RX_DUMP) || defined(ETH_TX_DUMP)
static void packet_dump(const char *msg, const void *ptr, rt_uint32_t len)
{
rt_uint32_t j;
rt_uint8_t *p = (rt_uint8_t *)ptr;
rt_kprintf("%s %d byte\n", msg, len);
#ifdef MINI_DUMP
return;
#endif
for (j = 0; j < len; j++)
{
if ((j % 8) == 0)
{
rt_kprintf(" ");
}
if ((j % 16) == 0)
{
rt_kprintf("\r\n");
}
rt_kprintf("%02x ", *p ++);
}
rt_kprintf("\n\n");
}
#endif /* dump */
err_t tls_netif_set_addr(void *ipaddr, void *netmask, void *gw)
{
LOG_D("%s %d\r\n", __FUNCTION__, __LINE__);
return 0;
}
static int wm_ethernetif_input(const rt_uint8_t *bssid, rt_uint8_t *buf, rt_uint32_t buf_len)
{
rt_err_t err = -RT_ERROR;
if (0 == compare_ether_addr(bssid, wifi_ap.dev_addr))
err = rt_wlan_dev_report_data(wifi_ap.wlan, (void *)buf, buf_len);
else
err = rt_wlan_dev_report_data(wifi_sta.wlan, (void *)buf, buf_len);
return err ? -1 : 0;
}
static void wm_wlan_client_event(u8 *mac, enum tls_wifi_client_event_type event)
{
struct rt_wlan_buff buff;
struct rt_wlan_info sta;
rt_memcpy(sta.bssid, mac, MAX_ADDR_LEN);
buff.data = &sta;
buff.len = sizeof(sta);
if (WM_WIFI_CLIENT_EVENT_ONLINE == event)
{
rt_wlan_dev_indicate_event_handle(wifi_ap.wlan, RT_WLAN_DEV_EVT_AP_ASSOCIATED, &buff);
}
else
{
rt_wlan_dev_indicate_event_handle(wifi_ap.wlan, RT_WLAN_DEV_EVT_AP_DISASSOCIATED, &buff);
}
}
static void wm_wlan_status_changed(rt_uint8_t status)
{
LOG_D("status:%d", status);
switch (status)
{
case WIFI_JOIN_SUCCESS:
LOG_D("NETIF_WIFI_JOIN_SUCCESS");
rt_wlan_dev_indicate_event_handle(wifi_sta.wlan, RT_WLAN_DEV_EVT_CONNECT, RT_NULL);
break;
case WIFI_JOIN_FAILED:
LOG_D("NETIF_WIFI_JOIN_FAILED");
rt_wlan_dev_indicate_event_handle(wifi_sta.wlan, RT_WLAN_DEV_EVT_CONNECT_FAIL, RT_NULL);
break;
case WIFI_DISCONNECTED:
LOG_D("NETIF_WIFI_DISCONNECTED");
rt_wlan_dev_indicate_event_handle(wifi_sta.wlan, RT_WLAN_DEV_EVT_DISCONNECT, RT_NULL);
break;
case WIFI_SOFTAP_SUCCESS:
LOG_D("WIFI_SOFTAP_SUCCESS");
rt_wlan_dev_indicate_event_handle(wifi_ap.wlan, RT_WLAN_DEV_EVT_AP_START, RT_NULL);
break;
case WIFI_SOFTAP_CLOSED:
LOG_D("WIFI_SOFTAP_CLOSED");
rt_wlan_dev_indicate_event_handle(wifi_ap.wlan, RT_WLAN_DEV_EVT_AP_STOP, RT_NULL);
break;
default:
break;
}
}
static rt_err_t wm_wlan_init(void)
{
extern rt_uint8_t tx_gain_group[];
rt_uint8_t mac_addr[6] = {0x00, 0x25, 0x08, 0x09, 0x01, 0x0F};
/*PARAM GAIN,MAC default*/
tls_ft_param_init();
tls_param_load_factory_default();
tls_param_init(); /*add param to init sysparam_lock sem*/
tls_get_tx_gain(&tx_gain_group[0]);
TLS_DBGPRT_INFO("tx gain ");
TLS_DBGPRT_DUMP((char *)(&tx_gain_group[0]), 12);
if (tls_wifi_mem_cfg(WIFI_MEM_START_ADDR, 7, 7)) /*wifi tx&rx mem customized interface*/
{
LOG_E("wl mem initial failured\n");
}
tls_get_mac_addr(&mac_addr[0]);
TLS_DBGPRT_INFO("mac addr ");
TLS_DBGPRT_DUMP((char *)(&mac_addr[0]), 6);
if (tls_wl_init(NULL, &mac_addr[0], NULL) == NULL)
{
LOG_I("wl driver initial failured\n");
}
if (wpa_supplicant_init(mac_addr))
{
LOG_I("supplicant initial failured\n");
}
rt_memcpy(wifi_sta.dev_addr, wpa_supplicant_get_mac(), MAX_ADDR_LEN);
LOG_D("sta_mac:%02x-%02x-%02x-%02x-%02x-%02x\r\n", wifi_sta.dev_addr[0], wifi_sta.dev_addr[1], wifi_sta.dev_addr[2], wifi_sta.dev_addr[3], wifi_sta.dev_addr[4], wifi_sta.dev_addr[5]);
rt_memcpy(wifi_ap.dev_addr, hostapd_get_mac(), MAX_ADDR_LEN);
LOG_D("ap_mac:%02x-%02x-%02x-%02x-%02x-%02x\r\n", wifi_ap.dev_addr[0], wifi_ap.dev_addr[1], wifi_ap.dev_addr[2], wifi_ap.dev_addr[3], wifi_ap.dev_addr[4], wifi_ap.dev_addr[5]);
return RT_EOK;
}
static void wm_wlan_promisc_dataframe_callback(u8 *data, u32 data_len)
{
rt_wlan_dev_promisc_handler(wifi_sta.wlan, data, data_len);
}
static rt_err_t drv_wlan_init(struct rt_wlan_device *wlan)
{
static int inited = 0;
if (inited)
return RT_EOK;
wm_wlan_init();
tls_ethernet_data_rx_callback(wm_ethernetif_input);
tls_wifi_status_change_cb_register(wm_wlan_status_changed);
tls_wifi_softap_client_event_register(wm_wlan_client_event);
inited = 1;
return RT_EOK;
}
static rt_err_t drv_wlan_mode(struct rt_wlan_device *wlan, rt_wlan_mode_t mode)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
u8 wmode = IEEE80211_MODE_INFRA;
if (mode == RT_WLAN_AP)
wmode = IEEE80211_MODE_AP;
tls_param_set(TLS_PARAM_ID_WPROTOCOL, (void *)&wmode, TRUE);
return RT_EOK;
}
static void wm_wlan_scan_callback(void)
{
int buflen = 2000;
char *buf = RT_NULL;
int err;
struct rt_wlan_info wlan_info;
struct rt_wlan_buff buff;
buf = rt_malloc(buflen);
if (RT_NULL == buf)
{
LOG_E("rt_malloc failed...\r\n");
return;
}
err = tls_wifi_get_scan_rslt((u8 *)buf, buflen);
if (err != WM_SUCCESS)
{
rt_free(buf);
return;
}
struct tls_scan_bss_t *scan_res = (struct tls_scan_bss_t *)buf;
struct tls_bss_info_t *bss_info = (struct tls_bss_info_t *)scan_res->bss;
if (scan_res->count <= 0)
{
rt_free(buf);
return;
}
int i;
for (i = 0; i < scan_res->count; i ++)
{
rt_memset(&wlan_info, 0, sizeof(wlan_info));
rt_memcpy(&wlan_info.bssid[0], bss_info->bssid, 6);
rt_memcpy(wlan_info.ssid.val, bss_info->ssid, bss_info->ssid_len);
wlan_info.ssid.len = bss_info->ssid_len;
if (bss_info->ssid_len)
wlan_info.hidden = 0;
else
wlan_info.hidden = 1;
wlan_info.channel = (rt_int16_t)bss_info->channel;
wlan_info.rssi = -(char)(0x100 - bss_info->rssi);
wlan_info.datarate = bss_info->max_data_rate * 1000000;
wlan_info.band = RT_802_11_BAND_2_4GHZ;
wlan_info.security = SECURITY_OPEN;
if (WM_WIFI_AUTH_MODE_WEP_AUTO & bss_info->privacy)
wlan_info.security |= WEP_ENABLED;
if (WM_WIFI_AUTH_MODE_WPA_PSK_TKIP & bss_info->privacy)
wlan_info.security |= WPA_SECURITY | TKIP_ENABLED;
if (WM_WIFI_AUTH_MODE_WPA_PSK_CCMP & bss_info->privacy)
wlan_info.security |= WPA_SECURITY | AES_ENABLED;
if (WM_WIFI_AUTH_MODE_WPA2_PSK_CCMP & bss_info->privacy)
wlan_info.security |= WPA2_SECURITY | AES_ENABLED;
if (WM_WIFI_AUTH_MODE_WPA2_PSK_TKIP & bss_info->privacy)
wlan_info.security |= WPA2_SECURITY | TKIP_ENABLED;
if (bss_info->wps_support)
wlan_info.security |= WPS_ENABLED;
if (WM_WIFI_AUTH_MODE_UNKNOWN == bss_info->privacy)
wlan_info.security = SECURITY_UNKNOWN;
/* rtt incompleted... */
if (wlan_info.security & SECURITY_WPA2_MIXED_PSK)
wlan_info.security = SECURITY_WPA2_MIXED_PSK;
else if (wlan_info.security & SECURITY_WPA2_TKIP_PSK)
wlan_info.security = SECURITY_WPA2_TKIP_PSK;
else if (wlan_info.security & SECURITY_WPA2_AES_PSK)
wlan_info.security = SECURITY_WPA2_AES_PSK;
else if (wlan_info.security & SECURITY_WPA_AES_PSK)
wlan_info.security = SECURITY_WPA_AES_PSK;
else if (wlan_info.security & SECURITY_WPA_TKIP_PSK)
wlan_info.security = SECURITY_WPA_TKIP_PSK;
else if (wlan_info.security & SECURITY_WEP_PSK)
wlan_info.security = SECURITY_WEP_PSK;
else if ((SECURITY_UNKNOWN == wlan_info.security) && bss_info->wps_support)
wlan_info.security = SECURITY_WPS_SECURE;
LOG_D("%s-%x", wlan_info.ssid.val, wlan_info.security);
bss_info ++;
buff.data = &wlan_info;
buff.len = sizeof(wlan_info);
rt_wlan_dev_indicate_event_handle(wifi_sta.wlan, RT_WLAN_DEV_EVT_SCAN_REPORT, &buff);
}
rt_free(buf);
rt_wlan_dev_indicate_event_handle(wifi_sta.wlan, RT_WLAN_DEV_EVT_SCAN_DONE, RT_NULL);
}
static rt_err_t drv_wlan_scan(struct rt_wlan_device *wlan, struct rt_scan_info *scan_info)
{
int ret;
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
/* register scan complt callback*/
tls_wifi_scan_result_cb_register(wm_wlan_scan_callback);
/* trigger the scan */
ret = tls_wifi_scan();
if ((ret == WM_WIFI_SCANNING_BUSY) || (ret == WM_FAILED))
return -RT_ERROR;
return RT_EOK;
}
static rt_err_t drv_wlan_join(struct rt_wlan_device *wlan, struct rt_sta_info *sta_info)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
tls_wifi_disconnect();
tls_wifi_connect((u8 *)sta_info->ssid.val, sta_info->ssid.len, (u8 *)sta_info->key.val, sta_info->key.len);
return RT_EOK;
}
static rt_err_t drv_wlan_softap(struct rt_wlan_device *wlan, struct rt_ap_info *ap_info)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
struct tls_softap_info_t apinfo;
struct tls_ip_info_t ipinfo;
rt_memset(&apinfo, 0, sizeof(apinfo));
rt_memcpy(apinfo.ssid, ap_info->ssid.val, ap_info->ssid.len);
apinfo.channel = ap_info->channel;
switch (ap_info->security) /* only support wpa2-psk and open */
{
case SECURITY_WEP_PSK:
apinfo.encrypt = IEEE80211_ENCRYT_WEP40;
break;
case SECURITY_WPA_TKIP_PSK:
apinfo.encrypt = IEEE80211_ENCRYT_TKIP_WPA;
break;
case SECURITY_WPA_AES_PSK:
apinfo.encrypt = IEEE80211_ENCRYT_CCMP_WPA;
break;
case SECURITY_WPA2_TKIP_PSK:
apinfo.encrypt = IEEE80211_ENCRYT_TKIP_WPA2;
break;
case SECURITY_WPA2_AES_PSK:
case SECURITY_WPA2_MIXED_PSK:
apinfo.encrypt = IEEE80211_ENCRYT_CCMP_WPA2;
break;
default:
apinfo.encrypt = IEEE80211_ENCRYT_NONE;
break;
}
apinfo.keyinfo.format = 1; /* ascii */
apinfo.keyinfo.index = 1; /* index */
apinfo.keyinfo.key_len = ap_info->key.len;
rt_memcpy(apinfo.keyinfo.key, ap_info->key.val, ap_info->key.len);
LOG_D("ch=%d, hd=%d, key=%s, sec=%x, ssid=%s", ap_info->channel, ap_info->hidden, ap_info->key.val, ap_info->security, ap_info->ssid.val);
rt_memset(&ipinfo, 0, sizeof(ipinfo));
ipinfo.ip_addr[0] = 192;
ipinfo.ip_addr[1] = 168;
ipinfo.ip_addr[2] = 48;
ipinfo.ip_addr[3] = 1;
ipinfo.netmask[0] = 255;
ipinfo.netmask[1] = 255;
ipinfo.netmask[2] = 255;
ipinfo.netmask[3] = 0;
u8 ssid_set = ap_info->hidden ? 0 : 1;
tls_param_set(TLS_PARAM_ID_BRDSSID, (void *)&ssid_set, FALSE);
rt_memcpy(ipinfo.dnsname, "local.w60x", sizeof("local.w60x"));
int ret = tls_wifi_softap_create(&apinfo, &ipinfo);
return (ret == WM_SUCCESS) ? RT_EOK : RT_ERROR;
}
static rt_err_t drv_wlan_disconnect(struct rt_wlan_device *wlan)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
tls_wifi_disconnect();
return RT_EOK;
}
static rt_err_t drv_wlan_ap_stop(struct rt_wlan_device *wlan)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
tls_wifi_softap_destroy();
return RT_EOK;
}
static rt_err_t drv_wlan_ap_deauth(struct rt_wlan_device *wlan, rt_uint8_t mac[])
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
struct tls_wifi_hdr_mac_t machdr;
struct tls_wifi_tx_rate_t tx;
rt_memset(&machdr, 0, sizeof(machdr));
rt_memcpy(machdr.da_addr, mac, MAX_ADDR_LEN);
rt_memcpy(machdr.sa_addr, hostapd_get_mac(), MAX_ADDR_LEN);
rt_memcpy(machdr.bssid, hostapd_get_mac(), MAX_ADDR_LEN);
rt_memset(&tx, 0, sizeof(tx));
tx.tx_rate = WM_WIFI_TX_RATEIDX_1M;
tx.tx_gain = tls_wifi_get_tx_gain_max(WM_WIFI_TX_RATEIDX_1M);
unsigned short reason = WLAN_REASON_UNSPECIFIED;/* htons */
int ret = tls_wifi_send_mgmt(WM_WIFI_MGMT_TYPE_DEAUTH, &machdr, (u8 *)&reason, sizeof(reason), &tx);
return (0 == ret) ? RT_EOK : RT_ERROR;
}
static rt_err_t drv_wlan_scan_stop(struct rt_wlan_device *wlan)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
return RT_EOK;
}
static int drv_wlan_get_rssi(struct rt_wlan_device *wlan)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
struct tls_curr_bss_t bss;
rt_memset(&bss, 0, sizeof(bss));
tls_wifi_get_current_bss(&bss);
return -bss.rssi - 1;
}
static rt_err_t drv_wlan_set_powersave(struct rt_wlan_device *wlan, int level)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
tls_wifi_set_psflag(level ? TRUE : FALSE, FALSE);
return RT_EOK;
}
static int drv_wlan_get_powersave(struct rt_wlan_device *wlan)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
return tls_wifi_get_psflag();
}
static rt_err_t drv_wlan_cfg_promisc(struct rt_wlan_device *wlan, rt_bool_t start)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
if (RT_TRUE == start)
{
tls_wifi_set_listen_mode(1);
tls_wifi_data_recv_cb_register(wm_wlan_promisc_dataframe_callback);
}
else
{
tls_wifi_set_listen_mode(0);
tls_wifi_data_recv_cb_register(RT_NULL);
}
return RT_EOK;
}
static rt_err_t drv_wlan_cfg_filter(struct rt_wlan_device *wlan, struct rt_wlan_filter *filter)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
return RT_EINVAL;/* not support */
}
static rt_err_t drv_wlan_set_channel(struct rt_wlan_device *wlan, int channel)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
tls_wifi_change_chanel(channel - 1);
return RT_EOK;
}
static int drv_wlan_get_channel(struct rt_wlan_device *wlan)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
return hed_rf_current_channel;
}
static rt_err_t drv_wlan_set_country(struct rt_wlan_device *wlan, rt_country_code_t country_code)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
u8 region = (u8)country_code;
tls_param_set(TLS_PARAM_ID_COUNTRY_REGION, (void *)&region, TRUE);
return RT_EOK;
}
static rt_country_code_t drv_wlan_get_country(struct rt_wlan_device *wlan)
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
u8 region = RT_COUNTRY_CHINA;
tls_param_get(TLS_PARAM_ID_COUNTRY_REGION, (void *)&region, FALSE);
return (rt_country_code_t)region; //RT_EOK;
}
static rt_err_t drv_wlan_set_mac(struct rt_wlan_device *wlan, rt_uint8_t mac[])
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
if (wlan->user_data == &wifi_sta) /* ap don't support */
{
wpa_supplicant_set_mac(mac);
tls_set_mac_addr(mac);
}
return RT_EOK;
}
static rt_err_t drv_wlan_get_mac(struct rt_wlan_device *wlan, rt_uint8_t mac[])
{
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
if (wlan->user_data == &wifi_sta)
rt_memcpy(mac, wpa_supplicant_get_mac(), MAX_ADDR_LEN);
else
rt_memcpy(mac, hostapd_get_mac(), MAX_ADDR_LEN);
return RT_EOK;
}
static int drv_wlan_recv(struct rt_wlan_device *wlan, void *buff, int len)
{
return RT_EOK;
}
static int drv_wlan_send(struct rt_wlan_device *wlan, void *buff, int len)
{
rt_uint8_t *dst = tls_wifi_buffer_acquire(len);
if (dst == NULL)
return -RT_ENOMEM;
#if ETH_PAD_SIZE
pbuf_header(p, -ETH_PAD_SIZE); /* Drop the padding word */
#endif
#if defined(ETH_TX_DUMP)
packet_dump("Tx", buff, len);
#endif
rt_memcpy(dst, buff, len);
#if TLS_CONFIG_AP
if (netif != tls_get_netif())
tls_wifi_buffer_release(true, dst);
else
#endif
tls_wifi_buffer_release(false, dst);
#if ETH_PAD_SIZE
pbuf_header(p, ETH_PAD_SIZE); /* Reclaim the padding word */
#endif
return RT_EOK;
}
static const struct rt_wlan_dev_ops ops =
{
.wlan_init = drv_wlan_init,
.wlan_mode = drv_wlan_mode,
.wlan_scan = drv_wlan_scan,
.wlan_join = drv_wlan_join,
.wlan_softap = drv_wlan_softap,
.wlan_disconnect = drv_wlan_disconnect,
.wlan_ap_stop = drv_wlan_ap_stop,
.wlan_ap_deauth = drv_wlan_ap_deauth,
.wlan_scan_stop = drv_wlan_scan_stop,
.wlan_get_rssi = drv_wlan_get_rssi,
.wlan_set_powersave = drv_wlan_set_powersave,
.wlan_get_powersave = drv_wlan_get_powersave,
.wlan_cfg_promisc = drv_wlan_cfg_promisc,
.wlan_cfg_filter = drv_wlan_cfg_filter,
.wlan_set_channel = drv_wlan_set_channel,
.wlan_get_channel = drv_wlan_get_channel,
.wlan_set_country = drv_wlan_set_country,
.wlan_get_country = drv_wlan_get_country,
.wlan_set_mac = drv_wlan_set_mac,
.wlan_get_mac = drv_wlan_get_mac,
.wlan_recv = drv_wlan_recv,
.wlan_send = drv_wlan_send,
};
int wm_hw_wifi_init(void)
{
static struct rt_wlan_device wlan;
static struct rt_wlan_device wlan2;
LOG_D("F:%s L:%d", __FUNCTION__, __LINE__);
rt_memset(&wifi_sta, 0, sizeof(wifi_sta));
rt_err_t ret = rt_wlan_dev_register(&wlan, RT_WLAN_DEVICE_STA_NAME, &ops, 0, &wifi_sta);
wifi_sta.wlan = &wlan;
rt_memset(&wifi_ap, 0, sizeof(wifi_ap));
ret |= rt_wlan_dev_register(&wlan2, RT_WLAN_DEVICE_AP_NAME, &ops, 0, &wifi_ap);
wifi_ap.wlan = &wlan2;
return ret; //RT_EOK;
}
INIT_DEVICE_EXPORT(wm_hw_wifi_init);

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

177
bsp/w60x/template.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>

390
bsp/w60x/template.uvprojx Normal file
View File

@ -0,0 +1,390 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
<SchemaVersion>2.1</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<Targets>
<Target>
<TargetName>rt-thread</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>ARMCM3</Device>
<Vendor>ARM</Vendor>
<PackID>ARM.CMSIS.5.4.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000,0x00020000) IROM(0x00000000,0x00040000) CPUTYPE("Cortex-M3") CLOCK(12000000) ESEL ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile>
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000)</FlashDriverDll>
<DeviceId>0</DeviceId>
<RegisterFile>$$Device:ARMCM3$Device\ARM\ARMCM3\Include\ARMCM3.h</RegisterFile>
<MemoryEnv></MemoryEnv>
<Cmp></Cmp>
<Asm></Asm>
<Linker></Linker>
<OHString></OHString>
<InfinionOptionDll></InfinionOptionDll>
<SLE66CMisc></SLE66CMisc>
<SLE66AMisc></SLE66AMisc>
<SLE66LinkerMisc></SLE66LinkerMisc>
<SFDFile>$$Device:ARMCM3$Device\ARM\SVD\ARMCM3.svd</SFDFile>
<bCustSvd>0</bCustSvd>
<UseEnv>0</UseEnv>
<BinPath></BinPath>
<IncludePath></IncludePath>
<LibPath></LibPath>
<RegisterFilePath></RegisterFilePath>
<DBRegisterFilePath></DBRegisterFilePath>
<TargetStatus>
<Error>0</Error>
<ExitCodeStop>0</ExitCodeStop>
<ButtonStop>0</ButtonStop>
<NotGenerated>0</NotGenerated>
<InvalidFlash>1</InvalidFlash>
</TargetStatus>
<OutputDirectory>.\build\keil\Obj\</OutputDirectory>
<OutputName>rtthread-w60x</OutputName>
<CreateExecutable>1</CreateExecutable>
<CreateLib>0</CreateLib>
<CreateHexFile>0</CreateHexFile>
<DebugInformation>1</DebugInformation>
<BrowseInformation>1</BrowseInformation>
<ListingPath>.\build\keil\List\</ListingPath>
<HexFormatSelection>1</HexFormatSelection>
<Merge32K>0</Merge32K>
<CreateBatchFile>0</CreateBatchFile>
<BeforeCompile>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopU1X>0</nStopU1X>
<nStopU2X>0</nStopU2X>
</BeforeCompile>
<BeforeMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopB1X>0</nStopB1X>
<nStopB2X>0</nStopB2X>
</BeforeMake>
<AfterMake>
<RunUserProg1>1</RunUserProg1>
<RunUserProg2>1</RunUserProg2>
<UserProg1Name>fromelf --bin !L --output rtthread.bin</UserProg1Name>
<UserProg2Name>.\makeimg.bat</UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopA1X>0</nStopA1X>
<nStopA2X>0</nStopA2X>
</AfterMake>
<SelectedForBatchBuild>0</SelectedForBatchBuild>
<SVCSIdString></SVCSIdString>
</TargetCommonOption>
<CommonProperty>
<UseCPPCompiler>0</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>1</IncludeInBuild>
<AlwaysBuild>0</AlwaysBuild>
<GenerateAssemblyFile>0</GenerateAssemblyFile>
<AssembleAssemblyFile>0</AssembleAssemblyFile>
<PublicsOnly>0</PublicsOnly>
<StopOnExitCode>3</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<DllOption>
<SimDllName>SARMCM3.DLL</SimDllName>
<SimDllArguments> -MPU</SimDllArguments>
<SimDlgDll>DCM.DLL</SimDlgDll>
<SimDlgDllArguments>-pCM3</SimDlgDllArguments>
<TargetDllName>SARMCM3.DLL</TargetDllName>
<TargetDllArguments> -MPU</TargetDllArguments>
<TargetDlgDll>TCM.DLL</TargetDlgDll>
<TargetDlgDllArguments>-pCM3</TargetDlgDllArguments>
</DllOption>
<DebugOption>
<OPTHX>
<HexSelection>1</HexSelection>
<HexRangeLowAddress>0</HexRangeLowAddress>
<HexRangeHighAddress>0</HexRangeHighAddress>
<HexOffset>0</HexOffset>
<Oh166RecLen>16</Oh166RecLen>
</OPTHX>
</DebugOption>
<Utilities>
<Flash1>
<UseTargetDll>1</UseTargetDll>
<UseExternalTool>0</UseExternalTool>
<RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
<Capability>1</Capability>
<DriverSelection>4100</DriverSelection>
</Flash1>
<bUseTDR>0</bUseTDR>
<Flash2>Segger\JL2CM3.dll</Flash2>
<Flash3>"" ()</Flash3>
<Flash4></Flash4>
<pFcarmOut></pFcarmOut>
<pFcarmGrp></pFcarmGrp>
<pFcArmRoot></pFcArmRoot>
<FcArmLst>0</FcArmLst>
</Utilities>
<TargetArmAds>
<ArmAdsMisc>
<GenerateListings>0</GenerateListings>
<asHll>1</asHll>
<asAsm>1</asAsm>
<asMacX>1</asMacX>
<asSyms>1</asSyms>
<asFals>1</asFals>
<asDbgD>1</asDbgD>
<asForm>1</asForm>
<ldLst>0</ldLst>
<ldmm>1</ldmm>
<ldXref>1</ldXref>
<BigEnd>0</BigEnd>
<AdsALst>1</AdsALst>
<AdsACrf>1</AdsACrf>
<AdsANop>0</AdsANop>
<AdsANot>0</AdsANot>
<AdsLLst>1</AdsLLst>
<AdsLmap>1</AdsLmap>
<AdsLcgr>1</AdsLcgr>
<AdsLsym>1</AdsLsym>
<AdsLszi>1</AdsLszi>
<AdsLtoi>1</AdsLtoi>
<AdsLsun>1</AdsLsun>
<AdsLven>1</AdsLven>
<AdsLsxf>1</AdsLsxf>
<RvctClst>0</RvctClst>
<GenPPlst>0</GenPPlst>
<AdsCpuType>"Cortex-M3"</AdsCpuType>
<RvctDeviceName></RvctDeviceName>
<mOS>0</mOS>
<uocRom>0</uocRom>
<uocRam>0</uocRam>
<hadIROM>1</hadIROM>
<hadIRAM>1</hadIRAM>
<hadXRAM>0</hadXRAM>
<uocXRam>0</uocXRam>
<RvdsVP>0</RvdsVP>
<RvdsMve>0</RvdsMve>
<hadIRAM2>0</hadIRAM2>
<hadIROM2>0</hadIROM2>
<StupSel>8</StupSel>
<useUlib>0</useUlib>
<EndSel>1</EndSel>
<uLtcg>0</uLtcg>
<nSecure>0</nSecure>
<RoSelD>3</RoSelD>
<RwSelD>3</RwSelD>
<CodeSel>0</CodeSel>
<OptFeed>0</OptFeed>
<NoZi1>0</NoZi1>
<NoZi2>0</NoZi2>
<NoZi3>0</NoZi3>
<NoZi4>0</NoZi4>
<NoZi5>0</NoZi5>
<Ro1Chk>0</Ro1Chk>
<Ro2Chk>0</Ro2Chk>
<Ro3Chk>0</Ro3Chk>
<Ir1Chk>1</Ir1Chk>
<Ir2Chk>0</Ir2Chk>
<Ra1Chk>0</Ra1Chk>
<Ra2Chk>0</Ra2Chk>
<Ra3Chk>0</Ra3Chk>
<Im1Chk>1</Im1Chk>
<Im2Chk>0</Im2Chk>
<OnChipMemories>
<Ocm1>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm1>
<Ocm2>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm2>
<Ocm3>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm3>
<Ocm4>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm4>
<Ocm5>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm5>
<Ocm6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm6>
<IRAM>
<Type>0</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x20000</Size>
</IRAM>
<IROM>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x40000</Size>
</IROM>
<XRAM>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</XRAM>
<OCR_RVCT1>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT1>
<OCR_RVCT2>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT2>
<OCR_RVCT3>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT3>
<OCR_RVCT4>
<Type>1</Type>
<StartAddress>0x8010100</StartAddress>
<Size>0xefeff</Size>
</OCR_RVCT4>
<OCR_RVCT5>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT5>
<OCR_RVCT6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT6>
<OCR_RVCT7>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT7>
<OCR_RVCT8>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT8>
<OCR_RVCT9>
<Type>0</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x3c000</Size>
</OCR_RVCT9>
<OCR_RVCT10>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT10>
</OnChipMemories>
<RvctStartVector></RvctStartVector>
</ArmAdsMisc>
<Cads>
<interw>1</interw>
<Optim>1</Optim>
<oTime>0</oTime>
<SplitLS>0</SplitLS>
<OneElfS>0</OneElfS>
<Strict>0</Strict>
<EnumInt>0</EnumInt>
<PlainCh>0</PlainCh>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<wLevel>0</wLevel>
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<uC99>1</uC99>
<uGnu>0</uGnu>
<useXO>0</useXO>
<v6Lang>1</v6Lang>
<v6LangP>1</v6LangP>
<vShortEn>1</vShortEn>
<vShortWch>1</vShortWch>
<v6Lto>0</v6Lto>
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls>--c99 --gnu</MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
<Aads>
<interw>1</interw>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<thumb>0</thumb>
<SplitLS>0</SplitLS>
<SwStkChk>0</SwStkChk>
<NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc>
<useXO>0</useXO>
<uClangAs>0</uClangAs>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Aads>
<LDads>
<umfTarg>1</umfTarg>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<noStLib>0</noStLib>
<RepFail>1</RepFail>
<useFile>0</useFile>
<TextAddressRange>0x08000000</TextAddressRange>
<DataAddressRange>0x20000000</DataAddressRange>
<pXoBase></pXoBase>
<ScatterFile></ScatterFile>
<IncludeLibs></IncludeLibs>
<IncludeLibsPath></IncludeLibsPath>
<Misc></Misc>
<LinkerInputFile></LinkerInputFile>
<DisabledWarnings></DisabledWarnings>
</LDads>
</TargetArmAds>
</TargetOption>
</Target>
</Targets>
<RTE>
<apis/>
<components/>
<files/>
</RTE>
</Project>

BIN
bsp/w60x/tools/library.zip Normal file

Binary file not shown.

BIN
bsp/w60x/tools/makeimg Normal file

Binary file not shown.

137
bsp/w60x/tools/makeimg.py Normal file
View File

@ -0,0 +1,137 @@
# -*- coding:utf-8 -*-
#
# W600 make img script
# Copyright (c) 2018 Winner Micro Electronic Design Co., Ltd.
# All rights reserved.
#
# image header structure
# --------------------------------------------------------------------------------------------
# | magic number(4B) | image type(2B)| zip type(2B) | run image addr(4B) | run image len(4B) |
# --------------------------------------------------------------------------------------------
# | run image crc(4B) | update image addr(4B) | update image len(4B) | update image crc(4B) |
# ---------------------------------------------------------------------------------------------
# | update no(4B) | ver(16B) |
# ---------------------------------------------------------------------------------------------
# | run code |
# ---------------------------------------------------------------------------------------------
#
import sys
import os
import struct
from zlib import crc32
magic_no = 0xA0FFFF9F
def main(argv):
if(len(argv) < 8):
print("param cnt error")
print("param 0: .py")
print("param 1: input .bin file.(uncompressed file or compressed file)")
print("param 2: output file")
print("param 3: image type ,0old param user image,1reserved,2secboot,3: new param user image")
print("param 4: compressed type,0uncompressed file,1.compressed file")
print("param 5: firmware version file")
print("param 6 input image storage address")
print("param 7 input image running address")
print("param 8 input original image file")
raise Exception("param cnt error!")
# version
try:
f_ver = open(argv[5], "r+")
except IOError:
print("not find %s file" % argv[5])
raise
else:
version = f_ver.readline(20)
p = version.rfind('.')
if p == -1:
version = '1.0.00'
newversion = '1.0.01'
else:
newversion = version[:p+1]
ver = int(version[p+1:]) + 1
newversion = newversion + '{:0>2d}'.format(ver)
#print(newversion)
if len(newversion) < 16:
newversion = newversion + '\0' * (16 - len(newversion))
#print(len(newversion), newversion)
else:
newversion = newversion[:15] + '\0'
f_ver.close()
# bin file crc
try:
f_bin = open(argv[1], mode='rb')
except IOError:
print("not find %s file" % argv[1])
raise
else:
bin_data = f_bin.read()
bin_len = os.path.getsize(argv[1])
bin_crc = crc32(bin_data) ^ (0xFFFFFFFF)
# print(hex(bin_crc))
magic = struct.pack('<I', magic_no)
img_type = struct.pack('<H', int(argv[3]))
zip_type = struct.pack('<H', int(argv[4]))
# print(argv[7], int(argv[7] ,16))
run_img_addr = struct.pack('<I', int(argv[7], 16))
upd_img_addr = struct.pack('<I', int(argv[6], 16))
upd_img_len = struct.pack('<I', bin_len)
upd_checksum = struct.pack('<I', bin_crc)
upd_no = struct.pack('<I', 0)
ver_name = newversion.encode('utf-8')
# non-zip image
if not int(argv[4]):
run_img_len = struct.pack('<I', bin_len)
run_org_checksum = struct.pack('<I', bin_crc)
else:
# zip image
try:
f_src = open(argv[8], 'rb+')
except IOError:
f_bin.close()
print("not find %s file" % argv[8])
raise
else:
src_data = f_src.read()
src_len = os.path.getsize(argv[8])
src_crc = crc32(src_data) ^ (0xFFFFFFFF)
# print(src_data)
f_src.close()
run_img_len = struct.pack('<I', src_len)
run_org_checksum = struct.pack('<I', src_crc)
#image header crc
image_header = magic + img_type + zip_type + run_img_addr + run_img_len \
+ run_org_checksum + upd_img_addr + upd_img_len + upd_checksum \
+ upd_no + ver_name
header_crc = crc32(image_header) ^ (0xFFFFFFFF)
try:
f_img = open(argv[2], "wb+")
except IOError:
f_bin.close()
print("create %s file fail" % argv[2])
raise
else:
f_img.write(image_header)
f_img.write(struct.pack('<I', header_crc))
f_img.write(bin_data)
# write dummy data to pad 4byte-aligned
dummy = len(bin_data) % 4
if dummy != 0:
dummy = 4 - len(bin_data) % 4
f_img.write(struct.pack('<B', 0) * dummy)
f_img.close()
f_bin.close()
print("image %s create success!" % argv[2])
if __name__ == '__main__':
main(sys.argv)

BIN
bsp/w60x/tools/makeimg_all Normal file

Binary file not shown.

View File

@ -0,0 +1,159 @@
# -*- coding:utf-8 -*_
#
# W600 make img script
# Copyright (c) 2018 Winner Micro Electronic Design Co., Ltd.
# All rights reserved.
#
# image header structure
# --------------------------------------------------------------------------------------------
# | magic number(4B) | image type(2B)| zip type(2B) | run image addr(4B) | run image len(4B) |
# --------------------------------------------------------------------------------------------
# | run image crc(4B) | update image addr(4B) | update image len(4B) | update image crc(4B) |
# ---------------------------------------------------------------------------------------------
# | update no(4B) | ver(16B) |
# ---------------------------------------------------------------------------------------------
#
#
# FLS File structure
# ----------------------------------------------
# | FLS file header (image header) |
# ------------------------------------
# | secboot header (image header) |
# ------------------------------------
# | 256-sizeof(image header) pad 0xFF |
# ------------------------------------
# | secboot img area-(56*1024 - 256) |
# ------------------------------------
# | application image header (image header) |
# ------------------------------------
# | 256-sizeof(image heager)-pad 0xFF |
# ------------------------------------
# | application image |
# ------------------------------------------------
#
#
import sys
import os
import struct
from zlib import crc32
secboot_img_addr = 0x2100
secboot_header_len = 0x100
secboot_header_pos = secboot_img_addr - secboot_header_len
secboot_img_total_len = 56*1024
run_img_header_len = 0x100
magic_no = 0xA0FFFF9F
def main(argv):
if(len(argv) != 4):
print("param cnt error")
print("param 0: .py")
print("param 1: input \"secboot.img\" file")
print("param 2: input image file")
print("param 3: output FLS file")
raise Exception("param cnt error!")
# second boot
try:
f_sec = open(argv[1], "rb+")
except IOError:
print("not find %s file" % argv[1])
raise
else:
magic_word = f_sec.read(4)
magic, = struct.unpack('<I', magic_word)
if magic != magic_no:
f_sec.close()
raise Exception("input %s file error" % argv[1])
# app image
try:
f_app=open(argv[2], "rb+")
except IOError:
f_sec.close()
print("not find %s file" % argv[2])
raise
else:
magic_word=f_app.read(4)
magic, = struct.unpack('<I', magic_word)
if magic != magic_no:
f_sec.close()
f_app.close()
raise Exception("input %s file error" % argv[1])
appimg_len=os.path.getsize(argv[2])
# create outfile
try:
f_out=open(argv[3], 'wb+')
except IOError:
f_app.close()
f_sec.close()
print("create %s file error" % argv[3])
raise
else:
final_len=secboot_img_total_len + appimg_len
data = struct.pack('<B', 0xff) * final_len
f_out.write(data)
# Write SECBOOT header to output file
f_out.seek(56)
f_sec.seek(0)
f_out.write(f_sec.read(56))
# Write SECBOOT image to output file
f_out.seek(56 + 256)
f_out.write(f_sec.read())
# Write run img header to output file
f_out.seek(56 + secboot_img_total_len)
f_app.seek(0)
f_out.write(f_app.read(56))
# Write run img to output file
f_out.seek(56 + secboot_img_total_len + run_img_header_len)
f_out.write(f_app.read())
# Calculate CRC from secboot header
f_out.seek(56)
out_data = f_out.read()
out_crc = crc32(out_data) ^ (0xFFFFFFFF)
out_len = len(out_data)
#print(hex(out_crc))
magic = struct.pack('<I', magic_no)
img_type = struct.pack('<H', 0)
zip_type = struct.pack('<H', 0)
run_img_addr = struct.pack('<I', secboot_header_pos)
upd_img_addr = struct.pack('<I', 0)
upd_img_len = struct.pack('<I', 0)
upd_checksum = struct.pack('<I', 0)
upd_no = struct.pack('<I', 0)
version = '\0' * 16
ver_name = version.encode('utf-8')
run_img_len = struct.pack('<I', out_len)
run_org_checksum = struct.pack('<I', out_crc)
# image header crc
image_header=magic + img_type + zip_type + run_img_addr + run_img_len \
+ run_org_checksum + upd_img_addr + upd_img_len + upd_checksum \
+ upd_no + ver_name
header_crc=crc32(image_header) ^ (0xFFFFFFFF)
# Write fls's header to output file
f_out.seek(0)
f_out.write(image_header)
f_out.write(struct.pack('<I', header_crc))
f_sec.close()
f_app.close()
f_out.close()
print("create %s file success!" % argv[3])
print("%s size:%dKB. %s size:%dKB" % (argv[2], appimg_len / 1024.0 , argv[3], final_len / 1024.0))
if __name__ == '__main__':
main(sys.argv)

BIN
bsp/w60x/tools/python34.dll Normal file

Binary file not shown.

BIN
bsp/w60x/tools/secboot.img Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
1.0.06

16
bsp/w60x/tools/wm_gzip.py Normal file
View File

@ -0,0 +1,16 @@
# -*- coding:utf-8 -*-
#
# W600 make gzip file
# Copyright (c) 2018 Winner Micro Electronic Design Co., Ltd.
# All rights reserved.
import sys
import gzip
file_name = sys.argv[1]
file_prefix = file_name + '.gz'
with open(file_name, 'rb') as f_in:
with gzip.open(file_prefix, 'wb') as f_out:
f_out.writelines(f_in)
f_in.close()
f_out.close()