更新驱动
This commit is contained in:
parent
16d886578a
commit
b4f7c45b13
|
@ -663,7 +663,7 @@
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>Application/MDK-ARM</GroupName>
|
<GroupName>Application/MDK-ARM</GroupName>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
|
@ -683,7 +683,7 @@
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>Application/User/Core</GroupName>
|
<GroupName>Application/User/Core</GroupName>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
|
@ -1259,7 +1259,7 @@
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>User/system</GroupName>
|
<GroupName>User/system</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
|
|
Binary file not shown.
|
@ -95,6 +95,11 @@
|
||||||
*/
|
*/
|
||||||
#define FL_SEM_RELEASE(sem) FLOW_SEM_RELEASE((sem))
|
#define FL_SEM_RELEASE(sem) FLOW_SEM_RELEASE((sem))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测一个信号量是否被释放
|
||||||
|
*/
|
||||||
|
#define FL_SEM_IS_RELEASE(fl ,sem) FLOW_SEM_IS_RELEASE((fl), (sem))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化一个软件定时器
|
* 初始化一个软件定时器
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
--(s)->count; \
|
--(s)->count; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define FLOW_SEM_RELEASE(s) (++(s)->count) // 释放信号量s的计数值
|
#define FLOW_SEM_RELEASE(s) (++(s)->count)
|
||||||
|
|
||||||
|
#define FLOW_SEM_IS_RELEASE(f, s) (flow_tick - (f)->time) < ((s)->time)
|
||||||
|
|
||||||
#endif /* __FLOW_SEM_H__ */
|
#endif /* __FLOW_SEM_H__ */
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
#define __IO volatile
|
#define __IO volatile
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef unsigned char BOOL; /* boolean data */
|
typedef unsigned char BOOL; /* boolean data */
|
||||||
|
typedef unsigned char bool_t; /* boolean data */
|
||||||
|
|
||||||
#if !defined(__stdint_h) && !defined(_GCC_WRAP_STDINT_H)
|
#if !defined(__stdint_h) && !defined(_GCC_WRAP_STDINT_H)
|
||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
|
|
|
@ -33,12 +33,12 @@ typedef struct
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint16_t size; // 滑动窗口大小
|
uint16_t size; // 滑动窗口大小
|
||||||
float32 *window; // 滑动窗口
|
float32 *window; // 滑动窗口
|
||||||
float32 out; // 滤波结果
|
volatile float32 sum; // 滑动窗口和
|
||||||
uint16_t index; // 滑动窗口索引
|
volatile float32 out; // 滤波结果
|
||||||
uint16_t sum;
|
uint16_t index; // 滑动窗口索引
|
||||||
} lpf_window_t; // 滑动窗口滤波器
|
} lpf_window_t; // 滑动窗口滤波器
|
||||||
|
|
||||||
void kalman_init(kalman_t *cfg);
|
void kalman_init(kalman_t *cfg);
|
||||||
void kalman_reset(kalman_t *cfg);
|
void kalman_reset(kalman_t *cfg);
|
||||||
|
|
|
@ -60,14 +60,15 @@ extern uint16_t crc16_compute(const uint8_t *const uc_ptr, uint16_t uc_len); //
|
||||||
extern uint8_t xor_compute(const uint8_t *const uc_ptr, uint16_t uc_len); // 异或校验
|
extern uint8_t xor_compute(const uint8_t *const uc_ptr, uint16_t uc_len); // 异或校验
|
||||||
extern uint8_t get_bit_num(uint8_t bit); // 获取bit位的值
|
extern uint8_t get_bit_num(uint8_t bit); // 获取bit位的值
|
||||||
extern BOOL is_bit_set(int x, int k); // 判断x的第k位是否为1
|
extern BOOL is_bit_set(int x, int k); // 判断x的第k位是否为1
|
||||||
extern uint8_t isLeap(uint16_t year); // 检查是否是闰年
|
extern uint8_t isLeap(uint16_t year); // 检查是否是闰年
|
||||||
extern uint16_t dayOfyear(uint16_t year, uint8_t month, uint8_t day); // 计算一年中的第几天
|
extern uint16_t dayOfyear(uint16_t year, uint8_t month, uint8_t day); // 计算一年中的第几天
|
||||||
extern uint16_t weekOfyear(uint16_t year, uint8_t month, uint8_t day); // 计算一年中的第几周
|
extern uint16_t weekOfyear(uint16_t year, uint8_t month, uint8_t day); // 计算一年中的第几周
|
||||||
extern uint8_t get_weekday(uint16_t year, uint8_t month, uint8_t day); // 获取今天星期几
|
extern uint8_t get_weekday(uint16_t year, uint8_t month, uint8_t day); // 获取今天星期几
|
||||||
extern uint8_t hex_format_dec(uint8_t hex); // 十六进制转十进制
|
extern uint8_t hex_format_dec(uint8_t hex); // 十六进制转十进制
|
||||||
extern uint8_t dec_format_hex(uint8_t dec); // 十进制转十六进制
|
extern uint8_t dec_format_hex(uint8_t dec); // 十进制转十六进制
|
||||||
|
extern void quicksort(uint16_t arr[], int low, int high); // 快速排序
|
||||||
|
|
||||||
uint32_t time2Stamp(rtc_date_t date, rtc_time_t time); // 北京时间转时间戳
|
extern uint32_t time2Stamp(rtc_date_t date, rtc_time_t time); // 北京时间转时间戳
|
||||||
extern void stamp2Time(uint32_t stamp, rtc_date_t *date, rtc_time_t *time); // 时间戳转北京时间
|
extern void stamp2Time(uint32_t stamp, rtc_date_t *date, rtc_time_t *time); // 时间戳转北京时间
|
||||||
|
|
||||||
#endif //__LIB_H
|
#endif //__LIB_H
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
// mem1内存参数设定.mem1完全处于内部SRAM里面.(设置内部SARM的内存池和内存表的参数)
|
// mem1内存参数设定.mem1完全处于内部SRAM里面.(设置内部SARM的内存池和内存表的参数)
|
||||||
#define MEM1_BLOCK_SIZE 32 // 一个内存块大小为32字节
|
#define MEM1_BLOCK_SIZE 32 // 一个内存块大小为32字节
|
||||||
#define MEM1_MAX_SIZE 30 * 1024 // 最大管理内存 1K (我们这个内存管理系统的内部SRAM可控制的内存大小)
|
#define MEM1_MAX_SIZE 20 * 1024 // 最大管理内存 1K (我们这个内存管理系统的内部SRAM可控制的内存大小)
|
||||||
#define MEM1_ALLOC_TABLE_SIZE MEM1_MAX_SIZE / MEM1_BLOCK_SIZE // 内存表大小(有多少块内存块)
|
#define MEM1_ALLOC_TABLE_SIZE MEM1_MAX_SIZE / MEM1_BLOCK_SIZE // 内存表大小(有多少块内存块)
|
||||||
|
|
||||||
// mem2内存参数设定.mem2的内存池处于外部SRAM里面
|
// mem2内存参数设定.mem2的内存池处于外部SRAM里面
|
||||||
|
|
|
@ -15,16 +15,28 @@
|
||||||
#define hal_int_state_t char
|
#define hal_int_state_t char
|
||||||
#ifdef STM32
|
#ifdef STM32
|
||||||
#include "stm32l4xx.h"
|
#include "stm32l4xx.h"
|
||||||
|
#define HAL_ENTER_CRITICAL(__HANDLE__) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if ((__HANDLE__)->Lock == HAL_LOCKED) \
|
||||||
|
{ \
|
||||||
|
return HAL_BUSY; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
(__HANDLE__)->Lock = HAL_LOCKED; \
|
||||||
|
} \
|
||||||
|
} while (0U)
|
||||||
|
|
||||||
#define HAL_ENTER_CRITICAL(s) \
|
#define HAL_EXIT_CRITICAL(__HANDLE__) \
|
||||||
s = s; \
|
do \
|
||||||
__ASM volatile("cpsid i");
|
{ \
|
||||||
#define HAL_EXIT_CRITICAL(s) \
|
(__HANDLE__)->Lock = HAL_UNLOCKED; \
|
||||||
__ASM volatile("cpsie i");
|
} while (0U)
|
||||||
#else
|
#else
|
||||||
#define HAL_ENTER_CRITICAL(s)
|
#define HAL_ENTER_CRITICAL(__HANDLE__)
|
||||||
|
|
||||||
#define HAL_EXIT_CRITICAL(s)
|
#define HAL_EXIT_CRITICAL(__HANDLE__)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -39,7 +51,6 @@
|
||||||
#define osel_mem_free2 _free2
|
#define osel_mem_free2 _free2
|
||||||
|
|
||||||
#define osel_mstrlen _mstrlen
|
#define osel_mstrlen _mstrlen
|
||||||
#define osel_quick_sort _quick_sort
|
|
||||||
|
|
||||||
static inline void *_malloc(uint32_t size)
|
static inline void *_malloc(uint32_t size)
|
||||||
{
|
{
|
||||||
|
@ -127,32 +138,4 @@ static inline unsigned int _mstrlen(const unsigned char *s)
|
||||||
return ss - s;
|
return ss - s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 快速排序
|
|
||||||
static inline void _quick_sort(uint16_t *array, int left, int right)
|
|
||||||
{
|
|
||||||
if (left >= right)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int i = left;
|
|
||||||
int j = right;
|
|
||||||
uint16_t key = array[left];
|
|
||||||
while (i < j)
|
|
||||||
{
|
|
||||||
while (i < j && array[j] > key)
|
|
||||||
{
|
|
||||||
j--;
|
|
||||||
}
|
|
||||||
array[i] = array[j];
|
|
||||||
while (i < j && array[i] <= key)
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
array[j] = array[i];
|
|
||||||
}
|
|
||||||
array[i] = key;
|
|
||||||
_quick_sort(array, left, i - 1);
|
|
||||||
_quick_sort(array, i + 1, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __OSEL_ARCH_H__
|
#endif // __OSEL_ARCH_H__
|
||||||
|
|
|
@ -81,8 +81,8 @@ static GUI_CONST_STORAGE unsigned char ac0032[60] = {
|
||||||
________, ______XX, XXX_____,
|
________, ______XX, XXX_____,
|
||||||
________, _______X, XX______};
|
________, _______X, XX______};
|
||||||
|
|
||||||
/* char: code:0x0034 */
|
/* char: code:0x0033 */
|
||||||
static GUI_CONST_STORAGE unsigned char ac0034[60] = {
|
static GUI_CONST_STORAGE unsigned char ac0033[60] = {
|
||||||
________, ________, ________,
|
________, ________, ________,
|
||||||
________, ________, ________,
|
________, ________, ________,
|
||||||
________, ________, ________,
|
________, ________, ________,
|
||||||
|
@ -104,24 +104,90 @@ static GUI_CONST_STORAGE unsigned char ac0034[60] = {
|
||||||
________, ________, ________,
|
________, ________, ________,
|
||||||
________, ________, ________};
|
________, ________, ________};
|
||||||
|
|
||||||
static GUI_CONST_STORAGE GUI_CHARINFO Cinfo[4] = {
|
/* char: code:0x0034 */
|
||||||
|
static GUI_CONST_STORAGE unsigned char ac0034[60] = {
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, _______X, ________,
|
||||||
|
___X____, _X____X_, X_______,
|
||||||
|
__X_X___, X_X__X__, ________,
|
||||||
|
___X____, _X____X_, X_______,
|
||||||
|
________, _______X, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________};
|
||||||
|
|
||||||
|
/* char: code:0x0035 */
|
||||||
|
static GUI_CONST_STORAGE unsigned char ac0035[60] = {
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
___X____, ________, ________,
|
||||||
|
__X_XX__, _X_____X, ________,
|
||||||
|
_____X__, X_X___X_, X_______,
|
||||||
|
__X_XX__, _X_____X, ________,
|
||||||
|
___X____, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________};
|
||||||
|
|
||||||
|
/* char: code:0x0036 */
|
||||||
|
static GUI_CONST_STORAGE unsigned char ac0036[60] = {
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, _X______, ________,
|
||||||
|
___X____, X_X____X, ________,
|
||||||
|
__X_X__X, ___X__X_, X_______,
|
||||||
|
___X____, X_X____X, ________,
|
||||||
|
________, _X______, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________,
|
||||||
|
________, ________, ________};
|
||||||
|
|
||||||
|
static GUI_CONST_STORAGE GUI_CHARINFO Cinfo[7] = {
|
||||||
{19, 19, 3, (unsigned char *)&ac0030}, /*0: */
|
{19, 19, 3, (unsigned char *)&ac0030}, /*0: */
|
||||||
{20, 20, 3, (unsigned char *)&ac0031}, /*1: */
|
{20, 20, 3, (unsigned char *)&ac0031}, /*1: */
|
||||||
{20, 20, 3, (unsigned char *)&ac0032}, /*2: */
|
{20, 20, 3, (unsigned char *)&ac0032}, /*2: */
|
||||||
{19, 19, 3, (unsigned char *)&ac0034}, /*3: */
|
{19, 19, 3, (unsigned char *)&ac0033}, /*3: */
|
||||||
|
{17, 17, 3, (unsigned char *)&ac0034}, /*4: */
|
||||||
|
{17, 17, 3, (unsigned char *)&ac0035}, /*5: */
|
||||||
|
{17, 17, 3, (unsigned char *)&ac0036}, /*6: */
|
||||||
};
|
};
|
||||||
|
|
||||||
static GUI_CONST_STORAGE GUI_FONT_PROP Prop2 = {
|
|
||||||
0x0034, /*start :*/
|
|
||||||
0x0034, /*end :, len=1*/
|
|
||||||
&Cinfo[3],
|
|
||||||
(void *)0};
|
|
||||||
|
|
||||||
static GUI_CONST_STORAGE GUI_FONT_PROP Prop1 = {
|
static GUI_CONST_STORAGE GUI_FONT_PROP Prop1 = {
|
||||||
0x0030, /*start :*/
|
0x0030, /*start :*/
|
||||||
0x0032, /*end :, len=3*/
|
0x0036, /*end :, len=7*/
|
||||||
&Cinfo[0],
|
&Cinfo[0],
|
||||||
&Prop2};
|
(void *)0};
|
||||||
|
|
||||||
GUI_CONST_STORAGE GUI_FONT GUI_FontHZ20x20 = {
|
GUI_CONST_STORAGE GUI_FONT GUI_FontHZ20x20 = {
|
||||||
GUI_FONTTYPE_PROP_SJIS,
|
GUI_FONTTYPE_PROP_SJIS,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
定位器功能菜单介绍无江苏巨石数字技术有限公司实际行程目标报警提示自动手校验整详细设置备调试气作用电流输入范围开关显正常反类型直角速率增加
|
定位器功能菜单介绍无江苏巨石数字技术有限公司实际行程目标报警提示自动手校验整详细设置备调试气作用电流输入范围开关显正常反类型直角速率增加
|
||||||
减小下上供压力阀门特性信号切除值线等于快义闭使方式触发处理错误死区连续暂停待时间源次累计温度摩擦弹驱逻辑禁其他排量高级控制参准积分激活出传感选择语言中文向恢复厂否是诊断全允许移或启结束差最大混合滞后簧欢迎智版本主执机构地址日期编息双曲节通讯模块屏幕英工磁条在离确认保持完成存失败载取消进故障超规格检查要求维护测重℃○●↑↓√
|
减小下上供压力阀门特性信号切除值线等于快义闭使方式触发处理错误死区连续暂停待时间源次累计温度摩擦弹驱逻辑禁其他排量高级控制参准积分激活出传感选择语言中文向恢复厂否是诊断全允许移或启结束差最大混合滞后簧欢迎智版本主执机构地址日期编息双曲节通讯模块屏幕英工磁条在离确认保持完成存失败载取消进故障超规格检查要求维护测重算法变频平衡当前已域℃○●↑↓√
|
||||||
*/
|
*/
|
||||||
#ifndef __LCDS_H__
|
#ifndef __LCDS_H__
|
||||||
#define __LCDS_H__
|
#define __LCDS_H__
|
||||||
|
|
Binary file not shown.
|
@ -93,20 +93,20 @@ void lpf_reset(lpf_t *cfg)
|
||||||
/**
|
/**
|
||||||
* 滑动平均窗口滤波
|
* 滑动平均窗口滤波
|
||||||
*/
|
*/
|
||||||
lpf_window_t* lpf_window_init(uint16_t size)
|
lpf_window_t *lpf_window_init(uint16_t size)
|
||||||
{
|
{
|
||||||
lpf_window_t* cfg = (lpf_window_t*)osel_mem_alloc(sizeof(lpf_window_t));
|
lpf_window_t *cfg = (lpf_window_t *)osel_mem_alloc(sizeof(lpf_window_t));
|
||||||
DBG_ASSERT(cfg != NULL __DBG_LINE);
|
DBG_ASSERT(cfg != NULL __DBG_LINE);
|
||||||
osel_memset((uint8_t*)cfg, 0, sizeof(lpf_window_t));
|
osel_memset((uint8_t *)cfg, 0, sizeof(lpf_window_t));
|
||||||
cfg->size = size;
|
cfg->size = size;
|
||||||
cfg->window = (float32*)osel_mem_alloc(sizeof(float32) * size);
|
cfg->window = (float32 *)osel_mem_alloc(sizeof(float32) * size);
|
||||||
DBG_ASSERT(cfg->window != NULL __DBG_LINE);
|
DBG_ASSERT(cfg->window != NULL __DBG_LINE);
|
||||||
cfg->index = 0;
|
cfg->index = 0;
|
||||||
cfg->sum = 0;
|
cfg->sum = 0;
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lpf_window_dinit(lpf_window_t* cfg)
|
void lpf_window_dinit(lpf_window_t *cfg)
|
||||||
{
|
{
|
||||||
if (cfg != NULL)
|
if (cfg != NULL)
|
||||||
{
|
{
|
||||||
|
@ -119,14 +119,14 @@ void lpf_window_dinit(lpf_window_t* cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 滑动平均窗口重置
|
// 滑动平均窗口重置
|
||||||
void lpf_window_reset(lpf_window_t* cfg)
|
void lpf_window_reset(lpf_window_t *cfg)
|
||||||
{
|
{
|
||||||
cfg->index = 0;
|
cfg->index = 0;
|
||||||
cfg->sum = 0;
|
cfg->sum = 0;
|
||||||
// osel_memset((uint8_t *)cfg->window, 0, sizeof(float32) * cfg->size);
|
// osel_memset((uint8_t *)cfg->window, 0, sizeof(float32) * cfg->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
float32 lpf_window_update(lpf_window_t* cfg, float32 input)
|
float32 lpf_window_update(lpf_window_t *cfg, float32 input)
|
||||||
{
|
{
|
||||||
cfg->sum = 0;
|
cfg->sum = 0;
|
||||||
// 如果窗口未满,直接添加新值到当前索引位置
|
// 如果窗口未满,直接添加新值到当前索引位置
|
||||||
|
@ -152,4 +152,3 @@ float32 lpf_window_update(lpf_window_t* cfg, float32 input)
|
||||||
cfg->out = cfg->sum / cfg->index;
|
cfg->out = cfg->sum / cfg->index;
|
||||||
return cfg->out;
|
return cfg->out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -327,3 +327,37 @@ void stamp2Time(uint32_t stamp, rtc_date_t *date, rtc_time_t *time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************排序**************************/
|
||||||
|
static void swap(uint16_t *a, uint16_t *b)
|
||||||
|
{
|
||||||
|
uint16_t t = *a;
|
||||||
|
*a = *b;
|
||||||
|
*b = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int partition(uint16_t arr[], int low, int high)
|
||||||
|
{
|
||||||
|
uint16_t pivot = arr[high];
|
||||||
|
int i = (low - 1);
|
||||||
|
for (int j = low; j <= high - 1; j++)
|
||||||
|
{
|
||||||
|
if (arr[j] < pivot)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
swap(&arr[i], &arr[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
swap(&arr[i + 1], &arr[high]);
|
||||||
|
return (i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void quicksort(uint16_t arr[], int low, int high)
|
||||||
|
{
|
||||||
|
if (low < high)
|
||||||
|
{
|
||||||
|
int pi = partition(arr, low, high);
|
||||||
|
quicksort(arr, low, pi - 1);
|
||||||
|
quicksort(arr, pi + 1, high);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -76,6 +76,28 @@ void adc_init(adcs_e num, ADC_TypeDef *adc, DMA_TypeDef *dma, uint32_t dma_chann
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ADC反初始化
|
||||||
|
* @param {adcs_e} num ADC编号
|
||||||
|
* @return {*}
|
||||||
|
* @note
|
||||||
|
*/
|
||||||
|
void adc_dinit(adcs_e num)
|
||||||
|
{
|
||||||
|
DBG_ASSERT(num < ADCS_MAX __DBG_LINE);
|
||||||
|
adcs_t *p = &adcs[num];
|
||||||
|
LL_ADC_REG_StopConversion(p->adc);
|
||||||
|
LL_DMA_DisableChannel(p->dma, p->dma_channel);
|
||||||
|
LL_ADC_Disable(p->adc);
|
||||||
|
if (p->adc_value != NULL)
|
||||||
|
{
|
||||||
|
#if defined(SRAM2_BASE)
|
||||||
|
osel_mem_free2(p->adc_value);
|
||||||
|
#else
|
||||||
|
osel_mem_free(p->adc_value);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief 获取ADC转换结果,只需要第一个值
|
* @brief 获取ADC转换结果,只需要第一个值
|
||||||
* @param {adcs_e} num
|
* @param {adcs_e} num
|
||||||
|
@ -92,10 +114,6 @@ uint16_t adc_result_only_one(adcs_e num, uint8_t chan)
|
||||||
return gram[0][chan];
|
return gram[0][chan];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序方法
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 中位值平均滤波,获取ADC转换结果
|
* @brief 中位值平均滤波,获取ADC转换结果
|
||||||
* @param {adcs_e} num ADC编号
|
* @param {adcs_e} num ADC编号
|
||||||
|
@ -107,35 +125,18 @@ uint16_t adc_result_median_average(adcs_e num, uint8_t chan)
|
||||||
{
|
{
|
||||||
DBG_ASSERT(num < ADCS_MAX __DBG_LINE);
|
DBG_ASSERT(num < ADCS_MAX __DBG_LINE);
|
||||||
uint16_t res = 0;
|
uint16_t res = 0;
|
||||||
uint16_t temp = 0;
|
|
||||||
uint16_t *value = NULL;
|
|
||||||
adcs_t *p = &adcs[num];
|
adcs_t *p = &adcs[num];
|
||||||
DBG_ASSERT(p != NULL __DBG_LINE);
|
DBG_ASSERT(p != NULL __DBG_LINE);
|
||||||
uint16_t adc_temp[p->adc_cct];
|
uint16_t adc_temp[p->adc_cct];
|
||||||
uint32_t adc_sum = 0;
|
uint32_t adc_sum = 0;
|
||||||
|
|
||||||
value = (uint16_t *)osel_mem_alloc(sizeof(uint16_t) * p->adc_sum);
|
|
||||||
DBG_ASSERT(value != NULL __DBG_LINE);
|
|
||||||
osel_memcpy((uint8_t *)value, (uint8_t *)p->adc_value, sizeof(uint16_t) * p->adc_sum);
|
|
||||||
uint16_t(*gram)[p->adc_chans_count] = (uint16_t(*)[p->adc_chans_count])value;
|
|
||||||
for (uint8_t i = 0; i < p->adc_cct; i++)
|
for (uint8_t i = 0; i < p->adc_cct; i++)
|
||||||
{
|
{
|
||||||
adc_temp[i] = gram[i][chan];
|
adc_temp[i] = p->adc_value[i * p->adc_chans_count + chan];
|
||||||
}
|
}
|
||||||
osel_mem_free(value);
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < p->adc_cct - 1; i++)
|
quicksort(adc_temp, 0, p->adc_cct - 1);
|
||||||
{
|
|
||||||
for (uint8_t j = 0; j < p->adc_cct - 1 - i; j++)
|
|
||||||
{
|
|
||||||
if (adc_temp[j] > adc_temp[j + 1])
|
|
||||||
{
|
|
||||||
temp = adc_temp[j];
|
|
||||||
adc_temp[j] = adc_temp[j + 1];
|
|
||||||
adc_temp[j + 1] = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (uint8_t i = 0; i < p->adc_cct; i++) // 遍历所有ADC通道
|
for (uint8_t i = 0; i < p->adc_cct; i++) // 遍历所有ADC通道
|
||||||
{
|
{
|
||||||
adc_sum += adc_temp[i]; // 将每个ADC通道的数据累加到adc_sum中
|
adc_sum += adc_temp[i]; // 将每个ADC通道的数据累加到adc_sum中
|
||||||
|
@ -156,32 +157,14 @@ uint16_t adc_result_median(adcs_e num, uint8_t chan)
|
||||||
{
|
{
|
||||||
DBG_ASSERT(num < ADCS_MAX __DBG_LINE);
|
DBG_ASSERT(num < ADCS_MAX __DBG_LINE);
|
||||||
uint16_t res = 0;
|
uint16_t res = 0;
|
||||||
uint16_t temp = 0;
|
|
||||||
uint16_t *value = NULL;
|
|
||||||
adcs_t *p = &adcs[num];
|
adcs_t *p = &adcs[num];
|
||||||
uint16_t adc_temp[p->adc_cct];
|
uint16_t adc_temp[p->adc_cct];
|
||||||
value = (uint16_t *)osel_mem_alloc(sizeof(uint16_t) * p->adc_sum);
|
|
||||||
DBG_ASSERT(p != NULL __DBG_LINE);
|
|
||||||
DBG_ASSERT(value != NULL __DBG_LINE);
|
|
||||||
osel_memcpy((uint8_t *)value, (uint8_t *)p->adc_value, sizeof(uint16_t) * p->adc_sum);
|
|
||||||
uint16_t(*gram)[p->adc_chans_count] = (uint16_t(*)[p->adc_chans_count])value;
|
|
||||||
for (uint8_t i = 0; i < p->adc_cct; i++)
|
for (uint8_t i = 0; i < p->adc_cct; i++)
|
||||||
{
|
{
|
||||||
adc_temp[i] = gram[i][chan];
|
adc_temp[i] = p->adc_value[i * p->adc_chans_count + chan];
|
||||||
}
|
|
||||||
osel_mem_free(value);
|
|
||||||
for (uint8_t i = 0; i < p->adc_cct - 1; i++)
|
|
||||||
{
|
|
||||||
for (uint8_t j = 0; j < p->adc_cct - 1 - i; j++)
|
|
||||||
{
|
|
||||||
if (adc_temp[j] > adc_temp[j + 1])
|
|
||||||
{
|
|
||||||
temp = adc_temp[j];
|
|
||||||
adc_temp[j] = adc_temp[j + 1];
|
|
||||||
adc_temp[j + 1] = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// 使用快速排序
|
||||||
|
quicksort(adc_temp, 0, p->adc_cct - 1);
|
||||||
res = adc_temp[p->adc_cct / 2];
|
res = adc_temp[p->adc_cct / 2];
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -196,20 +179,20 @@ uint16_t adc_result_median(adcs_e num, uint8_t chan)
|
||||||
uint16_t adc_result_average(adcs_e num, uint8_t chan)
|
uint16_t adc_result_average(adcs_e num, uint8_t chan)
|
||||||
{
|
{
|
||||||
DBG_ASSERT(num < ADCS_MAX __DBG_LINE);
|
DBG_ASSERT(num < ADCS_MAX __DBG_LINE);
|
||||||
uint16_t res = 0;
|
|
||||||
adcs_t *p = &adcs[num];
|
adcs_t *p = &adcs[num];
|
||||||
DBG_ASSERT(p != NULL __DBG_LINE);
|
DBG_ASSERT(p != NULL __DBG_LINE);
|
||||||
|
DBG_ASSERT(p->adc_cct != 0 __DBG_LINE); // 避免除以零的错误
|
||||||
uint32_t adc_sum = 0;
|
uint32_t adc_sum = 0;
|
||||||
|
|
||||||
uint16_t(*gram)[p->adc_chans_count] = (uint16_t(*)[p->adc_chans_count])p->adc_value;
|
uint16_t(*gram)[p->adc_chans_count] = (uint16_t(*)[p->adc_chans_count])p->adc_value;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < p->adc_cct; i++)
|
for (uint8_t i = 0; i < p->adc_cct; i++)
|
||||||
{
|
{
|
||||||
adc_sum += gram[i][chan];
|
uint32_t next_sum = adc_sum + gram[i][chan];
|
||||||
|
DBG_ASSERT(next_sum >= adc_sum __DBG_LINE); // 避免溢出
|
||||||
|
adc_sum = next_sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = adc_sum / p->adc_cct;
|
return adc_sum / p->adc_cct;
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -224,26 +207,18 @@ uint16_t adc_result_n_average(adcs_e num, uint8_t chan)
|
||||||
DBG_ASSERT(num < ADCS_MAX __DBG_LINE);
|
DBG_ASSERT(num < ADCS_MAX __DBG_LINE);
|
||||||
uint16_t res = 0;
|
uint16_t res = 0;
|
||||||
uint32_t adc_sum = 0;
|
uint32_t adc_sum = 0;
|
||||||
uint16_t *value = NULL;
|
|
||||||
adcs_t *p = &adcs[num];
|
adcs_t *p = &adcs[num];
|
||||||
DBG_ASSERT(p != NULL __DBG_LINE);
|
DBG_ASSERT(p != NULL __DBG_LINE);
|
||||||
uint16_t adc_temp[p->adc_cct];
|
uint16_t adc_temp[p->adc_cct];
|
||||||
uint8_t n = p->adc_cct / 4;
|
uint8_t n = p->adc_cct / 4;
|
||||||
uint8_t count = p->adc_cct > (2 * n) ? n : 0;
|
uint8_t count = p->adc_cct > (2 * n) ? n : 0;
|
||||||
value = (uint16_t *)osel_mem_alloc(sizeof(uint16_t) * p->adc_sum);
|
|
||||||
DBG_ASSERT(value != NULL __DBG_LINE);
|
|
||||||
osel_memcpy((uint8_t *)value, (uint8_t *)p->adc_value, sizeof(uint16_t) * p->adc_sum);
|
|
||||||
uint16_t(*gram)[p->adc_chans_count] = (uint16_t(*)[p->adc_chans_count])value;
|
|
||||||
for (uint8_t i = 0; i < p->adc_cct; i++)
|
for (uint8_t i = 0; i < p->adc_cct; i++)
|
||||||
{
|
{
|
||||||
adc_temp[i] = gram[i][chan];
|
adc_temp[i] = p->adc_value[i * p->adc_chans_count + chan];
|
||||||
}
|
}
|
||||||
osel_mem_free(value);
|
|
||||||
for (uint8_t i = 0; i < p->adc_cct; i++)
|
quicksort(adc_temp, 0, p->adc_cct - 1);
|
||||||
{
|
|
||||||
adc_temp[i] = gram[i][chan];
|
|
||||||
}
|
|
||||||
osel_quick_sort(adc_temp, 0, p->adc_cct - 1);
|
|
||||||
|
|
||||||
for (uint8_t i = count; i < p->adc_cct - count; i++)
|
for (uint8_t i = count; i < p->adc_cct - count; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,6 +84,7 @@ typedef struct
|
||||||
} adcs_t;
|
} adcs_t;
|
||||||
|
|
||||||
extern void adc_init(adcs_e num, ADC_TypeDef *adc, DMA_TypeDef *dma, uint32_t dma_channel, uint8_t adc_cct, uint32_t channels);
|
extern void adc_init(adcs_e num, ADC_TypeDef *adc, DMA_TypeDef *dma, uint32_t dma_channel, uint8_t adc_cct, uint32_t channels);
|
||||||
|
extern void adc_dinit(adcs_e num); // ADC反初始化
|
||||||
|
|
||||||
extern uint16_t adc_result_only_one(adcs_e num, uint8_t chan); // 获取ADC转换结果,只需要第一个值
|
extern uint16_t adc_result_only_one(adcs_e num, uint8_t chan); // 获取ADC转换结果,只需要第一个值
|
||||||
extern uint16_t adc_result_median_average(adcs_e num, uint8_t chan); // 中位值平均滤波,获取ADC转换结果
|
extern uint16_t adc_result_median_average(adcs_e num, uint8_t chan); // 中位值平均滤波,获取ADC转换结果
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "eeprom.h"
|
#include "eeprom.h"
|
||||||
#include "spis.h"
|
#include "spis.h"
|
||||||
#include "i2cs.h"
|
#include "i2cs.h"
|
||||||
#include "iwdgs.h"
|
|
||||||
|
|
||||||
#define DMA_ClEAR_FLAG(DMAX, CHx, Flag) \
|
#define DMA_ClEAR_FLAG(DMAX, CHx, Flag) \
|
||||||
do \
|
do \
|
||||||
|
|
|
@ -0,0 +1,530 @@
|
||||||
|
/**
|
||||||
|
* @file flash.c
|
||||||
|
* @author xxx
|
||||||
|
* @date 2024-02-07 11:49:34
|
||||||
|
* @brief
|
||||||
|
* @copyright Copyright (c) 2024 by xxx, All Rights Reserved.
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* ST 的官方驱动 LL 库并没有 flash 驱动。这里自己实现。
|
||||||
|
*
|
||||||
|
* 1. 由于在 stm32l4xx_ll_system.h 中存在部分 FLASH 操作函数(ACR寄存器的处理)且不全面
|
||||||
|
* 因此这里需要额外处理(重命名)
|
||||||
|
*
|
||||||
|
* 2. Main memory
|
||||||
|
* (1) FLASH_ACR 完成
|
||||||
|
* (2) FLASH_PDKEYR 完成
|
||||||
|
* (3) FLASH_KEYR 完成
|
||||||
|
* (4) FLASH_OPTKEYR 完成
|
||||||
|
* (5) FLASH_SR 完成
|
||||||
|
* (6) FLASH_CR 完成
|
||||||
|
* (7) FLASH_ECCR 完成
|
||||||
|
* (8) FLASH_OPTR 未完成
|
||||||
|
* (9) FLASH_PCROP1SR 未完成
|
||||||
|
* 后续寄存器 均未完成
|
||||||
|
* 3. Information block
|
||||||
|
* - System memory
|
||||||
|
* - OTP area
|
||||||
|
* - Option bytes
|
||||||
|
* 4. 根据 HAL 库的实现,相比于与手册的推荐流程,擦写的执行序列还有其他操作。
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "flash.h"
|
||||||
|
#include "stm32l4xx_ll_rcc.h"
|
||||||
|
#include "stm32l4xx_ll_system.h"
|
||||||
|
#include "stm32l4xx_ll_pwr.h"
|
||||||
|
#ifdef USE_FULL_ASSERT
|
||||||
|
#include "stm32_assert.h"
|
||||||
|
#else
|
||||||
|
#define assert_param(expr) ((void)0U)
|
||||||
|
#endif /* USE_FULL_ASSERT */
|
||||||
|
|
||||||
|
#define WHILE_MAX 10000U
|
||||||
|
/** @addtogroup STM32L4xx_LL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup FLASH_LL
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/** @addtogroup FLASH_LL_Private_Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
/** @addtogroup FLASH_LL_Private_Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define IS_LL_FLASH_WRITE_ADDR(__ADDR__) ((__ADDR__) % LL_FLASH_ALIGNMENT_MIN_SIZE == 0)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/** @defgroup FLASH_LL_Private_Functions FLASH Private functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @addtogroup FLASH_LL_Exported_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @brief Clear All Error in SR
|
||||||
|
* @param FLASHx FLASH Instance
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void LL_FLASH_ClearAllErrorFlag(void)
|
||||||
|
{
|
||||||
|
LL_FLASH_ClearFlag_OPTVERR(FLASH);
|
||||||
|
LL_FLASH_ClearFlag_RDERR(FLASH);
|
||||||
|
LL_FLASH_ClearFlag_FASTERR(FLASH);
|
||||||
|
LL_FLASH_ClearFlag_MISERR(FLASH);
|
||||||
|
LL_FLASH_ClearFlag_PGSERR(FLASH);
|
||||||
|
LL_FLASH_ClearFlag_SIZERR(FLASH);
|
||||||
|
LL_FLASH_ClearFlag_PGAERR(FLASH);
|
||||||
|
LL_FLASH_ClearFlag_WRPERR(FLASH);
|
||||||
|
LL_FLASH_ClearFlag_PROGERR(FLASH);
|
||||||
|
LL_FLASH_ClearFlag_OPERR(FLASH);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Flush the instruction and data caches.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void LL_FLASH_FlushCaches(void)
|
||||||
|
{
|
||||||
|
/* Flush instruction cache */
|
||||||
|
if (LL_FLASH_IsEnabledInstructionCache(FLASH))
|
||||||
|
{
|
||||||
|
LL_FLASH_DisableInstructionCache(FLASH);
|
||||||
|
/* Reset instruction cache */
|
||||||
|
LL_FLASH_InstructionCacheReset(FLASH);
|
||||||
|
/* Enable instruction cache */
|
||||||
|
LL_FLASH_EnableInstructionCache(FLASH);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Flush data cache */
|
||||||
|
if (LL_FLASH_IsEnabledDataCache(FLASH))
|
||||||
|
{
|
||||||
|
LL_FLASH_ZCS_DisableDataCache(FLASH);
|
||||||
|
/* Reset data cache */
|
||||||
|
LL_FLASH_DataCacheReset(FLASH);
|
||||||
|
/* Enable data cache */
|
||||||
|
LL_FLASH_ZCS_EnableDataCache(FLASH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Erase Page
|
||||||
|
* @param pageno Page number
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_FLASH_ErasePage(uint32_t pageno)
|
||||||
|
{
|
||||||
|
uint16_t count = 0;
|
||||||
|
/* Check that no Flash memory operation is ongoing by checking the BSY bit */
|
||||||
|
while (LL_FLASH_IsActiveFlag_BSY(FLASH))
|
||||||
|
{
|
||||||
|
if (count++ > WHILE_MAX)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
/* Check and clear all error programming flags due to a previous programming. If not, PGSERR is set. */
|
||||||
|
LL_FLASH_ClearAllErrorFlag();
|
||||||
|
|
||||||
|
/* Set the PER bit and select the page you wish to erase (PNB) with the associated bank (BKER) in the Flash control register (FLASH_CR). */
|
||||||
|
LL_FLASH_EnablePageErase(FLASH);
|
||||||
|
|
||||||
|
if (pageno >= LL_FLASH_BANK1_PAGE_NUM)
|
||||||
|
{
|
||||||
|
pageno -= LL_FLASH_BANK1_PAGE_NUM;
|
||||||
|
LL_FLASH_SetErasePageBank(FLASH, LL_FLASH_BANK2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LL_FLASH_SetErasePageBank(FLASH, LL_FLASH_BANK1);
|
||||||
|
}
|
||||||
|
|
||||||
|
LL_FLASH_SetErasePageNo(FLASH, pageno);
|
||||||
|
|
||||||
|
/* Set the STRT bit in the FLASH_CR register. */
|
||||||
|
LL_FLASH_EraseStart(FLASH);
|
||||||
|
|
||||||
|
/* Wait for the BSY bit to be cleared in the FLASH_SR register. */
|
||||||
|
while (LL_FLASH_IsActiveFlag_BSY(FLASH))
|
||||||
|
{
|
||||||
|
if (count++ > WHILE_MAX)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
/* 完成只有需要清除擦除标志. */
|
||||||
|
LL_FLASH_DisablePageErase(FLASH);
|
||||||
|
|
||||||
|
/* Flush the caches to be sure of the data consistency */
|
||||||
|
LL_FLASH_FlushCaches();
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Erase bank
|
||||||
|
* @param bank This parameter can be one of the following values:
|
||||||
|
* @arg @ref LL_FLASH_BANK1
|
||||||
|
* @arg @ref LL_FLASH_BANK2
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_FLASH_EraseBank(uint32_t bank)
|
||||||
|
{
|
||||||
|
uint16_t count = 0;
|
||||||
|
/* Check that no Flash memory operation is ongoing by checking the BSY bit */
|
||||||
|
while (LL_FLASH_IsActiveFlag_BSY(FLASH))
|
||||||
|
{
|
||||||
|
if (count++ > WHILE_MAX)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
/* Check and clear all error programming flags due to a previous programming. If not, PGSERR is set. */
|
||||||
|
LL_FLASH_ClearAllErrorFlag();
|
||||||
|
|
||||||
|
/* Set the MER1 bit or/and MER2 (depending on the bank) in the Flash control register (FLASH_CR).
|
||||||
|
Both banks can be selected in the same operation. */
|
||||||
|
if (bank == LL_FLASH_BANK1)
|
||||||
|
{
|
||||||
|
LL_FLASH_EnableBank1Erase(FLASH);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LL_FLASH_EnableBank2Erase(FLASH);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the STRT bit in the FLASH_CR register. */
|
||||||
|
LL_FLASH_EraseStart(FLASH);
|
||||||
|
|
||||||
|
/* Wait for the BSY bit to be cleared in the FLASH_SR register. */
|
||||||
|
while (LL_FLASH_IsActiveFlag_BSY(FLASH))
|
||||||
|
{
|
||||||
|
if (count++ > WHILE_MAX)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
/* 完成只有需要清除擦除标志. */
|
||||||
|
LL_FLASH_DisableBank1Erase(FLASH);
|
||||||
|
LL_FLASH_DisableBank2Erase(FLASH);
|
||||||
|
|
||||||
|
/* Flush the caches to be sure of the data consistency */
|
||||||
|
LL_FLASH_FlushCaches();
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Erase Chip
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_FLASH_EraseChip(void)
|
||||||
|
{
|
||||||
|
uint16_t count = 0;
|
||||||
|
/* Check that no Flash memory operation is ongoing by checking the BSY bit */
|
||||||
|
while (LL_FLASH_IsActiveFlag_BSY(FLASH))
|
||||||
|
{
|
||||||
|
if (count++ > WHILE_MAX)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
/* Check and clear all error programming flags due to a previous programming. If not, PGSERR is set. */
|
||||||
|
LL_FLASH_ClearAllErrorFlag();
|
||||||
|
|
||||||
|
/* Set the MER1 bit or/and MER2 (depending on the bank) in the Flash control register (FLASH_CR).
|
||||||
|
Both banks can be selected in the same operation. */
|
||||||
|
LL_FLASH_EnableBank1Erase(FLASH);
|
||||||
|
LL_FLASH_EnableBank2Erase(FLASH);
|
||||||
|
|
||||||
|
/* Set the STRT bit in the FLASH_CR register. */
|
||||||
|
LL_FLASH_EraseStart(FLASH);
|
||||||
|
|
||||||
|
/* Wait for the BSY bit to be cleared in the FLASH_SR register. */
|
||||||
|
while (LL_FLASH_IsActiveFlag_BSY(FLASH))
|
||||||
|
{
|
||||||
|
if (count++ > WHILE_MAX)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
/* 完成只有需要清除擦除标志. */
|
||||||
|
LL_FLASH_DisableBank1Erase(FLASH);
|
||||||
|
LL_FLASH_DisableBank2Erase(FLASH);
|
||||||
|
|
||||||
|
/* Flush the caches to be sure of the data consistency */
|
||||||
|
LL_FLASH_FlushCaches();
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Program Double Word
|
||||||
|
* @param address specifies the address to be programmed.
|
||||||
|
* @param data specifies the data to be programmed.
|
||||||
|
* @retval An ErrorStatus enumeration value:
|
||||||
|
* - SUCCESS: Write successfully
|
||||||
|
* - ERROR: error
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_FLASH_ProgramDoubleWord(uint32_t address, uint64_t data)
|
||||||
|
{
|
||||||
|
assert_param(!IS_LL_FLASH_WRITE_ADDR(address));
|
||||||
|
uint16_t count = 0;
|
||||||
|
/* Check that no Flash memory operation is ongoing by checking the BSY bit */
|
||||||
|
while (LL_FLASH_IsActiveFlag_BSY(FLASH))
|
||||||
|
{
|
||||||
|
if (count++ > WHILE_MAX)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count = 0;
|
||||||
|
/* Check and clear all error programming flags due to a previous programming. If not, PGSERR is set. */
|
||||||
|
LL_FLASH_ClearAllErrorFlag();
|
||||||
|
|
||||||
|
/* Set the PG bit in the Flash control register (FLASH_CR). */
|
||||||
|
LL_FLASH_EnableProgram(FLASH);
|
||||||
|
|
||||||
|
/* Perform the data write operation at the desired memory address, inside main memory
|
||||||
|
block or OTP area. Only double word can be programmed. */
|
||||||
|
/* Program the double word */
|
||||||
|
*(__IO uint32_t *)address = (uint32_t)data;
|
||||||
|
*(__IO uint32_t *)(address + 4U) = (uint32_t)(data >> 32);
|
||||||
|
|
||||||
|
/* Check that no Flash memory operation is ongoing by checking the BSY bit */
|
||||||
|
while (LL_FLASH_IsActiveFlag_BSY(FLASH))
|
||||||
|
{
|
||||||
|
if (count++ > WHILE_MAX)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count = 0;
|
||||||
|
/* Check that EOP flag is set in the FLASH_SR register (meaning that the programming
|
||||||
|
operation has succeed), and clear it by software. */
|
||||||
|
if (LL_FLASH_IsActiveFlag_EOP(FLASH))
|
||||||
|
{
|
||||||
|
LL_FLASH_ClearFlag_EOP(FLASH);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear the PG bit in the FLASH_CR register if there no more programming request anymore. */
|
||||||
|
LL_FLASH_DisableProgram(FLASH);
|
||||||
|
|
||||||
|
/* Flush the caches to be sure of the data consistency */
|
||||||
|
LL_FLASH_FlushCaches();
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Program
|
||||||
|
* @param address specifies the address to be programmed.
|
||||||
|
* @param data specifies the data to be programmed.
|
||||||
|
* @param num specifies the data number
|
||||||
|
* @retval An ErrorStatus enumeration value:
|
||||||
|
* - SUCCESS: Write successfully
|
||||||
|
* - ERROR: error
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_FLASH_Program(uint32_t address, uint8_t data[], uint32_t num)
|
||||||
|
{
|
||||||
|
static uint64_t DataT = 0;
|
||||||
|
uint32_t T = 0, S = 0;
|
||||||
|
uint16_t count = 0;
|
||||||
|
assert_param(!IS_LL_FLASH_WRITE_ADDR(address));
|
||||||
|
|
||||||
|
if (num == 0)
|
||||||
|
{
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check that no Flash memory operation is ongoing by checking the BSY bit */
|
||||||
|
while (LL_FLASH_IsActiveFlag_BSY(FLASH))
|
||||||
|
{
|
||||||
|
if (count++ > WHILE_MAX)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count = 0;
|
||||||
|
/* Check and clear all error programming flags due to a previous programming. If not, PGSERR is set. */
|
||||||
|
LL_FLASH_ClearAllErrorFlag();
|
||||||
|
|
||||||
|
/* Set the PG bit in the Flash control register (FLASH_CR). */
|
||||||
|
LL_FLASH_EnableProgram(FLASH);
|
||||||
|
|
||||||
|
/* Perform the data write operation at the desired memory address, inside main memory
|
||||||
|
block or OTP area. Only double word can be programmed. */
|
||||||
|
T = num;
|
||||||
|
while (num > 0)
|
||||||
|
{
|
||||||
|
DataT = 0;
|
||||||
|
if (num >= 8)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < LL_FLASH_ALIGNMENT_MIN_SIZE; i++)
|
||||||
|
{
|
||||||
|
DataT = DataT << 8;
|
||||||
|
DataT |= data[S + 7 - i];
|
||||||
|
}
|
||||||
|
S += LL_FLASH_ALIGNMENT_MIN_SIZE;
|
||||||
|
num -= LL_FLASH_ALIGNMENT_MIN_SIZE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
DataT = DataT << 8;
|
||||||
|
DataT |= data[T - 1 - i];
|
||||||
|
}
|
||||||
|
num = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Program the double word */
|
||||||
|
*(__IO uint32_t *)address = (uint32_t)DataT;
|
||||||
|
*(__IO uint32_t *)(address + 4U) = (uint32_t)(DataT >> 32);
|
||||||
|
|
||||||
|
/* Check that no Flash memory operation is ongoing by checking the BSY bit */
|
||||||
|
while (LL_FLASH_IsActiveFlag_BSY(FLASH))
|
||||||
|
{
|
||||||
|
if (count++ > WHILE_MAX)
|
||||||
|
{
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
/* Check that EOP flag is set in the FLASH_SR register (meaning that the programming
|
||||||
|
operation has succeed), and clear it by software. */
|
||||||
|
if (LL_FLASH_IsActiveFlag_EOP(FLASH))
|
||||||
|
{
|
||||||
|
LL_FLASH_ClearFlag_EOP(FLASH);
|
||||||
|
}
|
||||||
|
|
||||||
|
address += LL_FLASH_ALIGNMENT_MIN_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear the PG bit in the FLASH_CR register if there no more programming request anymore. */
|
||||||
|
LL_FLASH_DisableProgram(FLASH);
|
||||||
|
|
||||||
|
/* Flush the caches to be sure of the data consistency */
|
||||||
|
LL_FLASH_FlushCaches();
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup FLASH_LL_Private_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @brief Fast program a row double-word (64-bit) at a specified address.
|
||||||
|
* @param address: specifies the address to be programmed.
|
||||||
|
* @param DataAddress: specifies the address where the data are stored.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void LL_FLASH_ProgramFast(uint32_t address, uint32_t DataAddress)
|
||||||
|
{
|
||||||
|
uint8_t row_index = (2 * LL_FLASH_ROW_SIZE);
|
||||||
|
__IO uint32_t *dest_addr = (__IO uint32_t *)address;
|
||||||
|
__IO uint32_t *src_addr = (__IO uint32_t *)DataAddress;
|
||||||
|
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_FLASH_MAIN_MEM_ADDRESS(address));
|
||||||
|
|
||||||
|
/* Set FSTPG bit */
|
||||||
|
LL_FLASH_EnableFastProgram(FLASH);
|
||||||
|
|
||||||
|
/* Disable interrupts to avoid any interruption during the loop */
|
||||||
|
__disable_irq();
|
||||||
|
|
||||||
|
/* Program the double word of the row */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
*dest_addr = *src_addr;
|
||||||
|
dest_addr++;
|
||||||
|
src_addr++;
|
||||||
|
row_index--;
|
||||||
|
} while (row_index != 0U);
|
||||||
|
|
||||||
|
/* Re-enable the interrupts */
|
||||||
|
__enable_irq();
|
||||||
|
|
||||||
|
LL_FLASH_DisableFastProgram(FLASH);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fast program a row double-word (64-bit) at a specified address.
|
||||||
|
* @param address: specifies the address to be programmed.
|
||||||
|
* @param data: specifies the data to be programmed.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_FLASH_Read(uint32_t address, uint8_t data[], uint32_t num)
|
||||||
|
{
|
||||||
|
if (num == 0)
|
||||||
|
{
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
for (uint32_t i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
data[i] = *(__IO uint8_t *)(address + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
File diff suppressed because it is too large
Load Diff
|
@ -287,7 +287,7 @@ static BOOL _read_mem_dma(i2c_t *handle, uint16_t mem_address, uint16_t mem_adds
|
||||||
{
|
{
|
||||||
i2c_reset(handle->i2c); // xsh:重置I2C,修复一段时间后无法读写的问题
|
i2c_reset(handle->i2c); // xsh:重置I2C,修复一段时间后无法读写的问题
|
||||||
}
|
}
|
||||||
uint16_t count = 10000;
|
uint16_t count = 5000;
|
||||||
handle->txsize = 0;
|
handle->txsize = 0;
|
||||||
handle->tx_dma_ok = FALSE;
|
handle->tx_dma_ok = FALSE;
|
||||||
handle->rx_dma_ok = FALSE;
|
handle->rx_dma_ok = FALSE;
|
||||||
|
@ -301,7 +301,7 @@ static BOOL _read_mem_dma(i2c_t *handle, uint16_t mem_address, uint16_t mem_adds
|
||||||
LL_DMA_EnableChannel(handle->dma, handle->dma_tx_channel);
|
LL_DMA_EnableChannel(handle->dma, handle->dma_tx_channel);
|
||||||
|
|
||||||
LL_I2C_HandleTransfer(handle->i2c, handle->w_address, LL_I2C_ADDRSLAVE_7BIT, handle->txsize, LL_I2C_MODE_SOFTEND, LL_I2C_GENERATE_START_WRITE);
|
LL_I2C_HandleTransfer(handle->i2c, handle->w_address, LL_I2C_ADDRSLAVE_7BIT, handle->txsize, LL_I2C_MODE_SOFTEND, LL_I2C_GENERATE_START_WRITE);
|
||||||
count = 10000;
|
count = 5000;
|
||||||
while (!handle->tx_dma_ok)
|
while (!handle->tx_dma_ok)
|
||||||
{
|
{
|
||||||
if (count-- == 0)
|
if (count-- == 0)
|
||||||
|
@ -311,7 +311,7 @@ static BOOL _read_mem_dma(i2c_t *handle, uint16_t mem_address, uint16_t mem_adds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
count = 10000;
|
count = 5000;
|
||||||
while (LL_I2C_IsActiveFlag_TC(handle->i2c) != 1)
|
while (LL_I2C_IsActiveFlag_TC(handle->i2c) != 1)
|
||||||
{
|
{
|
||||||
if (count-- == 0)
|
if (count-- == 0)
|
||||||
|
|
|
@ -46,8 +46,8 @@ struct I2CS
|
||||||
uint16_t txsize;
|
uint16_t txsize;
|
||||||
uint8_t w_address; // 7位地址
|
uint8_t w_address; // 7位地址
|
||||||
uint8_t r_address; // 7位地址
|
uint8_t r_address; // 7位地址
|
||||||
volatile BOOL rx_dma_ok; // 接收DMA完成标志
|
__IO BOOL rx_dma_ok; // 接收DMA完成标志
|
||||||
volatile BOOL tx_dma_ok; // 发送DMA完成标志
|
__IO BOOL tx_dma_ok; // 发送DMA完成标志
|
||||||
|
|
||||||
i2cs_dma_callback *dma_rx_cb; // DMA接收完成回调函数
|
i2cs_dma_callback *dma_rx_cb; // DMA接收完成回调函数
|
||||||
i2cs_dma_callback *dma_tx_cb; // DMA发送完成回调函数
|
i2cs_dma_callback *dma_tx_cb; // DMA发送完成回调函数
|
||||||
|
|
|
@ -25,8 +25,7 @@ BOOL check_watchdog_reset(void)
|
||||||
*/
|
*/
|
||||||
void debug_freeze_watchdog(void)
|
void debug_freeze_watchdog(void)
|
||||||
{
|
{
|
||||||
// LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_DBGMCU);
|
LL_DBGMCU_APB1_GRP1_FreezePeriph(LL_DBGMCU_APB1_GRP1_IWDG_STOP);
|
||||||
SET_BIT(DBGMCU->APB1FZR1, DBGMCU_APB1FZR1_DBG_IWDG_STOP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,5 +35,5 @@ void debug_freeze_watchdog(void)
|
||||||
*/
|
*/
|
||||||
void debug_unfreeze_watchdog(void)
|
void debug_unfreeze_watchdog(void)
|
||||||
{
|
{
|
||||||
CLEAR_BIT(DBGMCU->APB1FZR1, DBGMCU_APB1FZR1_DBG_IWDG_STOP);
|
LL_DBGMCU_APB1_GRP1_UnFreezePeriph(LL_DBGMCU_APB1_GRP1_IWDG_STOP);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
/**
|
||||||
|
* @file iwdgs.h
|
||||||
|
* @author xxx
|
||||||
|
* @date 2023-12-27 14:44:03
|
||||||
|
* @brief 独立看门狗
|
||||||
|
* @copyright Copyright (c) 2024 by xxx, All Rights Reserved.
|
||||||
|
*/
|
||||||
#ifndef __IWDGS_H__
|
#ifndef __IWDGS_H__
|
||||||
#define __IWDGS_H__
|
#define __IWDGS_H__
|
||||||
|
|
||||||
|
|
|
@ -121,8 +121,8 @@ struct SPIS
|
||||||
DMA_TypeDef *dma; // 外部设置
|
DMA_TypeDef *dma; // 外部设置
|
||||||
uint32_t dma_rx_channel; // 外部设置
|
uint32_t dma_rx_channel; // 外部设置
|
||||||
uint32_t dma_tx_channel; // 外部设置
|
uint32_t dma_tx_channel; // 外部设置
|
||||||
volatile BOOL rx_dma_ok;
|
__IO BOOL rx_dma_ok;
|
||||||
volatile BOOL tx_dma_ok;
|
__IO BOOL tx_dma_ok;
|
||||||
spis_dma_callback *dma_rx_cb; // DMA接收回调函数
|
spis_dma_callback *dma_rx_cb; // DMA接收回调函数
|
||||||
spis_dma_callback *dma_tx_cb; // DMA发送回调函数
|
spis_dma_callback *dma_tx_cb; // DMA发送回调函数
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,12 @@ typedef void (*rx_interupt_cb_t)(uint8_t uart_index, uint8_t *data, uint16_t len
|
||||||
//
|
//
|
||||||
typedef void (*tx_complete_cb_t)(void);
|
typedef void (*tx_complete_cb_t)(void);
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
UART_OK = 0x00u, /**< The action was successful. */
|
||||||
|
UART_ERROR = 0xFFu /**< Generic error. */
|
||||||
|
} uart_status_e;
|
||||||
|
|
||||||
//
|
//
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -27,7 +33,7 @@ typedef struct
|
||||||
BOOL tx_dma_en;
|
BOOL tx_dma_en;
|
||||||
uint8_t *txbuf;
|
uint8_t *txbuf;
|
||||||
uint16_t txsize;
|
uint16_t txsize;
|
||||||
volatile BOOL tx_dma_ok; // 发送DMA完成标志
|
__IO BOOL tx_dma_ok; // 发送DMA完成标志
|
||||||
|
|
||||||
// 接收中断回调
|
// 接收中断回调
|
||||||
rx_interupt_cb_t rx_interupt_cb;
|
rx_interupt_cb_t rx_interupt_cb;
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
volatile uint32_t uwTick;
|
__IO uint32_t uwTick;
|
||||||
volatile uint32_t scheduler_start_time; // 调度器开始时间
|
__IO uint32_t scheduler_start_time; // 调度器开始时间
|
||||||
volatile uint32_t scheduler_end_time; // 调度器结束时间
|
__IO uint32_t scheduler_end_time; // 调度器结束时间
|
||||||
volatile uint32_t scheduler_occupancy_time = 0; // 调度器占用时间
|
__IO uint32_t scheduler_occupancy_time = 0; // 调度器占用时间
|
||||||
/**
|
/**
|
||||||
* @brief 设置中断向量表偏移地址
|
* @brief 设置中断向量表偏移地址
|
||||||
* @param baseaddr : 基址
|
* @param baseaddr : 基址
|
||||||
|
@ -32,7 +32,7 @@ void sys_nvic_set_vector_table(uint32_t baseaddr, uint32_t offset)
|
||||||
*/
|
*/
|
||||||
void sys_wfi_set(void)
|
void sys_wfi_set(void)
|
||||||
{
|
{
|
||||||
__ASM volatile("wfi");
|
__ASM __IO("wfi");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,7 +42,7 @@ void sys_wfi_set(void)
|
||||||
*/
|
*/
|
||||||
void sys_intx_disable(void)
|
void sys_intx_disable(void)
|
||||||
{
|
{
|
||||||
__ASM volatile("cpsid i");
|
__ASM __IO("cpsid i");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +52,7 @@ void sys_intx_disable(void)
|
||||||
*/
|
*/
|
||||||
void sys_intx_enable(void)
|
void sys_intx_enable(void)
|
||||||
{
|
{
|
||||||
__ASM volatile("cpsie i");
|
__ASM __IO("cpsie i");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,7 +125,7 @@ void sys_millis_reset(void)
|
||||||
*/
|
*/
|
||||||
uint32_t sys_to_seconds(uint32_t start_time)
|
uint32_t sys_to_seconds(uint32_t start_time)
|
||||||
{
|
{
|
||||||
return (uwTick - start_time) / 1000;
|
return (sys_millis() - start_time) / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Reference in New Issue