Skip to content

Commit

Permalink
Change delay counts from ticks to ms
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavosr8 committed Feb 23, 2024
1 parent a0942fd commit b242cce
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 35 deletions.
14 changes: 7 additions & 7 deletions modules/adn4604.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ mmc_err adn4604_tx_control( uint8_t output, uint8_t tx_mode )
*/
enable[1] = tx_mode << 4;

if (i2c_take_by_chipid(CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t)10) ) {
if (i2c_take_by_chipid(CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t) pdMS_TO_TICKS(10)) ) {
tx_len = xI2CMasterWrite( i2c_interf, i2c_addr, enable, sizeof(enable) );
i2c_give(i2c_interf);
}
Expand All @@ -84,7 +84,7 @@ mmc_err adn4604_update( void )
uint8_t update[2] = { ADN_XPT_UPDATE_REG, 0x01 };
uint8_t tx_len = 0;

if (i2c_take_by_chipid(CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t)10) ) {
if (i2c_take_by_chipid(CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t) pdMS_TO_TICKS(10)) ) {
tx_len = xI2CMasterWrite( i2c_interf, i2c_addr, update, sizeof(update) );
i2c_give(i2c_interf);
}
Expand All @@ -99,7 +99,7 @@ mmc_err adn4604_reset( void )
uint8_t update[2] = { ADN_RESET_REG, 0x01 };
uint8_t tx_len = 0;

if (i2c_take_by_chipid(CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t)10) ) {
if (i2c_take_by_chipid(CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t) pdMS_TO_TICKS(10)) ) {
tx_len = xI2CMasterWrite( i2c_interf, i2c_addr, update, sizeof(update) );
i2c_give(i2c_interf);
}
Expand All @@ -114,7 +114,7 @@ mmc_err adn4604_xpt_config( uint8_t map, adn_connect_map_t xpt_con )

adn_connect_cfg_t cfg = { map, xpt_con };

if (i2c_take_by_chipid(CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t)10) ) {
if (i2c_take_by_chipid(CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t) pdMS_TO_TICKS(10)) ) {
tx_len = xI2CMasterWrite( i2c_interf, i2c_addr, (uint8_t *)&cfg, sizeof(cfg) );
i2c_give(i2c_interf);
}
Expand All @@ -130,7 +130,7 @@ mmc_err adn4604_active_map( uint8_t map )
/* Select the active map */
uint8_t map_sel[2] = { ADN_XPT_MAP_TABLE_SEL_REG, map };

if ( i2c_take_by_chipid( CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t)10 ) ) {
if ( i2c_take_by_chipid( CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t) pdMS_TO_TICKS(10) ) ) {
tx_len = xI2CMasterWrite( i2c_interf, i2c_addr, map_sel, sizeof(map_sel) );
i2c_give( i2c_interf );
}
Expand All @@ -145,7 +145,7 @@ adn_connect_map_t adn4604_out_status( void )
uint8_t cmd;
adn_connect_map_t stat_map = {0};

