添加控制部分
This commit is contained in:
parent
af341d58fe
commit
0288f9a9a6
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"chargcontrol.h": "c",
|
||||||
|
"parameter.h": "c",
|
||||||
|
"comm.h": "c",
|
||||||
|
"bl_chargcontrol.h": "c",
|
||||||
|
"comm_types.h": "c"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
# application应用层
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# businessLogic业务逻辑层
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# functionalModule功能模块层
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# hardwareDriver硬件驱动层
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
#ifndef APP_CHARG_CONTROL_H_
|
||||||
|
#define APP_CHARG_CONTROL_H_
|
||||||
|
|
||||||
|
#include "bl_chargControl.h"
|
||||||
|
|
||||||
|
|
||||||
|
void chargControl(void);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
#ifndef APP_COMM_H_
|
||||||
|
#define APP_COMM_H_
|
||||||
|
|
||||||
|
#include "comm_types.h"
|
||||||
|
|
||||||
|
|
||||||
|
void uart_comm(void);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef APP_START_H_
|
||||||
|
#define APP_START_H_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void start(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
#include "chargControl.h"
|
||||||
|
#include "parameter.h"
|
||||||
|
#include "comm_types.h"
|
||||||
|
|
||||||
|
void chargControl(void)
|
||||||
|
{
|
||||||
|
getCVData();
|
||||||
|
judgeYNBattery();
|
||||||
|
|
||||||
|
g_otherParameter.MPPT_Mode = chargControlMode();
|
||||||
|
|
||||||
|
if (g_otherParameter.MPPT_Mode == noWork) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_otherParameter.batteryState) {
|
||||||
|
BatteryChargControl();
|
||||||
|
} else {
|
||||||
|
noBatteryChargControl();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
#include "comm.h"
|
||||||
|
|
||||||
|
void uart_comm(void)
|
||||||
|
{
|
||||||
|
GW485_comm();
|
||||||
|
BAT485_comm();
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
#include "start.h"
|
||||||
|
|
||||||
|
|
||||||
|
void start(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef BL_CHARG_CONTROL_H_
|
||||||
|
#define BL_CHARG_CONTROL_H_
|
||||||
|
|
||||||
|
#include "chargControlEnum.h"
|
||||||
|
|
||||||
|
void getCVData(void);
|
||||||
|
void judgeYNBattery(void);
|
||||||
|
int chargControlMode(void);
|
||||||
|
void BatteryChargControl(void);
|
||||||
|
void noBatteryChargControl(void);
|
||||||
|
|
||||||
|
extern void chargControl(void);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
#ifndef BL_COMM_H_
|
||||||
|
#define BL_COMM_H_
|
||||||
|
|
||||||
|
#include "comm_types.h"
|
||||||
|
|
||||||
|
|
||||||
|
void GW485_comm(void);
|
||||||
|
void BAT485_comm(void);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,88 @@
|
||||||
|
|
||||||
|
#ifndef BL_PARAMETER_H_
|
||||||
|
#define BL_PARAMETER_H_
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#define softVer "SV01_24101501"
|
||||||
|
|
||||||
|
#pragma pack(push,1)
|
||||||
|
|
||||||
|
/* 主要有配置文件读取出来的数据 */
|
||||||
|
typedef struct _config_parameter{
|
||||||
|
float constantVoltageV; /* 电压高于ConstantVoltageV且电流大于(FloatI + 0.1)进行恒压充电
|
||||||
|
电压低于该(ConstantVoltageV - 0.2) 进行恒流充电 (V) */
|
||||||
|
float floatI; /* 电压高于该ConstantVoltageV且电流低于FloatI进行浮充充电 (A) */
|
||||||
|
float startSolarOpenCircuitV; /* 太阳能板开路电压高于该电压开始充电 (V) */
|
||||||
|
float stopSolarOpenCircuitV; /* 太阳能板开路电压高于该电压停止充电 (V) */
|
||||||
|
float constantVoltageChargeV; /* 恒压充电时的输出电压 (V) */
|
||||||
|
float FloatV; /* 浮充充电时的输出电压 (V) */
|
||||||
|
float loopImpedance; /* 回路阻抗大小 (mΩ) */
|
||||||
|
float HighSideMosTemperature_stop; /* 当上桥温度达到该值时,停止输出 (°C) */
|
||||||
|
float HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 (°C) */
|
||||||
|
float HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 (°C) */
|
||||||
|
|
||||||
|
uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 (S) */
|
||||||
|
uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */
|
||||||
|
uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */
|
||||||
|
uint16_t excessiveLoadFlagTime; /* 出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出 (S) */
|
||||||
|
uint16_t eLAgainTime; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
|
||||||
|
uint32_t collectOpenCircuitVoltageTime; /* 开路电压采集时间间隔 */
|
||||||
|
|
||||||
|
/* SL */
|
||||||
|
uint8_t address[7]; /* 地址 */
|
||||||
|
uint16_t Access_Node_Type; /* 接入节点类型 */
|
||||||
|
uint16_t Communication_Methods; /* 通信方式 */
|
||||||
|
uint16_t Registration_Status; /* 注册状态 */
|
||||||
|
uint8_t startFlagSL[2]; /* 起始标志 */
|
||||||
|
uint8_t endFlagSL; /* 结束标志 */
|
||||||
|
|
||||||
|
/* HY */
|
||||||
|
uint8_t hardwareID[6]; /* 硬件ID */
|
||||||
|
uint8_t communicationID[4]; /* 通信ID */
|
||||||
|
uint8_t protocolType; /* 协议类型; 0x01表示:汇源协议(波特率9600) 0x02表示:南瑞协议(波特率115200)*/
|
||||||
|
uint8_t startFlagHY; /* 起始码 */
|
||||||
|
uint8_t endFlagHY; /* 结束码 */
|
||||||
|
|
||||||
|
uint8_t onlyPower; /* 是否只充当电源板:0x00:不是
|
||||||
|
0x01:是*/
|
||||||
|
|
||||||
|
uint32_t gw485_Baud; /* 串口波特率 */
|
||||||
|
uint32_t bat485_Baud; /* 串口波特率,为0代表bms不支持通信 */
|
||||||
|
} config_parameter;
|
||||||
|
extern config_parameter g_cfgParameter;
|
||||||
|
|
||||||
|
typedef struct _otherParameter{
|
||||||
|
float Battery_Voltage; /* 电池电压 (V) */
|
||||||
|
float Output_Voltage; /* 输出电压 */
|
||||||
|
float Charg_Current; /* 充电电流(流向电池+负载) (A) */
|
||||||
|
float Discharg_Current; /* 放电电流(流向负载) (A) */
|
||||||
|
float Input_Voltage; /* 系统输入电压 (V) */
|
||||||
|
float Solar_Open_Circuit_Voltage; /* 太阳能板开路电压 (V) */
|
||||||
|
float HighSideMos_Temperature; /* 高端mos的温度 (°C) */
|
||||||
|
float Solar_In_Circuit_Voltage; /* 太阳能板输入电压 (V) */
|
||||||
|
|
||||||
|
float Charg_BatteryCurrent; /* 电池充电电流(流向电池) (A) */
|
||||||
|
float totalElectricityConsumption; /* 总电量消耗(W*H) */
|
||||||
|
float totalChargCapacity; /* 总充电电量(W*H) */
|
||||||
|
float SOC; /* 剩余电量 */
|
||||||
|
|
||||||
|
uint16_t chargMos_State; /* 充电开关状态 */
|
||||||
|
uint16_t DischargMos_State; /* 放电mos的状态 */
|
||||||
|
uint16_t MPPT_Mode; /* 工作模式 */
|
||||||
|
|
||||||
|
uint8_t versionInformation[13]; /* 软件版本信息 */
|
||||||
|
|
||||||
|
uint8_t batteryState; /* 有无电池(估计) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float dutyRatio; /* 占空比 */
|
||||||
|
}otherParameter;
|
||||||
|
extern otherParameter g_otherParameter;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,199 @@
|
||||||
|
|
||||||
|
#include "bl_chargControl.h"
|
||||||
|
#include "parameter.h"
|
||||||
|
#include "comm_types.h"
|
||||||
|
|
||||||
|
static void stopChargWork(void);
|
||||||
|
static int stopChargConditions(void);
|
||||||
|
static int floatChargConditions(void);
|
||||||
|
static int mpptChargConditions(void);
|
||||||
|
static int constantVChargConditions(void);
|
||||||
|
static void mpptCharge(void);
|
||||||
|
static void constantVoltageCharge(void);
|
||||||
|
static void floatCharge(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 停止充电
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void stopChargWork(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 判断达到停止充电的条件
|
||||||
|
* @param
|
||||||
|
* @retval TRUE 达到停止充电
|
||||||
|
* FALSE 未达到
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
BOOL stopChargConditions(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 判断达到浮充充电的条件
|
||||||
|
* @param
|
||||||
|
* @retval TRUE 达到
|
||||||
|
* FALSE 未达到
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
BOOL floatChargConditions(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 判断达到最大功率充电的条件
|
||||||
|
* @param
|
||||||
|
* @retval TRUE 达到
|
||||||
|
* FALSE 未达到
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
BOOL mpptChargConditions(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 判断达到恒压充电的条件
|
||||||
|
* @param
|
||||||
|
* @retval TRUE 达到
|
||||||
|
* FALSE 未达到
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
BOOL constantVChargConditions(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 判断充电控制的模式
|
||||||
|
* @param
|
||||||
|
* @retval 返回充电控制器的模式
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int chargControlMode(void)
|
||||||
|
{
|
||||||
|
if (stopChargConditions()) {
|
||||||
|
stopChargWork();
|
||||||
|
return noWork;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (floatChargConditions()) {
|
||||||
|
return floatCharg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mpptChargConditions()) {
|
||||||
|
return MPPT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (constantVChargConditions()) {
|
||||||
|
return constantVoltage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到充电控制器控制所需的电流电压
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void getCVData(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 判断有无电池
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void judgeYNBattery(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 无电池时控制
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void noBatteryChargControl(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 最大功率充电
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void mpptCharge(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 恒压充电
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void constantVoltageCharge(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 浮充充电
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void floatCharge(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 有电池时控制
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void BatteryChargControl(void)
|
||||||
|
{
|
||||||
|
switch(g_otherParameter.MPPT_Mode) {
|
||||||
|
|
||||||
|
case CONSTANTCURRENT:
|
||||||
|
mpptCharge();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONSTANTVOLTAGE:
|
||||||
|
constantVoltageCharge();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FLOAT:
|
||||||
|
floatCharge();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
stopChargWork();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
#include "bl_comm.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void GW485_comm(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void BAT485_comm(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
#include "parameter.h"
|
||||||
|
|
||||||
|
config_parameter g_cfgParameter = {0};
|
||||||
|
otherParameter g_otherParameter = {0};
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>RTDescription</name>
|
<name>RTDescription</name>
|
||||||
<state>Use the full configuration of the C/C++ runtime library. Full locale interface, C locale, file descriptor support, multibytes in printf and scanf, and hex floats in strtod.</state>
|
<state>A complete configuration of the C/C++14 runtime library. Full locale interface, C locale, file descriptor support, multibytes in printf and scanf, and hex floats in strtod.</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>OGProductVersion</name>
|
<name>OGProductVersion</name>
|
||||||
|
@ -189,7 +189,7 @@
|
||||||
<option>
|
<option>
|
||||||
<name>TrustZoneModes</name>
|
<name>TrustZoneModes</name>
|
||||||
<version>0</version>
|
<version>0</version>
|
||||||
<state>1</state>
|
<state>0</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>OGAarch64Abi</name>
|
<name>OGAarch64Abi</name>
|
||||||
|
@ -359,6 +359,12 @@
|
||||||
<state>$PROJ_DIR$/../Drivers/CMSIS/Device/ST/STM32G4xx/Include</state>
|
<state>$PROJ_DIR$/../Drivers/CMSIS/Device/ST/STM32G4xx/Include</state>
|
||||||
<state>$PROJ_DIR$/../Drivers/CMSIS/Include</state>
|
<state>$PROJ_DIR$/../Drivers/CMSIS/Include</state>
|
||||||
<state>$PROJ_DIR$/../Middlewares/ST/ARM/DSP/Inc</state>
|
<state>$PROJ_DIR$/../Middlewares/ST/ARM/DSP/Inc</state>
|
||||||
|
<state>$PROJ_DIR$\..\APP\application\Inc</state>
|
||||||
|
<state>$PROJ_DIR$\..\APP\businessLogic\Inc</state>
|
||||||
|
<state>$PROJ_DIR$\..\APP\functionalModule\Inc</state>
|
||||||
|
<state>$PROJ_DIR$\..\APP\hardwareDriver\Inc</state>
|
||||||
|
<state>$PROJ_DIR$\..\tools\RingQueue</state>
|
||||||
|
<state>$PROJ_DIR$\..\tools</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCStdIncCheck</name>
|
<name>CCStdIncCheck</name>
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* ring_queue.c
|
||||||
|
*
|
||||||
|
* Created on: 2024年6月21日
|
||||||
|
* Author: psx
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//循环队列
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "ring_queue.h"
|
||||||
|
|
||||||
|
//#define RING_QUEUE_DEBUG
|
||||||
|
|
||||||
|
//#ifdef RING_QUEUE_DEBUG
|
||||||
|
//#define //rq_debug term_printf
|
||||||
|
//#else
|
||||||
|
//void rq_debug(const char *fmt, ...){};
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
//初始化队列
|
||||||
|
int InitRingQueue(RingQueue *q, RQ_ElementType *buff, int size)
|
||||||
|
{
|
||||||
|
q->elems = buff;
|
||||||
|
q->size = size;
|
||||||
|
q->front=q->rear=0;
|
||||||
|
return RQ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//遍历队列,
|
||||||
|
//消费者使用,故对生产者可能修改的rear先读取缓存
|
||||||
|
int ShowRingQueue(RingQueue *q)
|
||||||
|
{
|
||||||
|
//int i;
|
||||||
|
int rear = q->rear;
|
||||||
|
|
||||||
|
if(q->front == rear)
|
||||||
|
{
|
||||||
|
//rq_debug("队列为空\n");
|
||||||
|
return RQ_ERROR;
|
||||||
|
}
|
||||||
|
//rq_debug("队列中的元素为:\n");
|
||||||
|
//for(i=((q->front)%q->size); i != rear; i=((i+1)%q->size))
|
||||||
|
//rq_debug(" %c\n",q->elems[i]);
|
||||||
|
|
||||||
|
//rq_debug("\n");
|
||||||
|
//rq_debug("队首元素为%c\n",q->elems[q->front]);
|
||||||
|
//rq_debug("队尾元素为%c\n",q->elems[rear - 1]);
|
||||||
|
return RQ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//向队尾插入元素e
|
||||||
|
int InRingQueue(RingQueue *q,RQ_ElementType e)
|
||||||
|
{
|
||||||
|
if(RingQueueFull(q))
|
||||||
|
{
|
||||||
|
//rq_debug("空间不足\n");
|
||||||
|
return(RQ_OVERFLOW);
|
||||||
|
}
|
||||||
|
q->elems[q->rear] = e;
|
||||||
|
q->rear = (q->rear+1) % q->size;
|
||||||
|
//rq_debug("rear = %d\n",q->rear);
|
||||||
|
return RQ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//从队首取回并删除元素
|
||||||
|
int OutRingQueue(RingQueue *q, RQ_ElementType *e)
|
||||||
|
{
|
||||||
|
if(RingQueueEmpty(q))
|
||||||
|
{
|
||||||
|
//rq_debug("队列为空\n");
|
||||||
|
return RQ_ERROR;
|
||||||
|
}
|
||||||
|
*e = q->elems[q->front];
|
||||||
|
//rq_debug("被删除的队首元素为%c\n",q->elems[q->front]);
|
||||||
|
q->front = (q->front+1) % q->size;
|
||||||
|
return RQ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
//队列中的元素个数
|
||||||
|
int RingQueueLength(RingQueue *q)
|
||||||
|
{
|
||||||
|
return ((q->rear - q->front) + q->size) % q->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* ring_queue.h
|
||||||
|
*
|
||||||
|
* Created on: 2024年6月21日
|
||||||
|
* Author: psx
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DRIVERS_RINGQUEUE_RING_QUEUE_H_
|
||||||
|
#define DRIVERS_RINGQUEUE_RING_QUEUE_H_
|
||||||
|
|
||||||
|
|
||||||
|
//#define RING_QUEUE_DEBUG //定义本宏会打印RingQueue的调试信息
|
||||||
|
|
||||||
|
#define RQ_OK 1
|
||||||
|
#define RQ_ERROR 0
|
||||||
|
#define RQ_OVERFLOW -2
|
||||||
|
typedef unsigned char RQ_ElementType;//元素类型
|
||||||
|
|
||||||
|
typedef struct _ring_queue
|
||||||
|
{
|
||||||
|
RQ_ElementType *elems;
|
||||||
|
int size;
|
||||||
|
volatile int front, rear;
|
||||||
|
}RingQueue;
|
||||||
|
|
||||||
|
//初始化队列,需传入保存队列状态的结构q,队列使用的buffer和buffer大小
|
||||||
|
int InitRingQueue(RingQueue *q, RQ_ElementType *buff, int size);
|
||||||
|
|
||||||
|
#define RingQueueFull(q) (((q)->rear+1) % (q)->size == (q)->front)
|
||||||
|
#define RingQueueEmpty(q) ((q)->front == (q)->rear)
|
||||||
|
|
||||||
|
//遍历队列,
|
||||||
|
//消费者使用,故对生产者可能修改的rear先读取缓存
|
||||||
|
int ShowRingQueue(RingQueue *q);
|
||||||
|
|
||||||
|
//向队尾插入元素e
|
||||||
|
int InRingQueue(RingQueue *q,RQ_ElementType e);
|
||||||
|
|
||||||
|
//从队首删除元素
|
||||||
|
int OutRingQueue(RingQueue *q, RQ_ElementType *e);
|
||||||
|
|
||||||
|
//队列中的元素个数
|
||||||
|
int RingQueueLength(RingQueue *q);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* DRIVERS_RINGQUEUE_RING_QUEUE_H_ */
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
#ifndef CHARG_CONTROL_ENUM_
|
||||||
|
#define CHARG_CONTROL_ENUM_
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
noWork = 0, /* 未进行充电 */
|
||||||
|
MPPT = 1, /* 最大功率充电 */
|
||||||
|
constantVoltage = 2, /* 恒压充电 */
|
||||||
|
floatCharg = 3 /* 浮充充电 */
|
||||||
|
}chargControlMode;
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,58 @@
|
||||||
|
#ifndef _COMM_TYPES_
|
||||||
|
#define _COMM_TYPES_
|
||||||
|
#define RAM_FUNC __ramfunc
|
||||||
|
|
||||||
|
typedef unsigned long int ulong;
|
||||||
|
typedef unsigned short int ushort;
|
||||||
|
typedef unsigned int uint;
|
||||||
|
typedef unsigned char u_int8_t;
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
typedef unsigned short int u_int16_t;
|
||||||
|
typedef unsigned short int uint16_t;
|
||||||
|
typedef unsigned int u_int32_t;
|
||||||
|
typedef unsigned int uint32_t;
|
||||||
|
typedef unsigned long long u_int64_t;
|
||||||
|
typedef unsigned long long uint64_t;
|
||||||
|
typedef unsigned char BOOL;
|
||||||
|
|
||||||
|
// This type MUST be 8 bit
|
||||||
|
typedef unsigned char BYTE;
|
||||||
|
|
||||||
|
// These types MUST be 16 bit
|
||||||
|
typedef short SHORT;
|
||||||
|
typedef unsigned short WORD;
|
||||||
|
typedef unsigned short WCHAR;
|
||||||
|
|
||||||
|
// These types MUST be 16 bit or 32 bit
|
||||||
|
typedef int INT;
|
||||||
|
typedef unsigned int UINT;
|
||||||
|
|
||||||
|
// These types MUST be 32 bit
|
||||||
|
typedef long LONG;
|
||||||
|
typedef unsigned long DWORD;
|
||||||
|
|
||||||
|
#ifdef FALSE
|
||||||
|
#undef FALSE
|
||||||
|
#endif
|
||||||
|
#define FALSE (0)
|
||||||
|
|
||||||
|
#ifdef TRUE
|
||||||
|
#undef TRUE
|
||||||
|
#endif
|
||||||
|
#define TRUE (1)
|
||||||
|
|
||||||
|
//#define SUCCESS (0)
|
||||||
|
|
||||||
|
#define ELEMENT_OF(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
typedef union{
|
||||||
|
int iValue;
|
||||||
|
float fValue;
|
||||||
|
u_int8_t cValue[4];
|
||||||
|
}U_DataType;
|
||||||
|
|
||||||
|
#endif /* _COMM_TYPES_ */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Filter Coefficients (C Source) generated by the Filter Design and Analysis Tool
|
||||||
|
* Generated by MATLAB(R) 9.13 and Signal Processing Toolbox 9.1.
|
||||||
|
* Generated on: 03-Dec-2024 14:47:22
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 离散时间 FIR 滤波器(实数)
|
||||||
|
* ----------------
|
||||||
|
* 滤波器结构 : 直接型 FIR
|
||||||
|
* 滤波器长度 : 6
|
||||||
|
* 稳定 : 是
|
||||||
|
* 线性相位 : 是 (Type 2)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* General type conversion for MATLAB generated C-code */
|
||||||
|
// #include "tmwtypes.h"
|
||||||
|
/*
|
||||||
|
* Expected path to tmwtypes.h
|
||||||
|
* C:\Program Files\MATLAB\R2022b\extern\include\tmwtypes.h
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Warning - Filter coefficients were truncated to fit specified data type.
|
||||||
|
* The resulting response may not match generated theoretical response.
|
||||||
|
* Use the Filter Design & Analysis Tool to design accurate
|
||||||
|
* single-precision filter coefficients.
|
||||||
|
*/
|
||||||
|
// const int BL = 6;
|
||||||
|
// const real32_T B[6] = {
|
||||||
|
// 0.01861755922, -0.1146286726, 0.5962908864, 0.5962908864, -0.1146286726,
|
||||||
|
// 0.01861755922
|
||||||
|
// };
|
|
@ -0,0 +1,36 @@
|
||||||
|
|
||||||
|
#ifndef TOOLS_PDEBUG_H_
|
||||||
|
#define TOOLS_PDEBUG_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "uart_dev.h"
|
||||||
|
#include "pdebug.h"
|
||||||
|
|
||||||
|
/* Comment out this define to include debug messages */
|
||||||
|
//#define NDEBUG
|
||||||
|
|
||||||
|
#define log_info_enable 1
|
||||||
|
#define log_warn_enable 0
|
||||||
|
#define log_error_enable 0
|
||||||
|
|
||||||
|
/* Comment out this define to include log messages */
|
||||||
|
//#define NLOG
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
#define debug(M, ...) do {}while(0)
|
||||||
|
#else
|
||||||
|
#define debug(M, ...) debug_printf("%s:%d: " M "\r\n", __FILE__, __LINE__, ##__VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NLOG
|
||||||
|
#define log_err(M, ...) do {}while(0)
|
||||||
|
#define log_warn(M, ...) do {}while(0)
|
||||||
|
#define log_info(M, ...) do {}while(0)
|
||||||
|
#else
|
||||||
|
#define log_info(M, ...) {if(log_info_enable){char *p = strrchr(__FILE__, '\\'); debug_printf("[INFO] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
||||||
|
#define log_warn(M, ...) {if(log_warn_enable){char *p = strrchr(__FILE__, '\\'); debug_printf("[WARN] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
||||||
|
#define log_error(M, ...) {if(log_error_enable){char *p = strrchr(__FILE__, '\\'); debug_printf("[ERROR] [%s:%d] " M "\r\n", p+1, __LINE__,##__VA_ARGS__);}}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue