From df67d03105d1699a90b6d8bdcc38b7cd6f5cd95f Mon Sep 17 00:00:00 2001 From: Peter Wittich Date: Thu, 23 May 2024 15:11:07 -0400 Subject: [PATCH] formatting and cleanup --- projects/cm_mcu/FireflyUtils.c | 8 ++--- projects/cm_mcu/MonUtils.c | 4 +-- projects/cm_mcu/MonitorTaskI2C_new.c | 2 +- projects/cm_mcu/clocksynth.c | 6 ++-- projects/cm_mcu/cm_mcu.c | 7 ++--- projects/cm_mcu/commands/SensorControl.c | 40 ++++++++++++------------ 6 files changed, 33 insertions(+), 34 deletions(-) diff --git a/projects/cm_mcu/FireflyUtils.c b/projects/cm_mcu/FireflyUtils.c index 009c60b5..3322b7aa 100644 --- a/projects/cm_mcu/FireflyUtils.c +++ b/projects/cm_mcu/FireflyUtils.c @@ -148,10 +148,10 @@ void readFFpresent(void) ((present_FFL12_BOTTOM_F1)); // 6 bits #elif defined(REV2) - present_FFL12_F1 = present_FFL12_F1 & 0x3FU; // bottom 6 bits - present_FFL12_F2 = present_FFL12_F2 & 0x3FU; // bottom 6 bits - present_FFL4_F1 = (present_FFL4_F1 >> 4) & 0xFU; // bits 4-7 - present_FFL4_F2 = (present_FFL4_F2 >> 4) & 0xFU; // bits 4-7 + present_FFL12_F1 = present_FFL12_F1 & 0x3FU; // bottom 6 bits + present_FFL12_F2 = present_FFL12_F2 & 0x3FU; // bottom 6 bits + present_FFL4_F1 = (present_FFL4_F1 >> 4) & 0xFU; // bits 4-7 + present_FFL4_F2 = (present_FFL4_F2 >> 4) & 0xFU; // bits 4-7 uint32_t ff_combined_present = ((present_FFL4_F2) << 16) | // 4 bits ((present_FFL12_F2) << 10) | // 6 bits diff --git a/projects/cm_mcu/MonUtils.c b/projects/cm_mcu/MonUtils.c index f697ed6e..a44ef6af 100644 --- a/projects/cm_mcu/MonUtils.c +++ b/projects/cm_mcu/MonUtils.c @@ -8,7 +8,7 @@ // for 4 channel parts, there is one XCVR part int FireflyType(int device) { - device = device %NFIREFLIES_F1; // F1 and F2 devices are the same. + device = device % NFIREFLIES_F1; // F1 and F2 devices are the same. switch (device) { case 0: case 1: @@ -50,7 +50,7 @@ int ClockType(int device) bool isEnabledFF_F2(int device) { // firefly devices on F2 are devices 10-19 - return isEnabledFF(device+NFIREFLIES_F1); + return isEnabledFF(device + NFIREFLIES_F1); } struct MonitorI2CTaskArgs_new_t ff_f1_args = { diff --git a/projects/cm_mcu/MonitorTaskI2C_new.c b/projects/cm_mcu/MonitorTaskI2C_new.c index 26630cc4..d82d09e1 100644 --- a/projects/cm_mcu/MonitorTaskI2C_new.c +++ b/projects/cm_mcu/MonitorTaskI2C_new.c @@ -121,7 +121,7 @@ void MonitorI2CTask_new(void *parameters) // what kind of device is this uint32_t devtype_mask = args->typeCallback(device); - uint32_t devtype = 32 - __builtin_clz( devtype_mask); // highest bit set FIXME: this is backwards + uint32_t devtype = 32 - __builtin_clz(devtype_mask); // highest bit set FIXME: this is backwards // Loop to read I2C registers/commands for (int c = 0; c < args->n_commands; ++c) { // check if the command is for this device diff --git a/projects/cm_mcu/clocksynth.c b/projects/cm_mcu/clocksynth.c index 86631bd7..ef8f6735 100644 --- a/projects/cm_mcu/clocksynth.c +++ b/projects/cm_mcu/clocksynth.c @@ -104,7 +104,7 @@ void getClockProgram(int device, char progname_clkdesgid[CLOCK_PROGNAME_REG_NAME CLOCK_CHANGEPAGE_REG_ADDR, 1, page); // now read out the six bytes of data in two reads - const uint8_t reg = (CLOCK_PROGNAME_REG_ADDR_START) & 0xFF; + const uint8_t reg = (CLOCK_PROGNAME_REG_ADDR_START)&0xFF; uint16_t init_postamble_page = 32 * (device + 1) - 1; // read the addresses in EEPROM that store the number of registers in Preamble-register, Register, and Postamble-register list per a clock config file @@ -131,10 +131,10 @@ void getClockProgram(int device, char progname_clkdesgid[CLOCK_PROGNAME_REG_NAME // as eepromdata[0] and eepromdat[1],respectively // third byte from three addresses in EEPROM is a value byte - apollo_i2c_ctl_reg_r(CLOCK_I2C_DEV, CLOCK_I2C_EEPROM_ADDR, 2, eeprom_progname_reg + ((i) * 3), 3, tempdata); + apollo_i2c_ctl_reg_r(CLOCK_I2C_DEV, CLOCK_I2C_EEPROM_ADDR, 2, eeprom_progname_reg + ((i)*3), 3, tempdata); eepromdata[0] |= ((tempdata[0] >> (16)) & 0xFF) << (i * 8); // third byte from three addresses in EEPROM is a value byte - apollo_i2c_ctl_reg_r(CLOCK_I2C_DEV, CLOCK_I2C_EEPROM_ADDR, 2, eeprom_progname_reg + 12 + ((i) * 3), 3, tempdata); + apollo_i2c_ctl_reg_r(CLOCK_I2C_DEV, CLOCK_I2C_EEPROM_ADDR, 2, eeprom_progname_reg + 12 + ((i)*3), 3, tempdata); eepromdata[1] |= ((tempdata[0] >> (16)) & 0xFF) << (i * 8); } } diff --git a/projects/cm_mcu/cm_mcu.c b/projects/cm_mcu/cm_mcu.c index 3a3f5fee..6b550086 100644 --- a/projects/cm_mcu/cm_mcu.c +++ b/projects/cm_mcu/cm_mcu.c @@ -137,7 +137,7 @@ void SystemInitInterrupts(void) #if defined(REV1) initI2C6(g_ui32SysClock); // controller for FPGAs #elif defined(REV2) - initI2C5(g_ui32SysClock); // controller for FPGAs + initI2C5(g_ui32SysClock); // controller for FPGAs #endif // smbus @@ -305,9 +305,8 @@ __attribute__((noreturn)) int main(void) #ifdef REV2 xTaskCreate(MonitorI2CTask_new, ff_f1_args.name, 2 * configMINIMAL_STACK_SIZE, &ff_f1_args, tskIDLE_PRIORITY + 4, NULL); - // these get stored to the wrong location -// xTaskCreate(MonitorI2CTask_new, ff_f2_args.name, 2 * configMINIMAL_STACK_SIZE, &ff_f2_args, tskIDLE_PRIORITY + 4, -// NULL); + xTaskCreate(MonitorI2CTask_new, ff_f2_args.name, 2 * configMINIMAL_STACK_SIZE, &ff_f2_args, tskIDLE_PRIORITY + 4, + NULL); xTaskCreate(MonitorI2CTask, clock_args.name, 2 * configMINIMAL_STACK_SIZE, &clock_args, tskIDLE_PRIORITY + 4, NULL); diff --git a/projects/cm_mcu/commands/SensorControl.c b/projects/cm_mcu/commands/SensorControl.c index d561d93b..9a6ae742 100644 --- a/projects/cm_mcu/commands/SensorControl.c +++ b/projects/cm_mcu/commands/SensorControl.c @@ -859,7 +859,7 @@ BaseType_t ff_temp(int argc, char **argv, char *m) int copied = 0; static int whichff = 0; - static int nn=0, n = 0; + static int nn = 0;//, n = 0; if (nn == 0) { // check for stale data @@ -902,25 +902,25 @@ BaseType_t ff_temp(int argc, char **argv, char *m) } copied += snprintf(m+copied, SCRATCH_SIZE - copied, "-------\r\n"); #endif - //static int nn = 0; - for (; nn < NFIREFLIES; ++nn) { - if (isEnabledFF(nn)) { - uint8_t val = get_FF_TEMPERATURE_data(nn); - copied += snprintf(m + copied, SCRATCH_SIZE - copied, "%17s: %2d", ff_moni2c_addrs[nn].name, val); - } - else // dummy value - copied += snprintf(m + copied, SCRATCH_SIZE - copied, "%17s: %2s", ff_moni2c_addrs[nn].name, "--"); - if ((SCRATCH_SIZE - copied) < 20) { - ++whichff; - return pdTRUE; - } - bool isTx = (strstr(ff_moni2c_addrs[nn].name, "Tx") != NULL); - if (isTx) - copied += snprintf(m + copied, SCRATCH_SIZE - copied, "\t"); - else - copied += snprintf(m + copied, SCRATCH_SIZE - copied, "\r\n"); + // static int nn = 0; + for (; nn < NFIREFLIES; ++nn) { + if (isEnabledFF(nn)) { + uint8_t val = get_FF_TEMPERATURE_data(nn); + copied += snprintf(m + copied, SCRATCH_SIZE - copied, "%17s: %2d", ff_moni2c_addrs[nn].name, val); } - nn = 0; + else // dummy value + copied += snprintf(m + copied, SCRATCH_SIZE - copied, "%17s: %2s", ff_moni2c_addrs[nn].name, "--"); + if ((SCRATCH_SIZE - copied) < 20) { + ++whichff; + return pdTRUE; + } + bool isTx = (strstr(ff_moni2c_addrs[nn].name, "Tx") != NULL); + if (isTx) + copied += snprintf(m + copied, SCRATCH_SIZE - copied, "\t"); + else + copied += snprintf(m + copied, SCRATCH_SIZE - copied, "\r\n"); + } + nn = 0; //} if (nn % 2 == 1) { @@ -929,7 +929,7 @@ BaseType_t ff_temp(int argc, char **argv, char *m) m[copied] = '\0'; } whichff = 0; - n = 0; + //n = 0; return pdFALSE; }