if ( i2c_take_by_chipid( CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t)10 ) ) {
if ( i2c_take_by_chipid( CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t) pdMS_TO_TICKS(10) ) ) {

/* Read all outputs status */
for ( i = 0; i < 8; i++ ) {
Expand All @@ -164,7 +164,7 @@ mmc_err adn4604_termination_ctl( uint8_t cfg )
uint8_t msg[2] = { ADN_TERMINATION_CTL_REG, (cfg & 0xF0) };
uint8_t tx_len = 0;

if ( i2c_take_by_chipid( CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t)10 ) ) {
if ( i2c_take_by_chipid( CHIP_ID_ADN, &i2c_addr, &i2c_interf, (TickType_t) pdMS_TO_TICKS(10) ) ) {
tx_len = xI2CMasterWrite( i2c_interf, i2c_addr, msg, sizeof(msg) );
i2c_give( i2c_interf );
}
Expand Down
2 changes: 1 addition & 1 deletion modules/eeprom_24xx64.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ size_t eeprom_24xx64_write( uint8_t id, uint16_t address, uint8_t *tx_data, size

/* Write the data */
tx_len += xI2CMasterWrite( i2c_interface, i2c_addr, &page_buf[0] , bytes_to_write+2 );
vTaskDelay(10);
vTaskDelay(pdMS_TO_TICKS(10));
tx_len -= 2; /* Remove the 2 page bytes from the count */
curr_addr += bytes_to_write;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/fpga_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void vTaskFPGA_COMM( void * Parameters )

/* Check if the FPGA has finished programming itself from the FLASH */
while (!gpio_read_pin( PIN_PORT(GPIO_FPGA_DONE_B), PIN_NUMBER(GPIO_FPGA_DONE_B))) {
vTaskDelay(FPGA_UPDATE_RATE);
vTaskDelay(pdMS_TO_TICKS(FPGA_UPDATE_RATE));
}

ssp_init( FPGA_SPI, FPGA_SPI_BITRATE, FPGA_SPI_FRAME_SIZE, SSP_MASTER, SSP_POLLING );
Expand Down Expand Up @@ -119,7 +119,7 @@ void vTaskFPGA_COMM( void * Parameters )
/* Data Valid byte - indicates that the bus is idle */
write_fpga_dword( 0x05, 0xAAAAAAAA );

vTaskDelay(FPGA_UPDATE_RATE);
vTaskDelay(pdMS_TO_TICKS(FPGA_UPDATE_RATE));
}
}

Expand Down
22 changes: 11 additions & 11 deletions modules/fru.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void fru_init( uint8_t id )
fru[id].fru_size = fru[id].cfg.build_f( &fru[id].buffer );

printf(" Writing FRU info to EEPROM... \n");
fru[id].cfg.write_f( fru[id].cfg.eeprom_id, 0x00, fru[id].buffer, fru[id].fru_size, 10 );
fru[id].cfg.write_f( fru[id].cfg.eeprom_id, 0x00, fru[id].buffer, fru[id].fru_size, pdMS_TO_TICKS(10) );
#endif

/* Read FRU info Common Header */
Expand Down Expand Up @@ -91,14 +91,14 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size )
if (fru[id].runtime) {
rec_len = fru[id].buffer[chassis_off+1];
} else {
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, chassis_off+1, &rec_len, 1, 10 );
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, chassis_off+1, &rec_len, 1, pdMS_TO_TICKS(10) );
}
rec_len *= 8;
if (rec_len > 0) {
if (fru[id].runtime) {
memcpy( &rec_buff[0], &fru[id].buffer[chassis_off], rec_len);
} else {
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, chassis_off, &rec_buff[0], rec_len, 10 );
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, chassis_off, &rec_buff[0], rec_len, pdMS_TO_TICKS(10) );
}
if ( !((calculate_chksum( &rec_buff[0], rec_len ) == 0) && rec_buff[0] == 1) ) {
/* Wrong checksum */
Expand All @@ -116,15 +116,15 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size )
if (fru[id].runtime) {
rec_len = fru[id].buffer[board_off+1];
} else {
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, board_off+1, &rec_len, 1, 10 );
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, board_off+1, &rec_len, 1, pdMS_TO_TICKS(10) );
}
rec_len *= 8;

if (rec_len > 0) {
if (fru[id].runtime) {
memcpy( &rec_buff[0], &fru[id].buffer[board_off], rec_len);
} else {
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, board_off, &rec_buff[0], rec_len, 10 );
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, board_off, &rec_buff[0], rec_len, pdMS_TO_TICKS(10) );
}
if ( !((calculate_chksum( &rec_buff[0], rec_len ) == 0) && rec_buff[0] == 1) ) {
/* Wrong checksum */
Expand All @@ -142,15 +142,15 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size )
if (fru[id].runtime) {
rec_len = fru[id].buffer[product_off+1];
} else {
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, product_off+1, &rec_len, 1, 10 );
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, product_off+1, &rec_len, 1, pdMS_TO_TICKS(10) );
}
rec_len *= 8;

