Skip to content

Commit

Permalink
CSE77xx fix (#1004)
Browse files Browse the repository at this point in the history
* improove CSE7759B

* reverted messed white spaces

---------

Co-authored-by: Your Name <[email protected]>
  • Loading branch information
artin961 and Your Name authored Dec 24, 2023
1 parent 8957d11 commit 84d3641
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/driver/drv_cse7766.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int CSE7766_TryToGetNextCSE7766Packet() {
int cs;
int i;
int c_garbage_consumed = 0;
byte a;
//byte a;
byte checksum;
int CSE7766_PACKET_LEN = 24;
byte header;
Expand All @@ -33,8 +33,8 @@ int CSE7766_TryToGetNextCSE7766Packet() {
header = UART_GetByte(0);
// skip garbage data (should not happen)
while(cs > 0) {
a = UART_GetByte(1);
if(a != 0x5A) {
//a = UART_GetByte(1);
if(UART_GetByte(0) != 0x55 || UART_GetByte(1) != 0x5A) {
UART_ConsumeBytes(1);
c_garbage_consumed++;
cs--;
Expand All @@ -48,8 +48,8 @@ int CSE7766_TryToGetNextCSE7766Packet() {
if(cs < CSE7766_PACKET_LEN) {
return 0;
}
a = UART_GetByte(1);
if(a != 0x5A) {
//a = UART_GetByte(1);
if(UART_GetByte(0) != 0x55 || UART_GetByte(1) != 0x5A) {
return 0;
}
checksum = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/driver/drv_pwrCal.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ static float current_cal = 1;
static float power_cal = 1;

static int latest_raw_voltage;
static int latest_raw_current;
static float latest_raw_current;
static int latest_raw_power;

//#define PWRCAL_DEBUG

static commandResult_t Calibrate(const char *cmd, const char *args, int raw,
static commandResult_t Calibrate(const char *cmd, const char *args, float raw,
float *cal, int cfg_index) {
Tokenizer_TokenizeString(args, 0);
if (Tokenizer_CheckArgsCountAndPrintWarning(cmd, 1)) {
Expand Down Expand Up @@ -58,7 +58,7 @@ static commandResult_t CalibratePower(const void *context, const char *cmd,
return Calibrate(cmd, args, latest_raw_power, &power_cal, CFG_OBK_POWER);
}

static float Scale(int raw, float cal) {
static float Scale(float raw, float cal) {
return (cal_type == PWR_CAL_MULTIPLY ? raw * cal : raw / cal);
}

Expand Down Expand Up @@ -90,7 +90,7 @@ void PwrCal_Init(pwr_cal_type_t type, float default_voltage_cal,
CMD_RegisterCommand("PowerSet", CalibratePower, NULL);
}

void PwrCal_Scale(int raw_voltage, int raw_current, int raw_power,
void PwrCal_Scale(int raw_voltage, float raw_current, int raw_power,
float *real_voltage, float *real_current, float *real_power) {
latest_raw_voltage = raw_voltage;
latest_raw_current = raw_current;
Expand Down
2 changes: 1 addition & 1 deletion src/driver/drv_pwrCal.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ typedef enum {

void PwrCal_Init(pwr_cal_type_t type, float default_voltage_cal,
float default_current_cal, float default_power_cal);
void PwrCal_Scale(int raw_voltage, int raw_current, int raw_power,
void PwrCal_Scale(int raw_voltage, float raw_current, int raw_power,
float *real_voltage, float *real_current, float *real_power);
float PwrCal_ScalePowerOnly(int raw_power);

0 comments on commit 84d3641

Please sign in to comment.