正确理解C语言指针申明的含义

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了正确理解C语言指针申明的含义相关的知识,希望对你有一定的参考价值。

/*说明:*/

?

//文件名 : JudgeControlMode.h

?

# ifndef _JUDGECONTROLMODE_H_

# define _JUDGECONTROLMODE_H_

?

//------------------------------------宏定义--------------------------------------------------

/*

#define CHARGESOFTSTARTUPBOUND 4.5

#define CHARGEUPBOUND 5.5

#define DEADZONEUPBOUND 6.0

#define DISCHARGEUPBOUND 7.0

#define DISCHARGESOFTSTARTUPBOUND 8.0

?

#define OVERVOLTAGE 12.0

#define SAFECURRENT 60.0

#define OVERCURRENT 72.0

*/

#define CHARGEREF 5.0

#define CHARGE_DISCHARGE 5.5

#define DISCHARGEREF 10.0

?

#define OVERVOLTAGE 15.0

#define SAFECURRENT 20.0

#define OVERCURRENT 40.0

?

#define WORKMODE 0

#define LASTWORKMODE 0

?

#define READYSTARTMODE 0

#define CHARGESOFTSTARTMODE 1

#define CHARGEMODE 2

#define DISCHARGEMODE 3

#define DISCHARGESOFTSTARTMODE 4

#define OVERVOLTAGEMODE 5

#define SAFECURRENTMODE 6

#define OVERCURRENTMODE 7

?

#define CHARGESOFTSTOPMODE 8

#define DISCHARGESOFTSTOPMODE 9

?

#define JUDGEMODE_DEFAULT {0,0,0,0,0,0,0,0,0,0,0,0,\

????2,10,10,2,10,0,0,0,10,10,10,10,\

????CHARGEREF,CHARGE_DISCHARGE,DISCHARGEREF,OVERVOLTAGE,SAFECURRENT,OVERCURRENT,\

????WORKMODE,LASTWORKMODE,\

????READYSTARTMODE,CHARGESOFTSTARTMODE,CHARGEMODE,DISCHARGEMODE,DISCHARGESOFTSTARTMODE,OVERVOLTAGEMODE,SAFECURRENTMODE,OVERCURRENTMODE,\

????CHARGESOFTSTOPMODE,DISCHARGESOFTSTOPMODE\

????}

?

//------------------------------------结构体--------------------------------------------------

????typedef struct

????{

????????//累计次数.最大31

????????unsigned long temp1:5;

????????unsigned long temp2:5;

????????unsigned long temp3:5;

????????unsigned long temp4:5;

????????unsigned long temp5:5;

????????unsigned long temp6:5;

????????unsigned long :0;

????????unsigned long temp7:5;

????????unsigned long temp8:5;

????????unsigned long temp9:5;

????????unsigned long tempA:5;

????????unsigned long tempB:5;

????????unsigned long tempC:5;

????????unsigned long :0;

?

????????//容错次数.最大31

????????const unsigned long ChangeLevel1:5;

????????const unsigned long ChangeLevel2:5;

????????const unsigned long ChangeLevel3:5;

????????const unsigned long ChangeLevel4:5;

????????const unsigned long ChangeLevel5:5;

????????const unsigned long ChangeLevel6:5;

????????unsigned long :0;

????????const unsigned long ChangeLevel7:5;

????????const unsigned long ChangeLevel8:5;

????????const unsigned long ChangeLevel9:5;

????????const unsigned long ChangeLevelA:5;

????????const unsigned long ChangeLevelB:5;

????????const unsigned long ChangeLevelC:5;

????????unsigned long :0;

?

????????//电压界限

????????const float ChargeRef; //充电给定电压

????????const float Charge_Discharge; //充电和放电的边界

????????const float DischargeRef; //放电给定电压

????????const float OverVoltage; //过压电压

????????//电流界限

????????const float SafeCurrent; //安全电流

????????const float OverCurrent; //过流电流

?

????????//工作模式

????????unsigned long WorkMode :6; //控制模式标志位

????????unsigned long LastWorkMode :6; //上一次的控制模式

????????unsigned long :0;

?

????????//模式标志

????????const unsigned long ReadyStartMode :1; //待机状态的代码 0

????????const unsigned long ChargeSoftStartMode :1; //充电软启动模式的代码 1

????????const unsigned long ChargeMode :2; //正常充电模式的代码 2

????????//const unsigned long DeadZoneMode :2; //死区模式的代码 3

????????const unsigned long DischargeMode :3; //放电模式的代码 4

????????const unsigned long DisChargeSoftStartMode:3; //放电软启的代码 5

????????const unsigned long OverVoltageMode :3; //立即保护模式的代码 6

????????const unsigned long SafeCurrentMode :3; //立即保护模式的代码 7

????????const unsigned long OverCurrentMode :4; //立即保护模式的代码 8

????????const unsigned long ChargeSoftStopMode :4; //充电时软关断的代码 9

????????const unsigned long DischargeSoftStopMode :4; //放电时软关断的代码 10

????????unsigned long :0;

????}JUDGEMODE;

?

?

//------------------------------------函数原型------------------------------------------------

????void RunJudgeControlMode(const float CurrentValue);

????void ControlModeSelect(const long WorkMode,const unsigned ExterSignal,const float Voltage,const float Current);

????void PWMJudge(const unsigned long WorkMode);

????void StartJudgeControlMode(const float Voltage,const float Current,const unsigned long WorkMode);

????void StopJudgeControlMode(const long);

????void ClearChargePIstat(void);

????void ClearDischargePIstate(void);

????void ClearDuty(const char ClrChargeDuty,const char ClrDischargeDuty);

????void ResetJudgeMode(void);

# endif

?

//------------------------------------no more-----------------------------------------------

以上是关于正确理解C语言指针申明的含义的主要内容,如果未能解决你的问题,请参考以下文章

如何正确的理解指针和结构体指针?

c语言define用法

C语言中关于指针的学习

C语言中关于指针的学习

c语言指针详解

指针学习笔记