Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
pwittich committed Jan 13, 2025
1 parent 66a7586 commit 941854c
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 46 deletions.
2 changes: 0 additions & 2 deletions common/power_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@ void turn_on_ps_at_prio(bool f2_enable, bool f1_enable, int prio)
}
}



void blade_power_ok(bool isok)
{
uint8_t val = (isok == true) ? 0x1U : 0x0U;
Expand Down
1 change: 0 additions & 1 deletion common/power_ctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ void setPSStatus(int i, enum ps_state theState);
// Number of enable and power good/OK pins
#define PS_NUM_PRIORITIES 6


#define N_PS_ENABLES 10
#define N_PS_OKS 12
#define PS_OKS_MASK ((1U << N_PS_OKS) - 1)
Expand Down
56 changes: 27 additions & 29 deletions projects/prod_test/ADCMonitorTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@

#include "ADCMonitorTask.h"


// a struct to hold some information about the ADC channel.
struct ADC_Info_t {
int channel; // which of the 20 ADC channels on the TM4C1290NCPDT on Apollo CM v1
const char *name; // name
float scale; // scaling, if needed, for signals bigger than 2.5V
float offset; // offset, if needed
int channel; // which of the 20 ADC channels on the TM4C1290NCPDT on Apollo CM v1
const char *name; // name
float scale; // scaling, if needed, for signals bigger than 2.5V
float offset; // offset, if needed
float target_value; // expected value for this ADC
int sequence; // sequence at which this power is turned on.
int sequence; // sequence at which this power is turned on.
};

// parameters for how data is organized in the fADC arrays and how the
Expand All @@ -71,33 +70,32 @@ struct ADC_Info_t {
//
// -------------------------------------------------

static
struct ADC_Info_t ADCs[] = {
{ADC_CTL_CH0, "VCC_12V", 6.f, 0.f, 12.f, 0},
{ADC_CTL_CH1, "VCC_M3V3", 2.f, 0.f, 3.3f, 0},
{ADC_CTL_CH2, "VCC_3V3", 2.f, 0.f, 3.3f, 3},
{ADC_CTL_CH3, "VCC_4V0", 2.f, 0.f, 4.0f, 6},
{ADC_CTL_CH4, "VCC_1V8", 1.f, 0.f, 1.8f, 2},
{ADC_CTL_CH5, "F1_VCCINT", 1.f, 0.f, 0.85f, 1},
{ADC_CTL_CH6, "F1_AVCC", 1.f, 0.f, 0.90f, 4},
{ADC_CTL_CH7, "F1_AVTT", 1.f, 0.f, 1.2f, 5},
{ADC_CTL_CH8, "F1_VCCAUX", 1.f, 0.f, 1.8f, 5},
{ADC_CTL_CH9, "F2_VCCINT", 1.f, 0.f, 0.85f, 1},
static struct ADC_Info_t ADCs[] = {
{ADC_CTL_CH0, "VCC_12V", 6.f, 0.f, 12.f, 0},
{ADC_CTL_CH1, "VCC_M3V3", 2.f, 0.f, 3.3f, 0},
{ADC_CTL_CH2, "VCC_3V3", 2.f, 0.f, 3.3f, 3},
{ADC_CTL_CH3, "VCC_4V0", 2.f, 0.f, 4.0f, 6},
{ADC_CTL_CH4, "VCC_1V8", 1.f, 0.f, 1.8f, 2},
{ADC_CTL_CH5, "F1_VCCINT", 1.f, 0.f, 0.85f, 1},
{ADC_CTL_CH6, "F1_AVCC", 1.f, 0.f, 0.90f, 4},
{ADC_CTL_CH7, "F1_AVTT", 1.f, 0.f, 1.2f, 5},
{ADC_CTL_CH8, "F1_VCCAUX", 1.f, 0.f, 1.8f, 5},
{ADC_CTL_CH9, "F2_VCCINT", 1.f, 0.f, 0.85f, 1},
{ADC_CTL_CH10, "F2_AVCC", 1.f, 0.f, 0.90f, 4},
{ADC_CTL_CH11, "F2_AVTT", 1.f, 0.f, 1.2f, 5},
{ADC_CTL_CH12, "F2_VCCAUX", 1.f, 0.f, 1.8f, 5},
#ifdef REV2
#ifdef REV2
{ADC_CTL_CH13, "CUR_V_12V", 10.f, 0.f, 2.5f, -1},
#else // REV3
#else // REV3
{ADC_CTL_CH13, "CUR_V_12V", 12.5f, 0.f, 2.5f, -1},
#endif //
#endif //
{ADC_CTL_CH14, "CUR_V_M3V3", 2.f, 0.f, 2.5f, -1},
{ADC_CTL_CH15, "CUR_V_4V0", 2.f, 0.f, 2.5f, -1},
{ADC_CTL_CH16, "CUR_V_F1VCCAUX", 1.f, 0.f, 2.5f, -1},
{ADC_CTL_CH17, "CUR_V_F2VCCAUX", 1.f, 0.f, 2.5f, -1},
{ADC_CTL_CH18, "F1_TEMP", (1.004f/1.026f)/0.004f, -273.15f, 35.f, -1}, // degrees C
{ADC_CTL_CH19, "F2_TEMP", (1.004f/1.026f)/0.004f, -273.15f, 35.f, -1}, // degrees C
{ADC_CTL_TS, "TM4C_TEMP", 1.f, 0.f, 0.f, -1}, // this one is special, temp in C
{ADC_CTL_CH18, "F1_TEMP", (1.004f / 1.026f) / 0.004f, -273.15f, 35.f, -1}, // degrees C
{ADC_CTL_CH19, "F2_TEMP", (1.004f / 1.026f) / 0.004f, -273.15f, 35.f, -1}, // degrees C
{ADC_CTL_TS, "TM4C_TEMP", 1.f, 0.f, 0.f, -1}, // this one is special, temp in C
};
#else
#error Need to define revision
Expand Down Expand Up @@ -128,7 +126,7 @@ float getADCtargetValue(const int i)

#if defined(REV2) || defined(REV3)
#define ADC_DIFF_TOLERANCE 0.05f // in percent
int check_ps_at_prio(int prio, bool f2_enable, bool f1_enable, float * delta)
int check_ps_at_prio(int prio, bool f2_enable, bool f1_enable, float *delta)
{
// in the special case where neither f1 or f2 are enabled (no FPGAs),
// enable both of them (commissioning of new PCB
Expand All @@ -138,13 +136,13 @@ int check_ps_at_prio(int prio, bool f2_enable, bool f1_enable, float * delta)
}
int retval = 0;
// loop over the ADC
for ( int i = 0; i < ADC_CHANNEL_COUNT; ++i) {
if ( ADCs[i].sequence == prio) {
for (int i = 0; i < ADC_CHANNEL_COUNT; ++i) {
if (ADCs[i].sequence == prio) {
float current_val = getADCvalue(i);
float target_val = getADCtargetValue(i);
float diff = (current_val - target_val)/target_val;
float diff = (current_val - target_val) / target_val;
*delta = diff;
if (ABS(diff) > ADC_DIFF_TOLERANCE ) {
if (ABS(diff) > ADC_DIFF_TOLERANCE) {
retval = 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion projects/prod_test/ADCMonitorTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// ADC task
#define ADC_CHANNEL_COUNT 21
#define ADC_INFO_TEMP_ENTRY 20 // this needs to be manually kept correct.
#define ADC_INFO_TEMP_ENTRY 20 // this needs to be manually kept correct.
#if defined(REV2) || defined(REV3) // REV2
#define ADC_INFO_GEN_VCC_INIT_CH 0
#define ADC_INFO_GEN_VCC_4V0_CH 3
Expand Down
24 changes: 12 additions & 12 deletions projects/prod_test/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ __attribute__((noreturn)) BaseType_t bl_ctl(int argc, char **argv, char *m)
}

//// power control state names
//static const char *power_control_state_names[] = {
//#define X(name) #name,
// X_MACRO_PS_STATES
//#undef X
//};
// static const char *power_control_state_names[] = {
// #define X(name) #name,
// X_MACRO_PS_STATES
// #undef X
// };

int check_ps_at_prio(int prio, bool f2_enable, bool f1_enable, float * delta);
int check_ps_at_prio(int prio, bool f2_enable, bool f1_enable, float *delta);

// turn on power at the specified level
BaseType_t power_ctl(int argc, char **argv, char *m)
Expand All @@ -84,14 +84,14 @@ BaseType_t power_ctl(int argc, char **argv, char *m)
return pdFALSE;
}
// 0 is automatic
if ( level > 0)
if (level > 0)
turn_on_ps_at_prio(true, true, level);
vTaskDelay(pdMS_TO_TICKS(1000)); // let ADC catch up
float delta;
int r = check_ps_at_prio(level, true, true, &delta);
int copied = snprintf(m, SCRATCH_SIZE, "volt compare at level %d: %s\r\n",
level, (r==0?"good":"bad"));
copied += snprintf(m+copied, SCRATCH_SIZE-copied, "delta: %f%%\r\n",
level, (r == 0 ? "good" : "bad"));
copied += snprintf(m + copied, SCRATCH_SIZE - copied, "delta: %f%%\r\n",
(double)delta);

return pdFALSE;
Expand Down Expand Up @@ -130,10 +130,10 @@ BaseType_t adc_ctl(int argc, char **argv, char *m)
float val = getADCvalue(whichadc);
copied += snprintf(m + copied, SCRATCH_SIZE - copied, "%14s: %5.2f",
getADCname(whichadc), (double)val);
if ( whichadc < ADC_INFO_CUR_INIT_CH ) { // for voltage vals, check
if (whichadc < ADC_INFO_CUR_INIT_CH) { // for voltage vals, check
float target_val = getADCtargetValue(whichadc);
float diff = (target_val - val)/val;
if ( ABS(diff) > 0.05f) {
float diff = (target_val - val) / val;
if (ABS(diff) > 0.05f) {
copied += snprintf(m + copied, SCRATCH_SIZE - copied, "\tBAD");
}
}
Expand Down
2 changes: 1 addition & 1 deletion projects/prod_test/printf_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef PROD_TEST_PRINTF_CONFIG_H_
#define PROD_TEST_PRINTF_CONFIG_H_

//#define PRINTF_DISABLE_SUPPORT_FLOAT
// #define PRINTF_DISABLE_SUPPORT_FLOAT
#define PRINTF_DISABLE_SUPPORT_EXPONENTIAL
#define PRINTF_DISABLE_SUPPORT_LONG_LONG
#define PRINTF_DISABLE_SUPPORT_PTRDIFF_T
Expand Down

0 comments on commit 941854c

Please sign in to comment.