Commit ba4f68a3 authored by 赵康弘's avatar 赵康弘

feat: U48,外部信号设置过电流

parent 85379b6e
......@@ -4,9 +4,10 @@
#include "SGM4591Q.h"
#include "Dio.h"
#include "CAN_CH0_CAN_Communication_Matrix.h"
#include "Simulated_SPI_Master.h"
/*此文件用于上位机控制U16和U48*/
uint8_t state_23 = 1;
uint8_t state_23 = 0;
/*U16*/
void PC_Control_U16(void)
{
......@@ -45,9 +46,14 @@ void PC_Control_U16(void)
}
/*U48*/
uint8_t state_U48_1 = 1;
uint8_t state_U48_1 = 0;
void PC_Control_U48(void)
{
static uint8_t U48_Overcurrent_Last = 0;
uint8_t U48_Overcurrent = 0;
uint8_t U48_Overcurrent_LOW = 0;
uint8_t U48_Overcurrent_HIGH = 0;
state_U48_1 = Get_ID_18000000_Sig_PC_Control_U48_Power();
/*20A_OUT2*/
if (state_U48_1 == 1)
......@@ -62,5 +68,16 @@ void PC_Control_U48(void)
{
;
}
Get_ID_18000000_Sig_PC_Control_U48_CurrentControlSet();
U48_Overcurrent_LOW = Get_ID_18000000_Sig_PC_Control_U48_LOW();
U48_Overcurrent_HIGH = Get_ID_18000000_Sig_PC_Control_U48_HIGH();
U48_Overcurrent = U48_Overcurrent_LOW + U48_Overcurrent_HIGH << 3;
if (U48_Overcurrent_Last != U48_Overcurrent)
{
/*3.过电流高/低选择*/
MC33984EHFK_CS1_Output_Low();
Sim_SPI_Master_0_Byte_Write(MC33984_SOCHLR_0);
Sim_SPI_Master_0_Byte_Write(0x07);
MC33984EHFK_CS1_Output_High();
U48_Overcurrent_Last = U48_Overcurrent;
}
}
......@@ -80,7 +80,7 @@ extern volatile SGM4591Q_Pin_en SGM4591Q_Chip4_3_Segment1;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip4_4_Segment0;
extern volatile SGM4591Q_Pin_en SGM4591Q_Chip4_4_Segment1;
extern uint16_t ADC_4;
void SGM4591Q_Init(void);
void SGM4591Q_Global_Control(uint8_t Chip, uint8_t Segment);
void SGM4591Q_Control(void);
......@@ -38,18 +38,10 @@ void Sys_20ms_Tasks(void)
{
// Can_MainFunction_Read();
}
uint32_t u32IOConvert;
uint8_t u8test;
void Sys_50ms_Tasks(void)
{
u8test = Get_ID_18FF30E1_Sig_ECAS_Decrease();
u32IOConvert++;
// if (u32IOConvert > 100)
// {
// Port_SetPinDirection(Port_Config_PortGroup24_PortPin13,PORT_PIN_IN);
// Dio_WriteChannel(DioConf_DioChannel_P24_13,STD_LOW);
// }
u8test = Get_ID_18FF30E1_Sig_ECAS_Decrease();
}
uint16_t g_u16ADCValue[16] = {0};
uint8_t g_u8secstatus = 0U;
......@@ -79,72 +71,33 @@ uint16_t ADC_Input_Voltage_Calc(uint16_t u16ADCSample, uint16_t u16ADCRes, uint1
return u16Result;
}
uint32_t time_test=0;
uint8_t aaaaaaData = 0U;
uint8_t bcvcb = 0U;
// uint8 GaaByteAccfdfss[100] = { 0 };
uint32_t time_test = 0;
void Sys_100ms_Tasks(void)
{
time_test++;
// Dio_FlipChannel(DioConf_DioChannel_P56DioChannel);
// Dio_FlipChannel(DioConf_DioChannel_P24_13);
// g_u8secstatus++;
// Dio_FlipChannel(DioConf_DioChannel_P02_08);
/* Starts the conversion of group */
Adc_StartGroupConversion(AdcConf_AdcGroup_AdcGroup_000);
Adc_StartGroupConversion(AdcConf_AdcGroup_AdcGroup_000);
while (ADC_STREAM_COMPLETED != Adc_GetGroupStatus(AdcConf_AdcGroup_AdcGroup_000))
;
while (ADC_STREAM_COMPLETED != Adc_GetGroupStatus(AdcConf_AdcGroup_AdcGroup_000))
;
Adc_ReadGroup(AdcConf_AdcGroup_AdcGroup_000, g_u16ADCValue);
Adc_ReadGroup(AdcConf_AdcGroup_AdcGroup_000, g_u16ADCValue);
for (uint8_t i = 0; i < 16; i++)
{
g_u16ADCValue[i] = ADC_Input_Voltage_Calc(g_u16ADCValue[i], 4096, 5000);
if (i==4)
{
ADC_4=g_u16ADCValue[i];
}
}
// SGM4591Q_Control();
// Port_SetPinDirection(Port_Config_PortGroup4_PortPin8, PORT_PIN_OUT);
for (uint8_t i = 0; i < 16; i++)
{
g_u16ADCValue[i] = ADC_Input_Voltage_Calc(g_u16ADCValue[i], 4096, 5000);
if (i == 4)
{
ADC_U16 = g_u16ADCValue[i];
}
if (i == 0)
{
ADC_U48 = g_u16ADCValue[i];
}
}
Dio_WriteChannel(DioConf_DioChannel_P04_08, STD_LOW);
MC33984EHFK_Read();
// if (bcvcb == 1)
// {
// Dio_WriteChannel(DioConf_DioChannel_P02_05, STD_HIGH);
// Dio_WriteChannel(DioConf_DioChannel_P02_01, STD_HIGH);
// bcvcb = 0;
// }
// if (bcvcb == 2)
// {
// Dio_WriteChannel(DioConf_DioChannel_P02_05, STD_LOW);
// Dio_WriteChannel(DioConf_DioChannel_P02_01, STD_LOW);
// bcvcb = 0;
// }
MC33984EHFK_Read();
// if (aaaaaaData < 99)
// {
// aaaaaaData++;
// }
// else
// {
// aaaaaaData = 0;
// }
// GaaByteAccfdfss[aaaaaaData] = Dio_ReadChannel(Port_Config_PortGroup2_PortPin1);
// abbaaaData= Dio_ReadChannel(Port_Config_PortGroup22_PortPin3);
// Port_SetPinDirection(Port_Config_PortGroup22_PortPin3, PORT_PIN_IN);
// Port_SetPinDirection(Port_Config_PortGroup22_PortPin4, PORT_PIN_IN);
// Port_SetPinDirection(Port_Config_PortGroup22_PortPin4, PORT_PIN_OUT);
// Port_SetPinDirection(Port_Config_PortGroup22_PortPin3, PORT_PIN_OUT);
SGMCD1020Q_MainFunction();
PC_Control_U16();
PC_Control_U48();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment