AM263Px MCU+ SDK: General types and functions

| AM263Px MCU+ SDK 26.00.00 |

Files | Data Structures | Functions | Typedefs | Enumerations | Macros
General types and functions
APIs for Unibase Binding

## Introduction

## Files
file | unibase.h
| unibase general global header

## Data Structures
struct | unibase_cb_set_t
| a set of callback functions to process platform specific tasks More...
struct | unibase_init_para_t
| initialization parameters More...

## Functions
int | unibase_init (unibase_init_para_t *ub_init_para)
| initialize unibase More...
void | unibase_close (void)
| claose unibase More...
void | ub_fatal (const char *mes1, const char *mes2)
| process a fatal error More...
bool | ub_fatalerror (void)
| return the fatal error status More...
static bool | ub_assert_fatal (bool cond, const char *mes1, const char *mes2)
| conditinal ub_fatal More...
uint64_t | ub_rt_gettime64 (void)
| get 64-bit REALTIME clock value More...
uint64_t | ub_mt_gettime64 (void)
| get 64-bit MONOTONIC clock value More...
uint64_t | ub_gptp_gettime64 (void)
| get 64-bit PTP clock value More...
int | ub_non_aligned_intsubst (void *srcval, void *destval, int vsize)
| copy non-aligned srcval to aligned destval for integer size from 1,2,4,8 bytes More...
int64_t | ub_int64_from_non_aligned (void *value, int vsize, int *error)
| evalute non-aligned value as integer, return result as int64_t number. More...
uint64_t | ub_uint64_from_non_aligned (void *value, int vsize, int *error)

## Typedefs
typedef int(* | ub_console_out) (bool flush, const char *str)
| console output function More...
typedef int(* | ub_debug_out) (bool flush, const char *str)
| debug output function More...
typedef void *(* | ub_mutex_init) (void)
| mutex initialization function More...
typedef int(* | ub_mutex_close) (void *mutex)
| mutex de-initialization function More...
typedef int(* | ub_mutex_lock) (void *mutex)
| mutex lock function More...
typedef int(* | ub_mutex_unlock) (void *mutex)
| mutex unlock function More...
typedef void(* | ub_fatal_func) (void)
| function to process a fatal error event More...
typedef uint64_t(* | ub_gettime64) (ub_clocktype_t ctype)
| 64-bit timestamp function More...

## Enumerations
enum | ub_clocktype_t { UB_CLOCK_DEFAULT =0, UB_CLOCK_REALTIME, UB_CLOCK_MONOTONIC, UB_CLOCK_GPTP }
| clock type which provides timestamp More...

## Macros
#define | CLOCK_MONOTONIC CLOCK_REALTIME
#define | UB_UNIBASE_LOGCAT 0

## Macro Definition Documentation

## ◆ CLOCK_MONOTONIC

#define CLOCK_MONOTONIC CLOCK_REALTIME

## ◆ UB_UNIBASE_LOGCAT

#define UB_UNIBASE_LOGCAT 0

## Typedef Documentation

## ◆ ub_console_out

typedef int(* ub_console_out) (bool flush, const char *str)

console output function

## ◆ ub_debug_out

typedef int(* ub_debug_out) (bool flush, const char *str)

debug output function

## ◆ ub_mutex_init

typedef void*(* ub_mutex_init) (void)

mutex initialization function

## ◆ ub_mutex_close

typedef int(* ub_mutex_close) (void *mutex)

mutex de-initialization function

## ◆ ub_mutex_lock

typedef int(* ub_mutex_lock) (void *mutex)

mutex lock function

## ◆ ub_mutex_unlock

typedef int(* ub_mutex_unlock) (void *mutex)

mutex unlock function

## ◆ ub_fatal_func

typedef void(* ub_fatal_func) (void)

function to process a fatal error event

## ◆ ub_gettime64

typedef uint64_t(* ub_gettime64) (ub_clocktype_t ctype)

64-bit timestamp function

## Enumeration Type Documentation

## ◆ ub_clocktype_t

enum ub_clocktype_t

clock type which provides timestamp

Enumerator
UB_CLOCK_DEFAULT |
UB_CLOCK_REALTIME |
UB_CLOCK_MONOTONIC |
UB_CLOCK_GPTP |

## Function Documentation

## ◆ unibase_init()

int unibase_init | ( | unibase_init_para_t * | ub_init_para | ) |

initialize unibase

Parameters

  ub_init_para | a set of callback functions to support platfrom specific functions, and a string to initialize logging functions

Returns
  0:succes, -1:error

Note
  unibase_init MUST be called at the beginning. Calling unibase_init again after the first call are all ignored. If mutex_init=Null, it runs in a single thread mode.

## ◆ unibase_close()

void unibase_close | ( | void |  | ) |

claose unibase

## ◆ ub_fatal()

void ub_fatal | ( | const char * | mes1,
|  | const char * | mes2
| ) |  |

process a fatal error

Parameters

  mes1 | printing message 1
  mes2 | printing message 2

Note
  'fatal' callback is called if it is registered. after this call 'ub_fatalerror()' returns true;

## ◆ ub_fatalerror()

bool ub_fatalerror | ( | void |  | ) |

return the fatal error status

## ◆ ub_assert_fatal()

static bool ub_assert_fatal | ( | bool | cond,
|  | const char * | mes1,
|  | const char * | mes2
| ) |  |
| inlinestatic

conditinal ub_fatal

## ◆ ub_rt_gettime64()

uint64_t ub_rt_gettime64 | ( | void |  | ) |

get 64-bit REALTIME clock value

Returns
  clock value

## ◆ ub_mt_gettime64()

uint64_t ub_mt_gettime64 | ( | void |  | ) |

get 64-bit MONOTONIC clock value

Returns
  clock value

## ◆ ub_gptp_gettime64()

uint64_t ub_gptp_gettime64 | ( | void |  | ) |

get 64-bit PTP clock value

Returns
  clock value

## ◆ ub_non_aligned_intsubst()

int ub_non_aligned_intsubst | ( | void * | srcval,
|  | void * | destval,
|  | int | vsize
| ) |  |

copy non-aligned srcval to aligned destval for integer size from 1,2,4,8 bytes

Parameters

  srcval | source data poiter
  destval | destination data poiter
  vsize | integer data size must be one of 1,2,4,8.

Returns
  0:okay, -1:error

## ◆ ub_int64_from_non_aligned()

int64_t ub_int64_from_non_aligned | ( | void * | value,
|  | int | vsize,
|  | int * | error
| ) |  |

evalute non-aligned value as integer, return result as int64_t number.

Parameters

  value | source data poiter
  vsize | integer data size must be one of 1,2,4,8.
  error | 0:okay, -1:error, no return when error=NULL.

Returns
  evaluated number, -1 with any errors.

## ◆ ub_uint64_from_non_aligned()

uint64_t ub_uint64_from_non_aligned | ( | void * | value,
|  | int | vsize,
|  | int * | error
| ) |  |