mikroSDK Reference Manual
Conversions Library

Conversions library API Reference. More...

Functions list

void int8_to_hex (int8_t input, char *output)
 Converts int8_t to hex value. More...
 
void uint8_to_hex (uint8_t input, char *output)
 Converts uint8_t to hex value. More...
 
void uint16_to_hex (uint16_t input, char *output)
 Converts uint16_t to hex value. More...
 
void int16_to_hex (int16_t input, char *output)
 Converts int16_t to hex value. More...
 
void uint32_to_hex (uint32_t input, char *output)
 Converts uint32_t to hex value. More...
 
void int32_to_hex (int32_t input, char *output)
 Converts int32_t to hex value. More...
 
void uint64_to_hex (uint64_t input, char *output)
 Converts uint64_t to hex value. More...
 
void int64_to_hex (int64_t input, char *output)
 Converts int64_t to hex value. More...
 
void uint8_to_str (uint8_t input, char *output)
 Converts uint8_t to string. More...
 
void uint8_to_str_with_zeros (uint8_t input, char *output)
 Converts uint8_t to string with zeros. More...
 
void uint16_to_str (uint16_t input, char *output)
 Converts uint16_t to string. More...
 
void uint16_to_str_with_zeros (uint16_t input, char *output)
 Converts uint16_t to string with zeros. More...
 
void int8_to_str (int8_t input, char *output)
 Converts int8_t to string. More...
 
void int8_to_str_with_zeros (int8_t input, char *output)
 Converts int8_t to string with zeros. More...
 
void int16_to_str (int16_t input, char *output)
 Converts int16_t to string. More...
 
void int16_to_str_with_zeros (int16_t input, char *output)
 Converts int16_t to string with zeros. More...
 
void uint32_to_str (uint32_t input, char *output)
 Converts uint32_t to string. More...
 
void uint32_to_str_with_zeros (uint32_t input, char *output)
 Converts uint32_t to string with zeros. More...
 
void int32_to_str (int32_t input, char *output)
 Converts int32_t to string. More...
 
void int32_to_str_with_zeros (int32_t input, char *output)
 Converts int32_t to string with zeros. More...
 
void uint64_to_str_with_zeros (uint64_t input, char *output)
 Converts uint64_t to string with zeros. More...
 
void int64_to_str_with_zeros (int64_t input, char *output)
 Converts int64_t to string with zeros. More...
 
void uint64_to_str (uint64_t input, char *output)
 Converts uint64_t to string. More...
 
void int64_to_str (int64_t input, char *output)
 Converts int64_t to string. More...
 
uint8_t dec_to_bcd (uint8_t decnum)
 Converts decimal number to bcd value. More...
 
uint8_t bcd_to_dec (uint8_t bcdnum)
 Converts bcd value to decimal number. More...
 
uint16_t bcd_to_dec16 (uint16_t bcdnum)
 Converts bcd value to decimal number. More...
 
uint16_t dec_to_bcd16 (uint16_t decnum)
 Converts decimal number to bcd value. More...
 
char * r_trim (char *string)
 Trims the trailing spaces from an array given with *string. More...
 
char * l_trim (char *string)
 Trims the leading spaces from an array given with *string. More...
 
uint8_t float_to_str (float f_num, char *string)
 Converts floating point number into string. More...
 
uint8_t str_to_uint8 (char uint8_in[3])
 Converts string into uint8. More...
 
int8_t str_to_int8 (char int8_in[4])
 Converts string into int8. More...
 
int16_t str_to_int16 (char int16_in[6])
 Converts string into int16. More...
 
uint16_t str_to_uint16 (char uint16_in[5])
 Converts string into uint16. More...
 
uint32_t str_to_uint32 (char uint32_in[10])
 Converts string into uint32. More...
 
int32_t str_to_int32 (char int32_in[11])
 Converts string into int32. More...
 
int64_t str_to_int64 (char int64_in[20])
 Converts string into int64. More...
 
uint64_t str_to_uint64 (char uint64_in[20])
 Converts string into uint64. More...
 
float str_to_float (char data_str[20])
 Converts string into float. More...
 
uint8_t hex_to_uint8 (char hex_in[2])
 Converts hex into uint8. More...
 
uint16_t hex_to_uint16 (char hex_in[4])
 Converts hex into uint16. More...
 
uint32_t hex_to_uint32 (char hex_in[8])
 Converts hex into uint32. More...
 
uint64_t hex_to_uint64 (char hex_in[16])
 Converts hex into uint64. More...
 
int8_t hex_to_int8 (char hex_in[2])
 Converts hex into int8. More...
 
int16_t hex_to_int16 (char hex_in[4])
 Converts hex into int16. More...
 
int32_t hex_to_int32 (char hex_in[8])
 Converts hex into int32. More...
 
int64_t hex_to_int64 (char hex_in[16])
 Converts hex into int64. More...
 
uint8_t long_double_to_str (long double dnum, char *str)
 Converts a long double number into a string. More...
 

Detailed Description

The Conversions Library provides routines for converting numerals to strings and BCD/decimal conversions.

Function Documentation

◆ int8_to_hex()

void int8_to_hex ( int8_t  input,
char *  output 
)

Converts input number to a string containing the number's hexadecimal representation.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ uint8_to_hex()

void uint8_to_hex ( uint8_t  input,
char *  output 
)

Converts input number to a string containing the number's hexadecimal representation.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ uint16_to_hex()

void uint16_to_hex ( uint16_t  input,
char *  output 
)

Converts input number to a string containing the number's hexadecimal representation.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ int16_to_hex()

void int16_to_hex ( int16_t  input,
char *  output 
)

Converts input number to a string containing the number's hexadecimal representation.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ uint32_to_hex()

void uint32_to_hex ( uint32_t  input,
char *  output 
)

Converts input number to a string containing the number's hexadecimal representation.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ int32_to_hex()

void int32_to_hex ( int32_t  input,
char *  output 
)

Converts input number to a string containing the number's hexadecimal representation.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ uint64_to_hex()

void uint64_to_hex ( uint64_t  input,
char *  output 
)

Converts input number to a string containing the number's hexadecimal representation.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ int64_to_hex()

void int64_to_hex ( int64_t  input,
char *  output 
)

Converts input number to a string containing the number's hexadecimal representation.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ uint8_to_str()

void uint8_to_str ( uint8_t  input,
char *  output 
)

Converts input value to a string.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ uint8_to_str_with_zeros()

void uint8_to_str_with_zeros ( uint8_t  input,
char *  output 
)

Converts input value to a string.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ uint16_to_str()

void uint16_to_str ( uint16_t  input,
char *  output 
)

Converts input value to a string.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ uint16_to_str_with_zeros()

void uint16_to_str_with_zeros ( uint16_t  input,
char *  output 
)

Converts input value to a string. The output string is right justified and remaining positions on the left (if any) are filled with zeros.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ int8_to_str()

void int8_to_str ( int8_t  input,
char *  output 
)

Converts input value to a string.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ int8_to_str_with_zeros()

void int8_to_str_with_zeros ( int8_t  input,
char *  output 
)

Converts input value to a string. The output string is right justified and remaining positions on the left (if any) are filled with zeros.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ int16_to_str()

void int16_to_str ( int16_t  input,
char *  output 
)

Converts input value to a string.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ int16_to_str_with_zeros()

void int16_to_str_with_zeros ( int16_t  input,
char *  output 
)

Converts input value to a string. The output string is right justified and remaining positions on the left (if any) are filled with zeros.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ uint32_to_str()

void uint32_to_str ( uint32_t  input,
char *  output 
)

Converts input value to a string.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ uint32_to_str_with_zeros()

void uint32_to_str_with_zeros ( uint32_t  input,
char *  output 
)

Converts input value to a string. The output string is right justified and remaining positions on the left (if any) are filled with zeros.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ int32_to_str()

void int32_to_str ( int32_t  input,
char *  output 
)

Converts input value to a string.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ int32_to_str_with_zeros()

void int32_to_str_with_zeros ( int32_t  input,
char *  output 
)

Converts input value to a string. The output string is right justified and remaining positions on the left (if any) are filled with zeros.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ uint64_to_str_with_zeros()

void uint64_to_str_with_zeros ( uint64_t  input,
char *  output 
)

Converts input value to a string. The output string is right justified and remaining positions on the left (if any) are filled with zeros.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ int64_to_str_with_zeros()

void int64_to_str_with_zeros ( int64_t  input,
char *  output 
)

Converts input value to a string. The output string is right justified and remaining positions on the left (if any) are filled with zeros.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ uint64_to_str()

void uint64_to_str ( uint64_t  input,
char *  output 
)

Converts input value to a string.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ int64_to_str()

void int64_to_str ( int64_t  input,
char *  output 
)

Converts input value to a string.

Parameters
[in]inputValue to be converted.
[out]outputDestination string.
Returns
Nothing.

◆ dec_to_bcd()

uint8_t dec_to_bcd ( uint8_t  decnum)

Converts 8-bit unsigned decimal number to its appropriate BCD representation.

Parameters
[in]decnumValue to be converted.
Returns
Converted BCD value.

◆ bcd_to_dec()

uint8_t bcd_to_dec ( uint8_t  bcdnum)

Converts 8-bit BCD numeral to its decimal equivalent.

Parameters
[in]bcdnumValue to be converted.
Returns
Converted decimal value.

◆ bcd_to_dec16()

uint16_t bcd_to_dec16 ( uint16_t  bcdnum)

Converts 16-bit BCD numeral to its decimal equivalent.

Parameters
[in]bcdnumValue to be converted.
Returns
Converted decimal value.

◆ dec_to_bcd16()

uint16_t dec_to_bcd16 ( uint16_t  decnum)

Converts 16-bit unsigned decimal number to its appropriate BCD representation.

Parameters
[in]decnumValue to be converted.
Returns
Converted BCD value.

