Files
acquisition_module/user.H

122 lines
3.9 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef _user_H_
#define _user_H_
#define DF_SwTx 6
#define DF_SwRx 7
#define DF_RXTIME 11
#define DF_SwTxKGF1 8
#define DF_SwTxKGF2 10
#define DF_SwTxTemp 12
#define DF_SwRxKGF2 13
#define MAX_TIME 43200 //最大分钟也就是30天整
#define dfPwmH 10 //PWM的高电平时间1010ms左右具体需要测试20181227
#define WAKE_UP_PIN P1_5 //高压开关引脚 // 修改为旧版本硬件
#define KGF_PIN P0_0 //唤醒引脚
#define CAN_PIN P1_6 //唤醒引脚
#define STOP_PIN P3_6 //急停开关引脚
#define BATTERY_PIN P1_4 //电池控制脚
#define ON 0 //按下
#define OFF 1 //松开
#define FAULT 0
#define NORMAL 1
// 定义电源状态枚举
typedef enum {
POWER_STANDBY,
POWER_WORKING,
POWER_EMERGENCY,
POWER_PRE_CHARGE,
POWER_NEUTRAL,
POWER_SLEEP
} PowerState;
// 输出到开关阀模块
typedef struct _StrInfCanKGFOutput
{
//----------主机发送命令字0x11000002 --------------------------------------------
unsigned int KGF01 : 1; // 通道1
unsigned int KGF02 : 1; // 通道2
unsigned int KGF03 : 1; // 通道3
unsigned int KGF04 : 1; // 通道4
unsigned int KGF05 : 1; // 通道5
unsigned int KGF06 : 1; // 通道6
unsigned int KGF07 : 1; // 通道7
unsigned int KGF08 : 1; // 通道8
unsigned int KGF09 : 1; // 通道9
unsigned int KGF10 : 1; // 通道10
unsigned int KGF11 : 1; // 通道11
unsigned int KGF12 : 1; // 通道12
unsigned int KGF13 : 1; // 通道13
unsigned int KGF14 : 1; // 通道14
unsigned int KGF15 : 1; // 通道15
unsigned int KGF16 : 1; // 通道16
unsigned int can_rx2 : 8; // 保留
unsigned int can_rx3 : 8; // 保留
unsigned int can_rx4 : 8; // 保留
unsigned int can_rx5 : 8; // 保留
unsigned int can_period_h : 8; // 发送周期高位
unsigned int can_period_l : 8; // 发送周期低位
//----------发送0x11000003 ---------------------------------------------------
unsigned int pwm_01 : 4; // PWM通道1
unsigned int pwm_02 : 4; // PWM通道2
unsigned int pwm_03 : 4; // PWM通道3
unsigned int pwm_04 : 4; // PWM通道4
unsigned int pwm_05 : 4; // PWM通道5
unsigned int pwm_06 : 4; // PWM通道6
unsigned int pwm_07 : 4; // PWM通道7
unsigned int pwm_08 : 4; // PWM通道8
unsigned int pwm_09 : 4; // PWM通道9
unsigned int pwm_10 : 4; // PWM通道10
unsigned int pwm_11 : 4; // PWM通道11
unsigned int pwm_12 : 4; // PWM通道12
unsigned int pwm_13 : 4; // PWM通道13
unsigned int pwm_14 : 4; // PWM通道14
unsigned int pwm_15 : 4; // PWM通道15
unsigned int pwm_16 : 4; // PWM通道16
} StrInfCanKGFOutput;
typedef union _UnInfCanKGFOutput
{
StrInfCanKGFOutput bit_data; // 使用定义的结构体变量名
ubyte arr[sizeof(StrInfCanKGFOutput)]; // 通过结构体类型确定大小
} UnInfCanKGFOutput;
//---外部要使用变量声明---------------------------------------------------------------------
extern UnSwOut UnSwOut_1;
extern UnInfCan UnInfCan_1;
extern uword CntCan_1;
extern bit FlgCan_1;
extern ubyte can_error_cnt;
extern ubyte can_error_flg;
extern UnInfCanKGFOutput un_inf_can_kgf_output1;//kgf输出
void CanRXTX(void);
void SwSample(void);
void LedDr(void);
void RTCProcess(void);
void CanErrorProcess(void);
void CanTransmit(void);
void canSendTo(ubyte index, ubyte *buff);
#endif