Skip to content

Commit

Permalink
update drivers and Libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
liuhy-2020 authored and wangyq2018 committed Aug 4, 2021
1 parent 5cd4110 commit ee52f3b
Show file tree
Hide file tree
Showing 26 changed files with 623 additions and 164 deletions.
4 changes: 2 additions & 2 deletions RealThread_ES32F3.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
vendor: RealThread
dvendor: Essemi
dvendor: essemi
name: ES32F3
version: 0.0.1
version: 0.0.2
yaml_version: 1
type: Chip_Support_Packages
family_name: ES32
Expand Down
1 change: 1 addition & 0 deletions drivers/rtt/drv_can.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <board.h>
#include <rtdevice.h>
#include <rtthread.h>
#include <ald_cmu.h>
#include "es_conf_info_can.h"

#ifdef RT_USING_CAN
Expand Down
2 changes: 2 additions & 0 deletions drivers/rtt/drv_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ void SysTick_Configuration(void)
{
/* ticks = sysclk / RT_TICK_PER_SECOND */
SysTick_Config(ald_cmu_get_sys_clock() / RT_TICK_PER_SECOND);

__systick_interval = 1;
}

/**
Expand Down
4 changes: 0 additions & 4 deletions drivers/rtt/drv_example/i2c_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ static void i2c_io_sample(int argc, char *argv[])
temp_msg.flags = RT_I2C_RD; /* I2C读 */
s_stat = rt_i2c_transfer(i2c_bus,&temp_msg,num_msg); /* 传输消息 */

rt_thread_mdelay(400);

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

rt_thread_mdelay(400);

if( s_stat == num_msg )
{
rt_kprintf(" send successful \n messege : %s \n:",buffer);
Expand Down
5 changes: 3 additions & 2 deletions drivers/rtt/drv_example/led_blink_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

#include <rtthread.h>
#include <rtdevice.h>
#include <stdlib.h>
#include <stdlib.h>
#include "drv_gpio.h"

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

static void led_entry(void *parameter)
Expand Down
9 changes: 5 additions & 4 deletions drivers/rtt/drv_example/pin_beep_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
*/

#include <rtthread.h>
#include <rtdevice.h>
#include <rtdevice.h>
#include "drv_gpio.h"

/* 引脚编号,通过查看驱动文件drv_gpio.c确定 */
#ifndef BEEP_PIN_NUM
#define BEEP_PIN_NUM 19 /* PF1 */
#define BEEP_PIN_NUM GET_PIN( F , 1 )
#endif
#ifndef KEY0_PIN_NUM
#define KEY0_PIN_NUM 52 /* PC11 */
#define KEY0_PIN_NUM GET_PIN( C , 11 )
#endif
#ifndef KEY1_PIN_NUM
#define KEY1_PIN_NUM 53 /* PC12 */
#define KEY1_PIN_NUM GET_PIN( C , 12 )
#endif

void beep_on(void *args)
Expand Down
11 changes: 5 additions & 6 deletions drivers/rtt/drv_example/pm_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@

#include <rtthread.h>
#include <rtdevice.h>
#include "drv_pm.h"
#include "ald_gpio.h"

#include "drv_pm.h"
#include "drv_gpio.h"

#ifdef RT_USING_PM

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

/*部分芯片进入深度睡眠后,部分外设的部分寄存器可能会丢失*/
#define SAVE_REG UART0
Expand Down
8 changes: 4 additions & 4 deletions drivers/rtt/drv_example/pwm_led_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

#include <rtthread.h>
#include <rtdevice.h>

#include "drv_gpio.h"

#ifdef RT_USING_PWM

#define LED_PIN_NUM 37 /* PF1 LED PIN脚编号,查看驱动文件drv_gpio.c确定 */
#define PWM_DEV_NAME "pwm1" /* PWM设备名称 */
#define PWM_DEV_CHANNEL 1 /* 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设备句柄 */

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

#include <rtthread.h>

#define SAMPLE_UART_NAME "uart0" /* 串口设备名称 */
/* 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_device_t serial;

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

static void serial_thread_entry(void *parameter)
{
{
#if (UART_SAMPLE_TYPE == 1)
char ch;

while (1)
Expand All @@ -48,6 +61,42 @@ static void serial_thread_entry(void *parameter)
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[])
Expand Down
12 changes: 9 additions & 3 deletions drivers/rtt/drv_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,18 @@ 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)
{
rt_int32_t mapindex = gpio_pin & 0x00FF;
if (mapindex < 0 || mapindex >= ITEM_NUM(pin_irq_map))
uint8_t map_index = 0U;

while(gpio_pin >> (++map_index))
{
}
map_index--;

if (map_index >= ITEM_NUM(pin_irq_map))
{
return RT_NULL;
}
return &pin_irq_map[mapindex];
return &pin_irq_map[map_index];
};

rt_err_t es32f3_pin_attach_irq(struct rt_device *device, rt_int32_t pin,
Expand Down
2 changes: 2 additions & 0 deletions drivers/rtt/drv_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#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);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
/**
******************************************************************************
* @file startup_es32f36xx.s
* @author AE Team
* @brief ES32F36xx devices vector table for GCC toolchain.
* This module performs:
* - Set the initial SP
* - Set the initial PC == Reset_Handler,
* - Set the vector table entries with the exceptions ISR address
* - Set the vector table entries with the exceptions ISR addres
s
* - Branches to main in the C library (which eventually
* calls main()).
* After Reset the Cortex-M3 processor is in Thread mode,
* priority is Privileged, and the Stack is set to Main.
* @note
* Change Logs:
* Date Author Notes
* 23 Jan 2019 AE Team The first version
*
* Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserve
d.
*
* 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.
******************************************************************************
****
*/

.syntax unified
Expand Down Expand Up @@ -41,6 +65,48 @@ defined in linker script */
Reset_Handler:
ldr r0, =_estack
mov sp, r0 /* set stack pointer */

ldr r0, =0x55AA6996
ldr r1, =0x40080000
str r0, [r1]

ldr r0, =0x5A962814
ldr r1, =0x40080100
str r0, [r1]
ldr r0, =0xE7CB69A5
str r0, [r1]

ldr r0, =0x40083C00
ldr r1, [r0]
ldr r2, =0xffff
and r1, r2
ldr r2, =0x55AA0000
orr r1, r2
str r1, [r0]
str r1, [r0]
str r1, [r0]
str r1, [r0]
str r1, [r0]
str r1, [r0]
str r1, [r0]
str r1, [r0]
str r1, [r0]
str r1, [r0]

mov r0, r0
mov r0, r0

ldr r0, =0x123456
ldr r1, =0x40080100
str r0, [r1]

ldr r0, =0x40080404
ldr r1, =0x4000000
str r1, [r0]

ldr r0, =0x123456
ldr r1, =0x40080000
str r0, [r1]

/* Copy the data segment initializers from flash to SRAM */
ldr r0, =_sdata
Expand Down Expand Up @@ -72,6 +138,9 @@ FillZerobss:
LoopFillZerobss:
cmp r2, r4
bcc FillZerobss

bl sys_config
bl adc_config

/*bl __libc_init_array
Expand Down
Loading

0 comments on commit ee52f3b

Please sign in to comment.