◆ r_trim()

char* r_trim ( char *  string)

Trims the trailing spaces from an array given with *string.

Parameters
[in]stringArray to be trimmed.
Returns
The function returns the address of the first string character.

◆ l_trim()

char* l_trim ( char *  string)

Trims the leading spaces from array an given with *string.

Parameters
[in]stringArray to be trimmed.
Returns
The function returns the address of the first string character.

◆ float_to_str()

uint8_t float_to_str ( float  f_num,
char *  string 
)

Converts a floating point number to a string. The output string is left justified and null terminated after the last digit.

Parameters
[in]f_numFloating point number to be converted.
[out]stringPointer to a string where converted number is stored.
Returns
  • 0 - if conversion is ok (fnum is not +INF, -INF or NaN)
  • 1 - if fnum is +INF
  • 2 - if fnum is -INF
  • 3 - if fnum is NaN

◆ str_to_uint8()

uint8_t str_to_uint8 ( char  uint8_in[3])

Converts input string into uint8.

Parameters
[in]uint8_inString to be converted.
Returns
Converted uint8 number.

◆ str_to_int8()

int8_t str_to_int8 ( char  int8_in[4])

Converts input string into int8.

Parameters
[in]int8_inString to be converted.
Returns
Converted int8 number.

◆ str_to_int16()

int16_t str_to_int16 ( char  int16_in[6])

Converts input string into int16.

Parameters
[in]int16_inString to be converted.
Returns
Converted int16 number.

◆ str_to_uint16()

uint16_t str_to_uint16 ( char  uint16_in[5])

Converts input string into uint16.

Parameters
[in]uint16_inString to be converted.
Returns
Converted uint16 number.

◆ str_to_uint32()

uint32_t str_to_uint32 ( char  uint32_in[10])

Converts input string into uint32.

Parameters
[in]uint32_inString to be converted.
Returns
Converted uint32 number.

◆ str_to_int32()

int32_t str_to_int32 ( char  int32_in[11])

Converts input string into int32.

Parameters
[in]int32_inString to be converted.
Returns
Converted int32 number.

◆ str_to_int64()

int64_t str_to_int64 ( char  int64_in[20])

Converts input string into int64.

Parameters
[in]int64_inString to be converted.
Returns
Converted int64 number.

◆ str_to_uint64()

uint64_t str_to_uint64 ( char  uint64_in[20])

Converts input string into uint64.

Parameters
[in]uint64_inString to be converted.
Returns
Converted uint64 number.

◆ str_to_float()

float str_to_float ( char  data_str[20])

Converts input string into float.

Parameters
[in]data_strString to be converted.
Returns
Converted float number.

◆ hex_to_uint8()

uint8_t hex_to_uint8 ( char  hex_in[2])

Converts a string containing the number's hexadecimal representation to uint8.

Parameters
[in]hex_inString to be converted.
Returns
Converted uint8 number.

◆ hex_to_uint16()

uint16_t hex_to_uint16 ( char  hex_in[4])

Converts a string containing the number's hexadecimal representation to uint16.

Parameters
[in]hex_inString to be converted.
Returns
Converted uint16 number.

◆ hex_to_uint32()

uint32_t hex_to_uint32 ( char  hex_in[8])

Converts a string containing the number's hexadecimal representation to uint32.

Parameters
[in]hex_inString to be converted.
Returns
Converted uint32 number.

◆ hex_to_uint64()

uint64_t hex_to_uint64 ( char  hex_in[16])

Converts a string containing the number's hexadecimal representation to uint64.

Parameters
[in]hex_inString to be converted.
Returns
Converted uint64 number.

◆ hex_to_int8()

int8_t hex_to_int8 ( char  hex_in[2])

Converts a string containing the number's hexadecimal representation to int8.

Parameters
[in]hex_inString to be converted.
Returns
Converted int8 number.

◆ hex_to_int16()

int16_t hex_to_int16 ( char  hex_in[4])

Converts a string containing the number's hexadecimal representation to int16.

Parameters
[in]hex_inString to be converted.
Returns
Converted int16 number.

◆ hex_to_int32()

int32_t hex_to_int32 ( char  hex_in[8])

Converts a string containing the number's hexadecimal representation to int32.

Parameters
[in]hex_inString to be converted.
Returns
Converted int32 number.

◆ hex_to_int64()

int64_t hex_to_int64 ( char  hex_in[16])

Converts a string containing the number's hexadecimal representation to int64.

Parameters
[in]hex_inString to be converted.
Returns
Converted int64 number.

◆ long_double_to_str()

uint8_t long_double_to_str ( long double  dnum,
char *  str 
)

Converts a long double number to a string. The output string is left justified and null terminated after the last digit.

Parameters
[in]dnumLong double number to be converted.
[out]strPointer to a string where converted number is stored.
Returns
  • 0 - if conversion is ok (fnum is not +INF, -INF or NaN)
  • 1 - if fnum is +INF
  • 2 - if fnum is -INF
  • 3 - if fnum is NaN