if (rec_len > 0) {
if (fru[id].runtime) {
memcpy( &rec_buff[0], &fru[id].buffer[product_off], rec_len);
} else {
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, product_off, &rec_buff[0], rec_len, 10 );
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, product_off, &rec_buff[0], rec_len, pdMS_TO_TICKS(10) );
}
if ( !((calculate_chksum( &rec_buff[0], rec_len ) == 0 ) && rec_buff[0] == 1) ) {
/* Wrong checksum */
Expand All @@ -172,7 +172,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size )
if (fru[id].runtime) {
memcpy( &rec_buff[0], &fru[id].buffer[multirec_off], 5);
} else {
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, multirec_off, &rec_buff[0], 5, 10 );
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, multirec_off, &rec_buff[0], 5, pdMS_TO_TICKS(10) );
}
/* Calculate Multirecord header checksum */
if ( !(calculate_chksum( &rec_buff[0], 5 ) == 0) ) {
Expand All @@ -190,7 +190,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size )
if (fru[id].runtime) {
memcpy( &rec_buff[0], &fru[id].buffer[multirec_off], rec_len );
} else {
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, multirec_off, &rec_buff[0], rec_len, 10 );
fru[id].cfg.read_f( fru[id].cfg.eeprom_id, multirec_off, &rec_buff[0], rec_len, pdMS_TO_TICKS(10) );
}
if ( !((calculate_chksum( &rec_buff[0], rec_len ) == rec_chksum)) ) {
/* Wrong checksum */
Expand Down Expand Up @@ -243,7 +243,7 @@ size_t fru_read( uint8_t id, uint8_t *rx_buff, uint16_t offset, size_t len )
* Read EEPROM FRU info
*/
} else {
ret_val = fru[id].cfg.read_f( fru[id].cfg.eeprom_id, offset, rx_buff, len, 10 );
ret_val = fru[id].cfg.read_f( fru[id].cfg.eeprom_id, offset, rx_buff, len, pdMS_TO_TICKS(10) );
}
return ret_val;
}
Expand All @@ -255,7 +255,7 @@ size_t fru_write( uint8_t id, uint8_t *tx_buff, uint16_t offset, size_t len )
if ( id >= FRU_COUNT ) {
return 0;
}
ret_val = fru[id].cfg.write_f( fru[id].cfg.eeprom_id, offset, tx_buff, len, 10 );
ret_val = fru[id].cfg.write_f( fru[id].cfg.eeprom_id, offset, tx_buff, len, pdMS_TO_TICKS(10) );
return ret_val;
}

Expand Down
6 changes: 3 additions & 3 deletions modules/max116xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mmc_err max116xx_set_config(uint8_t chip_id, const max116xx_cfg* cfg)
setup_cfg[0] = 0x80 | cfg->ref_sel | cfg->clk_sel | cfg->pol_sel | 0b10;
setup_cfg[1] = cfg->scan_mode | (cfg->channel_sel << 1) | cfg->diff_mode;

