![]() |
no-OS
|
Utility functions header for input handling and data conversion in eval-powrms project. More...
#include <stdint.h>#include "common_data.h"Functions | |
| uint8_t | read_input () |
| Read and decode user input from UART. | |
| void | powrms_float_to_str (float var, char *text_buf, uint8_t int_digits, uint8_t float_digits, bool with_floating_comma) |
| Convert float value to string representation. | |
| void | powrms_int_to_str (int var, char *text_buf) |
| Convert integer value to string representation. | |
| int | powrms_watchdog_init (int msec) |
| Configure and initialize the watchdog timer. | |
| int | powrms_watchdog_reset (void) |
| Reset the watchdog timer to prevent system reset. | |
| int | powrms_watchdog_disable (void) |
| Disable the watchdog timer. | |
| int | powrms_eeprom_get_use_def_cal_data (int32_t *use_cal_data) |
| Initialize EEPROM and set first byte to 1 if it's 0. | |
| int | powrms_eeprom_set_use_def_cal_data (int32_t value) |
| Write a value to the first byte of the EEPROM. | |
| int | powrms_eeprom_get_temp_comp_data (int32_t *use_temp_comp) |
| Read temperature compensation flag from EEPROM. | |
| int | powrms_eeprom_set_temp_comp_data (int32_t value) |
| Write temperature compensation flag to EEPROM. | |
| int | powrms_eeprom_write_precision_array (const int32_t *precision_array) |
| Write precision array to EEPROM starting from the second byte. | |
| int | powrms_eeprom_read_precision_array (int32_t *precision_array) |
| Read precision array from EEPROM starting from the second byte. | |
| int | powrms_eeprom_write_precision_array_reverse (const int32_t *precision_array) |
| Write reverse precision array to EEPROM. | |
| int | powrms_eeprom_read_precision_array_reverse (int32_t *precision_array) |
| Read reverse precision array from EEPROM. | |
| int | powrms_eeprom_write_def_precision_array (const int32_t *precision_array) |
| Write default precision array to EEPROM. | |
| int | powrms_eeprom_read_def_precision_array (int32_t *precision_array) |
| Read default precision array from EEPROM. | |
| int | powrms_eeprom_write_def_precision_array_reverse (const int32_t *precision_array) |
| Write default reverse precision array to EEPROM. | |
| int | powrms_eeprom_read_def_precision_array_reverse (int32_t *precision_array) |
| Read default reverse precision array from EEPROM. | |
| void | powrms_get_firmware_version (char *version_buf) |
| Get firmware version string in format "major.minor.patch". | |
| int | powrms_eeprom_write_v_temp_comp_val (int32_t value) |
| Write voltage temperature compensation value to EEPROM. | |
| int | powrms_eeprom_read_v_temp_comp_val (int32_t *value) |
| Read voltage temperature compensation value from EEPROM. | |
| int | powrms_eeprom_write_def_v_temp_comp_val (int32_t value) |
| Write default voltage temperature compensation value to EEPROM. | |
| int | powrms_eeprom_read_def_v_temp_comp_val (int32_t *value) |
| Read default voltage temperature compensation value from EEPROM. | |
| int | powrms_eeprom_write_poly_5000MHz_coeffs (const double *coeffs) |
| Write polynomial calibration coefficients for 5000MHz to EEPROM. | |
| int | powrms_eeprom_read_poly_5000MHz_coeffs (double *coeffs) |
| Read polynomial calibration coefficients for 5000MHz from EEPROM. | |
| int | powrms_eeprom_write_def_poly_5000MHz_coeffs (const double *coeffs) |
| Write default polynomial calibration coefficients for 5000MHz to EEPROM. | |
| int | powrms_eeprom_read_def_poly_5000MHz_coeffs (double *coeffs) |
| Read default polynomial calibration coefficients for 5000MHz from EEPROM. | |
| int | powrms_eeprom_write_poly_5000MHz_reverse_coeffs (const double *coeffs) |
| Write polynomial calibration coefficients for 5000MHz reverse to EEPROM. | |
| int | powrms_eeprom_read_poly_5000MHz_reverse_coeffs (double *coeffs) |
| Read polynomial calibration coefficients for 5000MHz reverse from EEPROM. | |
| int | powrms_eeprom_write_def_poly_5000MHz_reverse_coeffs (const double *coeffs) |
| Write default polynomial calibration coefficients for 5000MHz reverse to EEPROM. | |
| int | powrms_eeprom_read_def_poly_5000MHz_reverse_coeffs (double *coeffs) |
| Read default polynomial calibration coefficients for 5000MHz reverse from EEPROM. | |
| int | powrms_init_memory_upon_boot () |
Utility functions header for input handling and data conversion in eval-powrms project.
Copyright 2025(c) Analog Devices, Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| #define MEM_DEF_POLY_5000MHZ_COEFFS_POZ (MEM_POLY_5000MHZ_COEFFS_POZ + MEM_POLY_5000MHZ_COEFFS_SIZE) |
| #define MEM_DEF_POLY_5000MHZ_COEFFS_SIZE 80 |
| #define MEM_DEF_POLY_5000MHZ_REVERSE_COEFFS_POZ (MEM_POLY_5000MHZ_REVERSE_COEFFS_POZ + MEM_POLY_5000MHZ_REVERSE_COEFFS_SIZE) |
| #define MEM_DEF_POLY_5000MHZ_REVERSE_COEFFS_SIZE 80 |
| #define MEM_DEF_PRECISION_ARRAY_POZ (MEM_V_TEMP_COMP_VAL_POZ + MEM_V_TEMP_COMP_VAL_SIZE) |
| #define MEM_DEF_PRECISION_ARRAY_REVERSE_POZ (MEM_PRECISION_ARRAY_REVERSE_POZ + MEM_PRECISION_ARRAY_REVERSE_SIZE) |
| #define MEM_DEF_PRECISION_ARRAY_REVERSE_SIZE 1232 |
| #define MEM_DEF_PRECISION_ARRAY_SIZE 1232 |
| #define MEM_DEF_TEMP_COMP_ARRAY_POZ (MEM_DEF_PRECISION_ARRAY_POZ + MEM_DEF_PRECISION_ARRAY_SIZE) |
| #define MEM_DEF_TEMP_COMP_ARRAY_SIZE 96 |
| #define MEM_DEF_V_TEMP_COMP_VAL_POZ (MEM_DEF_TEMP_COMP_ARRAY_POZ + MEM_DEF_TEMP_COMP_ARRAY_SIZE) |
| #define MEM_DEF_V_TEMP_COMP_VAL_SIZE 4 |
| #define MEM_POLY_5000MHZ_COEFFS_POZ (MEM_DEF_PRECISION_ARRAY_REVERSE_POZ + MEM_DEF_PRECISION_ARRAY_REVERSE_SIZE) |
| #define MEM_POLY_5000MHZ_COEFFS_SIZE 80 |
| #define MEM_POLY_5000MHZ_REVERSE_COEFFS_POZ (MEM_DEF_POLY_5000MHZ_COEFFS_POZ + MEM_DEF_POLY_5000MHZ_COEFFS_SIZE) |
| #define MEM_POLY_5000MHZ_REVERSE_COEFFS_SIZE 80 |
| #define MEM_PRECISION_ARRAY_POZ (MEM_TEMP_COMP_DATA_POZ + MEM_TEMP_COMP_DATA_LEN) |
| #define MEM_PRECISION_ARRAY_REVERSE_POZ (MEM_DEF_V_TEMP_COMP_VAL_POZ + MEM_DEF_V_TEMP_COMP_VAL_SIZE) |
| #define MEM_PRECISION_ARRAY_REVERSE_SIZE 1232 |
| #define MEM_PRECISION_ARRAY_SIZE 1232 |
| #define MEM_TEMP_COMP_ARRAY_POZ (MEM_PRECISION_ARRAY_POZ + MEM_PRECISION_ARRAY_SIZE) |
| #define MEM_TEMP_COMP_ARRAY_SIZE 96 |
| #define MEM_TEMP_COMP_DATA_LEN 1 |
| #define MEM_TEMP_COMP_DATA_POZ (MEM_USE_DEF_CALIB_DATA_POZ + MEM_USE_DEF_CALIB_DATA_LEN) |
| #define MEM_USE_DEF_CALIB_DATA_LEN 1 |
| #define MEM_USE_DEF_CALIB_DATA_POZ 0x0002 |
| #define MEM_V_TEMP_COMP_VAL_POZ (MEM_TEMP_COMP_ARRAY_POZ + MEM_TEMP_COMP_ARRAY_SIZE) |
| #define MEM_V_TEMP_COMP_VAL_SIZE 4 |
| int powrms_eeprom_get_temp_comp_data | ( | int32_t * | use_temp_comp | ) |
Read temperature compensation flag from EEPROM.
This function reads the temperature compensation flag from the EEPROM at the designated memory position. The EEPROM should already be initialized before calling this function.
| use_temp_comp | Pointer to store the temperature compensation flag value |
| int powrms_eeprom_get_use_def_cal_data | ( | int32_t * | use_cal_data | ) |
Initialize EEPROM and set first byte to 1 if it's 0.
This function reads the first byte of the EEPROM and if it's 0, sets it to 1. If it's already 1, leaves it as is. The EEPROM should already be initialized before calling this function.
| int powrms_eeprom_read_def_poly_5000MHz_coeffs | ( | double * | coeffs | ) |
Read default polynomial calibration coefficients for 5000MHz from EEPROM.
This function reads the default 10 polynomial calibration coefficients (double array) from the EEPROM at the designated memory position for factory data. The EEPROM should already be initialized before calling this function.
| coeffs | Pointer to array where 10 double default polynomial coefficients will be stored |
| int powrms_eeprom_read_def_poly_5000MHz_reverse_coeffs | ( | double * | coeffs | ) |
Read default polynomial calibration coefficients for 5000MHz reverse from EEPROM.
This function reads the default 10 polynomial calibration coefficients (double array) for reverse power from the EEPROM at the designated memory position for factory data. The EEPROM should already be initialized before calling this function.
| coeffs | Pointer to array where 10 double default polynomial coefficients will be stored |
| int powrms_eeprom_read_def_precision_array | ( | int32_t * | precision_array | ) |
Read default precision array from EEPROM.
This function reads the entire precision_values array (48 int32_t values) from the EEPROM starting from the default precision array memory position. The EEPROM should already be initialized before calling this function.
| precision_array | Pointer to the array where 48 int32_t precision values will be stored |
This function reads the precision array from the default precision array memory position using single-byte reads to avoid I2C bus blocking issues that can occur with large transfers. Each int32_t value is read byte by byte and reconstructed in little-endian format.
| int powrms_eeprom_read_def_precision_array_reverse | ( | int32_t * | precision_array | ) |
Read default reverse precision array from EEPROM.
This function reads the entire precision_values_reverse array (112 int32_t values) from the EEPROM starting from the default reverse precision array memory position. The EEPROM should already be initialized before calling this function.
| precision_array | Pointer to the array where 112 int32_t reverse precision values will be stored |
This function reads the precision array from the default reverse precision array memory position using single-byte reads to avoid I2C bus blocking issues that can occur with large transfers. Each int32_t value is read byte by byte and reconstructed in little-endian format.
| int powrms_eeprom_read_def_v_temp_comp_val | ( | int32_t * | value | ) |
Read default voltage temperature compensation value from EEPROM.
This function reads the default voltage temperature compensation value (int32_t) from the EEPROM at the designated memory position for default data. The EEPROM should already be initialized before calling this function.
| value | Pointer to store the default voltage temperature compensation value |
This function reads the default voltage temperature compensation value using single-byte reads to avoid I2C bus blocking issues that can occur with large transfers. The int32_t value is read byte by byte and reconstructed in little-endian format.
| int powrms_eeprom_read_poly_5000MHz_coeffs | ( | double * | coeffs | ) |
Read polynomial calibration coefficients for 5000MHz from EEPROM.
This function reads the 10 polynomial calibration coefficients (double array) from the EEPROM at the designated memory position. The EEPROM should already be initialized before calling this function.
| coeffs | Pointer to array where 10 double polynomial coefficients will be stored |
This function reads 10 polynomial coefficients (double array) from EEPROM. Uses single-byte reads to avoid I2C bus blocking.
| int powrms_eeprom_read_poly_5000MHz_reverse_coeffs | ( | double * | coeffs | ) |
Read polynomial calibration coefficients for 5000MHz reverse from EEPROM.
This function reads the 10 polynomial calibration coefficients (double array) for reverse power from the EEPROM at the designated memory position. The EEPROM should already be initialized before calling this function.
| coeffs | Pointer to array where 10 double polynomial coefficients will be stored |
This function reads 10 polynomial coefficients (double array) from EEPROM for reverse power. Uses single-byte reads to avoid I2C bus blocking.
| int powrms_eeprom_read_precision_array | ( | int32_t * | precision_array | ) |
Read precision array from EEPROM starting from the second byte.
This function reads the entire precision_values array (48 int32_t values) from the EEPROM starting from address 1 (second byte). The first byte is reserved for calibration flags. The EEPROM should already be initialized before calling this function.
| precision_array | Pointer to the array where 48 int32_t precision values will be stored |
This function reads the precision array using single-byte reads to avoid I2C bus blocking issues that can occur with large transfers. Each int32_t value is read byte by byte and reconstructed in little-endian format.
| int powrms_eeprom_read_precision_array_reverse | ( | int32_t * | precision_array | ) |
Read reverse precision array from EEPROM.
This function reads the entire precision_values_reverse array (112 int32_t values) from the EEPROM starting from the designated reverse precision array memory position. The EEPROM should already be initialized before calling this function.
| precision_array | Pointer to the array where 112 int32_t reverse precision values will be stored |
This function reads the precision array from the reverse precision array memory position using single-byte reads to avoid I2C bus blocking issues that can occur with large transfers. Each int32_t value is read byte by byte and reconstructed in little-endian format.
| int powrms_eeprom_read_v_temp_comp_val | ( | int32_t * | value | ) |
Read voltage temperature compensation value from EEPROM.
This function reads the voltage temperature compensation value (int32_t) from the EEPROM at the designated memory position for user configurable data. The EEPROM should already be initialized before calling this function.
| value | Pointer to store the voltage temperature compensation value |
This function reads the voltage temperature compensation value using single-byte reads to avoid I2C bus blocking issues that can occur with large transfers. The int32_t value is read byte by byte and reconstructed in little-endian format.
| int powrms_eeprom_set_temp_comp_data | ( | int32_t | value | ) |
Write temperature compensation flag to EEPROM.
This function writes the specified temperature compensation flag to the EEPROM at the designated memory position. The EEPROM should already be initialized before calling this function.
| value | The temperature compensation flag value to write (0 or 1) |
| int powrms_eeprom_set_use_def_cal_data | ( | int32_t | value | ) |
Write a value to the first byte of the EEPROM.
This function writes the specified value to the first byte (address 0) of the EEPROM. The EEPROM should already be initialized before calling this function.
| value | The value to write to the first byte |
| int powrms_eeprom_write_def_poly_5000MHz_coeffs | ( | const double * | coeffs | ) |
Write default polynomial calibration coefficients for 5000MHz to EEPROM.
This function writes the default 10 polynomial calibration coefficients (double array) to the EEPROM at the designated memory position for factory data. The EEPROM should already be initialized before calling this function.
| coeffs | Pointer to array of 10 double default polynomial coefficients |
| int powrms_eeprom_write_def_poly_5000MHz_reverse_coeffs | ( | const double * | coeffs | ) |
Write default polynomial calibration coefficients for 5000MHz reverse to EEPROM.
This function writes the default 10 polynomial calibration coefficients (double array) for reverse power to the EEPROM at the designated memory position for factory data. The EEPROM should already be initialized before calling this function.
| coeffs | Pointer to array of 10 double default polynomial coefficients |
| int powrms_eeprom_write_def_precision_array | ( | const int32_t * | precision_array | ) |
Write default precision array to EEPROM.
This function writes the entire precision_values array (48 int32_t values) to the EEPROM starting from the default precision array memory position. The EEPROM should already be initialized before calling this function.
| precision_array | Pointer to the array of 48 int32_t precision values |
This function writes the precision array to the default precision array memory position using single-byte writes to avoid I2C bus blocking issues that can occur with large transfers. Each int32_t value is broken down into bytes and written individually in little-endian format.
| int powrms_eeprom_write_def_precision_array_reverse | ( | const int32_t * | precision_array | ) |
Write default reverse precision array to EEPROM.
This function writes the entire precision_values_reverse array (112 int32_t values) to the EEPROM starting from the default reverse precision array memory position. The EEPROM should already be initialized before calling this function.
| precision_array | Pointer to the array of 112 int32_t reverse precision values |
This function writes the precision array to the default reverse precision array memory position using single-byte writes to avoid I2C bus blocking issues that can occur with large transfers. Each int32_t value is broken down into bytes and written individually in little-endian format.
| int powrms_eeprom_write_def_v_temp_comp_val | ( | int32_t | value | ) |
Write default voltage temperature compensation value to EEPROM.
This function writes the default voltage temperature compensation value (int32_t) to the EEPROM at the designated memory position for default data. The EEPROM should already be initialized before calling this function.
| value | The default voltage temperature compensation value to write |
This function writes the default voltage temperature compensation value using single-byte writes to avoid I2C bus blocking issues that can occur with large transfers. The int32_t value is broken down into bytes and written individually in little-endian format.
| int powrms_eeprom_write_poly_5000MHz_coeffs | ( | const double * | coeffs | ) |
Write polynomial calibration coefficients for 5000MHz to EEPROM.
This function writes the 10 polynomial calibration coefficients (double array) to the EEPROM at the designated memory position. The coefficients are: intercept, c_x, c_f, c_x2, c_xf, c_f2, c_x3, c_x2f, c_xf2, c_f3 The EEPROM should already be initialized before calling this function.
| coeffs | Pointer to array of 10 double polynomial coefficients |
This function writes 10 polynomial coefficients (double array) to EEPROM. Uses single-byte writes to avoid I2C bus blocking.
| int powrms_eeprom_write_poly_5000MHz_reverse_coeffs | ( | const double * | coeffs | ) |
Write polynomial calibration coefficients for 5000MHz reverse to EEPROM.
This function writes the 10 polynomial calibration coefficients (double array) for reverse power to the EEPROM at the designated memory position. The EEPROM should already be initialized before calling this function.
| coeffs | Pointer to array of 10 double polynomial coefficients |
This function writes 10 polynomial coefficients (double array) to EEPROM for reverse power. Uses single-byte writes to avoid I2C bus blocking.
| int powrms_eeprom_write_precision_array | ( | const int32_t * | precision_array | ) |
Write precision array to EEPROM starting from the second byte.
This function writes the entire precision_values array (48 int32_t values) to the EEPROM starting from address 1 (second byte). The first byte is reserved for calibration flags. The EEPROM should already be initialized before calling this function.
| precision_array | Pointer to the array of 48 int32_t precision values |
This function writes the precision array using single-byte writes to avoid I2C bus blocking issues that can occur with large transfers. Each int32_t value is broken down into bytes and written individually in little-endian format.
| int powrms_eeprom_write_precision_array_reverse | ( | const int32_t * | precision_array | ) |
Write reverse precision array to EEPROM.
This function writes the entire precision_values_reverse array (112 int32_t values) to the EEPROM starting from the designated reverse precision array memory position. The EEPROM should already be initialized before calling this function.
| precision_array | Pointer to the array of 112 int32_t reverse precision values |
This function writes the precision array to the reverse precision array memory position using single-byte writes to avoid I2C bus blocking issues that can occur with large transfers. Each int32_t value is broken down into bytes and written individually in little-endian format.
| int powrms_eeprom_write_v_temp_comp_val | ( | int32_t | value | ) |
Write voltage temperature compensation value to EEPROM.
This function writes the voltage temperature compensation value (int32_t) to the EEPROM at the designated memory position for user configurable data. The EEPROM should already be initialized before calling this function.
| value | The voltage temperature compensation value to write |
This function writes the voltage temperature compensation value using single-byte writes to avoid I2C bus blocking issues that can occur with large transfers. The int32_t value is broken down into bytes and written individually in little-endian format.
| void powrms_float_to_str | ( | float | var, |
| char * | text_buf, | ||
| uint8_t | int_digits, | ||
| uint8_t | float_digits, | ||
| bool | with_floating_comma ) |
Convert float value to string representation.
| var | Float value to convert |
| text_buf | Output buffer for string representation |
| int_digits | Number of integer digits |
| float_digits | Number of decimal digits |
| with_floating_comma | If true, include decimal point in output |
| void powrms_get_firmware_version | ( | char * | version_buf | ) |
Get firmware version string in format "major.minor.patch".
| version_buf | Buffer to store the version string (minimum 16 bytes) |
| int powrms_init_memory_upon_boot | ( | ) |
| void powrms_int_to_str | ( | int | var, |
| char * | text_buf ) |
Convert integer value to string representation.
| var | Integer value to convert |
| text_buf | Output buffer for string representation |
| int powrms_watchdog_disable | ( | void | ) |
Disable the watchdog timer.
| int powrms_watchdog_init | ( | int | msec | ) |
Configure and initialize the watchdog timer.
| msec | Timeout period in milliseconds |
| int powrms_watchdog_reset | ( | void | ) |
Reset the watchdog timer to prevent system reset.
| uint8_t read_input | ( | ) |
Read and decode user input from UART.