mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-09 20:45:41 +08:00
format es32f369x
This commit is contained in:
1 parent
421867f49e
commit
3482bf86dc
50 files changed
+3013
-4430
No files matched your search
@@ -0,0 +1,4 @@
|
||||
# files format check exclude path, please follow the instructions below to modify;
|
||||
|
||||
dir_path:
|
||||
- libraries
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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
|
||||
@@ -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
|
||||
@@ -38,6 +38,6 @@
|
||||
|
||||
#ifndef ES_DEVICE_NAME_RTC
|
||||
#define ES_DEVICE_NAME_RTC "rtc"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
#ifndef ES_SPI0_M_L_SB
|
||||
#define ES_SPI0_M_L_SB RT_SPI_MSB
|
||||
#endif
|
||||
#ifndef ES_SPI0_MAX_HZ
|
||||
#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
|
||||
#endif
|
||||
#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
|
||||
#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
|
||||
#ifndef ES_SPI1_M_L_SB
|
||||
#define ES_SPI1_M_L_SB RT_SPI_MSB
|
||||
#endif
|
||||
#ifndef ES_SPI1_MAX_HZ
|
||||
|
||||
#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
|
||||
#ifndef ES_SPI1_M_L_SB
|
||||
#define ES_SPI1_M_L_SB RT_SPI_MSB
|
||||
#endif
|
||||
#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
|
||||
@@ -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, \
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
# 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
|
||||
@@ -1,47 +0,0 @@
|
||||
# 外设驱动测试用例
|
||||
|
||||
## 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
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -1,148 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* 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. \nmessage: %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. \nmessage: %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
|
||||
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* 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);
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* 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);
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -1,152 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -1,149 +0,0 @@
|
||||
/*
|
||||
* 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);
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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
|
||||
*/
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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
|
||||
*/
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
@@ -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] =
|
||||
|
||||
@@ -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
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user