![]() |
no-OS
|
Utility functions for input handling and data conversion in EVAL-POWRMS project. More...
#include "powrms_utils.h"#include "powrms_gpios.h"#include "no_os_eeprom.h"#include "no_os_delay.h"#include "iio_powrms.h"#include <math.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_precision, uint8_t float_precision, bool is_settings_variable) |
| Convert float value to string representation. | |
| void | powrms_int_to_str (int var, char *text_buf) |
| Convert integer value to string representation. | |
| 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_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_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_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. | |
| 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. | |
| void | powrms_get_firmware_version (char *version_buf) |
| Get firmware version string in format "major.minor.patch". | |
| int | powrms_init_memory_upon_boot () |
Utility functions 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.
| 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 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 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_poly_5000MHz_coeffs | ( | double * | coeffs | ) |
Read polynomial calibration coefficients for 5000MHz from EEPROM.
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 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 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 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_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 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 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_poly_5000MHz_coeffs | ( | const double * | coeffs | ) |
Write polynomial calibration coefficients for 5000MHz to EEPROM.
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 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 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 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.
| 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 |
| uint8_t read_input | ( | ) |
Read and decode user input from UART.