
#ifndef SOFT_POWERAMP_H
#define SOFT_POWERAMP_H

#include "stdint.h"
#include "stdbool.h"
#include "common.h"
///////////////////

// #define POWERAMP_CRC8_KEY (0x2A)
// /*
// Number Item Data Index Remark
// 1 ����ܵ�ѹ Data[0-1] unsigned int, 16bits�� mV,Range: 0 �C 60000mV
// 2 ��ŵ���� Data[2-3] signed int�� 16bits�� 10mA
//                 Range: �C 300000 to 80000mA
//                 Positive for charging
//                 Negative for discharging.
// 3 Max allowable charging current
//                 Data[4-5] signed int�� 16bits�� 10mA
//                 Range: �C 300000 to 80000mA
//                 Positive for charging
//                 Negative for discharging.
//                 Remark:
//                 If communicating with UAV, this value
//                 will be 0.
// 4 ����о�¶� Data[6-7] signed int�� 16bits�� 0.1 Degree C, range: -40 to 125 degree C
// 5 ��С��о�¶� Data[8-9] signed int�� 16bits�� 0.1 Degree C, range: -40 to 125 degree C
// 6 ��Գ��״̬ Data[10-11] unsigned int�� 16bits�� 0.1% 0 to 1000 (0 to 1000��)
// 7 ���Գ��״̬ Data[12-13] unsigned int�� 16bits�� 0.1% 0 to 1000 (0 to 1000��)
// 8 ʣ������ Data[14-15] unsigned int�� 16bits�� mAH 0 mA to 20000 mAH
// 9 ����оѹ�� Data[16-17] unsigned int�� 16bits�� mV, 0mV to 1000mV
// 10 Cell 1 ��ѹ Data[18-19] unsigned int�� 16bits�� mV 0 to 4500mV
// 11 Cell 2 ��ѹ Data[20-21] unsigned int�� 16bits�� mV 0 to 4500mV
// 12 Cell 3 ��ѹ Data[22-23] unsigned int�� 16bits�� mV 0 to 4500mV
// 13 Cell 4 ��ѹ Data[24-25] unsigned int�� 16bits�� mV 0 to 4500mV
// 14 Cell 5 ��ѹ Data[26-27] unsigned int�� 16bits�� mV 0 to 4500mV
// 15 Cell 6 ��ѹ Data[28-29] unsigned int�� 16bits�� mV 0 to 4500mV
// 16 Cell 7 ��ѹ Data[30-31] unsigned int�� 16bits�� mV 0 to 4500mV
// 17 Cell 8 ��ѹ Data[32-33] unsigned int�� 16bits�� mV 0 to 4500mV
// 18 Cell 9 ��ѹ Data[34-35] unsigned int�� 16bits�� mV 0 to 4500mV
// 19 Cell 10 ��ѹ Data[36-37] unsigned int�� 16bits�� mV 0 to 4500mV
// 20 Cell 11 ��ѹ Data[38-39] unsigned int�� 16bits�� mV 0 to 4500mV
// 21 Cell 12 ��ѹ Data[40-41] unsigned int�� 16bits�� mV 0 to 4500mV
// 22 Cell 13 ��ѹ Data[42-43] unsigned int�� 16bits�� mV 0 to 4500mV
// 23 Warning level Data[44-45] Unsigned char, 8 bits,
//                             Value:
//                             0: no warning
//                             1: level 1 warning, UAV shall return
//                             2: level 2 warning, UAV shall land
// 24 ϵͳ״̬ Data[46-47] unsigned int, 16 bits
//                         Permanent Fault Alarm:
//                         Bit0: 1:��оѹ���, 0: ����
//                         Bit1: 1:ѭ������������ 0: ����
//                         Bit2: 1:��о�¶ȸߣ� 0: ����
//                         Bit3: 1:����ʧЧ�� 0: ����
//                         Cell Fault Alarm��
//                         Bit4: 1�� ��оѹ��ϴ�, 0: ����
//                         Discharging Alarm:
//                         Bit5: 1:��طŵ����, 0: ����
//                         Bit6: 1:��طŵ����, 0: ����
//                         Bit7, Bit8: �ŵ��ѹ�澯
//                         value: 0: ����
//                         value: 1: level 1, ��о��ѹ 3.4V ��
//                         SOC 30%, See Spec for details.
//                         value: 2: level 2, ��о��ѹ 3.0V ��
//                         SOC 20%, See Spec for details.
//                         value: 3: level 3, ��о��ѹ 2.8V ��
//                         SOC 10%, See Spec for details.
//                         Bit9: 1:�ŵ������ 0: ����
//                         Charging Alarm:
//                         Bit10: 1:�����£� 0: ����
//                         Bit11: 1:�����£� 0: ����
//                         Bit12: 1:����ѹ�� 0: ����
//                         Bit13: 1:�������� 0: ����
//                         Bit14: 1:������� 0: ����
//                         Remark:
//                         For charger: when BMS encounters
//                         the Charging Alarm or Cell fault
//                         alarm, BMS will turn off the charging
//                         MOSFET to stop charging.For UAV: when BMS encounters the
//                         Discharging Alarm or Cell fault alarm
//                         (UAV not in operation), BMS will turn
//                         off the discharging MOSFET.
// */
// #pragma pack(1)
// typedef struct
// {
//     short amp_data[24];  //
// }_POWERAMP_INF;
// #pragma pack()
// extern _POWERAMP_INF poweramp_inf;




