Skip to content

Commit ee52f3b

Browse files
liuhy-2020wangyq2018
authored andcommitted
update drivers and Libraries.
1 parent 5cd4110 commit ee52f3b

File tree

26 files changed

+623
-164
lines changed

26 files changed

+623
-164
lines changed

RealThread_ES32F3.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
vendor: RealThread
3-
dvendor: Essemi
3+
dvendor: essemi
44
name: ES32F3
5-
version: 0.0.1
5+
version: 0.0.2
66
yaml_version: 1
77
type: Chip_Support_Packages
88
family_name: ES32

drivers/rtt/drv_can.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <board.h>
2828
#include <rtdevice.h>
2929
#include <rtthread.h>
30+
#include <ald_cmu.h>
3031
#include "es_conf_info_can.h"
3132

3233
#ifdef RT_USING_CAN

drivers/rtt/drv_common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ void SysTick_Configuration(void)
127127
{
128128
/* ticks = sysclk / RT_TICK_PER_SECOND */
129129
SysTick_Config(ald_cmu_get_sys_clock() / RT_TICK_PER_SECOND);
130+
131+
__systick_interval = 1;
130132
}
131133

132134
/**

drivers/rtt/drv_example/i2c_sample.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ static void i2c_io_sample(int argc, char *argv[])
6464
temp_msg.flags = RT_I2C_RD; /* I2C读 */
6565
s_stat = rt_i2c_transfer(i2c_bus,&temp_msg,num_msg); /* 传输消息 */
6666

