Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
3482bf86
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3482bf86
编写于
10月 09, 2021
作者:
mysterywolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
format es32f369x
上级
421867f4
变更
50
展开全部
隐藏空白更改
内联
并排
Showing
50 changed file
with
3115 addition
and
4532 deletion
+3115
-4532
bsp/essemi/es32f369x/.ignore_format.yml
bsp/essemi/es32f369x/.ignore_format.yml
+4
-0
bsp/essemi/es32f369x/drivers/ES/es_conf_info_adc.h
bsp/essemi/es32f369x/drivers/ES/es_conf_info_adc.h
+23
-23
bsp/essemi/es32f369x/drivers/ES/es_conf_info_can.h
bsp/essemi/es32f369x/drivers/ES/es_conf_info_can.h
+4
-4
bsp/essemi/es32f369x/drivers/ES/es_conf_info_cmu.h
bsp/essemi/es32f369x/drivers/ES/es_conf_info_cmu.h
+15
-15
bsp/essemi/es32f369x/drivers/ES/es_conf_info_gpio.h
bsp/essemi/es32f369x/drivers/ES/es_conf_info_gpio.h
+44
-44
bsp/essemi/es32f369x/drivers/ES/es_conf_info_hwtimer.h
bsp/essemi/es32f369x/drivers/ES/es_conf_info_hwtimer.h
+21
-21
bsp/essemi/es32f369x/drivers/ES/es_conf_info_i2c.h
bsp/essemi/es32f369x/drivers/ES/es_conf_info_i2c.h
+16
-16
bsp/essemi/es32f369x/drivers/ES/es_conf_info_map.h
bsp/essemi/es32f369x/drivers/ES/es_conf_info_map.h
+2407
-2407
bsp/essemi/es32f369x/drivers/ES/es_conf_info_pm.h
bsp/essemi/es32f369x/drivers/ES/es_conf_info_pm.h
+2
-2
bsp/essemi/es32f369x/drivers/ES/es_conf_info_pwm.h
bsp/essemi/es32f369x/drivers/ES/es_conf_info_pwm.h
+9
-9
bsp/essemi/es32f369x/drivers/ES/es_conf_info_rtc.h
bsp/essemi/es32f369x/drivers/ES/es_conf_info_rtc.h
+1
-1
bsp/essemi/es32f369x/drivers/ES/es_conf_info_select.h
bsp/essemi/es32f369x/drivers/ES/es_conf_info_select.h
+2
-2
bsp/essemi/es32f369x/drivers/ES/es_conf_info_spi.h
bsp/essemi/es32f369x/drivers/ES/es_conf_info_spi.h
+48
-48
bsp/essemi/es32f369x/drivers/ES/es_conf_info_uart.h
bsp/essemi/es32f369x/drivers/ES/es_conf_info_uart.h
+26
-26
bsp/essemi/es32f369x/drivers/board.c
bsp/essemi/es32f369x/drivers/board.c
+27
-27
bsp/essemi/es32f369x/drivers/board.h
bsp/essemi/es32f369x/drivers/board.h
+2
-2
bsp/essemi/es32f369x/drivers/bsp_driver_example/.gitignore
bsp/essemi/es32f369x/drivers/bsp_driver_example/.gitignore
+0
-52
bsp/essemi/es32f369x/drivers/bsp_driver_example/README.md
bsp/essemi/es32f369x/drivers/bsp_driver_example/README.md
+0
-47
bsp/essemi/es32f369x/drivers/bsp_driver_example/adc_vol_sample.c
...emi/es32f369x/drivers/bsp_driver_example/adc_vol_sample.c
+0
-63
bsp/essemi/es32f369x/drivers/bsp_driver_example/can_sample.c
bsp/essemi/es32f369x/drivers/bsp_driver_example/can_sample.c
+0
-148
bsp/essemi/es32f369x/drivers/bsp_driver_example/hwtimer_sample.c
...emi/es32f369x/drivers/bsp_driver_example/hwtimer_sample.c
+0
-89
bsp/essemi/es32f369x/drivers/bsp_driver_example/i2c_e2_sample.c
...semi/es32f369x/drivers/bsp_driver_example/i2c_e2_sample.c
+0
-109
bsp/essemi/es32f369x/drivers/bsp_driver_example/i2c_sample.c
bsp/essemi/es32f369x/drivers/bsp_driver_example/i2c_sample.c
+0
-109
bsp/essemi/es32f369x/drivers/bsp_driver_example/led_blink_sample.c
...i/es32f369x/drivers/bsp_driver_example/led_blink_sample.c
+0
-84
bsp/essemi/es32f369x/drivers/bsp_driver_example/pin_beep_sample.c
...mi/es32f369x/drivers/bsp_driver_example/pin_beep_sample.c
+0
-68
bsp/essemi/es32f369x/drivers/bsp_driver_example/pm_sample.c
bsp/essemi/es32f369x/drivers/bsp_driver_example/pm_sample.c
+0
-219
bsp/essemi/es32f369x/drivers/bsp_driver_example/pwm_led_sample.c
...emi/es32f369x/drivers/bsp_driver_example/pwm_led_sample.c
+0
-77
bsp/essemi/es32f369x/drivers/bsp_driver_example/rtc_sample.c
bsp/essemi/es32f369x/drivers/bsp_driver_example/rtc_sample.c
+0
-55
bsp/essemi/es32f369x/drivers/bsp_driver_example/spi_sample.c
bsp/essemi/es32f369x/drivers/bsp_driver_example/spi_sample.c
+0
-152
bsp/essemi/es32f369x/drivers/bsp_driver_example/uart_sample.c
...essemi/es32f369x/drivers/bsp_driver_example/uart_sample.c
+0
-149
bsp/essemi/es32f369x/drivers/drv_adc.c
bsp/essemi/es32f369x/drivers/drv_adc.c
+20
-20
bsp/essemi/es32f369x/drivers/drv_adc.h
bsp/essemi/es32f369x/drivers/drv_adc.h
+1
-1
bsp/essemi/es32f369x/drivers/drv_can.c
bsp/essemi/es32f369x/drivers/drv_can.c
+63
-63
bsp/essemi/es32f369x/drivers/drv_can.h
bsp/essemi/es32f369x/drivers/drv_can.h
+1
-1
bsp/essemi/es32f369x/drivers/drv_gpio.c
bsp/essemi/es32f369x/drivers/drv_gpio.c
+96
-96
bsp/essemi/es32f369x/drivers/drv_gpio.h
bsp/essemi/es32f369x/drivers/drv_gpio.h
+3
-3
bsp/essemi/es32f369x/drivers/drv_hwtimer.c
bsp/essemi/es32f369x/drivers/drv_hwtimer.c
+50
-50
bsp/essemi/es32f369x/drivers/drv_hwtimer.h
bsp/essemi/es32f369x/drivers/drv_hwtimer.h
+1
-1
bsp/essemi/es32f369x/drivers/drv_i2c.c
bsp/essemi/es32f369x/drivers/drv_i2c.c
+22
-22
bsp/essemi/es32f369x/drivers/drv_i2c.h
bsp/essemi/es32f369x/drivers/drv_i2c.h
+2
-2
bsp/essemi/es32f369x/drivers/drv_pm.c
bsp/essemi/es32f369x/drivers/drv_pm.c
+12
-12
bsp/essemi/es32f369x/drivers/drv_pm.h
bsp/essemi/es32f369x/drivers/drv_pm.h
+2
-2
bsp/essemi/es32f369x/drivers/drv_pwm.c
bsp/essemi/es32f369x/drivers/drv_pwm.c
+95
-95
bsp/essemi/es32f369x/drivers/drv_rtc.c
bsp/essemi/es32f369x/drivers/drv_rtc.c
+7
-7
bsp/essemi/es32f369x/drivers/drv_rtc.h
bsp/essemi/es32f369x/drivers/drv_rtc.h
+1
-1
bsp/essemi/es32f369x/drivers/drv_spi.c
bsp/essemi/es32f369x/drivers/drv_spi.c
+66
-66
bsp/essemi/es32f369x/drivers/drv_spi.h
bsp/essemi/es32f369x/drivers/drv_spi.h
+2
-2
bsp/essemi/es32f369x/drivers/drv_spiflash.c
bsp/essemi/es32f369x/drivers/drv_spiflash.c
+1
-1
bsp/essemi/es32f369x/drivers/drv_spiflash.h
bsp/essemi/es32f369x/drivers/drv_spiflash.h
+1
-1
bsp/essemi/es32f369x/drivers/drv_uart.c
bsp/essemi/es32f369x/drivers/drv_uart.c
+18
-18
未找到文件。
bsp/essemi/es32f369x/.ignore_format.yml
0 → 100644
浏览文件 @
3482bf86
# files format check exclude path, please follow the instructions below to modify;
dir_path
:
-
libraries
bsp/essemi/es32f369x/drivers/ES/es_conf_info_adc.h
浏览文件 @
3482bf86
...
...
@@ -23,30 +23,30 @@
#ifndef __ES_CONF_INFO_ADC_H__
#define __ES_CONF_INFO_ADC_H__
#include "es_conf_info_map.h"
#include <ald_adc.h>
#define ES_C_ADC_CLK_DIV_1 ADC_CKDIV_1
#define ES_C_ADC_CLK_DIV_1 ADC_CKDIV_1
#define ES_C_ADC_CLK_DIV_2 ADC_CKDIV_2
#define ES_C_ADC_CLK_DIV_4 ADC_CKDIV_4
#define ES_C_ADC_CLK_DIV_8 ADC_CKDIV_8
#define ES_C_ADC_CLK_DIV_16 ADC_CKDIV_16
#define ES_C_ADC_CLK_DIV_32 ADC_CKDIV_32
#define ES_C_ADC_CLK_DIV_32 ADC_CKDIV_32
#define ES_C_ADC_CLK_DIV_64 ADC_CKDIV_64
#define ES_C_ADC_CLK_DIV_128 ADC_CKDIV_128
#define ES_C_ADC_ALIGN_RIGHT ADC_DATAALIGN_RIGHT
#define ES_C_ADC_ALIGN_RIGHT ADC_DATAALIGN_RIGHT
#define ES_C_ADC_ALIGN_LEFT ADC_DATAALIGN_LEFT
#define ES_C_ADC_CONV_BIT_6 ADC_CONV_BIT_6
#define ES_C_ADC_CONV_BIT_6 ADC_CONV_BIT_6
#define ES_C_ADC_CONV_BIT_8 ADC_CONV_BIT_8
#define ES_C_ADC_CONV_BIT_10 ADC_CONV_BIT_10
#define ES_C_ADC_CONV_BIT_12 ADC_CONV_BIT_12
#define ES_C_ADC_SAMPLE_TIME_1 ADC_SAMPLETIME_1
#define ES_C_ADC_SAMPLE_TIME_1 ADC_SAMPLETIME_1
#define ES_C_ADC_SAMPLE_TIME_2 ADC_SAMPLETIME_2
#define ES_C_ADC_SAMPLE_TIME_4 ADC_SAMPLETIME_4
#define ES_C_ADC_SAMPLE_TIME_15 ADC_SAMPLETIME_15
...
...
@@ -56,41 +56,41 @@
/* codes_main */
#define ES_ADC0_ALIGN ES_C_ADC_ALIGN_RIGHT
#define ES_ADC1_ALIGN ES_C_ADC_ALIGN_RIGHT
#define ES_ADC1_DATA_BIT ES_C_ADC_CONV_BIT_12
#define ES_ADC0_ALIGN ES_C_ADC_ALIGN_RIGHT
#define ES_ADC1_ALIGN ES_C_ADC_ALIGN_RIGHT
#define ES_ADC1_DATA_BIT ES_C_ADC_CONV_BIT_12
#define ES_ADC0_DATA_BIT ES_C_ADC_CONV_BIT_12
#ifndef ES_DEVICE_NAME_ADC0
#define ES_DEVICE_NAME_ADC0 "adc0"
#endif
#endif
#ifndef ES_DEVICE_NAME_ADC1
#define ES_DEVICE_NAME_ADC1 "adc1"
#endif
#ifndef ES_ADC0_CLK_DIV
#define ES_ADC0_CLK_DIV ES_C_ADC_CLK_DIV_128
#endif
#ifndef ES_ADC0_ALIGN
#ifndef ES_ADC0_CLK_DIV
#define ES_ADC0_CLK_DIV ES_C_ADC_CLK_DIV_128
#endif
#ifndef ES_ADC0_ALIGN
#define ES_ADC0_ALIGN ES_C_ADC_ALIGN_RIGHT
#endif
#ifndef ES_ADC0_DATA_BIT
#ifndef ES_ADC0_DATA_BIT
#define ES_ADC0_DATA_BIT ES_C_ADC_CONV_BIT_12
#endif
#ifndef ES_ADC0_NCH_SAMPLETIME
#ifndef ES_ADC0_NCH_SAMPLETIME
#define ES_ADC0_NCH_SAMPLETIME ES_C_ADC_SAMPLE_TIME_4
#endif
#ifndef ES_ADC1_CLK_DIV
#define ES_ADC1_CLK_DIV ES_C_ADC_CLK_DIV_128
#endif
#ifndef ES_ADC1_ALIGN
#ifndef ES_ADC1_CLK_DIV
#define ES_ADC1_CLK_DIV ES_C_ADC_CLK_DIV_128
#endif
#ifndef ES_ADC1_ALIGN
#define ES_ADC1_ALIGN ES_C_ADC_ALIGN_RIGHT
#endif
#ifndef ES_ADC1_DATA_BIT
#ifndef ES_ADC1_DATA_BIT
#define ES_ADC1_DATA_BIT ES_C_ADC_CONV_BIT_12
#endif
#ifndef ES_ADC1_NCH_SAMPLETIME
#ifndef ES_ADC1_NCH_SAMPLETIME
#define ES_ADC1_NCH_SAMPLETIME ES_C_ADC_SAMPLE_TIME_4
#endif
...
...
bsp/essemi/es32f369x/drivers/ES/es_conf_info_can.h
浏览文件 @
3482bf86
...
...
@@ -32,11 +32,11 @@
/*默认的CAN硬件过滤器的编号 0 */
#define ES_C_CAN_DEFAULT_FILTER_NUMBER 0
/*硬件过滤器,过滤帧类型*/
/*硬件过滤器,过滤帧类型*/
#define ES_C_CAN_FILTER_FRAME_TYPE 0
#define ES_C_CAN_SJW_NUM_1 CAN_SJW_1
#define ES_C_CAN_SJW_NUM_1 CAN_SJW_1
#define ES_C_CAN_SJW_NUM_2 CAN_SJW_2
#define ES_C_CAN_SJW_NUM_3 CAN_SJW_3
#define ES_C_CAN_SJW_NUM_4 CAN_SJW_4
...
...
@@ -44,7 +44,7 @@
/* CAN 配置 */
/* codes_main */
...
...
@@ -55,7 +55,7 @@
#ifndef ES_CAN0_AUTO_BAN_RE_T
#define ES_CAN0_AUTO_BAN_RE_T ES_C_ENABLE
#endif
#endif
#ifndef ES_CAN0_SPEED
#define ES_CAN0_SPEED 1000000
#endif
...
...
bsp/essemi/es32f369x/drivers/ES/es_conf_info_cmu.h
浏览文件 @
3482bf86
...
...
@@ -25,7 +25,7 @@
#define __ES_CONF_INFO_CMU_H__
#include <ald_cmu.h>
#include <ald_cmu.h>
/* 时钟树 配置 */
...
...
@@ -33,21 +33,21 @@
#define ES_C_MUL_9 CMU_PLL1_OUTPUT_36M
#define ES_C_MUL_12 CMU_PLL1_OUTPUT_48M
#define ES_C_MUL_18 CMU_PLL1_OUTPUT_72M
#define ES_C_MUL_24 CMU_PLL1_OUTPUT_96M
#define ES_C_MUL_24 CMU_PLL1_OUTPUT_96M
#define ES_C_DIV_1 CMU_DIV_1
#define ES_C_DIV_2 CMU_DIV_2
#define ES_C_DIV_4 CMU_DIV_4
#define ES_C_DIV_8 CMU_DIV_8
#define ES_C_DIV_16 CMU_DIV_16
#define ES_C_DIV_32 CMU_DIV_32
#define ES_C_DIV_64 CMU_DIV_64
#define ES_C_DIV_128 CMU_DIV_128
#define ES_C_DIV_256 CMU_DIV_256
#define ES_C_DIV_512 CMU_DIV_512
#define ES_C_DIV_1024 CMU_DIV_1024
#define ES_C_DIV_2048 CMU_DIV_2048
#define ES_C_DIV_4096 CMU_DIV_4096
#define ES_C_DIV_1 CMU_DIV_1
#define ES_C_DIV_2 CMU_DIV_2
#define ES_C_DIV_4 CMU_DIV_4
#define ES_C_DIV_8 CMU_DIV_8
#define ES_C_DIV_16 CMU_DIV_16
#define ES_C_DIV_32 CMU_DIV_32
#define ES_C_DIV_64 CMU_DIV_64
#define ES_C_DIV_128 CMU_DIV_128
#define ES_C_DIV_256 CMU_DIV_256
#define ES_C_DIV_512 CMU_DIV_512
#define ES_C_DIV_1024 CMU_DIV_1024
#define ES_C_DIV_2048 CMU_DIV_2048
#define ES_C_DIV_4096 CMU_DIV_4096
#define ES_C_HOSC_DIV_1 CMU_PLL1_INPUT_HOSC
#define ES_C_HOSC_DIV_2 CMU_PLL1_INPUT_HOSC_2
...
...
bsp/essemi/es32f369x/drivers/ES/es_conf_info_gpio.h
浏览文件 @
3482bf86
...
...
@@ -33,29 +33,29 @@
/* GPIO 配置 */
typedef
struct
{
uint8_t
pin
;
uint8_t
pin_mode
;
uint8_t
pin_level
;
uint8_t
irq_en
;
uint8_t
irq_mode
;
void
(
*
callback
)(
void
*
arg
);
uint8_t
pin
;
uint8_t
pin_mode
;
uint8_t
pin_level
;
uint8_t
irq_en
;
uint8_t
irq_mode
;
void
(
*
callback
)(
void
*
arg
);
}
gpio_conf_t
;
/*参数的定义*/
#define ES_C_GPIO_LEVEL_HIGH PIN_HIGH
#define ES_C_GPIO_LEVEL_HIGH PIN_HIGH
#define ES_C_GPIO_LEVEL_LOW PIN_LOW
#define ES_C_GPIO_MODE_OUTPUT PIN_MODE_OUTPUT
#define ES_C_GPIO_MODE_INPUT PIN_MODE_INPUT
#define ES_C_GPIO_MODE_INPUT_PULLUP PIN_MODE_INPUT_PULLUP
#define ES_C_GPIO_MODE_INPUT_PULLDOWN PIN_MODE_INPUT_PULLDOWN
#define ES_C_GPIO_MODE_OUTPUT_OD PIN_MODE_OUTPUT_OD
#define ES_C_GPIO_MODE_OUTPUT PIN_MODE_OUTPUT
#define ES_C_GPIO_MODE_INPUT PIN_MODE_INPUT
#define ES_C_GPIO_MODE_INPUT_PULLUP PIN_MODE_INPUT_PULLUP
#define ES_C_GPIO_MODE_INPUT_PULLDOWN PIN_MODE_INPUT_PULLDOWN
#define ES_C_GPIO_MODE_OUTPUT_OD PIN_MODE_OUTPUT_OD
#define ES_C_GPIO_IRQ_ENABLE PIN_IRQ_ENABLE
#define ES_C_GPIO_IRQ_ENABLE PIN_IRQ_ENABLE
#define ES_C_GPIO_IRQ_DISABLE PIN_IRQ_DISABLE
#define ES_C_GPIO_IRQ_MODE_FALL PIN_IRQ_MODE_FALLING
#define ES_C_GPIO_IRQ_MODE_FALL PIN_IRQ_MODE_FALLING
#define ES_C_GPIO_IRQ_MODE_RISE PIN_IRQ_MODE_RISING
#define ES_C_GPIO_IRQ_MODE_R_F PIN_IRQ_MODE_RISING_FALLING
...
...
@@ -74,7 +74,7 @@ typedef struct {
/*GPIO外部中断回调函数控制需要,补充是否中断*/
#if 11111
#ifndef ES_INIT_GPIO_A_0_IRQ_EN
#define ES_INIT_GPIO_A_0_IRQ_EN ES_C_GPIO_IRQ_DISABLE
#endif
...
...
@@ -681,67 +681,67 @@ typedef struct {
#if 11111
#ifdef ES_CONF_EXTI_IRQ_0
void
irq_pin0_callback
(
void
*
arg
);
void
irq_pin0_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_1
void
irq_pin1_callback
(
void
*
arg
);
#endif
void
irq_pin1_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_2
void
irq_pin2_callback
(
void
*
arg
);
void
irq_pin2_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_3
void
irq_pin3_callback
(
void
*
arg
);
void
irq_pin3_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_4
void
irq_pin4_callback
(
void
*
arg
);
void
irq_pin4_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_5
void
irq_pin5_callback
(
void
*
arg
);
#endif
void
irq_pin5_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_6
void
irq_pin6_callback
(
void
*
arg
);
void
irq_pin6_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_7
void
irq_pin7_callback
(
void
*
arg
);
void
irq_pin7_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_8
void
irq_pin8_callback
(
void
*
arg
);
void
irq_pin8_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_9
void
irq_pin9_callback
(
void
*
arg
);
#endif
void
irq_pin9_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_10
void
irq_pin10_callback
(
void
*
arg
);
void
irq_pin10_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_11
void
irq_pin11_callback
(
void
*
arg
);
void
irq_pin11_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_12
void
irq_pin12_callback
(
void
*
arg
);
void
irq_pin12_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_13
void
irq_pin13_callback
(
void
*
arg
);
#endif
void
irq_pin13_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_14
void
irq_pin14_callback
(
void
*
arg
);
void
irq_pin14_callback
(
void
*
arg
);
#endif
#ifdef ES_CONF_EXTI_IRQ_15
void
irq_pin15_callback
(
void
*
arg
);
void
irq_pin15_callback
(
void
*
arg
);
#endif
...
...
@@ -782,7 +782,7 @@ void irq_pin15_callback(void* arg);
defined(ES_INIT_PIN_GPIO_H_0) || defined(ES_INIT_PIN_GPIO_H_1) || defined(ES_INIT_PIN_GPIO_H_2) || defined(ES_INIT_PIN_GPIO_H_3) || \
defined(ES_INIT_PIN_GPIO_H_4) || defined(ES_INIT_PIN_GPIO_H_5) || defined(ES_INIT_PIN_GPIO_H_6) || defined(ES_INIT_PIN_GPIO_H_7) || \
defined(ES_INIT_PIN_GPIO_H_8) || defined(ES_INIT_PIN_GPIO_H_9) || defined(ES_INIT_PIN_GPIO_H_10) || defined(ES_INIT_PIN_GPIO_H_11) || \
defined(ES_INIT_PIN_GPIO_H_12) || defined(ES_INIT_PIN_GPIO_H_13) || defined(ES_INIT_PIN_GPIO_H_14) || defined(ES_INIT_PIN_GPIO_H_15)
defined(ES_INIT_PIN_GPIO_H_12) || defined(ES_INIT_PIN_GPIO_H_13) || defined(ES_INIT_PIN_GPIO_H_14) || defined(ES_INIT_PIN_GPIO_H_15)
#define ES_INIT_GPIOS
...
...
@@ -791,9 +791,9 @@ void irq_pin15_callback(void* arg);
#ifdef ES_INIT_GPIOS
static
gpio_conf_t
gpio_conf_all
[]
=
static
gpio_conf_t
gpio_conf_all
[]
=
{
#ifdef ES_INIT_PIN_GPIO_A_0
{
...
...
@@ -5146,12 +5146,12 @@ static gpio_conf_t gpio_conf_all[] =
#endif
};
#endif
};
#endif
#endif
bsp/essemi/es32f369x/drivers/ES/es_conf_info_hwtimer.h
浏览文件 @
3482bf86
...
...
@@ -27,7 +27,7 @@
#include <ald_cmu.h>
#include <ald_timer.h>
#define ES_C_HWTIMER_MODE_UP HWTIMER_CNTMODE_UP
#define ES_C_HWTIMER_MODE_UP HWTIMER_CNTMODE_UP
#define ES_C_HWTIMER_MODE_DOWN HWTIMER_CNTMODE_DW
/* HWTIMER 配置 */
...
...
@@ -37,34 +37,34 @@
#ifndef ES_AD16C4T0_HWTIMER_MODE
#define ES_AD16C4T0_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#endif
#define ES_AD16C4T0_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#endif
#ifndef ES_AD16C4T1_HWTIMER_MODE
#define ES_AD16C4T1_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#define ES_AD16C4T1_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#endif
#ifndef ES_GP32C4T0_HWTIMER_MODE
#define ES_GP32C4T0_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#endif
#define ES_GP32C4T0_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#endif
#ifndef ES_GP32C4T1_HWTIMER_MODE
#define ES_GP32C4T1_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#define ES_GP32C4T1_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#endif
#ifndef ES_GP16C4T0_HWTIMER_MODE
#define ES_GP16C4T0_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#define ES_GP16C4T0_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#endif
#ifndef ES_GP16C4T1_HWTIMER_MODE
#define ES_GP16C4T1_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#define ES_GP16C4T1_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#endif
#ifndef ES_BS16T0_HWTIMER_MODE
#define ES_BS16T0_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#define ES_BS16T0_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#endif
#ifndef ES_BS16T1_HWTIMER_MODE
#define ES_BS16T1_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#define ES_BS16T1_HWTIMER_MODE ES_C_HWTIMER_MODE_UP
#endif
#define ES_AD16C4T0_HWTIMER_PRES 1
#define ES_AD16C4T0_HWTIMER_PRES 1
#define ES_AD16C4T1_HWTIMER_PRES 1
#define ES_GP16C4T0_HWTIMER_PRES 1
#define ES_GP16C4T1_HWTIMER_PRES 1
...
...
@@ -75,28 +75,28 @@
#ifndef ES_DEVICE_NAME_AD16C4T0_HWTIMER
#define ES_DEVICE_NAME_AD16C4T0_HWTIMER "timer0"
#endif
#endif
#ifndef ES_DEVICE_NAME_AD16C4T1_HWTIMER
#define ES_DEVICE_NAME_AD16C4T1_HWTIMER "timer1"
#endif
#endif
#ifndef ES_DEVICE_NAME_GP32C4T0_HWTIMER
#define ES_DEVICE_NAME_GP32C4T0_HWTIMER "timer2"
#endif
#endif
#ifndef ES_DEVICE_NAME_GP32C4T1_HWTIMER
#define ES_DEVICE_NAME_GP32C4T1_HWTIMER "timer3"
#endif
#endif
#ifndef ES_DEVICE_NAME_GP16C4T0_HWTIMER
#define ES_DEVICE_NAME_GP16C4T0_HWTIMER "timer4"
#endif
#endif
#ifndef ES_DEVICE_NAME_GP16C4T1_HWTIMER
#define ES_DEVICE_NAME_GP16C4T1_HWTIMER "timer5"
#endif
#endif
#ifndef ES_DEVICE_NAME_BS16T0_HWTIMER
#define ES_DEVICE_NAME_BS16T0_HWTIMER "timer6"
#endif
#endif
#ifndef ES_DEVICE_NAME_BS16T1_HWTIMER
#define ES_DEVICE_NAME_BS16T1_HWTIMER "timer7"
#endif
#endif
#endif
bsp/essemi/es32f369x/drivers/ES/es_conf_info_i2c.h
浏览文件 @
3482bf86
...
...
@@ -29,35 +29,35 @@
#include <ald_gpio.h>
#include <rtdbg.h>
#define ES_C_I2C_STRETCH I2C_NOSTRETCH_DISABLE
#define ES_C_I2C_STRETCH I2C_NOSTRETCH_DISABLE
#define ES_C_I2C_NO_STRETCH I2C_NOSTRETCH_ENABLE
#define ES_C_I2C_GENERALCALL I2C_GENERALCALL_ENABLE
#define ES_C_I2C_NO_GENERALCALL I2C_GENERALCALL_DISABLE
#define ES_C_I2C_ADDR_7_MODE I2C_ADDR_7BIT
#define ES_C_I2C_ADDR_7_MODE I2C_ADDR_7BIT
#define ES_C_I2C_ADDR_10_MODE I2C_ADDR_10BIT
/* I2C 配置 */
/* codes_main */
#ifndef ES_DEVICE_NAME_I2C0
#define ES_DEVICE_NAME_I2C0 "i2c0"
#endif
#endif
#ifndef ES_DEVICE_NAME_I2C1
#define ES_DEVICE_NAME_I2C1 "i2c1"
#endif
#endif
#ifndef ES_I2C0_CLK_SPEED
#define ES_I2C0_CLK_SPEED 100000
#endif
...
...
@@ -70,8 +70,8 @@
#ifndef ES_I2C0_STRETCH
#define ES_I2C0_STRETCH ES_C_I2C_STRETCH
#endif
#ifndef ES_I2C0_ADDR_MODE
#define ES_I2C0_ADDR_MODE ES_C_I2C_ADDR_7_MODE
#ifndef ES_I2C0_ADDR_MODE
#define ES_I2C0_ADDR_MODE ES_C_I2C_ADDR_7_MODE
#endif
#ifndef ES_I2C1_CLK_SPEED
...
...
@@ -85,11 +85,11 @@
#endif
#ifndef ES_I2C1_STRETCH
#define ES_I2C1_STRETCH ES_C_I2C_STRETCH
#endif
#ifndef ES_I2C1_ADDR_MODE
#define ES_I2C1_ADDR_MODE ES_C_I2C_ADDR_7_MODE
#endif
#ifndef ES_I2C1_ADDR_MODE
#define ES_I2C1_ADDR_MODE ES_C_I2C_ADDR_7_MODE
#endif
#endif
bsp/essemi/es32f369x/drivers/ES/es_conf_info_map.h
浏览文件 @
3482bf86
此差异已折叠。
点击以展开。
bsp/essemi/es32f369x/drivers/ES/es_conf_info_pm.h
浏览文件 @
3482bf86
...
...
@@ -23,10 +23,10 @@
#include <ald_cmu.h>
#include <ald_pmu.h>
#define ES_PMU_SAVE_LOAD_UART
#define ES_PMU_SAVE_LOAD_UART
/* PM 配置 */
#endif
bsp/essemi/es32f369x/drivers/ES/es_conf_info_pwm.h
浏览文件 @
3482bf86
...
...
@@ -37,7 +37,7 @@
#define ES_C_PWM_OC_MODE_PWM2 TIMER_OC_MODE_PWM2
/* PWM 配置 */
...
...
@@ -50,29 +50,29 @@
#ifndef ES_PWM_OC_POLARITY
#define ES_PWM_OC_POLARITY ES_C_PWM_OC_POL_HIGH
#endif
#ifndef ES_PWM_OC_MODE
#endif
#ifndef ES_PWM_OC_MODE
#define ES_PWM_OC_MODE ES_C_PWM_OC_MODE_PWM2
#endif
#ifndef ES_DEVICE_NAME_AD16C4T0_PWM
#define ES_DEVICE_NAME_AD16C4T0_PWM "pwm0"
#endif
#endif
#ifndef ES_DEVICE_NAME_AD16C4T1_PWM
#define ES_DEVICE_NAME_AD16C4T1_PWM "pwm1"
#endif
#endif
#ifndef ES_DEVICE_NAME_GP32C4T0_PWM
#define ES_DEVICE_NAME_GP32C4T0_PWM "pwm2"
#endif
#endif
#ifndef ES_DEVICE_NAME_GP32C4T1_PWM
#define ES_DEVICE_NAME_GP32C4T1_PWM "pwm3"
#endif
#endif
#ifndef ES_DEVICE_NAME_GP16C4T0_PWM
#define ES_DEVICE_NAME_GP16C4T0_PWM "pwm4"
#endif
#endif
#ifndef ES_DEVICE_NAME_GP16C4T1_PWM
#define ES_DEVICE_NAME_GP16C4T1_PWM "pwm5"
#endif
#endif
#endif
bsp/essemi/es32f369x/drivers/ES/es_conf_info_rtc.h
浏览文件 @
3482bf86
...
...
@@ -38,6 +38,6 @@
#ifndef ES_DEVICE_NAME_RTC
#define ES_DEVICE_NAME_RTC "rtc"
#endif
#endif
#endif
bsp/essemi/es32f369x/drivers/ES/es_conf_info_select.h
浏览文件 @
3482bf86
...
...
@@ -27,7 +27,7 @@
#define ES_C_ENABLE 1
#define ES_C_DISABLE 0
/* codes_main */
...
...
@@ -36,7 +36,7 @@
#endif
#if ES_USE_ASSERT
#if ES_USE_ASSERT
#define USE_ASSERT
#endif
...
...
bsp/essemi/es32f369x/drivers/ES/es_conf_info_spi.h
浏览文件 @
3482bf86
...
...
@@ -42,7 +42,7 @@
_CONF_.max_hz = ES_SPI##_I_##_MAX_HZ; \
}while(0)
// spi_config.mode &= ~RT_SPI_SLAVE; /* 主机模式 */
// spi_config.mode &= ~RT_SPI_3WIRE; /* 4线,双向传输 */
// spi_config.mode |= RT_SPI_CPHA; /* 第二边沿采样 */
...
...
@@ -52,14 +52,14 @@
// spi_config.data_width = 8; /* 数据长度:8 */
// spi_config.max_hz = 2000000; /* 最快时钟频率 */
#define ES_C_SPI_CLK_POL_HIGH RT_SPI_CPOL
#define ES_C_SPI_CLK_POL_LOW !RT_SPI_CPOL
#define ES_C_SPI_CLK_PHA_FIRST !RT_SPI_CPHA
#define ES_C_SPI_CLK_POL_HIGH RT_SPI_CPOL
#define ES_C_SPI_CLK_POL_LOW !RT_SPI_CPOL
#define ES_C_SPI_CLK_PHA_FIRST !RT_SPI_CPHA
#define ES_C_SPI_CLK_PHA_SECOND RT_SPI_CPHA
#define ES_C_SPI_MSB RT_SPI_MSB
#define ES_C_SPI_LSB RT_SPI_LSB
#define ES_C_SPI_MSB RT_SPI_MSB
#define ES_C_SPI_LSB RT_SPI_LSB
#define ES_C_SPI_CS_LOW_LEVEL 0
#define ES_C_SPI_CS_HIGH_LEVEL 1
...
...
@@ -69,91 +69,91 @@
#ifndef ES_DEVICE_NAME_SPI0_BUS
#define ES_DEVICE_NAME_SPI0_BUS "spi0"
#endif
#endif
#ifndef ES_DEVICE_NAME_SPI0_DEV0
#define ES_DEVICE_NAME_SPI0_DEV0 "spi00"
#endif
#endif
#ifndef ES_DEVICE_NAME_SPI1_BUS
#define ES_DEVICE_NAME_SPI1_BUS "spi1"
#endif
#endif
#ifndef ES_DEVICE_NAME_SPI1_DEV0
#define ES_DEVICE_NAME_SPI1_DEV0 "spi10"
#endif
#endif
#ifndef ES_DEVICE_NAME_SPI2_BUS
#define ES_DEVICE_NAME_SPI2_BUS "spi2"
#endif
#endif
#ifndef ES_DEVICE_NAME_SPI2_DEV0
#define ES_DEVICE_NAME_SPI2_DEV0 "spi20"
#endif
#endif
#define ES_SPI_CS_LEVEL ES_C_SPI_CS_LOW_LEVEL
#ifndef ES_SPI0_CPHA_1_2
#ifndef ES_SPI0_CPHA_1_2
#define ES_SPI0_CPHA_1_2 ES_C_SPI_CLK_PHA_SECOND
#endif
#ifndef ES_SPI0_CPOL_H_L
#define ES_SPI0_CPOL_H_L ES_C_SPI_CLK_POL_HIGH
#endif
#endif
#ifndef ES_SPI0_CPOL_H_L
#define ES_SPI0_CPOL_H_L ES_C_SPI_CLK_POL_HIGH
#endif
#ifndef ES_SPI0_M_L_SB
#define ES_SPI0_M_L_SB RT_SPI_MSB
#define ES_SPI0_M_L_SB RT_SPI_MSB
#endif
#ifndef ES_SPI0_MAX_HZ
#ifndef ES_SPI0_MAX_HZ
#define ES_SPI0_MAX_HZ 2000000
#endif
#endif
#ifndef ES_SPI0_NSS_PIN
#define ES_SPI0_NSS_PIN 0xFFFFFFFF
#endif
#ifndef ES_SPI1_CPHA_1_2
#endif
#ifndef ES_SPI1_CPHA_1_2
#define ES_SPI1_CPHA_1_2 ES_C_SPI_CLK_PHA_SECOND
#endif
#ifndef ES_SPI1_CPOL_H_L
#define ES_SPI1_CPOL_H_L ES_C_SPI_CLK_POL_HIGH
#endif
#endif
#ifndef ES_SPI1_CPOL_H_L
#define ES_SPI1_CPOL_H_L ES_C_SPI_CLK_POL_HIGH
#endif
#ifndef ES_SPI1_M_L_SB
#define ES_SPI1_M_L_SB RT_SPI_MSB
#define ES_SPI1_M_L_SB RT_SPI_MSB
#endif
#ifndef ES_SPI1_MAX_HZ
#ifndef ES_SPI1_MAX_HZ
#define ES_SPI1_MAX_HZ 2000000
#endif
#endif
#ifndef ES_SPI1_NSS_PIN
#define ES_SPI1_NSS_PIN 0xFFFFFFFF
#endif
#ifndef ES_SPI2_CPHA_1_2
#endif
#ifndef ES_SPI2_CPHA_1_2
#define ES_SPI2_CPHA_1_2 ES_C_SPI_CLK_PHA_SECOND
#endif
#ifndef ES_SPI2_CPOL_H_L
#define ES_SPI2_CPOL_H_L ES_C_SPI_CLK_POL_HIGH
#endif
#endif
#ifndef ES_SPI2_CPOL_H_L
#define ES_SPI2_CPOL_H_L ES_C_SPI_CLK_POL_HIGH
#endif
#ifndef ES_SPI2_M_L_SB
#define ES_SPI2_M_L_SB RT_SPI_MSB
#endif
#ifndef ES_SPI2_MAX_HZ
#define ES_SPI2_M_L_SB RT_SPI_MSB
#endif
#ifndef ES_SPI2_MAX_HZ
#define ES_SPI2_MAX_HZ 2000000
#endif
#endif
#ifndef ES_SPI2_NSS_PIN
#define ES_SPI2_NSS_PIN 0xFFFFFFFF
#endif
#endif
#define ES_SPI0_MASTER_SLAVE !RT_SPI_SLAVE
#define ES_SPI0_WIRE_3_4 !RT_SPI_3WIRE
#define ES_SPI0_CS RT_SPI_NO_CS
#define ES_SPI0_DATA_W 8
#define ES_SPI1_MASTER_SLAVE !RT_SPI_SLAVE
#define ES_SPI1_WIRE_3_4 !RT_SPI_3WIRE
#define ES_SPI1_CS RT_SPI_NO_CS
#define ES_SPI1_DATA_W 8
#define ES_SPI2_MASTER_SLAVE !RT_SPI_SLAVE
#define ES_SPI2_WIRE_3_4 !RT_SPI_3WIRE
#define ES_SPI2_CS RT_SPI_NO_CS
#define ES_SPI2_DATA_W 8
#endif
bsp/essemi/es32f369x/drivers/ES/es_conf_info_uart.h
浏览文件 @
3482bf86
...
...
@@ -28,14 +28,14 @@
#include <ald_gpio.h>
#include <ald_uart.h>
#include <ald_cmu.h>
#define ES_C_UART_PARITY_NONE PARITY_NONE
#define ES_C_UART_PARITY_NONE PARITY_NONE
#define ES_C_UART_PARITY_ODD PARITY_ODD
#define ES_C_UART_PARITY_EVEN PARITY_EVEN
#define ES_C_UART_STOP_1 STOP_BITS_1
#define ES_C_UART_STOP_1 STOP_BITS_1
#define ES_C_UART_STOP_2 STOP_BITS_2
...
...
@@ -47,7 +47,7 @@
#ifndef ES_DEVICE_NAME_UART0
#define ES_DEVICE_NAME_UART0 "uart0"
#endif
#endif
#ifndef ES_DEVICE_NAME_UART1
#define ES_DEVICE_NAME_UART1 "uart1"
#endif
...
...
@@ -59,72 +59,72 @@
#endif
#ifndef ES_DEVICE_NAME_UART4
#define ES_DEVICE_NAME_UART4 "uart4"
#endif
#endif
#ifndef ES_DEVICE_NAME_UART5
#define ES_DEVICE_NAME_UART5 "uart5"
#endif
#ifndef ES_CONF_UART0_BAUD_RATE
#define ES_CONF_UART0_BAUD_RATE 115200
#define ES_CONF_UART0_BAUD_RATE 115200
#endif
#ifndef ES_CONF_UART0_PARITY
#define ES_CONF_UART0_PARITY ES_C_UART_PARITY_NONE
#endif
#ifndef ES_CONF_UART0_STOP_BITS
#define ES_CONF_UART0_STOP_BITS ES_C_UART_STOP_1
#endif
#endif
#ifndef ES_CONF_UART1_BAUD_RATE
#define ES_CONF_UART1_BAUD_RATE 115200
#define ES_CONF_UART1_BAUD_RATE 115200
#endif
#ifndef ES_CONF_UART1_PARITY
#define ES_CONF_UART1_PARITY ES_C_UART_PARITY_NONE
#endif
#ifndef ES_CONF_UART1_STOP_BITS
#define ES_CONF_UART1_STOP_BITS ES_C_UART_STOP_1
#endif
#endif
#ifndef ES_CONF_UART2_BAUD_RATE
#define ES_CONF_UART2_BAUD_RATE 115200
#define ES_CONF_UART2_BAUD_RATE 115200
#endif
#ifndef ES_CONF_UART2_PARITY
#define ES_CONF_UART2_PARITY ES_C_UART_PARITY_NONE
#endif
#ifndef ES_CONF_UART2_STOP_BITS
#define ES_CONF_UART2_STOP_BITS ES_C_UART_STOP_1
#endif
#endif
#ifndef ES_CONF_UART3_BAUD_RATE
#define ES_CONF_UART3_BAUD_RATE 115200
#define ES_CONF_UART3_BAUD_RATE 115200
#endif
#ifndef ES_CONF_UART3_PARITY
#define ES_CONF_UART3_PARITY ES_C_UART_PARITY_NONE
#endif
#ifndef ES_CONF_UART3_STOP_BITS
#define ES_CONF_UART3_STOP_BITS ES_C_UART_STOP_1
#endif
#endif
#ifndef ES_CONF_UART4_BAUD_RATE
#define ES_CONF_UART4_BAUD_RATE 115200
#define ES_CONF_UART4_BAUD_RATE 115200
#endif
#ifndef ES_CONF_UART4_PARITY
#define ES_CONF_UART4_PARITY ES_C_UART_PARITY_NONE
#endif
#ifndef ES_CONF_UART4_STOP_BITS
#define ES_CONF_UART4_STOP_BITS ES_C_UART_STOP_1
#endif
#endif
#ifndef ES_CONF_UART5_BAUD_RATE
#define ES_CONF_UART5_BAUD_RATE 115200
#define ES_CONF_UART5_BAUD_RATE 115200
#endif
#ifndef ES_CONF_UART5_PARITY
#define ES_CONF_UART5_PARITY ES_C_UART_PARITY_NONE
#endif
#ifndef ES_CONF_UART5_STOP_BITS
#define ES_CONF_UART5_STOP_BITS ES_C_UART_STOP_1
#endif
#endif
#define ES_UART0_CONFIG \
{ \
ES_CONF_UART0_BAUD_RATE, \
...
...
@@ -136,7 +136,7 @@
RT_SERIAL_RB_BUFSZ, \
0 \
}
#define ES_UART1_CONFIG \
{ \
...
...
@@ -149,8 +149,8 @@
RT_SERIAL_RB_BUFSZ, \
0 \
}
#define ES_UART2_CONFIG \
{ \
ES_CONF_UART2_BAUD_RATE, \
...
...
@@ -162,8 +162,8 @@
RT_SERIAL_RB_BUFSZ, \
0 \
}
#define ES_UART3_CONFIG \
{ \
ES_CONF_UART3_BAUD_RATE, \
...
...
@@ -188,8 +188,8 @@
RT_SERIAL_RB_BUFSZ, \
0 \
}
#define ES_UART5_CONFIG \
{ \
ES_CONF_UART5_BAUD_RATE, \
...
...
bsp/essemi/es32f369x/drivers/board.c
浏览文件 @
3482bf86
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
...
...
@@ -17,7 +17,7 @@
*
* Change Logs:
* Date Author Notes
* 2020-01-14 wangyq the first version
* 2020-01-14 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
@@ -54,59 +54,59 @@ void NVIC_Configuration(void)
*******************************************************************************/
void
SystemClock_Config
(
void
)
{
SYSCFG_UNLOCK
();
#if ES_CMU_LRC_EN
SYSCFG_UNLOCK
();
#if ES_CMU_LRC_EN
SET_BIT
(
CMU
->
CLKENR
,
CMU_CLKENR_LRCEN_MSK
);
#else
CLEAR_BIT
(
CMU
->
CLKENR
,
CMU_CLKENR_LRCEN_MSK
);
#endif
/*ES_CMU_LRC_EN*/
#if ES_CMU_LOSC_EN
#endif
/*ES_CMU_LRC_EN*/
#if ES_CMU_LOSC_EN
SET_BIT
(
CMU
->
CLKENR
,
CMU_CLKENR_LOSCEN_MSK
);
#else
CLEAR_BIT
(
CMU
->
CLKENR
,
CMU_CLKENR_LOSCEN_MSK
);
#endif
/*ES_CMU_LOSC_EN*/
#if ES_CMU_HRC_EN
#endif
/*ES_CMU_LOSC_EN*/
#if ES_CMU_HRC_EN
SET_BIT
(
CMU
->
CLKENR
,
CMU_CLKENR_HRCEN_MSK
);
#else
CLEAR_BIT
(
CMU
->
CLKENR
,
CMU_CLKENR_HRCEN_MSK
);
#endif
/*ES_CMU_HRC_EN*/
#if ES_CMU_HOSC_EN
#endif
/*ES_CMU_HRC_EN*/
#if ES_CMU_HOSC_EN
SET_BIT
(
CMU
->
CLKENR
,
CMU_CLKENR_HOSCEN_MSK
);
#else
CLEAR_BIT
(
CMU
->
CLKENR
,
CMU_CLKENR_HOSCEN_MSK
);
#endif
/*ES_CMU_HOSC_EN*/
#endif
/*ES_CMU_HOSC_EN*/
SYSCFG_LOCK
();
SYSCFG_LOCK
();
#if ES_CMU_PLL1_EN
#if ES_CMU_PLL1_EN
/*PLL的源必须是4M*/
ald_cmu_pll1_config
(
ES_PLL1_REFER_CLK
,
ES_PLL1_OUT_CLK
);
#if ES_CMU_PLL1_SAFE_EN
ald_cmu_pll_safe_config
(
ENABLE
);
#else
ald_cmu_pll_safe_config
(
DISABLE
);
#endif
#else
CLEAR_BIT
(
CMU
->
CLKENR
,
CMU_CLKENR_PLL1EN_MSK
);
#endif
/*ES_CMU_PLL1_EN*/
#endif
/*ES_CMU_PLL1_EN*/
ald_cmu_clock_config
(
ES_SYS_CLK_SOURSE
,
ES_SYS_CLK
);
ald_cmu_div_config
(
CMU_SYS
,
ES_CMU_SYS_DIV
);
ald_cmu_div_config
(
CMU_HCLK_1
,
ES_CMU_HCLK_1_DIV
);
ald_cmu_div_config
(
CMU_HCLK_2
,
ES_CMU_HCLK_2_DIV
);
ald_cmu_div_config
(
CMU_PCLK_1
,
ES_CMU_PCLK_1_DIV
);
ald_cmu_div_config
(
CMU_PCLK_2
,
ES_CMU_PCLK_2_DIV
);
ald_cmu_perh_clock_config
(
CMU_PERH_ALL
,
ENABLE
);
/*低功耗时钟使能*/
/*低功耗时钟使能*/
#ifdef RT_USING_PM
SYSCFG_UNLOCK
();
SET_BIT
(
CMU
->
LPENR
,
CMU_LPENR_LRCEN_MSK
);
...
...
@@ -115,7 +115,7 @@ void SystemClock_Config(void)
SET_BIT
(
CMU
->
LPENR
,
CMU_LPENR_HOSCEN_MSK
);
SYSCFG_LOCK
();
#endif
}
/*******************************************************************************
...
...
@@ -129,7 +129,7 @@ void SysTick_Configuration(void)
{
/* ticks = sysclk / RT_TICK_PER_SECOND */
SysTick_Config
(
ald_cmu_get_sys_clock
()
/
RT_TICK_PER_SECOND
);
__systick_interval
=
1
;
}
...
...
bsp/essemi/es32f369x/drivers/board.h
浏览文件 @
3482bf86
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
...
...
@@ -17,7 +17,7 @@
*
* Change Logs:
* Date Author Notes
* 2020-01-14 wangyq the first version
* 2020-01-14 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
bsp/essemi/es32f369x/drivers/bsp_driver_example/.gitignore
已删除
100644 → 0
浏览文件 @
421867f4
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
bsp/essemi/es32f369x/drivers/bsp_driver_example/README.md
已删除
100644 → 0
浏览文件 @
421867f4
# 外设驱动测试用例
## 1、介绍
这个软件包包含一些外设设备操作的例程。
### 1.1 例程说明
| 文件 | 说明 |
| ---------------- | ------------------------------- |
| adc_vol_sample.c | 使用 ADC 设备转换电压数据 |
| can_sample.c | 通过 CAN 设备发送一帧,并创建一个线程接收数据然后打印输出。 |
| hwtimer_sample.c | 使用 硬件定时器定时 |
| i2c_sample.c | 使用 i2c 设备进行读写 |
| pm.c | 反复进入不同程度的睡眠。 |
| led_blink_sample.c | 使用 pin 设备控制 LED 闪烁 |
| pin_beep_sample.c | 使用 pin 设备控制蜂鸣器 |
| pwm_led_sample.c | 使用 pwm 设备控制 LED 的亮度 |
| rtc_sample.c | 使用 rtc 设备设置年月日时分秒信息 |
| spi_sample.c | 使用 spi 设备进行读写 |
| uart_sample.c | 使用 serial 设备中断接收及轮询发送模式收发数据 |
### 1.2 依赖
依赖设备管理模块提供的设备驱动。
## 2、如何打开 外设驱动测试用例
使用 外设驱动测试用例 需要在 RT-Thread 的menuconfig中选择它,具体路径如下:
```
Hardware Driver Config --->
Peripheral Driver test example--->
```
## 3、使用 外设驱动测试用例
在打开 Peripheral Driver test example 后,当进行 BSP 编译时,选择的软件包相关源代码会被加入到 BSP 工程中进行编译。
## 4、注意事项
暂无。
## 5、联系方式 & 感谢
*
维护:
[
misonyo
](
https://github.com/misonyo
)
*
主页:https://github.com/RT-Thread-packages/peripheral-sample
bsp/essemi/es32f369x/drivers/bsp_driver_example/adc_vol_sample.c
已删除
100644 → 0
浏览文件 @
421867f4
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-29 misonyo first implementation.
*/
/*
* 程序清单: ADC 设备使用例程
* 例程导出了 adc_sample 命令到控制终端
* 命令调用格式:adc_sample
* 程序功能:通过 ADC 设备采样电压值并转换为数值。
* 示例代码参考电压为3.3V,转换位数为12位。
*/
#include <rtthread.h>
#include <rtdevice.h>
#ifdef RT_USING_ADC
#define ADC_DEV_NAME "adc0"
/* ADC 设备名称 */
#define ADC_DEV_CHANNEL 5
/* ADC 通道 5 PA1*/
#define REFER_VOLTAGE 330
/* 参考电压 3.3V,数据精度乘以100保留2位小数*/
#define CONVERT_BITS (1 << 12)
/* 转换位数为12位 */
static
int
adc_vol_sample
(
int
argc
,
char
*
argv
[])
{
rt_adc_device_t
adc_dev
;
rt_uint32_t
value
,
vol
;
rt_err_t
ret
=
RT_EOK
;
/* 查找设备 */
adc_dev
=
(
rt_adc_device_t
)
rt_device_find
(
ADC_DEV_NAME
);
if
(
adc_dev
==
RT_NULL
)
{
rt_kprintf
(
"adc sample run failed! can't find %s device!
\n
"
,
ADC_DEV_NAME
);
return
RT_ERROR
;
}
/* 使能设备 */
ret
=
rt_adc_enable
(
adc_dev
,
ADC_DEV_CHANNEL
);
/* 读取采样值 */
value
=
rt_adc_read
(
adc_dev
,
ADC_DEV_CHANNEL
);
rt_kprintf
(
"the value is :%d
\n
"
,
value
);
/* 转换为对应电压值 */
vol
=
value
*
REFER_VOLTAGE
/
CONVERT_BITS
;
rt_kprintf
(
"the voltage is :%d.%02d
\n
"
,
vol
/
100
,
vol
%
100
);
/* 关闭通道 */
ret
=
rt_adc_disable
(
adc_dev
,
ADC_DEV_CHANNEL
);
return
ret
;
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT
(
adc_vol_sample
,
adc
voltage
convert
sample
);
#endif
bsp/essemi/es32f369x/drivers/bsp_driver_example/can_sample.c
已删除
100644 → 0
浏览文件 @
421867f4
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-06-25 misonyo first implementation.
*/
/*
* 程序清单:这是一个 CAN 设备使用例程
* 例程导出了 can_sample 命令到控制终端
* 命令调用格式:can_sample can
* 命令解释:命令第二个参数是要使用的 CAN 设备名称,为空则使用默认的 CAN 设备
* 程序功能:通过 CAN 设备发送一帧,并创建一个线程接收数据然后打印输出。
*/
#include <rtthread.h>
#include "rtdevice.h"
#ifdef RT_USING_CAN
#define CAN_DEV_NAME "can0"
/* CAN 设备名称 */
static
struct
rt_semaphore
rx_sem
;
/* 用于接收消息的信号量 */
static
rt_device_t
can_dev
;
/* CAN 设备句柄 */
/* 接收数据回调函数 */
static
rt_err_t
can_rx_call
(
rt_device_t
dev
,
rt_size_t
size
)
{
/* CAN 接收到数据后产生中断,调用此回调函数,然后发送接收信号量 */
rt_sem_release
(
&
rx_sem
);
return
RT_EOK
;
}
static
void
can_rx_thread
(
void
*
parameter
)
{
int
i
;
struct
rt_can_msg
rxmsg
=
{
0
};
/* 设置接收回调函数 */
rt_device_set_rx_indicate
(
can_dev
,
can_rx_call
);
#ifdef RT_CAN_USING_HDR
rt_err_t
res
;
struct
rt_can_filter_item
items
[
5
]
=
{
RT_CAN_FILTER_ITEM_INIT
(
0x100
,
0
,
0
,
0
,
0x700
,
RT_NULL
,
RT_NULL
),
/* std,match ID:0x100~0x1ff,hdr为-1,设置默认过滤表 */
RT_CAN_FILTER_ITEM_INIT
(
0x300
,
0
,
0
,
0
,
0x700
,
RT_NULL
,
RT_NULL
),
/* std,match ID:0x300~0x3ff,hdr为-1 */
RT_CAN_FILTER_ITEM_INIT
(
0x211
,
0
,
0
,
0
,
0x7ff
,
RT_NULL
,
RT_NULL
),
/* std,match ID:0x211,hdr为-1 */
RT_CAN_FILTER_STD_INIT
(
0x486
,
RT_NULL
,
RT_NULL
),
/* std,match ID:0x486,hdr为-1 */
{
0x555
,
0
,
0
,
0
,
0x7ff
,
7
,}
/* std,match ID:0x555,hdr为7,指定设置7号过滤表 */
};
struct
rt_can_filter_config
cfg
=
{
5
,
1
,
items
};
/* 一共有5个过滤表 */
/* 设置硬件过滤表 */
res
=
rt_device_control
(
can_dev
,
RT_CAN_CMD_SET_FILTER
,
&
cfg
);
RT_ASSERT
(
res
==
RT_EOK
);
#endif
while
(
1
)
{
/* hdr值为-1,表示直接从uselist链表读取数据 */
rxmsg
.
hdr
=
-
1
;
/* 阻塞等待接收信号量 */
rt_sem_take
(
&
rx_sem
,
RT_WAITING_FOREVER
);
/* 从CAN读取一帧数据 */
rt_device_read
(
can_dev
,
0
,
&
rxmsg
,
sizeof
(
rxmsg
));
/* 打印数据ID及内容 */
rt_kprintf
(
"ID:%x "
,
rxmsg
.
id
);
for
(
i
=
0
;
i
<
8
;
i
++
)
{
rt_kprintf
(
"%2x "
,
rxmsg
.
data
[
i
]);
}
rt_kprintf
(
"
\n
"
);
}
}
int
can_sample
(
int
argc
,
char
*
argv
[])
{
struct
rt_can_msg
msg
=
{
0
};
rt_err_t
res
;
rt_size_t
size
;
rt_thread_t
thread
;
char
can_name
[
RT_NAME_MAX
];
if
(
argc
==
2
)
{
rt_strncpy
(
can_name
,
argv
[
1
],
RT_NAME_MAX
);
}
else
{
rt_strncpy
(
can_name
,
CAN_DEV_NAME
,
RT_NAME_MAX
);
}
can_dev
=
rt_device_find
(
can_name
);
if
(
!
can_dev
)
{
rt_kprintf
(
"find %s failed!
\n
"
,
can_name
);
return
RT_ERROR
;
}
/* 初始化CAN接收信号量 */
rt_sem_init
(
&
rx_sem
,
"rx_sem"
,
0
,
RT_IPC_FLAG_FIFO
);
/* 以中断接收及发送方式打开CAN设备 */
res
=
rt_device_open
(
can_dev
,
RT_DEVICE_FLAG_INT_TX
|
RT_DEVICE_FLAG_INT_RX
);
RT_ASSERT
(
res
==
RT_EOK
);
thread
=
rt_thread_create
(
"can_rx"
,
can_rx_thread
,
RT_NULL
,
1024
,
25
,
10
);
if
(
thread
!=
RT_NULL
)
{
rt_thread_startup
(
thread
);
}
else
{
rt_kprintf
(
"create can_rx thread failed!
\n
"
);
}
msg
.
id
=
0x78
;
/* ID为0x78 */
msg
.
ide
=
RT_CAN_STDID
;
/* 标准格式 */
msg
.
rtr
=
RT_CAN_DTR
;
/* 数据帧 */
msg
.
len
=
8
;
/* 数据长度为8 */
/* 待发送的8字节数据 */
msg
.
data
[
0
]
=
0x00
;
msg
.
data
[
1
]
=
0x11
;
msg
.
data
[
2
]
=
0x22
;
msg
.
data
[
3
]
=
0x33
;
msg
.
data
[
4
]
=
0x44
;
msg
.
data
[
5
]
=
0x55
;
msg
.
data
[
6
]
=
0x66
;
msg
.
data
[
7
]
=
0x77
;
/* 发送一帧CAN数据 */
size
=
rt_device_write
(
can_dev
,
0
,
&
msg
,
sizeof
(
msg
));
if
(
size
==
0
)
{
rt_kprintf
(
"can dev write data failed!
\n
"
);
}
return
res
;
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT
(
can_sample
,
can
device
sample
);
#endif
bsp/essemi/es32f369x/drivers/bsp_driver_example/hwtimer_sample.c
已删除
100644 → 0
浏览文件 @
421867f4
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-30 misonyo first implementation.
*/
/*
* 程序清单:这是一个 hwtimer 设备使用例程
* 例程导出了 hwtimer_sample 命令到控制终端
* 命令调用格式:hwtimer_sample
* 程序功能:硬件定时器超时回调函数周期性的打印当前tick值,2次tick值之差换算为时间等同于定时时间值。
*/
#include <rtthread.h>
#include <rtdevice.h>
#ifdef RT_USING_HWTIMER
#define HWTIMER_DEV_NAME "timer0"
/* 定时器名称 */
/* 定时器超时回调函数 */
static
rt_err_t
timeout_cb
(
rt_device_t
dev
,
rt_size_t
size
)
{
rt_kprintf
(
"tick is :%d !
\n
"
,
rt_tick_get
());
return
0
;
}
static
int
hwtimer_sample
(
int
argc
,
char
*
argv
[])
{
rt_err_t
ret
=
RT_EOK
;
rt_hwtimerval_t
timeout_s
;
/* 定时器超时值 */
rt_device_t
hw_dev
=
RT_NULL
;
/* 定时器设备句柄 */
rt_hwtimer_mode_t
mode
;
/* 定时器模式 */
/* 查找定时器设备 */
hw_dev
=
rt_device_find
(
HWTIMER_DEV_NAME
);
if
(
hw_dev
==
RT_NULL
)
{
rt_kprintf
(
"hwtimer sample run failed! can't find %s device!
\n
"
,
HWTIMER_DEV_NAME
);
return
RT_ERROR
;
}
/* 以读写方式打开设备 */
ret
=
rt_device_open
(
hw_dev
,
RT_DEVICE_OFLAG_RDWR
);
if
(
ret
!=
RT_EOK
)
{
rt_kprintf
(
"open %s device failed!
\n
"
,
HWTIMER_DEV_NAME
);
return
ret
;
}
/* 设置超时回调函数 */
rt_device_set_rx_indicate
(
hw_dev
,
timeout_cb
);
/* 设置模式为周期性定时器 */
mode
=
HWTIMER_MODE_PERIOD
;
ret
=
rt_device_control
(
hw_dev
,
HWTIMER_CTRL_MODE_SET
,
&
mode
);
if
(
ret
!=
RT_EOK
)
{
rt_kprintf
(
"set mode failed! ret is :%d
\n
"
,
ret
);
return
ret
;
}
/* 设置定时器超时值为5s并启动定时器 */
timeout_s
.
sec
=
5
;
/* 秒 */
timeout_s
.
usec
=
0
;
/* 微秒 */
if
(
rt_device_write
(
hw_dev
,
0
,
&
timeout_s
,
sizeof
(
timeout_s
))
!=
sizeof
(
timeout_s
))
{
rt_kprintf
(
"set timeout value failed
\n
"
);
return
RT_ERROR
;
}
/* 延时3500ms */
rt_thread_mdelay
(
3500
);
/* 读取定时器当前值 */
rt_device_read
(
hw_dev
,
0
,
&
timeout_s
,
sizeof
(
timeout_s
));
rt_kprintf
(
"Read: Sec = %d, Usec = %d
\n
"
,
timeout_s
.
sec
,
timeout_s
.
usec
);
return
ret
;
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT
(
hwtimer_sample
,
hwtimer
sample
);
#endif
bsp/essemi/es32f369x/drivers/bsp_driver_example/i2c_e2_sample.c
已删除
100644 → 0
浏览文件 @
421867f4
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Change Logs:
* Date Author Notes
* 2020-12-15 liuhy first implementation.
*/
/*
* 程序清单:这是一个 I2C 设备使用例程
* 例程导出了 i2c_e2_sample 命令到控制终端
* 命令调用格式:i2c_e2_sample
* 命令解释:使用默认的I2C总线设备i2c0
* 程序功能:通过 I2C 设备写读e2prom,ST24C04WP。
*/
/*ST24C04WP 有2个Block :Block0 的从机地址为:0x50,Block1 的从机地址为:0x51
一个Block有 256字节,一页16字节,写只可在一页内(超过一页的范围后,会回到页的开始),读无页限制*/
#include <rtthread.h>
#include <rtdevice.h>
#ifdef RT_USING_I2C
#define I2C_BUS_NAME "i2c0"
/*I2C总线设备名称 */
#define SLAVE_ADDR 0x50
/*从机地址*/
#define MEM_ADDR 0x00
/*从机的起始储存地址,范围:0x00到0xEF(例程写读范围:2页)*/
#define ADDR_LEN 1
/*定义从机储存地址的长度,默认8位,1字节*/
#define STR_LEN 16
/*接收发送的页数据长度 ,最大16*/
static
rt_uint8_t
mem_addr
,
rx_buffer
[
33
]
=
{
0U
};
/*读两页,需要32字节,字符串结束'\0'*/
/*第一个字节' '用来放 E2PROM 的内存地址,最后一个字节'\0'作为子串的结束,不存入e2prom*/
static
rt_uint8_t
tx_buffer1
[
STR_LEN
+
ADDR_LEN
+
1
]
=
" e2prom example !
\0
"
;
static
rt_uint8_t
tx_buffer2
[
STR_LEN
+
ADDR_LEN
+
1
]
=
" ABCDEFGH12345678
\0
"
;
static
void
i2c_e2_sample
(
int
argc
,
char
*
argv
[])
{
struct
rt_i2c_bus_device
*
i2c_bus
=
RT_NULL
;
/* I2C总线设备句柄 */
struct
rt_i2c_msg
i2c_msg
[
2
];
/* I2C消息 */
rt_size_t
s_stat
;
i2c_bus
=
(
struct
rt_i2c_bus_device
*
)
rt_device_find
(
I2C_BUS_NAME
);
/* 通过名字获取I2C总线设备的句柄 */
if
(
i2c_bus
==
RT_NULL
)
{
rt_kprintf
(
"can't find i2c device :%s !
\n
"
,
I2C_BUS_NAME
);
return
;
}
/*写T24C04WP
如果 (MEM_ADDR & 0x0F) + STR_LEN <= 16, 写的范围为:(MEM_ADDR , MEM_ADDR + STR_LEN )
(0x10 + MEM_ADDR , 0x10 + MEM_ADDR + STR_LEN )
如果 (MEM_ADDR & 0x0F) + STR_LEN > 16, 超出范围的部分会在页内循环写。*/
tx_buffer1
[
0
]
=
MEM_ADDR
;
/*初始化消息*/
i2c_msg
[
0
].
addr
=
SLAVE_ADDR
;
/* 从机地址 */
i2c_msg
[
0
].
len
=
ADDR_LEN
+
STR_LEN
;
/* 写入的长度,地址+数据 */
i2c_msg
[
0
].
buf
=
tx_buffer1
;
/* 待写入第一段数据 */
i2c_msg
[
0
].
flags
=
RT_I2C_WR
;
/* I2C写 */
s_stat
=
rt_i2c_transfer
(
i2c_bus
,
i2c_msg
,
1
);
/* 写入第一段数据 */
if
(
s_stat
==
1
)
rt_kprintf
(
"write successful.
\n
message: %s
\n
"
,
&
tx_buffer1
[
1
]);
else
rt_kprintf
(
"device %s write fail
\n
"
,
I2C_BUS_NAME
);
tx_buffer2
[
0
]
=
MEM_ADDR
+
0x10
;
/*加一页*/
i2c_msg
[
0
].
buf
=
tx_buffer2
;
/* 待写入第二段数据 */
s_stat
=
rt_i2c_transfer
(
i2c_bus
,
i2c_msg
,
1
);
/* 写入第二段数据 */
if
(
s_stat
==
1
)
rt_kprintf
(
"write successful.
\n
message: %s
\n
"
,
&
tx_buffer2
[
1
]);
else
rt_kprintf
(
"device %s write fail
\n
"
,
I2C_BUS_NAME
);
/*读T24C04WP 读2页的数据。读数据需要2条消息:第一条消息:发送读取的地址。
第二条消息:读取具体的数据。*/
mem_addr
=
MEM_ADDR
&
0xF0
;
/*从页的开始读*/
i2c_msg
[
0
].
len
=
ADDR_LEN
;
i2c_msg
[
0
].
buf
=
&
mem_addr
;
i2c_msg
[
1
].
addr
=
SLAVE_ADDR
;
/* 从机地址 */
i2c_msg
[
1
].
len
=
32
;
/* 读取的数据长度:2*16 */
i2c_msg
[
1
].
buf
=
rx_buffer
;
/* 数据存放地址 */
i2c_msg
[
1
].
flags
=
RT_I2C_RD
;
/* I2C读 */
s_stat
=
rt_i2c_transfer
(
i2c_bus
,
i2c_msg
,
2
);
/* 读已写的2页 */
if
(
s_stat
==
2
)
rt_kprintf
(
" read successful
\n
messege : %s
\n
"
,
rx_buffer
);
else
rt_kprintf
(
"read fail
\n
"
);
return
;
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT
(
i2c_e2_sample
,
i2c
e2prom
sample
);
#endif
bsp/essemi/es32f369x/drivers/bsp_driver_example/i2c_sample.c
已删除
100644 → 0
浏览文件 @
421867f4
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Change Logs:
* Date Author Notes
* 2020-12-15 liuhy first implementation.
*/
/*
* 程序清单:这是一个 I2C 设备使用例程
* 例程导出了 i2c_io_sample 命令到控制终端
* 命令调用格式:i2c_io_sample
* 命令解释:使用默认的I2C总线设备i2c0
* 程序功能:通过 I2C 设备接收数据并打印,然后将接收的字符加1输出。
*/
#include <rtthread.h>
#include <rtdevice.h>
#ifdef RT_USING_I2C
#define I2C_BUS_NAME "i2c0"
/* I2C总线设备名称 */
#define SLAVE_ADDR 0x2D
/* 从机地址 */
#define STR_LEN 16
/* 接收发送的数据长度 */
static
void
i2c_io_sample
(
int
argc
,
char
*
argv
[])
{
struct
rt_i2c_bus_device
*
i2c_bus
=
RT_NULL
;
/* I2C总线设备句柄 */
struct
rt_i2c_msg
temp_msg
;
/* I2C消息 */
rt_uint8_t
buffer
[
STR_LEN
]
=
{
0U
};
rt_uint32_t
i
,
num_msg
;
rt_size_t
s_stat
;
i2c_bus
=
(
struct
rt_i2c_bus_device
*
)
rt_device_find
(
I2C_BUS_NAME
);
/* 通过名字获取I2C总线设备的句柄 */
if
(
i2c_bus
==
RT_NULL
)
{
rt_kprintf
(
"can't find i2c device :%s !
\n
"
,
I2C_BUS_NAME
);
return
;
}
/*初始化消息*/
temp_msg
.
addr
=
SLAVE_ADDR
;
/* 从机地址 */
temp_msg
.
len
=
STR_LEN
;
/* 传输的数据长度 */
temp_msg
.
buf
=
buffer
;
/* 读写缓存器 */
num_msg
=
1
;
/* 传输一条消息 */
temp_msg
.
flags
=
RT_I2C_RD
;
/* I2C读 */
s_stat
=
rt_i2c_transfer
(
i2c_bus
,
&
temp_msg
,
num_msg
);
/* 传输消息 */
if
(
s_stat
==
num_msg
)
{
rt_kprintf
(
"receive successful.
\n
receive messege : %s
\n
:"
,
buffer
);
for
(
i
=
0
;
i
<
STR_LEN
;
i
++
)
rt_kprintf
(
" %x"
,(
unsigned
int
)
buffer
[
i
]);
rt_kprintf
(
"
\n
"
);
}
else
{
rt_kprintf
(
"device s% recieve fail
\n
buffer : s%
\n
"
,
I2C_BUS_NAME
,
buffer
);
return
;
}
for
(
i
=
0
;
i
<
STR_LEN
;
i
++
)
buffer
[
i
]
++
;
temp_msg
.
flags
=
RT_I2C_WR
;
/* I2C写 */
s_stat
=
rt_i2c_transfer
(
i2c_bus
,
&
temp_msg
,
num_msg
);
/* 传输一条 */
if
(
s_stat
==
num_msg
)
{
rt_kprintf
(
" send successful
\n
messege : %s
\n
:"
,
buffer
);
for
(
i
=
0
;
i
<
STR_LEN
;
i
++
)
rt_kprintf
(
" %x"
,(
unsigned
int
)
buffer
[
i
]);
rt_kprintf
(
"
\n
"
);
}
else
{
rt_kprintf
(
"device s% send fail
\n
"
,
I2C_BUS_NAME
);
return
;
}
return
;
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT
(
i2c_io_sample
,
i2c
io
sample
);
#endif
bsp/essemi/es32f369x/drivers/bsp_driver_example/led_blink_sample.c
已删除
100644 → 0
浏览文件 @
421867f4
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-09-25 misonyo first edition.
*/
/*
* 程序清单:这是一个通过PIN脚控制LED亮灭的使用例程
* 例程导出了 led_sample 命令到控制终端
* 命令调用格式:led_sample 41
* 命令解释:命令第二个参数是要使用的PIN脚编号,为空则使用例程默认的引脚编号。
* 程序功能:程序创建一个led线程,线程每隔1000ms改变PIN脚状态,达到控制led灯
* 亮灭的效果。
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <stdlib.h>
#include "drv_gpio.h"
/* PIN脚编号,查看驱动文件drv_gpio.c确定 */
#define LED_PIN_NUM GET_PIN( F , 1 )
static
int
pin_num
;
static
void
led_entry
(
void
*
parameter
)
{
int
count
=
0
;
/* 设置PIN脚模式为输出 */
rt_pin_mode
(
pin_num
,
PIN_MODE_OUTPUT
);
while
(
1
)
{
count
++
;
rt_kprintf
(
"thread run count : %d
\r\n
"
,
count
);
/* 拉低PIN脚 */
rt_pin_write
(
pin_num
,
PIN_LOW
);
rt_kprintf
(
"led on!
\r\n
"
);
/* 延时1000ms */
rt_thread_mdelay
(
1000
);
/* 拉高PIN脚 */
rt_pin_write
(
pin_num
,
PIN_HIGH
);
rt_kprintf
(
"led off!
\r\n
"
);
rt_thread_mdelay
(
1000
);
}
}
static
int
led_sample
(
int
argc
,
char
*
argv
[])
{
rt_thread_t
tid
;
rt_err_t
ret
=
RT_EOK
;
/* 判断命令行参数是否给定了PIN脚编号 */
if
(
argc
==
2
)
{
pin_num
=
atoi
(
argv
[
1
]);
}
else
{
pin_num
=
LED_PIN_NUM
;
}
tid
=
rt_thread_create
(
"led"
,
led_entry
,
RT_NULL
,
512
,
RT_THREAD_PRIORITY_MAX
/
3
,
20
);
if
(
tid
!=
RT_NULL
)
{
rt_thread_startup
(
tid
);
}
else
{
ret
=
RT_ERROR
;
}
return
ret
;
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT
(
led_sample
,
led
sample
);
bsp/essemi/es32f369x/drivers/bsp_driver_example/pin_beep_sample.c
已删除
100644 → 0
浏览文件 @
421867f4
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-08-15 misonyo first implementation.
*/
/*
* 程序清单:这是一个 PIN 设备使用例程
* 例程导出了 pin_beep_sample 命令到控制终端
* 命令调用格式:pin_beep_sample
* 程序功能:通过按键控制蜂鸣器对应引脚的电平状态控制蜂鸣器
*/
#include <rtthread.h>
#include <rtdevice.h>
#include "drv_gpio.h"
/* 引脚编号,通过查看驱动文件drv_gpio.c确定 */
#ifndef BEEP_PIN_NUM
#define BEEP_PIN_NUM GET_PIN( F , 1 )
#endif
#ifndef KEY0_PIN_NUM
#define KEY0_PIN_NUM GET_PIN( C , 11 )
#endif
#ifndef KEY1_PIN_NUM
#define KEY1_PIN_NUM GET_PIN( C , 12 )
#endif
void
beep_on
(
void
*
args
)
{
rt_kprintf
(
"turn on beep!
\n
"
);
rt_pin_write
(
BEEP_PIN_NUM
,
PIN_HIGH
);
}
void
beep_off
(
void
*
args
)
{
rt_kprintf
(
"turn off beep!
\n
"
);
rt_pin_write
(
BEEP_PIN_NUM
,
PIN_LOW
);
}
static
void
pin_beep_sample
(
void
)
{
/* 蜂鸣器引脚为输出模式 */
rt_pin_mode
(
BEEP_PIN_NUM
,
PIN_MODE_OUTPUT
);
/* 默认低电平 */
rt_pin_write
(
BEEP_PIN_NUM
,
PIN_LOW
);
/* 按键0引脚为输入模式 */
rt_pin_mode
(
KEY0_PIN_NUM
,
PIN_MODE_INPUT_PULLUP
);
/* 绑定中断,下降沿模式,回调函数名为beep_on */
rt_pin_attach_irq
(
KEY0_PIN_NUM
,
PIN_IRQ_MODE_FALLING
,
beep_on
,
RT_NULL
);
/* 使能中断 */
rt_pin_irq_enable
(
KEY0_PIN_NUM
,
PIN_IRQ_ENABLE
);
/* 按键1引脚为输入模式 */
rt_pin_mode
(
KEY1_PIN_NUM
,
PIN_MODE_INPUT_PULLUP
);
/* 绑定中断,下降沿模式,回调函数名为beep_off */
rt_pin_attach_irq
(
KEY1_PIN_NUM
,
PIN_IRQ_MODE_FALLING
,
beep_off
,
RT_NULL
);
/* 使能中断 */
rt_pin_irq_enable
(
KEY1_PIN_NUM
,
PIN_IRQ_ENABLE
);
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT
(
pin_beep_sample
,
pin
beep
sample
);
bsp/essemi/es32f369x/drivers/bsp_driver_example/pm_sample.c
已删除
100644 → 0
浏览文件 @
421867f4
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Change Logs:
* Date Author Notes
* 2020-12-15 liuhy first implementation.
*/
/*
* 程序清单:这是一个 pm睡眠唤醒的使用例程
* 例程导出了 pm_sample 命令到控制终端
* 命令调用格式:pm_sample
* 命令解释:进入不同的睡眠模式,然后用按键唤醒。
* 程序功能:通过串口输出字符串,告知进入睡眠和唤醒睡眠的情况。
* 注意:进入睡眠前,如果有中断挂起(SYSTICK、UART、EXTI等),睡眠将被瞬间唤醒。
*/
#include <rtthread.h>
#include <rtdevice.h>
#include "drv_pm.h"
#include "drv_gpio.h"
#ifdef RT_USING_PM
#define PM_NAME "pm"
/* 设备名称 */
#define WAKE_UP_PIN GET_PIN( C , 10 )
/* 唤醒源 */
#define SLEEP_TIMES 12
/* 进入睡眠次数,轮流进入不同的睡眠模式,包括无睡眠模式 */
/*部分芯片进入深度睡眠后,部分外设的部分寄存器可能会丢失*/
#define SAVE_REG UART0
#define SAVE_REG_TYPE UART_TypeDef
struct
pm_callback_t
{
volatile
int
in_fun_times
;
/*进入函数的次数*/
volatile
char
flag
;
/*标志*/
volatile
int
mode
;
/*需要打印的模式*/
};
volatile
struct
pm_callback_t
g_pm_data
;
uint32_t
save_load_mem
[
1024
]
__attribute__
((
aligned
(
4
)));
/*备份的空间*/
/*进入睡眠前,睡眠唤醒后,都会进入。*/
/*函数打印睡眠相关的信息*/
void
sleep_in_out_callback
(
rt_uint8_t
event
,
rt_uint8_t
mode
,
void
*
data
)
{
/*没有标志,不处理*/
if
(
!
(
g_pm_data
.
flag
))
{
return
;
}
/*标志不正常,清空标志*/
if
((
g_pm_data
.
flag
)
>
2
)
{
(
g_pm_data
.
flag
)
=
0
;
return
;
}
/*模式不匹配*/
if
(
g_pm_data
.
mode
!=
mode
)
{
return
;
}
/*进入的事件*/
switch
(
event
)
{
/*进入睡眠前*/
case
RT_PM_ENTER_SLEEP
:
g_pm_data
.
flag
=
1
;
rt_kprintf
(
"
\n\r
##%d : ENTER "
,
g_pm_data
.
in_fun_times
);
/*进入深度睡眠后,部分外设的部分寄存器可能会丢失*/
save_register
(
SAVE_REG
,
sizeof
(
SAVE_REG_TYPE
),
save_load_mem
);
/*备份寄存器的值*/
g_pm_data
.
in_fun_times
++
;
/*进入睡眠次数+1*/
break
;
/*睡眠唤醒后*/
case
RT_PM_EXIT_SLEEP
:
g_pm_data
.
flag
=
0
;
/*睡眠唤醒后*/
load_register
(
SAVE_REG
,
sizeof
(
SAVE_REG_TYPE
),
save_load_mem
);
/*还原寄存器的值*/
rt_kprintf
(
"
\n\r
EXIT
\n\r
"
);
rt_pm_request
(
PM_SLEEP_MODE_NONE
);
/*进无休眠模式*/
return
;
default:
break
;
};
/*当前的睡眠模式*/
switch
(
mode
)
{
case
PM_SLEEP_MODE_NONE
:
rt_kprintf
(
"PM_SLEEP_MODE_NONE
\n\r
"
);
break
;
case
PM_SLEEP_MODE_IDLE
:
rt_kprintf
(
"PM_SLEEP_MODE_IDLE
\n\r
"
);
break
;
case
PM_SLEEP_MODE_LIGHT
:
rt_kprintf
(
"PM_SLEEP_MODE_LIGHT
\n\r
"
);
break
;
case
PM_SLEEP_MODE_DEEP
:
rt_kprintf
(
"PM_SLEEP_MODE_DEEP
\n\r
"
);
break
;
case
PM_SLEEP_MODE_STANDBY
:
rt_kprintf
(
"PM_SLEEP_MODE_STANDBY
\n\r
"
);
break
;
case
PM_SLEEP_MODE_SHUTDOWN
:
rt_kprintf
(
"PM_SLEEP_MODE_SHUTDOWN
\n\r
"
);
break
;
case
PM_SLEEP_MODE_MAX
:
rt_kprintf
(
"PM_SLEEP_MODE_MAX
\n\r
"
);
break
;
default:
break
;
}
}
/* pm测试函数 */
static
void
pm_test
(
void
*
parameter
)
{
int
in_mode
[
7
],
i
=
0
;
g_pm_data
.
in_fun_times
=
0
;
g_pm_data
.
flag
=
0
;
in_mode
[
0
]
=
PM_SLEEP_MODE_NONE
;
in_mode
[
1
]
=
PM_SLEEP_MODE_IDLE
;
in_mode
[
2
]
=
PM_SLEEP_MODE_LIGHT
;
in_mode
[
3
]
=
PM_SLEEP_MODE_DEEP
;
in_mode
[
4
]
=
PM_SLEEP_MODE_STANDBY
;
in_mode
[
5
]
=
PM_SLEEP_MODE_SHUTDOWN
;
in_mode
[
6
]
=
PM_SLEEP_MODE_MAX
;
/*设置回调函数和私有数据*/
rt_pm_notify_set
(
sleep_in_out_callback
,
RT_NULL
);
while
(
i
<
SLEEP_TIMES
)
{
g_pm_data
.
mode
=
in_mode
[
i
%
6
];
/*无休眠模式,不赋予标志*/
if
(
g_pm_data
.
mode
!=
PM_SLEEP_MODE_NONE
)
{
g_pm_data
.
flag
=
2
;
}
/*彻底释放无休眠模式*/
rt_pm_release_all
(
PM_SLEEP_MODE_NONE
);
/*请求选择的休眠模式*/
rt_pm_request
(
in_mode
[
i
%
6
]);
rt_thread_mdelay
(
500
);
/*无休眠模式,不需要额外的等待*/
while
((
g_pm_data
.
flag
!=
0
)
&&
(
g_pm_data
.
mode
!=
PM_SLEEP_MODE_NONE
))
{
rt_thread_mdelay
(
500
);
}
/*释放选择的休眠模式 ,彻底释放*/
rt_pm_release_all
(
in_mode
[
i
%
6
]);
i
++
;
}
/*切换为无睡眠模式*/
rt_pm_request
(
PM_SLEEP_MODE_NONE
);
/*清除回调函数和私有数据*/
rt_pm_notify_set
(
RT_NULL
,
RT_NULL
);
rt_kprintf
(
"thread pm_test close
\n\r
"
);
}
/*按键唤醒的回调函数*/
void
wake_by_pin
(
void
*
args
)
{
}
static
int
pm_sample
(
int
argc
,
char
*
argv
[])
{
rt_thread_t
thread
;
/* 按键引脚为输入模式 */
rt_pin_mode
(
WAKE_UP_PIN
,
PIN_MODE_INPUT_PULLUP
);
/* 绑定中断,下降沿模式,回调函数名为wake_by_pin */
rt_pin_attach_irq
(
WAKE_UP_PIN
,
PIN_IRQ_MODE_RISING
,
wake_by_pin
,
RT_NULL
);
/* 使能中断 */
rt_pin_irq_enable
(
WAKE_UP_PIN
,
PIN_IRQ_ENABLE
);
thread
=
rt_thread_create
(
"pm_test"
,
pm_test
,
RT_NULL
,
1024
,
25
,
10
);
if
(
thread
!=
RT_NULL
)
{
rt_thread_startup
(
thread
);
}
else
{
rt_kprintf
(
"create pm_test thread failed!
\n\r
"
);
}
return
RT_EOK
;
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT
(
pm_sample
,
pm
sample
);
#endif
bsp/essemi/es32f369x/drivers/bsp_driver_example/pwm_led_sample.c
已删除
100644 → 0
浏览文件 @
421867f4
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-25 misonyo first implementation.
*/
/*
* 程序清单:这是一个 PWM 设备使用例程
* 例程导出了 pwm_led_sample 命令到控制终端
* 命令调用格式:pwm_led_sample
* 程序功能:通过 PWM 设备控制 LED 灯的亮度,可以看到LED不停的由暗变到亮,然后又从亮变到暗。
*/
#include <rtthread.h>
#include <rtdevice.h>
#include "drv_gpio.h"
#ifdef RT_USING_PWM
#define LED_PIN_NUM GET_PIN( C , 6 )
/* LED PIN脚编号,查看驱动文件drv_gpio.c确定 */
#define PWM_DEV_NAME "pwm1"
/* PWM设备名称 */
#define PWM_DEV_CHANNEL 1
/* PWM通道 */
struct
rt_device_pwm
*
pwm_dev
;
/* PWM设备句柄 */
static
int
pwm_led_sample
(
int
argc
,
char
*
argv
[])
{
rt_uint32_t
period
,
pulse
,
dir
;
period
=
500000
;
/* 周期为0.5ms,单位为纳秒ns */
dir
=
1
;
/* PWM脉冲宽度值的增减方向 */
pulse
=
0
;
/* PWM脉冲宽度值,单位为纳秒ns */
/* 查找设备 */
pwm_dev
=
(
struct
rt_device_pwm
*
)
rt_device_find
(
PWM_DEV_NAME
);
if
(
pwm_dev
==
RT_NULL
)
{
rt_kprintf
(
"pwm sample run failed! can't find %s device!
\n
"
,
PWM_DEV_NAME
);
return
RT_ERROR
;
}
/* 设置PWM周期和脉冲宽度默认值 */
rt_pwm_set
(
pwm_dev
,
PWM_DEV_CHANNEL
,
period
,
pulse
);
/* 使能设备 */
rt_pwm_enable
(
pwm_dev
,
PWM_DEV_CHANNEL
);
while
(
1
)
{
rt_thread_mdelay
(
50
);
if
(
dir
)
{
pulse
+=
5000
;
/* 从0值开始每次增加5000ns */
}
else
{
pulse
-=
5000
;
/* 从最大值开始每次减少5000ns */
}
if
(
pulse
>=
period
)
{
dir
=
0
;
}
if
(
0
==
pulse
)
{
dir
=
1
;
}
/* 设置PWM周期和脉冲宽度 */
rt_pwm_set
(
pwm_dev
,
PWM_DEV_CHANNEL
,
period
,
pulse
);
}
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT
(
pwm_led_sample
,
pwm
sample
);
#endif
bsp/essemi/es32f369x/drivers/bsp_driver_example/rtc_sample.c
已删除
100644 → 0
浏览文件 @
421867f4
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-30 misonyo first implementation.
*/
/*
* 程序清单:这是一个 RTC 设备使用例程
* 例程导出了 rtc_sample 命令到控制终端
* 命令调用格式:rtc_sample
* 程序功能:设置RTC设备的日期和时间,延时一段时间后获取当前时间并打印显示。
*/
#include <rtthread.h>
#include <rtdevice.h>
#ifdef RT_USING_RTC
static
int
rtc_sample
(
int
argc
,
char
*
argv
[])
{
rt_err_t
ret
=
RT_EOK
;
time_t
now
;
/* 设置日期 */
ret
=
set_date
(
2018
,
12
,
3
);
if
(
ret
!=
RT_EOK
)
{
rt_kprintf
(
"set RTC date failed
\n
"
);
return
ret
;
}
/* 设置时间 */
ret
=
set_time
(
11
,
15
,
50
);
if
(
ret
!=
RT_EOK
)
{
rt_kprintf
(
"set RTC time failed
\n
"
);
return
ret
;
}
/* 延时3秒 */
rt_thread_mdelay
(
3000
);
/* 获取时间 */
now
=
time
(
RT_NULL
);
rt_kprintf
(
"%s
\n
"
,
ctime
(
&
now
));
return
ret
;
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT
(
rtc_sample
,
rtc
sample
);
#endif
bsp/essemi/es32f369x/drivers/bsp_driver_example/spi_sample.c
已删除
100644 → 0
浏览文件 @
421867f4
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Change Logs:
* Date Author Notes
* 2020-12-15 liuhy first implementation.
*/
/*
* 程序清单:这是一个 SPI 设备使用例程
* 例程导出了 spi_io_sample 命令到控制终端
* 命令调用格式:spi_io_sample
* 程序功能:通过SPI设备先读取数据,然后每个字符加1后输出。
*/
#include <rtthread.h>
#include <rtdevice.h>
#ifdef RT_USING_SPI
#define SPI_DEVICE_NAME "spi00"
#define BUF_LEN 16
static
void
spi_io_sample
(
int
argc
,
char
*
argv
[])
{
struct
rt_spi_device
*
spi_dev
;
/* spi设备的句柄 */
rt_uint8_t
i
,
buffer
[
BUF_LEN
]
=
{
0U
};
rt_err_t
s_stat
;
rt_err_t
result
;
/* 查找 spi设备 获取spi设备句柄 */
spi_dev
=
(
struct
rt_spi_device
*
)
rt_device_find
(
SPI_DEVICE_NAME
);
if
(
spi_dev
==
RT_NULL
)
{
rt_kprintf
(
"spi sample run failed! can't find %s device!
\n
"
,
SPI_DEVICE_NAME
);
return
;
}
/* 配置SPI设备 */
s_stat
=
rt_spi_configure
(
spi_dev
,
&
(
spi_dev
->
config
));
if
(
s_stat
!=
RT_EOK
)
{
rt_kprintf
(
" spi config fail !
\n
"
);
return
;
}
/* 获取总线 ,防止总线被多个线程同时使用 */
result
=
rt_spi_take_bus
(
spi_dev
);
if
(
result
!=
RT_EOK
)
{
rt_kprintf
(
" %s take spi bus failed!
\n
"
,
SPI_DEVICE_NAME
);
return
;
}
/* 选中片选 */
result
=
rt_spi_take
(
spi_dev
);
if
(
result
!=
RT_EOK
)
{
rt_kprintf
(
" %s take spi cs failed!
\n
"
,
SPI_DEVICE_NAME
);
return
;
}
/*接收一次数据*/
result
=
rt_spi_recv
(
spi_dev
,
buffer
,
BUF_LEN
);
if
(
result
!=
BUF_LEN
)
{
rt_kprintf
(
"receive fail.
\n
buffer is : %s
\n
:"
,
buffer
);
for
(
i
=
0
;
i
<
BUF_LEN
;
i
++
)
rt_kprintf
(
" %x"
,(
unsigned
int
)
buffer
[
i
]);
rt_kprintf
(
"
\n
"
);
return
;
}
rt_kprintf
(
"receive successful.
\n
buffer is : %s
\n
:"
,
buffer
);
for
(
i
=
0
;
i
<
BUF_LEN
;
i
++
)
rt_kprintf
(
" %x"
,(
unsigned
int
)
buffer
[
i
]);
rt_kprintf
(
"
\n
"
);
/* 将接收到的数据加1 */
for
(
i
=
0
;
i
<
BUF_LEN
;
i
++
)
buffer
[
i
]
++
;
/*发送数据*/
result
=
rt_spi_send
(
spi_dev
,
buffer
,
BUF_LEN
);
if
(
result
!=
BUF_LEN
)
{
rt_kprintf
(
"send fail.
\n
buffer is : %s
\n
:"
,
buffer
);
for
(
i
=
0
;
i
<
BUF_LEN
;
i
++
)
rt_kprintf
(
" %x"
,(
unsigned
int
)
buffer
[
i
]);
rt_kprintf
(
"
\n
"
);
return
;
}
rt_kprintf
(
"send successful.
\n
buffer is : %s
\n
:"
,
buffer
);
for
(
i
=
0
;
i
<
BUF_LEN
;
i
++
)
rt_kprintf
(
" %x"
,(
unsigned
int
)
buffer
[
i
]);
rt_kprintf
(
"
\n
"
);
/* 释放片选 */
result
=
rt_spi_release
(
spi_dev
);
if
(
result
!=
RT_EOK
)
{
rt_kprintf
(
" %s release spi cs failed!
\n
"
,
SPI_DEVICE_NAME
);
return
;
}
/* 释放总线 */
result
=
rt_spi_release_bus
(
spi_dev
);
if
(
result
!=
RT_EOK
)
{
rt_kprintf
(
" %s release spi bus failed!
\n
"
,
SPI_DEVICE_NAME
);
return
;
}
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT
(
spi_io_sample
,
spi
sample
);
#endif
bsp/essemi/es32f369x/drivers/bsp_driver_example/uart_sample.c
已删除
100644 → 0
浏览文件 @
421867f4
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-08-15 misonyo first implementation.
*/
/*
* 程序清单:这是一个 串口 设备使用例程
* 例程导出了 uart_sample 命令到控制终端
* 命令调用格式:uart_sample uart2
* 命令解释:命令第二个参数是要使用的串口设备名称,为空则使用默认的串口设备
* 程序功能:通过串口输出字符串"hello RT-Thread!",然后根据例子类型,处理输入数据,然后输出
*/
#include <rtthread.h>
/* UART_SAMPLE_TYPE = 1,错位输出
= 2 接收到固定格式之后输出
*/
#define UART_SAMPLE_TYPE 1
#if (UART_SAMPLE_TYPE == 2)
#define SAMPLE_UART_RXBUF_SIZE 256
/* 接收缓存大小 */
#define SAMPLE_UART_END_SRTING "\r\n"
/* 结尾固定格式 */
#endif
#define SAMPLE_UART_NAME "uart1"
/* 串口设备名称 */
/* 用于接收消息的信号量 */
static
struct
rt_semaphore
rx_sem
;
static
rt_device_t
serial
;
/* 接收数据回调函数 */
static
rt_err_t
uart_input
(
rt_device_t
dev
,
rt_size_t
size
)
{
/* 串口接收到数据后产生中断,调用此回调函数,然后发送接收信号量 */
rt_sem_release
(
&
rx_sem
);
return
RT_EOK
;
}
static
void
serial_thread_entry
(
void
*
parameter
)
{
#if (UART_SAMPLE_TYPE == 1)
char
ch
;
while
(
1
)
{
/* 从串口读取一个字节的数据,没有读取到则等待接收信号量 */
while
(
rt_device_read
(
serial
,
-
1
,
&
ch
,
1
)
!=
1
)
{
/* 阻塞等待接收信号量,等到信号量后再次读取数据 */
rt_sem_take
(
&
rx_sem
,
RT_WAITING_FOREVER
);
}
/* 读取到的数据通过串口错位输出 */
ch
=
ch
+
1
;
rt_device_write
(
serial
,
0
,
&
ch
,
1
);
}
#endif
#if (UART_SAMPLE_TYPE == 2)
char
rx_buf
[
SAMPLE_UART_RXBUF_SIZE
],
*
end
=
SAMPLE_UART_END_SRTING
;
/*rx_buf[]:接收缓存,可修改大小 end[]:固定的结束格式(可修改,不可包含'\0')*/
uint32_t
rx_index
=
0
;
/*接收数据的索引 */
uint32_t
end_len
=
rt_strlen
(
end
);
/*固定的结束格式的长度*/
while
(
1
)
{
/* 从串口读取一个字节的数据,没有读取到则等待接收信号量 */
while
(
rt_device_read
(
serial
,
-
1
,
(
rx_buf
+
rx_index
),
1
)
!=
1
)
{
/* 阻塞等待接收信号量,等到信号量后再次读取数据 */
rt_sem_take
(
&
rx_sem
,
RT_WAITING_FOREVER
);
}
rx_index
++
;
if
(
rx_index
>=
SAMPLE_UART_RXBUF_SIZE
)
{
rt_kprintf
(
"rx_buf over!
\r\n
"
);
/*范围越界*/
}
/*判断是否固定的结尾格式*/
if
((
rx_index
>=
end_len
)
&&
\
((
rt_strncmp
(
end
,(
rx_buf
+
rx_index
-
end_len
),
end_len
))
==
0
))
{
rt_device_write
(
serial
,
0
,
rx_buf
,
rx_index
);
rx_index
=
0
;
}
}
#endif
}
static
int
uart_sample
(
int
argc
,
char
*
argv
[])
{
rt_err_t
ret
=
RT_EOK
;
char
uart_name
[
RT_NAME_MAX
];
char
str
[]
=
"hello RT-Thread!
\r\n
"
;
if
(
argc
==
2
)
{
rt_strncpy
(
uart_name
,
argv
[
1
],
RT_NAME_MAX
);
}
else
{
rt_strncpy
(
uart_name
,
SAMPLE_UART_NAME
,
RT_NAME_MAX
);
}
/* 查找串口设备 */
serial
=
rt_device_find
(
uart_name
);
if
(
!
serial
)
{
rt_kprintf
(
"find %s failed!
\n
"
,
uart_name
);
return
RT_ERROR
;
}
/* 初始化信号量 */
rt_sem_init
(
&
rx_sem
,
"rx_sem"
,
0
,
RT_IPC_FLAG_FIFO
);
/* 以中断接收及轮询发送方式打开串口设备 */
rt_device_open
(
serial
,
RT_DEVICE_FLAG_INT_RX
);
/* 设置接收回调函数 */
rt_device_set_rx_indicate
(
serial
,
uart_input
);
/* 发送字符串 */
rt_device_write
(
serial
,
0
,
str
,
(
sizeof
(
str
)
-
1
));
/* 创建 serial 线程 */
rt_thread_t
thread
=
rt_thread_create
(
"serial"
,
serial_thread_entry
,
RT_NULL
,
1024
,
25
,
10
);
/* 创建成功则启动线程 */
if
(
thread
!=
RT_NULL
)
{
rt_thread_startup
(
thread
);
}
else
{
ret
=
RT_ERROR
;
}
return
ret
;
}
/* 导出到 msh 命令列表中 */
MSH_CMD_EXPORT
(
uart_sample
,
uart
device
sample
);
bsp/essemi/es32f369x/drivers/drv_adc.c
浏览文件 @
3482bf86
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
...
...
@@ -18,7 +18,7 @@
* Change Logs:
* Date Author Notes
* 2019-04-03 wangyq the first version
* 2019-11-01 wangyq update libraries
* 2019-11-01 wangyq update libraries
* 2021-04-20 liuhy the second version
*/
...
...
@@ -26,7 +26,7 @@
#include <rtthread.h>
#include <rtdevice.h>
#include "board.h"
#include "drv_adc.h"
#include "drv_adc.h"
#ifdef RT_USING_ADC
...
...
@@ -35,7 +35,7 @@
#ifdef BSP_USING_ADC0
static
struct
rt_adc_device
_device_adc0
;
#endif
/*BSP_USING_ADC0*/
#ifdef BSP_USING_ADC1
static
struct
rt_adc_device
_device_adc1
;
#endif
/*BSP_USING_ADC1*/
...
...
@@ -66,8 +66,8 @@ static adc_channel_t es32f3_adc_get_channel(rt_uint32_t channel)
/* Initialize ADC pin */
gpio_initstruct
.
mode
=
GPIO_MODE_INPUT
;
gpio_initstruct
.
pupd
=
GPIO_FLOATING
;
gpio_initstruct
.
odos
=
GPIO_OPEN_DRAIN
;
gpio_initstruct
.
pupd
=
GPIO_FLOATING
;
gpio_initstruct
.
odos
=
GPIO_OPEN_DRAIN
;
gpio_initstruct
.
podrv
=
GPIO_OUT_DRIVE_6
;
gpio_initstruct
.
nodrv
=
GPIO_OUT_DRIVE_6
;
gpio_initstruct
.
flt
=
GPIO_FILTER_DISABLE
;
...
...
@@ -141,7 +141,7 @@ static adc_channel_t es32f3_adc_get_channel(rt_uint32_t channel)
es32f3_channel
=
ADC_CHANNEL_15
;
ald_gpio_init
(
ES_GPIO_ADC_CH15_GPIO
,
ES_GPIO_ADC_CH15_PIN
,
&
gpio_initstruct
);
break
;
default:
break
;
}
...
...
@@ -191,40 +191,40 @@ int rt_hw_adc_init(void)
_h_adc
.
init
.
nche_sel
=
ADC_NCHESEL_MODE_ALL
;
_h_adc
.
init
.
cont
=
DISABLE
;
_h_adc
.
init
.
n_ref
=
ADC_NEG_REF_VSS
;
_h_adc
.
init
.
p_ref
=
ADC_POS_REF_VDD
;
_h_adc
.
init
.
p_ref
=
ADC_POS_REF_VDD
;
#ifdef BSP_USING_ADC0
static
adc_handle_t
_h_adc0
;
_h_adc0
.
init
=
_h_adc
.
init
;
_h_adc0
.
perh
=
ADC0
;
_h_adc0
.
init
.
align
=
ES_ADC0_ALIGN
;
_h_adc0
.
init
.
data_bit
=
ES_ADC0_DATA_BIT
;
_h_adc0
.
init
.
div
=
ES_ADC0_CLK_DIV
;
ald_adc_init
(
&
_h_adc0
);
rt_hw_adc_register
(
&
_device_adc0
,
ES_DEVICE_NAME_ADC0
,
&
es32f3_adc_ops
,
&
_h_adc0
);
#endif
/*BSP_USING_ADC0*/
#ifdef BSP_USING_ADC1
#ifdef BSP_USING_ADC1
static
adc_handle_t
_h_adc1
;
_h_adc1
.
init
=
_h_adc
.
init
;
_h_adc1
.
perh
=
ADC1
;
_h_adc1
.
init
.
align
=
ES_ADC1_ALIGN
;
_h_adc1
.
init
.
data_bit
=
ES_ADC1_DATA_BIT
;
_h_adc1
.
init
.
div
=
ES_ADC1_CLK_DIV
;
ald_adc_init
(
&
_h_adc1
);
rt_hw_adc_register
(
&
_device_adc1
,
ES_DEVICE_NAME_ADC1
,
&
es32f3_adc_ops
,
&
_h_adc1
);
#endif
/*BSP_USING_ADC1*/
return
result
;
}
...
...
bsp/essemi/es32f369x/drivers/drv_adc.h
浏览文件 @
3482bf86
...
...
@@ -17,7 +17,7 @@
*
* Change Logs:
* Date Author Notes
* 2019-04-03 wangyq the first version
* 2019-04-03 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
bsp/essemi/es32f369x/drivers/drv_can.c
浏览文件 @
3482bf86
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
...
...
@@ -17,7 +17,7 @@
*
* Change Logs:
* Date Author Notes
* 2020-01-14 wangyq the first version
* 2020-01-14 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
@@ -29,26 +29,26 @@ static struct es32f3_can can;
static
rt_uint32_t
get_can_baud_index
(
rt_uint32_t
baud
,
can_init_t
*
init
)
{
{
/* attention !!! baud calculation example: Pclk / ((1 + seg1 + seg2) * psc) Pclk=48 / ((1 + seg1=3 + seg2=2) * 8) = 1MHz */
double
target
,
temp
,
min
;
uint32_t
i
,
j
,
j_max
,
near
=
0
;
target
=
(
double
)(
ald_cmu_get_pclk1_clock
());
target
/=
baud
;
/*计算误差1*/
min
=
0xFFFFFFFF
;
for
(
i
=
1
+
16
+
8
;
i
>
2
;
i
--
)
/*SYNC_SEG + SEG1 + SEG2*/
{
j_max
=
target
/
i
/
(
0
.
98
)
+
1
;
/*缩小范围*/
j_max
=
(
j_max
>
1024
)
?
(
1024
)
:
(
j_max
);
for
(
j
=
target
/
i
/
1
.
02
;
j
<
j_max
;
j
++
)
{
{
temp
=
target
/
i
/
j
;
/*计算误差2*/
temp
=
(
temp
>
1
)
?
(
temp
-
1
)
:
(
1
-
temp
);
temp
+=
((
1
.
0
*
i
*
j
)
/
0xFFFFFFFF
)
;
temp
+=
((
1
.
0
*
i
*
j
)
/
0xFFFFFFFF
)
;
if
(
temp
<
min
)
{
if
(
temp
>
0
.
000001
)
...
...
@@ -56,12 +56,12 @@ static rt_uint32_t get_can_baud_index(rt_uint32_t baud,can_init_t * init)
near
=
(
i
<<
16
)
+
j
;
min
=
temp
;
}
else
else
{
init
->
seg1
=
(
can_seg1_t
)((
i
-
1
)
*
2
/
3
-
1
);
init
->
seg2
=
(
can_seg2_t
)(
i
-
init
->
seg1
-
1
-
1
-
1
);
init
->
psc
=
j
;
return
0
;
}
}
...
...
@@ -75,15 +75,15 @@ static rt_uint32_t get_can_baud_index(rt_uint32_t baud,can_init_t * init)
init
->
seg1
=
(
can_seg1_t
)((
i
-
1
)
*
2
/
3
-
1
);
init
->
seg2
=
(
can_seg2_t
)(
i
-
init
->
seg1
-
1
-
1
-
1
);
init
->
psc
=
j
;
return
0
;
}
else
{
return
1
;
return
1
;
}
}
static
rt_err_t
_can_config
(
struct
rt_can_device
*
can_device
,
struct
can_configure
*
cfg
)
{
...
...
@@ -120,10 +120,10 @@ static rt_err_t _can_config(struct rt_can_device *can_device, struct can_configu
/*配置参数*/
if
(
get_can_baud_index
(
cfg
->
baud_rate
,
&
(
drv_can
->
CanHandle
.
init
)))
{
return
-
RT_ERROR
;
return
-
RT_ERROR
;
}
drv_can
->
CanHandle
.
init
.
sjw
=
(
can_sjw_t
)(
cfg
->
reserved
);
/* init can */
if
(
ald_can_init
(
&
drv_can
->
CanHandle
)
!=
OK
)
{
...
...
@@ -167,7 +167,7 @@ static rt_err_t _can_control(struct rt_can_device *can_device, int cmd, void *ar
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_TXM
,
DISABLE
);
}
else
if
(
argval
==
RT_DEVICE_CAN_INT_ERR
)
{
{
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_WARN
,
DISABLE
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_PERR
,
DISABLE
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_BOF
,
DISABLE
);
...
...
@@ -181,33 +181,33 @@ static rt_err_t _can_control(struct rt_can_device *can_device, int cmd, void *ar
{
NVIC_SetPriority
(
CAN0_RX0_IRQn
,
1
);
NVIC_EnableIRQ
(
CAN0_RX0_IRQn
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_FP0
,
ENABLE
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_FF0
,
ENABLE
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_FOV0
,
ENABLE
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_FP1
,
ENABLE
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_FF1
,
ENABLE
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_FOV1
,
ENABLE
);
}
else
if
(
argval
==
RT_DEVICE_FLAG_INT_TX
)
{
NVIC_SetPriority
(
CAN0_TX_IRQn
,
1
);
NVIC_EnableIRQ
(
CAN0_TX_IRQn
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_TXM
,
ENABLE
);
}
else
if
(
argval
==
RT_DEVICE_CAN_INT_ERR
)
{
NVIC_SetPriority
(
CAN0_EXCEPTION_IRQn
,
1
);
NVIC_EnableIRQ
(
CAN0_EXCEPTION_IRQn
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_WARN
,
ENABLE
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_PERR
,
ENABLE
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_BOF
,
ENABLE
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_PRERR
,
ENABLE
);
ald_can_interrupt_config
(
&
drv_can
->
CanHandle
,
CAN_IT_ERR
,
ENABLE
);
}
break
;
#ifdef RT_CAN_USING_HDR
...
...
@@ -222,12 +222,12 @@ static rt_err_t _can_control(struct rt_can_device *can_device, int cmd, void *ar
filter_cfg
=
(
struct
rt_can_filter_config
*
)
arg
;
/* get default filter */
for
(
int
i
=
0
;
i
<
filter_cfg
->
count
;
i
++
)
{
{
/*默认过滤表判断*/
if
(
filter_cfg
->
items
[
i
].
hdr
<
drv_can
->
device
.
config
.
maxhdr
)
if
(
filter_cfg
->
items
[
i
].
hdr
<
drv_can
->
device
.
config
.
maxhdr
)
drv_can
->
FilterConfig
.
number
=
filter_cfg
->
items
[
i
].
hdr
;
else
else
drv_can
->
FilterConfig
.
number
=
ES_C_CAN_DEFAULT_FILTER_NUMBER
;
if
(
filter_cfg
->
items
[
i
].
mode
)
...
...
@@ -235,40 +235,40 @@ static rt_err_t _can_control(struct rt_can_device *can_device, int cmd, void *ar
/*标识符列表模式: 类型匹配 ,id匹配为:接收的id = 配置的id
或者 = 配置的mask ,通过*/
/*扩展帧*/
if
(
filter_cfg
->
items
[
i
].
ide
)
{
if
(
filter_cfg
->
items
[
i
].
ide
)
{
// filter_cfg->items[i].id = filter_cfg->items[i].id ; /*id 29 位*/
filter_cfg
->
items
[
i
].
mask
=
((
filter_cfg
->
items
[
i
].
mask
<<
3
)
|
(
filter_cfg
->
items
[
i
].
ide
<<
2
)
|
(
filter_cfg
->
items
[
i
].
rtr
<<
1
));
(
filter_cfg
->
items
[
i
].
rtr
<<
1
));
}
else
/*标准帧*/
{
filter_cfg
->
items
[
i
].
id
=
(
filter_cfg
->
items
[
i
].
id
<<
18
);
filter_cfg
->
items
[
i
].
id
=
(
filter_cfg
->
items
[
i
].
id
<<
18
);
filter_cfg
->
items
[
i
].
mask
=
((
filter_cfg
->
items
[
i
].
mask
<<
21
)
|
(
filter_cfg
->
items
[
i
].
ide
<<
2
)
|
(
filter_cfg
->
items
[
i
].
rtr
<<
1
));
}
(
filter_cfg
->
items
[
i
].
rtr
<<
1
));
}
}
else
{
/*标识符掩码模式*/
/*扩展帧*/
if
(
filter_cfg
->
items
[
i
].
ide
)
{
filter_cfg
->
items
[
i
].
mask
=
(
filter_cfg
->
items
[
i
].
mask
)
<<
3
;
if
(
filter_cfg
->
items
[
i
].
ide
)
{
filter_cfg
->
items
[
i
].
mask
=
(
filter_cfg
->
items
[
i
].
mask
)
<<
3
;
}
else
/*标准帧*/
{
filter_cfg
->
items
[
i
].
id
=
(
filter_cfg
->
items
[
i
].
id
)
<<
18
;
filter_cfg
->
items
[
i
].
id
=
(
filter_cfg
->
items
[
i
].
id
)
<<
18
;
filter_cfg
->
items
[
i
].
mask
=
(
filter_cfg
->
items
[
i
].
mask
)
<<
21
;
}
}
#if ES_C_CAN_FILTER_FRAME_TYPE
/*匹配类型*/
filter_cfg
->
items
[
i
].
mask
|=
0x6
;
#endif
#endif
}
drv_can
->
FilterConfig
.
id_high
=
(
filter_cfg
->
items
[
i
].
id
>>
13
)
&
0xFFFF
;
...
...
@@ -277,7 +277,7 @@ static rt_err_t _can_control(struct rt_can_device *can_device, int cmd, void *ar
(
filter_cfg
->
items
[
i
].
rtr
<<
1
))
&
0xFFFF
;
drv_can
->
FilterConfig
.
mask_id_high
=
(
filter_cfg
->
items
[
i
].
mask
>>
16
)
&
0xFFFF
;
drv_can
->
FilterConfig
.
mask_id_low
=
filter_cfg
->
items
[
i
].
mask
&
0xFFFF
;
drv_can
->
FilterConfig
.
mode
=
(
can_filter_mode_t
)
filter_cfg
->
items
[
i
].
mode
;
/* Filter conf */
ald_can_filter_config
(
&
drv_can
->
CanHandle
,
&
drv_can
->
FilterConfig
);
...
...
@@ -303,7 +303,7 @@ static rt_err_t _can_control(struct rt_can_device *can_device, int cmd, void *ar
break
;
case
RT_CAN_CMD_SET_BAUD
:
argval
=
(
rt_uint32_t
)
arg
;
if
(
argval
!=
drv_can
->
device
.
config
.
baud_rate
)
{
drv_can
->
device
.
config
.
baud_rate
=
argval
;
...
...
@@ -412,10 +412,10 @@ static int _can_sendmsg(struct rt_can_device *can, const void *buf, rt_uint32_t
}
/* clear TIR */
h_can
->
perh
->
TxMailBox
[
box_num
].
TXID
&=
CAN_TXID0_TXMREQ_MSK
;
/* Set up the Id */
/* Set up the Id */
if
(
RT_CAN_STDID
==
pmsg
->
ide
)
{
{
h_can
->
perh
->
TxMailBox
[
box_num
].
TXID
|=
(
txheader
.
std
<<
CAN_TXID0_STDID_POSS
)
|
(
txheader
.
rtr
<<
CAN_TXID0_RTR_POS
);
}
else
...
...
@@ -437,7 +437,7 @@ static int _can_sendmsg(struct rt_can_device *can, const void *buf, rt_uint32_t
((
uint32_t
)
pmsg
->
data
[
0
]
<<
CAN_TXDL0_BYTE0_POSS
));
/* Request transmission */
SET_BIT
(
h_can
->
perh
->
TxMailBox
[
box_num
].
TXID
,
CAN_TXID0_TXMREQ_MSK
);
return
RT_EOK
;
}
else
...
...
@@ -447,8 +447,8 @@ static int _can_sendmsg(struct rt_can_device *can, const void *buf, rt_uint32_t
return
-
RT_ERROR
;
}
}
static
int
_can_recvmsg
(
struct
rt_can_device
*
can
,
void
*
buf
,
rt_uint32_t
fifo
)
...
...
@@ -530,8 +530,8 @@ static void _can_rx_isr(struct rt_can_device *can, rt_uint32_t fifo)
/* RX interrupt */
else
{
if
(
CAN_RX_MSG_PENDING
(
h_can
,
CAN_RX_FIFO0
)
!=
0
)
{
if
(
CAN_RX_MSG_PENDING
(
h_can
,
CAN_RX_FIFO0
)
!=
0
)
{
/* save to user list */
rt_hw_can_isr
(
can
,
RT_CAN_EVENT_RX_IND
|
fifo
<<
8
);
}
...
...
@@ -551,8 +551,8 @@ static void _can_rx_isr(struct rt_can_device *can, rt_uint32_t fifo)
/* RX interrupt */
else
{
if
(
CAN_RX_MSG_PENDING
(
h_can
,
CAN_RX_FIFO1
)
!=
0
)
{
if
(
CAN_RX_MSG_PENDING
(
h_can
,
CAN_RX_FIFO1
)
!=
0
)
{
/* save to user list */
rt_hw_can_isr
(
can
,
RT_CAN_EVENT_RX_IND
|
fifo
<<
8
);
}
...
...
@@ -695,21 +695,21 @@ int rt_hw_can_init(void)
h_gpio
.
flt
=
GPIO_FILTER_DISABLE
;
h_gpio
.
type
=
GPIO_TYPE_TTL
;
#if defined(ES_CAN0_RX_GPIO_FUNC)&&defined(ES_CAN0_RX_GPIO_PORT)&&defined(ES_CAN0_RX_GPIO_PIN)
#if defined(ES_CAN0_RX_GPIO_FUNC)&&defined(ES_CAN0_RX_GPIO_PORT)&&defined(ES_CAN0_RX_GPIO_PIN)
/* Initialize can rx pin */
h_gpio
.
mode
=
GPIO_MODE_INPUT
;
h_gpio
.
mode
=
GPIO_MODE_INPUT
;
h_gpio
.
func
=
ES_CAN0_RX_GPIO_FUNC
;
ald_gpio_init
(
ES_CAN0_RX_GPIO_PORT
,
ES_CAN0_RX_GPIO_PIN
,
&
h_gpio
);
#endif
#if defined(ES_CAN0_TX_GPIO_FUNC)&&defined(ES_CAN0_TX_GPIO_PORT)&&defined(ES_CAN0_TX_GPIO_PIN)
#endif
#if defined(ES_CAN0_TX_GPIO_FUNC)&&defined(ES_CAN0_TX_GPIO_PORT)&&defined(ES_CAN0_TX_GPIO_PIN)
/* Initialize can tx pin */
h_gpio
.
mode
=
GPIO_MODE_OUTPUT
;
h_gpio
.
mode
=
GPIO_MODE_OUTPUT
;
h_gpio
.
func
=
ES_CAN0_TX_GPIO_FUNC
;
ald_gpio_init
(
ES_CAN0_TX_GPIO_PORT
,
ES_CAN0_TX_GPIO_PIN
,
&
h_gpio
);
#endif
#endif
/* config default filter */
can_filter_t
filter
=
{
0
};
...
...
@@ -718,13 +718,13 @@ int rt_hw_can_init(void)
filter
.
mask_id_high
=
0x0000
;
filter
.
mask_id_low
=
0x0000
;
filter
.
fifo
=
CAN_FILTER_FIFO0
;
filter
.
number
=
ES_C_CAN_DEFAULT_FILTER_NUMBER
;
filter
.
number
=
ES_C_CAN_DEFAULT_FILTER_NUMBER
;
filter
.
mode
=
CAN_FILTER_MODE_MASK
;
filter
.
scale
=
CAN_FILTER_SCALE_32
;
filter
.
active
=
ENABLE
;
can
.
FilterConfig
=
filter
;
can
.
device
.
config
=
(
struct
can_configure
)
ES_CAN0_CONFIG
;
can
.
device
.
config
=
(
struct
can_configure
)
ES_CAN0_CONFIG
;
#ifdef RT_CAN_USING_HDR
can
.
device
.
config
.
maxhdr
=
14
;
#endif
...
...
bsp/essemi/es32f369x/drivers/drv_can.h
浏览文件 @
3482bf86
...
...
@@ -17,7 +17,7 @@
*
* Change Logs:
* Date Author Notes
* 2020-01-14 wangyq the first version
* 2020-01-14 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
bsp/essemi/es32f369x/drivers/drv_gpio.c
浏览文件 @
3482bf86
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
...
...
@@ -17,7 +17,7 @@
*
* Change Logs:
* Date Author Notes
* 2020-01-14 wangyq the first version
* 2020-01-14 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
@@ -73,150 +73,150 @@ struct rt_pin_irq_hdr pin_irq_hdr_tab[] =
{
-
1
,
0
,
RT_NULL
,
RT_NULL
},
{
-
1
,
0
,
RT_NULL
,
RT_NULL
},
{
-
1
,
0
,
RT_NULL
,
RT_NULL
},
};
};
#ifdef ES_CONF_EXTI_IRQ_0
RT_WEAK
void
irq_pin0_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 0
\r\n
"
);
}
}
#endif
#ifdef ES_CONF_EXTI_IRQ_1
#ifdef ES_CONF_EXTI_IRQ_1
RT_WEAK
void
irq_pin1_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 1
\r\n
"
);
}
}
#endif
#ifdef ES_CONF_EXTI_IRQ_2
RT_WEAK
void
irq_pin2_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 2
\r\n
"
);
}
rt_kprintf
(
"
\r\n
EXTI 2
\r\n
"
);
}
#endif
#ifdef ES_CONF_EXTI_IRQ_3
RT_WEAK
void
irq_pin3_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 3
\r\n
"
);
}
#endif
rt_kprintf
(
"
\r\n
EXTI 3
\r\n
"
);
}
#endif
#ifdef ES_CONF_EXTI_IRQ_4
RT_WEAK
void
irq_pin4_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 4
\r\n
"
);
}
#endif
rt_kprintf
(
"
\r\n
EXTI 4
\r\n
"
);
}
#endif
#ifdef ES_CONF_EXTI_IRQ_5
RT_WEAK
void
irq_pin5_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 5
\r\n
"
);
}
#endif
rt_kprintf
(
"
\r\n
EXTI 5
\r\n
"
);
}
#endif
#ifdef ES_CONF_EXTI_IRQ_6
RT_WEAK
void
irq_pin6_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 6
\r\n
"
);
}
#endif
rt_kprintf
(
"
\r\n
EXTI 6
\r\n
"
);
}
#endif
#ifdef ES_CONF_EXTI_IRQ_7
RT_WEAK
void
irq_pin7_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 7
\r\n
"
);
}
#endif
rt_kprintf
(
"
\r\n
EXTI 7
\r\n
"
);
}
#endif
#ifdef ES_CONF_EXTI_IRQ_8
RT_WEAK
void
irq_pin8_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 8
\r\n
"
);
}
#endif
rt_kprintf
(
"
\r\n
EXTI 8
\r\n
"
);
}
#endif
#ifdef ES_CONF_EXTI_IRQ_9
RT_WEAK
void
irq_pin9_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 9
\r\n
"
);
}
#endif
rt_kprintf
(
"
\r\n
EXTI 9
\r\n
"
);
}
#endif
#ifdef ES_CONF_EXTI_IRQ_10
RT_WEAK
void
irq_pin10_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 10
\r\n
"
);
}
#endif
rt_kprintf
(
"
\r\n
EXTI 10
\r\n
"
);
}
#endif
#ifdef ES_CONF_EXTI_IRQ_11
RT_WEAK
void
irq_pin11_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 11
\r\n
"
);
}
#endif
rt_kprintf
(
"
\r\n
EXTI 11
\r\n
"
);
}
#endif
#ifdef ES_CONF_EXTI_IRQ_12
RT_WEAK
void
irq_pin12_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 12
\r\n
"
);
}
#endif
rt_kprintf
(
"
\r\n
EXTI 12
\r\n
"
);
}
#endif
#ifdef ES_CONF_EXTI_IRQ_13
RT_WEAK
void
irq_pin13_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 13
\r\n
"
);
}
#endif
rt_kprintf
(
"
\r\n
EXTI 13
\r\n
"
);
}
#endif
#ifdef ES_CONF_EXTI_IRQ_14
RT_WEAK
void
irq_pin14_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 14
\r\n
"
);
}
#endif
rt_kprintf
(
"
\r\n
EXTI 14
\r\n
"
);
}
#endif
#ifdef ES_CONF_EXTI_IRQ_15
RT_WEAK
void
irq_pin15_callback
(
void
*
arg
)
{
rt_kprintf
(
"
\r\n
EXTI 15
\r\n
"
);
}
#endif
rt_kprintf
(
"
\r\n
EXTI 15
\r\n
"
);
}
#endif
#define ITEM_NUM(items) sizeof(items) / sizeof(items[0])
...
...
@@ -277,7 +277,7 @@ void es32f3_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
gpio_initstruct
.
podrv
=
GPIO_OUT_DRIVE_6
;
gpio_initstruct
.
nodrv
=
GPIO_OUT_DRIVE_6
;
gpio_initstruct
.
type
=
GPIO_TYPE_CMOS
;
gpio_initstruct
.
odos
=
GPIO_PUSH_PULL
;
gpio_initstruct
.
odos
=
GPIO_PUSH_PULL
;
gpio_initstruct
.
flt
=
GPIO_FILTER_DISABLE
;
if
(
mode
==
PIN_MODE_OUTPUT
)
...
...
@@ -317,12 +317,12 @@ void es32f3_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
rt_inline
const
struct
pin_irq_map
*
get_pin_irq_map
(
rt_uint16_t
gpio_pin
)
{
uint8_t
map_index
=
0U
;
while
(
gpio_pin
>>
(
++
map_index
))
{
}
map_index
--
;
if
(
map_index
>=
ITEM_NUM
(
pin_irq_map
))
{
return
RT_NULL
;
...
...
@@ -448,9 +448,9 @@ rt_err_t es32f3_pin_irq_enable(struct rt_device *device, rt_base_t pin,
/* Configure GPIO_InitStructure */
gpio_initstruct
.
mode
=
GPIO_MODE_INPUT
;
gpio_initstruct
.
odos
=
GPIO_PUSH_PULL
;
gpio_initstruct
.
podrv
=
GPIO_OUT_DRIVE_6
;
gpio_initstruct
.
nodrv
=
GPIO_OUT_DRIVE_6
;
gpio_initstruct
.
func
=
GPIO_FUNC_1
;
gpio_initstruct
.
podrv
=
GPIO_OUT_DRIVE_6
;
gpio_initstruct
.
nodrv
=
GPIO_OUT_DRIVE_6
;
gpio_initstruct
.
func
=
GPIO_FUNC_1
;
gpio_initstruct
.
flt
=
GPIO_FILTER_DISABLE
;
switch
(
pin_irq_hdr_tab
[
irqindex
].
mode
)
{
...
...
@@ -641,16 +641,16 @@ void EXTI15_Handler(void)
int
rt_hw_pin_init
(
void
)
{
int
result
;
#ifdef ES_INIT_GPIOS
rt_size_t
i
,
gpio_conf_num
=
sizeof
(
gpio_conf_all
)
/
sizeof
(
gpio_conf_t
);
#endif
#endif
ald_cmu_perh_clock_config
(
CMU_PERH_GPIO
,
ENABLE
);
result
=
rt_device_pin_register
(
ES_DEVICE_NAME_PIN
,
&
_es32f3_pin_ops
,
RT_NULL
);
if
(
result
!=
RT_EOK
)
return
result
;
...
...
@@ -660,20 +660,20 @@ int rt_hw_pin_init(void)
for
(
i
=
0
;
i
<
gpio_conf_num
;
i
++
)
{
rt_pin_mode
(
gpio_conf_all
[
i
].
pin
,
gpio_conf_all
[
i
].
pin_mode
);
if
((
gpio_conf_all
[
i
].
pin_mode
==
ES_C_GPIO_MODE_OUTPUT
)
||
(
gpio_conf_all
[
i
].
pin_mode
==
ES_C_GPIO_MODE_OUTPUT_OD
))
rt_pin_write
(
gpio_conf_all
[
i
].
pin
,
gpio_conf_all
[
i
].
pin_level
);
if
(
!
gpio_conf_all
[
i
].
irq_en
)
continue
;
rt_pin_attach_irq
(
gpio_conf_all
[
i
].
pin
,
gpio_conf_all
[
i
].
irq_mode
,
gpio_conf_all
[
i
].
callback
,
RT_NULL
);
rt_pin_irq_enable
(
gpio_conf_all
[
i
].
pin
,
gpio_conf_all
[
i
].
irq_en
);
}
#endif
#endif
return
result
;
}
INIT_BOARD_EXPORT
(
rt_hw_pin_init
);
...
...
bsp/essemi/es32f369x/drivers/drv_gpio.h
浏览文件 @
3482bf86
...
...
@@ -17,15 +17,15 @@
*
* Change Logs:
* Date Author Notes
* 2020-01-14 wangyq the first version
* 2021-04-20 liuhy the second version
* 2020-01-14 wangyq the first version
* 2021-04-20 liuhy the second version
*/
#ifndef DRV_GPIO_H__
#define DRV_GPIO_H__
#include "es_conf_info_gpio.h"
#define GET_PIN(port,pin) (ES_PIN_GPIO_##port##_##pin)
int
rt_hw_pin_init
(
void
);
...
...
bsp/essemi/es32f369x/drivers/drv_hwtimer.c
浏览文件 @
3482bf86
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
...
...
@@ -18,7 +18,7 @@
* Change Logs:
* Date Author Notes
* 2019-3-19 wangyq the first version
* 2019-11-01 wangyq update libraries
* 2019-11-01 wangyq update libraries
* 2021-04-20 liuhy the second version
*/
...
...
@@ -26,7 +26,7 @@
#include <rtthread.h>
#include <rtdevice.h>
#include <drv_hwtimer.h>
#include <board.h>
#include <board.h>
#ifdef RT_USING_HWTIMER
...
...
@@ -82,7 +82,7 @@ static struct es32f3_hwtimer_dev gp32c4t0_hwtimer;
static
struct
rt_hwtimer_info
gp32c4t0_info
=
{
ES_SYS_CLK
>>
ES_CMU_PCLK_1_DIV
,
/* maximum count frequency */
(
ES_SYS_CLK
>>
ES_CMU_PCLK_1_DIV
)
/
(
1U
<<
16
),
/* minimum count frequency */
0xFFFFFFFF
,
/* counter maximum value */
...
...
@@ -198,7 +198,7 @@ static void es32f3_hwtimer_init(rt_hwtimer_t *timer, rt_uint32_t state)
struct
rt_hwtimer_info
*
hwtimer_info
=
(
struct
rt_hwtimer_info
*
)
timer
->
info
;
RT_ASSERT
(
hwtimer
!=
RT_NULL
);
if
(
1
==
state
)
...
...
@@ -207,21 +207,21 @@ static void es32f3_hwtimer_init(rt_hwtimer_t *timer, rt_uint32_t state)
ald_timer_interrupt_config
(
hwtimer
->
hwtimer_periph
,
TIMER_IT_UPDATE
,
ENABLE
);
NVIC_EnableIRQ
(
hwtimer
->
IRQn
);
}
hwtimer
->
parent
.
freq
=
ald_cmu_get_pclk1_clock
()
/
((
hwtimer
->
hwtimer_periph
->
perh
->
PRES
&
0xFFFF
)
+
1
);
hwtimer_info
->
maxfreq
=
hwtimer
->
parent
.
freq
;
hwtimer_info
->
minfreq
=
(
hwtimer
->
parent
.
freq
)
/
0xFFFF
;
}
static
rt_err_t
es32f3_hwtimer_start
(
rt_hwtimer_t
*
timer
,
rt_uint32_t
cnt
,
rt_hwtimer_mode_t
mode
)
{
struct
es32f3_hwtimer_dev
*
hwtimer
=
(
struct
es32f3_hwtimer_dev
*
)
timer
->
parent
.
user_data
;
struct
es32f3_hwtimer_dev
*
hwtimer
=
(
struct
es32f3_hwtimer_dev
*
)
timer
->
parent
.
user_data
;
RT_ASSERT
(
hwtimer
!=
RT_NULL
);
WRITE_REG
(
hwtimer
->
hwtimer_periph
->
perh
->
AR
,
cnt
);
ald_timer_base_start
(
hwtimer
->
hwtimer_periph
);
...
...
@@ -263,19 +263,19 @@ static rt_err_t es32f3_hwtimer_control(rt_hwtimer_t *timer,
{
case
HWTIMER_CTRL_FREQ_SET
:
freq
=
*
(
rt_uint32_t
*
)
args
;
ret
=
-
RT_ERROR
;
if
(
freq
)
{
{
double
temp
,
target
;
temp
=
(
double
)
ald_cmu_get_pclk1_clock
();
target
=
temp
/
freq
;
if
(
target
<
0x10001
)
/*最大分频 = max(PRES)+1*/
{
temp
=
target
-
(
int
)(
target
);
if
((
temp
>
0
.
998
)
&&
(
target
<
0x10000
))
{
hwtimer
->
hwtimer_periph
->
perh
->
PRES
=
(
uint32_t
)
target
;
...
...
@@ -286,14 +286,14 @@ static rt_err_t es32f3_hwtimer_control(rt_hwtimer_t *timer,
hwtimer
->
hwtimer_periph
->
perh
->
PRES
=
(
uint32_t
)
target
-
1
;
ret
=
RT_EOK
;
}
}
if
(
ret
==
RT_EOK
)
/*更新信息*/
hwtimer
->
parent
.
freq
=
ald_cmu_get_pclk1_clock
()
/
((
hwtimer
->
hwtimer_periph
->
perh
->
PRES
&
0xFFFF
)
+
1
);
}
break
;
case
HWTIMER_CTRL_STOP
:
...
...
@@ -323,14 +323,14 @@ int rt_hw_hwtimer_init(void)
#ifdef BSP_USING_AD16C4T0_HWTIMER
static
timer_handle_t
ad16c4t0_hwtimer_periph
;
ad16c4t0_hwtimer_periph
.
perh
=
AD16C4T0
;
ad16c4t0_hwtimer
.
IRQn
=
AD16C4T0_UP_IRQn
;
ad16c4t0_hwtimer_periph
.
init
.
prescaler
=
ES_AD16C4T0_HWTIMER_PRES
-
1
;
ad16c4t0_hwtimer_periph
.
init
.
prescaler
=
ES_AD16C4T0_HWTIMER_PRES
-
1
;
ad16c4t0_hwtimer_periph
.
init
.
mode
=
(
ES_AD16C4T0_HWTIMER_MODE
==
HWTIMER_CNTMODE_UP
)
?
TIMER_CNT_MODE_UP
:
TIMER_CNT_MODE_DOWN
;
ad16c4t0_hwtimer
.
hwtimer_periph
=
&
ad16c4t0_hwtimer_periph
;
ad16c4t0_hwtimer
.
parent
.
info
=
&
ad16c4t0_info
;
ad16c4t0_hwtimer
.
parent
.
ops
=
&
es32f3_hwtimer_ops
;
ret
=
rt_device_hwtimer_register
(
&
ad16c4t0_hwtimer
.
parent
,
ES_DEVICE_NAME_AD16C4T0_HWTIMER
,
&
ad16c4t0_hwtimer
);
...
...
@@ -338,14 +338,14 @@ int rt_hw_hwtimer_init(void)
#ifdef BSP_USING_AD16C4T1_HWTIMER
static
timer_handle_t
ad16c4t1_hwtimer_periph
;
ad16c4t1_hwtimer_periph
.
perh
=
AD16C4T1
;
ad16c4t1_hwtimer
.
IRQn
=
AD16C4T1_UP_IRQn
;
ad16c4t1_hwtimer_periph
.
init
.
prescaler
=
ES_AD16C4T1_HWTIMER_PRES
-
1
;
ad16c4t1_hwtimer_periph
.
init
.
prescaler
=
ES_AD16C4T1_HWTIMER_PRES
-
1
;
ad16c4t1_hwtimer_periph
.
init
.
mode
=
(
ES_AD16C4T1_HWTIMER_MODE
==
HWTIMER_CNTMODE_UP
)
?
TIMER_CNT_MODE_UP
:
TIMER_CNT_MODE_DOWN
;
ad16c4t1_hwtimer
.
hwtimer_periph
=
&
ad16c4t1_hwtimer_periph
;
ad16c4t1_hwtimer
.
parent
.
info
=
&
ad16c4t1_info
;
ad16c4t1_hwtimer
.
parent
.
ops
=
&
es32f3_hwtimer_ops
;
ret
=
rt_device_hwtimer_register
(
&
ad16c4t1_hwtimer
.
parent
,
ES_DEVICE_NAME_AD16C4T1_HWTIMER
,
&
ad16c4t1_hwtimer
);
...
...
@@ -353,14 +353,14 @@ int rt_hw_hwtimer_init(void)
#ifdef BSP_USING_GP32C4T0_HWTIMER
static
timer_handle_t
gp32c4t0_hwtimer_periph
;
gp32c4t0_hwtimer_periph
.
perh
=
GP32C4T0
;
gp32c4t0_hwtimer
.
IRQn
=
GP32C4T0_IRQn
;
gp32c4t0_hwtimer_periph
.
init
.
prescaler
=
ES_GP32C4T0_HWTIMER_PRES
-
1
;
gp32c4t0_hwtimer_periph
.
init
.
prescaler
=
ES_GP32C4T0_HWTIMER_PRES
-
1
;
gp32c4t0_hwtimer_periph
.
init
.
mode
=
(
ES_GP32C4T0_HWTIMER_MODE
==
HWTIMER_CNTMODE_UP
)
?
TIMER_CNT_MODE_UP
:
TIMER_CNT_MODE_DOWN
;
gp32c4t0_hwtimer
.
hwtimer_periph
=
&
gp32c4t0_hwtimer_periph
;
gp32c4t0_hwtimer
.
parent
.
info
=
&
gp32c4t0_info
;
gp32c4t0_hwtimer
.
parent
.
ops
=
&
es32f3_hwtimer_ops
;
ret
=
rt_device_hwtimer_register
(
&
gp32c4t0_hwtimer
.
parent
,
ES_DEVICE_NAME_GP32C4T0_HWTIMER
,
&
gp32c4t0_hwtimer
);
...
...
@@ -368,14 +368,14 @@ int rt_hw_hwtimer_init(void)
#ifdef BSP_USING_GP32C4T1_HWTIMER
static
timer_handle_t
gp32c4t1_hwtimer_periph
;
gp32c4t1_hwtimer_periph
.
perh
=
GP32C4T1
;
gp32c4t1_hwtimer
.
IRQn
=
GP32C4T1_IRQn
;
gp32c4t1_hwtimer_periph
.
init
.
prescaler
=
ES_GP32C4T1_HWTIMER_PRES
-
1
;
gp32c4t1_hwtimer_periph
.
init
.
prescaler
=
ES_GP32C4T1_HWTIMER_PRES
-
1
;
gp32c4t1_hwtimer_periph
.
init
.
mode
=
(
ES_GP32C4T1_HWTIMER_MODE
==
HWTIMER_CNTMODE_UP
)
?
TIMER_CNT_MODE_UP
:
TIMER_CNT_MODE_DOWN
;
gp32c4t1_hwtimer
.
hwtimer_periph
=
&
gp32c4t1_hwtimer_periph
;
gp32c4t1_hwtimer
.
parent
.
info
=
&
gp32c4t1_info
;
gp32c4t1_hwtimer
.
parent
.
ops
=
&
es32f3_hwtimer_ops
;
ret
=
rt_device_hwtimer_register
(
&
gp32c4t1_hwtimer
.
parent
,
ES_DEVICE_NAME_GP32C4T1_HWTIMER
,
&
gp32c4t1_hwtimer
);
...
...
@@ -383,14 +383,14 @@ int rt_hw_hwtimer_init(void)
#ifdef BSP_USING_GP16C4T0_HWTIMER
static
timer_handle_t
gp16c4t0_hwtimer_periph
;
gp16c4t0_hwtimer_periph
.
perh
=
GP16C4T0
;
gp16c4t0_hwtimer
.
IRQn
=
GP16C4T0_IRQn
;
gp16c4t0_hwtimer_periph
.
init
.
prescaler
=
ES_GP16C4T0_HWTIMER_PRES
-
1
;
gp16c4t0_hwtimer_periph
.
init
.
prescaler
=
ES_GP16C4T0_HWTIMER_PRES
-
1
;
gp16c4t0_hwtimer_periph
.
init
.
mode
=
(
ES_GP16C4T0_HWTIMER_MODE
==
HWTIMER_CNTMODE_UP
)
?
TIMER_CNT_MODE_UP
:
TIMER_CNT_MODE_DOWN
;
gp16c4t0_hwtimer
.
hwtimer_periph
=
&
gp16c4t0_hwtimer_periph
;
gp16c4t0_hwtimer
.
parent
.
info
=
&
gp16c4t0_info
;
gp16c4t0_hwtimer
.
parent
.
ops
=
&
es32f3_hwtimer_ops
;
ret
=
rt_device_hwtimer_register
(
&
gp16c4t0_hwtimer
.
parent
,
ES_DEVICE_NAME_GP16C4T0_HWTIMER
,
&
gp16c4t0_hwtimer
);
...
...
@@ -398,14 +398,14 @@ int rt_hw_hwtimer_init(void)
#ifdef BSP_USING_GP16C4T1_HWTIMER
static
timer_handle_t
gp16c4t1_hwtimer_periph
;
gp16c4t1_hwtimer_periph
.
perh
=
GP16C4T1
;
gp16c4t1_hwtimer
.
IRQn
=
GP16C4T1_IRQn
;
gp16c4t1_hwtimer_periph
.
init
.
prescaler
=
ES_GP16C4T1_HWTIMER_PRES
-
1
;
gp16c4t1_hwtimer_periph
.
init
.
prescaler
=
ES_GP16C4T1_HWTIMER_PRES
-
1
;
gp16c4t1_hwtimer_periph
.
init
.
mode
=
(
ES_GP16C4T1_HWTIMER_MODE
==
HWTIMER_CNTMODE_UP
)
?
TIMER_CNT_MODE_UP
:
TIMER_CNT_MODE_DOWN
;
gp16c4t1_hwtimer
.
hwtimer_periph
=
&
gp16c4t1_hwtimer_periph
;
gp16c4t1_hwtimer
.
parent
.
info
=
&
gp16c4t1_info
;
gp16c4t1_hwtimer
.
parent
.
ops
=
&
es32f3_hwtimer_ops
;
ret
=
rt_device_hwtimer_register
(
&
gp16c4t1_hwtimer
.
parent
,
ES_DEVICE_NAME_GP16C4T1_HWTIMER
,
&
gp16c4t1_hwtimer
);
...
...
@@ -413,14 +413,14 @@ int rt_hw_hwtimer_init(void)
#ifdef BSP_USING_BS16T0_HWTIMER
static
timer_handle_t
bs16t0_hwtimer_periph
;
bs16t0_hwtimer_periph
.
perh
=
BS16T0
;
bs16t0_hwtimer
.
IRQn
=
BS16T0_IRQn
;
bs16t0_hwtimer_periph
.
init
.
prescaler
=
ES_BS16T0_HWTIMER_PRES
-
1
;
bs16t0_hwtimer_periph
.
init
.
prescaler
=
ES_BS16T0_HWTIMER_PRES
-
1
;
bs16t0_hwtimer_periph
.
init
.
mode
=
(
ES_BS16T0_HWTIMER_MODE
==
HWTIMER_CNTMODE_UP
)
?
TIMER_CNT_MODE_UP
:
TIMER_CNT_MODE_DOWN
;
bs16t0_hwtimer
.
hwtimer_periph
=
&
bs16t0_hwtimer_periph
;
bs16t0_hwtimer
.
parent
.
info
=
&
bs16t0_info
;
bs16t0_hwtimer
.
parent
.
ops
=
&
es32f3_hwtimer_ops
;
ret
=
rt_device_hwtimer_register
(
&
bs16t0_hwtimer
.
parent
,
ES_DEVICE_NAME_BS16T0_HWTIMER
,
&
bs16t0_hwtimer
);
...
...
@@ -428,14 +428,14 @@ int rt_hw_hwtimer_init(void)
#ifdef BSP_USING_BS16T1_HWTIMER
static
timer_handle_t
bs16t1_hwtimer_periph
;
bs16t1_hwtimer_periph
.
perh
=
BS16T1
;
bs16t1_hwtimer
.
IRQn
=
BS16T1_IRQn
;
bs16t1_hwtimer_periph
.
init
.
prescaler
=
ES_BS16T1_HWTIMER_PRES
-
1
;
bs16t1_hwtimer_periph
.
init
.
prescaler
=
ES_BS16T1_HWTIMER_PRES
-
1
;
bs16t1_hwtimer_periph
.
init
.
mode
=
(
ES_BS16T1_HWTIMER_MODE
==
HWTIMER_CNTMODE_UP
)
?
TIMER_CNT_MODE_UP
:
TIMER_CNT_MODE_DOWN
;
bs16t1_hwtimer
.
hwtimer_periph
=
&
bs16t1_hwtimer_periph
;
bs16t1_hwtimer
.
parent
.
info
=
&
bs16t1_info
;
bs16t1_hwtimer
.
parent
.
ops
=
&
es32f3_hwtimer_ops
;
ret
=
rt_device_hwtimer_register
(
&
bs16t1_hwtimer
.
parent
,
ES_DEVICE_NAME_BS16T1_HWTIMER
,
&
bs16t1_hwtimer
);
...
...
bsp/essemi/es32f369x/drivers/drv_hwtimer.h
浏览文件 @
3482bf86
...
...
@@ -17,7 +17,7 @@
*
* Change Logs:
* Date Author Notes
* 2019-3-19 wangyq the first version
* 2019-3-19 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
bsp/essemi/es32f369x/drivers/drv_i2c.c
浏览文件 @
3482bf86
...
...
@@ -15,9 +15,9 @@
* limitations under the License.
*
* Change Logs:
* Date Author Notes
* 2019-11-01 wangyq update libraries
* 2020-01-14 wangyq the first version
* Date Author Notes
* 2019-11-01 wangyq update libraries
* 2020-01-14 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
@@ -53,22 +53,22 @@ static void _i2c_init(void)
gpio_instruct
.
nodrv
=
GPIO_OUT_DRIVE_6
;
gpio_instruct
.
flt
=
GPIO_FILTER_DISABLE
;
gpio_instruct
.
type
=
GPIO_TYPE_CMOS
;
#ifdef BSP_USING_I2C0
#if defined(ES_I2C0_SCL_GPIO_FUNC)&&defined(ES_I2C0_SCL_GPIO_PORT)&&defined(ES_I2C0_SCL_GPIO_PIN)
#ifdef BSP_USING_I2C0
#if defined(ES_I2C0_SCL_GPIO_FUNC)&&defined(ES_I2C0_SCL_GPIO_PORT)&&defined(ES_I2C0_SCL_GPIO_PIN)
gpio_instruct
.
func
=
ES_I2C0_SCL_GPIO_FUNC
;
ald_gpio_init
(
ES_I2C0_SCL_GPIO_PORT
,
ES_I2C0_SCL_GPIO_PIN
,
&
gpio_instruct
);
#endif
#endif
#if defined(ES_I2C0_SDA_GPIO_FUNC)&&defined(ES_I2C0_SDA_GPIO_PORT)&&defined(ES_I2C0_SDA_GPIO_PIN)
gpio_instruct
.
func
=
ES_I2C0_SDA_GPIO_FUNC
;
ald_gpio_init
(
ES_I2C0_SDA_GPIO_PORT
,
ES_I2C0_SDA_GPIO_PIN
,
&
gpio_instruct
);
#endif
ald_gpio_init
(
ES_I2C0_SDA_GPIO_PORT
,
ES_I2C0_SDA_GPIO_PIN
,
&
gpio_instruct
);
#endif
/* Initialize I2C Function */
_h_i2c0
.
perh
=
I2C0
;
_h_i2c0
.
perh
=
I2C0
;
_h_i2c0
.
init
.
module
=
I2C_MODULE_MASTER
;
_h_i2c0
.
init
.
clk_speed
=
ES_I2C0_CLK_SPEED
;
_h_i2c0
.
init
.
own_addr1
=
ES_I2C0_OWN_ADDR1
;
...
...
@@ -78,24 +78,24 @@ static void _i2c_init(void)
ald_i2c_reset
(
&
_h_i2c0
);
ald_i2c_init
(
&
_h_i2c0
);
#endif
#ifdef BSP_USING_I2C1
#ifdef BSP_USING_I2C1
#if defined(ES_I2C1_SCL_GPIO_FUNC)&&defined(ES_I2C1_SCL_GPIO_PORT)&&defined(ES_I2C1_SCL_GPIO_PIN)
#if defined(ES_I2C1_SCL_GPIO_FUNC)&&defined(ES_I2C1_SCL_GPIO_PORT)&&defined(ES_I2C1_SCL_GPIO_PIN)
gpio_instruct
.
func
=
ES_I2C1_SCL_GPIO_FUNC
;
ald_gpio_init
(
ES_I2C1_SCL_GPIO_PORT
,
ES_I2C1_SCL_GPIO_PIN
,
&
gpio_instruct
);
#endif
#if defined(ES_I2C1_SDA_GPIO_FUNC)&&defined(ES_I2C1_SDA_GPIO_PORT)&&defined(ES_I2C1_SDA_GPIO_PIN)
#endif
#if defined(ES_I2C1_SDA_GPIO_FUNC)&&defined(ES_I2C1_SDA_GPIO_PORT)&&defined(ES_I2C1_SDA_GPIO_PIN)
gpio_instruct
.
func
=
ES_I2C1_SDA_GPIO_FUNC
;
ald_gpio_init
(
ES_I2C1_SDA_GPIO_PORT
,
ES_I2C1_SDA_GPIO_PIN
,
&
gpio_instruct
);
#endif
#endif
/* Initialize i2c function */
_h_i2c1
.
perh
=
I2C1
;
_h_i2c1
.
init
.
module
=
I2C_MODULE_MASTER
;
_h_i2c1
.
perh
=
I2C1
;
_h_i2c1
.
init
.
module
=
I2C_MODULE_MASTER
;
_h_i2c1
.
init
.
clk_speed
=
ES_I2C1_CLK_SPEED
;
_h_i2c1
.
init
.
own_addr1
=
ES_I2C1_OWN_ADDR1
;
_h_i2c1
.
init
.
addr_mode
=
ES_I2C1_ADDR_MODE
;
...
...
@@ -104,7 +104,7 @@ static void _i2c_init(void)
ald_i2c_reset
(
&
_h_i2c1
);
ald_i2c_init
(
&
_h_i2c1
);
#endif
}
...
...
bsp/essemi/es32f369x/drivers/drv_i2c.h
浏览文件 @
3482bf86
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
...
...
@@ -17,7 +17,7 @@
*
* Change Logs:
* Date Author Notes
* 2020-01-14 wangyq the first version
* 2020-01-14 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
bsp/essemi/es32f369x/drivers/drv_pm.c
浏览文件 @
3482bf86
...
...
@@ -20,7 +20,7 @@
* 2020-12-15 liuhy the first version
*/
#include "drv_pm.h"
#include "drv_pm.h"
#ifdef RT_USING_PM
...
...
@@ -29,20 +29,20 @@ void save_register(void *p_head,uint32_t size,void *p_save)
{
memcpy
(
p_save
,
p_head
,
size
);
}
void
load_register
(
void
*
p_head
,
uint32_t
size
,
void
*
p_load
)
{
memcpy
(
p_head
,
p_load
,
size
);
#ifdef ES_PMU_SAVE_LOAD_UART
if
((
p_head
==
UART0
)
||
(
p_head
==
UART1
)
||
(
p_head
==
UART2
)
||
#ifdef ES_PMU_SAVE_LOAD_UART
if
((
p_head
==
UART0
)
||
(
p_head
==
UART1
)
||
(
p_head
==
UART2
)
||
(
p_head
==
UART3
)
||
(
p_head
==
UART4
)
||
(
p_head
==
UART5
)
)
{
((
UART_TypeDef
*
)
p_head
)
->
IER
=
((
UART_TypeDef
*
)
p_load
)
->
IVS
;
}
#endif
}
static
void
uart_console_reconfig
(
void
)
...
...
@@ -62,7 +62,7 @@ static void uart_console_reconfig(void)
/* 注意:进入睡眠前,如果有中断挂起(SYSTICK、PENDSV、UART、EXTI等),睡眠将被瞬间唤醒。*/
static
void
sleep
(
struct
rt_pm
*
pm
,
uint8_t
mode
)
{
switch
(
mode
)
{
case
PM_SLEEP_MODE_NONE
:
...
...
@@ -76,18 +76,18 @@ static void sleep(struct rt_pm *pm, uint8_t mode)
ald_pmu_stop1_enter
();
break
;
case
PM_SLEEP_MODE_DEEP
:
/* Enter STOP 2 mode */
case
PM_SLEEP_MODE_DEEP
:
/* Enter STOP 2 mode */
ald_pmu_stop2_enter
();
break
;
case
PM_SLEEP_MODE_STANDBY
:
/* Enter STANDBY mode */
/* Enter STANDBY mode */
ald_pmu_stop2_enter
();
break
;
case
PM_SLEEP_MODE_SHUTDOWN
:
/* Enter SHUTDOWNN mode */
/* Enter SHUTDOWNN mode */
ald_pmu_stop2_enter
();
break
;
...
...
@@ -95,7 +95,7 @@ static void sleep(struct rt_pm *pm, uint8_t mode)
RT_ASSERT
(
0
);
break
;
}
}
static
uint8_t
run_speed
[
PM_RUN_MODE_MAX
][
2
]
=
...
...
bsp/essemi/es32f369x/drivers/drv_pm.h
浏览文件 @
3482bf86
...
...
@@ -17,7 +17,7 @@
*
* Change Logs:
* Date Author Notes
* 2019-04-01 wangyq the first version
* 2019-04-01 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
@@ -33,7 +33,7 @@
int
rt_hw_pm_init
(
void
);
extern
void
save_register
(
void
*
p_head
,
uint32_t
size
,
void
*
p_save
);
extern
void
load_register
(
void
*
p_head
,
uint32_t
size
,
void
*
p_load
);
#endif
bsp/essemi/es32f369x/drivers/drv_pwm.c
浏览文件 @
3482bf86
...
...
@@ -18,7 +18,7 @@
* Change Logs:
* Date Author Notes
* 2019-03-11 wangyq the first version
* 2019-11-01 wangyq update libraries
* 2019-11-01 wangyq update libraries
* 2021-04-20 liuhy the second version
*/
...
...
@@ -57,32 +57,32 @@ static rt_err_t es32f3_pwm_control(struct rt_device_pwm *device, int cmd, void *
struct
rt_pwm_configuration
*
cfg
=
(
struct
rt_pwm_configuration
*
)
arg
;
RT_ASSERT
(
timer_initstruct
!=
RT_NULL
);
/* select pwm output channel */
if
(
1
==
cfg
->
channel
)
{
pwm_channel
=
TIMER_CHANNEL_1
;
_ccep_ch_en
=
timer_initstruct
->
perh
->
CCEP
&
TIMER_CCEP_CC1EN_MSK
;
}
else
if
(
2
==
cfg
->
channel
)
else
if
(
2
==
cfg
->
channel
)
{
pwm_channel
=
TIMER_CHANNEL_2
;
_ccep_ch_en
=
timer_initstruct
->
perh
->
CCEP
&
TIMER_CCEP_CC2EN_MSK
;
}
else
if
(
3
==
cfg
->
channel
)
else
if
(
3
==
cfg
->
channel
)
{
pwm_channel
=
TIMER_CHANNEL_3
;
_ccep_ch_en
=
timer_initstruct
->
perh
->
CCEP
&
TIMER_CCEP_CC3EN_MSK
;
}
else
if
(
4
==
cfg
->
channel
)
else
if
(
4
==
cfg
->
channel
)
{
pwm_channel
=
TIMER_CHANNEL_4
;
_ccep_ch_en
=
timer_initstruct
->
perh
->
CCEP
&
TIMER_CCEP_CC4EN_MSK
;
}
else
return
RT_EINVAL
;
switch
(
cmd
)
{
case
PWM_CMD_ENABLE
:
...
...
@@ -94,53 +94,53 @@ static rt_err_t es32f3_pwm_control(struct rt_device_pwm *device, int cmd, void *
break
;
case
PWM_CMD_SET
:
/*当通道没开的时候:关通道,设置输出模式和极性,初始化通道*/
if
(
!
_ccep_ch_en
)
{
tim_ocinit
.
oc_mode
=
ES_PWM_OC_MODE
;
if
(
!
_ccep_ch_en
)
{
tim_ocinit
.
oc_mode
=
ES_PWM_OC_MODE
;
tim_ocinit
.
oc_polarity
=
ES_PWM_OC_POLARITY
;
tim_ocinit
.
oc_fast_en
=
DISABLE
;
tim_ocinit
.
ocn_polarity
=
TIMER_OCN_POLARITY_HIGH
;
tim_ocinit
.
ocn_idle
=
TIMER_OCN_IDLE_RESET
;
tim_ocinit
.
oc_idle
=
TIMER_OC_IDLE_RESET
;
ald_timer_oc_config_channel
(
timer_initstruct
,
&
tim_ocinit
,
pwm_channel
);
}
bus_speed
=
(
uint64_t
)
ald_cmu_get_pclk1_clock
();
/*判断外设的计数器最大值*/
#ifdef ES32F36xx
#ifdef ES32F36xx
if
((
timer_initstruct
->
perh
==
GP32C4T0
)
||
(
timer_initstruct
->
perh
==
GP32C4T1
))
{
_maxcnt
=
0xFFFFFFFF
;
_maxcnt
=
0xFFFFFFFF
;
}
else
_maxcnt
=
0xFFFF
;
#else
_maxcnt
=
0xFFFF
;
#endif
#endif
/*当最大分频 <= _maxcnt时:估计大概的分频,加快速度 */
tmp
=
bus_speed
*
(
cfg
->
period
)
/
1000000000
/
_maxcnt
;
timer_initstruct
->
init
.
prescaler
=
(
tmp
>
2U
)
?
(
tmp
-
2U
)
:
0U
;
/*bus_speed < 500000000*/
/* count registers max , auto adjust prescaler */
do
{
_arr
=
bus_speed
*
(
cfg
->
period
)
/
1000000000
/
(
++
timer_initstruct
->
init
.
prescaler
);
}
while
(
_arr
>
_maxcnt
);
while
(
_arr
>
_maxcnt
);
WRITE_REG
(
timer_initstruct
->
perh
->
AR
,
(
uint32_t
)
_arr
);
timer_initstruct
->
init
.
period
=
(
uint32_t
)
_arr
;
/* update prescaler */
WRITE_REG
(
timer_initstruct
->
perh
->
PRES
,
--
timer_initstruct
->
init
.
prescaler
);
pwm_set_duty
(
timer_initstruct
,
pwm_channel
,
cfg
->
pulse
);
break
;
case
PWM_CMD_GET
:
...
...
@@ -181,25 +181,25 @@ int rt_hw_pwm_init(void)
/* gpio initialization */
#if defined(ES_AD16C4T0_CH1_GPIO_FUNC)&&defined(ES_AD16C4T0_CH1_GPIO_PORT)&&defined(ES_AD16C4T0_CH1_GPIO_PIN)
#if defined(ES_AD16C4T0_CH1_GPIO_FUNC)&&defined(ES_AD16C4T0_CH1_GPIO_PORT)&&defined(ES_AD16C4T0_CH1_GPIO_PIN)
gpio_initstructure
.
func
=
ES_AD16C4T0_CH1_GPIO_FUNC
;
ald_gpio_init
(
ES_AD16C4T0_CH1_GPIO_PORT
,
ES_AD16C4T0_CH1_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_AD16C4T0_CH2_GPIO_FUNC)&&defined(ES_AD16C4T0_CH2_GPIO_PORT)&&defined(ES_AD16C4T0_CH2_GPIO_PIN)
#endif
#if defined(ES_AD16C4T0_CH2_GPIO_FUNC)&&defined(ES_AD16C4T0_CH2_GPIO_PORT)&&defined(ES_AD16C4T0_CH2_GPIO_PIN)
gpio_initstructure
.
func
=
ES_AD16C4T0_CH2_GPIO_FUNC
;
ald_gpio_init
(
ES_AD16C4T0_CH2_GPIO_PORT
,
ES_AD16C4T0_CH2_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#endif
#if defined(ES_AD16C4T0_CH3_GPIO_FUNC)&&defined(ES_AD16C4T0_CH3_GPIO_PORT)&&defined(ES_AD16C4T0_CH3_GPIO_FUNC)
#if defined(ES_AD16C4T0_CH3_GPIO_FUNC)&&defined(ES_AD16C4T0_CH3_GPIO_PORT)&&defined(ES_AD16C4T0_CH3_GPIO_FUNC)
gpio_initstructure
.
func
=
ES_AD16C4T0_CH3_GPIO_FUNC
;
ald_gpio_init
(
ES_AD16C4T0_CH3_GPIO_PORT
,
ES_AD16C4T0_CH3_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#endif
#if defined(ES_AD16C4T0_CH4_GPIO_FUNC)&&defined(ES_AD16C4T0_CH4_GPIO_PORT)&&defined(ES_AD16C4T0_CH4_GPIO_PIN)
#if defined(ES_AD16C4T0_CH4_GPIO_FUNC)&&defined(ES_AD16C4T0_CH4_GPIO_PORT)&&defined(ES_AD16C4T0_CH4_GPIO_PIN)
gpio_initstructure
.
func
=
ES_AD16C4T0_CH4_GPIO_FUNC
;
ald_gpio_init
(
ES_AD16C4T0_CH4_GPIO_PORT
,
ES_AD16C4T0_CH4_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ald_gpio_init
(
ES_AD16C4T0_CH4_GPIO_PORT
,
ES_AD16C4T0_CH4_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ret
=
rt_device_pwm_register
(
&
ad16c4t0_pwm_dev
,
ES_DEVICE_NAME_AD16C4T0_PWM
,
&
es32f3_pwm_ops
,
&
ad16c4t0_timer_initstruct
);
...
...
@@ -213,26 +213,26 @@ int rt_hw_pwm_init(void)
ald_timer_pwm_init
(
&
ad16c4t1_timer_initstruct
);
/* gpio initialization */
#if defined(ES_AD16C4T1_CH1_GPIO_FUNC)&&defined(ES_AD16C4T1_CH1_GPIO_PORT)&&defined(ES_AD16C4T1_CH1_GPIO_PIN)
#if defined(ES_AD16C4T1_CH1_GPIO_FUNC)&&defined(ES_AD16C4T1_CH1_GPIO_PORT)&&defined(ES_AD16C4T1_CH1_GPIO_PIN)
gpio_initstructure
.
func
=
ES_AD16C4T1_CH1_GPIO_FUNC
;
ald_gpio_init
(
ES_AD16C4T1_CH1_GPIO_PORT
,
ES_AD16C4T1_CH1_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_AD16C4T1_CH2_GPIO_FUNC)&&defined(ES_AD16C4T1_CH2_GPIO_PORT)&&defined(ES_AD16C4T1_CH2_GPIO_PIN)
ald_gpio_init
(
ES_AD16C4T1_CH1_GPIO_PORT
,
ES_AD16C4T1_CH1_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_AD16C4T1_CH2_GPIO_FUNC)&&defined(ES_AD16C4T1_CH2_GPIO_PORT)&&defined(ES_AD16C4T1_CH2_GPIO_PIN)
gpio_initstructure
.
func
=
ES_AD16C4T1_CH2_GPIO_FUNC
;
ald_gpio_init
(
ES_AD16C4T1_CH2_GPIO_PORT
,
ES_AD16C4T1_CH2_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ald_gpio_init
(
ES_AD16C4T1_CH2_GPIO_PORT
,
ES_AD16C4T1_CH2_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_AD16C4T1_CH3_GPIO_FUNC)&&defined(ES_AD16C4T1_CH3_GPIO_PORT)&&defined(ES_AD16C4T1_CH3_GPIO_PIN)
#if defined(ES_AD16C4T1_CH3_GPIO_FUNC)&&defined(ES_AD16C4T1_CH3_GPIO_PORT)&&defined(ES_AD16C4T1_CH3_GPIO_PIN)
gpio_initstructure
.
func
=
ES_AD16C4T1_CH3_GPIO_FUNC
;
ald_gpio_init
(
ES_AD16C4T1_CH3_GPIO_PORT
,
ES_AD16C4T1_CH3_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#endif
#if defined(ES_AD16C4T1_CH4_GPIO_FUNC)&&defined(ES_AD16C4T1_CH4_GPIO_PORT)&&defined(ES_AD16C4T1_CH4_GPIO_PIN)
gpio_initstructure
.
func
=
ES_AD16C4T1_CH4_GPIO_FUNC
;
ald_gpio_init
(
ES_AD16C4T1_CH4_GPIO_PORT
,
ES_AD16C4T1_CH4_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ald_gpio_init
(
ES_AD16C4T1_CH4_GPIO_PORT
,
ES_AD16C4T1_CH4_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ret
=
rt_device_pwm_register
(
&
ad16c4t1_pwm_dev
,
ES_DEVICE_NAME_AD16C4T1_PWM
,
&
es32f3_pwm_ops
,
&
ad16c4t1_timer_initstruct
);
...
...
@@ -247,26 +247,26 @@ int rt_hw_pwm_init(void)
ald_timer_pwm_init
(
&
gp32c4t0_timer_initstruct
);
/* gpio initialization */
#if defined(ES_GP32C4T0_CH1_GPIO_FUNC)&&defined(ES_GP32C4T0_CH1_GPIO_PORT)&&defined(ES_GP32C4T0_CH1_GPIO_PIN)
#if defined(ES_GP32C4T0_CH1_GPIO_FUNC)&&defined(ES_GP32C4T0_CH1_GPIO_PORT)&&defined(ES_GP32C4T0_CH1_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP32C4T0_CH1_GPIO_FUNC
;
ald_gpio_init
(
ES_GP32C4T0_CH1_GPIO_PORT
,
ES_GP32C4T0_CH1_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_GP32C4T0_CH2_GPIO_FUNC)&&defined(ES_GP32C4T0_CH2_GPIO_PORT)&&defined(ES_GP32C4T0_CH2_GPIO_PIN)
ald_gpio_init
(
ES_GP32C4T0_CH1_GPIO_PORT
,
ES_GP32C4T0_CH1_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_GP32C4T0_CH2_GPIO_FUNC)&&defined(ES_GP32C4T0_CH2_GPIO_PORT)&&defined(ES_GP32C4T0_CH2_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP32C4T0_CH2_GPIO_FUNC
;
ald_gpio_init
(
ES_GP32C4T0_CH2_GPIO_PORT
,
ES_GP32C4T0_CH2_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ald_gpio_init
(
ES_GP32C4T0_CH2_GPIO_PORT
,
ES_GP32C4T0_CH2_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_GP32C4T0_CH3_GPIO_FUNC)&&defined(ES_GP32C4T0_CH3_GPIO_PORT)&&defined(ES_GP32C4T0_CH3_GPIO_PIN)
#if defined(ES_GP32C4T0_CH3_GPIO_FUNC)&&defined(ES_GP32C4T0_CH3_GPIO_PORT)&&defined(ES_GP32C4T0_CH3_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP32C4T0_CH3_GPIO_FUNC
;
ald_gpio_init
(
ES_GP32C4T0_CH3_GPIO_PORT
,
ES_GP32C4T0_CH3_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#endif
#if defined(ES_GP32C4T0_CH4_GPIO_FUNC)&&defined(ES_GP32C4T0_CH4_GPIO_PORT)&&defined(ES_GP32C4T0_CH4_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP32C4T0_CH4_GPIO_FUNC
;
ald_gpio_init
(
ES_GP32C4T0_CH4_GPIO_PORT
,
ES_GP32C4T0_CH4_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ald_gpio_init
(
ES_GP32C4T0_CH4_GPIO_PORT
,
ES_GP32C4T0_CH4_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ret
=
rt_device_pwm_register
(
&
gp32c4t0_pwm_dev
,
ES_DEVICE_NAME_AD16C4T1_PWM
,
&
es32f3_pwm_ops
,
&
gp32c4t0_timer_initstruct
);
...
...
@@ -281,26 +281,26 @@ int rt_hw_pwm_init(void)
ald_timer_pwm_init
(
&
gp32c4t1_timer_initstruct
);
/* gpio initialization */
#if defined(ES_GP32C4T1_CH1_GPIO_FUNC)&&defined(ES_GP32C4T1_CH1_GPIO_PORT)&&defined(ES_GP32C4T1_CH1_GPIO_PIN)
#if defined(ES_GP32C4T1_CH1_GPIO_FUNC)&&defined(ES_GP32C4T1_CH1_GPIO_PORT)&&defined(ES_GP32C4T1_CH1_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP32C4T1_CH1_GPIO_FUNC
;
ald_gpio_init
(
ES_GP32C4T1_CH1_GPIO_PORT
,
ES_GP32C4T1_CH1_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_GP32C4T1_CH2_GPIO_FUNC)&&defined(ES_GP32C4T1_CH2_GPIO_PORT)&&defined(ES_GP32C4T1_CH2_GPIO_PIN)
ald_gpio_init
(
ES_GP32C4T1_CH1_GPIO_PORT
,
ES_GP32C4T1_CH1_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_GP32C4T1_CH2_GPIO_FUNC)&&defined(ES_GP32C4T1_CH2_GPIO_PORT)&&defined(ES_GP32C4T1_CH2_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP32C4T1_CH2_GPIO_FUNC
;
ald_gpio_init
(
ES_GP32C4T1_CH2_GPIO_PORT
,
ES_GP32C4T1_CH2_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ald_gpio_init
(
ES_GP32C4T1_CH2_GPIO_PORT
,
ES_GP32C4T1_CH2_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_GP32C4T1_CH3_GPIO_FUNC)&&defined(ES_GP32C4T1_CH3_GPIO_PORT)&&defined(ES_GP32C4T1_CH3_GPIO_PIN)
#if defined(ES_GP32C4T1_CH3_GPIO_FUNC)&&defined(ES_GP32C4T1_CH3_GPIO_PORT)&&defined(ES_GP32C4T1_CH3_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP32C4T1_CH3_GPIO_FUNC
;
ald_gpio_init
(
ES_GP32C4T1_CH3_GPIO_PORT
,
ES_GP32C4T1_CH3_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#endif
#if defined(ES_GP32C4T1_CH4_GPIO_FUNC)&&defined(ES_GP32C4T1_CH4_GPIO_PORT)&&defined(ES_GP32C4T1_CH4_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP32C4T1_CH4_GPIO_FUNC
;
ald_gpio_init
(
ES_GP32C4T1_CH4_GPIO_PORT
,
ES_GP32C4T1_CH4_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ald_gpio_init
(
ES_GP32C4T1_CH4_GPIO_PORT
,
ES_GP32C4T1_CH4_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ret
=
rt_device_pwm_register
(
&
gp32c4t1_pwm_dev
,
ES_DEVICE_NAME_GP32C4T1_PWM
,
&
es32f3_pwm_ops
,
&
gp32c4t1_timer_initstruct
);
...
...
@@ -315,26 +315,26 @@ int rt_hw_pwm_init(void)
ald_timer_pwm_init
(
&
gp16c4t0_timer_initstruct
);
/* gpio initialization */
#if defined(ES_GP16C4T0_CH1_GPIO_FUNC)&&defined(ES_GP16C4T0_CH1_GPIO_PORT)&&defined(ES_GP16C4T0_CH1_GPIO_PIN)
#if defined(ES_GP16C4T0_CH1_GPIO_FUNC)&&defined(ES_GP16C4T0_CH1_GPIO_PORT)&&defined(ES_GP16C4T0_CH1_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP16C4T0_CH1_GPIO_FUNC
;
ald_gpio_init
(
ES_GP16C4T0_CH1_GPIO_PORT
,
ES_GP16C4T0_CH1_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_GP16C4T0_CH2_GPIO_FUNC)&&defined(ES_GP16C4T0_CH2_GPIO_PORT)&&defined(ES_GP16C4T0_CH2_GPIO_PIN)
ald_gpio_init
(
ES_GP16C4T0_CH1_GPIO_PORT
,
ES_GP16C4T0_CH1_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_GP16C4T0_CH2_GPIO_FUNC)&&defined(ES_GP16C4T0_CH2_GPIO_PORT)&&defined(ES_GP16C4T0_CH2_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP16C4T0_CH2_GPIO_FUNC
;
ald_gpio_init
(
ES_GP16C4T0_CH2_GPIO_PORT
,
ES_GP16C4T0_CH2_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ald_gpio_init
(
ES_GP16C4T0_CH2_GPIO_PORT
,
ES_GP16C4T0_CH2_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_GP16C4T0_CH3_GPIO_FUNC)&&defined(ES_GP16C4T0_CH3_GPIO_PORT)&&defined(ES_GP16C4T0_CH3_GPIO_PIN)
#if defined(ES_GP16C4T0_CH3_GPIO_FUNC)&&defined(ES_GP16C4T0_CH3_GPIO_PORT)&&defined(ES_GP16C4T0_CH3_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP16C4T0_CH3_GPIO_FUNC
;
ald_gpio_init
(
ES_GP16C4T0_CH3_GPIO_PORT
,
ES_GP16C4T0_CH3_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#endif
#if defined(ES_GP16C4T0_CH4_GPIO_FUNC)&&defined(ES_GP16C4T0_CH4_GPIO_PORT)&&defined(ES_GP16C4T0_CH4_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP16C4T0_CH4_GPIO_FUNC
;
ald_gpio_init
(
ES_GP16C4T0_CH4_GPIO_PORT
,
ES_GP16C4T0_CH4_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ald_gpio_init
(
ES_GP16C4T0_CH4_GPIO_PORT
,
ES_GP16C4T0_CH4_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ret
=
rt_device_pwm_register
(
&
gp16c4t0_pwm_dev
,
ES_DEVICE_NAME_GP16C4T0_PWM
,
&
es32f3_pwm_ops
,
&
gp16c4t0_timer_initstruct
);
...
...
@@ -349,26 +349,26 @@ int rt_hw_pwm_init(void)
ald_timer_pwm_init
(
&
gp16c4t1_timer_initstruct
);
/* gpio initialization */
#if defined(ES_GP16C4T1_CH1_GPIO_FUNC)&&defined(ES_GP16C4T1_CH1_GPIO_PORT)&&defined(ES_GP16C4T1_CH1_GPIO_PIN)
#if defined(ES_GP16C4T1_CH1_GPIO_FUNC)&&defined(ES_GP16C4T1_CH1_GPIO_PORT)&&defined(ES_GP16C4T1_CH1_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP16C4T1_CH1_GPIO_FUNC
;
ald_gpio_init
(
ES_GP16C4T1_CH1_GPIO_PORT
,
ES_GP16C4T1_CH1_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_GP16C4T1_CH2_GPIO_FUNC)&&defined(ES_GP16C4T1_CH2_GPIO_PORT)&&defined(ES_GP16C4T1_CH2_GPIO_PIN)
ald_gpio_init
(
ES_GP16C4T1_CH1_GPIO_PORT
,
ES_GP16C4T1_CH1_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_GP16C4T1_CH2_GPIO_FUNC)&&defined(ES_GP16C4T1_CH2_GPIO_PORT)&&defined(ES_GP16C4T1_CH2_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP16C4T1_CH2_GPIO_FUNC
;
ald_gpio_init
(
ES_GP16C4T1_CH2_GPIO_PORT
,
ES_GP16C4T1_CH2_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ald_gpio_init
(
ES_GP16C4T1_CH2_GPIO_PORT
,
ES_GP16C4T1_CH2_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_GP16C4T1_CH3_GPIO_FUNC)&&defined(ES_GP16C4T1_CH3_GPIO_PORT)&&defined(ES_GP16C4T1_CH3_GPIO_PIN)
#if defined(ES_GP16C4T1_CH3_GPIO_FUNC)&&defined(ES_GP16C4T1_CH3_GPIO_PORT)&&defined(ES_GP16C4T1_CH3_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP16C4T1_CH3_GPIO_FUNC
;
ald_gpio_init
(
ES_GP16C4T1_CH3_GPIO_PORT
,
ES_GP16C4T1_CH3_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#endif
#if defined(ES_GP16C4T1_CH4_GPIO_FUNC)&&defined(ES_GP16C4T1_CH4_GPIO_PORT)&&defined(ES_GP16C4T1_CH4_GPIO_PIN)
gpio_initstructure
.
func
=
ES_GP16C4T1_CH4_GPIO_FUNC
;
ald_gpio_init
(
ES_GP16C4T1_CH4_GPIO_PORT
,
ES_GP16C4T1_CH4_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ald_gpio_init
(
ES_GP16C4T1_CH4_GPIO_PORT
,
ES_GP16C4T1_CH4_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ret
=
rt_device_pwm_register
(
&
gp16c4t1_pwm_dev
,
ES_DEVICE_NAME_GP16C4T1_PWM
,
&
es32f3_pwm_ops
,
&
gp16c4t1_timer_initstruct
);
...
...
bsp/essemi/es32f369x/drivers/drv_rtc.c
浏览文件 @
3482bf86
...
...
@@ -18,17 +18,17 @@
* Change Logs:
* Date Author Notes
* 2019-03-22 wangyq the first version
* 2019-11-01 wangyq update libraries
* 2019-11-01 wangyq update libraries
* 2021-04-20 liuhy the second version
*/
#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>
#include <rtdevice.h>
#include <sys/time.h>
#include <string.h>
#include "board.h"
#include "drv_rtc.h"
#include "drv_rtc.h"
#ifdef RT_USING_RTC
...
...
@@ -128,7 +128,7 @@ int rt_hw_rtc_init(void)
rt_err_t
ret
=
RT_EOK
;
static
struct
rt_device
rtc_dev
;
rtc_init_t
rtc_initstruct
;
/* enable clk */
ald_rtc_source_select
(
ES_RTC_CLK_SOURCE
);
...
...
@@ -137,18 +137,18 @@ int rt_hw_rtc_init(void)
CMU_LOSC_ENABLE
();
ald_cmu_losc_safe_config
(
ENABLE
);
}
/* set default time */
RTC_UNLOCK
();
WRITE_REG
(
RTC
->
TIME
,
0x134251
);
WRITE_REG
(
RTC
->
DATE
,
0x1190401
);
RTC_LOCK
();
/* RTC function initialization */
rtc_initstruct
.
hour_format
=
RTC_HOUR_FORMAT_24
;
rtc_initstruct
.
asynch_pre_div
=
0
;
rtc_initstruct
.
synch_pre_div
=
32767
;
rtc_initstruct
.
output
=
RTC_OUTPUT_DISABLE
;
rtc_initstruct
.
output
=
RTC_OUTPUT_DISABLE
;
rtc_initstruct
.
output_polarity
=
RTC_OUTPUT_POLARITY_HIGH
;
__rtc_init
(
&
rtc_initstruct
);
...
...
bsp/essemi/es32f369x/drivers/drv_rtc.h
浏览文件 @
3482bf86
...
...
@@ -17,7 +17,7 @@
*
* Change Logs:
* Date Author Notes
* 2019-03-22 wangyq the first version
* 2019-03-22 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
bsp/essemi/es32f369x/drivers/drv_spi.c
浏览文件 @
3482bf86
...
...
@@ -16,9 +16,9 @@
* limitations under the License.
*
* Change Logs:
* Date Author Notes
* 2019-11-01 wangyq update libraries
* 2020-01-14 wangyq the first version
* Date Author Notes
* 2019-11-01 wangyq update libraries
* 2020-01-14 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
@@ -43,7 +43,7 @@ rt_err_t spi_configure(struct rt_spi_device *device,
hspi
->
init
.
ss_en
=
DISABLE
;
hspi
->
init
.
crc_calc
=
DISABLE
;
hspi
->
init
.
frame
=
SPI_FRAME_MOTOROLA
;
/* config spi mode */
if
(
cfg
->
mode
&
RT_SPI_SLAVE
)
{
...
...
@@ -86,7 +86,7 @@ rt_err_t spi_configure(struct rt_spi_device *device,
{
hspi
->
init
.
first_bit
=
SPI_FIRSTBIT_LSB
;
}
if
(
cfg
->
mode
&
RT_SPI_CPOL
)
{
hspi
->
init
.
polarity
=
SPI_CPOL_HIGH
;
...
...
@@ -157,7 +157,7 @@ rt_err_t spi_configure(struct rt_spi_device *device,
{
hspi
->
init
.
baud
=
SPI_BAUD_256
;
}
ald_spi_init
(
hspi
);
return
RT_EOK
;
}
...
...
@@ -171,7 +171,7 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
RT_ASSERT
(
device
!=
RT_NULL
);
RT_ASSERT
(
device
->
bus
!=
RT_NULL
);
RT_ASSERT
(
device
->
bus
->
parent
.
user_data
!=
RT_NULL
);
hspi
=
(
spi_handle_t
*
)
device
->
bus
->
parent
.
user_data
;
cs
=
device
->
parent
.
user_data
;
...
...
@@ -179,7 +179,7 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
{
rt_pin_write
(
cs
->
pin
,
ES_SPI_CS_LEVEL
);
}
if
(
message
->
send_buf
!=
RT_NULL
||
message
->
recv_buf
!=
RT_NULL
)
{
/* send & receive */
...
...
@@ -201,28 +201,28 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
res
=
ald_spi_recv
(
hspi
,
(
rt_uint8_t
*
)
message
->
recv_buf
,
(
rt_int32_t
)
message
->
length
,
SPITIMEOUT
);
}
}
if
(
message
->
cs_release
)
{
rt_pin_write
(
cs
->
pin
,
!
ES_SPI_CS_LEVEL
);
}
if
(
res
!=
RT_EOK
)
if
(
res
!=
RT_EOK
)
return
RT_ERROR
;
else
else
return
message
->
length
;
}
else
{
if
(
message
->
cs_release
)
{
rt_pin_write
(
cs
->
pin
,
!
ES_SPI_CS_LEVEL
);
}
return
RT_EOK
;
}
}
const
struct
rt_spi_ops
es32f3_spi_ops
=
...
...
@@ -242,19 +242,19 @@ rt_err_t es32f3_spi_device_attach(rt_uint32_t pin, const char *bus_name, const c
cs_pin
->
pin
=
pin
;
rt_pin_mode
(
pin
,
PIN_MODE_OUTPUT
);
rt_pin_write
(
pin
,
1
);
result
=
rt_spi_bus_attach_device
(
spi_device
,
device_name
,
bus_name
,
(
void
*
)
cs_pin
);
#ifdef BSP_USING_SPI0
if
(
!
(
strcmp
(
bus_name
,
ES_DEVICE_NAME_SPI0_BUS
)))
SPI_BUS_CONFIG
(
spi_device
->
config
,
0
);
#endif
#ifdef BSP_USING_SPI1
if
(
!
(
strcmp
(
bus_name
,
ES_DEVICE_NAME_SPI1_BUS
)))
SPI_BUS_CONFIG
(
spi_device
->
config
,
1
);
#endif
#ifdef BSP_USING_SPI2
if
(
!
(
strcmp
(
bus_name
,
ES_DEVICE_NAME_SPI2_BUS
)))
SPI_BUS_CONFIG
(
spi_device
->
config
,
2
);
#endif
#ifdef BSP_USING_SPI0
if
(
!
(
strcmp
(
bus_name
,
ES_DEVICE_NAME_SPI0_BUS
)))
SPI_BUS_CONFIG
(
spi_device
->
config
,
0
);
#endif
#ifdef BSP_USING_SPI1
if
(
!
(
strcmp
(
bus_name
,
ES_DEVICE_NAME_SPI1_BUS
)))
SPI_BUS_CONFIG
(
spi_device
->
config
,
1
);
#endif
#ifdef BSP_USING_SPI2
if
(
!
(
strcmp
(
bus_name
,
ES_DEVICE_NAME_SPI2_BUS
)))
SPI_BUS_CONFIG
(
spi_device
->
config
,
2
);
#endif
return
result
;
}
...
...
@@ -280,14 +280,14 @@ int rt_hw_spi_init(void)
struct
rt_spi_bus
*
spi_bus
;
spi_handle_t
*
spi
;
gpio_init_t
gpio_instruct
;
gpio_instruct
.
pupd
=
GPIO_PUSH_UP_DOWN
;
gpio_instruct
.
odos
=
GPIO_PUSH_PULL
;
gpio_instruct
.
podrv
=
GPIO_OUT_DRIVE_6
;
gpio_instruct
.
nodrv
=
GPIO_OUT_DRIVE_6
;
gpio_instruct
.
type
=
GPIO_TYPE_TTL
;
gpio_instruct
.
flt
=
GPIO_FILTER_DISABLE
;
#ifdef BSP_USING_SPI0
_spi0
.
perh
=
SPI0
;
spi_bus
=
&
_spi_bus0
;
...
...
@@ -299,19 +299,19 @@ int rt_hw_spi_init(void)
#if defined(ES_SPI0_SCK_GPIO_FUNC)&&defined(ES_SPI0_SCK_GPIO_PORT)&&defined(ES_SPI0_SCK_GPIO_PIN)
gpio_instruct
.
func
=
ES_SPI0_SCK_GPIO_FUNC
;
ald_gpio_init
(
ES_SPI0_SCK_GPIO_PORT
,
ES_SPI0_SCK_GPIO_PIN
,
&
gpio_instruct
);
#endif
#endif
#if defined(ES_SPI0_MOSI_GPIO_FUNC)&&defined(ES_SPI0_MOSI_GPIO_PORT)&&defined(ES_SPI0_MOSI_GPIO_PIN)
#if defined(ES_SPI0_MOSI_GPIO_FUNC)&&defined(ES_SPI0_MOSI_GPIO_PORT)&&defined(ES_SPI0_MOSI_GPIO_PIN)
gpio_instruct
.
func
=
ES_SPI0_MOSI_GPIO_FUNC
;
ald_gpio_init
(
ES_SPI0_MOSI_GPIO_PORT
,
ES_SPI0_MOSI_GPIO_PIN
,
&
gpio_instruct
);
#endif
#endif
gpio_instruct
.
mode
=
GPIO_MODE_INPUT
;
#if defined(ES_SPI0_MISO_GPIO_FUNC)&&defined(ES_SPI0_MISO_GPIO_PORT)&&defined(ES_SPI0_MISO_GPIO_PIN)
#if defined(ES_SPI0_MISO_GPIO_FUNC)&&defined(ES_SPI0_MISO_GPIO_PORT)&&defined(ES_SPI0_MISO_GPIO_PIN)
gpio_instruct
.
func
=
ES_SPI0_MISO_GPIO_FUNC
;
ald_gpio_init
(
ES_SPI0_MISO_GPIO_PORT
,
ES_SPI0_MISO_GPIO_PIN
,
&
gpio_instruct
);
#endif
#endif
spi_bus
->
parent
.
user_data
=
spi
;
result
=
rt_spi_bus_register
(
spi_bus
,
ES_DEVICE_NAME_SPI0_BUS
,
&
es32f3_spi_ops
);
...
...
@@ -319,14 +319,14 @@ int rt_hw_spi_init(void)
{
return
result
;
}
result
=
es32f3_spi_device_attach
(
ES_SPI0_NSS_PIN
,
ES_DEVICE_NAME_SPI0_BUS
,
ES_DEVICE_NAME_SPI0_DEV0
);
if
(
result
!=
RT_EOK
)
{
return
result
;
}
#endif
#ifdef BSP_USING_SPI1
...
...
@@ -336,23 +336,23 @@ int rt_hw_spi_init(void)
/* SPI1 gpio init */
gpio_instruct
.
mode
=
GPIO_MODE_OUTPUT
;
#if defined(ES_SPI1_SCK_GPIO_FUNC)&&defined(ES_SPI1_SCK_GPIO_PORT)&&defined(ES_SPI1_SCK_GPIO_PIN)
gpio_instruct
.
func
=
ES_SPI1_SCK_GPIO_FUNC
;
ald_gpio_init
(
ES_SPI1_SCK_GPIO_PORT
,
ES_SPI1_SCK_GPIO_PIN
,
&
gpio_instruct
);
#endif
#if defined(ES_SPI1_MOSI_GPIO_FUNC)&&defined(ES_SPI1_MOSI_GPIO_PORT)&&defined(ES_SPI1_MOSI_GPIO_PIN)
ald_gpio_init
(
ES_SPI1_SCK_GPIO_PORT
,
ES_SPI1_SCK_GPIO_PIN
,
&
gpio_instruct
);
#endif
#if defined(ES_SPI1_MOSI_GPIO_FUNC)&&defined(ES_SPI1_MOSI_GPIO_PORT)&&defined(ES_SPI1_MOSI_GPIO_PIN)
gpio_instruct
.
func
=
ES_SPI1_MOSI_GPIO_FUNC
;
ald_gpio_init
(
ES_SPI1_MOSI_GPIO_PORT
,
ES_SPI1_MOSI_GPIO_PIN
,
&
gpio_instruct
);
#endif
ald_gpio_init
(
ES_SPI1_MOSI_GPIO_PORT
,
ES_SPI1_MOSI_GPIO_PIN
,
&
gpio_instruct
);
#endif
gpio_instruct
.
mode
=
GPIO_MODE_INPUT
;
#if defined(ES_SPI1_MISO_GPIO_FUNC)&&defined(ES_SPI1_MISO_GPIO_PORT)&&defined(ES_SPI1_MISO_GPIO_PIN)
#if defined(ES_SPI1_MISO_GPIO_FUNC)&&defined(ES_SPI1_MISO_GPIO_PORT)&&defined(ES_SPI1_MISO_GPIO_PIN)
gpio_instruct
.
func
=
ES_SPI1_MISO_GPIO_FUNC
;
ald_gpio_init
(
ES_SPI1_MISO_GPIO_PORT
,
ES_SPI1_MISO_GPIO_PIN
,
&
gpio_instruct
);
#endif
ald_gpio_init
(
ES_SPI1_MISO_GPIO_PORT
,
ES_SPI1_MISO_GPIO_PIN
,
&
gpio_instruct
);
#endif
spi_bus
->
parent
.
user_data
=
spi
;
result
=
rt_spi_bus_register
(
spi_bus
,
ES_DEVICE_NAME_SPI1_BUS
,
&
es32f3_spi_ops
);
...
...
@@ -360,14 +360,14 @@ int rt_hw_spi_init(void)
{
return
result
;
}
result
=
es32f3_spi_device_attach
(
ES_SPI1_NSS_PIN
,
ES_DEVICE_NAME_SPI1_BUS
,
ES_DEVICE_NAME_SPI1_DEV0
);
if
(
result
!=
RT_EOK
)
{
return
result
;
}
#endif
#ifdef BSP_USING_SPI2
...
...
@@ -377,23 +377,23 @@ int rt_hw_spi_init(void)
/* SPI2 gpio init */
gpio_instruct
.
mode
=
GPIO_MODE_OUTPUT
;
#if defined(ES_SPI2_SCK_GPIO_FUNC)&&defined(ES_SPI2_SCK_GPIO_PORT)&&defined(ES_SPI2_SCK_GPIO_PIN)
#if defined(ES_SPI2_SCK_GPIO_FUNC)&&defined(ES_SPI2_SCK_GPIO_PORT)&&defined(ES_SPI2_SCK_GPIO_PIN)
gpio_instruct
.
func
=
ES_SPI2_SCK_GPIO_FUNC
;
ald_gpio_init
(
ES_SPI2_SCK_GPIO_PORT
,
ES_SPI2_SCK_GPIO_PIN
,
&
gpio_instruct
);
#endif
#if defined(ES_SPI2_MOSI_GPIO_FUNC)&&defined(ES_SPI2_MOSI_GPIO_PORT)&&defined(ES_SPI2_MOSI_GPIO_PIN)
#endif
#if defined(ES_SPI2_MOSI_GPIO_FUNC)&&defined(ES_SPI2_MOSI_GPIO_PORT)&&defined(ES_SPI2_MOSI_GPIO_PIN)
gpio_instruct
.
func
=
ES_SPI2_MOSI_GPIO_FUNC
;
ald_gpio_init
(
ES_SPI2_MOSI_GPIO_PORT
,
ES_SPI2_MOSI_GPIO_PIN
,
&
gpio_instruct
);
#endif
#endif
gpio_instruct
.
mode
=
GPIO_MODE_INPUT
;
#if defined(ES_SPI2_MISO_GPIO_FUNC)&&defined(ES_SPI2_MISO_GPIO_PORT)&&defined(ES_SPI2_MISO_GPIO_PIN)
#if defined(ES_SPI2_MISO_GPIO_FUNC)&&defined(ES_SPI2_MISO_GPIO_PORT)&&defined(ES_SPI2_MISO_GPIO_PIN)
gpio_instruct
.
func
=
ES_SPI2_MISO_GPIO_FUNC
;
ald_gpio_init
(
ES_SPI2_MISO_GPIO_PORT
,
ES_SPI2_MISO_GPIO_PIN
,
&
gpio_instruct
);
#endif
#endif
spi_bus
->
parent
.
user_data
=
spi
;
result
=
rt_spi_bus_register
(
spi_bus
,
ES_DEVICE_NAME_SPI2_BUS
,
&
es32f3_spi_ops
);
...
...
@@ -401,14 +401,14 @@ int rt_hw_spi_init(void)
{
return
result
;
}
result
=
es32f3_spi_device_attach
(
ES_SPI2_NSS_PIN
,
ES_DEVICE_NAME_SPI2_BUS
,
ES_DEVICE_NAME_SPI1_DEV0
);
if
(
result
!=
RT_EOK
)
{
return
result
;
}
#endif
return
result
;
}
...
...
bsp/essemi/es32f369x/drivers/drv_spi.h
浏览文件 @
3482bf86
...
...
@@ -17,7 +17,7 @@
*
* Change Logs:
* Date Author Notes
* 2020-01-14 wangyq the first version
* 2020-01-14 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
@@ -27,7 +27,7 @@
#include <rtthread.h>
#include <rthw.h>
#include <rtdevice.h>
#include "es_conf_info_spi.h"
struct
es32f3_hw_spi_cs
...
...
bsp/essemi/es32f369x/drivers/drv_spiflash.c
浏览文件 @
3482bf86
...
...
@@ -21,7 +21,7 @@
int
rt_hw_spi_flash_init
(
void
)
{
if
(
RT_NULL
==
rt_sfud_flash_probe
(
ES_DEVICE_NAME_SPI_FALSH_DEV
,
ES_DEVICE_NAME_SPI_DEV
))
{
return
-
RT_ERROR
;
...
...
bsp/essemi/es32f369x/drivers/drv_spiflash.h
浏览文件 @
3482bf86
...
...
@@ -10,7 +10,7 @@
*/
#ifndef DRV_NOR_FLASH_H__
#define DRV_NOR_FLASH_H__
#define DRV_NOR_FLASH_H__
#include "es_conf_info_spi.h"
...
...
bsp/essemi/es32f369x/drivers/drv_uart.c
浏览文件 @
3482bf86
...
...
@@ -17,7 +17,7 @@
*
* Change Logs:
* Date Author Notes
* 2020-01-14 wangyq the first version
* 2020-01-14 wangyq the first version
* 2021-04-20 liuhy the second version
*/
...
...
@@ -211,7 +211,7 @@ static rt_err_t es32f3x_configure(struct rt_serial_device *serial, struct serial
ald_gpio_init
(
ES_UART0_TX_GPIO_PORT
,
ES_UART0_TX_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_UART0_RX_GPIO_FUNC)&&defined(ES_UART0_RX_GPIO_PORT)&&defined(ES_UART0_RX_GPIO_PIN)
#if defined(ES_UART0_RX_GPIO_FUNC)&&defined(ES_UART0_RX_GPIO_PORT)&&defined(ES_UART0_RX_GPIO_PIN)
/* Initialize rx pin ,the same as txpin except mode */
gpio_initstructure
.
mode
=
GPIO_MODE_INPUT
;
gpio_initstructure
.
func
=
ES_UART0_RX_GPIO_FUNC
;
...
...
@@ -219,18 +219,18 @@ static rt_err_t es32f3x_configure(struct rt_serial_device *serial, struct serial
#endif
ald_cmu_perh_clock_config
(
CMU_PERH_UART0
,
ENABLE
);
}
#endif
/* uart0 gpio init */
#ifdef BSP_USING_UART1
if
(
uart
==
(
&
uart1
))
{
#if defined(ES_UART1_TX_GPIO_FUNC)&&defined(ES_UART1_TX_GPIO_PORT)&&defined(ES_UART1_TX_GPIO_PIN)
#if defined(ES_UART1_TX_GPIO_FUNC)&&defined(ES_UART1_TX_GPIO_PORT)&&defined(ES_UART1_TX_GPIO_PIN)
gpio_initstructure
.
func
=
ES_UART1_TX_GPIO_FUNC
;
ald_gpio_init
(
ES_UART1_TX_GPIO_PORT
,
ES_UART1_TX_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_UART1_RX_GPIO_FUNC)&&defined(ES_UART1_RX_GPIO_PORT)&&defined(ES_UART1_RX_GPIO_PIN)
#if defined(ES_UART1_RX_GPIO_FUNC)&&defined(ES_UART1_RX_GPIO_PORT)&&defined(ES_UART1_RX_GPIO_PIN)
/* Initialize rx pin ,the same as txpin except mode */
gpio_initstructure
.
mode
=
GPIO_MODE_INPUT
;
gpio_initstructure
.
func
=
ES_UART1_RX_GPIO_FUNC
;
...
...
@@ -240,7 +240,7 @@ static rt_err_t es32f3x_configure(struct rt_serial_device *serial, struct serial
ald_cmu_perh_clock_config
(
CMU_PERH_UART1
,
ENABLE
);
}
#endif
/* uart1 gpio init */
#ifdef BSP_USING_UART2
if
(
uart
==
(
&
uart2
))
{
...
...
@@ -259,11 +259,11 @@ static rt_err_t es32f3x_configure(struct rt_serial_device *serial, struct serial
ald_cmu_perh_clock_config
(
CMU_PERH_UART2
,
ENABLE
);
}
#endif
/* uart2 gpio init */
#ifdef BSP_USING_UART3
if
(
uart
==
(
&
uart3
))
{
#if defined(ES_UART3_TX_GPIO_FUNC)&&defined(ES_UART3_TX_GPIO_PORT)&&defined(ES_UART3_TX_GPIO_PIN)
#if defined(ES_UART3_TX_GPIO_FUNC)&&defined(ES_UART3_TX_GPIO_PORT)&&defined(ES_UART3_TX_GPIO_PIN)
gpio_initstructure
.
func
=
ES_UART3_TX_GPIO_FUNC
;
ald_gpio_init
(
ES_UART3_TX_GPIO_PORT
,
ES_UART3_TX_GPIO_PIN
,
&
gpio_initstructure
);
#endif
...
...
@@ -275,38 +275,38 @@ static rt_err_t es32f3x_configure(struct rt_serial_device *serial, struct serial
ald_gpio_init
(
ES_UART3_RX_GPIO_PORT
,
ES_UART3_RX_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ald_cmu_perh_clock_config
(
CMU_PERH_UART3
,
ENABLE
);
ald_cmu_perh_clock_config
(
CMU_PERH_UART3
,
ENABLE
);
}
#endif
/* uart3 gpio init */
#ifdef BSP_USING_UART4
if
(
uart
==
(
&
uart4
))
{
#if defined(ES_UART4_TX_GPIO_FUNC)&&defined(ES_UART4_TX_GPIO_PORT)&&defined(ES_UART4_TX_GPIO_PIN)
#if defined(ES_UART4_TX_GPIO_FUNC)&&defined(ES_UART4_TX_GPIO_PORT)&&defined(ES_UART4_TX_GPIO_PIN)
gpio_initstructure
.
func
=
ES_UART4_TX_GPIO_FUNC
;
ald_gpio_init
(
ES_UART4_TX_GPIO_PORT
,
ES_UART4_TX_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_UART4_RX_GPIO_FUNC)&&defined(ES_UART4_RX_GPIO_PORT)&&defined(ES_UART4_RX_GPIO_PIN)
#if defined(ES_UART4_RX_GPIO_FUNC)&&defined(ES_UART4_RX_GPIO_PORT)&&defined(ES_UART4_RX_GPIO_PIN)
/* Initialize rx pin ,the same as txpin except mode */
gpio_initstructure
.
mode
=
GPIO_MODE_INPUT
;
gpio_initstructure
.
func
=
ES_UART4_RX_GPIO_FUNC
;
ald_gpio_init
(
ES_UART4_RX_GPIO_PORT
,
ES_UART4_RX_GPIO_PIN
,
&
gpio_initstructure
);
#endif
ald_cmu_perh_clock_config
(
CMU_PERH_UART4
,
ENABLE
);
ald_cmu_perh_clock_config
(
CMU_PERH_UART4
,
ENABLE
);
}
#endif
/* uart4 gpio init */
#ifdef BSP_USING_UART5
if
(
uart
==
(
&
uart5
))
{
#if defined(ES_UART5_TX_GPIO_FUNC)&&defined(ES_UART5_TX_GPIO_PORT)&&defined(ES_UART5_TX_GPIO_PIN)
#if defined(ES_UART5_TX_GPIO_FUNC)&&defined(ES_UART5_TX_GPIO_PORT)&&defined(ES_UART5_TX_GPIO_PIN)
gpio_initstructure
.
func
=
ES_UART5_TX_GPIO_FUNC
;
ald_gpio_init
(
ES_UART5_TX_GPIO_PORT
,
ES_UART5_TX_GPIO_PIN
,
&
gpio_initstructure
);
#endif
#if defined(ES_UART5_RX_GPIO_FUNC)&&defined(ES_UART5_RX_GPIO_PORT)&&defined(ES_UART5_RX_GPIO_PIN)
#if defined(ES_UART5_RX_GPIO_FUNC)&&defined(ES_UART5_RX_GPIO_PORT)&&defined(ES_UART5_RX_GPIO_PIN)
/* Initialize rx pin ,the same as txpin except mode */
gpio_initstructure
.
mode
=
GPIO_MODE_INPUT
;
gpio_initstructure
.
func
=
ES_UART5_RX_GPIO_FUNC
;
...
...
@@ -324,7 +324,7 @@ static rt_err_t es32f3x_configure(struct rt_serial_device *serial, struct serial
uart
->
huart
.
init
.
baud
=
cfg
->
baud_rate
;
uart
->
huart
.
init
.
word_length
=
(
uart_word_length_t
)(
8
-
cfg
->
data_bits
);
uart
->
huart
.
init
.
parity
=
(
uart_parity_t
)(
cfg
->
parity
==
PARITY_EVEN
?
UART_PARITY_EVEN
:
cfg
->
parity
);
uart
->
huart
.
init
.
fctl
=
UART_HW_FLOW_CTL_DISABLE
;
uart
->
huart
.
init
.
fctl
=
UART_HW_FLOW_CTL_DISABLE
;
uart
->
huart
.
init
.
stop_bits
=
UART_STOP_BITS_1
;
ald_uart_init
(
&
uart
->
huart
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录