Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pwittich committed May 30, 2024
1 parent 001c597 commit b7ccfc9
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 13 deletions.
37 changes: 31 additions & 6 deletions projects/cm_mcu/FireflyUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,22 +263,25 @@ uint16_t getFFpresentbit(const uint8_t i)
return val;
}

// figure out which parts are 25G and which are not, for 12 channel parts
uint32_t ff_map_25gb_parts(void)
{
uint32_t ff_25gb_parts = 0U;
uint32_t ff_25gb_pairs = 0U;
for (int i = 0; i < NFIREFLIES; ++i) {
if (!isEnabledFF(i)) { // skip the FF if it's not enabled via the FF config
continue;
}
// skip 4 channel parts
if (FireflyType(i) == DEVICE_25G4) {
continue;
}

char name[17];
memset(name, '\0', 17);
int startReg = VENDOR_START_BIT_FF12;
int count = VENDOR_COUNT_FF12;
int startReg = VENDOR_START_BIT_FFDAQ;
int count = VENDOR_COUNT_FFDAQ;
int type = FireflyType(i);
if (type == DEVICE_CERNB || type == DEVICE_25G12) {
startReg = VENDOR_START_BIT_FF12;
count = VENDOR_COUNT_FF12;
}
int ret = 0;
// build up name of the device (vendor string)
for (unsigned char c = 0; c < count; ++c) {
Expand All @@ -290,11 +293,33 @@ uint32_t ff_map_25gb_parts(void)
log_error(LOG_SERVICE, "Error reading vendor string for FF %d\r\n", i);
// what to do? FIXME: return error?
}
log_info(LOG_SERVICE, "F%d FF%02d: %s\r\n", i/10+1, i%10, name);
// skip 4 channel parts
if (type == DEVICE_25G4) {
continue;
}
if (strstr(name, "14") == NULL &&
strstr(name, "CRRNB") == NULL && strstr(name, "CERNB") == NULL) {
ff_25gb_parts |= (0x1U << i);
int ipair = i/2; // counts pairs of 12 channel devices
ff_25gb_pairs |= (0x1U << ipair);
}
}
log_info(LOG_SERVICE, "ff 25G12 mask: 0x%08lx\r\n", ff_25gb_parts);
// these masks have one bit per pair of receiver/transceiver
ff_bitmask_args[0].ffpart_bit_mask = ff_25gb_pairs & 0x7U;
ff_bitmask_args[2].ffpart_bit_mask = (ff_25gb_pairs>>10) & 0x7U;
// check if the 4v switch settings match
// F1
if (ff_bitmask_args[0].ffpart_bit_mask != f1_ff12xmit_4v0_sel) {
log_error(LOG_SERVICE, "4v switch and part mismatch F1: 0x%x != 0x%x\r\n",
ff_bitmask_args[0].ffpart_bit_mask,f1_ff12xmit_4v0_sel);
}
// F2
if (ff_bitmask_args[2].ffpart_bit_mask != f2_ff12xmit_4v0_sel) {
log_error(LOG_SERVICE, "4v switch and part mismatch F2: 0x%x != 0x%x\r\n",
ff_bitmask_args[2].ffpart_bit_mask,f2_ff12xmit_4v0_sel);
}
return ff_25gb_parts;
}

Expand Down
1 change: 1 addition & 0 deletions projects/cm_mcu/FireflyUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ float getFFavgoptpow(const uint8_t i);
uint16_t getFFpresentbit(const uint8_t i);
#ifdef REV2
void getFFpart(void);
uint32_t ff_map_25gb_parts(void);
#endif

uint8_t getFFstatus(const uint8_t i);
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 @@ -126,7 +126,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 = 31 - __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
4 changes: 2 additions & 2 deletions projects/cm_mcu/MonitorTaskI2C_new.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ struct MonitorI2CTaskArgs_new_t {
#define DEVICE_14G 0x02
#define DEVICE_25G4 0x04
#define DEVICE_25G12 0x08
#define DEVICE_SI5395 0x10
#define DEVICE_SI5341 0x20
#define DEVICE_SI5341 0x01
#define DEVICE_SI5395 0x02

#define DEVICE_NONE 0x80

Expand Down
1 change: 1 addition & 0 deletions projects/cm_mcu/PowerSupplyTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ void PowerSupplyTask(void *parameters)
// check 12-ch FF parts from vendors on FPGA1/2
vTaskDelay(pdMS_TO_TICKS(1000));
getFFpart();
ff_map_25gb_parts();
UBaseType_t ffmask[2] = {0xe, 0xe};
if ((f1_ff12xmit_4v0_sel ^ ff_bitmask_args[0].ffpart_bit_mask) == 0x0U && (f2_ff12xmit_4v0_sel ^ ff_bitmask_args[2].ffpart_bit_mask) == 0x0U) {
int ret = enable_3v8(ffmask, false); // enable v38
Expand Down
9 changes: 5 additions & 4 deletions projects/cm_mcu/commands/SensorControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1362,8 +1362,9 @@ BaseType_t clkmon_ctl(int argc, char **argv, char *m)
continue;
}
uint16_t val = clk_args.commands[c].retrieveData(i);
int devtype = 31 - __builtin_clz(ClockType(i));
copied += snprintf(m + copied, SCRATCH_SIZE - copied, "%-15s : 0x%04x 0x%04x 0x%04x\r\n",
clk_args.commands[c].name, clk_args.commands[c].command[ClockType(i)],
clk_args.commands[c].name, clk_args.commands[c].command[devtype],
clk_args.commands[c].bit_mask, val);
if ((SCRATCH_SIZE - copied) < 20) {
++c;
Expand All @@ -1377,12 +1378,12 @@ BaseType_t clkmon_ctl(int argc, char **argv, char *m)
}
c = 0;
#ifdef REV2
copied += snprintf(m + copied, SCRATCH_SIZE - copied, "Program (read from clock chip): %s", clkprog_args[0].progname_clkdesgid);
if (strncmp(clkprog_args[0].progname_clkdesgid, "5395ABP1", 3) == 0 || strncmp(clkprog_args[0].progname_clkdesgid, "5341ABP1", 3) == 0) {
copied += snprintf(m + copied, SCRATCH_SIZE - copied, "Program (read from clock chip): %s", clkprog_args[i].progname_clkdesgid);
if (strncmp(clkprog_args[i].progname_clkdesgid, "5395ABP1", 3) == 0 || strncmp(clkprog_args[i].progname_clkdesgid, "5341ABP1", 3) == 0) {
copied += snprintf(m + copied, SCRATCH_SIZE - copied, " (not found)");
}

snprintf(m + copied, SCRATCH_SIZE - copied, "\r\nProgram (read from eeprom): %s\r\n", clkprog_args[0].progname_eeprom);
snprintf(m + copied, SCRATCH_SIZE - copied, "\r\nProgram (read from eeprom): %s\r\n", clkprog_args[i].progname_eeprom);
#endif

return pdFALSE;
Expand Down

0 comments on commit b7ccfc9

Please sign in to comment.