提交 06106918 编写于 作者: misonyo's avatar misonyo

[bsp/swm320-lq100]add gcc/iar support and hwtimer driver

上级 95b97884
......@@ -101,34 +101,7 @@ CONFIG_FINSH_ARG_MAX=10
#
# Device virtual file system
#
CONFIG_RT_USING_DFS=y
CONFIG_DFS_USING_WORKDIR=y
CONFIG_DFS_FILESYSTEMS_MAX=8
CONFIG_DFS_FILESYSTEM_TYPES_MAX=8
CONFIG_DFS_FD_MAX=8
# CONFIG_RT_USING_DFS_MNTTABLE is not set
CONFIG_RT_USING_DFS_ELMFAT=y
#
# elm-chan's FatFs, Generic FAT Filesystem Module
#
CONFIG_RT_DFS_ELM_CODE_PAGE=437
CONFIG_RT_DFS_ELM_WORD_ACCESS=y
# CONFIG_RT_DFS_ELM_USE_LFN_0 is not set
# CONFIG_RT_DFS_ELM_USE_LFN_1 is not set
# CONFIG_RT_DFS_ELM_USE_LFN_2 is not set
CONFIG_RT_DFS_ELM_USE_LFN_3=y
CONFIG_RT_DFS_ELM_USE_LFN=3
CONFIG_RT_DFS_ELM_MAX_LFN=255
CONFIG_RT_DFS_ELM_DRIVES=2
CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=4096
# CONFIG_RT_DFS_ELM_USE_ERASE is not set
CONFIG_RT_DFS_ELM_REENTRANT=y
CONFIG_RT_USING_DFS_DEVFS=y
# CONFIG_RT_USING_DFS_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 is not set
#
# Device Drivers
......@@ -136,31 +109,22 @@ CONFIG_RT_USING_DFS_DEVFS=y
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_USING_DMA is not set
# CONFIG_RT_USING_CAN is not set
CONFIG_RT_USING_HWTIMER=y
# CONFIG_RT_USING_CPUTIME is not set
CONFIG_RT_USING_I2C=y
CONFIG_RT_USING_I2C_BITOPS=y
# CONFIG_RT_USING_I2C is not set
CONFIG_RT_USING_PIN=y
# CONFIG_RT_USING_ADC is not set
CONFIG_RT_USING_PWM=y
CONFIG_RT_USING_MTD_NOR=y
# 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=y
# CONFIG_RT_USING_SOFT_RTC is not set
# CONFIG_RT_USING_RTC is not set
# CONFIG_RT_USING_SDIO is not set
CONFIG_RT_USING_SPI=y
# CONFIG_RT_USING_QSPI is not set
# CONFIG_RT_USING_SPI_MSD is not set
# CONFIG_RT_USING_SFUD is not set
# CONFIG_RT_USING_W25QXX is not set
# CONFIG_RT_USING_GD is not set
# CONFIG_RT_USING_ENC28J60 is not set
# CONFIG_RT_USING_SPI_WIFI is not set
CONFIG_RT_USING_WDT=y
# CONFIG_RT_USING_SPI is not set
# CONFIG_RT_USING_WDT is not set
# CONFIG_RT_USING_AUDIO is not set
#
......@@ -177,10 +141,8 @@ CONFIG_RT_USING_WDT=y
#
# POSIX layer and C standard library
#
CONFIG_RT_USING_LIBC=y
# CONFIG_RT_USING_LIBC is not set
# CONFIG_RT_USING_PTHREADS is not set
# CONFIG_RT_USING_POSIX is not set
# CONFIG_RT_USING_MODULE is not set
#
# Network
......@@ -310,6 +272,7 @@ CONFIG_RT_USING_LIBC=y
# 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
......@@ -323,6 +286,8 @@ CONFIG_RT_USING_LIBC=y
# 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_KENDRYTE_SDK is not set
#
# miscellaneous packages
......@@ -338,10 +303,6 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_DSTR is not set
# CONFIG_PKG_USING_TINYFRAME is not set
#
# sample package
#
#
# samples: kernel and components samples
#
......@@ -349,10 +310,6 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set
# CONFIG_PKG_USING_NETWORK_SAMPLES is not set
# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
#
# example package: hello
#
# CONFIG_PKG_USING_HELLO is not set
CONFIG_SOC_SWM320VET7=y
......@@ -364,6 +321,7 @@ CONFIG_SOC_SWM320VET7=y
# On-chip Peripheral Drivers
#
CONFIG_BSP_USING_GPIO=y
# CONFIG_BSP_USING_WDT is not set
#
# UART Drivers
......@@ -385,7 +343,7 @@ CONFIG_BSP_USING_UART0=y
# CONFIG_BSP_USING_I2C is not set
#
# PWM module
# PWM Drivers
#
# CONFIG_BSP_USING_PWM0 is not set
# CONFIG_BSP_USING_PWM1 is not set
......@@ -393,14 +351,19 @@ CONFIG_BSP_USING_UART0=y
# CONFIG_BSP_USING_PWM3 is not set
#
# RTC module
# RTC Drivers
#
# CONFIG_BSP_USING_RTC is not set
#
# RTC SET
# HWtimer Drivers
#
# CONFIG_BSP_USING_RTC is not set
# CONFIG_BSP_USING_WDT is not set
# CONFIG_BSP_USING_HWTIMER0 is not set
# CONFIG_BSP_USING_HWTIMER1 is not set
# CONFIG_BSP_USING_HWTIMER2 is not set
# CONFIG_BSP_USING_HWTIMER3 is not set
# CONFIG_BSP_USING_HWTIMER4 is not set
# CONFIG_BSP_USING_HWTIMER5 is not set
#
# Onboard Peripheral Drivers
......
......@@ -11,8 +11,7 @@ if rtconfig.CROSS_TOOL == 'gcc':
elif rtconfig.CROSS_TOOL == 'keil':
src += ['CMSIS/DeviceSupport/startup/arm/startup_SWM320.s']
elif rtconfig.CROSS_TOOL == 'iar':
print('Not Support iar now\n')
exit(0)
src += ['CMSIS/DeviceSupport/startup/iar/startup_SWM320.s']
group = DefineGroup('Libraries', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
......@@ -31,7 +31,7 @@ SWXT-LQ100-32102 V1.1 开发板板载资源如下:
- 常用接口:USB打印接口,TFT LCD接口,SD卡接口
- 调试接口:SWD
更多详细信息请咨询[华芯微特技术支持][5]
更多详细信息请咨询[华芯微特技术支持][http://www.synwit.cn/support.html]
### 1.2 MCU 简介
......@@ -53,25 +53,25 @@ SWM320VET7 是 SYNWIT 公司的一款面向工业控制、白色家电、电机
> 工程默认配置使用 Jlink 仿真器下载程序,在通过 Jlink 连接开发板到 PC 的基础上,点击下载按钮即可下载程序到开发板
推荐熟悉 RT_Thread 的用户使用[env工具][1],可以在console下进入到 `bsp/swm320-lq100` 目录中,运行以下命令:
推荐熟悉 RT_Thread 的用户使用[env工具](https://www.rt-thread.org/page/download.html),可以在console下进入到 `bsp/swm320-lq100` 目录中,运行以下命令:
`scons --target=mdk5`
`scons`
来编译这个板级支持包。如果编译正确无误,会产生rtthread.elf、rtthread.bin文件。其中 rtthread.bin 可以烧写到设备中进行运行。
来编译这个板级支持包。如果编译正确无误,会产生rtthread.elf、rtthread.bin文件。其中 rtthread.bin 可以烧写到设备中运行。
## 3. 烧写及执行
### 3.1 硬件连接
- 使用 USB B-Type 数据线连接开发板到 PC(注意:需要下载安装串口驱动支持CH340芯片,使用 MDK5 需要安装 SWM320 相关的 pack)。
- 使用 USB B-Type 数据线连接开发板到 PC(注意:需要下载安装串口驱动支持 CH340 芯片,使用 MDK5 需要安装 SWM320 相关的 pack)。
> USB B-Type 数据线用于串口通讯,同时供电
- 使用 Jlink 连接开发板到 PC (需要 Jlink 驱动)
连接好串口,使用115200-N-8-1的配置方式连接到设备上。串口引脚是:`[PA2/PA3]`
将串口 0 引脚为:`[PA2/PA3]`和 USB 转串口模块 P2 相连,串口配置方式为115200-N-8-1。
当使用 [env工具][1] 正确编译产生出rtthread.bin映像文件后,可以使用 ISP 的方式来烧写到设备中。
当使用 [env工具](https://www.rt-thread.org/page/download.html) 正确编译产生出rtthread.bin映像文件后,可以使用 ISP 的方式来烧写到设备中。
**建议使用 keil 软件直接下载**。ISP 下载较复杂。
......@@ -97,17 +97,15 @@ msh />
| TFT-LCD | 暂不支持 | 即将支持 |
|**片上外设** |**支持情况** |**备注** |
| GPIO | 支持 | PIN:1...100 |
| UART | 支持 | UART0 / UART1 / UART2 / UART3 |
| UART | 支持 | UART0 / UART1 / UART2 / UART3 |
| SPI | 支持 | SPI0 / SPI1 |
| I2C | 支持 | I2C0 IO模拟 |
| ADC | 暂不支持 | 即将支持 |
| PWM | 支持 | PWM0 / PWM1 /PWM2 /PWM3 其余两个后续补充 |
| PWM | 支持 | PWM0 / PWM1 /PWM2 /PWM3 其余两个后续补充|
| IWG | 支持 | |
| TIMER | 暂不支持 | |
| TIMER | 支持 | |
| RTC | 支持 | |
| CAN | 暂不支持 | |
|**板外外设** |**支持情况**|**备注** |
| Arduino 扩展接口 | 暂不支持 | |
## 5. 联系人信息
......@@ -117,10 +115,10 @@ msh />
## 6. 参考
- 芯片[SWM320系列 数据手册][4]
- 芯片[SWM320系列数据手册][http://www.synwit.cn/Public/Uploads/2018-11-05/5bdff49b396d1.pdf]
[1]: https://www.rt-thread.org/page/download.html
[2]: http://www.synwit.cn/Public/Uploads/2018-11-05/5bdfea74d5712.pdf
[3]: http://www.synwit.cn/Public/Uploads/2018-11-01/5bdab8ad2e5b9.pdf
[4]: http://www.synwit.cn/Public/Uploads/2018-11-05/5bdff49b396d1.pdf
[5]: http://www.synwit.cn/support.html
- [ SWM320_LQFP100原理图](http://www.synwit.cn/Public/Uploads/2018-11-01/5bdab8ad2e5b9.pdf)
- [ SWM320_LQFP64原理图](http://www.synwit.cn/Public/Uploads/2018-11-05/5bdfea74d5712.pdf)
- [ keil pack及其他资料](http://www.synwit.cn/support-1/2.html)
......@@ -27,7 +27,7 @@ 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 = ['$LINK $SOURCES $LINKFLAGS -o $TARGET --map project.map'])
env.Replace(LINKCOM = ['$LINK $SOURCES $LINKFLAGS -o $TARGET --map rtthread.map'])
Export('RTT_ROOT')
Export('rtconfig')
......
......@@ -10,18 +10,22 @@
#include <rtthread.h>
#include <rtdevice.h>
#define LED4_PIN 100
/* defined the LED pin: PA12 */
#define LED_PIN 100
int main(void)
{
/* user app entry */
rt_pin_mode(LED4_PIN, PIN_MODE_OUTPUT);
while (1)
int count = 1;
/* set LED4 pin mode to output */
rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT);
while (count++)
{
rt_pin_write(LED4_PIN, !rt_pin_read(LED4_PIN));
rt_thread_mdelay(1000);
rt_pin_write(LED_PIN, PIN_HIGH);
rt_thread_mdelay(500);
rt_pin_write(LED_PIN, PIN_LOW);
rt_thread_mdelay(500);
}
return 0;
return RT_EOK;
}
menu "Hardware Drivers Config"
menu "On-chip Peripheral Drivers"
config BSP_USING_GPIO
bool "Enable GPIO"
select RT_USING_PIN
default y
config BSP_USING_WDT
bool "Enable Watch Dog"
select RT_USING_WDT
default n
menu "UART Drivers"
config BSP_USING_UART0
bool "Enable UART0 PA2/3(R/T)"
select RT_USING_SERIAL
......@@ -28,11 +31,9 @@ menu "Hardware Drivers Config"
bool "Enable UART3 PC6/7(R/T)"
select RT_USING_SERIAL
default n
endmenu
menu "SPI Drivers"
config BSP_USING_SPI0
bool "Enable SPI0 BUS PC4/5/6(C/O/I)"
select RT_USING_SPI
......@@ -44,12 +45,10 @@ menu "Hardware Drivers Config"
select RT_USING_SPI
select RT_USING_PIN
default n
endmenu
menu "I2C Drivers"
menuconfig BSP_USING_I2C
config BSP_USING_I2C
bool "Enable I2C BUS"
select RT_USING_I2C
select RT_USING_PIN
......@@ -69,13 +68,10 @@ menu "Hardware Drivers Config"
config BSP_I2C_BUS_NAME
string "i2c bus name"
default "i2c0"
endif
endmenu
menu "PWM module"
menu "PWM Drivers"
config BSP_USING_PWM0
bool "Using PWM0 PA4/10(A/B)"
select RT_USING_PWM
......@@ -95,29 +91,49 @@ menu "Hardware Drivers Config"
bool "Using PWM3 PP1/3(A/B)"
select RT_USING_PWM
default n
endmenu
menu "RTC module"
comment "RTC SET"
menu "RTC Drivers"
config BSP_USING_RTC
bool "Using RTC"
select RT_USING_RTC
default n
endmenu
config BSP_USING_WDT
menu "HWtimer Drivers"
config BSP_USING_HWTIMER0
bool "Using timer0"
select RT_USING_HWTIMER
default n
bool "Enable Watch Dog"
select RT_USING_WDT
default n
config BSP_USING_HWTIMER1
bool "Using timer1"
select RT_USING_HWTIMER
default n
config BSP_USING_HWTIMER2
bool "Using timer2"
select RT_USING_HWTIMER
default n
config BSP_USING_HWTIMER3
bool "Using timer3"
select RT_USING_HWTIMER
default n
config BSP_USING_HWTIMER4
bool "Using timer4"
select RT_USING_HWTIMER
default n
config BSP_USING_HWTIMER5
bool "Using timer5"
select RT_USING_HWTIMER
default n
endmenu
endmenu
menu "Onboard Peripheral Drivers"
menuconfig BSP_USING_EXT_SRAM
bool "Enable external sram"
select RT_USING_MEMHEAP
......@@ -144,7 +160,6 @@ menu "Hardware Drivers Config"
hex "mtd nor flsah sector"
default 0x10000
endif
endmenu
menu "Offboard Peripheral Drivers"
......
......@@ -45,6 +45,10 @@ if GetDepend(['BSP_USING_RTC']):
if GetDepend(['BSP_USING_WDT']):
src += ['drv_iwg.c']
# add hwtimer driver code
if GetDepend('BSP_USING_HWTIMER0') or GetDepend('BSP_USING_HWTIMER1') or GetDepend('BSP_USING_HWTIMER2') or GetDepend('BSP_USING_HWTIMER3') or GetDepend('BSP_USING_HWTIMER4') or GetDepend('BSP_USING_HWTIMER5'):
src += ['drv_hwtimer.c']
CPPPATH = [cwd]
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
......
......@@ -23,7 +23,7 @@
#define EXT_SRAM_END (EXT_SRAM_BASE + EXT_SRAM_SIZE)
#endif
#define SRAM_END (SRAM_BASE + SRAM_SIZE * 1024UL)
#define SRAM_END (SRAM_BASE + SRAM_SIZE)
#ifdef __CC_ARM
extern int Image$$RW_IRAM1$$ZI$$Limit;
#define HEAP_BEGIN ((void *)&Image$$RW_IRAM1$$ZI$$Limit)
......
......@@ -283,7 +283,6 @@ static rt_err_t swm320_pin_irq_enable(struct rt_device *device,
}
if (enabled == PIN_IRQ_ENABLE)
{
switch (index->irq_mode)
{
case PIN_IRQ_MODE_RISING:
......
/*
* Copyright (c) 2006-2018, Synwit Technology Co.,Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-12-10 Zohar_Lee first version
*/
#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
#define SWM320_HWTIMER_DEVICE(hwtimer) (struct swm320_hwtimer_dev *)(hwtimer)
struct swm320_hwtimer_dev
{
rt_hwtimer_t parent;
TIMR_TypeDef *hwtimer_periph;
};
#ifdef BSP_USING_HWTIMER0
static struct swm320_hwtimer_dev hwtimer0;
void TIMR0_Handler(void)
{
TIMR_INTClr(TIMR0);
rt_device_hwtimer_isr(&hwtimer0.parent);
if (HWTIMER_MODE_ONESHOT == hwtimer0.parent.mode)
{
TIMR_Stop(hwtimer0.hwtimer_periph);
}
}
#endif //BSP_USING_HWTIMER0
#ifdef BSP_USING_HWTIMER1
static struct swm320_hwtimer_dev hwtimer1;
void TIMR1_Handler(void)
{
TIMR_INTClr(TIMR1);
rt_device_hwtimer_isr(&hwtimer1.parent);
if (HWTIMER_MODE_ONESHOT == hwtimer1.parent.mode)
{
TIMR_Stop(hwtimer1.hwtimer_periph);
}
}
#endif //BSP_USING_HWTIMER1
#ifdef BSP_USING_HWTIMER2
static struct swm320_hwtimer_dev hwtimer2;
void TIMR2_Handler(void)
{
TIMR_INTClr(TIMR2);
rt_device_hwtimer_isr(&hwtimer2.parent);
if (HWTIMER_MODE_ONESHOT == hwtimer2.parent.mode)
{
TIMR_Stop(hwtimer2.hwtimer_periph);
}
}
#endif //BSP_USING_HWTIMER2
#ifdef BSP_USING_HWTIMER3
static struct swm320_hwtimer_dev hwtimer3;
void TIMR3_Handler(void)
{
TIMR_INTClr(TIMR3);
rt_device_hwtimer_isr(&hwtimer3.parent);
if (HWTIMER_MODE_ONESHOT == hwtimer3.parent.mode)
{
TIMR_Stop(hwtimer3.hwtimer_periph);
}
}
#endif //BSP_USING_HWTIMER3
#ifdef BSP_USING_HWTIMER4
static struct swm320_hwtimer_dev hwtimer4;
void TIMR4_Handler(void)
{
TIMR_INTClr(TIMR4);
rt_device_hwtimer_isr(&hwtimer4.parent);
if (HWTIMER_MODE_ONESHOT == hwtimer4.parent.mode)
{
TIMR_Stop(hwtimer4.hwtimer_periph);
}
}
#endif //BSP_USING_HWTIMER4
#ifdef BSP_USING_HWTIMER5
static struct swm320_hwtimer_dev hwtimer5;
void TIMR5_Handler(void)
{
TIMR_INTClr(TIMR5);
rt_device_hwtimer_isr(&hwtimer5.parent);
if (HWTIMER_MODE_ONESHOT == hwtimer5.parent.mode)
{
TIMR_Stop(hwtimer5.hwtimer_periph);
}
}
#endif //BSP_USING_HWTIMER5
static struct rt_hwtimer_info swm320_hwtimer_info =
{
120000000, /*时钟源为系统时钟*/
120000000,
4294967295, /*32位计数器,2的32次方*/
HWTIMER_CNTMODE_DW
};
static void swm320_hwtimer_init(rt_hwtimer_t *timer, rt_uint32_t state)
{
struct swm320_hwtimer_dev *hwtimer = SWM320_HWTIMER_DEVICE(timer->parent.user_data);
RT_ASSERT(hwtimer != RT_NULL);
if (1 == state)
{
TIMR_Init(hwtimer->hwtimer_periph,
TIMR_MODE_TIMER,
SystemCoreClock,
1);
}
hwtimer->parent.freq = SystemCoreClock;
swm320_hwtimer_info.maxfreq = SystemCoreClock;
swm320_hwtimer_info.minfreq = SystemCoreClock;
}
static rt_err_t swm320_hwtimer_start(rt_hwtimer_t *timer,
rt_uint32_t cnt,
rt_hwtimer_mode_t mode)
{
struct swm320_hwtimer_dev *hwtimer = SWM320_HWTIMER_DEVICE(timer->parent.user_data);
RT_ASSERT(hwtimer != RT_NULL);
TIMR_SetPeriod(hwtimer->hwtimer_periph, cnt);
TIMR_Start(hwtimer->hwtimer_periph);
return RT_EOK;
}
static void swm320_hwtimer_stop(rt_hwtimer_t *timer)
{
struct swm320_hwtimer_dev *hwtimer = SWM320_HWTIMER_DEVICE(timer->parent.user_data);
RT_ASSERT(hwtimer != RT_NULL);
TIMR_Stop(hwtimer->hwtimer_periph);
}
static rt_uint32_t swm320_hwtimer_count_get(rt_hwtimer_t *timer)
{
struct swm320_hwtimer_dev *hwtimer = SWM320_HWTIMER_DEVICE(timer->parent.user_data);
uint32_t hwtimer_count = 0;
RT_ASSERT(hwtimer != RT_NULL);
hwtimer_count = TIMR_GetCurValue(hwtimer->hwtimer_periph);
return hwtimer_count;
}
static rt_err_t swm320_hwtimer_control(rt_hwtimer_t *timer,
rt_uint32_t cmd,
void *args)
{
rt_err_t ret = RT_EOK;
rt_uint32_t freq = 0;
struct swm320_hwtimer_dev *hwtimer = SWM320_HWTIMER_DEVICE(timer->parent.user_data);
RT_ASSERT(hwtimer != RT_NULL);
switch (cmd)
{
case HWTIMER_CTRL_FREQ_SET:
freq = *(rt_uint32_t*)args;
if (freq != SystemCoreClock)
{
ret = RT_EINVAL;
}
break;
case HWTIMER_CTRL_STOP:
TIMR_Stop(hwtimer->hwtimer_periph);
break;
default:
ret = RT_EINVAL;
break;
}
return ret;
}
static struct rt_hwtimer_ops swm320_hwtimer_ops =
{
swm320_hwtimer_init,
swm320_hwtimer_start,
swm320_hwtimer_stop,
swm320_hwtimer_count_get,
swm320_hwtimer_control
};
int rt_hw_hwtimer_init(void)
{
rt_err_t ret = RT_EOK;
#ifdef BSP_USING_HWTIMER0
hwtimer0.hwtimer_periph = TIMR0;
hwtimer0.parent.info = &swm320_hwtimer_info;
hwtimer0.parent.ops = &swm320_hwtimer_ops;
ret = rt_device_hwtimer_register(&hwtimer0.parent, "timer0", &hwtimer0);
#endif //BSP_USING_HWTIMER0
#ifdef BSP_USING_HWTIMER1
hwtimer1.hwtimer_periph = TIMR1;
hwtimer1.parent.info = &swm320_hwtimer_info;
hwtimer1.parent.ops = &swm320_hwtimer_ops;
ret = rt_device_hwtimer_register(&hwtimer1.parent, "timer1", &hwtimer1);
#endif //BSP_USING_HWTIMER1
#ifdef BSP_USING_HWTIMER2
hwtimer2.hwtimer_periph = TIMR2;
hwtimer2.parent.info = &swm320_hwtimer_info;
hwtimer2.parent.ops = &swm320_hwtimer_ops;
ret = rt_device_hwtimer_register(&hwtimer2.parent, "timer2", &hwtimer2);
#endif //BSP_USING_HWTIMER2
#ifdef BSP_USING_HWTIMER3
hwtimer3.hwtimer_periph = TIMR3;
hwtimer3.parent.info = &swm320_hwtimer_info;
hwtimer3.parent.ops = &swm320_hwtimer_ops;
ret = rt_device_hwtimer_register(&hwtimer3.parent, "timer3", &hwtimer3);
#endif //BSP_USING_HWTIMER3
#ifdef BSP_USING_HWTIMER4
hwtimer4.hwtimer_periph = TIMR4;
hwtimer4.parent.info = &swm320_hwtimer_info;
hwtimer4.parent.ops = &swm320_hwtimer_ops;
ret = rt_device_hwtimer_register(&hwtimer4.parent, "timer4", &hwtimer4);
#endif //BSP_USING_HWTIMER4
#ifdef BSP_USING_HWTIMER5
hwtimer5.hwtimer_periph = TIMR5;
hwtimer5.parent.info = &swm320_hwtimer_info;
hwtimer5.parent.ops = &swm320_hwtimer_ops;
ret = rt_device_hwtimer_register(&hwtimer5.parent, "timer5", &hwtimer5);
#endif //BSP_USING_HWTIMER5
return ret;
}
INIT_BOARD_EXPORT(rt_hw_hwtimer_init);
/*
* Copyright (c) 2006-2018, Synwit Technology Co.,Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-12-10 Zohar_Lee first version
*/
#ifndef DRV_HWTIMER_H__
#define DRV_HWTIMER_H__
int rt_hw_hwtimer_init(void);
#endif
......@@ -28,8 +28,7 @@ int rt_hw_sram_init(void)
SYS->CLKEN |= (1 << SYS_CLKEN_SDRAM_Pos);
while (SDRAMC->REFDONE == 0)
;
while (SDRAMC->REFDONE == 0);
SDRAMC->REFRESH &= ~(1 << SDRAMC_REFRESH_EN_Pos);
for (i = 0; i < 1000; i++)
......
此差异已折叠。
此差异已折叠。
<?xml version="1.0" encoding="iso-8859-1"?>
<workspace>
<project>
<path>$WS_DIR$\project.ewp</path>
</project>
<batchBuild/>
</workspace>
此差异已折叠。
......@@ -10,13 +10,13 @@
<TargetName>rt-thread</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
<pCCUsed>5060528::V5.06 update 5 (build 528)::ARMCC</pCCUsed>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>SWM320xE</Device>
<Vendor>Synwit</Vendor>
<PackID>Synwit.SWM32_DFP.1.6.8</PackID>
<PackID>Synwit.SWM32_DFP.1.6.2</PackID>
<PackURL>http://www.synwit.com/pack</PackURL>
<Cpu>IRAM(0x20000000,0x20000) IROM(0x00000000,0x80000) CPUTYPE("Cortex-M4") CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>
......@@ -48,13 +48,13 @@
<NotGenerated>0</NotGenerated>
<InvalidFlash>1</InvalidFlash>
</TargetStatus>
<OutputDirectory>.\build\</OutputDirectory>
<OutputDirectory>.\build\keil\Obj\</OutputDirectory>
<OutputName>rtthread</OutputName>
<CreateExecutable>1</CreateExecutable>
<CreateLib>0</CreateLib>
<CreateHexFile>0</CreateHexFile>
<DebugInformation>1</DebugInformation>
<BrowseInformation>1</BrowseInformation>
<BrowseInformation>0</BrowseInformation>
<ListingPath>.\build\</ListingPath>
<HexFormatSelection>1</HexFormatSelection>
<Merge32K>0</Merge32K>
......@@ -82,7 +82,7 @@
<AfterMake>
<RunUserProg1>1</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name>fromelf --bin !L --output @H.bin</UserProg1Name>
<UserProg1Name>fromelf --bin !L --output rtthread.bin</UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
......@@ -324,7 +324,6 @@
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<uC99>1</uC99>
<uGnu>0</uGnu>
<useXO>0</useXO>
<v6Lang>0</v6Lang>
<v6LangP>0</v6LangP>
......@@ -335,9 +334,9 @@
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define>RT_USING_ARM_LIBC</Define>
<Define></Define>
<Undefine></Undefine>
<IncludePath>applications;.;drivers;Libraries\CMSIS\CoreSupport;Libraries\CMSIS\DeviceSupport;Libraries\SWM320_StdPeriph_Driver;..\..\include;..\..\libcpu\arm\cortex-m4;..\..\libcpu\arm\common;..\..\components\dfs\include;..\..\components\dfs\filesystems\devfs;..\..\components\dfs\filesystems\elmfat;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\spi;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh;..\..\components\libc\compilers\armlibc;..\..\components\libc\compilers\common</IncludePath>
<IncludePath>applications;.;drivers;Libraries\CMSIS\CoreSupport;Libraries\CMSIS\DeviceSupport;Libraries\SWM320_StdPeriph_Driver;..\..\include;..\..\libcpu\arm\cortex-m4;..\..\libcpu\arm\common;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh</IncludePath>
</VariousControls>
</Cads>
<Aads>
......@@ -381,6 +380,11 @@
<Group>
<GroupName>Applications</GroupName>
<Files>
<File>
<FileName>hwtimer_sample.c</FileName>
<FileType>1</FileType>
<FilePath>applications\hwtimer_sample.c</FilePath>
</File>
<File>
<FileName>main.c</FileName>
<FileType>1</FileType>
......@@ -633,143 +637,14 @@
</File>
</Files>
</Group>
<Group>
<GroupName>Filesystem</GroupName>
<Files>
<File>
<FileName>dfs.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\dfs\src\dfs.c</FilePath>
</File>
<File>
<FileName>dfs_file.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\dfs\src\dfs_file.c</FilePath>
</File>
<File>
<FileName>dfs_fs.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\dfs\src\dfs_fs.c</FilePath>
</File>
<File>
<FileName>dfs_posix.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\dfs\src\dfs_posix.c</FilePath>
</File>
<File>
<FileName>devfs.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\dfs\filesystems\devfs\devfs.c</FilePath>
</File>
<File>
<FileName>dfs_elm.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\dfs\filesystems\elmfat\dfs_elm.c</FilePath>
</File>
<File>
<FileName>ff.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\dfs\filesystems\elmfat\ff.c</FilePath>
</File>
<File>
<FileName>ccsbcs.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\dfs\filesystems\elmfat\option\ccsbcs.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>DeviceDrivers</GroupName>
<GroupOption>
<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>0</ComprImg>
</CommonProperty>
<GroupArmAds>
<Cads>
<interw>2</interw>
<Optim>0</Optim>
<oTime>2</oTime>
<SplitLS>2</SplitLS>
<OneElfS>2</OneElfS>
<Strict>2</Strict>
<EnumInt>2</EnumInt>
<PlainCh>2</PlainCh>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<wLevel>0</wLevel>
<uThumb>2</uThumb>
<uSurpInc>2</uSurpInc>
<uC99>2</uC99>
<uGnu>2</uGnu>
<useXO>2</useXO>
<v6Lang>0</v6Lang>
<v6LangP>0</v6LangP>
<vShortEn>2</vShortEn>
<vShortWch>2</vShortWch>
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define> </Define>
<Undefine> </Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
<Aads>
<interw>2</interw>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<thumb>2</thumb>
<SplitLS>2</SplitLS>
<SwStkChk>2</SwStkChk>
<NoWarn>2</NoWarn>
<uSurpInc>2</uSurpInc>
<useXO>2</useXO>
<uClangAs>2</uClangAs>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Aads>
</GroupArmAds>
</GroupOption>
<Files>
<File>
<FileName>hwtimer.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\drivers\hwtimer\hwtimer.c</FilePath>
</File>
<File>
<FileName>i2c_core.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\drivers\i2c\i2c_core.c</FilePath>
</File>
<File>
<FileName>i2c_dev.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\drivers\i2c\i2c_dev.c</FilePath>
</File>
<File>
<FileName>i2c-bit-ops.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\drivers\i2c\i2c-bit-ops.c</FilePath>
</File>
<File>
<FileName>pin.c</FileName>
<FileType>1</FileType>
......@@ -780,31 +655,11 @@
<FileType>1</FileType>
<FilePath>..\..\components\drivers\misc\rt_drv_pwm.c</FilePath>
</File>
<File>
<FileName>mtd_nor.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\drivers\mtd\mtd_nor.c</FilePath>
</File>
<File>
<FileName>rtc.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\drivers\rtc\rtc.c</FilePath>
</File>
<File>
<FileName>serial.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\drivers\serial\serial.c</FilePath>
</File>
<File>
<FileName>spi_core.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\drivers\spi\spi_core.c</FilePath>
</File>
<File>
<FileName>spi_dev.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\drivers\spi\spi_dev.c</FilePath>
</File>
<File>
<FileName>completion.c</FileName>
<FileType>1</FileType>
......@@ -840,11 +695,6 @@
<FileType>1</FileType>
<FilePath>..\..\components\drivers\src\workqueue.c</FilePath>
</File>
<File>
<FileName>watchdog.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\drivers\watchdog\watchdog.c</FilePath>
</File>
</Files>
</Group>
<Group>
......@@ -932,41 +782,6 @@
</File>
</Files>
</Group>
<Group>
<GroupName>libc</GroupName>
<Files>
<File>
<FileName>libc.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\libc\compilers\armlibc\libc.c</FilePath>
</File>
<File>
<FileName>mem_std.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\libc\compilers\armlibc\mem_std.c</FilePath>
</File>
<File>
<FileName>stdio.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\libc\compilers\armlibc\stdio.c</FilePath>
</File>
<File>
<FileName>stubs.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\libc\compilers\armlibc\stubs.c</FilePath>
</File>
<File>
<FileName>time.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\libc\compilers\armlibc\time.c</FilePath>
</File>
<File>
<FileName>gmtime_r.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\libc\compilers\common\gmtime_r.c</FilePath>
</File>
</Files>
</Group>
</Groups>
</Target>
</Targets>
......
......@@ -68,40 +68,15 @@
/* Device virtual file system */
#define RT_USING_DFS
#define DFS_USING_WORKDIR
#define DFS_FILESYSTEMS_MAX 8
#define DFS_FILESYSTEM_TYPES_MAX 8
#define DFS_FD_MAX 8
#define RT_USING_DFS_ELMFAT
/* elm-chan's FatFs, Generic FAT Filesystem Module */
#define RT_DFS_ELM_CODE_PAGE 437
#define RT_DFS_ELM_WORD_ACCESS
#define RT_DFS_ELM_USE_LFN_3
#define RT_DFS_ELM_USE_LFN 3
#define RT_DFS_ELM_MAX_LFN 255
#define RT_DFS_ELM_DRIVES 2
#define RT_DFS_ELM_MAX_SECTOR_SIZE 4096
#define RT_DFS_ELM_REENTRANT
#define RT_USING_DFS_DEVFS
/* Device Drivers */
#define RT_USING_DEVICE_IPC
#define RT_PIPE_BUFSZ 512
#define RT_USING_SERIAL
#define RT_SERIAL_USING_DMA
#define RT_USING_HWTIMER
#define RT_USING_I2C
#define RT_USING_I2C_BITOPS
#define RT_USING_PIN
#define RT_USING_PWM
#define RT_USING_MTD_NOR
#define RT_USING_RTC
#define RT_USING_SPI
#define RT_USING_WDT
/* Using WiFi */
......@@ -111,7 +86,6 @@
/* POSIX layer and C standard library */
#define RT_USING_LIBC
/* Network */
......@@ -170,13 +144,8 @@
/* miscellaneous packages */
/* sample package */
/* samples: kernel and components samples */
/* example package: hello */
#define SOC_SWM320VET7
/* Hardware Drivers Config */
......@@ -195,12 +164,13 @@
/* I2C Drivers */
/* PWM module */
/* PWM Drivers */
/* RTC Drivers */
/* RTC module */
/* RTC SET */
/* HWtimer Drivers */
/* Onboard Peripheral Drivers */
......
......@@ -22,8 +22,8 @@ elif CROSS_TOOL == 'keil':
PLATFORM = 'armcc'
EXEC_PATH = 'C:/Keil_v5'
elif CROSS_TOOL == 'iar':
print("Not support gcc now\n")
exit(0)
PLATFORM = 'iar'
EXEC_PATH = 'C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.2'
if os.getenv('RTT_EXEC_PATH'):
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
......@@ -34,6 +34,7 @@ BUILD = 'debug'
if PLATFORM == 'gcc':
PREFIX = 'arm-none-eabi-'
CC = PREFIX + 'gcc'
CXX = PREFIX + 'g++'
AS = PREFIX + 'gcc'
AR = PREFIX + 'ar'
LINK = PREFIX + 'gcc'
......@@ -46,7 +47,7 @@ if PLATFORM == 'gcc':
FLOAT_ABI + ' -ffunction-sections -fdata-sections'
CFLAGS = DEVICE + ' -std=c99'
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb '
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T link.lds'
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T drivers/linker_scripts/link.lds'
CPATH = ''
LPATH = ''
......@@ -69,7 +70,7 @@ elif PLATFORM == 'armcc':
DEVICE = ' --cpu ' + CPU + '.fp '
CFLAGS = '-c ' + DEVICE + ' --apcs=interwork --c99'
AFLAGS = DEVICE + ' --apcs=interwork '
LFLAGS = DEVICE + ' --scatter "link.sct" --info sizes --info totals --info unused --info veneers --list rtthread.map --strict'
LFLAGS = DEVICE + ' --scatter "drivers/linker_scripts/link.sct" --info sizes --info totals --info unused --info veneers --list rtthread.map --strict'
CFLAGS += ' -I' + EXEC_PATH + '/ARM/ARMCC/INC'
LFLAGS += ' --libpath ' + EXEC_PATH + '/ARM/ARMCC/LIB'
......@@ -88,5 +89,49 @@ elif PLATFORM == 'armcc':
POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET'
elif PLATFORM == 'iar':
print('Not Support iar now\n')
exit(0)
# toolchains
CC = 'iccarm'
AS = 'iasmarm'
AR = 'iarchive'
LINK = 'ilinkarm'
TARGET_EXT = 'out'
DEVICE = '-Dewarm' # + ' -D' + PART_TYPE
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-M4'
CFLAGS += ' -e'
CFLAGS += ' --fpu=VFPv4_sp'
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-M4'
AFLAGS += ' --fpu VFPv4_sp'
AFLAGS += ' -S'
if BUILD == 'debug':
CFLAGS += ' --debug'
CFLAGS += ' -On'
else:
CFLAGS += ' -Oh'
LFLAGS = ' --config "drivers/linker_scripts/link.icf"'
LFLAGS += ' --entry __iar_program_start'
#LFLAGS += ' --silent'
EXEC_PATH = EXEC_PATH + '/arm/bin/'
POST_ACTION = ''
此差异已折叠。
<?xml version="1.0" encoding="iso-8859-1"?>
<workspace>
<project>
<path>$WS_DIR$\template.ewp</path>
</project>
<batchBuild/>
</workspace>
此差异已折叠。
......@@ -125,7 +125,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>JL2CM3</Key>
<Name>-U801000899 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8002 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC4000 -FN1 -FF0SWM320xE -FS00 -FL080000</Name>
<Name>-U30000299 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8002 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC4000 -FN1 -FF0SWM320xE -FS00 -FL080000 -FP0($$Device:SWM320xE$Flash\SWM320xE.FLM)</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册