mikroSDK Reference Manual
conversions.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2023 MikroElektronika d.o.o.
4 ** Contact: https://www.mikroe.com/contact
5 **
6 ** This file is part of the mikroSDK package
7 **
8 ** Commercial License Usage
9 **
10 ** Licensees holding valid commercial NECTO compilers AI licenses may use this
11 ** file in accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The MikroElektronika Company.
14 ** For licensing terms and conditions see
15 ** https://www.mikroe.com/legal/software-license-agreement.
16 ** For further information use the contact form at
17 ** https://www.mikroe.com/contact.
18 **
19 **
20 ** GNU Lesser General Public License Usage
21 **
22 ** Alternatively, this file may be used for
23 ** non-commercial projects under the terms of the GNU Lesser
24 ** General Public License version 3 as published by the Free Software
25 ** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
26 **
27 ** The above copyright notice and this permission notice shall be
28 ** included in all copies or substantial portions of the Software.
29 **
30 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31 ** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
32 ** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
35 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
36 ** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 **
38 ****************************************************************************/
44 #ifndef _CONVERSIONS_H_
45 #define _CONVERSIONS_H_
46 
47 #ifdef __cplusplus
48 extern "C"{
49 #endif
50 
51 #include <stdint.h>
52 #include <stdbool.h>
53 #ifdef __GNUC__
54 #include <me_built_in.h>
55 #endif
56 
77 void int8_to_hex(int8_t input, char * output);
78 
86 void uint8_to_hex(uint8_t input, char * output);
87 
95 void uint16_to_hex(uint16_t input, char * output);
96 
104 void int16_to_hex(int16_t input, char * output);
105 
113 void uint32_to_hex(uint32_t input, char * output);
114 
122 void int32_to_hex(int32_t input, char * output);
123 
131 void uint64_to_hex(uint64_t input, char * output);
132 
140 void int64_to_hex(int64_t input, char * output);
141 
149 void uint8_to_str( uint8_t input, char * output );
150 
158 void uint8_to_str_with_zeros( uint8_t input, char * output );
159 
167 void uint16_to_str( uint16_t input, char * output );
168 
176 void uint16_to_str_with_zeros(uint16_t input, char * output);
177 
185 void int8_to_str(int8_t input, char * output);
186 
194 void int8_to_str_with_zeros(int8_t input, char * output);
195 
203 void int16_to_str(int16_t input, char * output);
204 
212 void int16_to_str_with_zeros( int16_t input, char * output );
213 
221 void uint32_to_str( uint32_t input, char * output );
222 
230 void uint32_to_str_with_zeros( uint32_t input, char * output );
231 
239 void int32_to_str( int32_t input, char * output );
240 
248 void int32_to_str_with_zeros( int32_t input, char * output );
249 
257 void uint64_to_str_with_zeros(uint64_t input, char * output);
258 
266 void int64_to_str_with_zeros( int64_t input, char * output );
267 
275 void uint64_to_str( uint64_t input, char * output );
276 
284 void int64_to_str( int64_t input, char * output );
285 
292 uint8_t dec_to_bcd(uint8_t decnum);
293 
300 uint8_t bcd_to_dec( uint8_t bcdnum );
301 
308 uint16_t bcd_to_dec16(uint16_t bcdnum);
309 
316 uint16_t dec_to_bcd16( uint16_t decnum );
317 
324 char * r_trim( char * string );
325 
332 char * l_trim( char * string );
333 
344 uint8_t float_to_str( float f_num, char * string);
345 
352 uint8_t str_to_uint8( char uint8_in[3] );
353 
360 int8_t str_to_int8( char int8_in[4] );
361 
368 int16_t str_to_int16( char int16_in[6] );
369 
376 uint16_t str_to_uint16( char uint16_in[5] );
377 
384 uint32_t str_to_uint32( char uint32_in[10] );
385 
392 int32_t str_to_int32( char int32_in[11] );
393 
400 int64_t str_to_int64( char int64_in[20] );
401 
408 uint64_t str_to_uint64( char uint64_in[20] );
409 
416 float str_to_float( char data_str[20] );
417 
424 uint8_t hex_to_uint8( char hex_in[2] );
425 
432 uint16_t hex_to_uint16( char hex_in[4] );
433 
440 uint32_t hex_to_uint32( char hex_in[8] );
441 
448 uint64_t hex_to_uint64( char hex_in[16] );
449 
456 int8_t hex_to_int8( char hex_in[2] );
457 
464 int16_t hex_to_int16( char hex_in[4] );
465 
472 int32_t hex_to_int32( char hex_in[8] );
473 
480 int64_t hex_to_int64( char hex_in[16] );
481 
492 uint8_t long_double_to_str(long double dnum, char * str);
493 
494 #endif // _CONVERSIONS_H_
495  // conversions // platform
498 
499 
500 // ------------------------------------------------------------------------- END
uint32_to_str_with_zeros
void uint32_to_str_with_zeros(uint32_t input, char *output)
Converts uint32_t to string with zeros.
uint32_to_hex
void uint32_to_hex(uint32_t input, char *output)
Converts uint32_t to hex value.
uint8_to_str
void uint8_to_str(uint8_t input, char *output)
Converts uint8_t to string.
int32_to_str
void int32_to_str(int32_t input, char *output)
Converts int32_t to string.
bcd_to_dec
uint8_t bcd_to_dec(uint8_t bcdnum)
Converts bcd value to decimal number.
hex_to_int16
int16_t hex_to_int16(char hex_in[4])
Converts hex into int16.
uint16_to_str
void uint16_to_str(uint16_t input, char *output)
Converts uint16_t to string.
dec_to_bcd
uint8_t dec_to_bcd(uint8_t decnum)
Converts decimal number to bcd value.
str_to_int64
int64_t str_to_int64(char int64_in[20])
Converts string into int64.
dec_to_bcd16
uint16_t dec_to_bcd16(uint16_t decnum)
Converts decimal number to bcd value.
str_to_float
float str_to_float(char data_str[20])
Converts string into float.
int16_to_str_with_zeros
void int16_to_str_with_zeros(int16_t input, char *output)
Converts int16_t to string with zeros.
uint32_to_str
void uint32_to_str(uint32_t input, char *output)
Converts uint32_t to string.
int16_to_hex
void int16_to_hex(int16_t input, char *output)
Converts int16_t to hex value.
str_to_int8
int8_t str_to_int8(char int8_in[4])
Converts string into int8.
uint8_to_str_with_zeros
void uint8_to_str_with_zeros(uint8_t input, char *output)
Converts uint8_t to string with zeros.
str_to_int16
int16_t str_to_int16(char int16_in[6])
Converts string into int16.
int8_to_str_with_zeros
void int8_to_str_with_zeros(int8_t input, char *output)
Converts int8_t to string with zeros.
hex_to_uint8
uint8_t hex_to_uint8(char hex_in[2])
Converts hex into uint8.
float_to_str
uint8_t float_to_str(float f_num, char *string)
Converts floating point number into string.
int32_to_str_with_zeros
void int32_to_str_with_zeros(int32_t input, char *output)
Converts int32_t to string with zeros.
str_to_int32
int32_t str_to_int32(char int32_in[11])
Converts string into int32.
hex_to_int32
int32_t hex_to_int32(char hex_in[8])
Converts hex into int32.
uint16_to_hex
void uint16_to_hex(uint16_t input, char *output)
Converts uint16_t to hex value.
l_trim
char * l_trim(char *string)
Trims the leading spaces from an array given with *string.
int8_to_str
void int8_to_str(int8_t input, char *output)
Converts int8_t to string.
int32_to_hex
void int32_to_hex(int32_t input, char *output)
Converts int32_t to hex value.
uint64_to_hex
void uint64_to_hex(uint64_t input, char *output)
Converts uint64_t to hex value.
int64_to_hex
void int64_to_hex(int64_t input, char *output)
Converts int64_t to hex value.
hex_to_uint32
uint32_t hex_to_uint32(char hex_in[8])
Converts hex into uint32.
uint64_to_str_with_zeros
void uint64_to_str_with_zeros(uint64_t input, char *output)
Converts uint64_t to string with zeros.
hex_to_int8
int8_t hex_to_int8(char hex_in[2])
Converts hex into int8.
int64_to_str
void int64_to_str(int64_t input, char *output)
Converts int64_t to string.
r_trim
char * r_trim(char *string)
Trims the trailing spaces from an array given with *string.
uint8_to_hex
void uint8_to_hex(uint8_t input, char *output)
Converts uint8_t to hex value.
str_to_uint64
uint64_t str_to_uint64(char uint64_in[20])
Converts string into uint64.
bcd_to_dec16
uint16_t bcd_to_dec16(uint16_t bcdnum)
Converts bcd value to decimal number.
hex_to_int64
int64_t hex_to_int64(char hex_in[16])
Converts hex into int64.
long_double_to_str
uint8_t long_double_to_str(long double dnum, char *str)
Converts a long double number into a string.
int8_to_hex
void int8_to_hex(int8_t input, char *output)
Converts int8_t to hex value.
str_to_uint8
uint8_t str_to_uint8(char uint8_in[3])
Converts string into uint8.
int16_to_str
void int16_to_str(int16_t input, char *output)
Converts int16_t to string.
uint64_to_str
void uint64_to_str(uint64_t input, char *output)
Converts uint64_t to string.
int64_to_str_with_zeros
void int64_to_str_with_zeros(int64_t input, char *output)
Converts int64_t to string with zeros.
str_to_uint16
uint16_t str_to_uint16(char uint16_in[5])
Converts string into uint16.
uint16_to_str_with_zeros
void uint16_to_str_with_zeros(uint16_t input, char *output)
Converts uint16_t to string with zeros.
hex_to_uint16
uint16_t hex_to_uint16(char hex_in[4])
Converts hex into uint16.
str_to_uint32
uint32_t str_to_uint32(char uint32_in[10])
Converts string into uint32.
hex_to_uint64
uint64_t hex_to_uint64(char hex_in[16])
Converts hex into uint64.