// /*
// Number Item Data Index Remark
// 1 �����汾�� Data[0-1] unsigned char, 2 bytes.
//             Data[0]: major version
//             Data[1]: minor version
//             e.g.: v02.60, Data [0]=2, Data[1]=60
// 2 Ӳ���汾�� Data[2-3] unsigned char, 2 bytes.
//             Data[0]: major version
//             Data[1]: minor version
//             e.g.: v02.60, Data [0]=2, Data[1]=60
// 3 ͨ��Э��汾�� Data[4-5] unsigned char, 2 bytes.
//             Data[0]: major version
//             Data[1]: minor version
//             e.g.: v02.60, Data [0]=2, Data[1]=60
// */
// #pragma pack(1)
// typedef struct
// {
//     unsigned char amp_ver[6];  //
// }_POWERAMP_VER;
// #pragma pack()
// extern _POWERAMP_VER poweramp_ver;





// /*
// Number Item Data Index Remark
// 1 BMS ������� Data[0-1] unsigned int�� 16bits�� 0.1AH Max value 6553.5 AH
// 2 ��ش��� Data[2] unsigned char, 8bits, unit: 1 Value: 13
// 3 ��ؽ����� Data[3-4] unsigned int�� 16bits�� 0.1% Range: 0 to 1000 (0 to 1000��)
// 4 ���ѭ������ Data[5-6] unsigned int, 16bits, unit: 1 time
// 5 ��ع������ Data[7-8] unsigned int, 16bits, unit: 1 time
// 6 ��ع��Ŵ��� Data[9-10] unsigned int, 16bits, unit: 1 time
// 7 ��ع��´��� Data[11-12] unsigned int, 16bits, unit: 1 time
// 8 ��ع������� Data[13-14] unsigned int, 16bits, unit: 1 time
// 9 �����������ѹ Data[15-16] unsigned int, 16bits, mV
// 10 �����ع��ŵ�ѹ Data[17-18] unsigned int, 16bits, mV
// 11 ��ر�� Data[19-25] 7 bytes,
//                         Data [19-20]: ��J����M��
//                         Data [21]: year, 19-50, offset 2000,
//                         2019-2050
//                         Data [22]: month, 0-12
//                         Data [23]: day,0-31max
//                         Data [24-25]: unsigned int, production
//                         line SN
// 12 �� Data[26] unsigned char, 8 bits, offset 2000 E.g.: 19+2000 = 2019
// 13 �� Data[27] unsigned char, 8 bitsRange: 0 - 12
// 14 �� Data[28] unsigned char, 8 bitsRange: 0 �C 31 max
// 15 ʱ Data[29] unsigned char, 8 bitsRange: 0 - 23
// 16 �� Data[20] unsigned char, 8 bitsRange: 0 - 59
// 17 �� Data[31] unsigned char, 8 bitsRang
// */

// #pragma pack(1)
// typedef struct
// {
//     uint16_t amp_cap; //����
//     uint8_t amp_cellnum; //����
//     uint16_t amp_soh; //������
//     uint16_t amp_cycle; //ѭ������
//     uint16_t amp_chg_count; //
//     uint16_t amp_dsg_count;
//     uint16_t amp_otp_count;
//     uint16_t amp_ocp_count;
//     uint16_t amp_fullchg_cellvolt;
//     uint16_t amp_uvd_cellvolt;
//     uint8_t amp_sn[14]; //���
//     uint8_t amp_year;
//     uint8_t amp_month;
//     uint8_t amp_day;
//     uint8_t amp_hour;
//     uint8_t amp_min;
//     uint8_t amp_sencond;
// }_POWERAMP_SYS;
// #pragma pack()
// extern _POWERAMP_SYS poweramp_sys;

// extern Connect_check Poweramp_Link;
// void PowerAmpCanRecvHookFunction(uint32_t cellCanID, uint8_t* data, uint8_t len);

// void send_msg_to_poweramp(void);
// void check_poweramp_link(void);


// extern uint32_t time_poweramp_lastrecv;

#endif
