forked from achamaikin/CCSModuleSW30Web
80 lines
2.2 KiB
C
Executable File
80 lines
2.2 KiB
C
Executable File
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include "charger_config.h"
|
|
|
|
typedef enum{
|
|
RELAY_AUX0 = 0,
|
|
RELAY_AUX1,
|
|
RELAY3,
|
|
RELAY_DC,
|
|
RELAY_AC,
|
|
RELAY_CP,
|
|
RELAY_CC,
|
|
RELAY_DC1,
|
|
//
|
|
RELAY_COUNT
|
|
} relay_t;
|
|
|
|
void RELAY_Write(relay_t num, uint8_t state);
|
|
uint8_t RELAY_Read(relay_t num);
|
|
void Init_Peripheral();
|
|
uint8_t GBT_LockGetState();
|
|
void GBT_Lock(uint8_t state);
|
|
uint8_t SW_GetAddr();
|
|
void ADC_Select_Channel(uint32_t ch);
|
|
uint8_t ADC_TryLock(void);
|
|
void ADC_LockBlocking(void);
|
|
void ADC_Unlock(void);
|
|
int16_t GBT_ReadTemp(uint8_t ch);
|
|
int16_t CONN_ReadTemp(uint8_t ch);
|
|
|
|
typedef enum{
|
|
IN_SW0 = 0,
|
|
IN_SW1,
|
|
IN0,
|
|
IN_ESTOP,
|
|
IN_FB1,
|
|
IN_CONT_FB_DC,
|
|
ISO_IN,
|
|
} inputNum_t;
|
|
|
|
uint8_t IN_ReadInput(inputNum_t input_n);
|
|
|
|
// ConfigBlock: new bootloader at 0x08007800, legacy at 0x080001E4
|
|
#define VERSION_OFFSET (0x08007800u)
|
|
#define VERSION_OFFSET_LEGACY (0x080001E4u)
|
|
|
|
typedef struct __attribute__((packed)) {
|
|
uint32_t serialNumber; // Байты 0-3
|
|
uint8_t stationType; // Байт 4
|
|
uint8_t boardVersion; // Байт 5
|
|
uint8_t addrEdcan; // Байт 6
|
|
uint8_t contactorConfig; // Байт 7
|
|
uint8_t connectorConfig; // Байт 8
|
|
uint8_t maxPower; // Байт 9, 5 кВт/bit
|
|
uint8_t psuType; // Байт 10
|
|
uint8_t meterType; // Байт 11
|
|
uint8_t balancerType; // Байт 12
|
|
uint8_t autostartMode; // Байт 13
|
|
uint8_t motorEnable; // Байт 14
|
|
uint16_t connector1CurrentLimitA; // Байты 15-16, A; 0 = legacy PSU_MAX_CURRENT
|
|
uint16_t connector2CurrentLimitA; // Байты 17-18
|
|
uint16_t connector3CurrentLimitA; // Байты 19-20
|
|
uint8_t reserved[43]; // Байты 21-63
|
|
} InfoBlock_t;
|
|
|
|
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
|
_Static_assert(sizeof(InfoBlock_t) == 64, "InfoBlock_t must be 64 bytes");
|
|
#endif
|
|
|
|
extern InfoBlock_t *InfoBlock;
|
|
|
|
void Board_SelectInfoBlockAddress(void);
|
|
void Board_LoadInfoBlockLimits(void);
|
|
uint16_t Board_GetConnectorCurrentLimit_0p1A(void);
|
|
uint16_t Board_ClampCurrent_0p1A(uint16_t current_0p1A);
|
|
PsuType_t Board_GetPsuType(void);
|
|
uint16_t Board_GetPsuMaxCurrentA(void);
|
|
uint32_t Board_GetPsuMaxPowerW(void);
|