67-
rt_thread_mdelay(400);
68-
6967
if( s_stat == num_msg )
7068
{
7169
rt_kprintf("receive successful. \n receive messege : %s \n:",buffer);
@@ -87,8 +85,6 @@ static void i2c_io_sample(int argc, char *argv[])
8785
temp_msg.flags = RT_I2C_WR; /* I2C写 */
8886
s_stat = rt_i2c_transfer(i2c_bus,&temp_msg,num_msg); /* 传输一条 */
8987

90-
rt_thread_mdelay(400);
91-
9288
if( s_stat == num_msg )
9389
{
9490
rt_kprintf(" send successful \n messege : %s \n:",buffer);

drivers/rtt/drv_example/led_blink_sample.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818

1919
#include <rtthread.h>
2020
#include <rtdevice.h>
21-
#include <stdlib.h>
21+
#include <stdlib.h>
22+
#include "drv_gpio.h"
2223

2324
/* PIN脚编号,查看驱动文件drv_gpio.c确定 */
24-
#define LED_PIN_NUM 19 /*PF1*/
25+
#define LED_PIN_NUM GET_PIN( F , 1 )
2526
static int pin_num;
2627

2728
static void led_entry(void *parameter)

drivers/rtt/drv_example/pin_beep_sample.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@
1515
*/
1616

1717
#include <rtthread.h>
18-
#include <rtdevice.h>
18+
#include <rtdevice.h>
19+
#include "drv_gpio.h"
1920

2021
/* 引脚编号,通过查看驱动文件drv_gpio.c确定 */
2122
#ifndef BEEP_PIN_NUM
22-
#define BEEP_PIN_NUM 19 /* PF1 */
23+
#define BEEP_PIN_NUM GET_PIN( F , 1 )
2324
#endif
2425
#ifndef KEY0_PIN_NUM
25-
#define KEY0_PIN_NUM 52 /* PC11 */
26+
#define KEY0_PIN_NUM GET_PIN( C , 11 )
2627
#endif
2728
#ifndef KEY1_PIN_NUM
28-
#define KEY1_PIN_NUM 53 /* PC12 */
29+
#define KEY1_PIN_NUM GET_PIN( C , 12 )
2930
#endif
3031

3132
void beep_on(void *args)

drivers/rtt/drv_example/pm_sample.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@
3030

3131
#include <rtthread.h>
3232
#include <rtdevice.h>
33-
#include "drv_pm.h"
34-
#include "ald_gpio.h"
35-
33+
#include "drv_pm.h"
34+
#include "drv_gpio.h"
3635

3736
#ifdef RT_USING_PM
3837

39-
#define PM_NAME "pm" /* 设备名称 */
40-
#define WAKE_UP_PIN 51 /* 唤醒源 */
41-
#define SLEEP_TIMES 12 /* 进入睡眠次数,轮流进入不同的睡眠模式,包括无睡眠模式 */
38+
#define PM_NAME "pm" /* 设备名称 */
39+
#define WAKE_UP_PIN GET_PIN( C , 10 ) /* 唤醒源 */
40+
#define SLEEP_TIMES 12 /* 进入睡眠次数,轮流进入不同的睡眠模式,包括无睡眠模式 */
4241

4342
/*部分芯片进入深度睡眠后,部分外设的部分寄存器可能会丢失*/
4443
#define SAVE_REG UART0

drivers/rtt/drv_example/pwm_led_sample.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
#include <rtthread.h>
1818
#include <rtdevice.h>
19-
19+
#include "drv_gpio.h"
2020

2121
#ifdef RT_USING_PWM
2222

23-
#define LED_PIN_NUM 37 /* PF1 LED PIN脚编号,查看驱动文件drv_gpio.c确定 */
24-
#define PWM_DEV_NAME "pwm1" /* PWM设备名称 */
25-
#define PWM_DEV_CHANNEL 1 /* PWM通道 */
23+
#define LED_PIN_NUM GET_PIN( C , 6 ) /* LED PIN脚编号,查看驱动文件drv_gpio.c确定 */
24+
#define PWM_DEV_NAME "pwm1" /* PWM设备名称 */
25+
#define PWM_DEV_CHANNEL 1 /* PWM通道 */
2626

2727
struct rt_device_pwm *pwm_dev; /* PWM设备句柄 */
2828

drivers/rtt/drv_example/uart_sample.c

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,28 @@
1212
* 例程导出了 uart_sample 命令到控制终端
1313
* 命令调用格式:uart_sample uart2
1414
* 命令解释:命令第二个参数是要使用的串口设备名称,为空则使用默认的串口设备
15-
* 程序功能:通过串口输出字符串"hello RT-Thread!",然后错位输出输入的字符
15+
* 程序功能:通过串口输出字符串"hello RT-Thread!",然后根据例子类型,处理输入数据,然后输出
1616
*/
1717

1818
#include <rtthread.h>
1919

20-
#define SAMPLE_UART_NAME "uart0" /* 串口设备名称 */
20+
/* UART_SAMPLE_TYPE = 1,错位输出
21+
= 2 接收到固定格式之后输出
22+
*/
23+
#define UART_SAMPLE_TYPE 1
24+
25+
#if (UART_SAMPLE_TYPE == 2)
26+
27+
#define SAMPLE_UART_RXBUF_SIZE 256 /* 接收缓存大小 */
28+
#define SAMPLE_UART_END_SRTING "\r\n" /* 结尾固定格式 */
29+
30+
#endif
31+
32+
#define SAMPLE_UART_NAME "uart1" /* 串口设备名称 */
2133

2234
/* 用于接收消息的信号量 */
2335
static struct rt_semaphore rx_sem;
24-
static rt_device_t serial;
36+
static rt_device_t serial;
2537

2638
/* 接收数据回调函数 */
2739
static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
@@ -33,7 +45,8 @@ static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
3345
}
3446

3547
static void serial_thread_entry(void *parameter)
36-
{
48+
{
49+
#if (UART_SAMPLE_TYPE == 1)
3750
char ch;
3851

3952
while (1)
@@ -48,6 +61,42 @@ static void serial_thread_entry(void *parameter)
4861
ch = ch + 1;
4962
rt_device_write(serial, 0, &ch, 1);
5063
}
64+
#endif
65+
66+
#if (UART_SAMPLE_TYPE == 2)
67+
char rx_buf[SAMPLE_UART_RXBUF_SIZE],*end = SAMPLE_UART_END_SRTING; /*rx_buf[]:接收缓存,可修改大小 end[]:固定的结束格式(可修改,不可包含'\0')*/
68+
uint32_t rx_index = 0; /*接收数据的索引 */
69+
uint32_t end_len = rt_strlen(end); /*固定的结束格式的长度*/
70+
71+
while(1)
72+
{
73+
74+
/* 从串口读取一个字节的数据,没有读取到则等待接收信号量 */
75+
while (rt_device_read(serial, -1, (rx_buf + rx_index), 1) != 1)
76+
{
77+
/* 阻塞等待接收信号量,等到信号量后再次读取数据 */
78+
rt_sem_take(&rx_sem, RT_WAITING_FOREVER);
79+
}
80+
81+
rx_index++;
82+
if(rx_index >= SAMPLE_UART_RXBUF_SIZE)
83+
{
84+
rt_kprintf("rx_buf over!\r\n"); /*范围越界*/
85+
}
86+
87+
/*判断是否固定的结尾格式*/
88+
if((rx_index >= end_len)&&\
89+
((rt_strncmp(end,(rx_buf + rx_index - end_len),end_len)) == 0))
90+
{
91+
rt_device_write(serial, 0, rx_buf, rx_index);
92+
rx_index = 0;
93+
}
94+
95+
}
96+
97+
98+
#endif
99+
51100
}
52101

53102
static int uart_sample(int argc, char *argv[])

drivers/rtt/drv_gpio.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,18 @@ void es32f3_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
316316

317317
rt_inline const struct pin_irq_map *get_pin_irq_map(rt_uint16_t gpio_pin)
318318
{
319-
rt_int32_t mapindex = gpio_pin & 0x00FF;
320-
if (mapindex < 0 || mapindex >= ITEM_NUM(pin_irq_map))
319+
uint8_t map_index = 0U;
320+
321+
while(gpio_pin >> (++map_index))
322+
{
323+
}
324+
map_index--;
325+
326+
if (map_index >= ITEM_NUM(pin_irq_map))
321327
{
322328
return RT_NULL;
323329
}
324-
return &pin_irq_map[mapindex];
330+
return &pin_irq_map[map_index];
325331
};
326332

327333
rt_err_t es32f3_pin_attach_irq(struct rt_device *device, rt_int32_t pin,

drivers/rtt/drv_gpio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#define DRV_GPIO_H__
2626

2727
#include "es_conf_info_gpio.h"
28+
29+
#define GET_PIN(port,pin) (ES_PIN_GPIO_##port##_##pin)
2830

2931
int rt_hw_pin_init(void);
3032

libraries/CMSIS/Device/EastSoft/ES32F36xx/Startup/gcc/startup_es32f36xx.S

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,41 @@
11
/**
22
******************************************************************************
3+
34
* @file startup_es32f36xx.s
45
* @author AE Team
56
* @brief ES32F36xx devices vector table for GCC toolchain.
67
* This module performs:
78
* - Set the initial SP
89
* - Set the initial PC == Reset_Handler,
9-
* - Set the vector table entries with the exceptions ISR address
10+
* - Set the vector table entries with the exceptions ISR addres
11+
s
1012
* - Branches to main in the C library (which eventually
1113
* calls main()).
1214
* After Reset the Cortex-M3 processor is in Thread mode,
1315
* priority is Privileged, and the Stack is set to Main.
16+
* @note
17+
* Change Logs:
18+
* Date Author Notes
19+
* 23 Jan 2019 AE Team The first version
20+
*
21+
* Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserve
22+
d.
23+
*
24+
* SPDX-License-Identifier: Apache-2.0
25+
*
26+
* Licensed under the Apache License, Version 2.0 (the License); you may
27+
* not use this file except in compliance with the License.
28+
* You may obtain a copy of the License at
29+
*
30+
* www.apache.org/licenses/LICENSE-2.0
31+
*
32+
* Unless required by applicable law or agreed to in writing, software
33+
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
34+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35+
* See the License for the specific language governing permissions and
36+
* limitations under the License.
1437
******************************************************************************
38+
****
1539
*/
1640

1741
.syntax unified
@@ -41,6 +65,48 @@ defined in linker script */
4165
Reset_Handler:
4266
ldr r0, =_estack
4367
mov sp, r0 /* set stack pointer */
68+
69+
ldr r0, =0x55AA6996
70+
ldr r1, =0x40080000
71+
str r0, [r1]
72+
73+
ldr r0, =0x5A962814
74+
ldr r1, =0x40080100
75+
str r0, [r1]
76+
ldr r0, =0xE7CB69A5
77+
str r0, [r1]
78+
79+
ldr r0, =0x40083C00
80+
ldr r1, [r0]
81+
ldr r2, =0xffff
82+
and r1, r2
83+
ldr r2, =0x55AA0000
84+
orr r1, r2
85+
str r1, [r0]
86+
str r1, [r0]
87+
str r1, [r0]
88+
str r1, [r0]
89+
str r1, [r0]
90+
str r1, [r0]
91+
str r1, [r0]
92+
str r1, [r0]
93+
str r1, [r0]
94+
str r1, [r0]
95+
96+
mov r0, r0
97+
mov r0, r0
98+
99+
ldr r0, =0x123456
100+
ldr r1, =0x40080100
101+
str r0, [r1]
102+
103+
ldr r0, =0x40080404
104+
ldr r1, =0x4000000
105+
str r1, [r0]
106+
107+
ldr r0, =0x123456
108+
ldr r1, =0x40080000
109+
str r0, [r1]
44110

45111
/* Copy the data segment initializers from flash to SRAM */
46112
ldr r0, =_sdata
@@ -72,6 +138,9 @@ FillZerobss:
72138
LoopFillZerobss:
73139
cmp r2, r4
74140
bcc FillZerobss
141+
142+
bl sys_config
143+
bl adc_config
75144

76145
/*bl __libc_init_array
77146

0 commit comments

Comments
 (0)