if (i2c_take_by_chipid(chip_id, &i2c_addr, &i2c_id, (TickType_t) 10)) {
if (i2c_take_by_chipid(chip_id, &i2c_addr, &i2c_id, (TickType_t) pdMS_TO_TICKS(10))) {
tx_len = xI2CMasterWrite(i2c_id, i2c_addr, setup_cfg, sizeof(setup_cfg));
i2c_give(i2c_id);
} else {
Expand All @@ -69,7 +69,7 @@ mmc_err max116xx_read_uni(uint8_t chip_id, int16_t data[], uint8_t samples)
return MMC_INVALID_ARG_ERR;
}

if (i2c_take_by_chipid(chip_id, &i2c_addr, &i2c_id, (TickType_t) 10)) {
if (i2c_take_by_chipid(chip_id, &i2c_addr, &i2c_id, (TickType_t) pdMS_TO_TICKS(10))) {
rx_len = xI2CMasterRead(i2c_id, i2c_addr, (uint8_t*)data, (samples * 2));
i2c_give(i2c_id);
} else {
Expand Down Expand Up @@ -101,7 +101,7 @@ mmc_err max116xx_read_bip(uint8_t chip_id, int16_t data[], uint8_t samples)
return MMC_INVALID_ARG_ERR;
}

if (i2c_take_by_chipid(chip_id, &i2c_addr, &i2c_id, (TickType_t) 10)) {
if (i2c_take_by_chipid(chip_id, &i2c_addr, &i2c_id, (TickType_t) pdMS_TO_TICKS(10))) {
rx_len = xI2CMasterRead(i2c_id, i2c_addr, (uint8_t*)data, (samples * 2));
i2c_give(i2c_id);
} else {
Expand Down
8 changes: 4 additions & 4 deletions modules/mcp23016.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static mmc_err mcp23016_read_reg ( uint8_t reg, uint8_t *readout )
return MMC_INVALID_ARG_ERR;
}

if( i2c_take_by_chipid( CHIP_ID_MCP23016, &i2c_addr, &i2c_id, (TickType_t) 10) ) {
if( i2c_take_by_chipid( CHIP_ID_MCP23016, &i2c_addr, &i2c_id, (TickType_t) pdMS_TO_TICKS(10)) ) {
rx_len = xI2CMasterWriteRead(i2c_id, i2c_addr, &reg, 1, data, sizeof(data));
i2c_give(i2c_id);
} else {
Expand Down Expand Up @@ -90,7 +90,7 @@ static mmc_err mcp23016_write_reg (uint8_t reg, uint8_t data) {
cmd_data[0] = reg;
cmd_data[1] = data;

if( i2c_take_by_chipid( CHIP_ID_MCP23016, &i2c_addr, &i2c_id, (TickType_t) 10) ) {
if( i2c_take_by_chipid( CHIP_ID_MCP23016, &i2c_addr, &i2c_id, (TickType_t) pdMS_TO_TICKS(10)) ) {
tx_len = xI2CMasterWrite(i2c_id, i2c_addr, cmd_data, sizeof(cmd_data));
i2c_give(i2c_id);
} else {
Expand Down Expand Up @@ -176,7 +176,7 @@ mmc_err mcp23016_read_reg_pair ( uint8_t reg, uint16_t *readout ) {
uint8_t rx_len = 0;
uint8_t data[2] = {0};

if( i2c_take_by_chipid( CHIP_ID_MCP23016, &i2c_addr, &i2c_id, (TickType_t) 10) ) {
if( i2c_take_by_chipid( CHIP_ID_MCP23016, &i2c_addr, &i2c_id, (TickType_t) pdMS_TO_TICKS(10)) ) {
rx_len = xI2CMasterWriteRead(i2c_id, i2c_addr, &reg, 1, data, sizeof(data));
i2c_give(i2c_id);
} else {
Expand All @@ -203,7 +203,7 @@ mmc_err mcp23016_write_reg_pair ( uint8_t reg, uint16_t data )
};
uint8_t tx_len = 0;

if( i2c_take_by_chipid( CHIP_ID_MCP23016, &i2c_addr, &i2c_id, (TickType_t) 10) ) {
if( i2c_take_by_chipid( CHIP_ID_MCP23016, &i2c_addr, &i2c_id, (TickType_t) pdMS_TO_TICKS(10)) ) {
tx_len = xI2CMasterWrite(i2c_id, i2c_addr, cmd_data, sizeof(cmd_data));
i2c_give(i2c_id);
} else {
Expand Down
2 changes: 1 addition & 1 deletion modules/rtm.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void RTM_Manage( void * Parameters )
rtm_disable_payload_power();

for ( ;; ) {
vTaskDelay(500);
vTaskDelay(pdMS_TO_TICKS(500));

rtm_check_presence( &ps_new_state );

Expand Down
2 changes: 1 addition & 1 deletion modules/sensors/ina3221.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void vTaskINA3221( void *Parameters )
uint8_t channel;
TickType_t xLastWakeTime;
/* Task will run every 100ms */
const TickType_t xFrequency = INA3221_UPDATE_RATE / portTICK_PERIOD_MS;
const TickType_t xFrequency = pdMS_TO_TICKS(INA3221_UPDATE_RATE);

sensor_t * ina3221_sensor;
ina3221_data_t * data_ptr;
Expand Down
2 changes: 1 addition & 1 deletion modules/sensors/lm75.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TaskHandle_t vTaskLM75_Handle;

void vTaskLM75( void* Parameters )
{
const TickType_t xFrequency = LM75_UPDATE_RATE;
const TickType_t xFrequency = pdMS_TO_TICKS(LM75_UPDATE_RATE);

uint8_t i2c_addr, i2c_interf;
sensor_t * temp_sensor;
Expand Down
2 changes: 1 addition & 1 deletion modules/sensors/max6642.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ TaskHandle_t vTaskMAX6642_Handle;

void vTaskMAX6642( void* Parameters )
{
const TickType_t xFrequency = MAX6642_UPDATE_RATE;
const TickType_t xFrequency = pdMS_TO_TICKS(MAX6642_UPDATE_RATE);

sensor_t * temp_sensor;

Expand Down
2 changes: 1 addition & 1 deletion modules/watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void WatchdogTask (void * Parameters)
}
wdt_feed();
//printf(" Watchdog fed (again) \n ");
vTaskDelay(WATCHDOG_FEED_DELAY);
vTaskDelay(pdMS_TO_TICKS(WATCHDOG_FEED_DELAY));
}
}

Expand Down
4 changes: 2 additions & 2 deletions port/board/afc-v4/payload.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ uint8_t setDC_DC_ConvertersON(bool on)
for (uint8_t i = 0; i < (sizeof(power_pins) / sizeof(power_pins[0])); i++) {
pin = power_pins[i];
mcp23016_write_pin( ext_gpios[pin].port_num, ext_gpios[pin].pin_num, true );
vTaskDelay(10);
vTaskDelay(pdMS_TO_TICKS(10));
}
} else {
printf("Disable Power\n");

for (uint8_t i = (sizeof(power_pins) / sizeof(power_pins[0])); i > 0; i--) {
pin = power_pins[i];
mcp23016_write_pin( ext_gpios[pin].port_num, ext_gpios[pin].pin_num, false );
vTaskDelay(10);
vTaskDelay(pdMS_TO_TICKS(10));
}
}
return 1;
Expand Down

0 comments on commit b242cce

Please sign in to comment.