Skip to content

Commit

Permalink
Hotfix for two CLI Firefly commands (#226)
Browse files Browse the repository at this point in the history
* fix ff xmit off all and ff recvr off all commands
* add clearing of i2c mux on read_ff_register and write_ff_register
  • Loading branch information
pwittich authored May 31, 2024
1 parent 094b3e2 commit 864ea11
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions projects/cm_mcu/commands/SensorControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ int read_ff_register(const char *name, uint16_t packed_reg_addr, uint8_t *value,
SMBUS_get_error(res), ff_moni2c_addrs[ff].name);
}
}
if (!res) { // clear the mux
muxmask = 0x0U;
res = apollo_i2c_ctl_w(i2c_device, ff_moni2c_addrs[ff].mux_addr, 1, muxmask);
if (res != 0) {
log_warn(LOG_SERVICE, "%s: Mux clear error %d (%s) (ff=%s) ...\r\n", __func__, res,
SMBUS_get_error(res), ff_moni2c_addrs[ff].name);
}
}

// release the semaphore
if (xSemaphoreGetMutexHolder(s) == xTaskGetCurrentTaskHandle())
Expand Down Expand Up @@ -111,6 +119,14 @@ static int write_ff_register(const char *name, uint8_t reg, uint16_t value, int
SMBUS_get_error(res), ff_moni2c_addrs[ff].name);
}
}
if (!res) { // clear the mux
muxmask = 0x0U;
res = apollo_i2c_ctl_w(i2c_device, ff_moni2c_addrs[ff].mux_addr, 1, muxmask);
if (res != 0) {
log_warn(LOG_SERVICE, "%s: Mux clear error %d (%s) (ff=%s) ...\r\n", __func__, res,
SMBUS_get_error(res), ff_moni2c_addrs[ff].name);
}
}

// release the semaphore
if (xSemaphoreGetMutexHolder(s) == xTaskGetCurrentTaskHandle())
Expand Down Expand Up @@ -141,7 +157,7 @@ static int disable_transmit(bool disable, int num_ff)
}

if (strstr(ff_moni2c_addrs[i].name, "XCVR") != NULL) {
value = 0xf;
value &= 0x000fU;
ret += write_ff_register(ff_moni2c_addrs[i].name, ECU0_25G_XVCR_TX_DISABLE_REG, value, 1, i2c_dev);
}
else if (strstr(ff_moni2c_addrs[i].name, "Tx") != NULL) {
Expand Down Expand Up @@ -173,10 +189,10 @@ static int disable_receivers(bool disable, int num_ff)
i2c_dev = I2C_DEVICE_F2;
}
if (strstr(ff_moni2c_addrs[i].name, "XCVR") != NULL) {
value = 0xf;
value &= 0x000fU; // only 4 LSB matter, so mask out others
ret += write_ff_register(ff_moni2c_addrs[i].name, ECU0_25G_XVCR_RX_DISABLE_REG, value, 1, i2c_dev);
}
else if (strstr(ff_moni2c_addrs[i].name, "Rx") != NULL) {
else if (strstr(ff_moni2c_addrs[i].name, "Rx") != NULL) { // FIXME: check for CERNB vs 25G
ret += write_ff_register(ff_moni2c_addrs[i].name, ECU0_14G_RX_DISABLE_REG, value, 2, i2c_dev);
}
}
Expand Down

0 comments on commit 864ea11

Please sign in to comment.