ioLibrary for Cortex M series
util.h
Go to the documentation of this file.
1 
12  #ifndef _UTIL_H
13  #define _UTIL_H
14 
15  //#include "common/common.h"
16 
39  #define MEM_FREE(mem_p) do{ if(mem_p) { free(mem_p); mem_p = NULL; } }while(0)
40  #define BITSET(var_v, bit_v) (var_v |= bit_v)
41  #define BITCLR(var_v, bit_v) (var_v &= ~(bit_v))
42 
43  typedef void (*void_func)(void);
44  typedef void (*alarm_cbfunc)(int8_t arg);
45  typedef union long2char_t {
46  uint32_t byte4;
47  uint8_t byte1[4];
48  } long2char;
49 
50  typedef union short2char_t {
51  uint16_t s;
52  uint8_t c[2];
53  } short2char;
54 
55 
56  int8_t alarm_set(uint32_t time, alarm_cbfunc cb, int8_t arg);
57  int8_t alarm_del(alarm_cbfunc cb, int8_t arg);
58  int8_t alarm_chk(alarm_cbfunc cb, int8_t arg);
59  void alarm_run(void);
60  int8_t digit_length(int32_t dgt, int8_t base);
61  int32_t str_check(int (*method)(int), int8_t *str);
62  void print_dump(void *buf, uint16_t len);
63  uint16_t checksum(uint8_t * src, uint32_t len);
64  int32_t base64_decode(int8_t *text, uint8_t *dst, int32_t numBytes );
65  int32_t base64_encode(int8_t *text, int32_t numBytes, int8_t *encodedText);
66 
67  #endif //_UTIL_H
68 
69 
70