From b242ccef32890d4b6c69fbebcd1bed43d2bf1636 Mon Sep 17 00:00:00 2001 From: Gustavo de Souza dos Reis Date: Fri, 23 Feb 2024 10:26:34 -0300 Subject: [PATCH] Change delay counts from ticks to ms --- modules/adn4604.c | 14 +++++++------- modules/eeprom_24xx64.c | 2 +- modules/fpga_spi.c | 4 ++-- modules/fru.c | 22 +++++++++++----------- modules/max116xx.c | 6 +++--- modules/mcp23016.c | 8 ++++---- modules/rtm.c | 2 +- modules/sensors/ina3221.c | 2 +- modules/sensors/lm75.c | 2 +- modules/sensors/max6642.c | 2 +- modules/watchdog.c | 2 +- port/board/afc-v4/payload.c | 4 ++-- 12 files changed, 35 insertions(+), 35 deletions(-) diff --git a/modules/adn4604.c b/modules/adn4604.c index 395fa2cb7..1a780d440 100644 --- a/modules/adn4604.c +++ b/modules/adn4604.c @@ -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); } @@ -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); } @@ -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); } @@ -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); } @@ -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 ); } @@ -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++ ) { @@ -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 ); } diff --git a/modules/eeprom_24xx64.c b/modules/eeprom_24xx64.c index 74c4a9775..78f056ace 100644 --- a/modules/eeprom_24xx64.c +++ b/modules/eeprom_24xx64.c @@ -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; } diff --git a/modules/fpga_spi.c b/modules/fpga_spi.c index 0a852db95..aa8e405f3 100644 --- a/modules/fpga_spi.c +++ b/modules/fpga_spi.c @@ -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 ); @@ -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)); } } diff --git a/modules/fru.c b/modules/fru.c index 400789250..53b4a06e8 100644 --- a/modules/fru.c +++ b/modules/fru.c @@ -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 */ @@ -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 */ @@ -116,7 +116,7 @@ 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; @@ -124,7 +124,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size ) 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 */ @@ -142,7 +142,7 @@ 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; @@ -150,7 +150,7 @@ uint8_t fru_check_integrity( uint8_t id, size_t *fru_size ) 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 */ @@ -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) ) { @@ -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 */ @@ -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; } @@ -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; } diff --git a/modules/max116xx.c b/modules/max116xx.c index bb0ce19cd..35373fec9 100644 --- a/modules/max116xx.c +++ b/modules/max116xx.c @@ -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 { @@ -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 { @@ -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 { diff --git a/modules/mcp23016.c b/modules/mcp23016.c index 0253be804..6e02e9752 100644 --- a/modules/mcp23016.c +++ b/modules/mcp23016.c @@ -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, ®, 1, data, sizeof(data)); i2c_give(i2c_id); } else { @@ -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 { @@ -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, ®, 1, data, sizeof(data)); i2c_give(i2c_id); } else { @@ -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 { diff --git a/modules/rtm.c b/modules/rtm.c index 024789396..0b853cd51 100644 --- a/modules/rtm.c +++ b/modules/rtm.c @@ -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 ); diff --git a/modules/sensors/ina3221.c b/modules/sensors/ina3221.c index 8c7d39a0e..d71b96f62 100644 --- a/modules/sensors/ina3221.c +++ b/modules/sensors/ina3221.c @@ -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; diff --git a/modules/sensors/lm75.c b/modules/sensors/lm75.c index 04b8389ec..ca6936ae0 100644 --- a/modules/sensors/lm75.c +++ b/modules/sensors/lm75.c @@ -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; diff --git a/modules/sensors/max6642.c b/modules/sensors/max6642.c index b2bc9cb82..df37647ed 100644 --- a/modules/sensors/max6642.c +++ b/modules/sensors/max6642.c @@ -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; diff --git a/modules/watchdog.c b/modules/watchdog.c index f4c17b1e3..e5c6d3694 100644 --- a/modules/watchdog.c +++ b/modules/watchdog.c @@ -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)); } } diff --git a/port/board/afc-v4/payload.c b/port/board/afc-v4/payload.c index 16a29a8a0..08fc3aa1d 100644 --- a/port/board/afc-v4/payload.c +++ b/port/board/afc-v4/payload.c @@ -98,7 +98,7 @@ 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"); @@ -106,7 +106,7 @@ uint8_t setDC_DC_ConvertersON(bool on) 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;