Skip to content

Commit

Permalink
formatting and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pwittich committed May 23, 2024
1 parent 80d34bb commit df67d03
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 34 deletions.
8 changes: 4 additions & 4 deletions projects/cm_mcu/FireflyUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions projects/cm_mcu/MonUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion projects/cm_mcu/MonitorTaskI2C_new.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions projects/cm_mcu/clocksynth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
Expand Down
7 changes: 3 additions & 4 deletions projects/cm_mcu/cm_mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
40 changes: 20 additions & 20 deletions projects/cm_mcu/commands/SensorControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down

0 comments on commit df67d03

Please sign in to comment.