Common Support Functions: Definitions and Prototypes More...
Data Structures | |
struct | PACKET |
struct | T_ComDevice |
Macros | |
#define | COMMON_CODE_SECTION ".commontext" |
#define | PRAGMA(x) _Pragma(#x) |
#define | LOOP_COUNT_INFO(min, multiple) PRAGMA(MUST_ITERATE(min,,multiple)) |
#define | VAR_IN_SECTION(var, section) PRAGMA(DATA_SECTION(var, #section)) |
#define | PTR_IS_ALIGNED(ptr, pow2) _nassert(((uint32_t) (ptr) & (pow2)-1) == 0); |
#define | CSPRAGMA(f, s) PRAGMA(CODE_SECTION(f, s)) |
#define | _CPP_extern_open_ |
#define | _CPP_extern_close_ |
#define | NULL ((void *)UINT32_C(0)) |
#define | _CODE_ACCESS far |
#define | _DATA_ACCESS far |
#define | UNREFERENCED_PARAMETER(P) ((P)=(P)) \ |
#define | UNUSED_PARAMETER(P) ((void)(P)) \ |
#define | BUILD_YEAR |
#define | BUILD_DAY ((__DATE__ [4] == ' ' ? 0 : __DATE__ [4] - '0') * 10 + (__DATE__ [5] - '0')) \ |
#define | BUILD_MONTH |
#define | BUILD_HOUR ( (__TIME__ [0] - '0')*10 + (__TIME__ [1] - '0') ) |
#define | BUILD_MINUTE ( (__TIME__ [3] - '0')*10 + (__TIME__ [4] - '0') ) |
#define | BUILD_SECOND ( (__TIME__ [6] - '0')*10 + (__TIME__ [7] - '0') ) |
#define | MAX(a, b) ((a) > (b) ? (a) : (b)) |
#define | MIN(a, b) ((a) < (b) ? a : b) |
#define | BLOCK_OVERHEAD sizeof(PACKET) |
#define | BLOCK_OFFSET sizeof(PACKET) |
#define | SIZE_ACTUAL(x) ((x) & ~0x1) |
#define | SIZE_IS_USED(x) ((x) & 0x1) |
#define | HEAP_END(x, y) ((PACKET *)((char *)(x)+((y))-sizeof(PACKET))) |
#define | ASSERT_HEAP(i, h) if ( (i) < (h) ) prg_exit ("Insufficient heap"); |
#define | prg_exit(s) |
#define | tpFormatOutputFunc tpFormatOutputFunc |
#define | tpOutputFunc tpOutputFunc |
#define | tpWriteString tpWriteString |
#define | tpWriteChar tpWriteChar |
#define | tpReadChar tpReadChar |
#define | MessageLogFxn_type tpFormatOutputFunc |
#define | T_Handle T_Handle |
#define | COM_DEV_CCS 0 |
#define | COM_DEV_UART 1 |
#define | COM_DEV_USB 2 |
#define | COM_DEV_NET 3 |
#define | COM_DEV_TELNET 4 |
#define | COM_DEV_FILE 5 |
#define | COM_DEV_CDC 6 |
#define | T_ComDevice T_ComDevice |
#define | tpInputParser tpInputParser |
#define | BUFFEROVERFLOW_ERROR 1 |
Typedefs | |
typedef int(* | tpFormatOutputFunc) (const char *,...) |
typedef int(* | tpOutputFunc) (const char *,...) |
typedef void(* | tpWriteString) (const char *) |
typedef int32_t(* | tpWriteChar) (char) |
typedef int32_t(* | tpReadChar) (char *) |
typedef void * | T_Handle |
typedef int16_t(* | tpInputParser) (T_ComDevice *, char) |
Enumerations | |
enum | FUNC_RETURN { FR_OK = 0, FR_SKIPPED, FR_ERROR, FR_TIMEDOUT } |
Functions | |
void | config_std_output (void *output) |
configure standard output stream More... | |
void | PrintExitCode (void) |
Show a descriptive error message on exit. More... | |
void | AppInit (uint32_t dsp_clock) |
Initialize application. More... | |
void | AppCleanup (void) |
Disable interrupts, DMA, timer etc. More... | |
uint32_t | progress (uint32_t done, uint32_t left, uint32_t bad) |
char * | num2str (int32_t num, char *buffer, int32_t min, int hexmode) |
convert a 32bit integer to string More... | |
_CODE_ACCESS void | memmap (uint32_t heap_mem_size) |
show current dynamic memory allocation map More... | |
uint32_t | GetFreeHeapSize (void) |
determine free heap size More... | |
Variables | |
_DATA_ACCESS int | _SYSMEM_SIZE |
uint32_t | exit_code |
const char * | exit_string |
char * | exit_file |
uint32_t | exit_line |
char * | program_name |
const char * | FRMessages [] |
PACKET | _sys_memory |
_DATA_ACCESS int | _memory_size |
uint32_t | initial_heap_size |
_ _ _ __| | ___(_) ____ _ __ | |_ / _` | / __| |/ _` | '_ \| __| | (_| | _ \__ \ | (_| | | | | |_ \__,_|(_) ___/_|\__, |_| |_|\__| Signalprocessing |___/ Technology
#define COMMON_CODE_SECTION ".commontext" |
#define PRAGMA | ( | x | ) | _Pragma(#x) |
#define LOOP_COUNT_INFO | ( | min, | |
multiple | |||
) | PRAGMA(MUST_ITERATE(min,,multiple)) |
#define VAR_IN_SECTION | ( | var, | |
section | |||
) | PRAGMA(DATA_SECTION(var, #section)) |
#define PTR_IS_ALIGNED | ( | ptr, | |
pow2 | |||
) | _nassert(((uint32_t) (ptr) & (pow2)-1) == 0); |
#define CSPRAGMA | ( | f, | |
s | |||
) | PRAGMA(CODE_SECTION(f, s)) |
#define _CPP_extern_open_ |
#define _CPP_extern_close_ |
#define NULL ((void *)UINT32_C(0)) |
#define _CODE_ACCESS far |
#define _DATA_ACCESS far |
#define UNREFERENCED_PARAMETER | ( | P | ) | ((P)=(P)) \ |
suppresses warnings about params not used
#define UNUSED_PARAMETER | ( | P | ) | ((void)(P)) \ |
suppresses warnings about params not used
#define BUILD_YEAR |
build year macro. use to initialize timer variables or for descriptive outputs
#define BUILD_DAY ((__DATE__ [4] == ' ' ? 0 : __DATE__ [4] - '0') * 10 + (__DATE__ [5] - '0')) \ |
build day macro. use to initialize timer variables or for descriptive outputs
#define BUILD_MONTH |
build month macro. use to initialize timer variables or for descriptive outputs
#define BUILD_HOUR ( (__TIME__ [0] - '0')*10 + (__TIME__ [1] - '0') ) |
build hour macro. use to initialize timer variables or for descriptive outputs
#define BUILD_MINUTE ( (__TIME__ [3] - '0')*10 + (__TIME__ [4] - '0') ) |
build minute macro. use to initialize timer variables or for descriptive outputs
#define BUILD_SECOND ( (__TIME__ [6] - '0')*10 + (__TIME__ [7] - '0') ) |
build second macro. use to initialize timer variables or for descriptive outputs
#define MAX | ( | a, | |
b | |||
) | ((a) > (b) ? (a) : (b)) |
#define MIN | ( | a, | |
b | |||
) | ((a) < (b) ? a : b) |
#define BLOCK_OVERHEAD sizeof(PACKET) |
#define BLOCK_OFFSET sizeof(PACKET) |
#define SIZE_ACTUAL | ( | x | ) | ((x) & ~0x1) |
#define SIZE_IS_USED | ( | x | ) | ((x) & 0x1) |
HEAP check
#define prg_exit | ( | s | ) |
we use a macro rather than a function to log file and line
#define tpFormatOutputFunc tpFormatOutputFunc |
#define tpOutputFunc tpOutputFunc |
#define tpWriteString tpWriteString |
#define tpWriteChar tpWriteChar |
#define tpReadChar tpReadChar |
#define MessageLogFxn_type tpFormatOutputFunc |
#define COM_DEV_CCS 0 |
#define COM_DEV_UART 1 |
#define COM_DEV_USB 2 |
#define COM_DEV_NET 3 |
#define COM_DEV_TELNET 4 |
#define COM_DEV_FILE 5 |
#define COM_DEV_CDC 6 |
#define T_ComDevice T_ComDevice |
#define tpInputParser tpInputParser |
#define BUFFEROVERFLOW_ERROR 1 |
typedef int(* tpFormatOutputFunc) (const char *,...) |
Message log function. E.g. printf() or CPrintf()
typedef int(* tpOutputFunc) (const char *,...) |
typedef void(* tpWriteString) (const char *) |
typedef int32_t(* tpWriteChar) (char) |
typedef int32_t(* tpReadChar) (char *) |
typedef void* T_Handle |
a general handle to a peripheral
typedef int16_t(* tpInputParser) (T_ComDevice *, char) |
enum FUNC_RETURN |
void config_std_output | ( | void * | output | ) |
output | - new output stream |
void PrintExitCode | ( | void | ) |
- |
Print descriptive exit message. This function uses global pointer to exit string. Exit string is set by function prg_exit()
void AppInit | ( | uint32_t | dsp_clock | ) |
dsp_clock | [Hz] |
Application Initialization Code
Put all your initialization code into this central function. To make the CPrintf() function work as well in your initialization code called from here CPrintf_select_output() should be moved here too.
void AppCleanup | ( | void | ) |
- |
Application Cleanup Code at exit
This function is called on exit to cleanup running processes like interrupts and DMA, flush opened files, close handles
num | - number to convert |
*buffer | - pointer to string buffer |
min | - reserved number of digits in string, 0 means automatic |
hexmode | - 1: switch to hex mode |
_CODE_ACCESS void memmap | ( | uint32_t | heap_mem_size | ) |
This function is useful to show memory fragmentation and to detect memory leaks
heap_mem_size | - configured heap size |
uint32_t GetFreeHeapSize | ( | void | ) |
- |
This function determines the largest free heap block
- |
_DATA_ACCESS int _SYSMEM_SIZE |
exit_code |
Variable to hold exit code
exit codes => system error codes to signal fatal errors
const char* exit_string |
exit string => global variable set in prg_exit() to the current exit message
char* exit_file |
exit file => global variable set in prg_exit() to the current exit file
uint32_t exit_line |
exit line => global variable set in prg_exit() to the current exit line
char* program_name |
const char* FRMessages[] |
function return messages
PACKET _sys_memory |
_DATA_ACCESS int _memory_size |
uint32_t initial_heap_size |
configured heap size