Utils#
Functions#
Convert uint16 to two byte array.
Convert uint32 to four byte array.
Convert a 2 byte array to uint16, first byte in array is LSB.
Convert a 4 byte array to uint32, first byte in array is LSB.
ASCII to HEX conversion.
Convert given ASCII HEX notation to decimal notation (used for MAC address).
Convert notation MAC address to a 6-byte HEX address.
Hex to ascii conversion.
Convert given 6-byte HEX address to ASCII Mac address.
Calculate CRC for a given byte and accumulate CRC.
Calculate 6-bit hash value for given MAC address.
Convert the given lower-case character to upper case.
Convert the given string to array.
Convert integer value into null-terminated string and stores it.
Convert string to an integer.
ASCII to hex conversion.
Convert given ASCII HEX notation to decimal notation (used for mac address).
Convert ASCII notation MAC address to a 6-byte HEX address.
Convert ASCII notation network address to 4-byte HEX address.
Convert IP address to reverse HEX format.
Converts the unsigned integer from network byte order to host byte order.
Convert ASCII to Decimal Value.
Reverses the given string.
converts the integer into a string.
Convert uint16 to two byte array.
Convert uint32 to four byte array.
Convert a 2 byte array to uint16, first byte in array is LSB.
Convert a 4 byte array to uint32, first byte in array is LSB.
Function Documentation#
rsi_uint16_to_2bytes#
void rsi_uint16_to_2bytes (uint8_t * dBuf, uint16_t val)
Convert uint16 to two byte array.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t * | [in] | dBuf | - Pointer to buffer to put the data in |
uint16_t | [in] | val | - Data to convert |
Returns
void
rsi_uint32_to_4bytes#
void rsi_uint32_to_4bytes (uint8_t * dBuf, uint32_t val)
Convert uint32 to four byte array.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t * | [in] | dBuf | - Pointer to buffer to put the data in |
uint32_t | [in] | val | - Data to convert |
Returns
void
rsi_bytes2R_to_uint16#
uint16_t rsi_bytes2R_to_uint16 (uint8_t * dBuf)
Convert a 2 byte array to uint16, first byte in array is LSB.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t * | [in] | dBuf | - Pointer to a buffer to get the data from |
Returns
Converted 16 bit data
rsi_bytes4R_to_uint32#
uint32_t rsi_bytes4R_to_uint32 (uint8_t * dBuf)
Convert a 4 byte array to uint32, first byte in array is LSB.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t * | [in] | dBuf | - Pointer to a buffer to get the data from |
Returns
Converted 32 bit data
rsi_ascii_hex2num#
int8_t rsi_ascii_hex2num (int8_t ascii_hex_in)
ASCII to HEX conversion.
Type | Direction | Argument Name | Description |
---|---|---|---|
int8_t | [in] | ascii_hex_in | - ASCII HEX input |
Returns
HEX number
rsi_char_hex2dec#
int8 rsi_char_hex2dec (int8_t * cBuf)
Convert given ASCII HEX notation to decimal notation (used for MAC address).
Type | Direction | Argument Name | Description |
---|---|---|---|
int8_t * | [in] | cBuf | - ASCII HEX notation string |
Returns
Integer Value
rsi_ascii_dev_address_to_6bytes_rev#
uint8_t * rsi_ascii_dev_address_to_6bytes_rev (uint8_t * hex_addr, int8_t * ascii_mac_address)
Convert notation MAC address to a 6-byte HEX address.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t * | [in] | hex_addr | - Source address to convert, must be a null terminated string. |
int8_t * | [out] | ascii_mac_address | - Converted HEX address. |
Returns
HEX address
hex_to_ascii#
int8_t hex_to_ascii (uint8_t hex_num)
Hex to ascii conversion.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | [in] | hex_num | - HEX number |
Returns
Ascii value for given HEX value
rsi_6byte_dev_address_to_ascii#
int8_t * rsi_6byte_dev_address_to_ascii (uint8_t * ascii_mac_address, uint8_t * hex_addr)
Convert given 6-byte HEX address to ASCII Mac address.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t * | [in] | ascii_mac_address | - HEX address input. |
uint8_t * | [out] | hex_addr | - Converted ASCII mac address is returned here. |
Returns
Converted ASCII mac address
lmac_crc8_c#
uint8_t lmac_crc8_c (uint8_t crc8_din, uint8_t crc8_state, uint8_t end)
Calculate CRC for a given byte and accumulate CRC.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | [in] | crc8_din | - CRC byte input |
uint8_t | [in] | crc8_state | - accumulated CRC |
uint8_t | [in] | end | - last byte CRC |
Returns
CRC value
multicast_mac_hash#
uint8_t multicast_mac_hash (uint8_t * mac)
Calculate 6-bit hash value for given MAC address.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t * | [in] | mac | - pointer to MAC address |
Returns
6-bit Hash value
convert_lower_case_to_upper_case#
uint8_t convert_lower_case_to_upper_case (uint8_t lwrcase)
Convert the given lower-case character to upper case.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | [in] | lwrcase | - Lower case character to convert |
Returns
Converted Upper case character
string2array#
void string2array (uint8_t * dst, uint8_t * src, uint32_t length)
Convert the given string to array.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t * | [in] | dst | - Pointer to destination array |
uint8_t * | [in] | src | - Pointer to source string |
uint32_t | [in] | length | - Length of the string |
Returns
Void
rsi_itoa#
uint8_t * rsi_itoa (uint32_t val, uint8_t * str)
Convert integer value into null-terminated string and stores it.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | val | - Value to be converted to a string |
uint8_t * | [in] | str | - Array in memory where to store the resulting null-terminated string |
Returns
Null-terminated string
rsi_atoi#
int32_t rsi_atoi (const int8_t * str)
Convert string to an integer.
Type | Direction | Argument Name | Description |
---|---|---|---|
const int8_t * | [in] | str | - String to be converted to integer |
Returns
Converted Integer
asciihex_2_num#
int8_t asciihex_2_num (int8_t ascii_hex_in)
ASCII to hex conversion.
Type | Direction | Argument Name | Description |
---|---|---|---|
int8_t | [in] | ascii_hex_in | - ASCII hex input |
Returns
HEX number
rsi_charhex_2_dec#
int8_t rsi_charhex_2_dec (int8_t * cBuf)
Convert given ASCII HEX notation to decimal notation (used for mac address).
Type | Direction | Argument Name | Description |
---|---|---|---|
int8_t * | [in] | cBuf | - ASCII HEX notation string. |
Returns
Integer value
rsi_ascii_mac_address_to_6bytes#
void rsi_ascii_mac_address_to_6bytes (uint8_t * hexAddr, int8_t * asciiMacAddress)
Convert ASCII notation MAC address to a 6-byte HEX address.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t * | [in] | hexAddr | - Source address to convert, must be a null terminated string. |
int8_t * | [out] | asciiMacAddress | - Converted HEX address is returned here. |
Returns
Void
rsi_ascii_dot_address_to_4bytes#
void rsi_ascii_dot_address_to_4bytes (uint8_t * hexAddr, int8_t * asciiDotAddress)
Convert ASCII notation network address to 4-byte HEX address.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t * | [in] | hexAddr | - Source address to convert, must be a null terminated string. |
int8_t * | [out] | asciiDotAddress | - Output value is passed back in the 4-byte HEX Address. |
Returns
Void
ip_to_reverse_hex#
uint64_t ip_to_reverse_hex (char * ip)
Convert IP address to reverse HEX format.
Type | Direction | Argument Name | Description |
---|---|---|---|
char * | [in] | ip | - IP address to convert. |
Returns
IP address in reverse HEX format
rsi_ntohl#
uint32_t rsi_ntohl (uint32_t a)
Converts the unsigned integer from network byte order to host byte order.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | a | - Unsigned integer to convert. |
Returns
Unsigned integer in host byte order
ascii_to_dec#
uint8_t ascii_to_dec (uint8_t * num)
Convert ASCII to Decimal Value.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t * | [in] | num | - ASCII input |
Returns
dec_val - value after conversion
rsi_reverse#
void rsi_reverse (char * str, int len)
Reverses the given string.
Type | Direction | Argument Name | Description |
---|---|---|---|
char * | [in] | str | - string to be reversed |
int | [in] | len | - the length of the given string |
Returns
void
rsi_intToStr#
int rsi_intToStr (int x, char str, int d)
converts the integer into a string.
Type | Direction | Argument Name | Description |
---|---|---|---|
int | [in] | x | - the string in which the result must be stored |
char | [in] | str | - the float number that needs to be converted into a string |
int | [in] | d | - the number of points after the decimal that needs to be printed, should be less than 6. |
Converts a floating-point/double number to a string.
Returns
the lenght of the string
Returns
void
rsi_ftoa#
void rsi_ftoa (char * res, float n, int afterpoint)
Type | Direction | Argument Name | Description |
---|---|---|---|
char * | N/A | res | |
float | N/A | n | |
int | N/A | afterpoint |
ROM_WL_rsi_uint16_to_2bytes#
void ROM_WL_rsi_uint16_to_2bytes (global_cb_t * global_cb_p, uint8_t * dBuf, uint16_t val)
Convert uint16 to two byte array.
Type | Direction | Argument Name | Description |
---|---|---|---|
global_cb_t * | [in] | global_cb_p | - pointer to the common buffer |
uint8_t * | [in] | dBuf | - pointer to buffer to put the data in |
uint16_t | [in] | val | - data to convert |
Returns
void
ROM_WL_rsi_uint32_to_4bytes#
void ROM_WL_rsi_uint32_to_4bytes (global_cb_t * global_cb_p, uint8_t * dBuf, uint32_t val)
Convert uint32 to four byte array.
Type | Direction | Argument Name | Description |
---|---|---|---|
global_cb_t * | [in] | global_cb_p | - pointer to the common buffer |
uint8_t * | [in] | dBuf | - pointer to the buffer to put the data in |
uint32_t | [in] | val | - data to convert |
Returns
void
ROM_WL_rsi_bytes2R_to_uint16#
uint16_t ROM_WL_rsi_bytes2R_to_uint16 (global_cb_t * global_cb_p, uint8_t * dBuf)
Convert a 2 byte array to uint16, first byte in array is LSB.
Type | Direction | Argument Name | Description |
---|---|---|---|
global_cb_t * | [in] | global_cb_p | - pointer to the common buffer |
uint8_t * | [in] | dBuf | - pointer to a buffer to get the data from |
Returns
Converted data
ROM_WL_rsi_bytes4R_to_uint32#
uint32_t ROM_WL_rsi_bytes4R_to_uint32 (global_cb_t * global_cb_p, uint8_t * dBuf)
Convert a 4 byte array to uint32, first byte in array is LSB.
Type | Direction | Argument Name | Description |
---|---|---|---|
global_cb_t * | [in] | global_cb_p | - pointer to the common buffer |
uint8_t * | [in] | dBuf | - pointer to buffer to get the data from |
Returns
Converted data