/*****************************************************************************/ /* STDIO.H v15.4.0I15142 */ /* */ /* Copyright (c) 1993-2015 Texas Instruments Incorporated */ /* http://www.ti.com/ */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* */ /* Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in */ /* the documentation and/or other materials provided with the */ /* distribution. */ /* */ /* Neither the name of Texas Instruments Incorporated nor the names */ /* of its contributors may be used to endorse or promote products */ /* derived from this software without specific prior written */ /* permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /*****************************************************************************/ /*****************************************************************************/ /* linkage.h v15.4.0I15142 */ /* */ /* Copyright (c) 1998-2015 Texas Instruments Incorporated */ /* http://www.ti.com/ */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* */ /* Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in */ /* the documentation and/or other materials provided with the */ /* distribution. */ /* */ /* Neither the name of Texas Instruments Incorporated nor the names */ /* of its contributors may be used to endorse or promote products */ /* derived from this software without specific prior written */ /* permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /*****************************************************************************/ #pragma diag_push #pragma CHECK_MISRA("-19.4") /* macros required for implementation */ /* No modifiers are needed to access code or data */ /*--------------------------------------------------------------------------*/ /* Define _IDECL ==> how inline functions are declared */ /*--------------------------------------------------------------------------*/ #pragma diag_pop /*****************************************************************************/ /* stdarg.h v15.4.0I15142 */ /* */ /* Copyright (c) 1996-2015 Texas Instruments Incorporated */ /* http://www.ti.com/ */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* */ /* Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in */ /* the documentation and/or other materials provided with the */ /* distribution. */ /* */ /* Neither the name of Texas Instruments Incorporated nor the names */ /* of its contributors may be used to endorse or promote products */ /* derived from this software without specific prior written */ /* permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /*****************************************************************************/ #pragma diag_push #pragma CHECK_MISRA("-20.2") /* standard headers must define standard names */ #pragma CHECK_MISRA("-19.10") /* need types as macro arguments */ typedef struct __va_list { void * __ap; } va_list; #pragma diag_pop #pragma diag_push /* using declarations must occur outside header guard to support including both C and C++-wrapped version of header; see _CPP_STYLE_HEADER check */ /* this code is for C++ mode only and thus also not relevant for MISRA */ #pragma CHECK_MISRA("-19.15") #pragma diag_pop /*---------------------------------------------------------------------------*/ /* Attributes are only available in relaxed ANSI mode. */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* A header file conforming to ARM CLIB ABI (GENC-003539), should */ /* define _AEABI_PORTABLE when _AEABI_PORTABILITY_LEVEL is defined. */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* The macro definition that guards CLIB ABI (GENC-003539) requirements. */ /*---------------------------------------------------------------------------*/ /****************************************************************************/ /* TYPES THAT ANSI REQUIRES TO BE DEFINED */ /****************************************************************************/ typedef unsigned size_t; typedef struct { int fd; /* File descriptor */ unsigned char* buf; /* Pointer to start of buffer */ unsigned char* pos; /* Position in buffer */ unsigned char* bufend; /* Pointer to end of buffer */ unsigned char* buff_stop; /* Pointer to last read char in buffer */ unsigned int flags; /* File status flags (see below) */ } FILE; typedef long fpos_t; /****************************************************************************/ /* DEVICE AND STREAM RELATED MACROS */ /****************************************************************************/ /****************************************************************************/ /* MACROS THAT DEFINE AND USE FILE STATUS FLAGS */ /****************************************************************************/ /****************************************************************************/ /* MACROS THAT ANSI REQUIRES TO BE DEFINED */ /****************************************************************************/ /******** END OF ANSI MACROS ************************************************/ /****************************************************************************/ /* DEVICE AND STREAM RELATED DATA STRUCTURES AND MACROS */ /****************************************************************************/ extern FILE _ftable[10]; extern char __TI_tmpnams[10][16]; /****************************************************************************/ /* FUNCTION DEFINITIONS - ANSI */ /****************************************************************************/ /****************************************************************************/ /* OPERATIONS ON FILES */ /****************************************************************************/ extern int remove(const char *_file); extern int rename(const char *_old, const char *_new); extern FILE *tmpfile(void); extern char *tmpnam(char *_s); /****************************************************************************/ /* FILE ACCESS FUNCTIONS */ /****************************************************************************/ extern int fclose(FILE *_fp); extern FILE *fopen(const char *_fname, const char *_mode); extern FILE *freopen(const char *_fname, const char *_mode, register FILE *_fp); extern void setbuf(register FILE *_fp, char *_buf); extern int setvbuf(register FILE *_fp, register char *_buf, register int _type, register size_t _size); extern int fflush(register FILE *_fp); /****************************************************************************/ /* FORMATTED INPUT/OUTPUT FUNCTIONS */ /****************************************************************************/ extern int fprintf(FILE *_fp, const char *_format, ...) __attribute__((__format__ (__printf__, 2, 3))); extern int fscanf(FILE *_fp, const char *_fmt, ...) __attribute__((__format__ (__scanf__, 2, 3))); extern int printf(const char *_format, ...) __attribute__((__format__ (__printf__, 1, 2))); extern int scanf(const char *_fmt, ...) __attribute__((__format__ (__scanf__, 1, 2))); extern int sprintf(char *_string, const char *_format, ...) __attribute__((__format__ (__printf__, 2, 3))); extern int snprintf(char *_string, size_t _n, const char *_format, ...) __attribute__((__format__ (__printf__, 3, 4))); extern int sscanf(const char *_str, const char *_fmt, ...) __attribute__((__format__ (__scanf__, 2, 3))); extern int vfprintf(FILE *_fp, const char *_format, va_list _ap) __attribute__((__format__ (__printf__, 2, 0))); extern int vfscanf(FILE *_fp, const char *_fmt, va_list _ap) __attribute__((__format__ (__scanf__, 2, 0))); extern int vprintf(const char *_format, va_list _ap) __attribute__((__format__ (__printf__, 1, 0))); extern int vscanf(const char *_format, va_list _ap) __attribute__((__format__ (__scanf__, 1, 0))); extern int vsprintf(char *_string, const char *_format, va_list _ap) __attribute__((__format__ (__printf__, 2, 0))); extern int vsnprintf(char *_string, size_t _n, const char *_format, va_list _ap) __attribute__((__format__ (__printf__, 3, 0))); extern int vsscanf(const char *_str, const char *_fmt, va_list _ap) __attribute__((__format__ (__scanf__, 2, 0))); /****************************************************************************/ /* CHARACTER INPUT/OUTPUT FUNCTIONS */ /****************************************************************************/ extern int fgetc(register FILE *_fp); extern char *fgets(char *_ptr, register int _size, register FILE *_fp); extern int fputc(int _c, register FILE *_fp); extern int fputs(const char *_ptr, register FILE *_fp); extern int getc(FILE *_p); extern int getchar(void); extern char *gets(char *_ptr); extern int putc(int _x, FILE *_fp); extern int putchar(int _x); extern int puts(const char *_ptr); extern int ungetc(int _c, register FILE *_fp); /****************************************************************************/ /* DIRECT INPUT/OUTPUT FUNCTIONS */ /****************************************************************************/ extern size_t fread(void *_ptr, size_t _size, size_t _count, FILE *_fp); extern size_t fwrite(const void *_ptr, size_t _size, size_t _count, register FILE *_fp); /****************************************************************************/ /* FILE POSITIONING FUNCTIONS */ /****************************************************************************/ extern int fgetpos(FILE *_fp, fpos_t *_pos); extern int fseek(register FILE *_fp, long _offset, int _ptrname); extern int fsetpos(FILE *_fp, const fpos_t *_pos); extern long ftell(FILE *_fp); extern void rewind(register FILE *_fp); /****************************************************************************/ /* ERROR-HANDLING FUNCTIONS */ /****************************************************************************/ extern void clearerr(FILE *_fp); extern int feof(FILE *_fp); extern int ferror(FILE *_fp); extern void perror(const char *_s); /*----------------------------------------------------------------------- / Low level disk interface modlue include file R0.04a (C)ChaN, 2007 /-----------------------------------------------------------------------*/ typedef signed long INT; typedef unsigned long UINT; /* These types are assumed as 8-bit integer */ typedef signed char CHAR; typedef unsigned char UCHAR; typedef unsigned char BYTE; /* These types are assumed as 16-bit integer */ typedef signed short SHORT; typedef unsigned short USHORT; typedef unsigned short WORD; typedef unsigned short WCHAR; /* These types are assumed as 32-bit integer */ typedef signed int LONG; typedef unsigned int ULONG; typedef unsigned int DWORD; /* Boolean type */ //typedef enum {FALSE = 0, TRUE} BOOL; /*---------------------------------------------------------------------------/ / FatFs - FAT file system module include file R0.10b (C)ChaN, 2014 /----------------------------------------------------------------------------/ / FatFs module is a generic FAT file system module for small embedded systems. / This is a free software that opened for education, research and commercial / developments under license policy of following terms. / / Copyright (C) 2014, ChaN, all right reserved. / / * The FatFs module is a free software and there is NO WARRANTY. / * No restriction on use. You can use, modify and redistribute it for / personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY. / * Redistributions of source code must retain the above copyright notice. / /----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------/ / FatFs - FAT file system module configuration file R0.10b (C)ChaN, 2014 /---------------------------------------------------------------------------*/ /* ************************************************************************************************************************ * uC/OS-III * The Real-Time Kernel * * (c) Copyright 2009-2011; Micrium, Inc.; Weston, FL * All rights reserved. Protected by international copyright laws. * * File : OS.H * By : JJL * Version : V3.02.00 * * LICENSING TERMS: * --------------- * uC/OS-III is provided in source form for FREE short-term evaluation, for educational use or * for peaceful research. If you plan or intend to use uC/OS-III in a commercial application/ * product then, you need to contact Micrium to properly license uC/OS-III for its use in your * application/product. We provide ALL the source code for your convenience and to help you * experience uC/OS-III. The fact that the source is provided does NOT mean that you can use * it commercially without paying a licensing fee. * * Knowledge of the source code may NOT be used to develop a similar product. * * Please help us continue to provide the embedded community with the finest software available. * Your honesty is greatly appreciated. * * You can contact us at www.micrium.com, or by phone at +1 (954) 217-2036. ************************************************************************************************************************ * Note(s) : (1) Assumes the following versions (or more recent) of software modules are included in the project build: * * (a) uC/LIB V1.26 * (b) uC/CPU V1.25 ************************************************************************************************************************ */ /* ************************************************************************************************************************ * uC/OS-III VERSION NUMBER ************************************************************************************************************************ */ /* ************************************************************************************************************************ * INCLUDE HEADER FILES ************************************************************************************************************************ */ /* ************************************************************************************************************************ * uC/OS-III * The Real-Time Kernel * * (c) Copyright 2009-2012; Micrium, Inc.; Weston, FL * All rights reserved. Protected by international copyright laws. * * CONFIGURATION FILE * * File : OS_CFG.H * By : JJL * Version : V3.03.00 * * LICENSING TERMS: * --------------- * uC/OS-III is provided in source form for FREE short-term evaluation, for educational use or * for peaceful research. If you plan or intend to use uC/OS-III in a commercial application/ * product then, you need to contact Micrium to properly license uC/OS-III for its use in your * application/product. We provide ALL the source code for your convenience and to help you * experience uC/OS-III. The fact that the source is provided does NOT mean that you can use * it commercially without paying a licensing fee. * * Knowledge of the source code may NOT be used to develop a similar product. * * Please help us continue to provide the embedded community with the finest software available. * Your honesty is greatly appreciated. * * You can contact us at www.micrium.com, or by phone at +1 (954) 217-2036. ************************************************************************************************************************ */ /* ---------------------------- MISCELLANEOUS -------------------------- */ /* ----------------------------- EVENT FLAGS --------------------------- */ /* -------------------------- MEMORY MANAGEMENT ------------------------ */ /* --------------------- MUTUAL EXCLUSION SEMAPHORES ------------------- */ /* --------------------------- MESSAGE QUEUES -------------------------- */ /* ----------------------------- SEMAPHORES ---------------------------- */ /* -------------------------- TASK MANAGEMENT -------------------------- */ /* -------------------------- TIME MANAGEMENT -------------------------- */ /* ------------------- TASK LOCAL STORAGE MANAGEMENT ------------------- */ /* ------------------------- TIMER MANAGEMENT -------------------------- */ /* ********************************************************************************************************* * uC/CPU * CPU CONFIGURATION & PORT LAYER * * (c) Copyright 2004-2011; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/CPU is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * CPU PORT FILE * * ARM Cortex-A8 * CODE COMPOSER STUDIO (CCS) * * Filename : cpu.h * Version : V1.28.00.00 * Programmer(s) : FT ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE ********************************************************************************************************* */ /* ********************************************************************************************************* * CPU INCLUDE FILES * * Note(s) : (1) The following CPU files are located in the following directories : * * (a) \\cpu_cfg.h * * (b) \\cpu_def.h * * (c) \\\\cpu*.* * * where * directory path for Your Product's Application * directory path for common CPU-compiler software * directory name for specific CPU * directory name for specific compiler * * (2) Compiler MUST be configured to include the '\\' directory the * specific CPU-compiler directory, & '\\' as additional include * path directories. * * (3) Since NO custom library modules are included, 'cpu.h' may ONLY use configurations from * CPU configuration file 'cpu_cfg.h' that do NOT reference any custom library definitions. * * In other words, 'cpu.h' may use 'cpu_cfg.h' configurations that are #define'd to numeric * constants or to NULL (i.e. NULL-valued #define's); but may NOT use configurations to * custom library #define's (e.g. DEF_DISABLED or DEF_ENABLED). ********************************************************************************************************* */ /* ********************************************************************************************************* * uC/CPU * CPU CONFIGURATION & PORT LAYER * * (c) Copyright 2004-2011; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/CPU is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * CPU CONFIGURATION DEFINES * * Filename : cpu_def.h * Version : V1.29.01 * Programmer(s) : ITJ ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE * * Note(s) : (1) This CPU definition header file is protected from multiple pre-processor inclusion * through use of the CPU definition module present pre-processor macro definition. ********************************************************************************************************* */ /* ********************************************************************************************************* * CORE CPU MODULE VERSION NUMBER * * Note(s) : (1) (a) The core CPU module software version is denoted as follows : * * Vx.yy.zz * * where * V denotes 'Version' label * x denotes major software version revision number * yy denotes minor software version revision number * zz denotes sub-minor software version revision number * * (b) The software version label #define is formatted as follows : * * ver = x.yyzz * 100 * 100 * * where * ver denotes software version number scaled as an integer value * x.yyzz denotes software version number, where the unscaled integer * portion denotes the major version number & the unscaled * fractional portion denotes the (concatenated) minor * version numbers ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * CPU WORD CONFIGURATION * * Note(s) : (1) Configure CPU_CFG_ADDR_SIZE & CPU_CFG_DATA_SIZE in 'cpu.h' with CPU's word sizes : * * CPU_WORD_SIZE_08 8-bit word size * CPU_WORD_SIZE_16 16-bit word size * CPU_WORD_SIZE_32 32-bit word size * CPU_WORD_SIZE_64 64-bit word size * * (2) Configure CPU_CFG_ENDIAN_TYPE in 'cpu.h' with CPU's data-word-memory order : * * (a) CPU_ENDIAN_TYPE_BIG Big- endian word order (CPU words' most significant * octet @ lowest memory address) * (b) CPU_ENDIAN_TYPE_LITTLE Little-endian word order (CPU words' least significant * octet @ lowest memory address) ********************************************************************************************************* */ /* ---------------------- CPU WORD SIZE ----------------------- */ /* ------------------ CPU WORD-ENDIAN ORDER ------------------- */ /* ********************************************************************************************************* * CPU STACK CONFIGURATION * * Note(s) : (1) Configure CPU_CFG_STK_GROWTH in 'cpu.h' with CPU's stack growth order : * * (a) CPU_STK_GROWTH_LO_TO_HI CPU stack pointer increments to the next higher stack * memory address after data is pushed onto the stack * (b) CPU_STK_GROWTH_HI_TO_LO CPU stack pointer decrements to the next lower stack * memory address after data is pushed onto the stack ********************************************************************************************************* */ /* ------------------ CPU STACK GROWTH ORDER ------------------ */ /*$PAGE*/ /* ********************************************************************************************************* * CRITICAL SECTION CONFIGURATION * * Note(s) : (1) Configure CPU_CFG_CRITICAL_METHOD with CPU's/compiler's critical section method : * * Enter/Exit critical sections by ... * * CPU_CRITICAL_METHOD_INT_DIS_EN Disable/Enable interrupts * CPU_CRITICAL_METHOD_STATUS_STK Push/Pop interrupt status onto stack * CPU_CRITICAL_METHOD_STATUS_LOCAL Save/Restore interrupt status to local variable * * (a) CPU_CRITICAL_METHOD_INT_DIS_EN is NOT a preferred method since it does NOT support * multiple levels of interrupts. However, with some CPUs/compilers, this is the only * available method. * * (b) CPU_CRITICAL_METHOD_STATUS_STK is one preferred method since it supports multiple * levels of interrupts. However, this method assumes that the compiler provides C-level * &/or assembly-level functionality for the following : * * ENTER CRITICAL SECTION : * (1) Push/save interrupt status onto a local stack * (2) Disable interrupts * * EXIT CRITICAL SECTION : * (3) Pop/restore interrupt status from a local stack * * (c) CPU_CRITICAL_METHOD_STATUS_LOCAL is one preferred method since it supports multiple * levels of interrupts. However, this method assumes that the compiler provides C-level * &/or assembly-level functionality for the following : * * ENTER CRITICAL SECTION : * (1) Save interrupt status into a local variable * (2) Disable interrupts * * EXIT CRITICAL SECTION : * (3) Restore interrupt status from a local variable * * (2) Critical section macro's most likely require inline assembly. If the compiler does NOT * allow inline assembly in C source files, critical section macro's MUST call an assembly * subroutine defined in a 'cpu_a.asm' file located in the following software directory : * * \\\* * where * directory path for common CPU-compiler software * directory name for specific CPU * directory name for specific compiler * * (3) (a) To save/restore interrupt status, a local variable 'cpu_sr' of type 'CPU_SR' MAY need * to be declared (e.g. if 'CPU_CRITICAL_METHOD_STATUS_LOCAL' method is configured). * * (1) 'cpu_sr' local variable SHOULD be declared via the CPU_SR_ALLOC() macro which, * if used, MUST be declared following ALL other local variables (see any 'cpu.h * CRITICAL SECTION CONFIGURATION Note #3a1'). * * Example : * * void Fnct (void) * { * CPU_INT08U val_08; * CPU_INT16U val_16; * CPU_INT32U val_32; * CPU_SR_ALLOC(); MUST be declared after ALL other local variables * : * : * } * * (b) Configure 'CPU_SR' data type with the appropriate-sized CPU data type large enough to * completely store the CPU's/compiler's status word. ********************************************************************************************************* */ /* --------------- CPU CRITICAL SECTION METHODS --------------- */ /*$PAGE*/ /* ********************************************************************************************************* * MODULE END * * Note(s) : (1) See 'cpu_def.h MODULE'. ********************************************************************************************************* */ /* ********************************************************************************************************* * uC/CPU * CPU CONFIGURATION & PORT LAYER * * (c) Copyright 2004-2011; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/CPU is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * CPU CONFIGURATION FILE * * TEMPLATE * * Filename : cpu_cfg.h * Version : V1.28.00 * Programmer(s) : SR * ITJ ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE ********************************************************************************************************* */ /* ********************************************************************************************************* * CPU NAME CONFIGURATION * * Note(s) : (1) Configure CPU_CFG_NAME_EN to enable/disable CPU host name feature : * * (a) CPU host name storage * (b) CPU host name API functions * * (2) Configure CPU_CFG_NAME_SIZE with the desired ASCII string size of the CPU host name, * including the terminating NULL character. * * See also 'cpu_core.h GLOBAL VARIABLES Note #1'. ********************************************************************************************************* */ /* Configure CPU host name feature (see Note #1) : */ /* DEF_DISABLED CPU host name DISABLED */ /* DEF_ENABLED CPU host name ENABLED */ /* Configure CPU host name ASCII string size ... */ /*$PAGE*/ /* ********************************************************************************************************* * CPU TIMESTAMP CONFIGURATION * * Note(s) : (1) Configure CPU_CFG_TS_xx_EN to enable/disable CPU timestamp features : * * (a) CPU_CFG_TS_32_EN enable/disable 32-bit CPU timestamp feature * (b) CPU_CFG_TS_64_EN enable/disable 64-bit CPU timestamp feature * * (2) (a) Configure CPU_CFG_TS_TMR_SIZE with the CPU timestamp timer's word size : * * CPU_WORD_SIZE_08 8-bit word size * CPU_WORD_SIZE_16 16-bit word size * CPU_WORD_SIZE_32 32-bit word size * CPU_WORD_SIZE_64 64-bit word size * * (b) If the size of the CPU timestamp timer is not a binary multiple of 8-bit octets * (e.g. 20-bits or even 24-bits), then the next lower, binary-multiple octet word * size SHOULD be configured (e.g. to 16-bits). However, the minimum supported word * size for CPU timestamp timers is 8-bits. * * See also 'cpu_core.h FUNCTION PROTOTYPES CPU_TS_TmrRd() Note #2a'. ********************************************************************************************************* */ /* Configure CPU timestamp features (see Note #1) : */ /* DEF_DISABLED CPU timestamps DISABLED */ /* DEF_ENABLED CPU timestamps ENABLED */ /* Configure CPU timestamp timer word size ... */ /* ... (see Note #2) : */ /* ********************************************************************************************************* * CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION * * Note(s) : (1) (a) Configure CPU_CFG_INT_DIS_MEAS_EN to enable/disable measuring CPU's interrupts * disabled time : * * (a) Enabled, if CPU_CFG_INT_DIS_MEAS_EN #define'd in 'cpu_cfg.h' * * (b) Disabled, if CPU_CFG_INT_DIS_MEAS_EN NOT #define'd in 'cpu_cfg.h' * * See also 'cpu_core.h FUNCTION PROTOTYPES Note #1'. * * (b) Configure CPU_CFG_INT_DIS_MEAS_OVRHD_NBR with the number of times to measure & * average the interrupts disabled time measurements overhead. * * Recommend a single (1) overhead time measurement, even for instruction-cache-enabled * CPUs, since critical sections are NOT typically called within instruction-cached loops. * Thus, a single non-cached/non-averaged time measurement is a more realistic overhead * for the majority of non-cached interrupts disabled time measurements. * * See also 'cpu_core.c CPU_IntDisMeasInit() Note #3a'. ********************************************************************************************************* */ /* Configure number of interrupts disabled overhead ... */ /*$PAGE*/ /* ********************************************************************************************************* * CPU COUNT LEADING ZEROS CONFIGURATION * * Note(s) : (1) Configure CPU_CFG_LEAD_ZEROS_ASM_PRESENT to prototype/define count leading zeros bits * function(s) in : * * (a) 'cpu.h'/'cpu_a.asm', if CPU_CFG_LEAD_ZEROS_ASM_PRESENT #define'd in 'cpu.h'/ * 'cpu_cfg.h' to enable assembly-version function * * (b) 'cpu_core.h'/'cpu_core.c', if CPU_CFG_LEAD_ZEROS_ASM_PRESENT NOT #define'd in 'cpu.h'/ * 'cpu_cfg.h' to enable C-source-version function otherwise * * See also 'cpu_core.h FUNCTION PROTOTYPES Note #2'. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * MODULE END ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * CONFIGURE STANDARD DATA TYPES * * Note(s) : (1) Configure standard data types according to CPU-/compiler-specifications. * * (2) (a) (1) 'CPU_FNCT_VOID' data type defined to replace the commonly-used function pointer * data type of a pointer to a function which returns void & has no arguments. * * (2) Example function pointer usage : * * CPU_FNCT_VOID FnctName; * * FnctName(); * * (b) (1) 'CPU_FNCT_PTR' data type defined to replace the commonly-used function pointer * data type of a pointer to a function which returns void & has a single void * pointer argument. * * (2) Example function pointer usage : * * CPU_FNCT_PTR FnctName; * void *p_obj * * FnctName(p_obj); ********************************************************************************************************* */ typedef void CPU_VOID; typedef char CPU_CHAR; /* 8-bit character */ typedef unsigned char CPU_BOOLEAN; /* 8-bit boolean or logical */ typedef unsigned char CPU_INT08U; /* 8-bit unsigned integer */ typedef signed char CPU_INT08S; /* 8-bit signed integer */ typedef unsigned short CPU_INT16U; /* 16-bit unsigned integer */ typedef signed short CPU_INT16S; /* 16-bit signed integer */ typedef unsigned int CPU_INT32U; /* 32-bit unsigned integer */ typedef signed int CPU_INT32S; /* 32-bit signed integer */ typedef unsigned long long CPU_INT64U; /* 64-bit unsigned integer */ typedef signed long long CPU_INT64S; /* 64-bit signed integer */ typedef float CPU_FP32; /* 32-bit floating point */ typedef double CPU_FP64; /* 64-bit floating point */ typedef volatile CPU_INT08U CPU_REG08; /* 8-bit register */ typedef volatile CPU_INT16U CPU_REG16; /* 16-bit register */ typedef volatile CPU_INT32U CPU_REG32; /* 32-bit register */ typedef volatile CPU_INT64U CPU_REG64; /* 64-bit register */ typedef void (*CPU_FNCT_VOID)(void); /* See Note #2a. */ typedef void (*CPU_FNCT_PTR )(void *p_obj); /* See Note #2b. */ /*$PAGE*/ /* ********************************************************************************************************* * CPU WORD CONFIGURATION * * Note(s) : (1) Configure CPU_CFG_ADDR_SIZE & CPU_CFG_DATA_SIZE with CPU's word sizes : * * CPU_WORD_SIZE_08 8-bit word size * CPU_WORD_SIZE_16 16-bit word size * CPU_WORD_SIZE_32 32-bit word size * CPU_WORD_SIZE_64 64-bit word size See Note #1a * * (a) 64-bit word size NOT currently supported. * * (2) Configure CPU_CFG_ENDIAN_TYPE with CPU's data-word-memory order : * * (a) CPU_ENDIAN_TYPE_BIG Big- endian word order (CPU words' most significant * octet @ lowest memory address) * (b) CPU_ENDIAN_TYPE_LITTLE Little-endian word order (CPU words' least significant * octet @ lowest memory address) * * (3) '__LITTLE_ENDIAN__' is an IAR compiler #define that reflects the '--endian' option, * indicating the data word-memory order : * * (a) '0' for big endian word-memory order * (b) '1' for little endian word-memory order ********************************************************************************************************* */ /* Define CPU word sizes (see Note #1) : */ /* Defines CPU data word-memory order (see Note #2). */ /* ********************************************************************************************************* * CONFIGURE CPU ADDRESS & DATA TYPES ********************************************************************************************************* */ /* CPU address type based on address bus size. */ typedef CPU_INT32U CPU_ADDR; /* CPU data type based on data bus size. */ typedef CPU_INT32U CPU_DATA; typedef CPU_DATA CPU_ALIGN; /* Defines CPU data-word-alignment size. */ typedef CPU_ADDR CPU_SIZE_T; /* Defines CPU standard 'size_t' size. */ /* ********************************************************************************************************* * CPU STACK CONFIGURATION * * Note(s) : (1) Configure CPU_CFG_STK_GROWTH in 'cpu.h' with CPU's stack growth order : * * (a) CPU_STK_GROWTH_LO_TO_HI CPU stack pointer increments to the next higher stack * memory address after data is pushed onto the stack * (b) CPU_STK_GROWTH_HI_TO_LO CPU stack pointer decrements to the next lower stack * memory address after data is pushed onto the stack ********************************************************************************************************* */ typedef CPU_INT32U CPU_STK; /* Defines CPU stack word size (in octets). */ typedef CPU_ADDR CPU_STK_SIZE; /* Defines CPU stack size (in number of CPU_STKs). */ /*$PAGE*/ /* ********************************************************************************************************* * CRITICAL SECTION CONFIGURATION * * Note(s) : (1) Configure CPU_CFG_CRITICAL_METHOD with CPU's/compiler's critical section method : * * Enter/Exit critical sections by ... * * CPU_CRITICAL_METHOD_INT_DIS_EN Disable/Enable interrupts * CPU_CRITICAL_METHOD_STATUS_STK Push/Pop interrupt status onto stack * CPU_CRITICAL_METHOD_STATUS_LOCAL Save/Restore interrupt status to local variable * * (a) CPU_CRITICAL_METHOD_INT_DIS_EN is NOT a preferred method since it does NOT support * multiple levels of interrupts. However, with some CPUs/compilers, this is the only * available method. * * (b) CPU_CRITICAL_METHOD_STATUS_STK is one preferred method since it supports multiple * levels of interrupts. However, this method assumes that the compiler provides C-level * &/or assembly-level functionality for the following : * * ENTER CRITICAL SECTION : * (1) Push/save interrupt status onto a local stack * (2) Disable interrupts * * EXIT CRITICAL SECTION : * (3) Pop/restore interrupt status from a local stack * * (c) CPU_CRITICAL_METHOD_STATUS_LOCAL is one preferred method since it supports multiple * levels of interrupts. However, this method assumes that the compiler provides C-level * &/or assembly-level functionality for the following : * * ENTER CRITICAL SECTION : * (1) Save interrupt status into a local variable * (2) Disable interrupts * * EXIT CRITICAL SECTION : * (3) Restore interrupt status from a local variable * * (2) Critical section macro's most likely require inline assembly. If the compiler does NOT * allow inline assembly in C source files, critical section macro's MUST call an assembly * subroutine defined in a 'cpu_a.asm' file located in the following software directory : * * \\\* * where * directory path for common CPU-compiler software * directory name for specific CPU * directory name for specific compiler * * (3) (a) To save/restore interrupt status, a local variable 'cpu_sr' of type 'CPU_SR' MAY need * to be declared (e.g. if 'CPU_CRITICAL_METHOD_STATUS_LOCAL' method is configured). * * (1) 'cpu_sr' local variable SHOULD be declared via the CPU_SR_ALLOC() macro which, if * used, MUST be declared following ALL other local variables. * * Example : * * void Fnct (void) * { * CPU_INT08U val_08; * CPU_INT16U val_16; * CPU_INT32U val_32; * CPU_SR_ALLOC(); MUST be declared after ALL other local variables * : * : * } * * (b) Configure 'CPU_SR' data type with the appropriate-sized CPU data type large enough to * completely store the CPU's/compiler's status word. ********************************************************************************************************* */ /*$PAGE*/ /* Configure CPU critical method (see Note #1) : */ typedef CPU_INT32U CPU_SR; /* Defines CPU status register size (see Note #3b). */ /* Allocates CPU status register word (see Note #3a). */ /* Disable interrupts, ... */ /* & start interrupts disabled time measurement.*/ /* Stop & measure interrupts disabled time, */ /* ... & re-enable interrupts. */ /*$PAGE*/ /* ********************************************************************************************************* * ARM EXCEPTIONS VECTORS * * Note(s) : (1) Exceptions are taken whenever the normal flow of a program MUST temporarily halt, * for example, to service an interrupt from a peripheral. The ARM architecture has * the following execption vectors. * * CPU_ARM_EXCEPT_RST Reset exception. * CPU_ARM_EXCEPT_UND Undefined instruction. * CPU_ARM_EXCEPT_SWI Software interrupt. * CPU_ARM_EXCEPT_ABORT_PREFETCH Prefetch Abort. * CPU_ARM_EXCEPT_ABORT_DATA Data Abort. * CPU_ARM_EXCEPT_IRQ Interrupt request. * CPU_ARM_EXCEPT_FIQ Fast Interrupt Request. ********************************************************************************************************* */ /* ********************************************************************************************************* * ARM CORTEX-A8 PROGRAM STATUS REGISTER BIT & BIT-FIELDS DEFINES ********************************************************************************************************* */ /* ********************************************************************************************************* * ARM CORTEX-A8 FLOATING POINT UNIT BIT DEFINES ********************************************************************************************************* */ /* ********************************************************************************************************* * ARM CORTEX-A8 EVENTS AND PERFORMANCE MONITOR * * Note(s) : (1) The Performance Monitoring Unit (PMU) includes logic to detect various events * that can occur. This events can be counted using the registers in the PMU. ********************************************************************************************************* */ /* ... executed. */ /* ... instruction architecturally executed. */ /* ... than exception returns. */ /* ... an instruction. */ /* .. could have been predicted by the branch ... */ /* .. prediction Resources of the processor */ /* ... architecturally executed. */ /* ... from the prefetch unit. */ /* ... from the load/store unit. */ /* ... because of a resource shortage. */ /* ... slots have data in same cache line but with ... */ /* ... different attributes. */ /* ... conversion instruction executed. */ /* ... exception at exception vector.a */ /* ... unit. */ /* ... slave interface. */ /* ... interface. */ /* ********************************************************************************************************* * ARM CORTEX-A8 MEMORY PROTECTION UNIT DEFINES ********************************************************************************************************* */ /* ------------- ACCESS PERMISSION DEFINES ------------ */ /* ----------- MEMORY ACCESS TYPE ATTRIBUTES ---------- */ /*$PAGE*/ /* ********************************************************************************************************* * FUNCTION PROTOTYPES * * Note(s) : (1) CPU_CntLeadZeros() prototyped/defined respectively in : * * (a) 'cpu.h'/'cpu_a.asm', if CPU_CFG_LEAD_ZEROS_ASM_PRESENT #define'd in 'cpu.h'/ * 'cpu_cfg.h' to enable assembly-version function * * (b) 'cpu_core.h'/'cpu_core.c', if CPU_CFG_LEAD_ZEROS_ASM_PRESENT NOT #define'd in 'cpu.h'/ * 'cpu_cfg.h' to enable C-source-version function otherwise * * See also 'cpu_core.h FUNCTION PROTOTYPES Note #2'. * * (2) CPU_PMU_xxx() functions are intended to manage the Event & Performanace Monitor unit (PMU). ********************************************************************************************************* */ CPU_SR CPU_SR_Save (void); void CPU_SR_Restore (CPU_SR cpu_sr); void CPU_IntEn (void); void CPU_IntDis (void); void CPU_IRQ_En (void); void CPU_IRQ_Dis (void); void CPU_FIQ_En (void); void CPU_FIQ_Dis (void); CPU_DATA CPU_CntLeadZeros (CPU_DATA val); /* See Note #2 */ void CPU_PMU_Dis (void); void CPU_PMU_En (void); void CPU_PMU_Rst (void); /* Event counter functions. */ void CPU_PMU_CtrDis (CPU_INT08U ctr); void CPU_PMU_CtrEn (CPU_INT08U ctr); void CPU_PMU_CtrEventSet(CPU_INT08U ctr, CPU_INT08U event); CPU_DATA CPU_PMU_CtrGet (CPU_INT08U ctr); void CPU_PMU_CtrRst (CPU_INT08U ctr); /* Cycle counter functions. */ void CPU_PMU_CtrCycleDis(void); void CPU_PMU_CtrCycleEn (void); CPU_DATA CPU_PMU_CtrCycleGet(void); CPU_DATA CPU_PMU_CtrCycleRst(void); /* MMU functions */ void CPU_MMU_Init (void); void CPU_MMU_En (void); void CPU_MMU_Dis (void); CPU_BOOLEAN CPU_MMU_RegionEn (CPU_INT08U nbr, CPU_ADDR addr, CPU_INT08U sub_reg_en, CPU_INT32U size, CPU_INT32U acess_attrib); void CPU_MMU_RegionDis (CPU_INT08U nbr); void CPU_CtxID_Set (CPU_INT32U ctx_id); CPU_INT32U CPU_CtxID_Get (void); /*$PAGE*/ /* ********************************************************************************************************* * CONFIGURATION ERRORS ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * MODULE END ********************************************************************************************************* */ /* ********************************************************************************************************* * uC/CPU * CPU CONFIGURATION & PORT LAYER * * (c) Copyright 2004-2011; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/CPU is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * CORE CPU MODULE * * Filename : cpu_core.h * Version : V1.29.01 * Programmer(s) : SR * ITJ ********************************************************************************************************* * Note(s) : (1) Assumes the following versions (or more recent) of software modules are included in * the project build : * * (a) uC/LIB V1.35.00 ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE * * Note(s) : (1) This core CPU header file is protected from multiple pre-processor inclusion through use of * the core CPU module present pre-processor macro definition. ********************************************************************************************************* */ /* ********************************************************************************************************* * EXTERNS ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * INCLUDE FILES * * Note(s) : (1) CPU-configuration software files are located in the following directories : * * (a) \\cpu_cfg.h * * (b) (1) \\cpu_*.* * (2) \\\\cpu*.* * * where * directory path for Your Product's Application * directory path for common CPU-compiler software * directory name for specific processor (CPU) * directory name for specific compiler * * (2) NO compiler-supplied standard library functions SHOULD be used. * * (a) Standard library functions are implemented in the custom library module(s) : * * \\lib_*.* * * where * directory path for custom library software * * (3) Compiler MUST be configured to include as additional include path directories : * * (a) '\\' directory See Note #1a * * (b) (1) '\\' directory See Note #1b1 * (2) '\\\\' directory See Note #1b2 * * (c) '\\' directory See Note #2a ********************************************************************************************************* */ /* ********************************************************************************************************* * uC/LIB * CUSTOM LIBRARY MODULES * * (c) Copyright 2004-2012; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/LIB is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * CORE CUSTOM LIBRARY MODULE * * Filename : lib_def.h * Version : V1.37.01 * Programmer(s) : ITJ * FBJ ********************************************************************************************************* * Note(s) : (1) Assumes the following versions (or more recent) of software modules are included in * the project build : * * (a) uC/CPU V1.29.00 * * * (2) NO compiler-supplied standard library functions are used in library or product software. * * (a) ALL standard library functions are implemented in the custom library modules : * * (1) \\lib_*.* * * (2) \\Ports\\\lib*_a.* * * where * directory path for custom library software * directory name for specific processor (CPU) * directory name for specific compiler * * (b) Product-specific library functions are implemented in individual products. ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE * * Note(s) : (1) This library definition header file is protected from multiple pre-processor inclusion * through use of the library definition module present pre-processor macro definition. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * CUSTOM LIBRARY MODULE VERSION NUMBER * * Note(s) : (1) (a) The custom library module software version is denoted as follows : * * Vx.yy.zz * * where * V denotes 'Version' label * x denotes major software version revision number * yy denotes minor software version revision number * zz denotes sub-minor software version revision number * * (b) The software version label #define is formatted as follows : * * ver = x.yyzz * 100 * 100 * * where * ver denotes software version number scaled as an integer value * x.yyzz denotes software version number, where the unscaled integer * portion denotes the major version number & the unscaled * fractional portion denotes the (concatenated) minor * version numbers ********************************************************************************************************* */ /* ********************************************************************************************************* * INCLUDE FILES * * Note(s) : (1) The custom library software files are located in the following directories : * * (a) \\lib_*.* * * where * directory path for custom library software * * (2) CPU-configuration software files are located in the following directories : * * (a) \\cpu_*.* * (b) \\\\cpu*.* * * where * directory path for common CPU-compiler software * directory name for specific processor (CPU) * directory name for specific compiler * * (3) Compiler MUST be configured to include as additional include path directories : * * (a) '\\' directory See Note #1a * * (b) (1) '\\' directory See Note #2a * (2) '\\\\' directory See Note #2b ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * STANDARD DEFINES ********************************************************************************************************* */ /* ----------------- BOOLEAN DEFINES ------------------ */ /* ------------------- BIT DEFINES -------------------- */ /*$PAGE*/ /* ------------------ ALIGN DEFINES ------------------- */ /* ------------------ OCTET DEFINES ------------------- */ /* --------------- NUMBER BASE DEFINES ---------------- */ /*$PAGE*/ /* ----------------- INTEGER DEFINES ------------------ */ /*$PAGE*/ /* --------------- CPU INTEGER DEFINES ---------------- */ /*$PAGE*/ /* ------------------- TIME DEFINES ------------------- */ /*$PAGE*/ /* ********************************************************************************************************* * ERROR CODES * * Note(s) : (1) All library error codes are #define'd in 'lib_def.h'; ********************************************************************************************************* */ typedef enum lib_err { LIB_ERR_NONE = 0u, LIB_MEM_ERR_NONE = 10000u, LIB_MEM_ERR_NULL_PTR = 10001u, /* Ptr arg(s) passed NULL ptr(s). */ LIB_MEM_ERR_INVALID_MEM_SIZE = 10100u, /* Invalid mem size. */ LIB_MEM_ERR_INVALID_MEM_ALIGN = 10101u, /* Invalid mem align. */ LIB_MEM_ERR_INVALID_SEG_SIZE = 10110u, /* Invalid mem seg size. */ LIB_MEM_ERR_INVALID_SEG_OVERLAP = 10111u, /* Invalid mem seg overlaps other mem seg(s). */ LIB_MEM_ERR_INVALID_POOL = 10120u, /* Invalid mem pool. */ LIB_MEM_ERR_INVALID_BLK_NBR = 10130u, /* Invalid mem pool blk nbr. */ LIB_MEM_ERR_INVALID_BLK_SIZE = 10131u, /* Invalid mem pool blk size. */ LIB_MEM_ERR_INVALID_BLK_ALIGN = 10132u, /* Invalid mem pool blk align. */ LIB_MEM_ERR_INVALID_BLK_IX = 10133u, /* Invalid mem pool ix. */ LIB_MEM_ERR_INVALID_BLK_ADDR = 10135u, /* Invalid mem pool blk addr. */ LIB_MEM_ERR_INVALID_BLK_ADDR_IN_POOL = 10136u, /* Mem pool blk addr already in mem pool. */ LIB_MEM_ERR_SEG_EMPTY = 10200u, /* Mem seg empty; i.e. NO avail mem in seg. */ LIB_MEM_ERR_SEG_OVF = 10201u, /* Mem seg ovf; i.e. req'd mem ovfs rem mem in seg. */ LIB_MEM_ERR_POOL_FULL = 10205u, /* Mem pool full; i.e. all mem blks avail in mem pool. */ LIB_MEM_ERR_POOL_EMPTY = 10206u, /* Mem pool empty; i.e. NO mem blks avail in mem pool. */ LIB_MEM_ERR_HEAP_EMPTY = 10210u, /* Heap seg empty; i.e. NO avail mem in heap. */ LIB_MEM_ERR_HEAP_OVF = 10211u, /* Heap seg ovf; i.e. req'd mem ovfs rem mem in heap. */ LIB_MEM_ERR_HEAP_NOT_FOUND = 10215u /* Heap seg NOT found. */ } LIB_ERR; /*$PAGE*/ /* ********************************************************************************************************* * DATA TYPES ********************************************************************************************************* */ /* ********************************************************************************************************* * GLOBAL VARIABLES ********************************************************************************************************* */ /* ********************************************************************************************************* * TRACING ********************************************************************************************************* */ /* Trace level, default to TRACE_LEVEL_OFF. */ /*$PAGE*/ /* ********************************************************************************************************* * BIT MACRO'S ********************************************************************************************************* */ /* ********************************************************************************************************* * DEF_BIT() * * Description : Create bit mask with single, specified bit set. * * Argument(s) : bit Bit number of bit to set. * * Return(s) : Bit mask with single, specified bit set. * * Caller(s) : Application. * * Note(s) : (1) 'bit' SHOULD be a non-negative integer. * * (2) (a) 'bit' values that overflow the target CPU &/or compiler environment (e.g. negative * or greater-than-CPU-data-size values) MAY generate compiler warnings &/or errors. ********************************************************************************************************* */ /* ********************************************************************************************************* * DEF_BITxx() * * Description : Create bit mask of specified bit size with single, specified bit set. * * Argument(s) : bit Bit number of bit to set. * * Return(s) : Bit mask with single, specified bit set. * * Caller(s) : Application. * * Note(s) : (1) 'bit' SHOULD be a non-negative integer. * * (2) (a) 'bit' values that overflow the target CPU &/or compiler environment (e.g. negative * or greater-than-CPU-data-size values) MAY generate compiler warnings &/or errors. * * (b) To avoid overflowing any target CPU &/or compiler's integer data type, unsigned * bit constant '1' is cast to specified integer data type size. * * (3) Ideally, DEF_BITxx() macro's should be named DEF_BIT_xx(); however, these names already * previously-released for bit constant #define's (see 'STANDARD DEFINES BIT DEFINES'). ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DEF_BIT_MASK() * * Description : Shift a bit mask. * * Argument(s) : bit_mask Bit mask to shift. * * bit_shift Number of bit positions to left-shift bit mask. * * Return(s) : Shifted bit mask. * * Caller(s) : Application. * * Note(s) : (1) (a) 'bit_mask' SHOULD be an unsigned integer. * * (b) 'bit_shift' SHOULD be a non-negative integer. * * (2) 'bit_shift' values that overflow the target CPU &/or compiler environment (e.g. negative * or greater-than-CPU-data-size values) MAY generate compiler warnings &/or errors. ********************************************************************************************************* */ /* ********************************************************************************************************* * DEF_BIT_MASK_xx() * * Description : Shift a bit mask of specified bit size. * * Argument(s) : bit_mask Bit mask to shift. * * bit_shift Number of bit positions to left-shift bit mask. * * Return(s) : Shifted bit mask. * * Caller(s) : Application. * * Note(s) : (1) (a) 'bit_mask' SHOULD be an unsigned integer. * * (b) 'bit_shift' SHOULD be a non-negative integer. * * (2) 'bit_shift' values that overflow the target CPU &/or compiler environment (e.g. negative * or greater-than-CPU-data-size values) MAY generate compiler warnings &/or errors. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DEF_BIT_FIELD() * * Description : Create & shift a contiguous bit field. * * Argument(s) : bit_field Number of contiguous bits to set in the bit field. * * bit_shift Number of bit positions to left-shift bit field. * * Return(s) : Shifted bit field. * * Caller(s) : Application. * * Note(s) : (1) 'bit_field' & 'bit_shift' SHOULD be non-negative integers. * * (2) (a) 'bit_field'/'bit_shift' values that overflow the target CPU &/or compiler * environment (e.g. negative or greater-than-CPU-data-size values) MAY generate * compiler warnings &/or errors. * * (b) To avoid overflowing any target CPU &/or compiler's integer data type, unsigned * bit constant '1' is suffixed with 'L'ong integer modifier. * * This may still be insufficient for CPUs &/or compilers that support 'long long' * integer data types, in which case 'LL' integer modifier should be suffixed. * However, since almost all 16- & 32-bit CPUs & compilers support 'long' integer * data types but many may NOT support 'long long' integer data types, only 'long' * integer data types & modifiers are supported. * * See also 'DEF_BIT_FIELD_xx() Note #1b'. ********************************************************************************************************* */ /* ********************************************************************************************************* * DEF_BIT_FIELD_xx() * * Description : Create & shift a contiguous bit field of specified bit size. * * Argument(s) : bit_field Number of contiguous bits to set in the bit field. * * bit_shift Number of bit positions to left-shift bit field. * * Return(s) : Shifted bit field. * * Caller(s) : Application. * * Note(s) : (1) 'bit_field' & 'bit_shift' SHOULD be non-negative integers. * * (2) (a) 'bit_field'/'bit_shift' values that overflow the target CPU &/or compiler * environment (e.g. negative or greater-than-CPU-data-size values) MAY generate * compiler warnings &/or errors. * * (b) To avoid overflowing any target CPU &/or compiler's integer data type, unsigned * bit constant '1' is cast to specified integer data type size. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DEF_BIT_SET_xx() * * Description : Set specified bit(s) in a value of specified bit size. * * Argument(s) : val Value to modify by setting specified bit(s). * * mask Mask of bits to set. * * Return(s) : Modified value with specified bit(s) set. * * Caller(s) : Application. * * Note(s) : (1) 'val' & 'mask' SHOULD be unsigned integers. ********************************************************************************************************* */ /* ********************************************************************************************************* * DEF_BIT_SET() * * Description : Set specified bit(s) in a value. * * Argument(s) : val Value to modify by setting specified bit(s). * * mask Mask of bits to set. * * Return(s) : Modified value with specified bit(s) set. * * Caller(s) : Application. * * Note(s) : (1) 'val' & 'mask' SHOULD be unsigned integers. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DEF_BIT_CLR_xx() * * Description : Clear specified bit(s) in a value of specified bit size. * * Argument(s) : val Value to modify by clearing specified bit(s). * * mask Mask of bits to clear. * * Return(s) : Modified value with specified bit(s) clear. * * Caller(s) : Application. * * Note(s) : (1) 'val' & 'mask' SHOULD be unsigned integers. ********************************************************************************************************* */ /* ********************************************************************************************************* * DEF_BIT_CLR() * * Description : Clear specified bit(s) in a value. * * Argument(s) : val Value to modify by clearing specified bit(s). * * mask Mask of bits to clear. * * Return(s) : Modified value with specified bit(s) clear. * * Caller(s) : Application. * * Note(s) : (1) 'val' & 'mask' SHOULD be unsigned integers. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DEF_BIT_IS_SET() * * Description : Determine if specified bit(s) in a value are set. * * Argument(s) : val Value to check for specified bit(s) set. * * mask Mask of bits to check if set (see Note #2). * * Return(s) : DEF_YES, if ALL specified bit(s) are set in value. * * DEF_NO, if ALL specified bit(s) are NOT set in value. * * Caller(s) : Application. * * Note(s) : (1) 'val' & 'mask' SHOULD be unsigned integers. * * (2) NULL 'mask' allowed; returns 'DEF_NO' since NO mask bits specified. ********************************************************************************************************* */ /* ********************************************************************************************************* * DEF_BIT_IS_CLR() * * Description : Determine if specified bit(s) in a value are clear. * * Argument(s) : val Value to check for specified bit(s) clear. * * mask Mask of bits to check if clear (see Note #2). * * Return(s) : DEF_YES, if ALL specified bit(s) are clear in value. * * DEF_NO, if ALL specified bit(s) are NOT clear in value. * * Caller(s) : Application. * * Note(s) : (1) 'val' & 'mask' SHOULD be unsigned integers. * * (2) NULL 'mask' allowed; returns 'DEF_NO' since NO mask bits specified. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DEF_BIT_IS_SET_ANY() * * Description : Determine if any specified bit(s) in a value are set. * * Argument(s) : val Value to check for specified bit(s) set. * * mask Mask of bits to check if set (see Note #2). * * Return(s) : DEF_YES, if ANY specified bit(s) are set in value. * * DEF_NO, if ALL specified bit(s) are NOT set in value. * * Caller(s) : Application. * * Note(s) : (1) 'val' & 'mask' SHOULD be unsigned integers. * * (2) NULL 'mask' allowed; returns 'DEF_NO' since NO mask bits specified. ********************************************************************************************************* */ /* ********************************************************************************************************* * DEF_BIT_IS_CLR_ANY() * * Description : Determine if any specified bit(s) in a value are clear. * * Argument(s) : val Value to check for specified bit(s) clear. * * mask Mask of bits to check if clear (see Note #2). * * Return(s) : DEF_YES, if ANY specified bit(s) are clear in value. * * DEF_NO, if ALL specified bit(s) are NOT clear in value. * * Note(s) : (1) 'val' & 'mask' SHOULD be unsigned integers. * * (2) NULL 'mask' allowed; returns 'DEF_NO' since NO mask bits specified. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * VALUE MACRO'S ********************************************************************************************************* */ /* ********************************************************************************************************* * DEF_CHK_VAL_MIN() * * Description : Validate a value as greater than or equal to a specified minimum value. * * Argument(s) : val Value to validate. * * val_min Minimum value to test. * * Return(s) : DEF_OK, Value is greater than or equal to minimum value. * * DEF_FAIL, otherwise. * * Caller(s) : Application. * * Note(s) : (1) DEF_CHK_VAL_MIN() avoids directly comparing any two values if only one of the values * is negative since the negative value might be incorrectly promoted to an arbitrary * unsigned value if the other value to compare is unsigned. * * (2) Validation of values is limited to the range supported by the compiler &/or target * environment. All other values that underflow/overflow the supported range will * modulo/wrap into the supported range as arbitrary signed or unsigned values. * * Therefore, any values that underflow the most negative signed value or overflow * the most positive unsigned value supported by the compiler &/or target environment * cannot be validated : * * ( N-1 N ] * ( -(2 ) , 2 - 1 ] * ( ] * * where * N Number of data word bits supported by the compiler * &/or target environment * * (a) Note that the most negative value, -2^(N-1), is NOT included in the supported * range since many compilers do NOT always correctly handle this value. * * (3) 'val' and 'val_min' are compared to 1 instead of 0 to avoid warning generated for * unsigned numbers. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DEF_CHK_VAL_MAX() * * Description : Validate a value as less than or equal to a specified maximum value. * * Argument(s) : val Value to validate. * * val_max Maximum value to test. * * Return(s) : DEF_OK, Value is less than or equal to maximum value. * * DEF_FAIL, otherwise. * * Caller(s) : Application. * * Note(s) : (1) DEF_CHK_VAL_MAX() avoids directly comparing any two values if only one of the values * is negative since the negative value might be incorrectly promoted to an arbitrary * unsigned value if the other value to compare is unsigned. * * (2) Validation of values is limited to the range supported by the compiler &/or target * environment. All other values that underflow/overflow the supported range will * modulo/wrap into the supported range as arbitrary signed or unsigned values. * * Therefore, any values that underflow the most negative signed value or overflow * the most positive unsigned value supported by the compiler &/or target environment * cannot be validated : * * ( N-1 N ] * ( -(2 ) , 2 - 1 ] * ( ] * * where * N Number of data word bits supported by the compiler * &/or target environment * * (a) Note that the most negative value, -2^(N-1), is NOT included in the supported * range since many compilers do NOT always correctly handle this value. * * (3) 'val' and 'val_max' are compared to 1 instead of 0 to avoid warning generated for * unsigned numbers. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DEF_CHK_VAL() * * Description : Validate a value as greater than or equal to a specified minimum value & less than or * equal to a specified maximum value. * * Argument(s) : val Value to validate. * * val_min Minimum value to test. * * val_max Maximum value to test. * * Return(s) : DEF_OK, Value is greater than or equal to minimum value AND * less than or equal to maximum value. * * DEF_FAIL, otherwise. * * Caller(s) : Application. * * Note(s) : (1) DEF_CHK_VAL() avoids directly comparing any two values if only one of the values * is negative since the negative value might be incorrectly promoted to an arbitrary * unsigned value if the other value to compare is unsigned. * * (2) Validation of values is limited to the range supported by the compiler &/or target * environment. All other values that underflow/overflow the supported range will * modulo/wrap into the supported range as arbitrary signed or unsigned values. * * Therefore, any values that underflow the most negative signed value or overflow * the most positive unsigned value supported by the compiler &/or target environment * cannot be validated : * * ( N-1 N ] * ( -(2 ) , 2 - 1 ] * ( ] * * where * N Number of data word bits supported by the compiler * &/or target environment * * (a) Note that the most negative value, -2^(N-1), is NOT included in the supported * range since many compilers do NOT always correctly handle this value. * * (3) DEF_CHK_VAL() does NOT validate that the maximum value ('val_max') is greater than * or equal to the minimum value ('val_min'). ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DEF_GET_U_MAX_VAL() * * Description : Get the maximum unsigned value that can be represented in an unsigned integer variable * of the same data type size as an object. * * Argument(s) : obj Object or data type to return maximum unsigned value (see Note #1). * * Return(s) : Maximum unsigned integer value that can be represented by the object, if NO error(s). * * 0, otherwise. * * Caller(s) : Application. * * Note(s) : (1) 'obj' SHOULD be an integer object or data type but COULD also be a character or * pointer object or data type. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * MATH MACRO'S * * Note(s) : (1) Ideally, ALL mathematical macro's & functions SHOULD be defined in the custom mathematics * library ('lib_math.*'). #### However, to maintain backwards compatibility with previously- * released modules, mathematical macro & function definitions should only be moved to the * custom mathematics library once all previously-released modules are updated to include the * custom mathematics library. ********************************************************************************************************* */ /* ********************************************************************************************************* * DEF_MIN() * * Description : Determine the minimum of two values. * * Argument(s) : a First value. * * b Second value. * * Return(s) : Minimum of the two values. * * Caller(s) : Application. * * Note(s) : none. ********************************************************************************************************* */ /* ********************************************************************************************************* * DEF_MAX() * * Description : Determine the maximum of two values. * * Argument(s) : a First value. * * b Second value. * * Return(s) : Maximum of the two values. * * Note(s) : none. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DEF_ABS() * * Description : Determine the absolute value of a value. * * Argument(s) : a Value to calculate absolute value. * * Return(s) : Absolute value of the value. * * Caller(s) : Application. * * Note(s) : none. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * FUNCTION PROTOTYPES ********************************************************************************************************* */ /* ********************************************************************************************************* * CONFIGURATION ERRORS ********************************************************************************************************* */ /* ********************************************************************************************************* * LIBRARY CONFIGURATION ERRORS ********************************************************************************************************* */ /* See 'lib_def.h Note #1a'. */ /* ********************************************************************************************************* * MODULE END * * Note(s) : (1) See 'lib_def.h MODULE'. ********************************************************************************************************* */ /* ********************************************************************************************************* * uC/LIB * CUSTOM LIBRARY MODULES * * (c) Copyright 2004-2013; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/LIB is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * STANDARD MEMORY OPERATIONS * * Filename : lib_mem.h * Version : V1.37.01 * Programmer(s) : ITJ * FBJ ********************************************************************************************************* * Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software. * * (a) ALL standard library functions are implemented in the custom library modules : * * (1) \\lib_*.* * * (2) \\Ports\\\lib*_a.* * * where * directory path for custom library software * directory name for specific processor (CPU) * directory name for specific compiler * * (b) Product-specific library functions are implemented in individual products. * * (2) Assumes the following versions (or more recent) of software modules are included in * the project build : * * (a) uC/CPU V1.27 ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE * * Note(s) : (1) This memory library header file is protected from multiple pre-processor inclusion through * use of the memory library module present pre-processor macro definition. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * INCLUDE FILES * * Note(s) : (1) The custom library software files are located in the following directories : * * (a) \\lib_cfg.h * * (b) \\lib_*.* * * where * directory path for Your Product's Application * directory path for custom library software * * (2) CPU-configuration software files are located in the following directories : * * (a) \\cpu_*.* * (b) \\\\cpu*.* * * where * directory path for common CPU-compiler software * directory name for specific processor (CPU) * directory name for specific compiler * * (3) Compiler MUST be configured to include as additional include path directories : * * (a) '\\' directory See Note #1a * * (b) '\\' directory See Note #1b * * (c) (1) '\\' directory See Note #2a * (2) '\\\\' directory See Note #2b * * (4) NO compiler-supplied standard library functions SHOULD be used. ********************************************************************************************************* */ /* ********************************************************************************************************* * uC/CPU * CPU CONFIGURATION & PORT LAYER * * (c) Copyright 2004-2011; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/CPU is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * CORE CPU MODULE * * Filename : cpu_core.h * Version : V1.29.01 * Programmer(s) : SR * ITJ ********************************************************************************************************* * Note(s) : (1) Assumes the following versions (or more recent) of software modules are included in * the project build : * * (a) uC/LIB V1.35.00 ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE * * Note(s) : (1) This core CPU header file is protected from multiple pre-processor inclusion through use of * the core CPU module present pre-processor macro definition. ********************************************************************************************************* */ /* ********************************************************************************************************* * uC/LIB * CUSTOM LIBRARY MODULES * * (c) Copyright 2004-2011; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/LIB is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * CUSTOM LIBRARY CONFIGURATION FILE * * TEMPLATE * * Filename : lib_cfg.h * Version : V1.35.00 * Programmer(s) : ITJ ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* ********************************************************************************************************* * MEMORY LIBRARY CONFIGURATION ********************************************************************************************************* ********************************************************************************************************* */ /* ********************************************************************************************************* * MEMORY LIBRARY ARGUMENT CHECK CONFIGURATION * * Note(s) : (1) Configure LIB_MEM_CFG_ARG_CHK_EXT_EN to enable/disable the memory library suite external * argument check feature : * * (a) When ENABLED, arguments received from any port interface provided by the developer * or application are checked/validated. * * (b) When DISABLED, NO arguments received from any port interface provided by the developer * or application are checked/validated. ********************************************************************************************************* */ /* Configure external argument check feature (see Note #1) : */ /* DEF_DISABLED Argument check DISABLED */ /* DEF_ENABLED Argument check ENABLED */ /* ********************************************************************************************************* * MEMORY LIBRARY ASSEMBLY OPTIMIZATION CONFIGURATION * * Note(s) : (1) Configure LIB_MEM_CFG_OPTIMIZE_ASM_EN to enable/disable assembly-optimized memory function(s). ********************************************************************************************************* */ /* Configure assembly-optimized function(s) [see Note #1] : */ /* DEF_DISABLED Assembly-optimized function(s) DISABLED */ /* DEF_ENABLED Assembly-optimized function(s) ENABLED */ /* ********************************************************************************************************* * MEMORY ALLOCATION CONFIGURATION * * Note(s) : (1) Configure LIB_MEM_CFG_ALLOC_EN to enable/disable memory allocation functions. * * (2) (a) Configure LIB_MEM_CFG_HEAP_SIZE with the desired size of heap memory (in octets). * * (b) Configure LIB_MEM_CFG_HEAP_BASE_ADDR to specify a base address for heap memory : * * (1) Heap initialized to specified application memory, if LIB_MEM_CFG_HEAP_BASE_ADDR * #define'd in 'app_cfg.h'; * CANNOT #define to address 0x0 * * (2) Heap declared to Mem_Heap[] in 'lib_mem.c', if LIB_MEM_CFG_HEAP_BASE_ADDR * NOT #define'd in 'app_cfg.h' ********************************************************************************************************* */ /* Configure memory allocation feature (see Note #1) : */ /* DEF_DISABLED Memory allocation DISABLED */ /* DEF_ENABLED Memory allocation ENABLED */ /*$PAGE*/ /* ********************************************************************************************************* ********************************************************************************************************* * STRING LIBRARY CONFIGURATION ********************************************************************************************************* ********************************************************************************************************* */ /* ********************************************************************************************************* * STRING FLOATING POINT CONFIGURATION * * Note(s) : (1) Configure LIB_STR_CFG_FP_EN to enable/disable floating point string function(s). * * (2) Configure LIB_STR_CFG_FP_MAX_NBR_DIG_SIG to configure the maximum number of significant * digits to calculate &/or display for floating point string function(s). * * See also 'lib_str.h STRING FLOATING POINT DEFINES Note #1'. ********************************************************************************************************* */ /* Configure floating point feature(s) [see Note #1] : */ /* DEF_DISABLED Floating point functions DISABLED */ /* DEF_ENABLED Floating point functions ENABLED */ /* Configure floating point feature(s)' number of ... */ /* ... significant digits (see Note #2). */ /*$PAGE*/ /* ********************************************************************************************************* * MODULE END ********************************************************************************************************* */ /* ********************************************************************************************************* * EXTERNS ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DEFAULT CONFIGURATION ********************************************************************************************************* */ /* ********************************************************************************************************* * MEMORY LIBRARY ARGUMENT CHECK CONFIGURATION * * Note(s) : (1) Configure LIB_MEM_CFG_ARG_CHK_EXT_EN to enable/disable the memory library suite external * argument check feature : * * (a) When ENABLED, arguments received from any port interface provided by the developer * or application are checked/validated. * * (b) When DISABLED, NO arguments received from any port interface provided by the developer * or application are checked/validated. ********************************************************************************************************* */ /* Configure external argument check feature (see Note #1) : */ /* ********************************************************************************************************* * MEMORY LIBRARY ASSEMBLY OPTIMIZATION CONFIGURATION * * Note(s) : (1) Configure LIB_MEM_CFG_OPTIMIZE_ASM_EN to enable/disable assembly-optimized memory functions. ********************************************************************************************************* */ /* Configure assembly-optimized function(s) [see Note #1] : */ /* ********************************************************************************************************* * MEMORY ALLOCATION CONFIGURATION * * Note(s) : (1) Configure LIB_MEM_CFG_ALLOC_EN to enable/disable memory allocation functions. ********************************************************************************************************* */ /* Configure memory allocation feature (see Note #1) : */ /*$PAGE*/ /* ********************************************************************************************************* * DEFINES ********************************************************************************************************* */ /* ********************************************************************************************************* * MEMORY LIBRARY TYPE DEFINES * * Note(s) : (1) LIB_MEM_TYPE_&&& #define values specifically chosen as ASCII representations of the memory * library types. Memory displays of memory library objects will display the library TYPEs * with their chosen ASCII names. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DATA TYPES ********************************************************************************************************* */ /* ********************************************************************************************************* * LIB MEM TYPE * * Note(s) : (1) 'LIB_MEM_TYPE' declared as 'CPU_INT32U' & all 'LIB_MEM_TYPE's #define'd with large, non-trivial * values to trap & discard invalid/corrupted library memory objects based on 'LIB_MEM_TYPE'. ********************************************************************************************************* */ typedef CPU_INT32U LIB_MEM_TYPE; /* ********************************************************************************************************* * MEMORY POOL BLOCK QUANTITY DATA TYPE ********************************************************************************************************* */ typedef CPU_SIZE_T MEM_POOL_BLK_QTY; /* ********************************************************************************************************* * MEMORY POOL TABLE IX TYPE ********************************************************************************************************* */ typedef MEM_POOL_BLK_QTY MEM_POOL_IX; /*$PAGE*/ /* ********************************************************************************************************* * MEMORY POOL DATA TYPES * * MEMORY SEGMENT * ---------------- * MEMORY POOL'S | | <---- * POINTERS TO | MEMORY | | * MEM_POOL MEMORY BLOCKS | BLOCKS | | * |----------------| |---------| | -------- | | * | O------------------> | O--------------------> | | | | * |----------------| |---------| | | | | | * | Pool Addr Ptrs | | O------------- | -------- | | * | Pool Size | |---------| | | | | * |----------------| | | | | -------- | | * | Blk Size | | | --------> | | | | * | Blk Nbr | | | | | | | | * | Blk Ix | | . | | -------- | | * |----------------| | . | | | | * |----------------| | . | | . | | * | O----------------- | | | . | | * |----------------| | | | | . | | * | O------------ | | | | | | * |----------------| | | |---------| | -------- | | * | Seg Size Tot | | | | O--------------------> | | | | * | Seg Size Rem | | | |---------| | | | | | * |----------------| | | | | | -------- | | * | Seg List Ptrs | | | |---------| | | | * |----------------| | | | ------------ | | * | | | | <-------- * | | | | | | * | | | | | | * | | | | | | * | | | | | | * | | | | | | * | | ---------------- | | * | | | | * | -------------------------------------------------- | * | | * ----------------------------------------------------------- * ********************************************************************************************************* */ typedef struct mem_pool MEM_POOL; /* --------------------- MEM POOL --------------------- */ struct mem_pool { LIB_MEM_TYPE Type; /* Pool type : LIB_TYPE_POOL or LIB_TYPE_HEAP. */ MEM_POOL *SegHeadPtr; /* Ptr to head mem seg. */ MEM_POOL *SegPrevPtr; /* Ptr to PREV mem seg. */ MEM_POOL *SegNextPtr; /* Ptr to NEXT mem seg. */ MEM_POOL *PoolPrevPtr; /* Ptr to PREV mem pool. */ MEM_POOL *PoolNextPtr; /* Ptr to NEXT mem pool. */ void *PoolAddrStart; /* Ptr to start of mem seg for mem pool blks. */ void *PoolAddrEnd; /* Ptr to end of mem seg for mem pool blks. */ void **PoolPtrs; /* Ptr to mem pool's array of blk ptrs. */ MEM_POOL_IX BlkIx; /* Ix into mem pool's array of blk ptrs. */ CPU_SIZE_T PoolSize; /* Size of mem pool (in octets). */ MEM_POOL_BLK_QTY BlkNbr; /* Nbr of mem pool blks. */ CPU_SIZE_T BlkSize; /* Size of mem pool blks (in octets). */ CPU_SIZE_T BlkAlign; /* Align of mem pool blks (in octets). */ /* --------------------- MEM SEG ---------------------- */ void *SegAddr; /* Ptr to mem seg's base/start addr. */ void *SegAddrNextAvail; /* Ptr to mem seg's next avail addr. */ CPU_SIZE_T SegSizeTot; /* Tot size of mem seg (in octets). */ CPU_SIZE_T SegSizeRem; /* Rem size of mem seg (in octets). */ }; /*$PAGE*/ /* ********************************************************************************************************* * GLOBAL VARIABLES ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * MACRO'S ********************************************************************************************************* */ /* ********************************************************************************************************* * MEMORY DATA VALUE MACRO'S * * Note(s) : (1) (a) Some variables & variable buffers to pass & receive data values MUST start on appropriate * CPU word-aligned addresses. This is required because most word-aligned processors are more * efficient & may even REQUIRE that multi-octet words start on CPU word-aligned addresses. * * (1) For 16-bit word-aligned processors, this means that * * all 16- & 32-bit words MUST start on addresses that are multiples of 2 octets * * (2) For 32-bit word-aligned processors, this means that * * all 16-bit words MUST start on addresses that are multiples of 2 octets * all 32-bit words MUST start on addresses that are multiples of 4 octets * * (b) However, some data values macro's appropriately access data values from any CPU addresses, * word-aligned or not. Thus for processors that require data word alignment, data words can * be accessed to/from any CPU address, word-aligned or not, without generating data-word- * alignment exceptions/faults. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * ENDIAN WORD ORDER MACRO'S * * Description : Convert data values to & from big-, little, or host-endian CPU word order. * * Argument(s) : val Data value to convert (see Notes #1 & #2). * * Return(s) : Converted data value (see Notes #1 & #2). * * Caller(s) : Application. * * Note(s) : (1) Convert data values to the desired data-word order : * * MEM_VAL_BIG_TO_LITTLE_xx() Convert big- endian data values * to little- endian data values * MEM_VAL_LITTLE_TO_BIG_xx() Convert little- endian data values * to big- endian data values * MEM_VAL_xxx_TO_HOST_xx() Convert big-/little-endian data values * to host- endian data values * MEM_VAL_HOST_TO_xxx_xx() Convert host- endian data values * to big-/little-endian data values * * See also 'cpu.h CPU WORD CONFIGURATION Note #2'. * * (2) 'val' data value to convert & any variable to receive the returned conversion MUST * start on appropriate CPU word-aligned addresses. * * See also 'MEMORY DATA VALUE MACRO'S Note #1a'. * * (3) MEM_VAL_COPY_xxx() macro's are more efficient than generic endian word order macro's & * are also independent of CPU data-word-alignment & SHOULD be used whenever possible. * * See also 'MEM_VAL_COPY_GET_xxx() Note #4' * & 'MEM_VAL_COPY_SET_xxx() Note #4'. * * (4) Generic endian word order macro's are NOT atomic operations & MUST NOT be used on any * non-static (i.e. volatile) variables, registers, hardware, etc.; without the caller of * the macro's providing some form of additional protection (e.g. mutual exclusion). * * (5) The 'CPU_CFG_ENDIAN_TYPE' pre-processor 'else'-conditional code SHOULD never be compiled/ * linked since each 'cpu.h' SHOULD ensure that the CPU data-word-memory order configuration * constant (CPU_CFG_ENDIAN_TYPE) is configured with an appropriate data-word-memory order * value (see 'cpu.h CPU WORD CONFIGURATION Note #2'). The 'else'-conditional code is * included as an extra precaution in case 'cpu.h' is incorrectly configured. ********************************************************************************************************* */ /*$PAGE*/ /*$PAGE*/ /* ********************************************************************************************************* * MEM_VAL_GET_xxx() * * Description : Decode data values from any CPU memory address. * * Argument(s) : addr Lowest CPU memory address of data value to decode (see Notes #2 & #3a). * * Return(s) : Decoded data value from CPU memory address (see Notes #1 & #3b). * * Caller(s) : Application. * * Note(s) : (1) Decode data values based on the values' data-word order in CPU memory : * * MEM_VAL_GET_xxx_BIG() Decode big- endian data values -- data words' most * significant octet @ lowest memory address * MEM_VAL_GET_xxx_LITTLE() Decode little-endian data values -- data words' least * significant octet @ lowest memory address * MEM_VAL_GET_xxx() Decode data values using CPU's native or configured * data-word order * * See also 'cpu.h CPU WORD CONFIGURATION Note #2'. * * (2) CPU memory addresses/pointers NOT checked for NULL. * * (3) (a) MEM_VAL_GET_xxx() macro's decode data values without regard to CPU word-aligned addresses. * Thus for processors that require data word alignment, data words can be decoded from any * CPU address, word-aligned or not, without generating data-word-alignment exceptions/faults. * * (b) However, any variable to receive the returned data value MUST start on an appropriate CPU * word-aligned address. * * See also 'MEMORY DATA VALUE MACRO'S Note #1'. * * (4) MEM_VAL_COPY_GET_xxx() macro's are more efficient than MEM_VAL_GET_xxx() macro's & are * also independent of CPU data-word-alignment & SHOULD be used whenever possible. * * See also 'MEM_VAL_COPY_GET_xxx() Note #4'. * * (5) MEM_VAL_GET_xxx() macro's are NOT atomic operations & MUST NOT be used on any non-static * (i.e. volatile) variables, registers, hardware, etc.; without the caller of the macro's * providing some form of additional protection (e.g. mutual exclusion). * * (6) The 'CPU_CFG_ENDIAN_TYPE' pre-processor 'else'-conditional code SHOULD never be compiled/ * linked since each 'cpu.h' SHOULD ensure that the CPU data-word-memory order configuration * constant (CPU_CFG_ENDIAN_TYPE) is configured with an appropriate data-word-memory order * value (see 'cpu.h CPU WORD CONFIGURATION Note #2'). The 'else'-conditional code is * included as an extra precaution in case 'cpu.h' is incorrectly configured. ********************************************************************************************************* */ /*$PAGE*/ /*$PAGE*/ /* ********************************************************************************************************* * MEM_VAL_SET_xxx() * * Description : Encode data values to any CPU memory address. * * Argument(s) : addr Lowest CPU memory address to encode data value (see Notes #2 & #3a). * * val Data value to encode (see Notes #1 & #3b). * * Return(s) : none. * * Caller(s) : Application. * * Note(s) : (1) Encode data values into CPU memory based on the values' data-word order : * * MEM_VAL_SET_xxx_BIG() Encode big- endian data values -- data words' most * significant octet @ lowest memory address * MEM_VAL_SET_xxx_LITTLE() Encode little-endian data values -- data words' least * significant octet @ lowest memory address * MEM_VAL_SET_xxx() Encode data values using CPU's native or configured * data-word order * * See also 'cpu.h CPU WORD CONFIGURATION Note #2'. * * (2) CPU memory addresses/pointers NOT checked for NULL. * * (3) (a) MEM_VAL_SET_xxx() macro's encode data values without regard to CPU word-aligned addresses. * Thus for processors that require data word alignment, data words can be encoded to any * CPU address, word-aligned or not, without generating data-word-alignment exceptions/faults. * * (b) However, 'val' data value to encode MUST start on an appropriate CPU word-aligned address. * * See also 'MEMORY DATA VALUE MACRO'S Note #1'. * * (4) MEM_VAL_COPY_SET_xxx() macro's are more efficient than MEM_VAL_SET_xxx() macro's & are * also independent of CPU data-word-alignment & SHOULD be used whenever possible. * * See also 'MEM_VAL_COPY_SET_xxx() Note #4'. * * (5) MEM_VAL_SET_xxx() macro's are NOT atomic operations & MUST NOT be used on any non-static * (i.e. volatile) variables, registers, hardware, etc.; without the caller of the macro's * providing some form of additional protection (e.g. mutual exclusion). * * (6) The 'CPU_CFG_ENDIAN_TYPE' pre-processor 'else'-conditional code SHOULD never be compiled/ * linked since each 'cpu.h' SHOULD ensure that the CPU data-word-memory order configuration * constant (CPU_CFG_ENDIAN_TYPE) is configured with an appropriate data-word-memory order * value (see 'cpu.h CPU WORD CONFIGURATION Note #2'). The 'else'-conditional code is * included as an extra precaution in case 'cpu.h' is incorrectly configured. ********************************************************************************************************* */ /*$PAGE*/ /*$PAGE*/ /* ********************************************************************************************************* * MEM_VAL_COPY_GET_xxx() * * Description : Copy & decode data values from any CPU memory address to any CPU memory address. * * Argument(s) : addr_dest Lowest CPU memory address to copy/decode source address's data value * (see Notes #2 & #3). * * addr_src Lowest CPU memory address of data value to copy/decode * (see Notes #2 & #3). * * Return(s) : none. * * Caller(s) : Application. * * Note(s) : (1) Copy/decode data values based on the values' data-word order : * * MEM_VAL_COPY_GET_xxx_BIG() Decode big- endian data values -- data words' most * significant octet @ lowest memory address * MEM_VAL_COPY_GET_xxx_LITTLE() Decode little-endian data values -- data words' least * significant octet @ lowest memory address * MEM_VAL_COPY_GET_xxx() Decode data values using CPU's native or configured * data-word order * * See also 'cpu.h CPU WORD CONFIGURATION Note #2'. * * (2) (a) CPU memory addresses/pointers NOT checked for NULL. * * (b) CPU memory addresses/buffers NOT checked for overlapping. * * (1) IEEE Std 1003.1, 2004 Edition, Section 'memcpy() : DESCRIPTION' states that * "copying ... between objects that overlap ... is undefined". * * (3) MEM_VAL_COPY_GET_xxx() macro's copy/decode data values without regard to CPU word-aligned * addresses. Thus for processors that require data word alignment, data words can be copied/ * decoded to/from any CPU address, word-aligned or not, without generating data-word-alignment * exceptions/faults. * * (4) MEM_VAL_COPY_GET_xxx() macro's are more efficient than MEM_VAL_GET_xxx() macro's & are * also independent of CPU data-word-alignment & SHOULD be used whenever possible. * * See also 'MEM_VAL_GET_xxx() Note #4'. * * (5) Since octet-order copy/conversion are inverse operations, MEM_VAL_COPY_GET_xxx() & * MEM_VAL_COPY_SET_xxx() macros are inverse, but identical, operations & are provided * in both forms for semantics & consistency. * * See also 'MEM_VAL_COPY_SET_xxx() Note #5'. * * (6) MEM_VAL_COPY_GET_xxx() macro's are NOT atomic operations & MUST NOT be used on any non- * static (i.e. volatile) variables, registers, hardware, etc.; without the caller of the * macro's providing some form of additional protection (e.g. mutual exclusion). * * (7) The 'CPU_CFG_ENDIAN_TYPE' pre-processor 'else'-conditional code SHOULD never be compiled/ * linked since each 'cpu.h' SHOULD ensure that the CPU data-word-memory order configuration * constant (CPU_CFG_ENDIAN_TYPE) is configured with an appropriate data-word-memory order * value (see 'cpu.h CPU WORD CONFIGURATION Note #2'). The 'else'-conditional code is * included as an extra precaution in case 'cpu.h' is incorrectly configured. ********************************************************************************************************* */ /*$PAGE*/ /*$PAGE*/ /* ********************************************************************************************************* * MEM_VAL_COPY_GET_INTU_xxx() * * Description : Copy & decode data values from any CPU memory address to any CPU memory address for * any sized data values. * * Argument(s) : addr_dest Lowest CPU memory address to copy/decode source address's data value * (see Notes #2 & #3). * * addr_src Lowest CPU memory address of data value to copy/decode * (see Notes #2 & #3). * * val_size Number of data value octets to copy/decode. * * Return(s) : none. * * Caller(s) : Application. * * Note(s) : (1) Copy/decode data values based on the values' data-word order : * * MEM_VAL_COPY_GET_INTU_BIG() Decode big- endian data values -- data words' most * significant octet @ lowest memory address * MEM_VAL_COPY_GET_INTU_LITTLE() Decode little-endian data values -- data words' least * significant octet @ lowest memory address * MEM_VAL_COPY_GET_INTU() Decode data values using CPU's native or configured * data-word order * * See also 'cpu.h CPU WORD CONFIGURATION Note #2'. * * (2) (a) CPU memory addresses/pointers NOT checked for NULL. * * (b) CPU memory addresses/buffers NOT checked for overlapping. * * (1) IEEE Std 1003.1, 2004 Edition, Section 'memcpy() : DESCRIPTION' states that * "copying ... between objects that overlap ... is undefined". * * (3) MEM_VAL_COPY_GET_INTU_xxx() macro's copy/decode data values without regard to CPU word- * aligned addresses. Thus for processors that require data word alignment, data words * can be copied/decoded to/from any CPU address, word-aligned or not, without generating * data-word-alignment exceptions/faults. * * (4) MEM_VAL_COPY_GET_xxx() macro's are more efficient than MEM_VAL_COPY_GET_INTU_xxx() * macro's & SHOULD be used whenever possible. * * See also 'MEM_VAL_COPY_GET_xxx() Note #4'. * * (5) Since octet-order copy/conversion are inverse operations, MEM_VAL_COPY_GET_INTU_xxx() & * MEM_VAL_COPY_SET_INTU_xxx() macros are inverse, but identical, operations & are provided * in both forms for semantics & consistency. * * See also 'MEM_VAL_COPY_SET_INTU_xxx() Note #5'. * * (6) MEM_VAL_COPY_GET_INTU_xxx() macro's are NOT atomic operations & MUST NOT be used on any * non-static (i.e. volatile) variables, registers, hardware, etc.; without the caller of * the macro's providing some form of additional protection (e.g. mutual exclusion). * * (7) MISRA-C 2004 Rule 5.2 states that "identifiers in an inner scope shall not use the same * name as an indentifier in an outer scope, and therefore hide that identifier". * * Therefore, to avoid possible redeclaration of commonly-used loop counter identifier names, * 'i' & 'j', MEM_VAL_COPY_GET_INTU_xxx() loop counter identifier names are prefixed with a * single underscore. * * (8) The 'CPU_CFG_ENDIAN_TYPE' pre-processor 'else'-conditional code SHOULD never be compiled/ * linked since each 'cpu.h' SHOULD ensure that the CPU data-word-memory order configuration * constant (CPU_CFG_ENDIAN_TYPE) is configured with an appropriate data-word-memory order * value (see 'cpu.h CPU WORD CONFIGURATION Note #2'). The 'else'-conditional code is * included as an extra precaution in case 'cpu.h' is incorrectly configured. ********************************************************************************************************* */ /*$PAGE*/ /*$PAGE*/ /* ********************************************************************************************************* * MEM_VAL_COPY_SET_xxx() * * Description : Copy & encode data values from any CPU memory address to any CPU memory address. * * Argument(s) : addr_dest Lowest CPU memory address to copy/encode source address's data value * (see Notes #2 & #3). * * addr_src Lowest CPU memory address of data value to copy/encode * (see Notes #2 & #3). * * Return(s) : none. * * Caller(s) : Application. * * Note(s) : (1) Copy/encode data values based on the values' data-word order : * * MEM_VAL_COPY_SET_xxx_BIG() Encode big- endian data values -- data words' most * significant octet @ lowest memory address * MEM_VAL_COPY_SET_xxx_LITTLE() Encode little-endian data values -- data words' least * significant octet @ lowest memory address * MEM_VAL_COPY_SET_xxx() Encode data values using CPU's native or configured * data-word order * * See also 'cpu.h CPU WORD CONFIGURATION Note #2'. * * (2) (a) CPU memory addresses/pointers NOT checked for NULL. * * (b) CPU memory addresses/buffers NOT checked for overlapping. * * (1) IEEE Std 1003.1, 2004 Edition, Section 'memcpy() : DESCRIPTION' states that * "copying ... between objects that overlap ... is undefined". * * (3) MEM_VAL_COPY_SET_xxx() macro's copy/encode data values without regard to CPU word-aligned * addresses. Thus for processors that require data word alignment, data words can be copied/ * encoded to/from any CPU address, word-aligned or not, without generating data-word-alignment * exceptions/faults. * * (4) MEM_VAL_COPY_SET_xxx() macro's are more efficient than MEM_VAL_SET_xxx() macro's & are * also independent of CPU data-word-alignment & SHOULD be used whenever possible. * * See also 'MEM_VAL_SET_xxx() Note #4'. * * (5) Since octet-order copy/conversion are inverse operations, MEM_VAL_COPY_GET_xxx() & * MEM_VAL_COPY_SET_xxx() macros are inverse, but identical, operations & are provided * in both forms for semantics & consistency. * * See also 'MEM_VAL_COPY_GET_xxx() Note #5'. * * (6) MEM_VAL_COPY_SET_xxx() macro's are NOT atomic operations & MUST NOT be used on any * non-static (i.e. volatile) variables, registers, hardware, etc.; without the caller * of the macro's providing some form of additional protection (e.g. mutual exclusion). ********************************************************************************************************* */ /* See Note #5. */ /*$PAGE*/ /* ********************************************************************************************************* * MEM_VAL_COPY_SET_INTU_xxx() * * Description : Copy & encode data values from any CPU memory address to any CPU memory address for * any sized data values. * * Argument(s) : addr_dest Lowest CPU memory address to copy/encode source address's data value * (see Notes #2 & #3). * * addr_src Lowest CPU memory address of data value to copy/encode * (see Notes #2 & #3). * * val_size Number of data value octets to copy/encode. * * Return(s) : none. * * Caller(s) : Application. * * Note(s) : (1) Copy/encode data values based on the values' data-word order : * * MEM_VAL_COPY_SET_INTU_BIG() Encode big- endian data values -- data words' most * significant octet @ lowest memory address * MEM_VAL_COPY_SET_INTU_LITTLE() Encode little-endian data values -- data words' least * significant octet @ lowest memory address * MEM_VAL_COPY_SET_INTU() Encode data values using CPU's native or configured * data-word order * * See also 'cpu.h CPU WORD CONFIGURATION Note #2'. * * (2) (a) CPU memory addresses/pointers NOT checked for NULL. * * (b) CPU memory addresses/buffers NOT checked for overlapping. * * (1) IEEE Std 1003.1, 2004 Edition, Section 'memcpy() : DESCRIPTION' states that * "copying ... between objects that overlap ... is undefined". * * (3) MEM_VAL_COPY_SET_INTU_xxx() macro's copy/encode data values without regard to CPU word- * aligned addresses. Thus for processors that require data word alignment, data words * can be copied/encoded to/from any CPU address, word-aligned or not, without generating * data-word-alignment exceptions/faults. * * (4) MEM_VAL_COPY_SET_xxx() macro's are more efficient than MEM_VAL_COPY_SET_INTU_xxx() * macro's & SHOULD be used whenever possible. * * See also 'MEM_VAL_COPY_SET_xxx() Note #4'. * * (5) Since octet-order copy/conversion are inverse operations, MEM_VAL_COPY_GET_INTU_xxx() & * MEM_VAL_COPY_SET_INTU_xxx() macros are inverse, but identical, operations & are provided * in both forms for semantics & consistency. * * See also 'MEM_VAL_COPY_GET_INTU_xxx() Note #5'. * * (6) MEM_VAL_COPY_SET_INTU_xxx() macro's are NOT atomic operations & MUST NOT be used on any * non-static (i.e. volatile) variables, registers, hardware, etc.; without the caller of * the macro's providing some form of additional protection (e.g. mutual exclusion). ********************************************************************************************************* */ /* See Note #5. */ /*$PAGE*/ /* ********************************************************************************************************* * MEM_VAL_COPY_xxx() * * Description : Copy data values from any CPU memory address to any CPU memory address. * * Argument(s) : addr_dest Lowest CPU memory address to copy source address's data value * (see Notes #2 & #3). * * addr_src Lowest CPU memory address of data value to copy * (see Notes #2 & #3). * * val_size Number of data value octets to copy. * * Return(s) : none. * * Caller(s) : Application. * * Note(s) : (1) MEM_VAL_COPY_xxx() macro's copy data values based on CPU's native data-word order. * * See also 'cpu.h CPU WORD CONFIGURATION Note #2'. * * (2) (a) CPU memory addresses/pointers NOT checked for NULL. * * (b) CPU memory addresses/buffers NOT checked for overlapping. * * (1) IEEE Std 1003.1, 2004 Edition, Section 'memcpy() : DESCRIPTION' states that * "copying ... between objects that overlap ... is undefined". * * (3) MEM_VAL_COPY_xxx() macro's copy data values without regard to CPU word-aligned addresses. * Thus for processors that require data word alignment, data words can be copied to/from any * CPU address, word-aligned or not, without generating data-word-alignment exceptions/faults. * * (4) MEM_VAL_COPY_xxx() macro's are more efficient than MEM_VAL_COPY() macro & SHOULD be * used whenever possible. * * (5) MEM_VAL_COPY_xxx() macro's are NOT atomic operations & MUST NOT be used on any non-static * (i.e. volatile) variables, registers, hardware, etc.; without the caller of the macro's * providing some form of additional protection (e.g. mutual exclusion). * * (6) MISRA-C 2004 Rule 5.2 states that "identifiers in an inner scope shall not use the same * name as an indentifier in an outer scope, and therefore hide that identifier". * * Therefore, to avoid possible redeclaration of commonly-used loop counter identifier name, * 'i', MEM_VAL_COPY() loop counter identifier name is prefixed with a single underscore. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * FUNCTION PROTOTYPES ********************************************************************************************************* */ void Mem_Init ( void); /* ---------------- MEM API FNCTS ---------------- */ void Mem_Clr ( void *pmem, CPU_SIZE_T size); void Mem_Set ( void *pmem, CPU_INT08U data_val, CPU_SIZE_T size); void Mem_Copy ( void *pdest, const void *psrc, CPU_SIZE_T size); void Mem_Move ( void *pdest, const void *psrc, CPU_SIZE_T size); CPU_BOOLEAN Mem_Cmp (const void *p1_mem, const void *p2_mem, CPU_SIZE_T size); /*$PAGE*/ /* ********************************************************************************************************* * CONFIGURATION ERRORS ********************************************************************************************************* */ /* ********************************************************************************************************* * LIBRARY CONFIGURATION ERRORS ********************************************************************************************************* */ /* See 'lib_mem.h Note #2a'. */ /*$PAGE*/ /* ********************************************************************************************************* * MODULE END * * Note(s) : (1) See 'lib_mem.h MODULE'. ********************************************************************************************************* */ /* ********************************************************************************************************* * uC/LIB * CUSTOM LIBRARY MODULES * * (c) Copyright 2004-2013; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/LIB is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * ASCII STRING MANAGEMENT * * Filename : lib_str.h * Version : V1.37.01 * Programmer(s) : ITJ * JDH ********************************************************************************************************* * Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software. * * (a) ALL standard library functions are implemented in the custom library modules : * * (1) \\lib_*.* * * (2) \\Ports\\\lib*_a.* * * where * directory path for custom library software * directory name for specific processor (CPU) * directory name for specific compiler * * (b) Product-specific library functions are implemented in individual products. ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE * * Note(s) : (1) This string library header file is protected from multiple pre-processor inclusion through * use of the string library module present pre-processor macro definition. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * ASCII STRING CONFIGURATION DEFINES * * Note(s) : (1) Some ASCII string configuration #define's MUST be available PRIOR to including any * application configuration (see 'INCLUDE FILES Note #1a'). ********************************************************************************************************* */ /* ********************************************************************************************************* * STRING FLOATING POINT DEFINES * * Note(s) : (1) (a) (1) The maximum accuracy for 32-bit floating-point numbers : * * * Maximum Accuracy log [Internal-Base ^ (Number-Internal-Base-Digits)] * 32-bit Floating-point Number = ----------------------------------------------------- * log [External-Base] * * log [2 ^ 24] * = -------------- * log [10] * * < 7.225 Base-10 Digits * * where * Internal-Base Internal number base of floating- * point numbers (i.e. 2) * External-Base External number base of floating- * point numbers (i.e. 10) * Number-Internal-Base-Digits Number of internal number base * significant digits (i.e. 24) * * (2) Also, since some 32-bit floating-point calculations are converted to 32-bit * unsigned numbers, the maximum accuracy is limited to the maximum accuracy * for 32-bit unsigned numbers of 9 digits. * * (b) Some CPUs' &/or compilers' floating-point implementations MAY further reduce the * maximum accuracy. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * INCLUDE FILES * * Note(s) : (1) The custom library software files are located in the following directories : * * (a) \\lib_cfg.h * * (b) \\lib_*.* * * where * directory path for Your Product's Application * directory path for custom library software * * (2) CPU-configuration software files are located in the following directories : * * (a) \\cpu_*.* * (b) \\\\cpu*.* * * where * directory path for common CPU-compiler software * directory name for specific processor (CPU) * directory name for specific compiler * * (3) Compiler MUST be configured to include as additional include path directories : * * (a) '\\' directory See Note #1a * * (b) '\\' directory See Note #1b * * (c) (1) '\\' directory See Note #2a * (2) '\\\\' directory See Note #2b * * (4) NO compiler-supplied standard library functions SHOULD be used. * * #### The reference to standard library header files SHOULD be removed once all custom * library functions are implemented WITHOUT reference to ANY standard library function(s). * * See also 'STANDARD LIBRARY MACRO'S Note #1'. ********************************************************************************************************* */ /* ********************************************************************************************************* * uC/LIB * CUSTOM LIBRARY MODULES * * (c) Copyright 2004-2013; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/LIB is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * ASCII CHARACTER OPERATIONS * * Filename : lib_ascii.h * Version : V1.37.01 * Programmer(s) : BAN ********************************************************************************************************* * Note(s) : (1) NO compiler-supplied standard library functions are used in library or product software. * * (a) ALL standard library functions are implemented in the custom library modules : * * (1) \\lib_*.* * * (2) \\Ports\\\lib*_a.* * * where * directory path for custom library software * directory name for specific processor (CPU) * directory name for specific compiler * * (b) Product-specific library functions are implemented in individual products. * * * (2) (a) ECMA-6 '7-Bit coded Character Set' (6th edition), which corresponds to the * 3rd edition of ISO 646, specifies several versions of a 7-bit character set : * * (1) THE GENERAL VERSION, which allows characters at 0x23 and 0x24 to be given a * set alternate form and allows the characters 0x40, 0x5B, 0x5D, 0x60, 0x7B & * 0x7D to be assigned a "unique graphic character" or to be declared as unused. * All other characters are explicitly specified. * * (2) THE INTERNATIONAL REFERENCE VERSION, which explicitly specifies all characters * in the 7-bit character set. * * (3) NATIONAL & APPLICATION-ORIENTED VERSIONS, which may be derived from the * standard in specified ways. * * (b) The character set represented in this file reproduces the Internation Reference * Version. This is identical to the 7-bit character set which occupies Unicode * characters 0x0000 through 0x007F. The character names are taken from v5.0 of the * Unicode specification, with certain abbreviations so that the resulting #define * names will not violate ANSI C naming restriction : * * (1) For the Latin capital & lowercase letters, the name components 'LETTER_CAPITAL' * & 'LETTER_SMALL' are replaced by 'UPPER' & 'LOWER', respectively. ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE * * Note(s) : (1) This ASCII library header file is protected from multiple pre-processor inclusion through * use of the ASCII library module present pre-processor macro definition. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * INCLUDE FILES * * Note(s) : (1) The custom library software files are located in the following directories : * * (a) \\lib_*.* * * where * directory path for custom library software * * (2) CPU-configuration software files are located in the following directories : * * (a) \\cpu_*.* * (b) \\\\cpu*.* * * where * directory path for common CPU-compiler software * directory name for specific processor (CPU) * directory name for specific compiler * * (3) Compiler MUST be configured to include as additional include path directories : * * (a) '\\' directory See Note #1a * * (b) (1) '\\' directory See Note #2a * (2) '\\\\' directory See Note #2b * * (4) NO compiler-supplied standard library functions SHOULD be used. ********************************************************************************************************* */ /* ********************************************************************************************************* * EXTERNS ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DEFINES ********************************************************************************************************* */ /* ********************************************************************************************************* * ASCII CHARACTER DEFINES ********************************************************************************************************* */ /* -------------------- C0 CONTROLS ------------------- */ /*$PAGE*/ /* ------------ ASCII PUNCTUATION & SYMBOLS ----------- */ /* ------------------- ASCII DIGITS ------------------- */ /* ------------ ASCII PUNCTUATION & SYMBOLS ----------- */ /*$PAGE*/ /* ------------- UPPERCASE LATIN ALPHABET ------------- */ /* ------------ ASCII PUNCTUATION & SYMBOLS ----------- */ /* ------------- LOWERCASE LATIN ALPHABET ------------- */ /* ------------ ASCII PUNCTUATION & SYMBOLS ----------- */ /* ---------------- CONTROL CHARACTERS ---------------- */ /*$PAGE*/ /* ********************************************************************************************************* * DATA TYPES ********************************************************************************************************* */ /* ********************************************************************************************************* * GLOBAL VARIABLES ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * MACRO'S ********************************************************************************************************* */ /* ********************************************************************************************************* * ASCII CHARACTER CLASSIFICATION MACRO's * * Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.(1) states that "character classification functions ... * return nonzero (true) if and only if the value of the argument 'c' conforms to ... the * description of the function." ********************************************************************************************************* */ /* ********************************************************************************************************* * ASCII_IS_DIG() * * Description : Determine whether a character is a decimal-digit character. * * Argument(s) : c Character to examine. * * Return(s) : DEF_YES, if character is a decimal-digit character. * * DEF_NO, if character is NOT a decimal-digit character. * * Caller(s) : Application. * * Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.5.(2) states that "isdigit() ... tests for any * decimal-digit character". ********************************************************************************************************* */ /* ********************************************************************************************************* * ASCII_IS_DIG_OCT() * * Description : Determine whether a character is an octal-digit character. * * Argument(s) : c Character to examine. * * Return(s) : DEF_YES, if character is an octal-digit character. * * DEF_NO, if character is NOT an octal-digit character. * * Caller(s) : Application. * * Note(s) : none. ********************************************************************************************************* */ /* ********************************************************************************************************* * ASCII_IS_DIG_HEX() * * Description : Determine whether a character is a hexadecimal-digit character. * * Argument(s) : c Character to examine. * * Return(s) : DEF_YES, if character is a hexadecimal-digit character. * * DEF_NO, if character is NOT a hexadecimal-digit character. * * Caller(s) : Application. * * Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.12.(2) states that "isxdigit() ... tests for any * hexadecimal-digit character". ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * ASCII_IS_LOWER() * * Description : Determine whether a character is a lowercase alphabetic character. * * Argument(s) : c Character to examine. * * Return(s) : DEF_YES, if character is a lowercase alphabetic character. * * DEF_NO, if character is NOT a lowercase alphabetic character. * * Caller(s) : Application. * * Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.7.(2) states that "islower() returns true only for * the lowercase letters". ********************************************************************************************************* */ /* ********************************************************************************************************* * ASCII_IS_UPPER() * * Description : Determine whether a character is an uppercase alphabetic character. * * Argument(s) : c Character to examine. * * Return(s) : DEF_YES, if character is an uppercase alphabetic character. * * DEF_NO, if character is NOT an uppercase alphabetic character. * * Caller(s) : Application. * * Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.11.(2) states that "isupper() returns true only for * the uppercase letters". ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * ASCII_IS_ALPHA() * * Description : Determine whether a character is an alphabetic character. * * Argument(s) : c Character to examine. * * Return(s) : DEF_YES, if character is an alphabetic character. * * DEF_NO, if character is NOT an alphabetic character. * * Caller(s) : Application. * * Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.2.(2) states that "isalpha() returns true only for the * characters for which isupper() or islower() is true". ********************************************************************************************************* */ /* ********************************************************************************************************* * ASCII_IS_ALPHA_NUM() * * Description : Determine whether a character is an alphanumeric character. * * Argument(s) : c Character to examine. * * Return(s) : DEF_YES, if character is an alphanumeric character. * * DEF_NO, if character is NOT an alphanumeric character. * * Caller(s) : Application. * * Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.1.(2) states that "isalnum() ... tests for any character * for which isalpha() or isdigit() is true". ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * ASCII_IS_BLANK() * * Description : Determine whether a character is a standard blank character. * * Argument(s) : c Character to examine. * * Return(s) : DEF_YES, if character is a standard blank character. * * DEF_NO, if character is NOT a standard blank character. * * Caller(s) : Application. * * Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.3.(2) states that "isblank() returns true only for * the standard blank characters". * * (b) ISO/IEC 9899:TC2, Section 7.4.1.3.(2) defines "the standard blank characters" as * the "space (' '), and horizontal tab ('\t')". ********************************************************************************************************* */ /* ********************************************************************************************************* * ASCII_IS_SPACE() * * Description : Determine whether a character is a white-space character. * * Argument(s) : c Character to examine. * * Return(s) : DEF_YES, if character is a white-space character. * * DEF_NO, if character is NOT a white-space character. * * Caller(s) : Application. * * Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.10.(2) states that "isspace() returns true only * for the standard white-space characters". * * (b) ISO/IEC 9899:TC2, Section 7.4.1.10.(2) defines "the standard white-space characters" * as the "space (' '), form feed ('\f'), new-line ('\n'), carriage return ('\r'), * horizontal tab ('\t'), and vertical tab ('\v')". ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * ASCII_IS_PRINT() * * Description : Determine whether a character is a printing character. * * Argument(s) : c Character to examine. * * Return(s) : DEF_YES, if character is a printing character. * * DEF_NO, if character is NOT a printing character. * * Caller(s) : Application. * * Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.8.(2) states that "isprint() ... tests for any * printing character including space (' ')". * * (b) ISO/IEC 9899:TC2, Section 7.4.(3), Note 169, states that in "the seven-bit US * ASCII character set, the printing characters are those whose values lie from * 0x20 (space) through 0x7E (tilde)". ********************************************************************************************************* */ /* ********************************************************************************************************* * ASCII_IS_GRAPH() * * Description : Determine whether a character is any printing character except a space character. * * Argument(s) : c Character to examine. * * Return(s) : DEF_YES, if character is a graphic character. * * DEF_NO, if character is NOT a graphic character. * * Caller(s) : Application. * * Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.6.(2) states that "isgraph() ... tests for any * printing character except space (' ')". * * (b) ISO/IEC 9899:TC2, Section 7.4.(3), Note 169, states that in "the seven-bit US * ASCII character set, the printing characters are those whose values lie from * 0x20 (space) through 0x7E (tilde)". ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * ASCII_IS_PUNCT() * * Description : Determine whether a character is a punctuation character. * * Argument(s) : c Character to examine. * * Return(s) : DEF_YES, if character is a punctuation character. * * DEF_NO, if character is NOT a punctuation character. * * Caller(s) : Application. * * Note(s) : (1) ISO/IEC 9899:TC2, Section 7.4.1.9.(2) states that "ispunct() returns true for every * printing character for which neither isspace() nor isalnum() is true". ********************************************************************************************************* */ /* ********************************************************************************************************* * ASCII_IS_CTRL() * * Description : Determine whether a character is a control character. * * Argument(s) : c Character to examine. * * Return(s) : DEF_YES, if character is a control character. * * DEF_NO, if character is NOT a control character. * * Caller(s) : Application. * * Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.1.4.(2) states that "iscntrl() ... tests for any * control character". * * (b) ISO/IEC 9899:TC2, Section 7.4.(3), Note 169, states that in "the seven-bit US * ASCII character set, ... the control characters are those whose values lie from * 0 (NUL) through 0x1F (US), and the character 0x7F (DEL)". ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * ASCII CHARACTER CASE MAPPING MACRO's ********************************************************************************************************* */ /* ********************************************************************************************************* * ASCII_TO_LOWER() * * Description : Convert uppercase alphabetic character to its corresponding lowercase alphabetic character. * * Argument(s) : c Character to convert. * * Return(s) : Lowercase equivalent of 'c', if character 'c' is an uppercase character (see Note #1b1). * * Character 'c', otherwise (see Note #1b2). * * Caller(s) : Application. * * Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.2.1.(2) states that "tolower() ... converts an * uppercase letter to a corresponding lowercase letter". * * (b) ISO/IEC 9899:TC2, Section 7.4.2.1.(3) states that : * * (1) (A) "if the argument is a character for which isupper() is true and there are * one or more corresponding characters ... for which islower() is true," ... * (B) "tolower() ... returns one of the corresponding characters;" ... * * (2) "otherwise, the argument is returned unchanged." ********************************************************************************************************* */ /* ********************************************************************************************************* * ASCII_TO_UPPER() * * Description : Convert lowercase alphabetic character to its corresponding uppercase alphabetic character. * * Argument(s) : c Character to convert. * * Return(s) : Uppercase equivalent of 'c', if character 'c' is a lowercase character (see Note #1b1). * * Character 'c', otherwise (see Note #1b2). * * Caller(s) : Application. * * Note(s) : (1) (a) ISO/IEC 9899:TC2, Section 7.4.2.2.(2) states that "toupper() ... converts a * lowercase letter to a corresponding uppercase letter". * * (b) ISO/IEC 9899:TC2, Section 7.4.2.2.(3) states that : * * (1) (A) "if the argument is a character for which islower() is true and there are * one or more corresponding characters ... for which isupper() is true," ... * (B) "toupper() ... returns one of the corresponding characters;" ... * * (2) "otherwise, the argument is returned unchanged." ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * FUNCTION PROTOTYPES ********************************************************************************************************* */ CPU_BOOLEAN ASCII_IsAlpha (CPU_CHAR c); CPU_BOOLEAN ASCII_IsAlphaNum(CPU_CHAR c); CPU_BOOLEAN ASCII_IsLower (CPU_CHAR c); CPU_BOOLEAN ASCII_IsUpper (CPU_CHAR c); CPU_BOOLEAN ASCII_IsDig (CPU_CHAR c); CPU_BOOLEAN ASCII_IsDigOct (CPU_CHAR c); CPU_BOOLEAN ASCII_IsDigHex (CPU_CHAR c); CPU_BOOLEAN ASCII_IsBlank (CPU_CHAR c); CPU_BOOLEAN ASCII_IsSpace (CPU_CHAR c); CPU_BOOLEAN ASCII_IsPrint (CPU_CHAR c); CPU_BOOLEAN ASCII_IsGraph (CPU_CHAR c); CPU_BOOLEAN ASCII_IsPunct (CPU_CHAR c); CPU_BOOLEAN ASCII_IsCtrl (CPU_CHAR c); CPU_CHAR ASCII_ToLower (CPU_CHAR c); CPU_CHAR ASCII_ToUpper (CPU_CHAR c); CPU_BOOLEAN ASCII_Cmp (CPU_CHAR c1, CPU_CHAR c2); /*$PAGE*/ /* ********************************************************************************************************* * CONFIGURATION ERRORS ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE END * * Note(s) : (1) See 'lib_ascii.h MODULE'. ********************************************************************************************************* */ /* ********************************************************************************************************* * EXTERNS ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DEFAULT CONFIGURATION ********************************************************************************************************* */ /* ********************************************************************************************************* * STRING FLOATING POINT CONFIGURATION * * Note(s) : (1) Configure LIB_STR_CFG_FP_EN to enable/disable floating point string function(s). * * (2) Configure LIB_STR_CFG_FP_MAX_NBR_DIG_SIG to configure the maximum number of significant * digits to calculate &/or display for floating point string function(s). * * See also 'STRING FLOATING POINT DEFINES Note #1'. ********************************************************************************************************* */ /* Configure floating point feature(s) [see Note #1] : */ /* Configure floating point feature(s)' number of ... */ /* ... significant digits (see Note #2). */ /* ********************************************************************************************************* * DEFINES ********************************************************************************************************* */ /* ********************************************************************************************************* * DATA TYPES ********************************************************************************************************* */ /* ********************************************************************************************************* * GLOBAL VARIABLES ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * MACRO'S ********************************************************************************************************* */ /* ********************************************************************************************************* * STANDARD LIBRARY MACRO'S * * Note(s) : (1) NO compiler-supplied standard library functions SHOULD be used. * * #### The reference to standard memory functions SHOULD be removed once all custom library * functions are implemented WITHOUT reference to ANY standard library function(s). * * See also 'INCLUDE FILES Note #3'. ********************************************************************************************************* */ /* See Note #1. */ /*$PAGE*/ /* ********************************************************************************************************* * FUNCTION PROTOTYPES ********************************************************************************************************* */ /* ------------------ STR LEN FNCTS ------------------ */ CPU_SIZE_T Str_Len (const CPU_CHAR *pstr); CPU_SIZE_T Str_Len_N (const CPU_CHAR *pstr, CPU_SIZE_T len_max); /* ------------------ STR COPY FNCTS ------------------ */ CPU_CHAR *Str_Copy ( CPU_CHAR *pstr_dest, const CPU_CHAR *pstr_src); CPU_CHAR *Str_Copy_N ( CPU_CHAR *pstr_dest, const CPU_CHAR *pstr_src, CPU_SIZE_T len_max); CPU_CHAR *Str_Cat ( CPU_CHAR *pstr_dest, const CPU_CHAR *pstr_cat); CPU_CHAR *Str_Cat_N ( CPU_CHAR *pstr_dest, const CPU_CHAR *pstr_cat, CPU_SIZE_T len_max); /* ------------------ STR CMP FNCTS ------------------ */ CPU_INT16S Str_Cmp (const CPU_CHAR *p1_str, const CPU_CHAR *p2_str); CPU_INT16S Str_Cmp_N (const CPU_CHAR *p1_str, const CPU_CHAR *p2_str, CPU_SIZE_T len_max); CPU_INT16S Str_CmpIgnoreCase (const CPU_CHAR *p1_str, const CPU_CHAR *p2_str); CPU_INT16S Str_CmpIgnoreCase_N(const CPU_CHAR *p1_str, const CPU_CHAR *p2_str, CPU_SIZE_T len_max); /* ------------------ STR SRCH FNCTS ------------------ */ CPU_CHAR *Str_Char (const CPU_CHAR *pstr, CPU_CHAR srch_char); CPU_CHAR *Str_Char_N (const CPU_CHAR *pstr, CPU_SIZE_T len_max, CPU_CHAR srch_char); CPU_CHAR *Str_Char_Last (const CPU_CHAR *pstr, CPU_CHAR srch_char); CPU_CHAR *Str_Char_Last_N (const CPU_CHAR *pstr, CPU_SIZE_T len_max, CPU_CHAR srch_char); CPU_CHAR *Str_Char_Replace ( CPU_CHAR *pstr, CPU_CHAR char_srch, CPU_CHAR char_replace); CPU_CHAR *Str_Char_Replace_N ( CPU_CHAR *pstr, CPU_CHAR char_srch, CPU_CHAR char_replace, CPU_SIZE_T len_max); CPU_CHAR *Str_Str (const CPU_CHAR *pstr, const CPU_CHAR *pstr_srch); CPU_CHAR *Str_Str_N (const CPU_CHAR *pstr, const CPU_CHAR *pstr_srch, CPU_SIZE_T len_max); /*$PAGE*/ /* ------------------ STR FMT FNCTS ------------------ */ CPU_CHAR *Str_FmtNbr_Int32U ( CPU_INT32U nbr, CPU_INT08U nbr_dig, CPU_INT08U nbr_base, CPU_CHAR lead_char, CPU_BOOLEAN lower_case, CPU_BOOLEAN nul, CPU_CHAR *pstr); CPU_CHAR *Str_FmtNbr_Int32S ( CPU_INT32S nbr, CPU_INT08U nbr_dig, CPU_INT08U nbr_base, CPU_CHAR lead_char, CPU_BOOLEAN lower_case, CPU_BOOLEAN nul, CPU_CHAR *pstr); /* ----------------- STR PARSE FNCTS ------------------ */ CPU_INT32U Str_ParseNbr_Int32U(const CPU_CHAR *pstr, CPU_CHAR **pstr_next, CPU_INT08U nbr_base); CPU_INT32S Str_ParseNbr_Int32S(const CPU_CHAR *pstr, CPU_CHAR **pstr_next, CPU_INT08U nbr_base); /*$PAGE*/ /* ********************************************************************************************************* * CONFIGURATION ERRORS ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE END * * Note(s) : (1) See 'lib_str.h MODULE'. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * CPU CONFIGURATION * * Note(s) : (1) The following pre-processor directives correctly configure CPU parameters. DO NOT MODIFY. * * (2) CPU timestamp timer feature is required for : * * (a) CPU timestamps * (b) CPU interrupts disabled time measurement * * See also 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #1' * & 'cpu_cfg.h CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION Note #1'. ********************************************************************************************************* */ //#else //#define CPU_CFG_TS_EN DEF_DISABLED //#else //#define CPU_CFG_TS_TMR_EN DEF_DISABLED /* ********************************************************************************************************* * DEFINES ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * DATA TYPES ********************************************************************************************************* */ /* ********************************************************************************************************* * CPU ERROR CODES ********************************************************************************************************* */ typedef enum cpu_err { CPU_ERR_NONE = 0u, CPU_ERR_NULL_PTR = 10u, CPU_ERR_NAME_SIZE = 1000u, CPU_ERR_TS_FREQ_INVALID = 2000u } CPU_ERR; /* ********************************************************************************************************* * CPU TIMESTAMP DATA TYPES * * Note(s) : (1) CPU timestamp timer data type defined to the binary-multiple of 8-bit octets as configured * by 'CPU_CFG_TS_TMR_SIZE' (see 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #2'). ********************************************************************************************************* */ typedef CPU_INT32U CPU_TS32; typedef CPU_INT64U CPU_TS64; typedef CPU_TS32 CPU_TS; /* Req'd for backwards-compatibility. */ typedef CPU_INT32U CPU_TS_TMR; /* ********************************************************************************************************* * CPU TIMESTAMP TIMER FREQUENCY DATA TYPE ********************************************************************************************************* */ typedef CPU_INT32U CPU_TS_TMR_FREQ; /* ********************************************************************************************************* * GLOBAL VARIABLES ********************************************************************************************************* */ extern CPU_CHAR CPU_Name[16]; /* CPU host name. */ extern CPU_TS_TMR_FREQ CPU_TS_TmrFreq_Hz; /* CPU ts tmr freq (in Hz). */ extern CPU_INT16U CPU_IntDisMeasCtr; /* Nbr tot ints dis'd ctr. */ extern CPU_INT16U CPU_IntDisNestCtr; /* Nbr nested ints dis'd ctr. */ /* Ints dis'd time (in ts tmr cnts) : ... */ extern CPU_TS_TMR CPU_IntDisMeasStart_cnts; /* ... start time. */ extern CPU_TS_TMR CPU_IntDisMeasStop_cnts; /* ... stop time. */ extern CPU_TS_TMR CPU_IntDisMeasOvrhd_cnts; /* ... time meas ovrhd. */ extern CPU_TS_TMR CPU_IntDisMeasMaxCur_cnts; /* ... resetable max time dis'd. */ extern CPU_TS_TMR CPU_IntDisMeasMax_cnts; /* ... non-resetable max time dis'd. */ /*$PAGE*/ /* ********************************************************************************************************* * MACRO'S ********************************************************************************************************* */ /* ********************************************************************************************************* * CPU_SW_EXCEPTION() * * Description : Trap unrecoverable software exception. * * Argument(s) : err_rtn_val Error type &/or value of the calling function to return (see Note #2b). * * Return(s) : none. * * Caller(s) : various. * * Note(s) : (1) CPU_SW_EXCEPTION() deadlocks the current code execution -- whether multi-tasked/ * -processed/-threaded or single-threaded -- when the current code execution cannot * gracefully recover or report a fault or exception condition. * * Example CPU_SW_EXCEPTION() call : * * void Fnct (CPU_ERR *p_err) * { * : * * if (p_err == (CPU_ERR *)0) { If 'p_err' NULL, cannot return error ... * CPU_SW_EXCEPTION(;); ... so trap invalid argument exception. * } * * : * } * * See also 'cpu_core.c CPU_SW_Exception() Note #1'. * * (2) (a) CPU_SW_EXCEPTION() MAY be developer-implemented to output &/or handle any error or * exception conditions; but since CPU_SW_EXCEPTION() is intended to trap unrecoverable * software conditions, it is recommended that developer-implemented versions prevent * execution of any code following calls to CPU_SW_EXCEPTION() by deadlocking the code * (see Note #1). * * Example CPU_SW_EXCEPTION() : * * #define CPU_SW_EXCEPTION(err_rtn_val) do { * Log(__FILE__, __LINE__); * CPU_SW_Exception(); * } while (0) * * (b) (1) However, if execution of code following calls to CPU_SW_EXCEPTION() is required * (e.g. for automated testing); it is recommended that the last statement in * developer-implemented versions be to return from the current function to prevent * possible software exception(s) in the current function from triggering CPU &/or * hardware exception(s). * * Example CPU_SW_EXCEPTION() : * * #define CPU_SW_EXCEPTION(err_rtn_val) do { * Log(__FILE__, __LINE__); * return err_rtn_val; * } while (0) * * (A) Note that 'err_rtn_val' in the return statement MUST NOT be enclosed in * parentheses. This allows CPU_SW_EXCEPTION() to return from functions that * return 'void', i.e. NO return type or value (see also Note #2b2A). *$PAGE* * (2) In order for CPU_SW_EXCEPTION() to return from functions with various return * types/values, each caller function MUST pass an appropriate error return type * & value to CPU_SW_EXCEPTION(). * * (A) Note that CPU_SW_EXCEPTION() MUST NOT be passed any return type or value * for functions that return 'void', i.e. NO return type or value; but SHOULD * instead be passed a single semicolon. This prevents possible compiler * warnings that CPU_SW_EXCEPTION() is passed too few arguments. However, * the compiler may warn that CPU_SW_EXCEPTION() does NOT prevent creating * null statements on lines with NO other code statements. * * Example CPU_SW_EXCEPTION() calls : * * void Fnct (CPU_ERR *p_err) * { * : * * if (p_err == (CPU_ERR *)0) { * CPU_SW_EXCEPTION(;); Exception macro returns NO value * } (see Note #2b2A) * * : * } * * CPU_BOOLEAN Fnct (CPU_ERR *p_err) * { * : * * if (p_err == (CPU_ERR *)0) { * CPU_SW_EXCEPTION(DEF_FAIL); Exception macro returns 'DEF_FAIL' * } * * : * } * * OBJ *Fnct (CPU_ERR *p_err) * { * : * * if (p_err == (CPU_ERR *)0) { * CPU_SW_EXCEPTION((OBJ *)0); Exception macro returns NULL 'OBJ *' * } * * : * } * ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * CPU_VAL_UNUSED() * * Description : * * Argument(s) : none. * * Return(s) : none. * * Caller(s) : #### various. * * Note(s) : none. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * CPU_TYPE_CREATE() * * Description : Creates a generic type value. * * Argument(s) : char_1 1st ASCII character to create generic type value. * * char_2 2nd ASCII character to create generic type value. * * char_3 3rd ASCII character to create generic type value. * * char_4 4th ASCII character to create generic type value. * * Return(s) : 32-bit generic type value. * * Caller(s) : various. * * Note(s) : (1) (a) Generic type values should be #define'd with large, non-trivial values to trap * & discard invalid/corrupted objects based on type value. * * In other words, by assigning large, non-trivial values to valid objects' type * fields; the likelihood that an object with an unassigned &/or corrupted type * field will contain a value is highly improbable & therefore the object itself * will be trapped as invalid. * * (b) (1) CPU_TYPE_CREATE() creates a 32-bit type value from four values. * * (2) Ideally, generic type values SHOULD be created from 'CPU_CHAR' characters to * represent ASCII string abbreviations of the specific object types. Memory * displays of object type values will display the specific object types with * their chosen ASCII names. * * Examples : * * #define FILE_TYPE CPU_TYPE_CREATE('F', 'I', 'L', 'E') * #define BUF_TYPE CPU_TYPE_CREATE('B', 'U', 'F', ' ') ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * FUNCTION PROTOTYPES * * Note(s) : (1) CPU interrupts disabled time measurement functions prototyped/defined only if * CPU_CFG_INT_DIS_MEAS_EN #define'd in 'cpu_cfg.h'. * * (2) (a) CPU_CntLeadZeros() defined in : * * (1) 'cpu_a.asm', if CPU_CFG_LEAD_ZEROS_ASM_PRESENT #define'd in 'cpu.h'/ * 'cpu_cfg.h' to enable assembly-optimized function(s) * * (2) 'cpu_core.c', if CPU_CFG_LEAD_ZEROS_ASM_PRESENT NOT #define'd in 'cpu.h'/ * 'cpu_cfg.h' to enable C-source-optimized function(s) * * (b) CPU_CntTrailZeros() defined in : * * (1) 'cpu_a.asm', if CPU_CFG_TRAIL_ZEROS_ASM_PRESENT #define'd in 'cpu.h'/ * 'cpu_cfg.h' to enable assembly-optimized function(s) * * (2) 'cpu_core.c', if CPU_CFG_TRAIL_ZEROS_ASM_PRESENT NOT #define'd in 'cpu.h'/ * 'cpu_cfg.h' to enable C-source-optimized function(s) ********************************************************************************************************* */ void CPU_Init (void); void CPU_SW_Exception (void); void CPU_NameClr (void); void CPU_NameGet ( CPU_CHAR *p_name, CPU_ERR *p_err); void CPU_NameSet (const CPU_CHAR *p_name, CPU_ERR *p_err); /* --------------- CPU TS FNCTS --------------- */ CPU_TS32 CPU_TS_Get32 (void); void CPU_TS_Update (void); CPU_TS_TMR_FREQ CPU_TS_TmrFreqGet (CPU_ERR *p_err); void CPU_TS_TmrFreqSet (CPU_TS_TMR_FREQ freq_hz); /* See Note #1. */ CPU_TS_TMR CPU_IntDisMeasMaxCurReset(void); CPU_TS_TMR CPU_IntDisMeasMaxCurGet (void); CPU_TS_TMR CPU_IntDisMeasMaxGet (void); void CPU_IntDisMeasStart (void); void CPU_IntDisMeasStop (void); /* ----------- CPU CNT ZEROS FNCTS ------------ */ CPU_DATA CPU_CntLeadZeros (CPU_DATA val); CPU_DATA CPU_CntLeadZeros08 (CPU_INT08U val); CPU_DATA CPU_CntLeadZeros16 (CPU_INT16U val); CPU_DATA CPU_CntLeadZeros32 (CPU_INT32U val); CPU_DATA CPU_CntLeadZeros64 (CPU_INT64U val); CPU_DATA CPU_CntTrailZeros (CPU_DATA val); CPU_DATA CPU_CntTrailZeros08 (CPU_INT08U val); CPU_DATA CPU_CntTrailZeros16 (CPU_INT16U val); CPU_DATA CPU_CntTrailZeros32 (CPU_INT32U val); CPU_DATA CPU_CntTrailZeros64 (CPU_INT64U val); /*$PAGE*/ /* ********************************************************************************************************* * FUNCTION PROTOTYPES * DEFINED IN PRODUCT'S BSP ********************************************************************************************************* */ /* ********************************************************************************************************* * CPU_TS_TmrInit() * * Description : Initialize & start CPU timestamp timer. * * Argument(s) : none. * * Return(s) : none. * * Caller(s) : CPU_TS_Init(). * * This function is an INTERNAL CPU module function & MUST be implemented by application/ * BSP function(s) [see Note #1] but MUST NOT be called by application function(s). * * Note(s) : (1) CPU_TS_TmrInit() is an application/BSP function that MUST be defined by the developer * if either of the following CPU features is enabled : * * (a) CPU timestamps * (b) CPU interrupts disabled time measurements * * See 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #1' * & 'cpu_cfg.h CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION Note #1a'. * * (2) (a) Timer count values MUST be returned via word-size-configurable 'CPU_TS_TMR' * data type. * * (1) If timer has more bits, truncate timer values' higher-order bits greater * than the configured 'CPU_TS_TMR' timestamp timer data type word size. * * (2) Since the timer MUST NOT have less bits than the configured 'CPU_TS_TMR' * timestamp timer data type word size; 'CPU_CFG_TS_TMR_SIZE' MUST be * configured so that ALL bits in 'CPU_TS_TMR' data type are significant. * * In other words, if timer size is not a binary-multiple of 8-bit octets * (e.g. 20-bits or even 24-bits), then the next lower, binary-multiple * octet word size SHOULD be configured (e.g. to 16-bits). However, the * minimum supported word size for CPU timestamp timers is 8-bits. * * See also 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #2' * & 'cpu_core.h CPU TIMESTAMP DATA TYPES Note #1'. * * (b) Timer SHOULD be an 'up' counter whose values increase with each time count. * * (c) When applicable, timer period SHOULD be less than the typical measured time * but MUST be less than the maximum measured time; otherwise, timer resolution * inadequate to measure desired times. * * See also 'CPU_TS_TmrRd() Note #2'. ********************************************************************************************************* */ void CPU_TS_TmrInit(void); /*$PAGE*/ /* ********************************************************************************************************* * CPU_TS_TmrRd() * * Description : Get current CPU timestamp timer count value. * * Argument(s) : none. * * Return(s) : Timestamp timer count (see Notes #2a & #2b). * * Caller(s) : CPU_TS_Init(), * CPU_TS_Get32(), * CPU_TS_Get64(), * CPU_IntDisMeasStart(), * CPU_IntDisMeasStop(). * * This function is an INTERNAL CPU module function & MUST be implemented by application/ * BSP function(s) [see Note #1] but SHOULD NOT be called by application function(s). * * Note(s) : (1) CPU_TS_TmrRd() is an application/BSP function that MUST be defined by the developer * if either of the following CPU features is enabled : * * (a) CPU timestamps * (b) CPU interrupts disabled time measurements * * See 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #1' * & 'cpu_cfg.h CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION Note #1a'. * * (2) (a) Timer count values MUST be returned via word-size-configurable 'CPU_TS_TMR' * data type. * * (1) If timer has more bits, truncate timer values' higher-order bits greater * than the configured 'CPU_TS_TMR' timestamp timer data type word size. * * (2) Since the timer MUST NOT have less bits than the configured 'CPU_TS_TMR' * timestamp timer data type word size; 'CPU_CFG_TS_TMR_SIZE' MUST be * configured so that ALL bits in 'CPU_TS_TMR' data type are significant. * * In other words, if timer size is not a binary-multiple of 8-bit octets * (e.g. 20-bits or even 24-bits), then the next lower, binary-multiple * octet word size SHOULD be configured (e.g. to 16-bits). However, the * minimum supported word size for CPU timestamp timers is 8-bits. * * See also 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #2' * & 'cpu_core.h CPU TIMESTAMP DATA TYPES Note #1'. * * (b) Timer SHOULD be an 'up' counter whose values increase with each time count. * * (1) If timer is a 'down' counter whose values decrease with each time count, * then the returned timer value MUST be ones-complemented. * * (c) (1) When applicable, the amount of time measured by CPU timestamps is * calculated by either of the following equations : * * (A) Time measured = Number timer counts * Timer period * * where * * Number timer counts Number of timer counts measured * Timer period Timer's period in some units of * (fractional) seconds * Time measured Amount of time measured, in same * units of (fractional) seconds * as the Timer period * * Number timer counts * (B) Time measured = --------------------- * Timer frequency * * where * * Number timer counts Number of timer counts measured * Timer frequency Timer's frequency in some units * of counts per second * Time measured Amount of time measured, in seconds * * (2) Timer period SHOULD be less than the typical measured time but MUST be less * than the maximum measured time; otherwise, timer resolution inadequate to * measure desired times. ********************************************************************************************************* */ CPU_TS_TMR CPU_TS_TmrRd(void); /*$PAGE*/ /* ********************************************************************************************************* * CPU_TSxx_to_uSec() * * Description : Convert a 32-/64-bit CPU timestamp from timer counts to microseconds. * * Argument(s) : ts_cnts CPU timestamp (in timestamp timer counts [see Note #2aA]). * * Return(s) : Converted CPU timestamp (in microseconds [see Note #2aD]). * * Caller(s) : Application. * * This function is an (optional) CPU module application programming interface (API) * function which MAY be implemented by application/BSP function(s) [see Note #1] & * MAY be called by application function(s). * * Note(s) : (1) CPU_TS32_to_uSec()/CPU_TS64_to_uSec() are application/BSP functions that MAY be * optionally defined by the developer when either of the following CPU features is * enabled : * * (a) CPU timestamps * (b) CPU interrupts disabled time measurements * * See 'cpu_cfg.h CPU TIMESTAMP CONFIGURATION Note #1' * & 'cpu_cfg.h CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION Note #1a'. * * (2) (a) The amount of time measured by CPU timestamps is calculated by either of * the following equations : * * 10^6 microseconds * (1) Time measured = Number timer counts * ------------------- * Timer period * 1 second * * Number timer counts 10^6 microseconds * (2) Time measured = --------------------- * ------------------- * Timer frequency 1 second * * where * * (A) Number timer counts Number of timer counts measured * (B) Timer frequency Timer's frequency in some units * of counts per second * (C) Timer period Timer's period in some units of * (fractional) seconds * (D) Time measured Amount of time measured, * in microseconds * * (b) Timer period SHOULD be less than the typical measured time but MUST be less * than the maximum measured time; otherwise, timer resolution inadequate to * measure desired times. * * (c) Specific implementations may convert any number of CPU_TS32 or CPU_TS64 bits * -- up to 32 or 64, respectively -- into microseconds. ********************************************************************************************************* */ CPU_INT64U CPU_TS32_to_uSec(CPU_TS32 ts_cnts); /*$PAGE*/ /* ********************************************************************************************************* * CONFIGURATION ERRORS ********************************************************************************************************* */ /* Correctly configured in 'cpu_core.h'; DO NOT MODIFY. */ /*$PAGE*/ /* Correctly configured in 'cpu_core.h'; DO NOT MODIFY. */ /*$PAGE*/ /* ********************************************************************************************************* * CPU PORT CONFIGURATION ERRORS ********************************************************************************************************* */ /* ********************************************************************************************************* * LIBRARY CONFIGURATION ERRORS ********************************************************************************************************* */ /* See 'cpu_core.h Note #1a'. */ /* ********************************************************************************************************* * MODULE END * * Note(s) : (1) See 'cpu_core.h MODULE'. ********************************************************************************************************* */ /* ************************************************************************************************************************ * uC/OS-III * The Real-Time Kernel * * (c) Copyright 2009-2011; Micrium, Inc.; Weston, FL * All rights reserved. Protected by international copyright laws. * * File : OS_TYPE.H * By : JJL * Version : V3.02.00 * * LICENSING TERMS: * --------------- * uC/OS-III is provided in source form for FREE short-term evaluation, for educational use or * for peaceful research. If you plan or intend to use uC/OS-III in a commercial application/ * product then, you need to contact Micrium to properly license uC/OS-III for its use in your * application/product. We provide ALL the source code for your convenience and to help you * experience uC/OS-III. The fact that the source is provided does NOT mean that you can use * it commercially without paying a licensing fee. * * Knowledge of the source code may NOT be used to develop a similar product. * * Please help us continue to provide the embedded community with the finest software available. * Your honesty is greatly appreciated. * * You can contact us at www.micrium.com, or by phone at +1 (954) 217-2036. ************************************************************************************************************************ */ /* ************************************************************************************************************************ * INCLUDE HEADER FILES ************************************************************************************************************************ */ /* Description # Bits */ /* */ /* ----------------------------------------------------------- */ typedef CPU_INT08U OS_CPU_USAGE; /* CPU Usage 0..100% <8>/16/32 */ typedef CPU_INT32U OS_CTR; /* Counter, 32 */ typedef CPU_INT32U OS_CTX_SW_CTR; /* Counter of context switches, 32 */ typedef CPU_INT32U OS_CYCLES; /* CPU clock cycles, <32>/64 */ typedef CPU_INT32U OS_FLAGS; /* Event flags, 8/16/<32> */ typedef CPU_INT32U OS_IDLE_CTR; /* Holds the number of times the idle task runs, <32>/64 */ typedef CPU_INT16U OS_MEM_QTY; /* Number of memory blocks, <16>/32 */ typedef CPU_INT16U OS_MEM_SIZE; /* Size in bytes of a memory block, <16>/32 */ typedef CPU_INT16U OS_MSG_QTY; /* Number of OS_MSGs in the msg pool, <16>/32 */ typedef CPU_INT16U OS_MSG_SIZE; /* Size of messages in number of bytes, <16>/32 */ typedef CPU_INT08U OS_NESTING_CTR; /* Interrupt and scheduler nesting, <8>/16/32 */ typedef CPU_INT16U OS_OBJ_QTY; /* Number of kernel objects counter, <16>/32 */ typedef CPU_INT32U OS_OBJ_TYPE; /* Special flag to determine object type, 32 */ typedef CPU_INT16U OS_OPT; /* Holds function options <16>/32 */ typedef CPU_INT08U OS_PRIO; /* Priority of a task, <8>/16/32 */ typedef CPU_INT16U OS_QTY; /* Quantity <16>/32 */ typedef CPU_INT32U OS_RATE_HZ; /* Rate in Hertz 32 */ typedef CPU_INT32U OS_REG; /* Task register 8/16/<32> */ typedef CPU_INT08U OS_REG_ID; /* Index to task register <8>/16/32 */ typedef CPU_INT32U OS_SEM_CTR; /* Semaphore value 16/<32> */ typedef CPU_INT08U OS_STATE; /* State variable <8>/16/32 */ typedef CPU_INT08U OS_STATUS; /* Status <8>/16/32 */ typedef CPU_INT32U OS_TICK; /* Clock tick counter <32>/64 */ typedef CPU_INT16U OS_TICK_SPOKE_IX; /* Tick wheel spoke position 8/<16>/32 */ typedef CPU_INT16U OS_TMR_SPOKE_IX; /* Timer wheel spoke position 8/<16>/32 */ /* ********************************************************************************************************* * include ********************************************************************************************************* */ //Jimmy#include /* ********************************************************************************************************* * IRQ中?堆?大小 ********************************************************************************************************* */ extern CPU_STK OS_CPU_ExceptStk[768u]; extern CPU_STK *OS_CPU_ExceptStkBase; extern CPU_STK *OS_CPU_ExceptStkPtr; /* ********************************************************************************************************* * DEFINES ********************************************************************************************************* */ /* ********************************************************************************************************* * ARM EXCEPTION DEFINES ********************************************************************************************************* */ /* ARM exception IDs */ /* ARM exception vectors addresses */ /* ARM exception handlers addresses */ /* ARM "Jump To Self" asm instruction */ /* ARM "Jump To Exception Handler" asm instruction */ /* ********************************************************************************************************* * MACROS ********************************************************************************************************* */ /* ********************************************************************************************************* * TIMESTAMP CONFIGURATION * * Note(s) : (1) OS_TS_GET() is generally defined as CPU_TS_Get32() to allow CPU timestamp timer to be of * any data type size. * * (2) For architectures that provide 32-bit or higher precision free running counters * (i.e. cycle count registers): * * (a) OS_TS_GET() may be defined as CPU_TS_TmrRd() to improve performance when retrieving * the timestamp. * * (b) CPU_TS_TmrRd() MUST be configured to be greater or equal to 32-bits to avoid * truncation of TS. ********************************************************************************************************* */ /* ********************************************************************************************************* * FUNCTION PROTOTYPES ********************************************************************************************************* */ void OSCtxSw (void); void OSIntCtxSw (void); void OSStartHighRdy (void); void OS_CPU_ARM_ExceptUndefInstrHndlr (void); void OS_CPU_ARM_ExceptSwiHndlr (void); void OS_CPU_ARM_ExceptPrefetchAbortHndlr(void); void OS_CPU_ARM_ExceptDataAbortHndlr (void); void OS_CPU_ARM_ExceptIrqHndlr (void); void OS_CPU_ARM_ExceptFiqHndlr (void); void OS_CPU_IntHandler (CPU_INT32U src_id); void OS_CPU_InitExceptVect (void); CPU_INT32U OS_CPU_ExceptStkChk (void); /* ************************************************************************************************************************ * CRITICAL SECTION HANDLING ************************************************************************************************************************ */ /* ************************************************************************************************************************ * MISCELLANEOUS ************************************************************************************************************************ */ /*$PAGE*/ /* ************************************************************************************************************************ ************************************************************************************************************************ * # D E F I N E S ************************************************************************************************************************ ************************************************************************************************************************ */ /* ======================================================================================================================== * TASK STATUS ======================================================================================================================== */ /* ------------------- TASK STATES ------------------ */ /* | */ /* | | */ /* | | | */ /* V V V */ /* ----------------- PENDING ON ... ----------------- */ /* ------------------------------------------------------------------------------------------------------------------------ * TASK PEND STATUS * (Status codes for OS_TCBs field .PendStatus) ------------------------------------------------------------------------------------------------------------------------ */ /* ======================================================================================================================== * OS OBJECT TYPES * * Note(s) : (1) OS_OBJ_TYPE_&&& #define values specifically chosen as ASCII representations of the kernel * object types. Memory displays of kernel objects will display the kernel object TYPEs with * their chosen ASCII names. ======================================================================================================================== */ /* ======================================================================================================================== * Possible values for 'opt' argument ======================================================================================================================== */ /* ------------------------------------------------------------------------------------------------------------------------ * DELETE OPTIONS ------------------------------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------------------------------ * PEND OPTIONS ------------------------------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------------------------------ * PEND ABORT OPTIONS ------------------------------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------------------------------ * POST OPTIONS ------------------------------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------------------------------ * TASK OPTIONS ------------------------------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------------------------------ * TIME OPTIONS ------------------------------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------------------------------ * TIMER OPTIONS ------------------------------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------------------------------ * TIMER STATES ------------------------------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------------------------------ * PRIORITY ------------------------------------------------------------------------------------------------------------------------ */ /* Dflt prio to init task TCB */ /* ------------------------------------------------------------------------------------------------------------------------ * TIMER TICK THRESHOLDS ------------------------------------------------------------------------------------------------------------------------ */ /* Threshold to init previous tick time */ /* Threshold to check if tick time already ready */ /*$PAGE*/ /* ************************************************************************************************************************ ************************************************************************************************************************ * E N U M E R A T I O N S ************************************************************************************************************************ ************************************************************************************************************************ */ /* ------------------------------------------------------------------------------------------------------------------------ * ERROR CODES ------------------------------------------------------------------------------------------------------------------------ */ typedef enum os_err { OS_ERR_NONE = 0u, OS_ERR_A = 10000u, OS_ERR_ACCEPT_ISR = 10001u, OS_ERR_B = 11000u, OS_ERR_C = 12000u, OS_ERR_CREATE_ISR = 12001u, OS_ERR_D = 13000u, OS_ERR_DEL_ISR = 13001u, OS_ERR_E = 14000u, OS_ERR_F = 15000u, OS_ERR_FATAL_RETURN = 15001u, OS_ERR_FLAG_GRP_DEPLETED = 15101u, OS_ERR_FLAG_NOT_RDY = 15102u, OS_ERR_FLAG_PEND_OPT = 15103u, OS_ERR_FLUSH_ISR = 15104u, OS_ERR_G = 16000u, OS_ERR_H = 17000u, OS_ERR_I = 18000u, OS_ERR_ILLEGAL_CREATE_RUN_TIME = 18001u, OS_ERR_INT_Q = 18002u, OS_ERR_INT_Q_FULL = 18003u, OS_ERR_INT_Q_SIZE = 18004u, OS_ERR_J = 19000u, OS_ERR_K = 20000u, OS_ERR_L = 21000u, OS_ERR_LOCK_NESTING_OVF = 21001u, OS_ERR_M = 22000u, OS_ERR_MEM_CREATE_ISR = 22201u, OS_ERR_MEM_FULL = 22202u, OS_ERR_MEM_INVALID_P_ADDR = 22203u, OS_ERR_MEM_INVALID_BLKS = 22204u, OS_ERR_MEM_INVALID_PART = 22205u, OS_ERR_MEM_INVALID_P_BLK = 22206u, OS_ERR_MEM_INVALID_P_MEM = 22207u, OS_ERR_MEM_INVALID_P_DATA = 22208u, OS_ERR_MEM_INVALID_SIZE = 22209u, OS_ERR_MEM_NO_FREE_BLKS = 22210u, OS_ERR_MSG_POOL_EMPTY = 22301u, OS_ERR_MSG_POOL_NULL_PTR = 22302u, OS_ERR_MUTEX_NOT_OWNER = 22401u, OS_ERR_MUTEX_OWNER = 22402u, OS_ERR_MUTEX_NESTING = 22403u, OS_ERR_N = 23000u, OS_ERR_NAME = 23001u, OS_ERR_O = 24000u, OS_ERR_OBJ_CREATED = 24001u, OS_ERR_OBJ_DEL = 24002u, OS_ERR_OBJ_PTR_NULL = 24003u, OS_ERR_OBJ_TYPE = 24004u, OS_ERR_OPT_INVALID = 24101u, OS_ERR_OS_NOT_RUNNING = 24201u, OS_ERR_OS_RUNNING = 24202u, OS_ERR_P = 25000u, OS_ERR_PEND_ABORT = 25001u, OS_ERR_PEND_ABORT_ISR = 25002u, OS_ERR_PEND_ABORT_NONE = 25003u, OS_ERR_PEND_ABORT_SELF = 25004u, OS_ERR_PEND_DEL = 25005u, OS_ERR_PEND_ISR = 25006u, OS_ERR_PEND_LOCKED = 25007u, OS_ERR_PEND_WOULD_BLOCK = 25008u, OS_ERR_POST_NULL_PTR = 25101u, OS_ERR_POST_ISR = 25102u, OS_ERR_PRIO_EXIST = 25201u, OS_ERR_PRIO = 25202u, OS_ERR_PRIO_INVALID = 25203u, OS_ERR_PTR_INVALID = 25301u, OS_ERR_Q = 26000u, OS_ERR_Q_FULL = 26001u, OS_ERR_Q_EMPTY = 26002u, OS_ERR_Q_MAX = 26003u, OS_ERR_Q_SIZE = 26004u, OS_ERR_R = 27000u, OS_ERR_REG_ID_INVALID = 27001u, OS_ERR_ROUND_ROBIN_1 = 27002u, OS_ERR_ROUND_ROBIN_DISABLED = 27003u, OS_ERR_S = 28000u, OS_ERR_SCHED_INVALID_TIME_SLICE = 28001u, OS_ERR_SCHED_LOCK_ISR = 28002u, OS_ERR_SCHED_LOCKED = 28003u, OS_ERR_SCHED_NOT_LOCKED = 28004u, OS_ERR_SCHED_UNLOCK_ISR = 28005u, OS_ERR_SEM_OVF = 28101u, OS_ERR_SET_ISR = 28102u, OS_ERR_STAT_RESET_ISR = 28201u, OS_ERR_STATE_INVALID = 28202u, OS_ERR_STATUS_INVALID = 28203u, OS_ERR_STK_INVALID = 28204u, OS_ERR_STK_SIZE_INVALID = 28205u, OS_ERR_STK_LIMIT_INVALID = 28206u, OS_ERR_T = 29000u, OS_ERR_TASK_CHANGE_PRIO_ISR = 29001u, OS_ERR_TASK_CREATE_ISR = 29002u, OS_ERR_TASK_DEL = 29003u, OS_ERR_TASK_DEL_IDLE = 29004u, OS_ERR_TASK_DEL_INVALID = 29005u, OS_ERR_TASK_DEL_ISR = 29006u, OS_ERR_TASK_INVALID = 29007u, OS_ERR_TASK_NO_MORE_TCB = 29008u, OS_ERR_TASK_NOT_DLY = 29009u, OS_ERR_TASK_NOT_EXIST = 29010u, OS_ERR_TASK_NOT_SUSPENDED = 29011u, OS_ERR_TASK_OPT = 29012u, OS_ERR_TASK_RESUME_ISR = 29013u, OS_ERR_TASK_RESUME_PRIO = 29014u, OS_ERR_TASK_RESUME_SELF = 29015u, OS_ERR_TASK_STK_CHK_ISR = 29016u, OS_ERR_TASK_SUSPENDED = 29017u, OS_ERR_TASK_SUSPEND_IDLE = 29018u, OS_ERR_TASK_SUSPEND_INT_HANDLER = 29019u, OS_ERR_TASK_SUSPEND_ISR = 29020u, OS_ERR_TASK_SUSPEND_PRIO = 29021u, OS_ERR_TASK_WAITING = 29022u, OS_ERR_TCB_INVALID = 29101u, OS_ERR_TICK_WHEEL_SIZE = 29201u, OS_ERR_TIME_DLY_ISR = 29301u, OS_ERR_TIME_DLY_RESUME_ISR = 29302u, OS_ERR_TIME_GET_ISR = 29303u, OS_ERR_TIME_INVALID_HOURS = 29304u, OS_ERR_TIME_INVALID_MINUTES = 29305u, OS_ERR_TIME_INVALID_SECONDS = 29306u, OS_ERR_TIME_INVALID_MILLISECONDS = 29307u, OS_ERR_TIME_NOT_DLY = 29308u, OS_ERR_TIME_SET_ISR = 29309u, OS_ERR_TIME_ZERO_DLY = 29310u, OS_ERR_TIMEOUT = 29401u, OS_ERR_TMR_INACTIVE = 29501u, OS_ERR_TMR_INVALID_DEST = 29502u, OS_ERR_TMR_INVALID_DLY = 29503u, OS_ERR_TMR_INVALID_PERIOD = 29504u, OS_ERR_TMR_INVALID_STATE = 29505u, OS_ERR_TMR_INVALID = 29506u, OS_ERR_TMR_ISR = 29507u, OS_ERR_TMR_NO_CALLBACK = 29508u, OS_ERR_TMR_NON_AVAIL = 29509u, OS_ERR_TMR_STK_INVALID = 29510u, OS_ERR_TMR_STOPPED = 29511u, OS_ERR_U = 30000u, OS_ERR_V = 31000u, OS_ERR_W = 32000u, OS_ERR_X = 33000u, OS_ERR_Y = 34000u, OS_ERR_YIELD_ISR = 34001u, OS_ERR_Z = 35000u } OS_ERR; /*$PAGE*/ /* ************************************************************************************************************************ ************************************************************************************************************************ * D A T A T Y P E S ************************************************************************************************************************ ************************************************************************************************************************ */ typedef struct os_flag_grp OS_FLAG_GRP; typedef struct os_mem OS_MEM; typedef struct os_msg OS_MSG; typedef struct os_msg_pool OS_MSG_POOL; typedef struct os_msg_q OS_MSG_Q; typedef struct os_mutex OS_MUTEX; typedef struct os_int_q OS_INT_Q; typedef struct os_q OS_Q; typedef struct os_sem OS_SEM; typedef void (*OS_TASK_PTR)(void *p_arg); typedef struct os_tcb OS_TCB; typedef struct os_rdy_list OS_RDY_LIST; typedef struct os_tick_spoke OS_TICK_SPOKE; typedef void (*OS_TMR_CALLBACK_PTR)(void *p_tmr, void *p_arg); typedef struct os_tmr OS_TMR; typedef struct os_tmr_spoke OS_TMR_SPOKE; typedef struct os_pend_data OS_PEND_DATA; typedef struct os_pend_list OS_PEND_LIST; typedef struct os_pend_obj OS_PEND_OBJ; typedef void (*OS_APP_HOOK_VOID)(void); typedef void (*OS_APP_HOOK_TCB)(OS_TCB *p_tcb); /*$PAGE*/ /* ************************************************************************************************************************ ************************************************************************************************************************ * D A T A S T R U C T U R E S ************************************************************************************************************************ ************************************************************************************************************************ */ /* ------------------------------------------------------------------------------------------------------------------------ * ISR POST DATA ------------------------------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------------------------------ * READY LIST ------------------------------------------------------------------------------------------------------------------------ */ struct os_rdy_list { OS_TCB *HeadPtr; /* Pointer to task that will run at selected priority */ OS_TCB *TailPtr; /* Pointer to last task at selected priority */ OS_OBJ_QTY NbrEntries; /* Number of entries at selected priority */ }; /* ------------------------------------------------------------------------------------------------------------------------ * PEND DATA, PEND LIST and PEND OBJ ------------------------------------------------------------------------------------------------------------------------ */ struct os_pend_data { OS_PEND_DATA *PrevPtr; OS_PEND_DATA *NextPtr; OS_TCB *TCBPtr; OS_PEND_OBJ *PendObjPtr; OS_PEND_OBJ *RdyObjPtr; void *RdyMsgPtr; OS_MSG_SIZE RdyMsgSize; CPU_TS RdyTS; }; struct os_pend_list { OS_PEND_DATA *HeadPtr; OS_PEND_DATA *TailPtr; OS_OBJ_QTY NbrEntries; }; struct os_pend_obj { OS_OBJ_TYPE Type; CPU_CHAR *NamePtr; OS_PEND_LIST PendList; /* List of tasks pending on object */ void *DbgPrevPtr; void *DbgNextPtr; CPU_CHAR *DbgNamePtr; }; /* ------------------------------------------------------------------------------------------------------------------------ * EVENT FLAGS ------------------------------------------------------------------------------------------------------------------------ */ struct os_flag_grp { /* Event Flag Group */ OS_OBJ_TYPE Type; /* Should be set to OS_OBJ_TYPE_FLAG */ CPU_CHAR *NamePtr; /* Pointer to Event Flag Name (NUL terminated ASCII) */ OS_PEND_LIST PendList; /* List of tasks waiting on event flag group */ OS_FLAG_GRP *DbgPrevPtr; OS_FLAG_GRP *DbgNextPtr; CPU_CHAR *DbgNamePtr; OS_FLAGS Flags; /* 8, 16 or 32 bit flags */ CPU_TS TS; /* Timestamp of when last post occurred */ }; /*$PAGE*/ /* ------------------------------------------------------------------------------------------------------------------------ * MEMORY PARTITIONS ------------------------------------------------------------------------------------------------------------------------ */ struct os_mem { /* MEMORY CONTROL BLOCK */ OS_OBJ_TYPE Type; /* Should be set to OS_OBJ_TYPE_MEM */ void *AddrPtr; /* Pointer to beginning of memory partition */ CPU_CHAR *NamePtr; void *FreeListPtr; /* Pointer to list of free memory blocks */ OS_MEM_SIZE BlkSize; /* Size (in bytes) of each block of memory */ OS_MEM_QTY NbrMax; /* Total number of blocks in this partition */ OS_MEM_QTY NbrFree; /* Number of memory blocks remaining in this partition */ OS_MEM *DbgPrevPtr; OS_MEM *DbgNextPtr; }; /*$PAGE*/ /* ------------------------------------------------------------------------------------------------------------------------ * MESSAGES ------------------------------------------------------------------------------------------------------------------------ */ struct os_msg { /* MESSAGE CONTROL BLOCK */ OS_MSG *NextPtr; /* Pointer to next message */ void *MsgPtr; /* Actual message */ OS_MSG_SIZE MsgSize; /* Size of the message (in # bytes) */ CPU_TS MsgTS; /* Time stamp of when message was sent */ }; struct os_msg_pool { /* OS_MSG POOL */ OS_MSG *NextPtr; /* Pointer to next message */ OS_MSG_QTY NbrFree; /* Number of messages available from this pool */ OS_MSG_QTY NbrUsed; /* Number of messages used */ }; struct os_msg_q { /* OS_MSG_Q */ OS_MSG *InPtr; /* Pointer to next OS_MSG to be inserted in the queue */ OS_MSG *OutPtr; /* Pointer to next OS_MSG to be extracted from the queue */ OS_MSG_QTY NbrEntriesSize; /* Maximum allowable number of entries in the queue */ OS_MSG_QTY NbrEntries; /* Current number of entries in the queue */ OS_MSG_QTY NbrEntriesMax; /* Peak number of entries in the queue */ }; /*$PAGE*/ /* ------------------------------------------------------------------------------------------------------------------------ * MUTUAL EXCLUSION SEMAPHORES ------------------------------------------------------------------------------------------------------------------------ */ struct os_mutex { OS_OBJ_TYPE Type; /* Mutual Exclusion Semaphore */ CPU_CHAR *NamePtr; /* Should be set to OS_OBJ_TYPE_MUTEX */ OS_PEND_LIST PendList; /* Pointer to Mutex Name (NUL terminated ASCII) */ OS_MUTEX *DbgPrevPtr; OS_MUTEX *DbgNextPtr; CPU_CHAR *DbgNamePtr; OS_TCB *OwnerTCBPtr; /* List of tasks waiting on event flag group */ OS_PRIO OwnerOriginalPrio; OS_NESTING_CTR OwnerNestingCtr; /* Mutex is available when the counter is 0 */ CPU_TS TS; }; /*$PAGE*/ /* ------------------------------------------------------------------------------------------------------------------------ * MESSAGE QUEUES ------------------------------------------------------------------------------------------------------------------------ */ struct os_q { OS_OBJ_TYPE Type; /* Message Queue */ CPU_CHAR *NamePtr; /* Should be set to OS_OBJ_TYPE_Q */ OS_PEND_LIST PendList; /* Pointer to Message Queue (NUL terminated ASCII) */ OS_Q *DbgPrevPtr; OS_Q *DbgNextPtr; CPU_CHAR *DbgNamePtr; OS_MSG_Q MsgQ; /* List of tasks waiting on event flag group */ }; /*$PAGE*/ /* ------------------------------------------------------------------------------------------------------------------------ * SEMAPHORES ------------------------------------------------------------------------------------------------------------------------ */ struct os_sem { OS_OBJ_TYPE Type; /* Semaphore */ CPU_CHAR *NamePtr; /* Should be set to OS_OBJ_TYPE_SEM */ OS_PEND_LIST PendList; /* Pointer to Semaphore Name (NUL terminated ASCII) */ OS_SEM *DbgPrevPtr; OS_SEM *DbgNextPtr; CPU_CHAR *DbgNamePtr; OS_SEM_CTR Ctr; /* List of tasks waiting on event flag group */ CPU_TS TS; }; /*$PAGE*/ /* ------------------------------------------------------------------------------------------------------------------------ * TASK CONTROL BLOCK ------------------------------------------------------------------------------------------------------------------------ */ struct os_tcb { CPU_STK *StkPtr; /* Pointer to current top of stack */ void *ExtPtr; /* Pointer to user definable data for TCB extension */ CPU_STK *StkLimitPtr; /* Pointer used to set stack 'watermark' limit */ OS_TCB *NextPtr; /* Pointer to next TCB in the TCB list */ OS_TCB *PrevPtr; /* Pointer to previous TCB in the TCB list */ OS_TCB *TickNextPtr; OS_TCB *TickPrevPtr; OS_TICK_SPOKE *TickSpokePtr; /* Pointer to tick spoke if task is in the tick list */ CPU_CHAR *NamePtr; /* Pointer to task name */ CPU_STK *StkBasePtr; /* Pointer to base address of stack */ OS_TASK_PTR TaskEntryAddr; /* Pointer to task entry point address */ void *TaskEntryArg; /* Argument passed to task when it was created */ OS_PEND_DATA *PendDataTblPtr; /* Pointer to list containing objects pended on */ OS_STATE PendOn; /* Indicates what task is pending on */ OS_STATUS PendStatus; /* Pend status */ OS_STATE TaskState; /* See OS_TASK_STATE_xxx */ OS_PRIO Prio; /* Task priority (0 == highest) */ CPU_STK_SIZE StkSize; /* Size of task stack (in number of stack elements) */ OS_OPT Opt; /* Task options as passed by OSTaskCreate() */ OS_OBJ_QTY PendDataTblEntries; /* Size of array of objects to pend on */ CPU_TS TS; /* Timestamp */ OS_SEM_CTR SemCtr; /* Task specific semaphore counter */ /* DELAY / TIMEOUT */ OS_TICK TickCtrPrev; /* Previous time when task was ready */ OS_TICK TickCtrMatch; /* Absolute time when task is going to be ready */ OS_TICK TickRemain; /* Number of ticks remaining for a match (updated at ... */ /* ... run-time by OS_StatTask() */ OS_TICK TimeQuanta; OS_TICK TimeQuantaCtr; void *MsgPtr; /* Message received */ OS_MSG_SIZE MsgSize; OS_MSG_Q MsgQ; /* Message queue associated with task */ CPU_TS MsgQPendTime; /* Time it took for signal to be received */ CPU_TS MsgQPendTimeMax; /* Max amount of time it took for signal to be received */ OS_REG RegTbl[1u]; /* Task specific registers */ OS_FLAGS FlagsPend; /* Event flag(s) to wait on */ OS_FLAGS FlagsRdy; /* Event flags that made task ready to run */ OS_OPT FlagsOpt; /* Options (See OS_OPT_FLAG_xxx) */ OS_NESTING_CTR SuspendCtr; /* Nesting counter for OSTaskSuspend() */ OS_CPU_USAGE CPUUsage; /* CPU Usage of task (0-100%) */ OS_CTX_SW_CTR CtxSwCtr; /* Number of time the task was switched in */ CPU_TS CyclesDelta; /* value of OS_TS_GET() - .CyclesStart */ CPU_TS CyclesStart; /* Snapshot of cycle counter at start of task resumption */ OS_CYCLES CyclesTotal; /* Total number of # of cycles the task has been running */ OS_CYCLES CyclesTotalPrev; /* Snapshot of previous # of cycles */ CPU_TS SemPendTime; /* Time it took for signal to be received */ CPU_TS SemPendTimeMax; /* Max amount of time it took for signal to be received */ CPU_STK_SIZE StkUsed; /* Number of stack elements used from the stack */ CPU_STK_SIZE StkFree; /* Number of stack elements free on the stack */ CPU_TS IntDisTimeMax; /* Maximum interrupt disable time */ CPU_TS SchedLockTimeMax; /* Maximum scheduler lock time */ OS_TCB *DbgPrevPtr; OS_TCB *DbgNextPtr; CPU_CHAR *DbgNamePtr; }; /*$PAGE*/ /* ------------------------------------------------------------------------------------------------------------------------ * TICK DATA TYPE ------------------------------------------------------------------------------------------------------------------------ */ struct os_tick_spoke { OS_TCB *FirstPtr; /* Pointer to list of tasks in tick spoke */ OS_OBJ_QTY NbrEntries; /* Current number of entries in the tick spoke */ OS_OBJ_QTY NbrEntriesMax; /* Peak number of entries in the tick spoke */ }; /* ------------------------------------------------------------------------------------------------------------------------ * TIMER DATA TYPES ------------------------------------------------------------------------------------------------------------------------ */ struct os_tmr { OS_OBJ_TYPE Type; CPU_CHAR *NamePtr; /* Name to give the timer */ OS_TMR_CALLBACK_PTR CallbackPtr; /* Function to call when timer expires */ void *CallbackPtrArg; /* Argument to pass to function when timer expires */ OS_TMR *NextPtr; /* Double link list pointers */ OS_TMR *PrevPtr; OS_TICK Match; /* Timer expires when OSTmrTickCtr matches this value */ OS_TICK Remain; /* Amount of time remaining before timer expires */ OS_TICK Dly; /* Delay before start of repeat */ OS_TICK Period; /* Period to repeat timer */ OS_OPT Opt; /* Options (see OS_OPT_TMR_xxx) */ OS_STATE State; OS_TMR *DbgPrevPtr; OS_TMR *DbgNextPtr; }; struct os_tmr_spoke { OS_TMR *FirstPtr; /* Pointer to first timer in linked list */ OS_OBJ_QTY NbrEntries; OS_OBJ_QTY NbrEntriesMax; }; typedef enum { OS_HISTORY_INT=1, OS_HISTORY_THREAD }os_history_type_s; typedef struct { os_history_type_s type; unsigned long tick; unsigned long int_num; char thread_name[16]; }os_history_item_s; typedef struct { unsigned short History_Size; unsigned short Count; os_history_item_s item[2048]; }os_history_s; /*$PAGE*/ /* ************************************************************************************************************************ ************************************************************************************************************************ * G L O B A L V A R I A B L E S ************************************************************************************************************************ ************************************************************************************************************************ */ extern OS_APP_HOOK_TCB OS_AppTaskCreateHookPtr; /* Application hooks */ extern OS_APP_HOOK_TCB OS_AppTaskDelHookPtr; extern OS_APP_HOOK_TCB OS_AppTaskReturnHookPtr; extern OS_APP_HOOK_VOID OS_AppIdleTaskHookPtr; extern OS_APP_HOOK_VOID OS_AppStatTaskHookPtr; extern OS_APP_HOOK_VOID OS_AppTaskSwHookPtr; extern OS_APP_HOOK_VOID OS_AppTimeTickHookPtr; /* IDLE TASK ---------------------------------- */ extern OS_IDLE_CTR OSIdleTaskCtr; extern OS_TCB OSIdleTaskTCB; /* MISCELLANEOUS ------------------------------ */ extern OS_NESTING_CTR OSIntNestingCtr; /* Interrupt nesting level */ extern CPU_TS OSIntDisTimeMax; /* Overall interrupt disable time */ extern OS_STATE OSRunning; /* Flag indicating that kernel is running */ /* ISR HANDLER TASK --------------------------- */ /* FLAGS -------------------------------------- */ extern OS_FLAG_GRP *OSFlagDbgListPtr; extern OS_OBJ_QTY OSFlagQty; /* MEMORY MANAGEMENT -------------------------- */ extern OS_MEM *OSMemDbgListPtr; extern OS_OBJ_QTY OSMemQty; /* Number of memory partitions created */ /* OS_MSG POOL -------------------------------- */ extern OS_MSG_POOL OSMsgPool; /* Pool of OS_MSG */ /* MUTEX MANAGEMENT --------------------------- */ extern OS_MUTEX *OSMutexDbgListPtr; extern OS_OBJ_QTY OSMutexQty; /* Number of mutexes created */ /* PRIORITIES --------------------------------- */ extern OS_PRIO OSPrioCur; /* Priority of current task */ extern OS_PRIO OSPrioHighRdy; /* Priority of highest priority task */ extern OS_PRIO OSPrioSaved; /* Saved priority level when Post Deferred */ extern CPU_DATA OSPrioTbl[(((32u - 1u) / (4 * 8u)) + 1u)]; /* QUEUES ------------------------------------- */ extern OS_Q *OSQDbgListPtr; extern OS_OBJ_QTY OSQQty; /* Number of message queues created */ /* READY LIST --------------------------------- */ extern OS_RDY_LIST OSRdyList[32u]; /* Table of tasks ready to run */ /* SCHEDULER ---------------------------------- */ extern CPU_TS_TMR OSSchedLockTimeBegin; /* Scheduler lock time measurement */ extern CPU_TS_TMR OSSchedLockTimeMax; extern CPU_TS_TMR OSSchedLockTimeMaxCur; extern OS_NESTING_CTR OSSchedLockNestingCtr; /* Lock nesting level */ extern OS_TICK OSSchedRoundRobinDfltTimeQuanta; extern CPU_BOOLEAN OSSchedRoundRobinEn; /* Enable/Disable round-robin scheduling */ /* SEMAPHORES --------------------------------- */ extern OS_SEM *OSSemDbgListPtr; extern OS_OBJ_QTY OSSemQty; /* Number of semaphores created */ /* STATISTICS --------------------------------- */ extern OS_CPU_USAGE OSStatTaskCPUUsage; /* CPU Usage in % */ extern OS_TICK OSStatTaskCtr; extern OS_TICK OSStatTaskCtrMax; extern OS_TICK OSStatTaskCtrRun; extern CPU_BOOLEAN OSStatTaskRdy; extern OS_TCB OSStatTaskTCB; extern CPU_TS OSStatTaskTimeMax; extern CPU_BOOLEAN OSStatResetFlag; /* Force the reset of the computed statistics */ /* TASKS -------------------------------------- */ extern OS_CTX_SW_CTR OSTaskCtxSwCtr; /* Number of context switches */ extern OS_TCB *OSTaskDbgListPtr; extern OS_OBJ_QTY OSTaskQty; /* Number of tasks created */ /* TICK TASK ---------------------------------- */ extern OS_TICK OSTickCtr; /* Counts the #ticks since startup or last set */ extern OS_TCB OSTickTaskTCB; extern CPU_TS OSTickTaskTimeMax; extern OS_TMR *OSTmrDbgListPtr; extern OS_OBJ_QTY OSTmrQty; /* Number of timers created */ extern OS_TCB OSTmrTaskTCB; /* TCB of timer task */ extern CPU_TS OSTmrTaskTimeMax; extern OS_TICK OSTmrTickCtr; /* Current time for the timers */ extern OS_CTR OSTmrUpdateCnt; /* Counter for updating timers */ extern OS_CTR OSTmrUpdateCtr; /* TCBs --------------------------------------- */ extern OS_TCB *OSTCBCurPtr; /* Pointer to currently running TCB */ extern OS_TCB *OSTCBHighRdyPtr; /* Pointer to highest priority TCB */ /*$PAGE*/ /* ************************************************************************************************************************ ************************************************************************************************************************ * E X T E R N A L S ************************************************************************************************************************ ************************************************************************************************************************ */ extern CPU_STK * const OSCfg_IdleTaskStkBasePtr; extern CPU_STK_SIZE const OSCfg_IdleTaskStkLimit; extern CPU_STK_SIZE const OSCfg_IdleTaskStkSize; extern CPU_INT32U const OSCfg_IdleTaskStkSizeRAM; extern OS_INT_Q * const OSCfg_IntQBasePtr; extern OS_OBJ_QTY const OSCfg_IntQSize; extern CPU_INT32U const OSCfg_IntQSizeRAM; extern CPU_STK * const OSCfg_IntQTaskStkBasePtr; extern CPU_STK_SIZE const OSCfg_IntQTaskStkLimit; extern CPU_STK_SIZE const OSCfg_IntQTaskStkSize; extern CPU_INT32U const OSCfg_IntQTaskStkSizeRAM; extern CPU_STK * const OSCfg_ISRStkBasePtr; extern CPU_STK_SIZE const OSCfg_ISRStkSize; extern CPU_INT32U const OSCfg_ISRStkSizeRAM; extern OS_MSG_SIZE const OSCfg_MsgPoolSize; extern CPU_INT32U const OSCfg_MsgPoolSizeRAM; extern OS_MSG * const OSCfg_MsgPoolBasePtr; extern OS_PRIO const OSCfg_StatTaskPrio; extern OS_RATE_HZ const OSCfg_StatTaskRate_Hz; extern CPU_STK * const OSCfg_StatTaskStkBasePtr; extern CPU_STK_SIZE const OSCfg_StatTaskStkLimit; extern CPU_STK_SIZE const OSCfg_StatTaskStkSize; extern CPU_INT32U const OSCfg_StatTaskStkSizeRAM; extern CPU_STK_SIZE const OSCfg_StkSizeMin; extern OS_RATE_HZ const OSCfg_TickRate_Hz; extern OS_PRIO const OSCfg_TickTaskPrio; extern CPU_STK * const OSCfg_TickTaskStkBasePtr; extern CPU_STK_SIZE const OSCfg_TickTaskStkLimit; extern CPU_STK_SIZE const OSCfg_TickTaskStkSize; extern CPU_INT32U const OSCfg_TickTaskStkSizeRAM; extern OS_OBJ_QTY const OSCfg_TickWheelSize; extern CPU_INT32U const OSCfg_TickWheelSizeRAM; extern OS_PRIO const OSCfg_TmrTaskPrio; extern OS_RATE_HZ const OSCfg_TmrTaskRate_Hz; extern CPU_STK * const OSCfg_TmrTaskStkBasePtr; extern CPU_STK_SIZE const OSCfg_TmrTaskStkLimit; extern CPU_STK_SIZE const OSCfg_TmrTaskStkSize; extern CPU_INT32U const OSCfg_TmrTaskStkSizeRAM; extern OS_OBJ_QTY const OSCfg_TmrWheelSize; extern CPU_INT32U const OSCfg_TmrSizeRAM; extern CPU_STK OSCfg_IdleTaskStk[]; extern CPU_STK OSCfg_ISRStk[]; extern OS_MSG OSCfg_MsgPool[]; extern CPU_STK OSCfg_StatTaskStk[]; extern CPU_STK OSCfg_TickTaskStk[]; extern OS_TICK_SPOKE OSCfg_TickWheel[]; extern CPU_STK OSCfg_TmrTaskStk[]; extern OS_TMR_SPOKE OSCfg_TmrWheel[]; extern os_history_s os_history; extern unsigned short Int_Queue[100]; extern unsigned short Int_Queue_Cnt; /* ************************************************************************************************************************ ************************************************************************************************************************ * F U N C T I O N P R O T O T Y P E S ************************************************************************************************************************ ************************************************************************************************************************ */ /* ================================================================================================================== */ /* EVENT FLAGS */ /* ================================================================================================================== */ void OSFlagCreate (OS_FLAG_GRP *p_grp, CPU_CHAR *p_name, OS_FLAGS flags, OS_ERR *p_err); OS_FLAGS OSFlagPend (OS_FLAG_GRP *p_grp, OS_FLAGS flags, OS_TICK timeout, OS_OPT opt, CPU_TS *p_ts, OS_ERR *p_err); OS_FLAGS OSFlagPendGetFlagsRdy (OS_ERR *p_err); OS_FLAGS OSFlagPost (OS_FLAG_GRP *p_grp, OS_FLAGS flags, OS_OPT opt, OS_ERR *p_err); /* ------------------------------------------------ INTERNAL FUNCTIONS ---------------------------------------------- */ void OS_FlagClr (OS_FLAG_GRP *p_grp); void OS_FlagBlock (OS_PEND_DATA *p_pend_data, OS_FLAG_GRP *p_grp, OS_FLAGS flags, OS_OPT opt, OS_TICK timeout); void OS_FlagDbgListAdd (OS_FLAG_GRP *p_grp); void OS_FlagDbgListRemove (OS_FLAG_GRP *p_grp); void OS_FlagInit (OS_ERR *p_err); OS_FLAGS OS_FlagPost (OS_FLAG_GRP *p_grp, OS_FLAGS flags, OS_OPT opt, CPU_TS ts, OS_ERR *p_err); void OS_FlagTaskRdy (OS_TCB *p_tcb, OS_FLAGS flags_rdy, CPU_TS ts); /*$PAGE*/ /* ================================================================================================================== */ /* FIXED SIZE MEMORY BLOCK MANAGEMENT */ /* ================================================================================================================== */ void OSMemCreate (OS_MEM *p_mem, CPU_CHAR *p_name, void *p_addr, OS_MEM_QTY n_blks, OS_MEM_SIZE blk_size, OS_ERR *p_err); void *OSMemGet (OS_MEM *p_mem, OS_ERR *p_err); void OSMemPut (OS_MEM *p_mem, void *p_blk, OS_ERR *p_err); /* ------------------------------------------------ INTERNAL FUNCTIONS ---------------------------------------------- */ void OS_MemDbgListAdd (OS_MEM *p_mem); void OS_MemInit (OS_ERR *p_err); /*$PAGE*/ /* ================================================================================================================== */ /* MUTUAL EXCLUSION SEMAPHORES */ /* ================================================================================================================== */ void OSMutexCreate (OS_MUTEX *p_mutex, CPU_CHAR *p_name, OS_ERR *p_err); OS_OBJ_QTY OSMutexDel (OS_MUTEX *p_mutex, OS_OPT opt, OS_ERR *p_err); void OSMutexPend (OS_MUTEX *p_mutex, OS_TICK timeout, OS_OPT opt, CPU_TS *p_ts, OS_ERR *p_err); void OSMutexPost (OS_MUTEX *p_mutex, OS_OPT opt, OS_ERR *p_err); /* ------------------------------------------------ INTERNAL FUNCTIONS ---------------------------------------------- */ void OS_MutexClr (OS_MUTEX *p_mutex); void OS_MutexDbgListAdd (OS_MUTEX *p_mutex); void OS_MutexDbgListRemove (OS_MUTEX *p_mutex); void OS_MutexInit (OS_ERR *p_err); /*$PAGE*/ /* ================================================================================================================== */ /* MESSAGE QUEUES */ /* ================================================================================================================== */ OS_OBJ_QTY OSPendMulti (OS_PEND_DATA *p_pend_data_tbl, OS_OBJ_QTY tbl_size, OS_TICK timeout, OS_OPT opt, OS_ERR *p_err); /* ------------------------------------------------ INTERNAL FUNCTIONS ---------------------------------------------- */ OS_OBJ_QTY OS_PendMultiGetRdy (OS_PEND_DATA *p_pend_data_tbl, OS_OBJ_QTY tbl_size); CPU_BOOLEAN OS_PendMultiValidate (OS_PEND_DATA *p_pend_data_tbl, OS_OBJ_QTY tbl_size); void OS_PendMultiWait (OS_PEND_DATA *p_pend_data_tbl, OS_OBJ_QTY tbl_size, OS_TICK timeout); /* ================================================================================================================== */ /* MESSAGE QUEUES */ /* ================================================================================================================== */ void OSQCreate (OS_Q *p_q, CPU_CHAR *p_name, OS_MSG_QTY max_qty, OS_ERR *p_err); OS_OBJ_QTY OSQDel (OS_Q *p_q, OS_OPT opt, OS_ERR *p_err); void *OSQPend (OS_Q *p_q, OS_TICK timeout, OS_OPT opt, OS_MSG_SIZE *p_msg_size, CPU_TS *p_ts, OS_ERR *p_err); OS_OBJ_QTY OSQPendAbort (OS_Q *p_q, OS_OPT opt, OS_ERR *p_err); void OSQPost (OS_Q *p_q, void *p_void, OS_MSG_SIZE msg_size, OS_OPT opt, OS_ERR *p_err); /* ------------------------------------------------ INTERNAL FUNCTIONS ---------------------------------------------- */ void OS_QClr (OS_Q *p_q); void OS_QDbgListAdd (OS_Q *p_q); void OS_QDbgListRemove (OS_Q *p_q); void OS_QInit (OS_ERR *p_err); void OS_QPost (OS_Q *p_q, void *p_void, OS_MSG_SIZE msg_size, OS_OPT opt, CPU_TS ts, OS_ERR *p_err); /*$PAGE*/ /* ================================================================================================================== */ /* SEMAPHORES */ /* ================================================================================================================== */ void OSSemCreate (OS_SEM *p_sem, CPU_CHAR *p_name, OS_SEM_CTR cnt, OS_ERR *p_err); OS_OBJ_QTY OSSemDel (OS_SEM *p_sem, OS_OPT opt, OS_ERR *p_err); OS_SEM_CTR OSSemPend (OS_SEM *p_sem, OS_TICK timeout, OS_OPT opt, CPU_TS *p_ts, OS_ERR *p_err); OS_OBJ_QTY OSSemPendAbort (OS_SEM *p_sem, OS_OPT opt, OS_ERR *p_err); OS_SEM_CTR OSSemPost (OS_SEM *p_sem, OS_OPT opt, OS_ERR *p_err); void OSSemSet (OS_SEM *p_sem, OS_SEM_CTR cnt, OS_ERR *p_err); /* ------------------------------------------------ INTERNAL FUNCTIONS ---------------------------------------------- */ void OS_SemClr (OS_SEM *p_sem); void OS_SemDbgListAdd (OS_SEM *p_sem); void OS_SemDbgListRemove (OS_SEM *p_sem); void OS_SemInit (OS_ERR *p_err); OS_SEM_CTR OS_SemPost (OS_SEM *p_sem, OS_OPT opt, CPU_TS ts, OS_ERR *p_err); /*$PAGE*/ /* ================================================================================================================== */ /* TASK MANAGEMENT */ /* ================================================================================================================== */ void OSTaskChangePrio (OS_TCB *p_tcb, OS_PRIO prio_new, OS_ERR *p_err); void OSTaskCreate (OS_TCB *p_tcb, CPU_CHAR *p_name, OS_TASK_PTR p_task, void *p_arg, OS_PRIO prio, CPU_STK *p_stk_base, CPU_STK_SIZE stk_limit, CPU_STK_SIZE stk_size, OS_MSG_QTY q_size, OS_TICK time_quanta, void *p_ext, OS_OPT opt, OS_ERR *p_err); void OSTaskDel (OS_TCB *p_tcb, OS_ERR *p_err); OS_MSG_QTY OSTaskQFlush (OS_TCB *p_tcb, OS_ERR *p_err); void *OSTaskQPend (OS_TICK timeout, OS_OPT opt, OS_MSG_SIZE *p_msg_size, CPU_TS *p_ts, OS_ERR *p_err); CPU_BOOLEAN OSTaskQPendAbort (OS_TCB *p_tcb, OS_OPT opt, OS_ERR *p_err); void OSTaskQPost (OS_TCB *p_tcb, void *p_void, OS_MSG_SIZE msg_size, OS_OPT opt, OS_ERR *p_err); void OSTaskResume (OS_TCB *p_tcb, OS_ERR *p_err); void OSTaskSuspend (OS_TCB *p_tcb, OS_ERR *p_err); OS_REG OSTaskRegGet (OS_TCB *p_tcb, OS_REG_ID id, OS_ERR *p_err); void OSTaskRegSet (OS_TCB *p_tcb, OS_REG_ID id, OS_REG value, OS_ERR *p_err); OS_SEM_CTR OSTaskSemPend (OS_TICK timeout, OS_OPT opt, CPU_TS *p_ts, OS_ERR *p_err); CPU_BOOLEAN OSTaskSemPendAbort (OS_TCB *p_tcb, OS_OPT opt, OS_ERR *p_err); OS_SEM_CTR OSTaskSemPost (OS_TCB *p_tcb, OS_OPT opt, OS_ERR *p_err); OS_SEM_CTR OSTaskSemSet (OS_TCB *p_tcb, OS_SEM_CTR cnt, OS_ERR *p_err); void OSTaskStkChk (OS_TCB *p_tcb, CPU_STK_SIZE *p_free, CPU_STK_SIZE *p_used, OS_ERR *p_err); void OSTaskTimeQuantaSet (OS_TCB *p_tcb, OS_TICK time_quanta, OS_ERR *p_err); /* ------------------------------------------------ INTERNAL FUNCTIONS ---------------------------------------------- */ void OS_TaskBlock (OS_TCB *p_tcb, OS_TICK timeout); void OS_TaskDbgListAdd (OS_TCB *p_tcb); void OS_TaskDbgListRemove (OS_TCB *p_tcb); void OS_TaskInit (OS_ERR *p_err); void OS_TaskInitTCB (OS_TCB *p_tcb); void OS_TaskQPost (OS_TCB *p_tcb, void *p_void, OS_MSG_SIZE msg_size, OS_OPT opt, CPU_TS ts, OS_ERR *p_err); void OS_TaskRdy (OS_TCB *p_tcb); void OS_TaskReturn (void); OS_SEM_CTR OS_TaskSemPost (OS_TCB *p_tcb, OS_OPT opt, CPU_TS ts, OS_ERR *p_err); /*$PAGE*/ /* ================================================================================================================== */ /* TIME MANAGEMENT */ /* ================================================================================================================== */ void OSTimeDly (OS_TICK dly, OS_OPT opt, OS_ERR *p_err); void OSTimeDlyHMSM (CPU_INT16U hours, CPU_INT16U minutes, CPU_INT16U seconds, CPU_INT32U milli, OS_OPT opt, OS_ERR *p_err); OS_TICK OSTimeGet (OS_ERR *p_err); void OSTimeSet (OS_TICK ticks, OS_ERR *p_err); void OSTimeTick (void); /*$PAGE*/ /* ================================================================================================================== */ /* TIMER MANAGEMENT */ /* ================================================================================================================== */ void OSTmrCreate (OS_TMR *p_tmr, CPU_CHAR *p_name, OS_TICK dly, OS_TICK period, OS_OPT opt, OS_TMR_CALLBACK_PTR p_callback, void *p_callback_arg, OS_ERR *p_err); CPU_BOOLEAN OSTmrDel (OS_TMR *p_tmr, OS_ERR *p_err); OS_TICK OSTmrRemainGet (OS_TMR *p_tmr, OS_ERR *p_err); CPU_BOOLEAN OSTmrStart (OS_TMR *p_tmr, OS_ERR *p_err); OS_STATE OSTmrStateGet (OS_TMR *p_tmr, OS_ERR *p_err); CPU_BOOLEAN OSTmrStop (OS_TMR *p_tmr, OS_OPT opt, void *p_callback_arg, OS_ERR *p_err); /* ------------------------------------------------ INTERNAL FUNCTIONS ---------------------------------------------- */ void OS_TmrClr (OS_TMR *p_tmr); void OS_TmrDbgListAdd (OS_TMR *p_tmr); void OS_TmrDbgListRemove (OS_TMR *p_tmr); void OS_TmrInit (OS_ERR *p_err); void OS_TmrLink (OS_TMR *p_tmr, OS_OPT opt); void OS_TmrResetPeak (void); void OS_TmrUnlink (OS_TMR *p_tmr); void OS_TmrTask (void *p_arg); /*$PAGE*/ /* ================================================================================================================== */ /* MISCELLANEOUS */ /* ================================================================================================================== */ /*$PAGE*/ /* ************************************************************************************************************************ * OS INITIALIZATION * * Description: OSInit() initializes μC/OS-III and it must be called prior to calling any other μC/OS-III function. * Including OSStart() which will start multitasking * * * Argument(s): p_err is a pointer to an error code and can be: * * OS_ERR_NONE initialization was successful. * OS_ERR_???? some other OS_ERR_???? value returned by a sub-function of OSInit(). * * Returns : none * * Note(s) : 1) OSInit() must be called before OSStart(). * * 2) OSInit() returns as soon as it detects an error in any of the sub-functions it calls. For example, if OSInit() encounters a problem initializing the task manager, an appropriate error code will be returned and OSInit() will not go any further. It is therefore important that the user checks the error code before starting multitasking. ************************************************************************************************************************ */ void OSInit (OS_ERR *p_err); void OSIntEnter (void); void OSIntExit (void); void OSMsgPoolExtend (OS_MSG *p_msg, OS_MSG_QTY size, OS_ERR *p_err); void OSSchedRoundRobinCfg (CPU_BOOLEAN en, OS_TICK dflt_time_quanta, OS_ERR *p_err); void OSSchedRoundRobinYield (OS_ERR *p_err); void OSSched (void); void OSSchedLock (OS_ERR *p_err); void OSSchedUnlock (OS_ERR *p_err); void OS_Oscillator_Set (unsigned long Freq); void OSStart (OS_ERR *p_err); void OSStatReset (OS_ERR *p_err); void OSStatTaskCPUUsageInit (OS_ERR *p_err); CPU_INT16U OSVersion (OS_ERR *p_err); /* ------------------------------------------------ INTERNAL FUNCTIONS ---------------------------------------------- */ void OS_IdleTask (void *p_arg); void OS_IdleTaskInit (OS_ERR *p_err); void OS_StatTask (void *p_arg); void OS_StatTaskInit (OS_ERR *p_err); void OS_TickTask (void *p_arg); void OS_TickTaskInit (OS_ERR *p_err); /*$PAGE*/ /* ************************************************************************************************************************ ************************************************************************************************************************ * T A R G E T S P E C I F I C F U N C T I O N S ************************************************************************************************************************ ************************************************************************************************************************ */ void OSInitHook (void); void OSTaskCreateHook (OS_TCB *p_tcb); void OSTaskDelHook (OS_TCB *p_tcb); void OSIdleTaskHook (void); void OSTaskReturnHook (OS_TCB *p_tcb); void OSStatTaskHook (void); CPU_STK *OSTaskStkInit (OS_TASK_PTR p_task, void *p_arg, CPU_STK *p_stk_base, CPU_STK *p_stk_limit, CPU_STK_SIZE stk_size, OS_OPT opt); void OSTaskSwHook (void); void OSTimeTickHook (void); /*$PAGE*/ /* ************************************************************************************************************************ ************************************************************************************************************************ * u C / O S - I I I I N T E R N A L F U N C T I O N P R O T O T Y P E S ************************************************************************************************************************ ************************************************************************************************************************ */ void OSCfg_Init (void); void OS_Dbg_Init (void); /* ----------------------------------------------- MESSAGE MANAGEMENT ----------------------------------------------- */ void OS_MsgPoolCreate (OS_MSG *p_msg, OS_MSG_QTY size); void OS_MsgPoolInit (OS_ERR *p_err); void OS_MsgQEntriesPeakReset (OS_MSG_Q *p_msg_q); OS_MSG_QTY OS_MsgQFreeAll (OS_MSG_Q *p_msg_q); void *OS_MsgQGet (OS_MSG_Q *p_msg_q, OS_MSG_SIZE *p_msg_size, CPU_TS *p_ts, OS_ERR *p_err); void OS_MsgQInit (OS_MSG_Q *p_msg_q, OS_MSG_QTY size); void OS_MsgQPut (OS_MSG_Q *p_msg_q, void *p_void, OS_MSG_SIZE msg_size, OS_OPT opt, CPU_TS ts, OS_ERR *p_err); /* ---------------------------------------------- PEND/POST MANAGEMENT ---------------------------------------------- */ void OS_Pend (OS_PEND_DATA *p_pend_data, OS_PEND_OBJ *p_obj, OS_STATE pending_on, OS_TICK timeout); void OS_PendAbort (OS_PEND_OBJ *p_obj, OS_TCB *p_tcb, CPU_TS ts); void OS_PendAbort1 (OS_PEND_OBJ *p_obj, OS_TCB *p_tcb, CPU_TS ts); void OS_PendObjDel (OS_PEND_OBJ *p_obj, OS_TCB *p_tcb, CPU_TS ts); void OS_PendObjDel1 (OS_PEND_OBJ *p_obj, OS_TCB *p_tcb, CPU_TS ts); void OS_Post (OS_PEND_OBJ *p_obj, OS_TCB *p_tcb, void *p_void, OS_MSG_SIZE msg_size, CPU_TS ts); void OS_Post1 (OS_PEND_OBJ *p_obj, OS_TCB *p_tcb, void *p_void, OS_MSG_SIZE msg_size, CPU_TS ts); /* ----------------------------------------------- PRIORITY MANAGEMENT ---------------------------------------------- */ void OS_PrioInit (void); void OS_PrioInsert (OS_PRIO prio); void OS_PrioRemove (OS_PRIO prio); OS_PRIO OS_PrioGetHighest (void); /* --------------------------------------------------- SCHEDULING --------------------------------------------------- */ void OS_SchedLockTimeMeasStart (void); void OS_SchedLockTimeMeasStop (void); void OS_SchedRoundRobin (OS_RDY_LIST *p_rdy_list); /* --------------------------------------------- READY LIST MANAGEMENT ---------------------------------------------- */ void OS_RdyListInit (void); void OS_RdyListInsert (OS_TCB *p_tcb); void OS_RdyListInsertHead (OS_TCB *p_tcb); void OS_RdyListInsertTail (OS_TCB *p_tcb); void OS_RdyListMoveHeadToTail (OS_RDY_LIST *p_rdy_list); void OS_RdyListRemove (OS_TCB *p_tcb); /* ---------------------------------------------- PEND LIST MANAGEMENT ---------------------------------------------- */ void OS_PendDataInit (OS_TCB *p_tcb, OS_PEND_DATA *p_pend_data_tbl, OS_OBJ_QTY tbl_size); void OS_PendDbgNameAdd (OS_PEND_OBJ *p_obj, OS_TCB *p_tcb); void OS_PendDbgNameRemove (OS_PEND_OBJ *p_obj, OS_TCB *p_tcb); OS_PEND_LIST *OS_PendListGetPtr (OS_PEND_OBJ *p_obj); void OS_PendListInit (OS_PEND_LIST *p_pend_list); void OS_PendListInsertHead (OS_PEND_LIST *p_pend_list, OS_PEND_DATA *p_pend_data); void OS_PendListInsertPrio (OS_PEND_LIST *p_pend_list, OS_PEND_DATA *p_pend_data); void OS_PendListChangePrio (OS_TCB *p_tcb, OS_PRIO prio_new); void OS_PendListRemove (OS_TCB *p_tcb); void OS_PendListRemove1 (OS_PEND_LIST *p_pend_list, OS_PEND_DATA *p_pend_data); /* ---------------------------------------------- TICK LIST MANAGEMENT ---------------------------------------------- */ void OS_TickListInit (void); void OS_TickListInsert (OS_TCB *p_tcb, OS_TICK time, OS_OPT opt, OS_ERR *p_err); void OS_TickListRemove (OS_TCB *p_tcb); void OS_TickListResetPeak (void); void OS_TickListUpdate (void); /*$PAGE*/ /* ************************************************************************************************************************ * LOOK FOR MISSING #define CONSTANTS * * This section is used to generate ERROR messages at compile time if certain #define constants are * MISSING in OS_CFG.H. This allows you to quickly determine the source of the error. * * You SHOULD NOT change this section UNLESS you would like to add more comments as to the source of the * compile time error. ************************************************************************************************************************ */ /* ************************************************************************************************************************ * MISCELLANEOUS ************************************************************************************************************************ */ /* ************************************************************************************************************************ * EVENT FLAGS ************************************************************************************************************************ */ /* ************************************************************************************************************************ * MEMORY MANAGEMENT ************************************************************************************************************************ */ /* ************************************************************************************************************************ * MUTUAL EXCLUSION SEMAPHORES ************************************************************************************************************************ */ /* ************************************************************************************************************************ * MESSAGE QUEUES ************************************************************************************************************************ */ /* ************************************************************************************************************************ * SEMAPHORES ************************************************************************************************************************ */ /* ************************************************************************************************************************ * TASK MANAGEMENT ************************************************************************************************************************ */ /* ************************************************************************************************************************ * TIME MANAGEMENT ************************************************************************************************************************ */ /* ************************************************************************************************************************ * TIMER MANAGEMENT ************************************************************************************************************************ */ /* ************************************************************************************************************************ * LIBRARY CONFIGURATION ERRORS ************************************************************************************************************************ */ /* See 'os.h Note #1a'. */ /* See 'os.h Note #1b'. */ /* ************************************************************************************************************************ * uC/OS-III MODULE END ************************************************************************************************************************ */ /*---------------------------------------------------------------------------/ / Functions and Buffer Configurations /---------------------------------------------------------------------------*/ /* When _FS_TINY is set to 1, it reduces memory consumption _MAX_SS bytes each / file object. For file data transfer, FatFs uses the common sector buffer in / the file system object (FATFS) instead of private sector buffer eliminated / from the file object (FIL). */ /* Setting _FS_READONLY to 1 defines read only configuration. This removes / writing functions, f_write(), f_sync(), f_unlink(), f_mkdir(), f_chmod(), / f_rename(), f_truncate() and useless f_getfree(). */ /* The _FS_MINIMIZE option defines minimization level to remove API functions. / / 0: All basic functions are enabled. / 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(), / f_truncate() and f_rename() function are removed. / 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1. / 3: f_lseek() function is removed in addition to 2. */ /* To enable string functions, set _USE_STRFUNC to 1 or 2. */ /* To enable f_mkfs() function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */ /* To enable fast seek feature, set _USE_FASTSEEK to 1. */ /* To enable volume label functions, set _USE_LAVEL to 1 */ /* To enable f_forward() function, set _USE_FORWARD to 1 and set _FS_TINY to 1. */ /*---------------------------------------------------------------------------/ / Locale and Namespace Configurations /---------------------------------------------------------------------------*/ /* The _CODE_PAGE specifies the OEM code page to be used on the target system. / Incorrect setting of the code page can cause a file open failure. / / 932 - Japanese Shift_JIS (DBCS, OEM, Windows) / 936 - Simplified Chinese GBK (DBCS, OEM, Windows) / 949 - Korean (DBCS, OEM, Windows) / 950 - Traditional Chinese Big5 (DBCS, OEM, Windows) / 1250 - Central Europe (Windows) / 1251 - Cyrillic (Windows) / 1252 - Latin 1 (Windows) / 1253 - Greek (Windows) / 1254 - Turkish (Windows) / 1255 - Hebrew (Windows) / 1256 - Arabic (Windows) / 1257 - Baltic (Windows) / 1258 - Vietnam (OEM, Windows) / 437 - U.S. (OEM) / 720 - Arabic (OEM) / 737 - Greek (OEM) / 775 - Baltic (OEM) / 850 - Multilingual Latin 1 (OEM) / 858 - Multilingual Latin 1 + Euro (OEM) / 852 - Latin 2 (OEM) / 855 - Cyrillic (OEM) / 866 - Russian (OEM) / 857 - Turkish (OEM) / 862 - Hebrew (OEM) / 874 - Thai (OEM, Windows) / 1 - ASCII (Valid for only non-LFN configuration) */ /* The _USE_LFN option switches the LFN feature. / / 0: Disable LFN feature. _MAX_LFN has no effect. / 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe. / 2: Enable LFN with dynamic working buffer on the STACK. / 3: Enable LFN with dynamic working buffer on the HEAP. / / When enable LFN feature, Unicode handling functions ff_convert() and ff_wtoupper() / function must be added to the project. / The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes. When use stack for the / working buffer, take care on stack overflow. When use heap memory for the working / buffer, memory management functions, ff_memalloc() and ff_memfree(), must be added / to the project. */ /* To switch the character encoding on the FatFs API (TCHAR) to Unicode, enable LFN / feature and set _LFN_UNICODE to 1. This option affects behavior of string I/O / functions. This option must be 0 when LFN feature is not enabled. */ /* When Unicode API is enabled by _LFN_UNICODE option, this option selects the character / encoding on the file to be read/written via string I/O functions, f_gets(), f_putc(), / f_puts and f_printf(). This option has no effect when _LFN_UNICODE == 0. Note that / FatFs supports only BMP. */ /* The _FS_RPATH option configures relative path feature. / / 0: Disable relative path feature and remove related functions. / 1: Enable relative path. f_chdrive() and f_chdir() function are available. / 2: f_getcwd() function is available in addition to 1. / / Note that output of the f_readdir() fnction is affected by this option. */ /*---------------------------------------------------------------------------/ / Drive/Volume Configurations /---------------------------------------------------------------------------*/ /* Number of volumes (logical drives) to be used. */ /* When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive / number in the path name. _VOLUME_STRS defines the drive ID strings for each logical / drives. Number of items must be equal to _VOLUMES. Valid characters for the drive ID / strings are: 0-9 and A-Z. */ /* By default(0), each logical drive number is bound to the same physical drive number / and only a FAT volume found on the physical drive is mounted. When it is set to 1, / each logical drive number is bound to arbitrary drive/partition listed in VolToPart[]. */ /* These options configure the range of sector size to be supported. (512, 1024, 2048 or / 4096) Always set both 512 for most systems, all memory card and harddisk. But a larger / value may be required for on-board flash memory and some type of optical media. / When _MAX_SS is larger than _MIN_SS, FatFs is configured to variable sector size and / GET_SECTOR_SIZE command must be implemented to the disk_ioctl() function. */ /* To enable sector erase feature, set _USE_ERASE to 1. Also CTRL_ERASE_SECTOR command / should be added to the disk_ioctl() function. */ /* If you need to know correct free space on the FAT32 volume, set bit 0 of this option / and f_getfree() function at first time after volume mount will force a full FAT scan. / Bit 1 controls the last allocated cluster number as bit 0. / / bit0=0: Use free cluster count in the FSINFO if available. / bit0=1: Do not trust free cluster count in the FSINFO. / bit1=0: Use last allocated cluster number in the FSINFO if available. / bit1=1: Do not trust last allocated cluster number in the FSINFO. */ /*---------------------------------------------------------------------------/ / System Configurations /---------------------------------------------------------------------------*/ /* To enable file lock control feature, set _FS_LOCK to non-zero value. / The value defines how many files/sub-directories can be opened simultaneously / with file lock control. This feature uses bss _FS_LOCK * 12 bytes. */ /* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs module. / / 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect. / 1: Enable re-entrancy. Also user provided synchronization handlers, / ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj() / function must be added to the project. */ /* The _WORD_ACCESS option is an only platform dependent option. It defines / which access method is used to the word data on the FAT volume. / / 0: Byte-by-byte access. Always compatible with all platforms. / 1: Word access. Do not choose this unless under both the following conditions. / / * Address misaligned memory access is always allowed for ALL instructions. / * Byte order on the memory is little-endian. / / If it is the case, _WORD_ACCESS can also be set to 1 to improve performance and / reduce code size. Following table shows an example of some processor types. / / ARM7TDMI 0 ColdFire 0 V850E 0 / Cortex-M3 0 Z80 0/1 V850ES 0/1 / Cortex-M0 0 RX600(LE) 0/1 TLCS-870 0/1 / AVR 0/1 RX600(BE) 0 TLCS-900 0/1 / AVR32 0 RL78 0 R32C 0 / PIC18 0/1 SH-2 0 M16C 0/1 / PIC24 0 H8S 0 MSP430 0 / PIC32 0 H8/300H 0 x86 0/1 */ /* Definitions of volume management */ /* Type of path name strings on FatFs API */ typedef WCHAR TCHAR; /* File system object structure (FATFS) */ typedef struct { BYTE fs_type; /* FAT sub-type (0:Not mounted) */ BYTE drv; /* Physical drive number */ BYTE csize; /* Sectors per cluster (1,2,4...128) */ BYTE n_fats; /* Number of FAT copies (1 or 2) */ BYTE wflag; /* win[] flag (b0:dirty) */ BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ WORD id; /* File system mount ID */ WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ OS_MUTEX* sobj; /* Identifier of sync object */ DWORD last_clust; /* Last allocated cluster */ DWORD free_clust; /* Number of free clusters */ DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */ DWORD fsize; /* Sectors per FAT */ DWORD volbase; /* Volume start sector */ DWORD fatbase; /* FAT start sector */ DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */ DWORD database; /* Data start sector */ DWORD winsect; /* Current sector appearing in the win[] */ BYTE win[512]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ } FATFS; /* File object structure (FIL) */ typedef struct { FATFS* fs; /* Pointer to the related file system object (**do not change order**) */ WORD id; /* Owner file system mount ID (**do not change order**) */ BYTE flag; /* Status flags */ BYTE err; /* Abort flag (error code) */ DWORD fptr; /* File read/write pointer (Zeroed on file open) */ DWORD fsize; /* File size */ DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */ DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */ DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */ DWORD dir_sect; /* Sector number containing the directory entry */ BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */ BYTE buf[512]; /* File private data read/write window */ } FIL; /* Directory object structure (DIR) */ typedef struct { FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */ WORD id; /* Owner file system mount ID (**do not change order**) */ WORD index; /* Current read/write index number */ DWORD sclust; /* Table start cluster (0:Root dir) */ DWORD clust; /* Current cluster */ DWORD sect; /* Current sector */ BYTE* dir; /* Pointer to the current SFN entry in the win[] */ BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ WCHAR* lfn; /* Pointer to the LFN working buffer */ WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */ } DIR; /* File status structure (FILINFO) */ typedef struct { DWORD fsize; /* File size */ WORD fdate; /* Last modified date */ WORD ftime; /* Last modified time */ BYTE fattrib; /* Attribute */ TCHAR fname[13]; /* Short file name (8.3 format) */ TCHAR* lfname; /* Pointer to the LFN buffer */ UINT lfsize; /* Size of LFN buffer in TCHAR */ } FILINFO; /* File function return code (FRESULT) */ typedef enum { FR_OK = 0, /* (0) Succeeded */ FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ FR_INT_ERR, /* (2) Assertion failed */ FR_NOT_READY, /* (3) The physical drive cannot work */ FR_NO_FILE, /* (4) Could not find the file */ FR_NO_PATH, /* (5) Could not find the path */ FR_INVALID_NAME, /* (6) The path name format is invalid */ FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ FR_EXIST, /* (8) Access denied due to prohibited access */ FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ FR_NOT_ENABLED, /* (12) The volume has no work area */ FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ } FRESULT; BYTE check_fs (FATFS* fs,DWORD sect); /*--------------------------------------------------------------*/ /* FatFs module application interface */ FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ FRESULT f_close (FIL* fp); /* Close an open file object */ FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */ FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */ FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */ FRESULT f_truncate (FIL* fp); /* Truncate file */ FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */ FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */ FRESULT f_closedir (DIR* dp); /* Close an open directory */ FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */ FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ FRESULT f_chmod (const TCHAR* path, BYTE value, BYTE mask); /* Change attribute of the file/dir */ FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */ FRESULT f_chdir (const TCHAR* path); /* Change current directory */ FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au,CHAR *name); /* Create a file system on the volume */ FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ FRESULT f_scanfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs);/* Scan number of free clusters on the drive */ int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ void byte2Word(unsigned char *byte,unsigned short *word,unsigned short cnt); WCHAR* wstrstr(WCHAR *string,WCHAR *target); WCHAR* wstrpbrk(WCHAR *string,WCHAR *target); WCHAR* wstrrchr(WCHAR *string,WCHAR target); unsigned long wstrlen(WCHAR *string); void wstrcpy(WCHAR *string,WCHAR *target); unsigned long wstrcmp(WCHAR *string,WCHAR *target); WCHAR* wstrcat(WCHAR *string, WCHAR *target); /*--------------------------------------------------------------*/ /* Additional user defined functions */ /* RTC function */ DWORD get_fattime (void); /* Unicode support functions */ WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */ WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */ /* Sync functions */ int ff_cre_syncobj (BYTE vol, OS_MUTEX* * sobj); /* Create a sync object */ int ff_req_grant (OS_MUTEX* sobj); /* Lock sync object */ void ff_rel_grant (OS_MUTEX* sobj); /* Unlock sync object */ int ff_del_syncobj (OS_MUTEX* sobj); /* Delete a sync object */ /*--------------------------------------------------------------*/ /* Flags and offset address */ /* File access control and file status flags (FIL.flag) */ /* FAT sub type (FATFS.fs_type) */ /* File attribute bits for directory entry */ /* Fast seek feature */ /*--------------------------------*/ /* Multi-byte word access macros */ /* FatFs refers the members in the FAT structures as byte array instead of / structure member because the structure is not binary compatible between / different platforms */ typedef enum { LIBER_NONE=0, LIBER_USB_TYPE, //Info int,表示磁碟機代號0~9 //Value 0:Unmount 1:Mount LIBER_USB_MOUNT, //Info= unsigned long[2], Unmount時,[1]無效 // [0]:表示磁碟機代號0~9 // [1]:表示磁碟機大小,單位KB //Value 0:Unmount 1:Mount }Lib_Error_s; extern void Lib_Info_Setup(Lib_Error_s Error,void *Info,unsigned short Value); /* Status of Disk Functions */ typedef BYTE DSTATUS; /* Results of Disk Functions */ typedef enum { RES_OK = 0, /* 0: Successful */ RES_ERROR, /* 1: R/W Error */ RES_WRPRT, /* 2: Write Protected */ RES_NOTRDY, /* 3: Not Ready */ RES_PARERR /* 4: Invalid Parameter */ } DRESULT; typedef enum { FAT_DEV_NANDFLASH=1, FAT_DEV_USB0, FAT_DEV_USB1, FAT_DEV_MMCSD, FAT_DEV_END }FAT_Dev_Type_e; /*---------------------------------------*/ /* Prototypes for disk control functions */ DSTATUS disk_initialize (BYTE); DSTATUS disk_status (BYTE); DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE); DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE); DRESULT disk_ioctl (BYTE, BYTE, void*); void disk_timerproc (void); void disk_insert(char disk,FAT_Dev_Type_e dev_type,unsigned long Start_Addr,unsigned long End_Addr,void *dev,FATFS *fs,char *disk_name); unsigned short USB_Mount_Test(FAT_Dev_Type_e dev_type); void USB_Unmount(FAT_Dev_Type_e dev_type); void USBPolling(FAT_Dev_Type_e dev_type); unsigned short Get_USB0_Disk_ID(void); unsigned short Get_USB1_Disk_ID(void); unsigned short MMCSD_Mount_Test(void); void MMCSD_Unmount(void); void MMCSDPolling(void); unsigned short Get_MMCSD_Disk_ID(void); unsigned short ListDirectory(WCHAR *name,WCHAR *out,unsigned long *out_len); unsigned short ListFile(WCHAR *name,WCHAR *out,unsigned long *out_len); unsigned short ListDirectory_Appoint(WCHAR *name,WCHAR *out,unsigned long *out_len,unsigned short appoint,unsigned short appoint_cnt); unsigned short ListFile_Appoint(WCHAR *name,WCHAR *out,unsigned long *out_len,unsigned short appoint,unsigned short appoint_cnt); void Get_Dir_File_Cnt(WCHAR *name, unsigned long *folder_cnt, unsigned long *file_cnt); unsigned short ListAllFile(WCHAR *name,WCHAR *out,unsigned long *out_len); unsigned short ListAllDirectory(WCHAR *name,WCHAR *out,unsigned long *out_len); void Remove_Directory(WCHAR *name); unsigned short Create_Directory(WCHAR *dir); unsigned long DirFreeSpace(WCHAR *dir);//return kB unsigned long ScanFreeSpace(WCHAR *dir);//return kB void FormatDisk(char disk); unsigned char Check_Disk(char disk); unsigned long Get_Disk_Space(char disk);//return kB unsigned char Check_DiskDrv_Free(char disk); unsigned short Check_Disk_Error(unsigned char disk_id); void Set_Disk_Error(unsigned char disk_id,unsigned short Error); void Fat_System_Time_Renew(unsigned short f_y, unsigned short f_m, unsigned short f_d, unsigned short f_h, unsigned short f_min,unsigned short f_s); void Set_FAT_Not_Init(unsigned char disk_id); /* Disk Status Bits (DSTATUS) */ /* Generic command (used by FatFs) */ /* Generic command (not used by FatFs) */ /* MMC/SDC specific ioctl command */ /* ATA/CF specific ioctl command */ /** * \file interrupt.h * * \brief Interrupt related API declarations. * * This file contains the API prototypes for configuring INTC for * ARM Cortex-A8 */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /** * @Component: INTC * * @Filename: intc_header.h * * @Description: Component description is not available * * Generated by: Genesis 2.0.1.3 * Autogen 2.4.0.0 * *//* ====================================================================== */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /************************************************************************* * Registers Definition \*************************************************************************/ /*************************************************************************** Field Definition Macros \**************************************************************************/ /* REVISION */ /* SYSCONFIG */ /* SYSSTATUS */ /* SIR_IRQ */ /* SIR_FIQ */ /* CONTROL */ /* PROTECTION */ /* IDLE */ /* IRQ_PRIORITY */ /* FIQ_PRIORITY */ /* THRESHOLD */ /* SICR */ /* SCR0 */ /* SCR1 */ /* SCR2 */ /* ITR0 */ /* MIR0 */ /* MIR_CLEAR0 */ /* MIR_SET0 */ /* ISR_SET0 */ /* ISR_CLEAR0 */ /* PENDING_IRQ0 */ /* PENDING_FIQ0 */ /* ITR1 */ /* MIR1 */ /* MIR_CLEAR1 */ /* MIR_SET1 */ /* ISR_SET1 */ /* ISR_CLEAR1 */ /* PENDING_IRQ1 */ /* PENDING_FIQ1 */ /* ITR2 */ /* MIR2 */ /* MIR_CLEAR2 */ /* MIR_SET2 */ /* ISR_SET2 */ /* ISR_CLEAR2 */ /* PENDING_IRQ2 */ /* PENDING_FIQ2 */ /* ILR */ /** * \file hw_types.h * * \brief Common type definitions and macros */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ //***************************************************************************** // // Define a boolean type, and values for true and false. // //***************************************************************************** typedef unsigned char tBoolean; //***************************************************************************** // // Macros for hardware access, both direct and via the bit-band region. // //***************************************************************************** /**************************************************************************** ** MACRO DEFINITIONS ****************************************************************************/ /* ** Macros which can be passed to IntPrioritySet API as hostIntRoute. */ /* To route an interrupt to IRQ */ /* To route an interrupt to FIQ */ /* ** Interrupt number list */ /***************************************************************************** ** API FUNCTION PROTOTYPES *****************************************************************************/ extern void IntAINTCInit (void); extern void IntIfClkFreeRunSet(void); extern void IntIfClkAutoGateSet(void); extern void IntProtectionEnable(void); extern void IntProtectionDisable(void); extern void IntSyncClkFreeRunSet(void); extern void IntSyncClkAutoGateSet(void); extern void IntFuncClkFreeRunSet(void); extern void IntFuncClkAutoGateSet(void); extern void IntPriorityThresholdSet(unsigned int threshold); extern void IntSoftwareIntSet(unsigned int intrNum); extern void IntSoftwareIntClear(unsigned int intrNum); extern void IntMasterIRQEnable(void); extern void IntMasterIRQDisable(void); extern void IntMasterFIQEnable(void); extern void IntMasterFIQDisable(void); extern void IntSystemEnable(unsigned int intrNum); extern void IntSystemDisable(unsigned int intrNum); extern void IntUnRegister(unsigned int intrNum); extern void IntEnable(unsigned char status); extern void IntRegister(unsigned int intrNum, void (*pfnHandler)(void)); extern void IntPrioritySet(unsigned int intrNum, unsigned int priority, unsigned int hostIntRoute); extern unsigned char IntDisable(void); extern unsigned int IntMasterStatusGet(void); extern unsigned int IntActiveIrqNumGet(void); extern unsigned int IntActiveFiqNumGet(void); extern unsigned int IntSpurIrqFlagGet(void); extern unsigned int IntSpurFiqFlagGet(void); extern unsigned int IntCurrIrqPriorityGet(void); extern unsigned int IntCurrFiqPriorityGet(void); extern unsigned int IntPriorityThresholdGet(void); extern unsigned int IntRawStatusGet(unsigned int intrNum); extern unsigned int IntPendingIrqMaskedStatusGet(unsigned int intrNum); extern unsigned int IntPendingFiqMaskedStatusGet(unsigned int intrNum); /** * \file edma_event.h * * \brief EDMA event enumeration * */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /**************************************************************************** ** MACRO DEFINITIONS ****************************************************************************/ /********************* Direct Mapped Events ********************************/ /* Events for McASP 1*/ /* MCSPI0 Channel 0 transmit event */ /* MCSPI0 Channel 0 receive event */ /* MCSPI0 Channel 1 transmit event */ /* MCSPI0 Channel 1 receive event */ /* MMCSD0 transmit event. */ /* MMCSD0 receive event. */ /* UART0 Transmit Event. */ /* UART0 Receive Event. */ /* UART1 Transmit Event. */ /* UART1 Receive Event. */ /* UART2 Transmit Event. */ /* UART2 Receive Event. */ /* MCSPI1 Channel 0 transmit event */ /* MCSPI1 Channel 0 receive event */ /* MCSPI1 Channel 1 transmit event */ /* MCSPI1 Channel 1 receive event */ /* I2C0 Transmit Event */ /* I2C0 Receive Event */ /* I2C1 Receive Event */ /* I2C1 Transmit Event */ /********************** Crossbar Mapped Events ********************************/ /* I2C2 Receive Event */ /* I2C2 Transmit Event */ /* UART3 Transmit Event. */ /* UART3 Receive Event. */ /* UART4 Transmit Event. */ /* UART4 Receive Event. */ /* UART5 Transmit Event. */ /* UART5 Receive Event. */ /* Events for McASP 0*/ /* Events for McASP 1*/ /* **EDMA Event number list */ //EDMA3 channel setting typedef enum { McaSp1_RX = (11u), McaSp1_TX = (10u), }MCASP1_Int_Flag_e; extern unsigned short McASP0_Channel; void EDMA3IntSetup(void); void EDMA3_Init(void); //#define NUM_I2S_CHANNELS (2u) extern long McASP0_Tx_Buff[3][64][(4u)]; extern long McASP0_Rx_Buff[3][64][(4u)]; void McASP0_Init(void); void McASP0_DMA_Sync(void); //TDM //#define NUM_TDM_CHANNELS (32u) extern unsigned long McASP1_Tx_Buff[3][64][(8u)]; extern unsigned long McASP1_Rx_Buff[3][64][(8u)]; void McASP1_Init(void); void McASP1_DMA_Sync(void); //#define NUM_DOWNSLOT_CHANNEL NUM_I2S_CHANNELS //新增E槽 typedef enum { Ethernet_Audio_In_L, //0 Ethernet_Audio_In_R, //1 Index_VOIP_In, //2 Index_Mic1, //3 MAX_RX_CHANNEL, //4 }Index_Audio_In_s; typedef enum { Index_Amp_L, //0 Index_VOIP_Out, //1 Index_Limiter_VOIP, //2 Index_DownSample_VOIP, //3 Index_FadeOut_L, //4 Index_Limiter_L, //5 MAX_TX_CHANNEL, // }Index_Audio_Out_s; typedef enum { EthL_L, //0 //eth left EthL_R, //1 //eth right //預留 VOIP_InL, //2 //VOIP Mic1_L, //3 AEC_Mic1_L, //4 NS_AEC_L, //5 AGC_VOIP_L, //6 AGC_Mic1_L, //7 Eq_VOIP_L, //8 Eq_Mic1_L, //9 Hi_VOIP_L, //10 Hi_Mic1_L, //11 Lo_VOIP_L, //12 Lo_Mic1_L, //13 PEQ_Eth_L, //14 Duck_Out_L, //15 Duck_Out_R, //16 //預留 Cal_Temp, //17 Cal_Temp2, //18 Zero_Temp, //19 Pink_Noise_L, //20 Gate_L, //21 Old_VOIP_L, //22 Num_Line, }Index_DSP_Line; enum Chip_Table { TABLE_SIZE, //0 SAMPLE_RATE, //1 HW_INPUT_AUDIO_CHANNELS_TABLE_MAPPING, //2 HW_OUTPUT_AUDIO_CHANNELS_TABLE_MAPPING, //3 }; typedef enum { Down_Board, //0 //順序不可改 Up_Board, //1 //順序不可改 E_Board, //2 //順序不可改 Num_Stage_Board, //3 //分成上下層兩段 //順序不可改 DMA_Receive, //4 DMA_Transmit, //5 Finish_Receive, //6 Finish_Cal, //7 SP1_Off, //8 //sp1 未使用 Same_Interrupt_SP01, //9 DSP_ON, //10 DSP_Bypass, //11 DMA_DigiMic_To_AMP, //12 //Rx DgMic to A DMA_AUX_To_AMP, //13 //使輸入port1對至輸出port1輸出 Tone_TO_MIC, //14 //自產tone 取代Mic輸入 for Flag_In_Set DATA_TO_AMP, //15 MCU丟聲音DATA到AMP輸出 }Common_Status_s; typedef struct { unsigned long TimeBase10ms; //sample 點計算 unsigned short Index_Function; unsigned short Fromat; //I2s or TDM unsigned short COMM_Rx; unsigned short COMM_Tx; unsigned short Flag_SP[3]; //SP0與SP1是否有收完 //[3] 紀錄sp1有無使用狀況 unsigned char Flag_First_NRT; unsigned char Update_NRT_Parameter; //參數改變時 //unsigned char First_I2S_Enable; unsigned short Board[3]; //目前只能接兩張卡, 0 為 C 位置, 1 為 D 位置, 2 為 E 位置//可能接 IO, TC //此對應到硬體版子 ID unsigned short Flag_In_Set; //Tone_TO_AUX unsigned short Flag_Out_Set; //DMA_Bypass, DMA_Arrange_Bypass unsigned short Flag_First_RT; }Process_Status; typedef struct { unsigned short Num[Num_Stage_Board]; //0: 下版, 1 : 上版In channel 數 unsigned short Index[Num_Stage_Board][(4u)]; // //0: 下版, 1 : 上版 }Index_Channel_s; typedef struct { unsigned short Board_HW_Table[2][3]; //[In:0, 1: out][board C :0, board D : 1, board E : 2] //從Comman 收到的 table 對應到OCTO_Sr_Slot_ID_e Index_Channel_s In; Index_Channel_s Out; float OutChan[MAX_TX_CHANNEL][64]; //int *ptr_In; }Audio_To_HW_Channel_s; extern Process_Status sProcess_Status; extern Audio_To_HW_Channel_s AudioTo_HWChan; extern float AudioBufferin[MAX_RX_CHANNEL][64]; extern float AudioBufferout[MAX_TX_CHANNEL][64]; extern float Audio_Temp_buffer[Num_Line][64]; extern float Buf_Trans_DSP[16][64]; extern const unsigned short Offset_To_FunctNo_NRTParaTable; extern const unsigned int BIT32_SET[32]; extern const unsigned int BIT32_CLEAR[32]; extern const unsigned short BIT16_SET[16]; extern const unsigned short BIT16_CLEAR[16]; extern const unsigned char BIT8_SET[8]; extern const unsigned char BIT8_CLEAR[8]; extern int Index_SP0_Temp; extern int Index_SP1_Temp; extern int DMA_SP0_Rx_Temp[2][64][(4u)]; extern int DMA_SP0_Tx_Temp[2][64][(4u)]; extern int DMA_SP1_Rx_Temp[2][64][(8u)]; extern int DMA_SP1_Tx_Temp[2][64][(8u)]; void DSPThread_Init(void); void Match_DSP_To_HW_Channel(Audio_To_HW_Channel_s *ptr); void DSP_Table_Reset(void); extern void Set_Audio_Line(void); extern float Level_Ref_Modify; extern float dB_Level_Ref_Modify; typedef enum { Ethernet_Audio_In, //0 VOIP_In, //1 Mic1_In, //2 //沒問題後將此拿掉 NUM_DSP_INPUT, //3 }ID_DSP_INPUT_s; //=====Ap================= typedef struct { unsigned short Num_In; unsigned short LED_RTO; unsigned short LED_Signal; unsigned short LED_Clip; unsigned short Mute; unsigned short Bypass; unsigned short Clip_Th[2]; }New_Input_AP_s; typedef struct { unsigned short Index_In; unsigned short Level[2]; unsigned short Index_Out; unsigned short Display_Volume[2]; }New_Input_Channel_AP_s; typedef struct { New_Input_AP_s Main; New_Input_Channel_AP_s Ch[1]; }AP_New_Input_Struct; //=====RT================= typedef struct { int Command_Num; int Num_In; int Cnt; }New_Input_RT_s; typedef struct { float Sum_Square; float Level; unsigned long Address_In; unsigned long Address_Out; }New_Input_Channel_RT_s; typedef struct { New_Input_RT_s Main; New_Input_Channel_RT_s Ch[1]; }RT_New_Input_Struct; //=====Temp================= typedef struct { unsigned long Index; }New_Input_NRT_Temp_s; typedef struct { float Ave[8]; }New_Input_Channel_NRT_Temp_s; typedef struct { New_Input_NRT_Temp_s Main; New_Input_Channel_NRT_Temp_s Ch[1]; }NRT_Temp_New_Input_Struct; extern void NRT_Input(AP_New_Input_Struct *ptr_AP, RT_New_Input_Struct *ptr_RT, NRT_Temp_New_Input_Struct *ptr_NRT); void NRT_New_Input(void); extern void NRT_New_Input_Fix(New_Input_AP_s *ptr_AP, New_Input_RT_s *ptr_RT, New_Input_NRT_Temp_s *ptr_NRT_Temp); extern void Asm_Input_Fix(int *ptr_num); extern void Set_AudioLine_Input(void); typedef enum { ID_Output1, //0 ID_Output_VOIP, //1 NUM_DSP_OUTPUT, //2 }ID_DSP_OUTPUT_s; //=====Ap================= typedef struct { unsigned short Num_In; unsigned short Mute_Mode; //[0~12] Mute, [13~15]:Mode unsigned short LED_Signal; unsigned short LED_Overload; unsigned short Th_Over[2]; }New_Output_AP_s; typedef struct { unsigned short Index_In; unsigned short Level[2]; unsigned short Index_Out; unsigned short Display_Volume[2]; }New_Output_Channel_AP_s; typedef struct { New_Output_AP_s Main; New_Output_Channel_AP_s Ch[1]; }AP_New_Output_Struct; //=====RT================= typedef struct { int Command_Num; int Num_In; int Cnt; }New_Output_RT_s; typedef struct { float Sum_Square; float Level; unsigned long Address_In; unsigned long Address_Out; }New_Output_Channel_RT_s; typedef struct { New_Output_RT_s Main; New_Output_Channel_RT_s Ch[1]; }RT_New_Output_Struct; //=====NRT_Temp================= typedef struct { unsigned long Index; }New_Output_NRT_Temp_s; typedef struct { float Ave[8]; }New_Output_Channel_NRT_Temp_s; typedef struct { New_Output_NRT_Temp_s Main; New_Output_Channel_NRT_Temp_s Ch[1]; }NRT_Temp_New_Output_Struct; extern void NRT_Output(AP_New_Output_Struct *ptr_AP, RT_New_Output_Struct *ptr_RT, NRT_Temp_New_Output_Struct *ptr_NRT); void NRT_New_Output(void); extern void NRT_New_Output_Fix(New_Output_AP_s *ptr_AP, New_Output_RT_s *ptr_RT, New_Output_NRT_Temp_s *ptr_NRT_Temp); extern void Asm_Output_Fix(int *ptr); extern void Set_AudioLine_Output(void); //=======RT Eq, filter use=================== typedef struct { //可拉式編輯rt table一開使會全清, 固定式寫法一開始需clean 一次 float x0[4]; //SIMD, 4band一起處理 float x1[4]; float x2[4]; float y0[4]; float y1[4]; }RT_Old_Band_s; //=======NRT Eq, filter use=================== typedef struct { float b0[4]; float b1[4]; float b2[4]; float a1_N[4]; //固意取負號 float a2_N[4]; }Coeff_Order2_SIMD_s; void Non_RealTime_Procedure_modify(void); typedef struct { float *ptr_coeff; float Old[4]; long Sum; }Filter_Return_RMS_s; typedef struct { float Old[10]; }Band2_EQ_s; typedef enum { ID_PEQ_Eth, //0 NUM_DSP_PEQ, //1 }ID_DSP_PEQ_s; //======AP===================== typedef struct { unsigned short Index_In; unsigned short Index_Out; unsigned short Allpass_Num_of_Band; //[0]:all pass, [1~5]:num of band unsigned short Bypass; unsigned short Fs; unsigned short Reserve; }PEQ_AP_s; typedef struct { unsigned short Fc[2]; unsigned short Q[2]; unsigned short Gain[2]; }PEQ_AP_Parameter_s; typedef struct { PEQ_AP_s Main; PEQ_AP_Parameter_s Band[16]; }AP_PEQ_Struct; //======RT===================== typedef struct { unsigned long Command_Num; unsigned long Address_In; unsigned long Address_Out; unsigned long Num_Band; unsigned long Address_Coeff; unsigned long Flag_PingPong; }PEQ_RT_s; typedef struct { PEQ_RT_s Main; RT_Old_Band_s Band[4]; }RT_PEQ_Struct; //======NRT===================== typedef struct { Coeff_Order2_SIMD_s Coeff[2][4]; //ping pong }NRT_PEQ_Struct; //對應到NRT Temp Table //======Inner===================== typedef struct { float Temp[2][64]; //節省效能 : 避免輸入輸出讀同一個位置, 只有4 band以上才會使用到此 }PEQ_DSP_Inner_s; extern Filter_Return_RMS_s BP20k; extern void NRT_PEQ_Fix(PEQ_AP_s *ptr_AP, PEQ_RT_s *ptr_RT, Coeff_Order2_SIMD_s *ptr_NRT_Temp); void NRT_GEQ(void); void NRT_PEQ(); //extern void Asm_Input_Fix(int *ptr); extern void Asm_EQ_Fix(unsigned long out, unsigned long in, unsigned long *ptr_add, float *temp_buf); extern void Set_AudioLine_PEQ(void); extern float Temp_PEQ[2][64]; //for PEQ asm 中, 存取位置分開, 以節省效能 extern float CoeffOrder2_NS[5]; //調音質用 extern float Coeff_LP_8k[5]; extern Filter_Return_RMS_s VOIP_TX_LP8k; //1. 輸入長度不可小於4 //2. 輸入為4的倍數時, 輸出可聽聲音是否正確 void Filter_Return_RMS(float *out, float *in, int len, Filter_Return_RMS_s *ptr_s); void Asm_EQ_Const_Coeff_2Band(float *in,float *out, const float *coeff, float **ptr_old); //;因可拉式物件關係, 所以ptr_old要給位置的指標 ;len 改內建, 此處不可用物件指標, for 可拉式物件 //#include "RT_Processor.h" enum Define_Linear_Fade { FADE_IN = 1, //1 FADE_OUT, //2 }; typedef enum { Reset_Cycle =1, //1 Gate_Cycle, //2 Cal_All_ms, //3 }Cycle_DSP; typedef enum { PingRxTx_PongCal, //0 PongRxTx_PingCal, //1 Not_Full_PiPo, //2 Full_PiPo, //3 }Flag_PingPong; typedef struct { unsigned short Symmetry; unsigned short Quarter; unsigned short Total; unsigned short Log2; unsigned short Half; unsigned short Plus; float Inv; }Len_s; typedef struct { int Index; int Offset; unsigned int Log_Cycle[40]; float Log_ms[40]; float th; }Cycle_Record_s; typedef struct { int Cnt; float Level; float Step; }Linear_Fade_s; typedef struct { float Old; float Inv; float Arph; //for new float Arph_Plus; //for old }Regulate_DC_s; typedef struct { float re; float im; }Complex_s; typedef struct { float *ptr_Rx; float *ptr_Tx; float *ptr_Cal_Rx; float *ptr_Cal_Tx; Flag_PingPong Flag; Flag_PingPong Flag_Full; unsigned short Cnt_Cal; unsigned short RT_Len; unsigned short Total_Len; }PingPong_S; typedef struct { int Cnt; int Ave_Time; float Square_Sum; float dB; }dB_Cal_s; //紀錄db 響應 void Set_Linear_Fade(Linear_Fade_s *ptr, int type); void Asm_Level_Multi(float *out, float *in, float *level, int len); void Initial_All_Counters(int do_reset, int enable_long_record); unsigned int Get_Cyclecount (void); void Pre_Cycle_Record(unsigned int * cycle); void Post_Cycle_Record(unsigned int * pre_cycle, float *ms); void Initial_Cycle_Counters(int); void Reset_Cycle_Counters(void); void Get_Cycle(unsigned int *); void Detect_Cyle(Cycle_Record_s *ptr, Cycle_DSP flag); void Test_Performance(void); void Complex_Abs(Complex_s *ptr, float *out, int len); void Asm_Abs_Complex(Complex_s *ptr, float *out, int len); void Asm_Window_Cal(float *, float *, float *, int); void Asm_Euler_Eq(float *in, float *coeff, Complex_s *ptr_out); //;r0 : in, r1 : 分母buf, r2: out void Asm_Atan_Eq(Complex_s *in, float *out, float *coeff); void Initial_Atan_Coeff(void); void Initial_Euler_Coeff(void); void Set_Full_Status_PiPo(PingPong_S *ptr_s); void Ping_Pong_RT(float *in, float *out, PingPong_S *ptr_s); void Initial_Cycle_Record(Cycle_Record_s *ptr, float th, int offset); void Initial_Cal_dB(dB_Cal_s *ptr, int len_ave_time); void Asm_Square_Sum_32Sample_Base(float *old, float *in, int *cnt, int len); //使用資料為32的倍數 void DC_Regulate(float *in, float *out, float *dc); void Reset_DC_Regulate(Regulate_DC_s *ptr); void Asm_DC_Regulate_P32(float *out, float *in, Regulate_DC_s *dc, long len); extern void Asm_Addition(float *out, float *inA, float *inB, long len); //長度需為16的倍數 extern unsigned short Down_Sample_48kTo16k( float *out, float *in, int len_in, unsigned long *index_record); extern unsigned long Trans_ms_To_SampleLen(float ms, float fs); void Asm_Copy32(float *out, float *in, long len); extern Linear_Fade_s Fade_AudioOut; extern Cycle_Record_s Record_Cycle; extern const unsigned int Bit_Check[32]; extern const unsigned int Bit_Clear[32]; extern Regulate_DC_s Mic_DC; //FFT_s 宣告指標, 方便程式重覆利用 //另外宣告各組長度要使用實體位置, 藉Initial Fuction將其設起, 再將gloab FFT_s指標指到那 typedef struct { Len_s *Len; Complex_s * W; unsigned short *IP; //指出各階段資料排列 unsigned short *Index; unsigned short *Index_Asm; }FFT_s; //=============實體位置 1024 宣告============================== typedef struct { Len_s Len; Complex_s W[(1024 >> 1)]; unsigned short IP[10][1024]; //指出各階段資料排列 unsigned short Index_Initial[1024]; unsigned short Index_Initial_Asm[1024]; }FFT_1024_s; //一組長度只需宣告一組, 讀取係數與排列使用 //=============實體位置 1024 宣告============================== typedef struct { Len_s Len; Complex_s W[(256 >> 1)]; unsigned short IP[8][256]; //指出各階段資料排列 unsigned short Index_Initial[256]; unsigned short Index_Initial_Asm[256]; }FFT_256_s; //一組長度只需宣告一組, 讀取係數與排列使用 //=============實體位置 64 宣告============================== typedef struct { Len_s Len; Complex_s W[(64 >> 1)]; unsigned short IP[6][64]; //指出各階段資料排列 unsigned short Index_Initial[64]; unsigned short Index_Initial_Asm[64]; }FFT_Len_64_s; //一組長度只需宣告一組, 讀取係數與排列使用 //=============實體位置 32 宣告============================== typedef struct { Len_s Len; Complex_s W[(32 >> 1)]; unsigned short IP[5][32]; //指出各階段資料排列 unsigned short Index_Initial[32]; unsigned short Index_Initial_Asm[32]; }FFT_Len_32_s; //一組長度只需宣告一組, 讀取係數與排列使用 //========================================================== typedef struct { float Rx_Ping_Buf[256]; float Rx_Pong_Buf[256]; float Tx_Ping_Buf[256]; float Tx_Pong_Buf[256]; PingPong_S Status; }FFT_PingPong_S; extern void Asm_FFT(Complex_s *, float *, unsigned short *, unsigned short *); extern void RFFT_Cal(Complex_s *out, FFT_s *ptr_s, float *in); extern void FFT_Initial(FFT_s *ptr_s); extern void FFT32_Initial(FFT_s *ptr_s); extern void FFT64_Initial(FFT_s *ptr_s); extern void FFT256_Initial(FFT_s *ptr_s); extern void FFT1024_Initial(FFT_s *ptr_s); //void Asm_RFFT_In_Arrange_ORI(float *, int, Complex_s *, unsigned short *); extern void Asm_RFFT_In_Arrange(float *, int, Complex_s *, unsigned short *); extern void CFFT_Cal(Complex_s *out, FFT_s *ptr_s, Complex_s *in); //直接fft運算, 結果為複數, 需再進行排列才可給聲音使用 extern void IFFT_Cal(float *out, FFT_s *ptr_s, Complex_s *in); //排列fft運算, 結果為浮點, 可給聲音轉換直接使用 extern void RT_FFT_Ping_Pong(float *in, float *out, FFT_PingPong_S *ptr_F); extern void Cal_FFT_Trans(FFT_PingPong_S *ptr_F, FFT_s *ptr_FFT); extern FFT_s FFT_Pitch; extern FFT_s FFT_AEC; extern FFT_s ptr_FFT64; //指標 extern FFT_s ptr_FFT256; extern FFT_s ptr_FFT1024; extern unsigned short Initial_Arrange[256]; //====================Overlap======================== //pitch overlap 使用 typedef struct { int Len_Step; //256 int Len_Total; //1024 int Size_Hop; //升降頻皆有對應的Size_Hop int Index_An_Pre; //最新剛算完的一段 int Index_An; //最舊的一段 int Index_Sy; }Overlap_Status_s; typedef struct { int Index_Circular; int Len[2]; //給組語抓circular buf 資料的長度 unsigned int ptr_End_Circular; //與len順序需固定 float Buf_Circular[256]; float Buf_Window[4][256]; }Overlap_Analysis_s; typedef struct { int Index; //Synthesis 要讀取的紀錄, 有寫入時將其歸0, 每次讀Size_Hop, 讀至Len_Total float Buf[256]; }Overlap_Synthesis_s; typedef struct { Overlap_Status_s Sta; //status Overlap_Analysis_s An; Overlap_Synthesis_s Sy[4]; }Overlap_s; extern void Initial_Overlap(Overlap_s *ptr); extern void Asm_Overlap_Analysis(float *in, float *circular, float *out, int *len); extern void Analysis_Overlap(float *in, Overlap_s *ptr); extern void Synthesis_Overlap(float *out, Overlap_s *ptr); extern const float Coeff_Window_Overlap[256]; typedef enum { ID_NS1, //0 NUM_ID_NS, //1 }ID_NS_s; //====================指標移動======================== //======================================================= //====================NS======================== //#define HOLD_TIME_NS 10 //50 //約50ms //====================AP======================== typedef enum //勿超過16 { Bypass_Noise_Total, //0 //直接copy in to out Bypass_EM, //1 //仍會經過overlap 與 fft 轉換 Initial_NS_Overlap, //2 //inner table initial 判斷使用 }Noise_Flag_AP; typedef struct { unsigned short Falg; unsigned short Input_Index; unsigned short Output_Index; unsigned short Th[2]; //u16 Vol_In[2]; //以下對應AP時需再討論 //先填到其他物件display unsigned short Vol_Out[2]; //先填到其他物件display unsigned short Reserve; //for 對齊 }NS_AP_s; //====================RT======================== typedef enum { Flag_Update_Noise=16, //16 //設起來時, update noise }Noise_Flag_RT; typedef struct { unsigned long Command_Num; unsigned long Flag; //low 16 bit給AP, high 16 bit inner 使用 unsigned long Flag_Initial; //inner table initial 判斷使用 unsigned long Add_Input; unsigned long Add_Out; unsigned long Cnt; long Cnt_Hold; float Th; float Square_Sum_In; float Old_Square_Sum_In; float Square_Sum_Out; }NS_RT_s; //====================Inner======================== typedef enum { Arph_Noise, //0 //for new //越小時, update越慢, th低時則人聲不易有雜音, 但人聲若都低於th時, 則人聲消除會有雜音, 且水聲越明顯, 反之, 越大時, 人聲都低於th不會有雜音, 但是小聲時人聲易有雜音 Arph_Priori_New, //1 // Arph_Zeor, //2 //for new //方便組語控制 Arph_Priori_NewS, //3 //同樣的Arph_Priori_New 值, 只是方便取值所以重覆填 Arph_Priori_Old, //4 //(1-Arph_Priori_New) Num_ArphIndex_Noise, //5 }Noise_Arph_s; typedef struct { Overlap_s Overlap; float Old_Th; float NoiseE[129]; //Noise 頻譜smooth 能量 float Gain[129]; //需old資料smooth, 所以需要存old值 float OldPost[129]; //需存之前資料計算用, 此與gain 相對位置不可更改 Filter_Return_RMS_s NS_PEQ; }Inner_NS_s; typedef struct { NS_AP_s AP; NS_RT_s RT; Inner_NS_s Inner; }NS_s; extern float Arph_NoiseSuppress[Num_ArphIndex_Noise]; extern float Sq_In_NS; extern NS_AP_s AP_NS; extern void NRT_NS(void); extern void RT_NS(void); extern void NRT_NS_Fix(NS_AP_s *ptr_AP, NS_RT_s *ptr_RT); extern void RT_NS_Fix( NS_RT_s *ptr_RT, Inner_NS_s *ptr_Inner); extern void Asm_Update_Noise_Post(float *post, float *out_noise, Complex_s *in, float *arph); extern void Asm_Gain_Priori_Noise(Complex_s *out, Complex_s *in, float *gain, float *arph); extern void Set_AudioLine_NS(void); typedef enum { ID_AGC_VOIP, //0 ID_AGC_Mic1, //1 NUM_DSP_AGC, //2 }ID_AGC_s; typedef struct { unsigned short Flag_Action_Bypass_Release; //0: LED Action, 1 : Bypass, 2 : Determine the release time working or not. unsigned short Input_Index; unsigned short Output_Index; unsigned short Time_Average; unsigned short Th[2]; unsigned short Attact_Time; unsigned short Release_Time; unsigned short Target[2]; unsigned short Max_Gain[2]; unsigned short Display_Compensation_Gain[2]; }AGC_AP_s; typedef struct { unsigned long Command_Num; unsigned long Add_Input; unsigned long Add_Out; float Square_Sum; float Old_Gain; float Current_Gain; float Arph; unsigned long Cnt_Input; }AGC_RT_s; typedef struct { unsigned long Cnt_AVG_OverTh; int Cnt_UnderTh; float Old_SquareSum; float Time_OldAVG; }AGC_NRT_Temp_s; typedef struct { AGC_AP_s AP; AGC_RT_s RT; AGC_NRT_Temp_s NRT_Temp; }AGC_s; extern void NRT_AGC_Fix_Cal(AGC_AP_s *ptr_AP, AGC_RT_s *ptr_RT, AGC_NRT_Temp_s *ptr_NRT_Temp); extern void Asm_AGC_Fix_Cal(long in, long out, long len, float *ptr); extern void NRT_AGC(void); extern void Set_AudioLine_AGC(void); typedef enum { Clear_HwAGC_S, //0 Hold_Status, //1 Auto_HwAGC, //2 Manually_HwAGC, //3 }HwAGC_Status_s; typedef enum { Mic_Sensivity_6dB, //0 Mic_Sensivity_8dB , //1, Mic_Sensivity_10dB, //2 Mic_Sensivity_12dB, //3 Mic_Sensivity_14dB, //4 Mic_Sensivity_16dB, //5 Mic_Sensivity_18dB, //6 Mic_Sensivity_20dB, //7 Mic_Sensivity_22dB, //8 Mic_Sensivity_24dB, //9 Mic_Sensivity_26dB, //10 Mic_Sensivity_28dB, //11 Mic_Sensivity_30dB, //12 Mic_Sensivity_32dB, //13 Mic_Sensivity_34dB, //14 Mic_Sensivity_36dB, //15 Num_Set_Mic_Sensivity, //20 }HwAGC_Set_s; typedef enum { Index_HWAGC_DgMic, //0 NUM_DSP_HWAGC, //1 }Index_HWAGC; typedef struct { unsigned long Mode; unsigned long Set; unsigned long Set_Pre; unsigned long Display; unsigned long Flag_Hold; unsigned long CntOver; unsigned long CntUnder; unsigned long CntHold; float Square_Sum; }HwAGC_Control_s; typedef struct { AGC_AP_s AGC_AP; unsigned short Mode; unsigned short Set; unsigned short Display; unsigned short Mute; unsigned short Display_Volume[2]; short Base_dBSet; //設定此基準點, 在autoset時, 會參考此基準點改變th short Reserve123; }AP_HwAGC; typedef struct { AGC_NRT_Temp_s AGC_NRT_Temp; unsigned long Set_Pre; unsigned long Flag_Hold; unsigned long CntOver; unsigned long CntUnder; unsigned long CntHold; }HWAGC_NRT_Temp_s; typedef struct { AGC_RT_s AGC_RT; }HWAGC_RT_s; extern HwAGC_Control_s HwAGC; extern long Display_Set_HwMic[Num_Set_Mic_Sensivity]; extern void Initial_HwAGC(AP_HwAGC *ptr_AP, HWAGC_NRT_Temp_s *ptr_NRT_Temp); extern void NRT_HwAGC_Fix_Cal(AP_HwAGC *ptrHw_AP, HWAGC_RT_s *ptrHw_RT, HWAGC_NRT_Temp_s *ptrHw_NRT_Temp, NS_AP_s *ptr_NS); extern void Set_AudioLine_HWAGC(void); typedef enum { ID_Ducker1, //0 NUM_ID_Ducker, //1 }ID_Ducker_s; typedef struct { unsigned short Flag_Active_Bypass_Stereo_Fs; //0: LED Active, 1 : Bypass, 2 : Stereo, 8~15 Sample rate ratio unsigned short Input_Index; unsigned short Speech_Index; unsigned short Output_Index; unsigned short Th[2]; unsigned short Response_Time; unsigned short Hold_Time; unsigned short Attact_Time; unsigned short Release_Time; unsigned short Deepth_Response[2]; unsigned short Gain_Speech[2]; unsigned short Input2_Index; unsigned short Output2_Index; }Ducker_Stereo_AP_s; typedef struct { unsigned short Flag_Active_Bypass_Stereo_Fs; //0: LED Active, 1 : Bypass, 2 : Stereo, 8~15 Sample rate ratio unsigned short Input_Index; unsigned short Speech_Index; unsigned short Output_Index; unsigned short Th[2]; unsigned short Response_Time; unsigned short Hold_Time; unsigned short Attact_Time; unsigned short Release_Time; unsigned short Deepth_Response[2]; unsigned short Gain_Speech[2]; }Ducker_Mono_AP_s; typedef struct { unsigned long Add_Input; unsigned long Add_Speech; unsigned long Add_Out; }Ducker_Mono_IO_s; typedef struct { unsigned long Add_Input; unsigned long Add_Input2; unsigned long Add_Speech; unsigned long Add_Out; unsigned long Add_Out2; }Ducker_Stereo_IO_s; typedef struct { float Peak_Speech_In; float Arph; float Gain_Target_Out; float Gain_Old_Out; float Gain_Target_Speech; float Gain_Old_Speech; float Peak_Sum_Speech_In; float Cnt_Sum_Speech; }Ducker_Cal_s; typedef struct { unsigned long Command_Num; Ducker_Stereo_IO_s IO; Ducker_Cal_s Cal; }Ducker_Stereo_RT_s; typedef struct { unsigned long Command_Num; Ducker_Mono_IO_s IO; Ducker_Cal_s Cal; }Ducker_Mono_RT_s; typedef struct { unsigned long Flag_Response_Hold; float Cnt_Response; float Cnt_Hold; }Ducker_NRT_Temp_s; extern void NRT_Ducker(); extern void NRT_Ducker_Fix(Ducker_Mono_AP_s *ptr_AP, Ducker_Cal_s *ptr_RT, Ducker_NRT_Temp_s *ptr_NRT_Temp); extern void Asm_Ducker_Mono(Ducker_Mono_IO_s *ptr_IO, Ducker_Cal_s *ptr); extern void Asm_Ducker_Stereo(Ducker_Stereo_IO_s *ptr_IO, Ducker_Cal_s *ptr); extern void Ducker_Initial(int *ptr_rt_table, unsigned short *ptr_ap_table); extern void Set_AudioLine_Ducker(void); typedef enum { Slop_6dB, //0 Slop_12dB, //1 Slop_18dB, //2 Slop_24dB, //3 Slop_30dB, //4 Slop_36dB, //5 Slop_42dB, //6 Slop_48dB, //7 }Slop_Filter_s; typedef enum { NUM_DSP_Filter=1, //for mcu use 1 }Index_DSP_Filter; //======AP===================== typedef struct { unsigned short Flag; //[0~3] slop, [4~6] Mode, [7]Mute, [8]Bypass, {9]Type unsigned short Fc[2]; unsigned short Index_In; unsigned short Index_Out; unsigned short Level[2]; unsigned short Reserve; }Filter_AP_s; //======RT===================== typedef struct { unsigned long Command_Num; unsigned long Address_In; unsigned long Address_Out; unsigned long Address_Coeff; float Level; unsigned long Flag_PingPong; RT_Old_Band_s Old; }FILTER_HiLo_RT_s; //======NRT===================== typedef struct { unsigned long Nun_Band; Coeff_Order2_SIMD_s Coeff[2]; //ping pong }NRT_FILTER_HiLo_Struct; //對應到NRT Temp Table //Total typedef struct { Filter_AP_s AP; FILTER_HiLo_RT_s RT; NRT_FILTER_HiLo_Struct NRT; }FILTER_HiLo_S; void NRT_Filter_HiLoPass_Fix(Filter_AP_s *ptr_AP, FILTER_HiLo_RT_s *ptr_RT, NRT_FILTER_HiLo_Struct *ptr_NRT_Temp); //extern void Asm_Filter_HiLoPass_Fix(u32 out, u32 in, u32 *ptr_add, PEQ_DSP_Inner_s *ptr_inner); void NRT_Filter_HiLoPass(); extern void Asm_HiLoPass_Fix(unsigned long out, unsigned long in, unsigned long *ptr_coeff); extern void BypassFilterCoeff(NRT_FILTER_HiLo_Struct *ptr_NRT_Temp, unsigned short index); //#include "RT_Processor.h" //=========賡批=============================== typedef enum { ID_AEC1, //0 NUM_ID_AEC, //1 }ID_AEC_s; //=================================================== //===================AEC main======================================= //===================FIR======================================= //==================AEC FFT =================================== //===================NLMS======================================= //===================NLP======================================= //================InterAction======================= typedef enum { Index_Near_AEC, //0 Index_Ref_AEC, //1 Index_Out_AEC, //2 Mic_Too_Loud, //3 NLP_Bypass, //4 FilterBank_Bypass, //5 AEC_Bypass_RT, //6 AEC_Hold_RT, //7 AEC_Reset_RT, //8 DoubleTalk_AEC, //9 Detect_Echo, //10 Restore_AEC, //11 Error_RefAEC, //12 //ref 芣 }AEC_Use_s; typedef enum { Perform_AEC, //0 Bypass_AEC, //1 Hold_AEC_Coeff, //2 }AEC_AP_Coefficient_s; typedef enum { Soft_NLP, //0 Medium_NLP, //1 Aggressive_NLP, //2 Off_NLP, //3 }AEC_AP_NLP_s; typedef enum { LED_Echo_AEC, //0 LED_Near_Signal_AEC, //1 }AEC_LED_s; typedef enum { Normal_PathStatus, //0 //泱raing, 銝gain 1,0瘜 Traning_Echo_Status, //1 Path_Change_Status, //2 }Status_Path_AEC_s; //======AP===================== typedef struct { unsigned short Index_Ref; unsigned short Index_Ref_Channel; unsigned short Index_Near; unsigned short Index_Near_Channel; unsigned short Index_Out; unsigned short Index_Out_Channel; }AP_AEC_Index_s; typedef struct { unsigned short Flag_NLP; unsigned short LED_Echo_Signal; unsigned short ERLE[2]; //0: L, 1:H unsigned short Far_Volume[2]; unsigned short Near_Volume[2]; unsigned short Flag_AEC_Coeff; //[0~1] 0:perform, 1:bypass, 2:hold, [2]:reset, [3] noise reduction [4]BIT_Near_AEC unsigned short Th_Near[2]; unsigned short Level[2]; unsigned short NR_Level[2]; unsigned short Reserve; }AP_AEC_Display_Control_s; typedef struct { unsigned short ID_NumIn_NumOut; //[0~3]ID, [4~7]Num In, [8~11]Num Out unsigned short MaskIn_MaskOut; //[0~7]Mask In, [8~11]Mask Out AP_AEC_Index_s Index; AP_AEC_Display_Control_s Parameter; }AP_AEC_s; //==============NRT Temp===================== typedef struct { //霈 float Level_Speech_Ducker; float Level_OutL; float Level_OutR; float Level_Codec_Add; //桀隞 24 dB 箏箸 //頛詨 float Th_AGC_Hide; }NRT_InterAction_s; typedef struct { Filter_AP_s AP_Setting; //near far 閮凋璅 //銝畾萄芣撠蚓, }uf撠朣憿 NRT_FILTER_HiLo_Struct Coeff_Filter_AEC; NRT_InterAction_s InterAction; }NRT_AEC_s; //=====RT Inner============================= typedef struct { Len_s Len; Complex_s Cal[32]; Complex_s W[16]; unsigned short IP[5][32]; //箏畾菔 }AEC_FFT_s; typedef struct { int Index; float *ptr_End; float Old[10][32]; }Filter_Bank_s; typedef struct { int Index_RMS; float Buf_RMS[32]; float Ave_RMS; float dB; //ave 21 ms float dB_Immediate; float dB_Smooth; //smooth 500ms }dB_AEC_Cal_s; typedef struct { float Target; float Old; float Arph; }NLP_AEC_s; typedef struct { unsigned long Status; NLP_AEC_s Gain_Active; long Cnt_Continuous_Echo; //閮蝞臬阡蝥牠cho瘜 long Cnt_LessERLE; //閮蝞撠潭活 long Cnt_Reduce; //閮蝞銵唳 }Change_Path_AEC_s; typedef struct { Filter_Bank_s FB[3]; //0 :near, 1: far, 2:out Change_Path_AEC_s Path; }AEC_Inner_s; //==========RT======================= typedef struct { //批 : //u32 Detect_Echo; //敹恍, 蝯再GC雿輻 //孵莧EC_RT_Flag float Level_Ref; //撠Ref敺敶梢輸喲隞嗥level靘 float Level_Codec_Shift; //覓OIP Tx(頛詨16 bit), 亙蝡舀曉之頞憭, 甇文舐葬撠頞憭 float dB_MicOffset; float dB_SpkOffset; //撠Ref敺敶梢輸喲隞嗥dB靘 }RT_InterAction_s; typedef struct { unsigned long Command_Num; unsigned long Add_Ref; unsigned long Add_Near; unsigned long Add_Out; int Flag; //Bypass 閮剛絲撠雿蝵 int Flag_Hold; //喲撠, hold int Cnt_Hold; int Record_Reset; //reset 舫0 or 1, 寡撠梢脣餃 float Th_Mic_Min; //dB float Th_Mic_Max; //dB float Th_Ref_Min; //dB dB_AEC_Cal_s dCal[4]; //0:near, 1:Far, 2:out //甇山quare 箇嗆活rms 脣雿蝵 NLP_AEC_s NLP; unsigned long Flag_Initial; //inner table initial 斗瑚蝙 FILTER_HiLo_RT_s Near_Filter; FILTER_HiLo_RT_s Ref_Filter; RT_InterAction_s InterAction; }RT_AEC_s; extern void Check_NLMS_Reset(RT_AEC_s *ptr, AP_AEC_Display_Control_s *ptr_AP); //NRT check extern void Set_NLMS_Reset(RT_AEC_s *ptr, AP_AEC_Display_Control_s *ptr_AP); extern void ReduceLevel_ForChangePath(float *out, float *in, RT_AEC_s *ptr_RT, AEC_Inner_s *ptr_Inner); void Asm_Filter_Bank( Filter_Bank_s *ptr, float *Out, const float *Coeff); void Reset_Filter_Bank(Filter_Bank_s *ptr); extern void RT_AEC(void); extern void NRT_AEC(void); extern void NRT_AEC_Fix(AP_AEC_s *ptr_AP, RT_AEC_s *ptr_RT, NRT_AEC_s *ptr_NRT); extern void Reset_NRT_AEC(AP_AEC_Display_Control_s *ptr_AP, RT_AEC_s *ptr_RT, NRT_AEC_s *ptr_NRT); void CFFT_AEC(float *out, FFT_s *ptr_s, Complex_s *in, Complex_s *trans); void Asm_Filter_Bank_Shift(float *out, float *in); void Asm_Ref_Multi(float *in_re, float *in_im, float *ref_real, float *ref_im); void Denominator_NLMS_Cal(float *near_in, float *error, float *nlms_real, float *nlms_im); void W_NLMS_Cal(float *w, float *error, float *ref_re, float *ref_im); extern void NLMS_Function(float *Near_In, Complex_s ref[], float *Error, RT_AEC_s *ptr); extern void Initial_AEC(void); //(AEC_Inner_s *ptr); void Asm_RMS_AEC ( float *In, dB_AEC_Cal_s *ptr); void Cal_dB_AEC(float *In, dB_AEC_Cal_s *Cal); extern void Reset_RT_AEC(RT_AEC_s *ptr_RT, AEC_Inner_s *ptr_Inner); void Expander_AEC(float In_DB,float Expander_Threshold,float Expander_Ratio,float Inv_Expander_Ratio, float Expander_Range , NLP_AEC_s *ptr); void NLP_AEC_Function(float *out, float *in, RT_AEC_s *ptr); void Asm_NLP_AEC(float *Out, float *In, NLP_AEC_s *ptr); extern void NLMS_Reset(RT_AEC_s *ptr); extern long Detect_AEC_Status(RT_AEC_s *ptr_AEC); extern int flag_Bypass_NLMS; typedef enum { Fixed_SPC, //0 Vox_SPC, //1 Contact_SPC, //2 Vox_Contact_SPC, //3 }Activation_SPC_Mode; //===========AP==================== typedef struct { unsigned short Act; unsigned short Priority; }AP_SPC_Mode_s; //使因參數長度調整與固定部份交錯, 所以無法與可拉式編輯直接共用, 每段固定式需將struct 與程式微調才可 typedef struct { unsigned short LED_Gate_On[2]; unsigned short LED_Busy[2]; unsigned short NumIn_Num_Out; //[0~7]Num In, [8~15]Num_Out unsigned short Index_In[5]; unsigned short Index_Out[1]; unsigned short Solo[2]; unsigned short TTL[2]; unsigned short Th[2]; unsigned short Response_Time; unsigned short Hold_Time; AP_SPC_Mode_s Mode[5]; unsigned short Mask_InOut[1][2]; unsigned short Reserve[3]; }AP_SPC_s; //===========RT==================== typedef struct { unsigned long Command_Num; unsigned long Address_NRT_Temp; unsigned long Address_Input[5]; unsigned long Address_Out[1]; }RT_SPC_s; //===========NRT Temp==================== typedef struct { float Peak; float Peak_Buf[8]; float Peak_Ave; unsigned long Flag_Attact_Release; //[0] attct, [1] release float Cnt_Response; float Cnt_Hold; }NRT_SPC_In_Channel_s; typedef struct { unsigned long Address_Input; float Gain_Output; float Old_Gain_Output; }NRT_SPC_Out_Channel_s; typedef struct { unsigned long Num_In; unsigned long Num_Out; unsigned long Cnt_Buf_Index; //[0~15] Cnt Sample. [16~19] Buf Index NRT_SPC_In_Channel_s In[5]; NRT_SPC_Out_Channel_s Out[1]; }NRT_SPC_s; extern void NRT_SPC(); extern void RT_SPC(); extern void Asm_SPC(); extern unsigned long *ptr_asm_SPC; typedef enum { Index_Write_Circula, //0 Index_Read_Circula, //1 Nono_Error_Circular, //2 Write_Touch_Read , //3 //write 追到read 指標 : 表示進來資料已超出緩衝 Read_Touch_Write , //4 //read 追到write 指標 : 表示進來資料已超出緩衝 }Circular_Status_e; typedef struct { float *Write; float *Read; float *Base; float *End; unsigned long Offset_Write; //ex: 3點取1點與輸入長度無法整除, 需紀錄下一次取時, 要從那個起始位置取 unsigned long Len_Write; //ex: 3點取1點, 實際輸出長度 }Circular_Poniter_Float_s; typedef struct { Circular_Poniter_Float_s Address; Circular_Status_e Status[2]; }Circular_Float_s; extern void Initial_Circular_Buf(Circular_Float_s *ptr, float *buf, long len); extern void Write_To_Circular_Buf(float *in, int len, Circular_Float_s *ptr); extern void Write_To_Circular_Buf_Standard(float *in, int len, Circular_Float_s *ptr, long len_max); extern void Closed_Circular_Buf(Circular_Float_s *ptr, long len_buf); extern long Read_Circular_Buf(float *out, int len, Circular_Float_s *ptr); extern unsigned long Detect_Space_Circular_Buf(Circular_Float_s *ptr); extern Circular_Float_s Circular_Rx_VOIP; extern Circular_Float_s Circular_Tx_VOIP; extern float Buf_Rx_VOIP[6400]; extern float Buf_Tx_VOIP[6400]; typedef struct { unsigned short Mute; unsigned short Message_Index; unsigned short Output_Index; unsigned short Level[2]; unsigned short Line_Index; unsigned short Display_Volume[2]; }UDP_RX_AP_s; typedef struct { unsigned short Mute; unsigned short Input_Index; unsigned short Level[2]; unsigned short Message_Index; unsigned short Output_Index; unsigned short Display_Volume[2]; }UDP_TX_AP_s; typedef struct { unsigned long Command_Num; unsigned long Index_Struct; //與message共用物件channel, 此將指出使用那一個物件 unsigned long Add_Input; unsigned long Cnt; float Square_Sum; float Level; float Smooth_Gain; unsigned long Add_Out; }UDP_RT_s; extern void NRT_UDP_Receiver(); extern void NRT_UDP_Transmitter(); extern void RT_UDP(); extern void Asm_UDP_Rx_Fix(float *out, float *in, unsigned long *ptr); extern Circular_Float_s Circular_UDP_RxL; extern Circular_Float_s Circular_UDP_RxR; extern float Buf_UDP_L[6400]; extern float Buf_UDP_R[6400]; //#include "RT_Processor.h" typedef enum //勿超過16 { LED_GateOn_VG, //0 Mute_VG, //1 Bypass_VG, //1 }VoiceGate_Bit_s; typedef enum //勿超過16 { EasyVG, //0 MidVG, //1 HardVG, //2 NumType_VG, //3 }VoiceGate_Type_s; typedef struct { unsigned short Flag; unsigned short Index_In; unsigned short Index_Out; unsigned short Th[2]; unsigned short Recognition; unsigned short HoldTime; unsigned short ReleaseTime; }VoiceGate_AP_s; typedef struct { unsigned long Command_Num; Regulate_DC_s DC; unsigned long Flag; //VoiceGate_Bit_s unsigned long Address_In; long Cnt_Square; float SquareSum; unsigned long ptr_old_corrleation; //存 inner table位址 float RxOld; float ArphNew; long Recognition; long Flag_AudioOverTh; long HoldTime; unsigned long Address_Out; }VoiceGate_RT_s; typedef struct { float x0[2]; //in delay0 float x1[2]; float x2[2]; float y0[2]; //out delay0 float y1[2]; float OldCorrelation; float BufferTimeDomain[8]; float Acc; float Old_Envelop; float Sum_Envelop; float Cnt; float Last_AveEnvelop; float CntCondition; float ThPrepare; float ThVad; float CntHold; long CntDelayBuf; long Cnt24Sample; long IndexOldData; }VoiceGate_Inner_s; extern int Voice_Gate_Trigger; void NRT_Voice_Gate(void); void RT_Voice_Gate(void); void Asm_AutoCorrelation(float *in, float *Smooth_Rx_Temp); extern void Initial_VoiceGate(VoiceGate_AP_s *ptr); extern void Set_VoiceGate(unsigned short index, VoiceGate_AP_s *ptr); ///// AP structure ///// //Sample Rate Ratio (8 bit : 8~15) Bypass (1 bit : 2) Mute (1 bit : 1) @Gate on Flag (1 bit : 0) (Fix, 16 bit) //Input Index (Fix, 16 bit) //@Output Index (Fix, 16 bit) //Threshold (32 bit) (L,M) //Response time (16 bit) //Hold time (16 bit) //Attack time (16 bit) //Release time (16bit) //Depth(Gain) (32 bit) (L,M) typedef struct { unsigned short Sample_Bypass_Mute_Gate;//Sample Rate Ratio (8 bit : 8~15) Bypass (1 bit : 2) Mute (1 bit : 1) @Gate on Flag (1 bit : 0) (Fix, 16 bit) unsigned short Input_Index; unsigned short Output_Index; unsigned short Threshold_1; unsigned short Threshold_2; unsigned short Response_time; unsigned short Hold_time; unsigned short Attack_time; unsigned short Release_time; unsigned short Depth_Gain_1; unsigned short Depth_Gain_2; unsigned short Reserve; }Gate_Mono_AP_s; ///// RT structure ///// //Command Number(32 bit) //Input Address (Address, 32 bit) //Output Address (Address, 32 bit) //@Input Volumn Square Sum (Floating, 32 bit) //@Input Counter (Fix, 32 bit) //Output Gain (Floating 32bit) //Old Gain (Floating 32bit) //Arpha (Floating 32bit) typedef struct { unsigned long Command_Num; unsigned long Input_Address; unsigned long Output_Address; float Volumn_Square_Sum; int Counter; float Output_Gain; float Old_Gain; float Arpha; }Gate_Mono_RT_s; ///// RT_temp structure ///// //State[1:0] (00: OFF & Release, 01: Response, 10: Attack 11: ON & Hold) //Counter typedef struct { unsigned long State; unsigned long Counter; }Gate_Mono_temp_CH_NRT_s; typedef struct { Gate_Mono_AP_s AP; Gate_Mono_RT_s RT; Gate_Mono_temp_CH_NRT_s NRT_Temp; }Gate_Mono_s; void NRT_Gate_Mono_Fix_Cal(Gate_Mono_AP_s *ptr_AP, Gate_Mono_RT_s *ptr_RT, Gate_Mono_temp_CH_NRT_s *ptr_NRT_Temp); void Asm_Gate_Mono_Fix_Cal(long in, long out, long len, long Q_Debug); void RT_Gate_Mono(void); void NRT_Gate_Mono(void); //#include "../DSPThread.h" ///// AP structure ///// //Level Detector Type (2 bit : 3~4) Soft_knee (1 bit : 2 ) Byass (1 bit : 1) Compressing(Limiter,Expander) (1 bit : 0) //Input Address (Index, 16 bit) //Output Address (Index, 16 bit) //Threshold (Floating ,32 bit) //Threshold Range (Floating ,32 bit) //Ratio (Floating ,32 bit) //Attack Time (Fix 16bit) //Release Time (Fix 16bit) //Gain Reduction Volume (Floating, 32 bit) typedef struct { unsigned short Type_Softknee_Byass_Compressing; unsigned short Input_Index; unsigned short Output_Index; unsigned short Threshold_1; unsigned short Threshold_2; unsigned short Threshold_Range_1; unsigned short Threshold_Range_2; unsigned short Ratio_1; unsigned short Ratio_2; unsigned short Attack_time; unsigned short Release_time; unsigned short Gain_Reduction_Volume_1; unsigned short Gain_Reduction_Volume_2; }Compressor_AP_s; ///// RT structure ///// //Command Number(32 bit) //Function Type(32 bit) //Input Address (Address, 32 bit) //Output Address (Address, 32 bit) //@Input Volumn Square Sum (Floating, 32 bit) //@Input Counter (Fix, 32 bit) //Output Gain (Floating 32bit) //Old Gain (Floating 32bit) //Arpha (Floating 32bit) typedef struct { unsigned long Command_Num; unsigned long Function_Type; unsigned long Input_Address; unsigned long Output_Address; float Volumn_Square_Sum; int Counter; float Output_Gain; float Old_Gain; float Arpha; }Compressor_RT_s; ///// RT_temp structure ///// //State[1:0] (00: OFF & Release, 01: Response, 10: Attack 11: ON & Hold) //Counter typedef struct { unsigned long State; unsigned long Counter; float OLD_Threshold; float OLD_Threshold_Range; float OLD_Ratio; float SoftKness_parameter; }Compressor_temp_CH_NRT_s; void NRT_Compressor_Fix_Cal(Compressor_AP_s *ptr_AP, Compressor_RT_s *ptr_RT, Compressor_temp_CH_NRT_s *ptr_NRT_Temp); void Asm_Compressor_Fix_Cal(long in, long out, long len/*, long Q_Debug*/); void RT_Compressor(void); void NRT_Compressor(void); /* * Limiter.h * * Created on: 2016年3月18日 * Author: Owner */ //#define TYPE_LIMITER_OR 0x0008 //bit3 //#define TYPE_EXPANDER_OR 0x0010 //bit4 typedef enum { LED_Display_ORL, //0 Bypass_ORL, //1 Hard_Clip_ORL, //2 TYPE_LIMITER_OR, //3 TYPE_EXPANDER_OR, //4 Stereo_Limiter, //5 }OR_Limiter_AP_Bit_Define; typedef struct { float Arph_Limiter; float Th_Limiter; float Old_Limiter; float Current_Gain; //1.0, 方便組語一次取值與免載入值使用 }RT_Brick_Wall_Limiter_s; //============Ap=========================== typedef struct { unsigned short Flag; //[0]: active LED, [1]:bypass, [2]:hard_clip, [3-4]:type unsigned short Index_In; unsigned short Index_Out; unsigned short Th[2]; unsigned short Release_Time; //ms unsigned short Reduction_dB_Level[2]; }AP_Limiter_s; typedef struct { unsigned short Index_In; unsigned short Index_Out; }AP_Limiter_Stereo_s; //============RT=========================== typedef struct { unsigned long Command_Num; unsigned long Flag; //[0]:bypass, [1]:hardclip unsigned long Add_Input; unsigned long Add_Output; RT_Brick_Wall_Limiter_s Cal; }RT_Limiter_s; typedef struct { unsigned long Add_Input; unsigned long Add_Output; float Old_Limiter; float Current_Gain; //1.0, 方便組語一次取值與免載入值使用 }RT_Limiter_Stereo_s; extern RT_Brick_Wall_Limiter_s Limiter_Spk; extern RT_Brick_Wall_Limiter_s Limiter_USB_Tx; extern void RT_Brick_Wall(float *out, float *in, RT_Brick_Wall_Limiter_s *ptr_B); extern void NRT_Limiter_Fix_Cal(AP_Limiter_s *ptr_AP, RT_Limiter_s *ptr_RT); extern void NRT_Limiter(AP_Limiter_s *ptr_AP, RT_Limiter_s *ptr_RT); extern void RT_Limiter(RT_Limiter_s *ptr_RT); extern void RT_Limiter_Stereo(RT_Limiter_s *ptr_RT); extern void RT_Hard_Clip(float *out, float *in, float *th); extern RT_Brick_Wall_Limiter_s Limiter_Amp_L; extern RT_Brick_Wall_Limiter_s Limiter_Amp_R; extern RT_Brick_Wall_Limiter_s Limiter_VOIP_TX; //===============Compressor Limiter=============================== typedef enum { LED_Expander, //0 LED_Compressor, //1 LED_Limiter, //2 Bypass_AND_CLE, //3 SoftKnee_AND_CLE, //4 HardClip_AND_CLE, //5 }Bit_Set_AND_AP_Comporessor_Limiter_Expander_s; typedef struct { unsigned short Flag; unsigned short Index_In; unsigned short Index_Out; unsigned short Th_Limiter[2]; unsigned short Th_Expander[2]; unsigned short Th_Compressor[2]; unsigned short Ratio_Compressor[2]; unsigned short Ratio_Expander[2]; unsigned short Attack_Expander; unsigned short Release_Expander; unsigned short Attack_Compressor; unsigned short Release_Compressor; unsigned short Release_Limiter; unsigned short Reduction_dB_Level[2]; }AP_AND_Compliter_Limiter_Expander_s; typedef struct { Compressor_RT_s Compressor; RT_Brick_Wall_Limiter_s Limiter; }RT_Compliter_Limiter_s; extern void RT_Compressor_Limiter(RT_Compliter_Limiter_s *ptr_RT); extern void NRT_Compressor_Limiter(void); extern void Set_AudioLine_Compressor_Limiter(void); //======AP===================== typedef struct { unsigned short Num_Message; unsigned short Index_Chan_M; unsigned short Index_Out; unsigned short Mute; unsigned short Level[2]; }Message_AP_s; typedef struct { unsigned long Command_Num; unsigned long Index_Message; unsigned long Address_In; unsigned long Address_Out; float Level; }Message_RT_s; extern Circular_Float_s Circular_Message_L; extern Circular_Float_s Circular_Message_R; extern float Buf_MessageL[19200]; extern float Buf_MessageR[19200]; extern void NRT_Message_Event(void); extern void RT_Message_Event(void); extern float Level_SD_File; extern float Level_Message_File; //MCU將file所設定的音量存至此位置 /* typedef struct { u16 Selector; u16 Num_In; u16 Mask_L; u16 Mask_H; u16 Index[6]; //此為動態, 無法直接對應 u16 Index_Out; }AP_Selector_s; */ typedef struct { //int Command_Num; int Add_Input; int Add_Out; float Gain; }RT_Selector_s; typedef struct { unsigned short Selector; unsigned short Reserve; }AP_LR_Selector_s; typedef struct { int Add_Input[2]; int Add_Out[2]; }RT_LR_Selector_s; extern void NRT_Multi_In_Selector(); extern void RT_Multi_In_Selector(); extern void NRT_SelectorLR_Fix(); extern void RT_SelectorLR_Fix(RT_LR_Selector_s *ptr_RT); //===========Rx================= typedef struct { unsigned short Index_In; unsigned short Index_Out; unsigned short Mute; unsigned short Level[2]; unsigned short Reserve; }AP_Rx_VOIP_s; typedef struct { unsigned long Command_Num; unsigned long Channel_Num; unsigned long Address_Out; float Level; }RT_Rx_VOIP_s; //===========Tx================= typedef struct { unsigned short Index_In; unsigned short Index_Out; unsigned short Mute; unsigned short Level[2]; unsigned short Reserve; }AP_Tx_VOIP_s; typedef struct { unsigned long Command_Num; unsigned long Address_Input; unsigned long Address_Out; float Level; }RT_Tx_VOIP_s; extern Circular_Float_s Circular_Rx_VOIP; extern Circular_Float_s Circular_Tx_VOIP; extern float Buf_Rx_VOIP[6400]; extern float Buf_Tx_VOIP[6400]; extern int Buf_UpSample_RxVOIP[2]; extern void NRT_VOIP_Rx(void); extern void NRT_VOIP_Tx(void); extern void VOIP_Receive(void); /* * Hi_LoPass_PEQ.h * * Created on: 2016年5月19日 * Author: Owner */ //因為全域宣告, 所以需宣告出實體位置 typedef enum { Id_FilterPEQ_VOIP, //0 Id_FilterPEQ_Mic1, //1 NUM_DSP_FilterPEQ, //2 }ID_DSP_FilterPEQ; typedef enum { Modify_PEQ, //0 Modify_HiPass, //1 Modify_LoPass, //2 }Modify_Index_HiLoPass_PEQ; //內部使用, 節省nrt 全部重算時間 typedef struct { PEQ_AP_s Main; PEQ_AP_Parameter_s Band[4]; }AP_PEQ_HiLo_Struct; typedef struct { PEQ_RT_s Main; RT_Old_Band_s Band[4]; }RT_PEQ_HiLo_Struct; //======AP===================== typedef struct { unsigned short OffsetGloabTable; //可拉式編輯使用, 便於跳至下一張table unsigned short Offset_PEQ; unsigned short Offset_HiPass; unsigned short Offset_LoPass; unsigned short Mute; AP_PEQ_HiLo_Struct PEQ; Filter_AP_s HiPass; Filter_AP_s LoPass; }HiLoPass_PEQ_AP_s; //=============RT===================== typedef struct { unsigned long Command_Num; unsigned long Mute_Set; //因為全域宣告, 所以需宣告出實體位置 RT_PEQ_HiLo_Struct PEQ; FILTER_HiLo_RT_s HiPass; FILTER_HiLo_RT_s LoPass; }HiLoPass_PEQ_RT_s; //=============NRT Temp===================== typedef struct { AP_PEQ_HiLo_Struct Record_PEQ; Filter_AP_s Record_HiPass; Filter_AP_s Record_LoPass; NRT_PEQ_Struct PEQ; NRT_FILTER_HiLo_Struct HiPass; NRT_FILTER_HiLo_Struct LoPass; }NRT_PEQ_HiLo_Struct; //對應到NRT Temp Table extern void NRT_HiLoPass_PEQ(void); enum ARRANGE_AUDIO_DATA { GATHER_DMA, //0 ARRANGE_DATA_BY_C, //1 ARRANGE_DATA_BY_ASM, //2 TONE_OUT, //3 DMA_CBYPASS, //4 }; typedef struct { RT_New_Input_Struct Input_DSP[NUM_DSP_INPUT]; UDP_RT_s UDP_Rx; RT_Rx_VOIP_s VOIP_Rx; AGC_RT_s AGC[NUM_DSP_AGC]; NS_RT_s NS; HWAGC_RT_s HWAGC; RT_PEQ_Struct PEQ[NUM_DSP_PEQ]; FILTER_HiLo_RT_s Filter[NUM_DSP_Filter]; RT_SPC_s SPC; Ducker_Mono_RT_s Ducker; RT_Tx_VOIP_s VOIP_Tx; RT_New_Output_Struct Output_DSP[NUM_DSP_OUTPUT]; VoiceGate_RT_s VoiceGate; HiLoPass_PEQ_RT_s HiLoPass_PEQ[NUM_DSP_FilterPEQ]; RT_AEC_s AEC; Gate_Mono_RT_s Gate; RT_Compliter_Limiter_s Compressor_Limiter; }DSP_RT_Table_s; typedef struct { PEQ_DSP_Inner_s PEQ[NUM_DSP_PEQ]; AEC_Inner_s AEC; Inner_NS_s NS; VoiceGate_Inner_s VoiceGate; }Inner_Table_DSP_RT_s; extern DSP_RT_Table_s RT_Table_DSP; extern Inner_Table_DSP_RT_s Inner_Table_DSP; extern int RT_Parameter_Table[10000]; extern float Buf_RT_Inner[5000]; extern int *ptr_rt_parameter_table; extern int *ptr_asm_table; extern float *ptr_RT_Inner; extern void RT_Process(DSP_RT_Table_s *ptr); void Arrange_DSP_In(void); void Arrange_DSP_Out(void); void C_DMA_Bypass(void); void Rx_Arrange_Asm(int *in, float *out); void Tx_Arrange_Asm(int *out, float *in); void DSP_Audio_Process(void); extern void Path_Mic1(DSP_RT_Table_s *ptr, Inner_Table_DSP_RT_s *ptr_Inner); //#include "RT_Processor.h" //#include "../DSPThread.h" /* * Limiter.h * * Created on: 2016年3月18日 * Author: Owner */ /* * Hi_LoPass_PEQ.h * * Created on: 2016年5月19日 * Author: Owner */ typedef struct { unsigned short NRTPara_PresetStatus; unsigned short NRTPara_PresetLength; unsigned short NRTPara_MasterPresetLength; unsigned short NRTPara_PresetVersion; unsigned short NRTPara_MachineLicense; unsigned short NRTPara_MachineID; unsigned short NRTPara_AudioBoardTable[2]; unsigned short NRTPara_PresetHeaderReserve1[2]; unsigned short NRTPara_MasterPresetNo; unsigned short NRTPara_SubPresetNo; unsigned short NRTPara_AudioBoardInfo; unsigned short NRTPara_LVDSMode; unsigned short NRTPara_SamplingRate; unsigned short NRTPara_SubPresetNumber; unsigned short NRTPara_TotalNetBufferIn; unsigned short NRTPara_TotalNetBufferOut; unsigned short NRTPara_TotalPPMIn; unsigned short NRTPara_TotalPPMOut; unsigned short NRTPara_GlobalChannelNum;//NRTPara_APInfoOffset unsigned short NRTPara_MasterPresetParaOffset; unsigned short NRTPara_PresetHeaderReserve[12]; unsigned short parameter_table[27000]; }Preset_table; typedef enum { Ch0_DSP, //0 Ch1_DSP, //1 }Channel_DSP_s; typedef enum { EQ_Modify, //0 HiLoPass_PEQ_Modify, //1 Num_Modify, //2 }ID_Modify; typedef struct { Message_AP_s Message; UDP_RX_AP_s UDP_Rx; AP_New_Input_Struct Input_DSP[NUM_DSP_INPUT]; AP_Rx_VOIP_s VOIP_Rx; AP_LR_Selector_s LR_Selector; AGC_AP_s AGC[NUM_DSP_AGC]; AP_HwAGC HWAGC; AP_PEQ_Struct PEQ[NUM_DSP_PEQ]; Filter_AP_s Filter[NUM_DSP_Filter]; AP_AEC_s AEC; NS_AP_s NS; AP_SPC_s SPC; Ducker_Stereo_AP_s Ducker; AP_Tx_VOIP_s VOIP_Tx; AP_New_Output_Struct Output_DSP[NUM_DSP_OUTPUT]; VoiceGate_AP_s VoiceGate; HiLoPass_PEQ_AP_s HiLoPass_PEQ[NUM_DSP_FilterPEQ]; Gate_Mono_AP_s Gate; AP_AND_Compliter_Limiter_Expander_s Compressor_Limiter; }DSP_AP_Table_s; typedef struct { NRT_Temp_New_Input_Struct Input_DSP[NUM_DSP_INPUT]; AGC_NRT_Temp_s AGC[NUM_DSP_AGC]; HWAGC_NRT_Temp_s HWAGC; NRT_PEQ_Struct PEQ[NUM_DSP_PEQ]; NRT_FILTER_HiLo_Struct Filter[NUM_DSP_Filter]; NRT_SPC_s SPC; Ducker_NRT_Temp_s Ducker; NRT_Temp_New_Output_Struct Output_DSP[NUM_DSP_OUTPUT]; NRT_PEQ_HiLo_Struct HiLoPass_PEQ[NUM_DSP_FilterPEQ]; NRT_AEC_s AEC; Gate_Mono_temp_CH_NRT_s Gate; }DSP_NRT_Temp_s; extern void (*NRT_Funtion_Table[131])(void); extern void NRT_Process(void); extern DSP_AP_Table_s AP_Table_DSP; extern DSP_NRT_Temp_s NRT_Temp_DSP; extern Preset_table sPreset_table; extern unsigned short *ptr_parameter_table, *ptr_NRT_parameter; extern float NRT_Temp_Buffer[10000]; extern float *ptr_NRT_Temp_Buffer; extern int *ptr_Transfer_temp; extern float Transfer_temp; extern unsigned short *DSP_Chip_Table_Ptr; extern void Set_Modify_Function(ID_Modify Index, long ch); extern void Set_All_Modify(void); extern void Set_AudioLine_HiLoPass_PEQ(void); extern long Modify_Function[Num_Modify]; typedef struct { long Old; unsigned long Amp_Bit; //放大幾個bit, 不可超過 8 //neon 右移只支援定值, 所此沒在用, 直接取AMP_BIT_FOR_ASM_MESSAGE_UDP }UpSample_L16kToF48k_s; typedef struct { long Old; }UpSample_L24kToF48k_s; extern const short FIR_up3[3][2]; extern const long Asm_Coeff_16kTo48k[2][4]; //extern void Up_Sample_24kTo48k_Message(short *in, int *out, int len, unsigned short ch); //extern void Up_Sample_16kTo48k_Message(short *in, int *out, int len, unsigned short ch); extern int Filter_16kto48k(int *Input, const short *Fill); extern void UpSample_L16kToF48k(float *out, long *in, UpSample_L16kToF48k_s *ptr, unsigned short len); extern void UpSample_L24kToF48k(float *out, long *in, UpSample_L24kToF48k_s *ptr, unsigned short len); extern void Asm_UpSample_L16kToF48k(float *out, long *in, UpSample_L16kToF48k_s *ptr, unsigned short len); extern void UpSample_L48kToF48k(float *out, long *in, unsigned short len); extern void Asm_Sample_L48kToF48k(float *out, long *in, long len); extern void UpSample_S16kToF48k(float *out, short *in, int *old, int len); typedef struct { char *Data; unsigned long Size; }MachineSet_Backup_s; extern MachineSet_Backup_s MachineSet_Backup; extern Circular_Float_s Circular_IP_Tone; extern float Buf_IP_Tone[3200]; void Boot_Backup_MachineSet(void); void Boot_Detect_Thread_Init(void); /* ********************************************************************************************************* * uC/CSP * Chip Support Package * * (c) Copyright 2010; Micrium, Inc.; Weston, FL * (c) Copyright 2003-2010; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/CSP is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * uC/CSP COMMON DRIVER API * * Filename : csp.h * Version : V1.00 * Programmer(s) : FT ********************************************************************************************************* * Note(s) : ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * CHIP SUPPORT PACKAGE MODULE VERSION NUMBER * * Note(s) : (1) (a) The chip support package module software version is denoted as follows : * * Vx.yy * * where * V denotes 'Version' label * x denotes major software version revision number * yy denotes minor software version revision number * * (b) The software version label #define is formatted as follows : * * ver = x.yy * 100 * * where * ver denotes software version number scaled as an integer value * x.yy denotes software version number ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * CHIP SUPPORT PACKAGE INCLUDE FILES * * Note(s) : (1) The chip support package files are located in the following directories : * * (a) \\csp_cfg.h * * (b) \\MCU\csp.c * \csp.h * * (c) \\MCU\\\csp_grp_def.h * \csp_*.c * * (d) \\MCU\\\\csp_dev_def.h * * (e) \\OS\\csp_os.c * \csp_os.h * * where * directory path for Your Product's Application. * directory path for chip support package. * directory name for microcontroller manufacturer. * directory name for microcontroller family. * directory name for specific microcontroller on the same family. * directory name for specific operating system (OS) * * (2) CPU-configuration software files are located in the following directories : * * (a) \\cpu_def.h * * (b) \\\\cpu*.* * * where * directory path for common CPU-compiler software * directory name for specific processor (CPU) * directory name for specific compiler * * (3) NO compiler-supplied standard library functions are used by the chip support package * * (a) Standard library functions are implemented in the custom library module(s) : * * \\lib*.* * * where * directory path for custom library software * * (4) Compiler MUST be configured to include as additional include path directories : * * (a) '\\' directory See Note #1a * * (b) '\\MCU\' directory See Note #1b * * (c) '\\' directory See Note #3a * * (d) Specific port directories : * * (1) (A) '\\' directory See Note #2 * (B) '\\\' directory * * (2) '\\MCU\\\' directory See Note #1c * * (3) '\\MCU\\\' directory See Note #1d * * (3) '\\OS\\' directory See Note #1e * * where * directory path for Your Product's Application * directory path for chip support package * directory path for custom library software * directory path for common CPU-compiler software * directory name for microcontroller manufacturer. * directory name for microcontroller family. * directory name for specific microcontroller on the same family. * directory name for specific operating system (OS) * * (5) An application MUST pre-processor include ONLY this chip support package header file, * 'csp.h'. All other chip support package files are included via this main header file. * * See also 'MODULE Note #1'. ********************************************************************************************************* */ /* ********************************************************************************************************* * uC/CSP * Chip Support Package * * (c) Copyright 2010; Micrium, Inc.; Weston, FL * (c) Copyright 2003-2010; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/CSP is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * CSP CONFIGURATION FILE * * TEMPLATE * * Filename : csp_cfg.h * Version : V1.00 * Programmer(s) : FT ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * ARGUMENTS CHECKING * * Note(s) : (1) Configure 'CSP_CFG_ARG_CHK_EN' to enable/disable arguments checking. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * INTERRUPT MODULE CONFIGURATION * * Note(s) : (1) Configure CSP_CFG_INT_ISR_EXEC_MEAS_EN to include variables to measure CPU's interrupt * Interrupt Service Routine (ISR) execution time. * * (a) ISR execution time is only accurate only when interrupt nesting * 'CSP_CFG_INT_NESTING_EN' is disabled. * * (2) Configure CSP_INT_ISR_ARG_EN to enable/disable argument passing to ISR handlers. * * (3) Configure CSP_CFG_INT_NESTING_EN to enable/disable interrupt nesting. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * CHIP SUPPORT PACKAGE OSCILLATOR CONFIGURATION * * Note(s) : (1) Configure CSP_CFG_PM_MAIN_XTAL_FREQ_HZ with the frequency in Hertz of the main oscillator. * * (2) Configure CSP_CFG_PM_SLOW_XTAL_FREQ_HZ with the frequency in Hertz of the slow oscillator. * * (3) Configure CSP_CFG_PM_EXT_CLK_FREQ_HZ with the frequency on Hertz of the external clock. ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * MODULE END ********************************************************************************************************* */ /* ********************************************************************************************************* * uC/CSP * Chip Support Package * * (c) Copyright 2010; Micrium, Inc.; Weston, FL * (c) Copyright 2003-2010; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/CSP is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * uC/CSP DATA TYPES * * Filename : csp_types.h * Version : V1.00 * Programmer(s) : FT ********************************************************************************************************* * Note(s) : ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE ********************************************************************************************************* */ /* ********************************************************************************************************* * INCLUDE FILES ********************************************************************************************************* */ /* ********************************************************************************************************* * EXTERNS ********************************************************************************************************* */ /* ********************************************************************************************************* * DEVICE NUMBER IDENTIFIERS * * Note(s) : (1) The 'CSP_DEV_NBR' data type is used to reference port numbers, clk identifiers and peripherals * IDs. ********************************************************************************************************* */ typedef CPU_INT16U CSP_DEV_NBR; /* Device number. */ /* ********************************************************************************************************* * OPTIONS AND OPTIONS FLAGS ********************************************************************************************************* */ typedef CPU_INT16U CSP_OPT_FLAGS; /* Option flags. */ typedef CPU_INT16U CSP_OPT; /* Options. */ /* ********************************************************************************************************* * INTERRUPT VECTOR ********************************************************************************************************* */ typedef struct csp_int_vect { CPU_FNCT_PTR FnctPtr; /* ISR Function Pointer */ void *ArgPtr; /* ISR function Argument pointer. */ CPU_TS32 TimeMax; /* ISR maximum execution time. */ CPU_TS32 TimeCur; /* ISR current execution time. */ } CSP_INT_VECT; /* ********************************************************************************************************* * GLOBAL VARIABLES ********************************************************************************************************* */ /* ********************************************************************************************************* * MACRO'S ********************************************************************************************************* */ /* ********************************************************************************************************* * FUNCTION PROTOTYPES ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE END ********************************************************************************************************* */ /* ********************************************************************************************************* * uC/CSP * Chip Support Package * * (c) Copyright 2011; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/CSP is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * FAMILY DEFINITION & API * Texas Instruments RM48 * * Filename : csp_grp.h * Version : V1.00 * Programmer(s) : NB ********************************************************************************************************* * Note(s) : ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE ********************************************************************************************************* */ /* ********************************************************************************************************* * INCLUDE FILES ********************************************************************************************************* */ /* ********************************************************************************************************* * EXTERNS ********************************************************************************************************* */ /* ********************************************************************************************************* * DEFAULT CONFIGURATION ********************************************************************************************************* */ /* ********************************************************************************************************* * FAMILY IDENTIFIERS ********************************************************************************************************* */ /* ********************************************************************************************************* * INTERRUPT CONTROLLER DEVICE NUMBERS ********************************************************************************************************* */ /* ********************************************************************************************************* * INTERRUPT SOURCES * * Note(s) : (1) Interrupt controller sources #define's use the following standard: * * #define CSP_INT_SRC_NBR___ * * where * * Peripheral name (UART, ETHER, DMA, USB, etc) * Interrupt event (RX, TX, MATCH, ALERT, TO, etc) * Empty for multiple events interrupts. * Peripheral number. (00, 01, 02, etc) * * #define CSP_INT_SRC_NBR_UART_RX_00 UART 00 receive interrupt. * #define CSP_INT_SRC_NBR_UART_TX_00 UART 01 receive interrupt. * * (2) 'CSP_INT_SRC_NBR_MAX' defines maximum number of interrupts in the interrupt controller. ********************************************************************************************************* */ /* ********************************************************************************************************* * INTERRUPT PRIORITIES ********************************************************************************************************* */ /* ********************************************************************************************************* * PERIPHERALS CLOCKS DEFINES * * Note(s) : (1) The peripheral's clock #define's use the following standard. * * #define CSP_PM_PER_CLK_NBR__ * * where, * * Peripheral clock name. * Peripheral clock number identifier. * * (2) The TI RM48 MCU support Power down mode for peripherals memories and peripherals * register. For this reason two subsets of clk identifiers are defines to indidually enable/disable * the peripheral memory or the peripheral register. ********************************************************************************************************* */ /* ------------- PERIPHERAL MEMORY SELECTS ------------ */ /* ------------- PERIPHERAL REGISTER SELECTS --------- */ /* ********************************************************************************************************* * SYSTEM CLOCKS DEFINES * * Note(s) : (1) The system clock #define's use the following standard. * * #define CSP_PM_SYS_CLK_NBR__ * * where, * * System clock number name. * System clock number identifier. * * (2) The TMS570 implements the following clock_domains * * GCLK : CPU clock domain. * HCLK : System bus clock domain. * VCLK : System peripheral clock domain. * VCLK_PER : Primary clcok for peripherals. * VCLK_02 : VCLK_02 is a second VBUS clock domain used by the NHET * and HET TU peripherals. * VCLK_03 : VCLK_03 is a third VBUS clock domain used by the EMIF * and Ethernet. * AVCLK_01 : Asynchronous clock domain 1. * AVCLK_02 : Asynchronous clock domain 1. * VCLK_SYS : Primary clock for the VBUS clock domain. ********************************************************************************************************* */ /* ********************************************************************************************************* * GPIO PORT MASK ********************************************************************************************************* */ typedef CPU_INT32U CSP_GPIO_MSK; /* GPIOs port are 32-bits. */ /* ********************************************************************************************************* * TIMER VALUE DATA TYPE ********************************************************************************************************* */ typedef CPU_INT32U CSP_TMR_VAL; /* Timers are 32-bits wide. */ /* ********************************************************************************************************* * GLOBAL VARIABLES ********************************************************************************************************* */ /* ********************************************************************************************************* * MACRO'S ********************************************************************************************************* */ /* ********************************************************************************************************* * TI RM48 FAMILY API * * Note(s) : (1) Application code written using this API is 100% compatible trought all devices in the same * TI RM48 family. ********************************************************************************************************* */ CPU_BOOLEAN CSP_GPIO_CfgExt (CSP_DEV_NBR port_nbr, CSP_GPIO_MSK pins, CSP_OPT dir, CSP_OPT_FLAGS drv_mode, CPU_BOOLEAN int_en, CSP_OPT int_pol, CPU_BOOLEAN int_prio, CSP_OPT fnct); /* ********************************************************************************************************* * CONFIGURATION ERRORS ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE END ********************************************************************************************************* */ /* ********************************************************************************************************* * uC/CSP * Chip Support Package * * (c) Copyright 2010; Micrium, Inc.; Weston, FL * (c) Copyright 2003-2010; Micrium, Inc.; Weston, FL * * All rights reserved. Protected by international copyright laws. * * uC/CSP is provided in source form to registered licensees ONLY. It is * illegal to distribute this source code to any third party unless you receive * written permission by an authorized Micrium representative. Knowledge of * the source code may NOT be used to develop a similar product. * * Please help us continue to provide the Embedded community with the finest * software available. Your honesty is greatly appreciated. * * You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * * DEVICE DEFINITION * * Texas Instruments RM48 * * Filename : csp_dev.h * Version : V1.00 * Programmer(s) : NB ********************************************************************************************************* * Note(s) : ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* * INCLUDE FILES ********************************************************************************************************* */ /* ********************************************************************************************************* * EXTERNS ********************************************************************************************************* */ /* ********************************************************************************************************* * DEFAULT CONFIGURATION ********************************************************************************************************* */ /* ********************************************************************************************************* * FAMILY MEMBER DEFINITION ********************************************************************************************************* */ /* ********************************************************************************************************* * DEVICE PERIPHERAL ENABLED * * Note(s) : (1) 'CSP_DEV_PER__EN' configure if a specific peripheral is present or not. ********************************************************************************************************* */ /* ********************************************************************************************************* * DEVICE MEMORIES SIZE DEFINES ********************************************************************************************************* */ /* ********************************************************************************************************* * MODULE END ********************************************************************************************************* */ /* ********************************************************************************************************* * EXTERNS ********************************************************************************************************* */ /* ********************************************************************************************************* * DEFAULT CONFIGURATION ********************************************************************************************************* */ /* ********************************************************************************************************* * CLOCK DEFINES ********************************************************************************************************* */ /* ********************************************************************************************************* * GPIO GENERIC DEFINES * * Note(s) : (1) 'CSP_GPIO_DIR_xxx' defines the direction of the pin when the pin is controlled by the GPIO controller.. * * (2) Driver mode flags defines the pin configuration: * * CSP_GPIO_FLAG_MODE_NONE Pin has a has neither pull-up nor pull-down resister. * CSP_GPIO_FLAG_MODE_PULLUP Pin has a pull-up resistor enabled. * CSP_GPIO_FLAG_MODE_PULLDOWN Pin has a pull-down resistor enabled. * CSP_GPIO_FLAG_MODE_REPEATER Pin has repeater mode enabled * CSP_GPIO_FLAG_MODE_OPEN_DRAIN Pin is in normal open drain mode. * CSP_GPIO_FLAG_MODE_SCH_TRIGGER pin has schmitt trigger enabled. * * (3) The Option flags allows to perform optional operation in the GPIO configuration. * CSP_GPIO_OPT_RD_WR_EN Controlled pin is affected by writes to the port's. * CSP_GPIO_OPT_RD_WR_DIS Controlled pin is not affected by writes to the port. * * (3) I/O pins are shared with other peripherals or functions. 'CSP_GPIO_FNCT_xx' controls the IO function * for a specific pin. ********************************************************************************************************* */ /* -------------- GPIO PINS DIRECTION --------------- */ /* ------------ GPIO DRIVE MODE DEFINES ------------- */ /* ----------------- GPIO FUNCTIONS ----------------- */ /* ------------- GPIO PORT NUMBER DEFINES ------------- */ /* ********************************************************************************************************* * I2C DEFINES * * Note(s) : (1) The I2C specification defines the following speeds mode. * * (a) Standard mode. Transfer rate up to 100Kbit/s * (b) Fast mode. Trasnfer rate up to 400Kbits/s * (c) High Speed mode. Transfer rate up to 3.4 Mbits/s * * (2) The I2C specification defines the following addressing modes: * * (a) 7-bit addressing mode. * (b) 10-bit addressing mode. ********************************************************************************************************* */ /* ********************************************************************************************************* * TIMER DEFINES ********************************************************************************************************* */ /* ********************************************************************************************************* * INTERRUPT DEFINES ********************************************************************************************************* */ /* ********************************************************************************************************* * SPI DEFINES ********************************************************************************************************* */ /* ********************************************************************************************************* * DATA TYPES ********************************************************************************************************* */ /* ********************************************************************************************************* * GLOBAL VARIABLES ********************************************************************************************************* */ /* ********************************************************************************************************* * MACRO'S ********************************************************************************************************* */ /* ********************************************************************************************************* * FUNCTION PROTOTYPES * DEFINED IN FAMILIES csp_gpio.c ********************************************************************************************************* */ void CSP_GPIO_Init (void); /* GPIO port configuration. */ CPU_BOOLEAN CSP_GPIO_Cfg (CSP_DEV_NBR port_nbr, CSP_GPIO_MSK pins, CSP_OPT dir, CSP_OPT_FLAGS drv_mode, CPU_BOOLEAN int_en, CSP_OPT int_pol, CSP_OPT fnct); /* Clear a bit. */ void CSP_GPIO_BitClr (CSP_DEV_NBR port_nbr, CSP_GPIO_MSK pins); /* Set a bit. */ void CSP_GPIO_BitSet (CSP_DEV_NBR port_nbr, CSP_GPIO_MSK pins); /* Toggle a bit. */ void CSP_GPIO_BitToggle (CSP_DEV_NBR port_nbr, CSP_GPIO_MSK pins); /* Read value from the port. */ CSP_GPIO_MSK CSP_GPIO_Rd (CSP_DEV_NBR port_nbr); /* Write value to the port. */ void CSP_GPIO_Wr (CSP_DEV_NBR port_nbr, CSP_GPIO_MSK val); /* Clear pending interrupts. */ CSP_GPIO_MSK CSP_GPIO_IntClr (CSP_DEV_NBR port_nbr); /* ********************************************************************************************************* * FUNCTION PROTOTYPES * DEFINED IN FAMILIES csp_int.c ********************************************************************************************************* */ void CSP_IntInit (void); /* Initialize interrupt controller. */ /* Enable a interrupt source. */ void CSP_IntEn (CPU_INT08U int_id); /* Disable a interrupt source. */ void CSP_IntDis (CPU_INT08U int_id); /* Disable all interrupt sources. */ void CSP_IntDisAll (CSP_DEV_NBR int_ctrl); /* Clear a pending interrupt source. */ void CSP_IntClr (CPU_INT08U int_id); /* Configure a interrupt source. */ CPU_BOOLEAN CSP_IntSrcCfg (CSP_DEV_NBR int_ctrl, CSP_DEV_NBR src_nbr, CSP_OPT src_prio, CSP_OPT src_pol); /* Register an interrupt vector. */ CPU_BOOLEAN CSP_IntVectReg (CPU_INT08U int_id, CPU_FNCT_PTR isr); /* Un-register an interrupt vector. */ CPU_BOOLEAN CSP_IntVectUnreg (CPU_INT08U int_id); /* Global interrupt handler. */ void CSP_IntHandler (void); void CSP_IntHandlerSrc (CSP_DEV_NBR src_nbr); /* ********************************************************************************************************* * FUNCTION PROTOTYPES * DEFINED IN FAMILIES csp_pm.c ********************************************************************************************************* */ void CSP_PM_Init (void); /* Initialize power management module. */ CPU_INT32U CSP_PM_CPU_ClkFreqGet (void); /* Get CPU frequency. */ void CSP_PM_PerClkEn (CSP_DEV_NBR clk_nbr); /* Enable a peripheral clock. */ void CSP_PM_PerClkDis (CSP_DEV_NBR clk_nbr); /* Disable a peripheral clock. */ CPU_INT32U CSP_PM_PerClkFreqGet (CSP_DEV_NBR clk_nbr); /* Get a peripheral clock frequency. */ CPU_BOOLEAN CSP_PM_PerClkDivCfg (CSP_DEV_NBR clk_nbr, /* Configure a peripheral clock divider. */ CPU_INT32U clk_div); void CSP_PM_SysClkEn (CSP_DEV_NBR clk_nbr); /* Enable a system clock. */ void CSP_PM_SysClkDis (CSP_DEV_NBR clk_nbr); /* Disable a system clock. */ CPU_INT32U CSP_PM_SysClkFreqGet (CSP_DEV_NBR clk_nbr); /* Get system clock frequency */ CPU_BOOLEAN CSP_PM_SysClkDivCfg (CSP_DEV_NBR clk_nbr, /* Configure a system clock divider. */ CPU_INT32U clk_div); /* ********************************************************************************************************* * FUNCTION PROTOTYPES * DEFINED IN FAMILIES csp_tmr.c ********************************************************************************************************* */ void CSP_TmrInit (void); /* Initialize timer module. */ CPU_BOOLEAN CSP_TmrCfg (CSP_DEV_NBR tmr_nbr, CPU_INT32U freq); /* Configure a timer for compare mode. */ CPU_BOOLEAN CSP_TmrOutCmpCfg (CSP_DEV_NBR tmr_nbr, CSP_DEV_NBR pin, CSP_OPT pin_action, CPU_INT32U freq); void CSP_TmrIntClr (CSP_DEV_NBR tmr_nbr); /* Clear timer interrupt. */ void CSP_TmrRst (CSP_DEV_NBR tmr_nbr); /* Reset timer interrupt. */ CSP_TMR_VAL CSP_TmrRd (CSP_DEV_NBR tmr_nbr); /* Read the value of a timer. */ void CSP_TmrStart (CSP_DEV_NBR tmr_nbr); /* Start a timer. */ void CSP_TmrStop (CSP_DEV_NBR tmr_nbr); /* Stop a timer. */ void CSP_TmrWr (CSP_DEV_NBR tmr_nbr, /* Write a value to a timer. */ CSP_TMR_VAL tmr_val); /* ********************************************************************************************************* * FUNCTION PROTOTYPES * DEFINED IN FAMILIES csp_i2c.c * * Note(s) : (1) I2C common API limitations. * (a) Master mode only. * (b) 7-bit address. * (c) Only synchronous transfers (blocking) are supported. ********************************************************************************************************* */ void CSP_I2C_Init (void); CPU_BOOLEAN CSP_I2C_Open (CSP_DEV_NBR i2c_nbr, CSP_OPT addr_mode, CPU_INT32U freq, CSP_OPT gpio_cfg); CPU_BOOLEAN CSP_I2C_Close (CSP_DEV_NBR i2c_nbr); CPU_BOOLEAN CSP_I2C_WrRd (CSP_DEV_NBR i2c_nbr, /* I2C write follow by a read. */ CPU_INT16U addr, void *p_src, void *p_dest, CPU_SIZE_T src_len, CPU_SIZE_T dest_len); CPU_BOOLEAN CSP_I2C_RdWr (CSP_DEV_NBR i2c_nbr, /* I2C read follow by a write. */ CPU_INT16U addr, void *p_src, void *p_dest, CPU_SIZE_T src_len, CPU_SIZE_T dest_len); CPU_BOOLEAN CSP_I2C_Wr (CSP_DEV_NBR i2c_nbr, /* I2C write. */ CPU_INT16U addr, void *p_src, CPU_SIZE_T len); CPU_BOOLEAN CSP_I2C_Rd (CSP_DEV_NBR i2c_nbr, /* I2C read. */ CPU_INT16U addr, void *p_dest, CPU_SIZE_T len); /* ********************************************************************************************************* * FUNCTION PROTOTYPES * INTERNAL FUNCTIONS ********************************************************************************************************* */ void CSP_IntVectSet (CSP_INT_VECT *p_vect, CPU_FNCT_PTR isr_fnct, void *p_arg); void CSP_IntVectClr (CSP_INT_VECT *p_vect); void CSP_IntVectDeref (CSP_INT_VECT *p_vect); /* ********************************************************************************************************* * CONFIGURATION ERRORS ********************************************************************************************************* */ CPU_BOOLEAN CSP_IntVectReg (CPU_INT08U int_id, CPU_FNCT_PTR isr); /* ********************************************************************************************************* * MODULE END ********************************************************************************************************* */ /** * \file dmtimer.h * * \brief DMTimer API prototypes and macros. * * This file contains the driver API prototypes and macro definitions. */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /** * @Component: DMTIMER * * @Filename: hw_dmtimer.h * ============================================================================ */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /*********************************************************************** * Register arrays Definition \***********************************************************************/ /*********************************************************************** * Bundle arrays Definition \***********************************************************************/ /*********************************************************************** * Bundles Definition \***********************************************************************/ /************************************************************************* * Registers Definition \*************************************************************************/ /************************************************************************** * Field Definition Macros \**************************************************************************/ /* TIDR */ /* TIOCP_CFG */ /* TIOCP_CFG_1MS */ /* TIER */ /* TWER */ /* TISR */ /* IRQ_EOI */ /* IRQSTATUS_RAW */ /* IRQSTATUS */ /* IRQENABLE_SET */ /* IRQENABLE_CLR */ /* IRQWAKEEN */ /* TCLR */ /* TCRR */ /* TLDR */ /* TTGR */ /* TWPS */ /* TMAR */ /* TCAR1 */ /* TSICR */ /* TCAR2 */ /*****************************************************************************/ /* ** Values that can be passed to DMTimerPreScalerClkEnable as ptv so as to derive ** Pre-Scalar clock from timer clock. */ /* Value used to divide timer clock by 2 */ /* Value used to divide timer clock by 4 */ /* Value used to divide timer clock by 8 */ /* Value used to divide timer clock by 16 */ /* Value used to divide timer clock by 32 */ /* Value used to divide timer clock by 64 */ /* Value used to divide timer clock by 128 */ /* Value used to divide timer clock by 256 */ /******************************************************************************/ /* ** Values that can be passed to DMTimerModeConfigure as timerMode. */ /* Value used to enable the timer in one-shot and compare mode */ /* Value used to enable the timer only in one-shot mode */ /* Value used to enable the timer in auto-reload and compare mode */ /* Value used to enable the timer only in auto-reload mode */ /******************************************************************************/ /* ** Values that can be passed to DMTimerGPOConfigure as gpoCfg. */ /* Value used to drive 0 on PORGPOCFG pin */ /* Value used to drive 1 on PORGPOCFG pin */ /******************************************************************************/ /* ** Values that can be passed to DMTimerIntStatusClear/DMTimerIntRawStatusSet/ ** as intFlags. Also these values can be used while checking the status got from ** DMTimerIntRawStatusGet/DMTimerIntStatusGet. ** Any combination is also followed. ** Example- (DMTIMER_INT_TCAR_IT_FLAG | DMTIMER_INT_OVF_IT_FLAG) */ /* Value used for capture event of DMTimer */ /* Value used for overflow event of DMTimer */ /* Value used for Match event of DMTimer */ /******************************************************************************/ /* ** Values that can be passed to DMTimerIntEnable/DMTimerIntDisable as intFlags. ** Also these values can be used while checking the status got from ** DMTimerIntEnableGet. ** Any combination is also followed. ** Example- (DMTIMER_INT_TCAR_EN_FLAG | DMTIMER_INT_OVF_EN_FLAG) */ /* Value used for capture event of DMTimer */ /* Value used for overflow event of DMTimer */ /* Value used for Match event of DMTimer */ /******************************************************************************/ /* ** Values that can be passed to DMTimerResetConfigure as rstOption. */ /* Value used to enable software reset for DMTimer */ /* Value used to disable software reset for DMTimer */ /******************************************************************************/ /* ** Values that can be used while checking the status received from ** DMTimerIsResetDone. */ /* Value used to check whether reset is done */ /* Value used to check whether reset is ongoing */ /******************************************************************************/ /* ** Values that can be passed to DMTimerPostedModeConfig as postMode. */ /* Value used to enable the posted mode of operation */ /* Value used to disable the posted mode of operation */ /******************************************************************************/ /* ** Values that can be used while checking status received from ** DMTimerWritePostedStatusGet API. */ /* Value used to check the write posted condition for TMAR register */ /* Value used to check the write posted condition for TTGR register */ /* Value used to check the write posted condition for TLDR register */ /* Value used to check the write posted condition for TCRR register */ /* Value used to check the write posted condition for TCLR register */ /******************************************************************************/ /* ** Structure to store the DM timer context */ typedef struct dmtimerContext{ unsigned int tldr; unsigned int tmar; unsigned int irqenableset; unsigned int tcrr; unsigned int tclr; }DMTIMERCONTEXT; /* ** Prototype of the APIs */ extern void DMTimerEnable(unsigned int baseAdd); extern void DMTimerDisable(unsigned int baseAdd); extern void DMTimerModeConfigure(unsigned int baseAdd, unsigned int timerMode); extern void DMTimerPreScalerClkEnable(unsigned int baseAdd, unsigned int ptv); extern void DMTimerPreScalerClkDisable(unsigned int baseAdd); extern void DMTimerCounterSet(unsigned int baseAdd, unsigned int counter); extern unsigned int DMTimerCounterGet(unsigned int baseAdd); extern void DMTimerReloadSet(unsigned int baseAdd, unsigned int reload); extern unsigned int DMTimerReloadGet(unsigned int baseAdd); extern void DMTimerGPOConfigure(unsigned int baseAdd, unsigned int gpoCfg); extern void DMTimerCompareSet(unsigned int baseAdd, unsigned int compareVal); extern unsigned int DMTimerCompareGet(unsigned int baseAdd); extern void DMTimerEmulationModeConfigure(unsigned int baseAdd, unsigned int emuMode); extern void DMTimerIntRawStatusSet(unsigned int baseAdd, unsigned int intFlags); extern unsigned int DMTimerIntRawStatusGet(unsigned int baseAdd); extern unsigned int DMTimerIntStatusGet(unsigned int baseAdd); extern void DMTimerIntStatusClear(unsigned int baseAdd, unsigned int intFlags); extern void DMTimerIntEnable(unsigned int baseAdd, unsigned int intFlags); extern void DMTimerIntDisable(unsigned int baseAdd, unsigned int intFlags); extern void DMTimerTriggerSet(unsigned int baseAdd); extern unsigned int DMTimerIntEnableGet(unsigned int baseAdd); extern void DMTimerResetConfigure(unsigned int baseAdd, unsigned int rstOption); extern void DMTimerReset(unsigned int baseAdd); extern void DMTimerContextSave(unsigned int baseAdd, DMTIMERCONTEXT *contextPtr); extern void DMTimerContextRestore(unsigned int baseAdd, DMTIMERCONTEXT *contextPtr); extern void DMTimerPostedModeConfig(unsigned int baseAdd, unsigned int postMode); extern unsigned int DMTimerWritePostedStatusGet(unsigned int baseAdd); extern unsigned long Basic_100ms_Timer, Basic_20ms_Timer, Basic_1ms_Timer; void Delay_Init(void); void DMTimer5ModuleClkConfig(void); void nsleep(unsigned long nsec); void usleep(unsigned long usec); void msleep(unsigned long msec); void Cancel_timer_flag(unsigned long *Parameter,unsigned int Kind); void Reset_Timer_Flag(unsigned long *f_flag, unsigned int f_kind); unsigned long Rand_Value(void); unsigned int Register_timer_flag(unsigned long *Parameter,unsigned int Wait_Time,unsigned int Kind); unsigned char Timer_Interval_Check(long *f_check_timer, unsigned long *f_reg_timer, unsigned long f_interval_cnt); /*""FILE COMMENT""================================================================================== * System Name : TERRA * File Name : DSP_Table_Dnload_Upload.h * Version : * Contents : 等處理 相關 變數 / 定數 /Function樣版 定義 * CPU : TI 3352 * Compiler : CCSV6 * OS : uCOS-III * Programmer : * Note : =================================================================================================== * Copyright,2015 ATIES Technologies Co.,ltd =================================================================================================== * History : *""FILE COMMENT END""==============================================================================*/ //NandFlash Structure 0x0000000~0x07FFFFFF 128MB //==========================Boot Code Area==================0x0000000~0x00DFFFF 0.875MB //==========================Protect Area====================0x00E0000~0x1F5FFFF 30.5MB //==========================Unprotected Area================0x1F60000~0x24FFFFF 5.63MB // //NEXT_ADDR 0x01060000 //==========================Internal FAT Area===============0x2500000~0x29FFFFF 5MB //==========================User Data Area==================0x2A00000~0x79FFFFF 80MB //==========================Bad Block Area==================0x7A00000~0x7FFFFFF 6MB //==========System Log Table============ // // // //Ethernet setting // // // // //==========System Log Table============ typedef enum { PRODUCT_LCS8 = 0, PRODUCT_LIS8, PRODUCT_LIS8X, PRODUCT_APH30, PRODUCT_CCS4, PRODUCT_CCS6, PRODUCT_FORMAT4, PRODUCT_FORMAT6, PRODUCT_PBC6, PRODUCT_PBC10X, PRODUCT_NUM_END, }Product_List_e; typedef struct { char Title[17]; char Version[4]; char Product[sizeof("IP SPEAKER Product\0")]; char dumy[4]; unsigned short MCU_PCB_Ver; unsigned short AMP_PCB_Ver; unsigned short Product_ID; }Version_s; typedef struct { char Title[40]; unsigned short Product_ID; }Product_List_s; extern unsigned short Update_Buff[0x500000]; extern unsigned short Mass_Buff[0x080000]; extern unsigned char Serial_Number[10]; extern unsigned short System_Flag_Table[0x100+1]; extern Version_s MCU_Version; extern Product_List_s Product_List[]; unsigned short Save_System_Table(void); void Load_System_Table(void); /** * \file nandlib.h * * \brief Definitions used for NAND Abstractin Library. * * This file contains the macros, structures, function prototypes used by * nand application, abstraction layer, and platform spcific layer. */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /******************************************************************************* * MACRO & ENUM DEFINITIONS *******************************************************************************/ /*****************************************************************************/ /* ** Macros which defines the number of NAND devices can be connected to system */ /*****************************************************************************/ /* ** Macros which can be used as 'chip select' to the NANDInfoInit, ** NANDCtrlInfoInit and NANDDevInfoInit functions. */ /*****************************************************************************/ /* ** Macros which defines the ECC offset in OOB areaa, ecc byte count(size) ** of diffrent ECC schemes. ** */ /*****************************************************************************/ /* ** Macros which defines the last data and ecc bit in diffrent ECC schemes. ** */ /* 512 bytes of data plus 13 bytes ECC */ /* 13 bytes of ECC data plus 1 byte of ECC for ECC data */ /*****************************************************************************/ /* ** Macro which defines the number of bytes sent/received per transfer. ** */ /*****************************************************************************/ /* ** Macro which defines the values stored in OOB as bad block info. ** */ /*****************************************************************************/ /* ** Macros which can be used as 'busWidth' in NANDDevInfo structure. ** */ typedef enum _NAND_BUSWIDTH_ { NAND_BUSWIDTH_INVALID = (0xFF), NAND_BUSWIDTH_8BIT = (0x00), NAND_BUSWIDTH_16BIT = (0x01) } NandBusWidth_t; /*****************************************************************************/ /* ** Nand ECC alogorithm typedef ** */ typedef enum _NAND_ECC_ALGO_ { NAND_ECC_ALGO_NONE = (0x00), NAND_ECC_ALGO_HAMMING_1BIT = (0x01), NAND_ECC_ALGO_RS_4BIT = (0x02), NAND_ECC_ALGO_BCH_4BIT = (0x04), NAND_ECC_ALGO_BCH_8BIT = (0x08), NAND_ECC_ALGO_BCH_16BIT = (0x10) } NandEccAlgo_t; /*****************************************************************************/ /* ** NandPageSize typedef ** */ typedef enum _NAND_PAGE_SIZE_ { NAND_PAGESIZE_INVALID = ((0)*(512)), NAND_PAGESIZE_512BYTES = ((1)*(512)), NAND_PAGESIZE_2048BYTES = ((4)*(512)), NAND_PAGESIZE_4096BYTES = ((8)*(512)), NAND_PAGESIZE_8192BYTES = ((16)*(512)) } NandPageSize_t; /*****************************************************************************/ /* ** NandBlockSize typedef ** */ typedef enum _NAND_BLOCK_SIZE_ { NAND_BLOCKSIZE_INVALID = ((0)*(1024)), NAND_BLOCKSIZE_64KB = ((64)*(1024)), NAND_BLOCKSIZE_128KB = ((128)*(1024)), NAND_BLOCKSIZE_256KB = ((256)*(1024)), NAND_BLOCKSIZE_512KB = ((512)*(1024)) } NandBlockSize_t; /*****************************************************************************/ /* ** NandStatus typedef - returned from most NandLib APIs ** */ typedef enum _NAND_STATUS_ { NAND_STATUS_PASSED = (0x001), NAND_STATUS_FAILED = (0x002), NAND_STATUS_NOT_FOUND = (0x004), NAND_STATUS_DEVBUSY = (0x008), NAND_STATUS_DEVWRPROTECT = (0x010), NAND_STATUS_WAITTIMEOUT = (0x020), NAND_STATUS_READWRITE_DMA_FAIL = (0x040), NAND_STATUS_ECC_UNSUPPORTED = (0x080), NAND_STATUS_READ_ECC_ERROR_CORRECTED = (0x100), NAND_STATUS_READ_ECC_UNCORRECTABLE_ERROR = (0x200) } NandStatus_t; /*****************************************************************************/ /* ** NandBlockStatus typedef - returned from back block checking routine ** */ typedef enum _NAND_BLOCK_STATUS_ { NAND_BLOCK_GOOD = (0), NAND_BLOCK_BAD = (1), NAND_BLOCK_SPARE_AREA_READ_FAILED = (2) } NandBlockStatus_t; /*****************************************************************************/ /* ** Typedef which is used as 'dir' to DMAXfer, DMAXferSetup funcitons to indicate ** the transfer direction. ** */ typedef enum _NAND_DMA_DIR_ { NAND_DMA_DIR_READ = (0), NAND_DMA_DIR_WRITE = (1) } NandDmaDir_t; /*****************************************************************************/ /* ** Typedef which can be used as 'opMode' in NandInfo_t structure. ** */ typedef enum _NAND_XFER_MODE_ { NAND_XFER_MODE_CPU = (0), NAND_XFER_MODE_DMA = (1) } NandXFerMode_t; /******************************************************************************* * STRUCTURES DECLARION *******************************************************************************/ /* A consolidated structure which is the main object instantiated by the user. ** This contains all the other information for a NAND device/controller ** transaction. It contains the info like -- ** 1)NAND Device information that is connected. ** 2)NAND Controller information that is being used. ** 3)Function pointers for control/config/transfer. ** */ typedef struct _NAND_INFO_ { /* Array of memory controller chip selects in use */ int chipSelects[(4)]; /* Opmode. i.e CPU or DMA */ NandXFerMode_t opMode; /* ECC algorithm required by the NAND device */ NandEccAlgo_t eccType; /* Manufacturer ID */ unsigned char manId; /* Device ID */ unsigned char devId; /* Count of chip selects the nand device uses */ int chipSelectCnt; /* NAND die cnt - how many die in package */ int dieCnt; /* Bus width of the device. i,e 8 bit or 16 bit */ NandBusWidth_t busWidth; /* Page size of the device */ NandPageSize_t pageSize; /* Blk size (with out spare area) of the device */ NandBlockSize_t blkSize; /* Pages per block */ unsigned int pagesPerBlk; /* DATA Register address */ unsigned int dataRegAddr; /* ADDR Register address */ unsigned int addrRegAddr; /* CMD Register address */ unsigned int cmdRegAddr; /* Pointer to Memory Controller Structure */ struct _NAND_CTRL_INFO_ *hNandCtrlInfo; /* Pointer to ECC Structure */ struct _NAND_ECC_INFO_ *hNandEccInfo; /* Pointer to DMA Structure */ struct _NAND_DMA_INFO_ *hNandDmaInfo; } NandInfo_t; /* Contains the controller information like --- ** 1) chip select ** 2) Location for data, command and address registers ** 3) ECC supported by the controller and the default ecc to use. ** 4) Wait pin onformation ** 5) DMA related information and so on */ typedef struct _NAND_CTRL_INFO_ { /* Function to initialize the NAND controller before accessing the NAND */ NandStatus_t (*CtrlInit)(void); /* Function to get the wait pin status */ unsigned int (*WaitPinStatusGet)(void); /* Function to get the GPMC FIFO status */ unsigned int (*WriteBufReady) (void); /* Timing info for the device and the controller */ void *hNandTimingInfo; /* Base address of the controller */ unsigned int baseAddr; /* ECC supported by the controller */ unsigned int eccSupported; /* Wait pin where NAND dev R/B pin is connected */ unsigned int waitPin; /* Wait pin polarity */ unsigned int waitPinPol; /* Write protect pin polarity */ unsigned int wpPinPol; /* Chip select base address */ unsigned int chipSelectBaseAddr[(4)]; /* Chip select region size */ unsigned int chipSelectRegionSize[(4)]; /* Curr chip select in use by the memory controller */ int currChipSelect; } NandCtrlInfo_t; typedef struct _NAND_ECC_INFO_ { /* Base address of the ECC engine (ELM in GPMC for BCH ECC) */ unsigned int baseAddr; /* Offset of the page from where ECC has to store.*/ unsigned int eccOffSet; /* Total number of ecc bytes. */ unsigned int eccByteCnt; /* Function to initialize the controller w.r.t ECC */ NandStatus_t (*ECCInit)(void); /* Function to enable the ECC */ void (*ECCEnable)(void); /* Function to disable the ECC */ void (*ECCDisable)(void); /* Function which does the ECC setting for write */ void (*ECCWriteSet)(void); /* Function which does the ECC setting for read */ void (*ECCReadSet)(void); /* Function to caluclate/read the ECC */ void (*ECCCalculate)(unsigned char *eccData); /* Function to check for the ECC errors, and correct if any errors */ NandStatus_t (*ECCCheckAndCorrect)(unsigned char *readEcc,unsigned char *data); } NandEccInfo_t; typedef struct _NAND_DMA_INFO_ { /* Function to Initialize DMA */ void (*DMAInit)(void *unused); /* Function to transfer the Data through DMA */ NandStatus_t (*DMAXfer)(unsigned char *data,unsigned int len, NandDmaDir_t dir); /* Function to setup the DMA transfer */ void (*DMAXferSetup)(unsigned char *data, unsigned int len,NandDmaDir_t dir); /* Function to get the status of the DMA transfer */ unsigned int (*DMAXferStatusGet)(); } NandDmaInfo_t; /******************************************************************************* * FUNCTION PROTOTYPE DECLARATION *******************************************************************************/ extern NandInfo_t NandInfo; extern unsigned short NandFlash_Use; /* NAND APIs */ extern NandStatus_t NANDOpen(void); extern NandStatus_t NANDOpen_Without_BadBlock(void); extern NandStatus_t NANDReadId(void); extern NandStatus_t NANDReset(void); extern NandStatus_t NANDWaitUntilReady(void); extern NandBlockStatus_t NANDBadBlockCheck(unsigned int blkNum); extern NandStatus_t NANDMarkBlockAsBad(unsigned int blkNum); extern NandStatus_t NANDBlockErase(unsigned int blkNum); extern NandStatus_t NANDPageWrite(unsigned int blkNum,unsigned int pageNum,volatile unsigned char *txData,unsigned char *eccData); extern NandStatus_t NANDPageRead(unsigned int blkNum,unsigned int pageNum,volatile unsigned char *rxData,unsigned char *eccData); void NANDPinMux(void); unsigned short Erase_Flash(unsigned short Black_Sector_Flag,unsigned short Erase_Count); unsigned short Write_Flash(unsigned long Start_Addr,unsigned short *Data_Addr,unsigned long Length); unsigned short Write_Flash_Byte(unsigned long Start_Addr,unsigned char *Data_Addr,unsigned long Length); unsigned short Read_Flash(unsigned long Start_Addr,unsigned short *Data_Addr,unsigned long Length); unsigned short Read_Flash_Byte(unsigned long Start_Addr,unsigned char *Data_Addr,unsigned long Length); void Check_NandFlash_Ex_Data(void); void Code_Protect(void); void Code_Unprotect(void); void Set_Code_Area(unsigned long Start,unsigned long End); void Set_BadBlock_Area(unsigned long A,unsigned long B); unsigned short Check_BadBlock_Limite(void); void Boot_Code_Unlock(void); void Boot_Code_Lock(void); typedef enum { FUN_SYSTEM_STRUCT=0, FUN_MACHINE_SETTING, FUN_DSP_COMPONENT, FUN_MSG_COMP, FUN_ETH_AUDIO, FUN_LOGICIN, //5 FUN_MSG_EVENT, FUN_FILE_LEVEL, FUN_INTERCOM_EVENT, FUN_VOL_ADJ_EVENT, FUN_SRC_SEL_EVENT, //10 FUN_SCHEDULER, FUN_CTRL_OUT, FUN_CTRL_OUT_TARGET, FUN_3RDPARTY_SETTING, FUN_3RDPARTY_EVENT, //15 FUN_MESSAGE_ROUTE, FUN_RAC_LIST, FUN_END }Fun_Num_e; // //將資料湊滿為32bit倍數 typedef struct { unsigned short Prduct; unsigned short Zone; unsigned short Online; char DeviceName[200]; char SIP_Server[16];//default:0.0.0.0 需要IP格式 char SIP_ID[20];//不能為空 不能有逗號、空白 char SIP_PW[20]; unsigned short Payload; unsigned short Priority; unsigned short SIP_Port;//default:5060 不能為0 unsigned short RTP_Port;//default:6912 不能為0 unsigned short SIP_Buff;//0:RT 1:0.5 2:1.0 3:1.5 4:2.0 unit:second unsigned short SIP_Auto_Ans; unsigned short Server_Disable; unsigned short Tone_Level; unsigned short Monitor_Tone_Interval; unsigned short Reserve[62]; }System_Struct_Device_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; System_Struct_Device_s Device; unsigned long CRC32; }System_Struct_s; typedef struct { unsigned short Language; unsigned short Location; unsigned short Clock_Type;//24hr:1 12hr:0 unsigned short Region; unsigned short NTP_Enable; unsigned short NTP_ReHour; unsigned short NTP_ReMin; unsigned char NTP_Server[40]; unsigned short Scheduler_Enable;//0:disable 1:enable (all scheduler) unsigned long Reserver[20]; }Machine_Setting_Item_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; Machine_Setting_Item_s Item; unsigned long CRC32; }Machine_Setting_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; DSP_AP_Table_s DSP; unsigned long CRC32; }DSP_Component_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200];//event id char Sub_Name[200];//event name unsigned short StartYear; unsigned short StartMonth; unsigned short StartDay; unsigned short EndYear; unsigned short EndMonth; unsigned short EndDay; unsigned long Stop_Flag;//express event is deleted unsigned long long Event_Length; unsigned long ID;//event id unsigned long Parents; unsigned short RepeatMode; //======================== unsigned short Day_Every;//1~ //======================== unsigned short Week_Every;//1~ unsigned short Week_day;//bit0:日 1:一 2:二 3:三 4:四 5:五 6:六 //======================== unsigned short Month_Mode;//0~1 unsigned short Month_Day1;//1~31 unsigned short Month_Every1;//1~ unsigned short Month_WeekNum;//1~5 unsigned short Month_Day2;//bit0:日 1:一 2:二 3:三 4:四 5:五 6:六 unsigned short Month_Every2;//1~ //======================== unsigned short Year_Mode;//0~1 unsigned short Year_Month1;//1~12 unsigned short Year_Day1;//1~31 unsigned short Year_WeekNum;//1~5 unsigned short Year_Day2;//bit0:日 1:一 2:二 3:三 4:四 5:五 6:六 unsigned short Year_Month2;//1~12 //======================== unsigned short Occurrences;//0:forever unsigned char Enable; unsigned char Repeat_Enable; unsigned long TimeCount;//1~48 unsigned long Time[48];//0~7:hour 8~15:minute 16~23:second unsigned long Reserve[10]; char Event[200]; char Description[100]; unsigned long CRC32; }Scheduler_s; typedef struct { unsigned short Act_Type; unsigned short Act_Mode; char Play_File_List[200]; unsigned short LogicIN_Val; unsigned short LogicIN_Val_Former; unsigned short Play_Times; unsigned short Play_State; char Event_Name[200]; long Event_Changed; long LogicIN_Stable_Cnt; unsigned short Toggle_State; unsigned short LogicIN_Val_Diff; }MSG_Comp_Item_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; MSG_Comp_Item_s Item[2]; unsigned long CRC32; }MSG_Comp_Fun_s; typedef struct { char Name[200]; char IP[16]; unsigned long Port; unsigned short Buffer_Type; unsigned short Reserve[0]; }Eth_Fun_Item_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; unsigned short Act_Src_Index; unsigned short Mode; // 0: Audio Stream Mode, 1: TM Mode Eth_Fun_Item_s Item[8]; unsigned long Reserve[40]; unsigned long CRC32; }Eth_Audio_Fun_s; typedef struct { unsigned short Calibration_Max; unsigned short Calibration_Min; }LogicIN_Fun_Item_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; unsigned long Response_Time[3]; // 50m sec ~5000m sec LogicIN_Fun_Item_s Item[3]; unsigned long CRC32; }LogicIN_Fun_s; typedef struct { unsigned long Event_Start; unsigned long Event_End; unsigned short PlayTimes; unsigned short Idle; char Song[200]; }MSG_Event_Item_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; unsigned short Item_Count; unsigned short Play_Count; MSG_Event_Item_s Item[100]; unsigned long CRC32; }MSG_Event_s; typedef struct { unsigned long Reserve[4]; char File[200]; float Level; }File_Level_Item_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; unsigned long Count; unsigned long Reserve[30]; File_Level_Item_s Item[500]; unsigned long CRC32; }File_Level_s; typedef struct { unsigned short LogicIN_CH; unsigned short LogicIN_Val; unsigned short LogicIN_Val_Former; unsigned short Act_Mode; long LogicIN_Stable_Cnt; char URI[40]; unsigned short Toggle_State; unsigned short LogicIN_Val_Diff; }Intercom_Item_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; Intercom_Item_s Item; unsigned long Enable_Flag; unsigned long CRC32; }Intercom_s; typedef struct { unsigned short LogicIN_CH; unsigned short LogicIN_Val; unsigned short LogicIN_Val_Former; unsigned short Reserve[0]; long LogicIN_Stable_Cnt; unsigned short Cmponent_Type_ID; unsigned short Cmponent_ID; char Target[200]; unsigned short Enable_Flag; unsigned short LogicIN_Val_Diff; }VOL_Adjust_Item_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; unsigned long Count; VOL_Adjust_Item_s Item[20]; unsigned long CRC32; }Volume_Adjust_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; unsigned short LogicIN_CH; unsigned short LogicIN_Val; unsigned short LogicIN_Val_Former; unsigned short Reserve[0]; long LogicIN_Stable_Cnt; unsigned long OP_Type; // 0: RAC 5, 1: RAC 8 unsigned short Target[8]; unsigned short Enable_Flag; unsigned short LogicIN_Val_Diff; unsigned long CRC32; }SRC_Sel_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; unsigned short Channel; unsigned short Type; unsigned long NC; unsigned long NO; unsigned long Timers; unsigned long CRC32; }LogicOut_Target_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; LogicOut_Target_s Item[8]; unsigned long CRC32; }CTRL_OUT_Setting_s; // // // // typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; unsigned short Fun; // TP_FUN_LEVEL_CTL, TP_FUN_LEVEL_READ...etc unsigned short Source; // TP_LEVEL_SRC_MUSIC, TP_LOGIC_SRC_IN0..etc LogicOut_Target_s Logic_out; unsigned long CRC32; }ThirdParty_Event_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; unsigned short Network_Control; unsigned short Network_port; unsigned long Network_IGMP_En; char Network_IGMP[16]; unsigned long CRC32; }Third_Party_Setting_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; unsigned short Priority; // 0~99 unsigned short Msg_Player_ID; // 0: Music, 1: Message char Play_File_List[200]; unsigned long CRC32; }Message_Route_Event_s; typedef struct { Fun_Num_e FunNumber; unsigned long LTH; unsigned long VER; char Name[200]; unsigned long Mode; // 0: Automate, 1: Manul unsigned char RAC5[3][5][4];//0:min,1:max,2:use cnt unsigned char RAC8[3][8][4]; unsigned long CRC32; }RAC_List_s; void Initial_Function(void); void Function_Polling(void); unsigned short Save_Function_Table(void); void Delete_Function_Table(void); // extern unsigned short Fun_Buff[24*NAND_BLOCKSIZE_128KB/2]; extern unsigned long Function_NAND_Title; extern const unsigned long Function_Length[FUN_END]; extern const unsigned long Function_VER[FUN_END]; extern unsigned short Eth_Audio_Index; //=============User function============== extern Machine_Setting_s Machine_Setting; extern DSP_Component_s DSP_Component; extern LogicIN_Fun_s LogicIN_Fun; extern Intercom_s Intercom_Event; extern Volume_Adjust_s Vol_Adj_Event; extern SRC_Sel_s SRC_Sel_Event; extern Eth_Audio_Fun_s Eth_Audio_Fun; // void Save_Function_Polling(void); void Load_Function_Table(void); //function table maintain unsigned short Add_Function(void *data,unsigned short overwrite,unsigned long ex_lth); unsigned short Delete_Function(char *name); unsigned short Delete_Function_Event(char *name, Fun_Num_e num); void *Get_Function(char *name); unsigned short List_Function(Fun_Num_e num,void **list,unsigned short Max); unsigned long Function_Use_Space(void); unsigned long Function_All_Space(void); //function process unsigned short Add_Fun_Process(void *data,unsigned short overwrite); unsigned short Add_Fun_Process_Name(char *name,unsigned short overwrite); unsigned short Del_Fun_Process(char *name); void *Get_Process_Fun(unsigned short num, char *name); // unsigned short Fun_ADC_Value_To_RAC5(unsigned short f_ch, unsigned short f_value); unsigned short Fun_ADC_Value_To_RAC8(unsigned short f_ch, unsigned short f_value); unsigned short Fun_ADC_Value_Trans_RAC5_Disp(unsigned short f_ch, unsigned short f_value); unsigned short Fun_ADC_Value_Trans_RAC8_Disp(unsigned short f_ch, unsigned short f_value); unsigned short Fun_ThirdParty(ThirdParty_Event_s *ThirdParty,char *element,char *Out,unsigned long IP,unsigned short Port,unsigned short interface); unsigned short Save_Function_Bottom(void); void Fun_System_Struct_Init(void); void Fun_MachineSet_Init(void); void Fun_DSP_Table_Init(void); void Fun_LogicIN_Init(void); void Fun_LogicOUT_Init(void); /*""FILE COMMENT""================================================================================== * System Name : * File Name : Element_Handle.h * Version : * Contents : * CPU : * Compiler : * OS : * Programmer : * Note : =================================================================================================== * Copyright,2016 ATEIS Technologies Co.,ltd =================================================================================================== * History : *""FILE COMMENT END""==============================================================================*/ //===========================================================================// // PUBLIC CONSTANTS //===========================================================================// // New Input Element Index enum { IN_LEVEL = 0, IN_BYPASS, IN_MUTE, IN_SIGNAL, IN_CHIP_THRESHOLD, IN_CHIP_LED, IN_VOL, }; // Select Element Index enum { SEL_CH = 0, }; // New Output Element Index enum { OUT_MUTE= 0, OUT_SIGNAL, OUT_OVERLOAD_LED, OUT_OVERLOAD_THRESHOLD, OUT_LEVEL, OUT_VOL, }; // Ducker_Stereo Index enum { DUCKER_S_ACT = 0, DUCKER_S_BYPASS, DUCKER_S_STEREO, DUCKER_S_THRESHOLD, DUCKER_S_RESPONSE_TIME, DUCKER_S_HOLD_TIME, DUCKER_S_ATTACT_TIME, DUCKER_S_RELEASE_TIME, DUCKER_S_DEEPTH_RESPONSE, DUCKER_S_GAIN_SPEECH, }; // AGC Element Index enum { AGC_ACT = 0, AGC_GAIN_BYPASS, AGC_GAIN_RECOVER, AGC_GAIN_AVG_TIME, AGC_GAIN_THRESHOLD_LEVEL, AGC_GAIN_ATT_TIME, AGC_GAIN_RELEASE_TIME, AGC_TARGET_LEVLE, AGC_MAX_GAIN, AGC_LEVLE, }; // AEC Element Index enum { AEC_ECHO = 0, AEC_SIGNAL, AEC_NPL, AEC_ERLE, AEC_FAR_VOL, AEC_NEAR_VOL, AEC_COEFF, AEC_RESET, AEC_MIC_THRESHOLD, AEC_LEVEL, AEC_NR_LEVEL, }; // Hi/Lo Filter Element Index enum { HI_LO_FILTER_SLOP = 0, HI_LO_FILTER_MODE, HI_LO_FILTER_MUTE, HI_LO_FILTER_BYPASS, HI_LO_FILTER_TYPE, HI_LO_FILTER_CUT_FQ, HI_LO_FILTER_LEVEL, }; // PEQ Element Index enum { PEQ_ALL_PASS = 0, PEQ_PASS, PEQ_FREQUENCE, PEQ_BANDWIDTH, PEQ_GAIN, }; // HW AGC Element Index enum { HW_AGC_ACT = 0, HW_AGC_BYPASS, HW_AGC_RECOVER, HW_AGC_AVG_TIME, HW_AGC_THRESHOLD_LEVEL, HW_AGC_ATT_TIME, HW_AGC_RELEASE_TIME, HW_AGC_TARGET_LEVLE, HW_AGC_MAX_GAIN, HW_AGC_LEVLE, HW_AGC_MODE, HW_AGC_SET, HW_AGC_DISP_SET, HW_AGC_DB_BASE_SET, HW_AGC_MUTE, HW_AGC_VOL, }; // Signal Paging Control Element Index enum { SPC_LED_GATE_ON = 0, SPC_BUSY, SPC_SOLO, SPC_TTL, SPC_THRESHOLD, SPC_RESPONS_TIME, SPC_HOLD_TIME, SPC_ACT, SPC_PRIORITY, }; // Hi-Lo Pass + PEQ enum { HI_FILTER_SLOP = 0, HI_FILTER_MODE, HI_FILTER_MUTE, HI_FILTER_BYPASS, HI_FILTER_TYPE, HI_FILTER_CUT_FQ, HI_FILTER_LEVEL, LO_FILTER_SLOP, LO_FILTER_MODE, LO_FILTER_MUTE, LO_FILTER_BYPASS, LO_FILTER_TYPE, LO_FILTER_CUT_FQ, LO_FILTER_LEVEL, EQ_ALL_PASS, EQ_PASS, EQ_FREQUENCE, EQ_BANDWIDTH, EQ_GAIN, }; // Noise Reduction enum { NS_THRESHOLD = 0, NS_VOL, NS_BYPASS, }; // Compressor-Limiter enum { CL_SOFTKNEE = 0, CL_BYPASS, CL_LIMITING, CL_COMPRESSING, CL_EXPANDER, CL_EXPANDER_THR, CL_EXPANDER_RATIO, CL_COMPRESSOR_THR, CL_COMPRESSOR_RATIO, CL_LIMITER_THR, CL_EXPANDER_ATT_TIME, CL_EXPANDER_RELEASE_TIME, CL_COMPRESSSOR_ATT_TIME, CL_COMPRESSSOR_RELEASE_TIME, CL_LIMITER_RELEASE_TIME, CL_GAIN_REDUCTION_VOL, }; //===========================================================================// // PUBLIC VARIABLE //===========================================================================// extern unsigned long Elem_Change_Flag, Elem_Change_Flag_Old; //===========================================================================// // PUBLIC STRUCT DEFINE //===========================================================================// typedef struct { unsigned short Index; float Max; float Min; float Step; float Init_Value; unsigned short Type; // 0: int, 1: float unsigned short StartBit; unsigned long BitSize; unsigned short Convert; }DSP_Element_s; //===========================================================================// // PUBLIC FunCTION PROTOTYPES //===========================================================================// void Elem_New_Input_Write(unsigned short f_in_index, unsigned short f_ch, unsigned short f_ele_index, void *f_val, DSP_AP_Table_s *f_table); int Elem_New_Input_Read(unsigned short f_in_index, unsigned short f_ch, unsigned short f_ele_index); void Elem_Select_Write(unsigned short f_in_index, unsigned short f_ele_index, void *f_val, DSP_AP_Table_s *f_table); int Elem_Select_Read(unsigned short f_in_index, unsigned short f_ele_index); void Elem_New_Output_Write(unsigned short f_in_index, unsigned short f_ch, unsigned short f_ele_index, void *f_val, DSP_AP_Table_s *f_table); int Elem_New_Output_Read(unsigned short f_in_index, unsigned short f_ch, unsigned short f_ele_index); void Elem_Duncker_Stereo_Write(unsigned short f_in_index, unsigned short f_ele_index, void *f_val, DSP_AP_Table_s *f_table); int Elem_Duncker_Stereo_Read(unsigned short f_in_index, unsigned short f_ele_index); void Elem_AGC_Write(unsigned short f_in_index, unsigned short f_ele_index, void *f_val, DSP_AP_Table_s *f_table); int Elem_AGC_Read(unsigned short f_in_index, unsigned short f_ele_index); void Elem_AEC_Write(unsigned short f_in_index, unsigned short f_ele_index, void *f_val, DSP_AP_Table_s *f_table); int Elem_AEC_Read(unsigned short f_in_index, unsigned short f_ele_index); void Elem_Hi_Lo_Filter_Write(unsigned short f_in_index, unsigned short f_ele_index, void *f_val, DSP_AP_Table_s *f_table); int Elem_Hi_Lo_Filter_Read(unsigned short f_in_index, unsigned short f_ele_index); void Elem_PEQ_Write(unsigned short f_in_index, unsigned short f_band, unsigned short f_ele_index, void *f_val, DSP_AP_Table_s *f_table); int Elem_PEQ_Read(unsigned short f_in_index, unsigned short f_band, unsigned short f_ele_index); void Elem_HW_AGC_Write(unsigned short f_in_index, unsigned short f_ele_index, void *f_val, DSP_AP_Table_s *f_table); int Elem_HW_AGC_Read(unsigned short f_in_index, unsigned short f_ele_index); void Elem_SPC_Write(unsigned short f_in_index, unsigned short f_ch, unsigned short f_ele_index, void *f_val, DSP_AP_Table_s *f_table); int Elem_SPC_Read(unsigned short f_in_index, unsigned short f_ch, unsigned short f_ele_index); void Elem_HiLo_PEQ_Write(unsigned short f_in_index, unsigned short f_band, unsigned short f_ele_index, void *f_val, DSP_AP_Table_s *f_table); int Elem_HiLo_PEQ_Read(unsigned short f_in_index, unsigned short f_band, unsigned short f_ele_index); void Elem_NS_Write(unsigned short f_in_index, unsigned short f_ele_index, void *f_val, DSP_AP_Table_s *f_table); int Elem_NS_Read(unsigned short f_in_index, unsigned short f_ele_index); void Elem_CL_Write(unsigned short f_in_index, unsigned short f_ele_index, void *f_val, DSP_AP_Table_s *f_table); int Elem_CL_Read(unsigned short f_in_index, unsigned short f_ele_index); void Elem_CL_Init(unsigned short f_index, DSP_AP_Table_s *f_table); void Elem_Vol_Pencent_Write(unsigned short f_comp_type_id, unsigned short f_comp_id, float f_percent); void Elem_Vol_Log_Write(unsigned short f_comp_type_id, unsigned short f_comp_id, float f_percent); float Elem_Step_Get(unsigned short f_comp_type_id, unsigned short f_ele_index); void Elem_DSP_Table_Init(unsigned short f_product_id); void Elem_DSP_Save_Back_Polling(void); unsigned short* Elem_DSP_Comp_Addr_Lth_Get(DSP_AP_Table_s *f_table, unsigned short f_comp_type, unsigned short f_comp_id, unsigned long *f_comp_lth); void Elem_Ducker_Time_Correct(DSP_AP_Table_s *f_table, unsigned short f_table_ver); //===========================================================================// // FILE END //===========================================================================// //===========================================================================// // PUBLIC CONSTANTS //===========================================================================// // //===========================================================================// // PUBLIC STRUCT DEFINE //===========================================================================// typedef struct { char Title[40]; DSP_Component_s Table; unsigned short Reserve[4096]; }DSP_F_Table_s; /* Note typedef struct { unsigned short NAND_Title; unsigned short LTH[2]; unsigned short VER; unsigned short Amount; DSP_F_Table_s ~ unsigned long CRC32; }DSP_S_F_Table_s; */ //===========================================================================// // PUBLIC FUNCTION PROTOTYPES //===========================================================================// void DSP_Factory_Table_Init(void); void DSP_Factory_Table_Save(void); void DSP_Factory_Table_Load_From_File(unsigned short *f_data); unsigned long DSP_Factory_Table_Read_To_File(char **f_data); void DSP_Factory_Table_Load(unsigned short *f_data); void DSP_Factory_Table_Save_To_DSP(void); void DSP_Factory_Table_Elem_Chang(unsigned short f_comp_type, unsigned short f_comp_id, void *f_data); void DSP_Factory_Table_Elem_Read(unsigned short f_comp_type, unsigned short f_comp_id, void *f_data); void DSP_Factory_Table_Save_Back_Polling(unsigned short f_force); //===========================================================================// // FILE END //===========================================================================// /** * \file evmAM335x.h * * \brief This file contains prototype declarations of functions which * performs EVM configurations. */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /***************************************************************************** ** INTERNAL MACRO DEFINITIONS *****************************************************************************/ /* ** Structure to map selection of IO Pad for power down configuration */ typedef struct ioPadMap { unsigned int ioPad; unsigned int sel; }tIOPadMap; /* ** Structure to store the control register context. More registers ** can be added to this if need to be saved. */ typedef struct ctrlRegContext { unsigned int pwmssctrl; unsigned int gmiisel; tIOPadMap ioPadMap[(211)]; }CTRLREGCONTEXT; /***************************************************************************** ** FUNCTION PROTOTYPES *****************************************************************************/ extern unsigned int BoardInfoCheck(unsigned char *boardId, unsigned char *boardVer); extern void ControlRegContextSave(CTRLREGCONTEXT *contextPtr); extern void ControlRegContextRestore(CTRLREGCONTEXT *contextPtr); extern void EVMMACAddrGet(unsigned int addrIdx, unsigned char *macAddr); extern int McSPIPinMuxSetup(unsigned int instanceNum); extern int McSPI0CSPinMuxSetup(unsigned int csPinNum); extern void UARTPinMuxSetup(unsigned int instanceNum); extern unsigned int I2CPinMuxSetup(unsigned int instanceNum); extern void I2C0ModuleClkConfig(void); extern void I2C1ModuleClkConfig(void); extern void EDMAModuleClkConfig(void); extern void WatchdogTimer1ModuleClkConfig(void); extern unsigned int RTCRevisionInfoGet(void); extern void DMTimer2ModuleClkConfig(void); extern void DMTimer3ModuleClkConfig(void); extern void DMTimer4ModuleClkConfig(void); extern void DMTimer5_Module_Clk_Config(void); extern void DMTimer6ModuleClkConfig(void); extern void DMTimer7ModuleClkConfig(void); void DMTimer_1ms_Module_Clk_Config(void); extern void EVMPortRGMIIModeSelect(void); extern void McSPI0ModuleClkConfig(void); extern void McSPI1_Module_Clk_Config(void); extern unsigned int EVMProfileGet(void); extern unsigned int McASP1PinMuxSetup(void); extern void McASP0ModuleClkConfig(void); extern void McASP1ModuleClkConfig(void); extern unsigned int CPSWPinMuxSetup(void); extern unsigned int LCDPinMuxSetup(void); extern unsigned int GPIO0Pin6PinMuxSetup(void); extern unsigned int GPIO1Pin2PinMuxSetup(void); extern unsigned int GPIO0Pin2PinMuxSetup(void); extern unsigned int GPIO1PinMuxSetup(unsigned int pinNo); extern unsigned int GPIO1Pin30PinMuxSetup(void); extern void GPIO0ModuleClkConfig(void); extern void GPIO1ModuleClkConfig(void); extern void GPIO2_Module_Clk_Config(void); extern void GPIO3_Module_Clk_Config(void); extern void UART0ModuleClkConfig(void); extern void UART1_Module_Clk_Config(void); extern void UART2_Module_Clk_Config(void); extern void UART3_Module_Clk_Config(void); void UART_Baud_Rate_Set(unsigned long base_addr,unsigned long baud); extern void RTCModuleClkConfig(void); extern void EEPROMI2CSetUp(unsigned int slaveAddr); extern void EEPROMI2CRead(unsigned char *data, unsigned int length, unsigned short offset); extern unsigned int ECAPPinMuxSetup(unsigned int instanceNum); extern void WatchdogTimer1ModuleClkConfig(void); extern unsigned int RTCRevisionInfoGet(void); extern void DMTimer2ModuleClkConfig(void); extern unsigned int GPIO1Pin16PinMuxSetup(void); extern unsigned int EVMProfileGet(void); extern void GPIO1ModuleClkConfig(void); extern void LCDModuleClkConfig(void); extern unsigned int LCDPinMuxSetup(void); extern void LCDBackLightEnable(void); extern void TSCADCModuleClkConfig(void); extern void LCDBackLightDisable(void); extern void PWMSSModuleClkConfig(unsigned int instanceNum); extern unsigned int GPIO0Pin7PinMuxSetup(void); extern void CPSWClkEnable(void); extern unsigned int EPWM2PinMuxSetup(void); extern void PWMSSClockEnable(unsigned int instance, unsigned int module); extern unsigned int NANDPinMuxSetup(void); extern void GPMCClkConfig(void); extern unsigned int GPIO1Pin23PinMuxSetup(void); extern void EPWMSSModuleClkConfig(unsigned int instanceNum); extern unsigned int GPIO0Pin19PinMuxSetup(void); extern unsigned int GPIO1Pin28PinMuxSetup(void); extern void HSMMCSDModuleClkConfig(void); extern unsigned int HSMMCSDPinMuxSetup(void); extern unsigned int TSCADCPinMuxSetUp(void); extern void UPDNPinControl(void); extern unsigned int DCANPinMuxSetUp(unsigned int instanceNum); extern void DCANMsgRAMInit(unsigned int instanceNum); extern void DCANModuleClkConfig(void); extern void USB0ModuleClkConfig(void); extern void USBModuleClkEnable(unsigned int ulIndex, unsigned int ulBase); extern void USBModuleClkDisable(unsigned int ulIndex, unsigned int ulBase); extern unsigned int GPIO0PinMuxSetup(unsigned int pinNum); extern unsigned int GPIO1Pin20PinMuxSetup(void); extern unsigned int GPIO2Pin24PinMuxSetup(void); extern void PWMSSTBClkEnable(unsigned int); extern void PWMSSClockStop(unsigned int instance, unsigned int module); extern unsigned int PWMSSClockStopStatusGet(unsigned int instance, unsigned int module); unsigned int PWMSSClockEnableStatusGet(unsigned int instance, unsigned int module); extern void IOPadContextSave(CTRLREGCONTEXT *contextPtr, unsigned int ioPadOff); extern void IOPadContextRestore(CTRLREGCONTEXT *contextPtr, unsigned int ioPadOff); void IOPadConfigure(unsigned int ioPadOff, unsigned int ioPadValue); void IOPadSelConfigure(CTRLREGCONTEXT *contextPtr, unsigned int ioPadValue); void IOPadSel(CTRLREGCONTEXT *contextPtr, unsigned int ioPadOff, unsigned int ioPadSel); void GpioPinMuxSetup(unsigned int offsetAddr, unsigned int padConfValue); /******************************** End of file *******************************/ /** * \file gpio_v2.h * * \brief This file contains the prototypes of the APIs present in the * device abstraction layer file of GPIO belonging to AM335X SoC. * This also contains some related macros. */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /** * @Component: GPIO * * @Filename: ../../CredDataBase/gpio_v2_cred.h * ============================================================================ */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /*********************************************************************** * Register arrays Definition \***********************************************************************/ /*********************************************************************** * Bundle arrays Definition \***********************************************************************/ /*********************************************************************** * Bundles Definition \***********************************************************************/ /************************************************************************* * Registers Definition \*************************************************************************/ /************************************************************************** * Field Definition Macros \**************************************************************************/ /* REVISION */ /* SYSCONFIG */ /* IRQSTATUS_RAW_0 */ /* IRQSTATUS_RAW_1 */ /* IRQSTATUS_0 */ /* IRQSTATUS_1 */ /* IRQSTATUS_SET_0 */ /* IRQSTATUS_SET_1 */ /* IRQSTATUS_CLR_0 */ /* IRQSTATUS_CLR_1 */ /* SYSSTATUS */ /* CTRL */ /* OE */ /* DATAIN */ /* DATAOUT */ /* LEVELDETECT0 */ /* LEVELDETECT1 */ /* RISINGDETECT */ /* FALLINGDETECT */ /* DEBOUNCENABLE */ /* DEBOUNCINGTIME */ /* CLEARDATAOUT */ /* SETDATAOUT */ /***************************************************************************** ** MACRO DEFINITIONS *****************************************************************************/ /* Values used to configure the direction of GPIO pins. */ /* Values helping to decide the value on a GPIO pin. */ /* Values denoting the Interrupt Line number to be used. */ /* Values denoting the Smart Wakeup Interrupt Line to be used. */ /* ** Values used to enable/disable interrupt generation due to level ** detection on an input GPIO pin. */ /* ** Values used to enable/disable interrupt generation due to edge ** detection on an input GPIO pin. */ /* Values used for Idle Mode configurations. */ /* Values used to enable/disable Auto-Idle mode. */ /* Values used to configure the Gating Ratio. */ /* Values used to enable/disable Debouncing feature for an input pin. */ /* ** Structure to store the GPIO context */ typedef struct gpioContext{ unsigned int ctrl; unsigned int dir; unsigned int data; }GPIOCONTEXT; /***************************************************************************** ** FUNCTION PROTOTYPES *****************************************************************************/ extern void GPIOModuleReset(unsigned int baseAdd); extern void GPIOModuleEnable(unsigned int baseAdd); extern void GPIOModuleDisable(unsigned int baseAdd); extern void GPIODirModeSet(unsigned int baseAdd, unsigned int pinNumber, unsigned int pinDirection); extern unsigned int GPIODirModeGet(unsigned int baseAdd, unsigned int pinNumber); extern void GPIOPinWrite(unsigned int baseAdd, unsigned int pinNumber, unsigned int pinValue); extern unsigned int GPIOPinRead(unsigned int baseAdd, unsigned int pinNumber); extern void GPIOMultiplePinsWrite(unsigned int baseAdd, unsigned int setMask, unsigned int clrMask); extern unsigned int GPIOMultiplePinsRead(unsigned int baseAdd, unsigned int readMask); extern void GPIOPinIntEnable(unsigned int baseAdd, unsigned int intLine, unsigned int pinNumber); extern void GPIOPinIntDisable(unsigned int baseAdd, unsigned int intLine, unsigned int pinNumber); extern void GPIOIntTypeSet(unsigned int baseAdd, unsigned int pinNumber, unsigned int eventType); extern unsigned int GPIOIntTypeGet(unsigned int baseAdd, unsigned int pinNumber); extern unsigned int GPIOPinIntStatus(unsigned int baseAdd, unsigned int intLine, unsigned int pinNumber); extern void GPIOPinIntClear(unsigned int baseAdd, unsigned int intLine, unsigned int pinNumber); extern unsigned int GPIORawIntStatus(unsigned int baseAdd, unsigned int intLine, unsigned int readMask); extern void GPIOTriggerPinInt(unsigned int baseAdd, unsigned int intLine, unsigned int pinNumber); extern void GPIOWakeupGlobalEnable(unsigned int baseAdd); extern void GPIOWakeupGlobalDisable(unsigned int baseAdd); extern void GPIOPinIntWakeUpEnable(unsigned int baseAdd, unsigned int intLine, unsigned int pinNumber); extern void GPIOPinIntWakeUpDisable(unsigned int baseAdd, unsigned int intLine, unsigned int pinNumber); extern void GPIOAutoIdleModeControl(unsigned int baseAdd, unsigned int modeFlag); extern void GPIOIdleModeConfigure(unsigned int baseAdd, unsigned int modeFlag); extern void GPIOGatingRatioConfigure(unsigned int baseAdd, unsigned int configFlag); extern void GPIODebounceFuncControl(unsigned int baseAdd, unsigned int pinNumber, unsigned int controlFlag); extern void GPIODebounceTimeConfig(unsigned int baseAdd, unsigned int debounceTime); extern unsigned int GPIORevisionInfoGet(unsigned int baseAdd); extern void gpioContextSave(unsigned int baseAdd, GPIOCONTEXT *contextPtr); extern void gpioContextRestore(unsigned int baseAdd, GPIOCONTEXT *contextPtr); /********************************* End Of File ******************************/ /** * \file ecap.h * * \brief This file contains the function prototypes for the device * abstraction layer for ECAP. It also contains some * related macro definitions and some files to be included. */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /** * \file hw_ecap.h * * \brief ECAP register definitions */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /*************************************************************************** Field Definition Macros \**************************************************************************/ /* TSCTR */ /* CTRPHS */ /* CAP1 */ /* CAP2 */ /* CAP3 */ /* CAP4 */ /* ECCTL1 */ /* ECCTL2 */ /* ECEINT */ /* ECFLG */ /* ECCLR */ /* ECFRC */ /* REVID */ /****************************************************************************/ /* ** Values that can be passed to ECAPOperatingModeSelect API as modeSelect ** to select type operating mode. */ /****************************************************************************/ /* ** Values that can be passed to ECAPTimeStampRead API as capEvtFlag ** to determine for which capture event time-stamp has to be returned */ /****************************************************************************/ /* ** Values that can be passed to ECAPOneShotModeConfig API as stopVal ** which determines number of captures allowed to occur before ** Capture register(1-4) frozen.\n */ /****************************************************************************/ /* ** Values that can be passed to ECAPAPWMPolarityConfig API as flag ** which determines the output polarity for APWM output */ /****************************************************************************/ /* ** Values that can be passed to ECAPCounterControl API as flag ** which determines whether counter to be configured to stop ** or free running */ /****************************************************************************/ /* ** Values that can be passed to ECAPSyncInOutSelect API as syncIn ** to disable syncIn or to enable counter to be loaded from ** CNTPHS register upon a SYNCI signal */ /****************************************************************************/ /* ** Values that can be passed to ECAPSyncInOutSelect API as syncOut ** to select syncIn event to be the Sync-Out signal or select ** PRD_eq event to be Sync-Out signal or to disaqble syncOut ** signal */ /****************************************************************************/ /* ** Values that can be passed to ECAPIntEnable/Disable API ** to enable or disable interrupt or it can be passed ** ECAPIntStatus to get the interrupt or it can be passed ** to ECAPIntStatusClear to clear the interrupt status */ /* It can be passed to ECAPIntStatusClear to clear global interrupt flag */ /****************************************************************************/ /* ** Values that can be passed to ECAPStandByModeConfig API ** to configure ECAP module in different stand by mode. ** */ /****************************************************************************/ /* ** Values that can be passed to ECAPIdleModeConfig API ** to configure ECAP module in different Idle mode. ** */ /* ** Structure to save the ECAP context */ typedef struct ecapContext { unsigned short ecctl2; unsigned short ecclr; unsigned short eceint; unsigned int pwm0ssclkconfig; unsigned int tsctr; unsigned int cap1; unsigned int cap2; }ECAPCONTEXT; void ECAPClockStop(unsigned int baseAdd); void ECAPClockEnable(unsigned int baseAdd); void ECAPOneShotREARM(unsigned int baseAdd); void ECAPGlobalIntEnable(unsigned int baseAdd); void ECAPContinousModeConfig(unsigned int baseAdd); void ECAPCaptureLoadingEnable(unsigned int baseAdd); void ECAPCaptureLoadingDisable(unsigned int baseAdd); unsigned int ECAPPeripheralIdGet(unsigned int baseAdd); unsigned int ECAPClockStopStatusGet(unsigned int baseAdd); unsigned int ECAPClockEnableStatusGet(unsigned int baseAdd); void ECAPIntEnable(unsigned int baseAdd, unsigned int flag); void ECAPIntDisable(unsigned int baseAdd, unsigned int flag); void ECAPIntStatusClear(unsigned int baseAdd, unsigned int flag); void ECAPCounterControl(unsigned int baseAdd, unsigned int flag); void ECAPCounterConfig(unsigned int baseAdd, unsigned int countVal); unsigned int ECAPIntStatus(unsigned int baseAdd, unsigned int flag); void ECAPAPWMPolarityConfig(unsigned int baseAdd, unsigned int flag); void ECAPSyncInOutSelect(unsigned int baseAdd, unsigned int syncIn, unsigned int syncOut); void ECAPPrescaleConfig(unsigned int baseAdd, unsigned int prescale); void ECAPOneShotModeConfig(unsigned int baseAdd, unsigned int stopVal); void ECAPAPWMCaptureConfig(unsigned int baseAdd, unsigned int compareVal, unsigned int periodVal); void ECAPAPWMShadowCaptureConfig(unsigned int baseAdd, unsigned int compareVal, unsigned int periodVal); void ECAPOperatingModeSelect(unsigned int baseAdd, unsigned int modeSelect); unsigned int ECAPTimeStampRead(unsigned int baseAdd, unsigned int capEvtFlag); void ECAPCounterPhaseValConfig(unsigned int baseAdd, unsigned int cntPhaseVal); void ECAPCapeEvtPolarityConfig(unsigned int baseAdd, unsigned int capEvt1pol, unsigned int capEvt2pol, unsigned int capEvt3pol, unsigned int capEvt4pol); void ECAPCaptureEvtCntrRstConfig(unsigned int baseAdd, unsigned int CounterRst1, unsigned int CounterRst2,unsigned int CounterRst3, unsigned int CounterRst4); void ECAPClockEnable(unsigned int baseAdd); void ECAPClockDisable(unsigned int baseAdd); unsigned int ECAPClockEnableStatusGet(unsigned int baseAdd); unsigned int ECAPClockDisableStatusGet(unsigned int baseAdd); extern void EcapContextSave(unsigned int ecapBase, unsigned int pwmssBase, ECAPCONTEXT *contextPtr); extern void EcapContextRestore(unsigned int ecapBase, unsigned int pwmssBase, ECAPCONTEXT *contextPtr); /** * @Component: CONTROL * * @Filename: ../../CredDataBase/CONTROL_cred.h * ============================================================================ */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /*********************************************************************** * Register arrays Definition \***********************************************************************/ /*********************************************************************** * Bundle arrays Definition \***********************************************************************/ /*********************************************************************** * Bundles Definition \***********************************************************************/ /************************************************************************* * Registers Definition \*************************************************************************/ /************************************************************************** * Field Definition Macros \**************************************************************************/ /* CONTROL_REVISION */ /* CONTROL_HWINFO */ /* CONTROL_SYSCONFIG */ /* CONTROL_STATUS */ /* BOOTSTAT */ /* CONTROL_SEC_CTRL */ /* CONTROL_SEC_SW */ /* CONTROL_SEC_EMU */ /* SECURE_EMIF_SDRAM_CONFIG */ /* SECURE_EMIF_SDRAM_CONFIG_2 */ /* CONTROL_SW_CFG */ /* CONTROL_SW_CCFG */ /* CONTROL_MPK_0 */ /* CONTROL_MPK_1 */ /* CONTROL_MPK_2 */ /* CONTROL_MPK_3 */ /* CONTROL_MPK_4 */ /* CONTROL_MPK_5 */ /* CONTROL_MPK_6 */ /* CONTROL_MPK_7 */ /* CONTROL_SWRV_0 */ /* CONTROL_SWRV_1 */ /* CONTROL_SWRV_2 */ /* CONTROL_SWRV_3 */ /* CONTROL_SWRV_4 */ /* CONTROL_SWRV_5 */ /* CONTROL_SWRV_6 */ /* CONTROL_SEC_TAP */ /* CONTROL_SEC_TAP_CMDIN */ /* CONTROL_SEC_TAP_CMDOUT */ /* CONTROL_SEC_TAP_DATIN */ /* CONTROL_SEC_TAP_DATOUT */ /* CONTROL_MREQDOMAIN_EXP1 */ /* CONTROL_MREQDOMAIN_EXP2 */ /* L3_HW_FW_EXP_VAL_CONF0 */ /* L3_HW_FW_EXP_VAL_CONF1 */ /* L4_HW_FW_EXP_VAL_CONF */ /* CONTROL_SEC_LOAD_FW_EXP_VAL */ /* CONTROL_SEC_CTRL_RO */ /* EMIF_OBFUSCATION_KEY */ /* SEC_CLK_CTRL */ /* CONTROL_MREQDOMAIN_EXP3 */ /* CONTROL_CEK_0 */ /* CONTROL_CEK_1 */ /* CONTROL_CEK_2 */ /* CONTROL_CEK_3 */ /* CONTROL_CEK_BCH_0 */ /* CONTROL_CEK_BCH_1 */ /* CONTROL_CEK_BCH_2 */ /* CONTROL_CEK_BCH_3 */ /* CONTROL_CEK_BCH_4 */ /* CONTROL_MSV_0 */ /* CONTROL_MSV_BCH_0 */ /* CONTROL_MSV_BCH_1 */ /* CONTROL_SEC_STATUS */ /* CONTROL_SECMEM_STATUS */ /* CONTROL_SEC_ERR_STAT_FUNC0 */ /* CONTROL_SEC_ERR_STAT_FUNC1 */ /* CONTROL_SEC_ERR_STAT_DBUG0 */ /* CONTROL_SEC_ERR_STAT_DBUG1 */ /* CONTROL_KEK_SW_0 */ /* CONTROL_KEK_SW_1 */ /* CONTROL_KEK_SW_2 */ /* CONTROL_KEK_SW_3 */ /* CONTROL_CMPK_BCH_0 */ /* CONTROL_CMPK_BCH_1 */ /* CONTROL_CMPK_BCH_2 */ /* CONTROL_CMPK_BCH_3 */ /* CONTROL_CMPK_BCH_4 */ /* CONTROL_CMPK_BCH_5 */ /* CONTROL_CMPK_BCH_6 */ /* CONTROL_CMPK_BCH_7 */ /* CONTROL_CMPK_BCH_8 */ /* CONTROL_CMPK_0 */ /* CONTROL_CMPK_1 */ /* CONTROL_CMPK_2 */ /* CONTROL_CMPK_3 */ /* CONTROL_CMPK_4 */ /* CONTROL_CMPK_5 */ /* CONTROL_CMPK_6 */ /* CONTROL_CMPK_7 */ /* SSM_END_FAST_SECRAM */ /* SSM_FIREWALL_CONTROLLER */ /* SSM_START_SECURE_STACKED_RAM */ /* SSM_END_SECURE_STACKED_RAM */ /* SSM_START_SPM_STACK */ /* SSM_END_SPM_STACK */ /* SSM_START_MONITOR_RAMCODE */ /* SSM_END_MONITOR_RAMCODE */ /* SSM_END_MONITOR_RAMDATA */ /* SSM_START_MONITOR_CODE */ /* SSM_END_MONITOR_CODE */ /* SSM_START_MONITOR_PERIPH */ /* SSM_END_MONITOR_PERIPH */ /* SSM_START_MONITOR_STACK */ /* SSM_END_MONITOR_STACK */ /* SSM_START_MONITOR_RAMCODE_ETM */ /* SSM_END_MONITOR_RAMCODE_ETM */ /* SSM_END_MONITOR_RAMDATA_ETM */ /* SSM_START_MONITOR_CODE_ETM */ /* SSM_END_MONITOR_CODE_ETM */ /* SSM_START_MONITOR_STACK_ETM */ /* SSM_END_MONITOR_STACK_ETM */ /* SSM_START_MONITOR_SHARED_ETM */ /* SSM_END_MONITOR_SHARED_ETM */ /* SSM_START_MONITOR_PERIPH_ETM */ /* SSM_END_MONITOR_PERIPH_ETM */ /* SSM_CPSR_MODE_ENFC */ /* SSM_END_L3_SECRAM */ /* CORTEX_VBBLDO_CTRL */ /* CORE_SLDO_CTRL */ /* MPU_SLDO_CTRL */ /* REFCLK_LJCBLDO_CTRL */ /* CLK32KDIVRATIO_CTRL */ /* BANDGAP_CTRL */ /* BANDGAP_TRIM */ /* PLL_CLKINPULOW_CTRL */ /* MOSC_CTRL */ /* RCOSC_CTRL */ /* DEEPSLEEP_CTRL */ /* PE_SCRATCHPAD_0 */ /* PE_SCRATCHPAD_1 */ /* PE_SCRATCHPAD_2 */ /* PE_SCRATCHPAD_3 */ /* DEVICE_ID */ /* DEV_FEATURE */ /* INIT_PRIORITY_0 */ /* INIT_PRIORITY_1 */ /* MMU_CFG */ /* TPTC_CFG */ /* OCMC_CFG */ /* USB_CTRL0 */ /* USB_STS0 */ /* USB_CTRL1 */ /* USB_STS1 */ /* MAC_ID0_LO */ /* MAC_ID0_HI */ /* MAC_ID1_LO */ /* MAC_ID1_HI */ /* DCAN_RAMINIT */ /* USB_WKUP_CTRL */ /* GMII_SEL */ /* PWMSS_CTRL */ /* MREQPRIO_0 */ /* MREQPRIO_1 */ /* HW_EVENT_SEL_GRP1 */ /* HW_EVENT_SEL_GRP2 */ /* HW_EVENT_SEL_GRP3 */ /* HW_EVENT_SEL_GRP4 */ /* SMRT_CTRL */ /* SABTOOTH_HW_DEBUG_SEL */ /* SABTOOTH_HW_DBG_INFO */ /* MRGN_MODE0 */ /* MRGN_MODE1 */ /* VDD_MPU_OPP_050 */ /* VDD_MPU_OPP_100 */ /* VDD_MPU_OPP_119 */ /* VDD_MPU_OPP_TURBO */ /* VDD_CORE_OPP_050 */ /* VDD_CORE_OPP_100 */ /* BB_SCALE */ /* USB_VID_PID */ /* EFUSE_SMA */ /* CONF_GPMC_ADx */ /* CONF_GPMC_AD0 */ /* CONF_GPMC_AD1 */ /* CONF_GPMC_AD2 */ /* CONF_GPMC_AD3 */ /* CONF_GPMC_AD4 */ /* CONF_GPMC_AD5 */ /* CONF_GPMC_AD6 */ /* CONF_GPMC_AD7 */ /* CONF_GPMC_AD8 */ /* CONF_GPMC_AD9 */ /* CONF_GPMC_AD10 */ /* CONF_GPMC_AD11 */ /* CONF_GPMC_AD12 */ /* CONF_GPMC_AD13 */ /* CONF_GPMC_AD14 */ /* CONF_GPMC_AD15 */ /* CONF_GPMC_A0 */ /* CONF_GPMC_A1 */ /* CONF_GPMC_A2 */ /* CONF_GPMC_A3 */ /* CONF_GPMC_A4 */ /* CONF_GPMC_A5 */ /* CONF_GPMC_A6 */ /* CONF_GPMC_A7 */ /* CONF_GPMC_A8 */ /* CONF_GPMC_A9 */ /* CONF_GPMC_A10 */ /* CONF_GPMC_A11 */ /* CONF_GPMC_WAIT0 */ /* CONF_GPMC_WPN */ /* CONF_GPMC_BE1N */ /* CONF_GPMC_CSN0 */ /* CONF_GPMC_CSN1 */ /* CONF_GPMC_CSN2 */ /* CONF_GPMC_CSN3 */ /* CONF_GPMC_CLK */ /* CONF_GPMC_ADVN_ALE */ /* CONF_GPMC_OEN_REN */ /* CONF_GPMC_WEN */ /* CONF_GPMC_BE0N_CLE */ /* CONF_LCD_DATA0 */ /* CONF_LCD_DATA1 */ /* CONF_LCD_DATA2 */ /* CONF_LCD_DATA3 */ /* CONF_LCD_DATA4 */ /* CONF_LCD_DATA5 */ /* CONF_LCD_DATA6 */ /* CONF_LCD_DATA7 */ /* CONF_LCD_DATA8 */ /* CONF_LCD_DATA9 */ /* CONF_LCD_DATA10 */ /* CONF_LCD_DATA11 */ /* CONF_LCD_DATA12 */ /* CONF_LCD_DATA13 */ /* CONF_LCD_DATA14 */ /* CONF_LCD_DATA15 */ /* CONF_LCD_DATA16 */ /* CONF_LCD_DATA17 */ /* CONF_LCD_DATA18 */ /* CONF_LCD_DATA19 */ /* CONF_LCD_DATA20 */ /* CONF_LCD_DATA21 */ /* CONF_LCD_DATA22 */ /* CONF_LCD_DATA20 */ /* CONF_LCD_VSYNC */ /* CONF_LCD_HSYNC */ /* CONF_LCD_PCLK */ /* CONF_LCD_AC_BIAS_EN */ /* CONF_MMC0_DAT3 */ /* CONF_MMC0_DAT2 */ /* CONF_MMC0_DAT1 */ /* CONF_MMC0_DAT0 */ /* CONF_MMC0_CLK */ /* CONF_MMC0_CMD */ /* CONF_MII1_COL */ /* CONF_MII1_CRS */ /* CONF_MII1_RXERR */ /* CONF_MII1_TXEN */ /* CONF_MII1_RXDV */ /* CONF_MII1_TXD3 */ /* CONF_MII1_TXD2 */ /* CONF_MII1_TXD1 */ /* CONF_MII1_TXD0 */ /* CONF_MII1_TXCLK */ /* CONF_MII1_RXCLK */ /* CONF_MII1_RXD3 */ /* CONF_MII1_RXD2 */ /* CONF_MII1_RXD1 */ /* CONF_MII1_RXD0 */ /* CONF_RMII1_REFCLK */ /* CONF_MDIO_DATA */ /* CONF_MDIO_CLK */ /* CONF_SPI0_SCLK */ /* CONF_SPI0_D0 */ /* CONF_SPI0_D1 */ /* CONF_SPI0_CS0 */ /* CONF_SPI0_CS1 */ /* CONF_ECAP0_IN_PWM0_OUT */ /* CONF_UART0_CTSN */ /* CONF_UART0_RTSN */ /* CONF_UART0_RXD */ /* CONF_UART0_TXD */ /* CONF_UART1_CTSN */ /* CONF_UART1_RTSN */ /* CONF_UART1_RXD */ /* CONF_UART1_TXD */ /* CONF_I2C0_SDA */ /* CONF_I2C0_SCL */ /* CONF_I2C0_SDA */ /* CONF_I2C0_SCL */ /* CONF_MCASP0_ACLKX */ /* CONF_MCASP0_FSX */ /* CONF_MCASP0_AXR0 */ /* CONF_MCASP0_AHCLKR */ /* CONF_MCASP0_ACLKR */ /* CONF_MCASP0_FSR */ /* CONF_MCASP0_AXR1 */ /* CONF_MCASP0_AHCLKX */ /* CONF_XDMA_EVENT_INTR0 */ /* CONF_XDMA_EVENT_INTR1 */ /* CONF_NRESETIN_OUT */ /* CONF_PORZ */ /* CONF_NNMI */ /* CONF_OSC0_IN */ /* CONF_OSC0_OUT */ /* CONF_OSC0_VSS */ /* CONF_TMS */ /* CONF_TDI */ /* CONF_TDO */ /* CONF_TCK */ /* CONF_NTRST */ /* CONF_EMU0 */ /* CONF_EMU1 */ /* CONF_OSC1_IN */ /* CONF_OSC1_OUT */ /* CONF_OSC1_VSS */ /* CONF_RTC_PORZ */ /* CONF_PMIC_POWER_EN */ /* CONF_EXT_WAKEUP */ /* CONF_ENZ_KALDO_1P8V */ /* CONF_USB0_DM */ /* CONF_USB0_DP */ /* CONF_USB0_CE */ /* CONF_USB0_ID */ /* CONF_USB0_VBUS */ /* CONF_USB0_DRVVBUS */ /* CONF_USB1_DM */ /* CONF_USB1_DP */ /* CONF_USB1_CE */ /* CONF_USB1_ID */ /* CONF_USB1_VBUS */ /* CONF_USB1_DRVVBUS */ /* CONF_DDR_RESETN */ /* CONF_DDR_CSN0 */ /* CONF_DDR_CKE */ /* CONF_DDR_NCK */ /* CONF_DDR_CASN */ /* CONF_DDR_RASN */ /* CONF_DDR_WEN */ /* CONF_DDR_BA0 */ /* CONF_DDR_BA1 */ /* CONF_DDR_BA2 */ /* CONF_DDR_A0 */ /* CONF_DDR_A1 */ /* CONF_DDR_A2 */ /* CONF_DDR_A3 */ /* CONF_DDR_A4 */ /* CONF_DDR_A5 */ /* CONF_DDR_A6 */ /* CONF_DDR_A7 */ /* CONF_DDR_A8 */ /* CONF_DDR_A9 */ /* CONF_DDR_A10 */ /* CONF_DDR_A11 */ /* CONF_DDR_A12 */ /* CONF_DDR_A13 */ /* CONF_DDR_A14 */ /* CONF_DDR_A15 */ /* CONF_DDR_ODT */ /* CONF_DDR_D0 */ /* CONF_DDR_D1 */ /* CONF_DDR_D2 */ /* CONF_DDR_D3 */ /* CONF_DDR_D4 */ /* CONF_DDR_D5 */ /* CONF_DDR_D6 */ /* CONF_DDR_D7 */ /* CONF_DDR_D8 */ /* CONF_DDR_D9 */ /* CONF_DDR_D10 */ /* CONF_DDR_D11 */ /* CONF_DDR_D12 */ /* CONF_DDR_D13 */ /* CONF_DDR_D14 */ /* CONF_DDR_D15 */ /* CONF_DDR_DQM0 */ /* CONF_DDR_DQM1 */ /* CONF_DDR_DQS0 */ /* CONF_DDR_DQSN0 */ /* CONF_DDR_DQS1 */ /* CONF_DDR_DQSN1 */ /* CONF_DDR_VREF */ /* CONF_DDR_VTP */ /* CONF_DDR_STRBEN0 */ /* CONF_DDR_STRBEN1 */ /* CONF_AIN7 */ /* CONF_AIN6 */ /* CONF_AIN5 */ /* CONF_AIN4 */ /* CONF_AIN3 */ /* CONF_AIN2 */ /* CONF_AIN1 */ /* CONF_AIN0 */ /* CONF_VREFP */ /* CONF_VREFN */ /* CONF_AVDD */ /* CONF_AVSS */ /* CONF_IFORCE */ /* CONF_VSENSE */ /* CONF_TESTOUT */ /* CQDETECT_STATUS */ /* DDR_IO_CTRL */ /* VTP_CTRL */ /* VREF_CTRL */ /* SERDES_REFCLK_CTL */ /* TPCC_EVT_MUX_0_3 */ /* TPCC_EVT_MUX_4_7 */ /* TPCC_EVT_MUX_8_11 */ /* TPCC_EVT_MUX_12_15 */ /* TPCC_EVT_MUX_16_19 */ /* TPCC_EVT_MUX_20_23 */ /* TPCC_EVT_MUX_24_27 */ /* TPCC_EVT_MUX_28_31 */ /* TPCC_EVT_MUX_32_35 */ /* TPCC_EVT_MUX_36_39 */ /* TPCC_EVT_MUX_40_43 */ /* TPCC_EVT_MUX_44_47 */ /* TPCC_EVT_MUX_48_51 */ /* TPCC_EVT_MUX_52_55 */ /* TPCC_EVT_MUX_56_59 */ /* TPCC_EVT_MUX_60_63 */ /* TIMER_EVT_CAPT */ /* ECAP_EVT_CAPT */ /* ADC_EVT_CAPT */ /* RESET_ISO */ /* SMA0 */ /* DDR_CKE_CTRL */ /* SMA2 */ /* M3_TXEV_EOI */ /* IPC_MSG_REG0 */ /* IPC_MSG_REG1 */ /* IPC_MSG_REG2 */ /* IPC_MSG_REG3 */ /* IPC_MSG_REG4 */ /* IPC_MSG_REG5 */ /* IPC_MSG_REG6 */ /* IPC_MSG_REG7 */ /* DDR_CMD0_IOCTRL */ /* DDR_CMD1_IOCTRL */ /* DDR_CMD2_IOCTRL */ /* DDR_DATA0_IOCTRL */ /* DDR_DATA1_IOCTRL */ /* DDR_DATA2_IOCTRL */ /* DDR_DATA3_IOCTRL */ /* DDR_DATA4_IOCTRL */ /** ============================================================================ * \file soc_AM33XX.h * * \brief This file contains the peripheral information for AM33XX SoC * * ============================================================================ */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /** Cache Line size in ARM Cortex-A8. */ /** @brief Base address of AINTC memory mapped registers */ /** @brief Base addresses of UART memory mapped registers */ /** @brief Base addresses of USB memory mapped registers */ /** @brief Base addresses of SPI memory mapped registers */ /** @brief Base addresses of GPIO memory mapped registers */ /** @brief Base addresses of DMTIMER memory mapped registers */ /** @brief Base address of MMC memory mapped registers */ /** @brief Base address of GPMC memory mapped registers */ /** @brief Base address of GPMC memory mapped registers */ /** @brief Base address of I2C memory mapped registers */ /** @brief Base address of Timer 1ms memory mapped registers */ /** @brief Base address of WDT memory mapped registers */ /** @brief Base address of WDT memory mapped registers */ /** @brief Base address of McASP memory mapped registers */ /** @brief Base address of EMIF memory mapped registers */ /** @brief Base addresses of RTC memory mapped registers */ /** @brief Base addresses of PRCM memory mapped registers */ /** @brief Base address of control module memory mapped registers */ /** @brief Base address of Channel controller memory mapped registers */ /** @brief Base address of DCAN module memory mapped registers */ /******************************************************************************* Parameterizable Configuration:- These are fed directly from the RTL * parameters for the given SOC \******************************************************************************/ /** @brief Base addresses of PWMSS memory mapped registers. */ extern unsigned short Mcu_Board_Ver; void GPIO_Init(void); void GPIO2ModuleClkConfig(void); void GPIO3ModuleClkConfig(void); void MMCSDPinMuxSetup(void); void EcapInit(void); /* ============================================================================= * * Description: This is a C++ to C Header file for Device Driver Log * * ----------------------------------------------------------------------------- * Comments: * * ===========================================================================*/ //==============Error Number=========== // // //====================== Log reversion JH ===================== //====================== Log reversion End ==================== typedef enum { LOG_EMERGENCY, LOG_ALERT, LOG_CRITICAL, LOG_ERROR, LOG_WARNING, LOG_NOTICE, LOG_INFORMATIONAL, LOG_DEBUG }Severity_e; typedef struct { unsigned short Fault_Num; unsigned short Cnt; char message[200][60]; }Error_Message_s; typedef struct { char *Process_Current; char *Process_Save_Addr; unsigned long Backup_LTH; unsigned long Fault[((500-1)/32+1)]; unsigned long Fault_NULL_CRC32; unsigned long Fault_CRC32; Error_Message_s *Error_Message[500]; Severity_e Fault_Severity[500]; unsigned short Local_Fault_Exist; unsigned short Error_Message_Cnt; unsigned short Net_Message_Cnt; unsigned short Monitor_Counter; unsigned short Process_Num; unsigned short Backup_Num; unsigned char Fault_Into_Log[500]; char Fault_Title[500][30]; char Process[(512*1024)]; char Backup[(512*1024)]; }LOG_MESSAGE_s; typedef struct { Severity_e Severity; unsigned short Fault; unsigned short Log_Record; char Title[30]; }Fault_Title_s; extern LOG_MESSAGE_s LOG_MESSAGE; void Fault_Remove(unsigned short Kind); unsigned short Erase_Log(void); void Fault_Add(unsigned short Kind); unsigned short Fault_Check(unsigned short Kind); void Add_Error_MSG(unsigned short Kind,char *Msg); void Rm_Error_MSG(unsigned short Kind,char *Msg); void RM_Error_All_MSG(unsigned short Kind); unsigned short Get_Er_MSG_Cnt(unsigned short Kind); unsigned short Check_Er_MSG(unsigned short Kind,char *Msg); Error_Message_s* Get_Er_MSG(unsigned short Kind); //====================== Log reversion JH ===================== void Log_init(unsigned short first); unsigned short Log_Save(void); void Get_Log_Remain_Data(unsigned char *data); void Set_Log_Remain_Data(unsigned char *data); void Fault_Polling(void); unsigned short Log_add(Severity_e severity,char *Str_p); unsigned short Read_Appoint_log(unsigned short Appoint,unsigned short Count,char* Output,unsigned short *Output_string_size); unsigned short Get_Log_Count(void); void Reset_System_Fault(void); unsigned long Last_offset(char *String_p,unsigned long Search_Count); char *Last_string(char *String_p,unsigned long Search_Count); //====================== Log reversion End ==================== //======================================================================= unsigned short Net_Log_Request_Fun(unsigned short ID1,unsigned short Appoint,unsigned short Count,unsigned short *Length,char *data); extern unsigned short Exception_Flag; void NMI_Init(void); void NMI_Save_Init(void); void NMI_Recovery(void); void Reset_Machine(unsigned long f_wait_flag); void Reset_Machine_Register(void); void Exception_Init(void); void Exception_Reset_Machine(void); unsigned short Abnormal_Restart_Check(void); /** * \file rtc.h * * \brief Header file for RTC driver module. This file contains the * prototypes of the APIs of RTC module and some related macros. */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /** * @Component: RTC * * @Filename: hw_rtc.h * ============================================================================ */ /* * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /*********************************************************************** * Register arrays Definition \***********************************************************************/ /*********************************************************************** * Bundle arrays Definition \***********************************************************************/ /*********************************************************************** * Bundles Definition \***********************************************************************/ /************************************************************************* * Registers Definition \*************************************************************************/ /*------Definitions specific to RTC IP in AM335x -------- */ /*************************************************************************** Field Definition Macros \**************************************************************************/ /* SECOND */ /* MINUTE */ /* HOUR */ /* DAY */ /* MONTH */ /* YEAR */ /* DOTW */ /* ALARMSECOND */ /* ALARMMINUTE */ /* ALARMHOUR */ /* ALARMDAY */ /* ALARMMONTH */ /* ALARMYEAR */ /* CTRL */ /*----- Definition specific to RTC IP in AM1808 ----------*/ /*--------------------------------------------------------*/ /*-------- Definition specific to RTC IP in AM335x -------*/ /*--------------------------------------------------------*/ /* STATUS */ /* INTERRUPTS */ /* COMPLSB */ /* COMPMSB */ /* OSC */ /*----- Definition specific to RTC IP in AM1808 ----------*/ /*--------------------------------------------------------*/ /*----- Definitions specific to RTC IP in AM335x ---------*/ /*--------------------------------------------------------*/ /* SCRATCH0 */ /* SCRATCH1 */ /* SCRATCH2 */ /* KICK0 */ /* KICK1 */ /*----- Definitions specific to RTC IP in AM335x ---------*/ /* REVISION */ /* SYSCONFIG */ /* IRQWAKEEN */ /* ALARM2_SECONDS_REG */ /* ALARM2_MINUTES_REG */ /* ALARM2_HOURS_REG */ /* ALARM2_DAYS_REG */ /* ALARM2_MONTHS_REG */ /* ALARM2_YEARS_REG */ /* RTC_PMIC_REG */ /* RTC_DEBOUNCE_REG */ /*-------------------------------------------------------*/ /*****************************************************************************/ /* Either of these macros are returned by the RTCEnableStatus() API.*/ /* Used to disable RTC instance.*/ /* Used to indicate that RTC is enabled and functional.*/ /*****************************************************************************/ /* Either of these macros are used as a parameter to RTCHourModeSet() API.*/ /* Used to enable 12 hour mode for hours.*/ /* Used to enable 24 hour mode for hours.*/ /*****************************************************************************/ /* ** One among the following macros are passed as a parameter to ** RTCIntTimerEnable() API. */ /* Used to enable interrupt generation on every second.*/ /* Used to enable interrupt generation on every minute.*/ /* Used to enable interrupt generation on every hour.*/ /* Used to enable interrupt generation on every day.*/ /****************************************************************************/ /* Either of these macros are returned by the RTCAlarmIntStatusGet() API. */ /* Used to indicate that a new alarm interrupt has been generated. */ /* Used to indicate that no new alarm interrupt has been generated.*/ /****************************************************************************/ /* Either of these macros are returned by the RTCAlarm2IntStatusGet() API. */ /* Used to indicate that a new alarm interrupt has been generated. */ /* Used to indicate that no new alarm interrupt has been generated.*/ /****************************************************************************/ /* ** Any one of the following macros or a combination of the same are returned ** by the RTCEventUpdateGet() API. */ /* ** Used to indicate that DAY register was incremented in the latest ** time update. */ /* ** Used to indicate that HOUR register was incremented in the latest ** time update. */ /* ** Used to indicate that MINUTE register was incremented in the latest ** time update. */ /* ** Used to indicate that SECOND register was incremented in the latest ** time update. */ /****************************************************************************/ /* These macros are returned by the RTCBusyStatusGet() API. */ /* Used to indicate that RTC is busy in updating its registers.*/ /* ** Used to indicate that RTC is free and is currently not updating its ** registers. */ /****************************************************************************/ /* These macros are returned by the function RTCRunStatusGet() API. */ /* Used to indicate that RTC is in running state.*/ /* Used to indicate that RTC is in stopped state.*/ /*****************************************************************************/ /* ** Either of following macros are passed as a parameter to ** RTCAlarmHourMeridiemSet() and RTCMeridiemSet() APIs. Similarly either of ** these are returned by RTCAlarmHourMeridiemGet() and RTCMeridiemGet() APIs. */ /* Used to set the meridiem as post-meridiem(PM).*/ /* Used to set the meridiem as ante-meridiem(AM).*/ /*****************************************************************************/ /* ** One among the following macros are passed as a parameter to ** RTCDayOfTheWeekSet() API. Similarly one of these macros are returned by the ** RTCDayOfTheWeekGet() API. */ /* Used to indicate the days of the week. */ /*****************************************************************************/ /* Definitions specific to RTC IP in AM335X. */ /* ** RTC Idle Mode Options. */ /* ** Values are used to enable/disable Wakeup generation on Alarm event. */ /* ** Values are used to enable/disable Wakeup generation on Timer event. */ /* Values used to enable/disable Test Mode. */ /* Values used to select the clock source to the RTC. */ /* Values used to enable/disable the RTC to receive clock inputs from the selected source. */ /* Values used to enable/disable the Oscillator. */ /* Values used to select the mode of the Oscillator Feedback resistor. */ /* Values used to enable/disable PMIC Power. Passed as parameters to the API RTCConfigPmicPowerEnable(). */ /* Values used to configure polarity of external wake pin. Passed as parameters to the API RTCConfigPmicExtWakePolarity(). */ /* Values used to configure polarity of external wake pin. Passed as parameters to the API RTCConfigPmicExtWakePolarity(). */ /* Values used to configure polarity of external wake pin. Passed as parameters to the API RTCConfigPmicExtWakePolarity(). */ /*****************************************************************************/ /****************************************************************************** ** DRIVER API FUNCTIONS PROTOTYPES ******************************************************************************/ /****************************************************************************** ** APIs common to the RTC IPs of both AM1808 and AM335x. ******************************************************************************/ extern void RTCRun(unsigned int baseAddr); extern void RTCStop(unsigned int baseAddr); extern void RTCMinRoundingEnable(unsigned int baseAddr); extern void RTCMinRoundingDisable(unsigned int baseAddr); extern void RTCAutoCompEnable(unsigned int baseAddr); extern void RTCAutoCompDisable(unsigned int baseAddr); extern void RTCHourModeSet(unsigned int baseAddr, unsigned int hourType); extern unsigned int RTCHourModeGet(unsigned int baseAddr); extern void RTCSet32CounterEnable(unsigned int baseAddr); extern void RTCSet32CounterDisable(unsigned int baseAddr); extern unsigned int RTCEnableStatus(unsigned int baseAddr); extern void RTCDisable(unsigned int baseAddr); extern void RTCEnable(unsigned int baseAddr); extern void RTCSplitPwrEnable(unsigned int baseAddr); extern void RTCSplitPwrDisable(unsigned int baseAddr); extern void RTCWriteProtectEnable(unsigned int baseAddr); extern void RTCWriteProtectDisable(unsigned int baseAddr); extern void RTCIntAlarmEnable(unsigned int baseAddr); extern void RTCIntAlarmDisable(unsigned int baseAddr); extern void RTCIntTimerEnable(unsigned int baseAddr, unsigned int timerPeriod); extern void RTCIntTimerDisable(unsigned int baseAddr); extern unsigned int RTCBusyStatusGet(unsigned int baseAddr); extern unsigned int RTCRunStatusGet(unsigned int baseAddr); extern unsigned int RTCAlarmIntStatusGet(unsigned int baseAddr); extern void RTCAlarmIntStatusClear(unsigned int baseAddr); extern unsigned int RTCEventUpdateGet(unsigned int baseAddr); extern void RTCSecondSet(unsigned int baseAddr, unsigned int secValue); extern unsigned int RTCSecondGet(unsigned int baseAddr); extern void RTCMinuteSet(unsigned int baseAddr, unsigned int minValue); extern unsigned int RTCMinuteGet(unsigned int baseAddr); extern void RTCHourSet(unsigned int baseAddr, unsigned int hourValue); extern unsigned int RTCHourGet(unsigned int baseAddr); extern void RTCMeridiemSet(unsigned int baseAddr, unsigned int meridiemType); extern unsigned int RTCMeridiemGet(unsigned int baseAddr); extern void RTCDayOfMonthSet(unsigned int baseAddr, unsigned int dayValue); extern unsigned int RTCDayOfMonthGet(unsigned int baseAddr); extern void RTCMonthSet(unsigned int baseAddr, unsigned int monthValue); extern unsigned int RTCMonthGet(unsigned int baseAddr); extern void RTCYearSet(unsigned int baseAddr, unsigned int yearValue); extern unsigned int RTCYearGet(unsigned int baseAddr); extern void RTCDayOfTheWeekSet(unsigned int baseAddr, unsigned int dotwValue); extern unsigned int RTCDayOfTheWeekGet(unsigned int baseAddr); extern void RTCTimeSet(unsigned int baseAddr, unsigned int time); extern unsigned int RTCTimeGet(unsigned int baseAddr); extern void RTCCalendarSet(unsigned int baseAddr, unsigned int calendar); extern unsigned int RTCCalendarGet(unsigned int baseAddr); extern void RTCAlarmSecondSet(unsigned int baseAddr, unsigned int alarmSecValue); extern unsigned int RTCAlarmSecondGet(unsigned int baseAddr); extern void RTCAlarmMinuteSet(unsigned int baseAddr, unsigned int alrmMinValue); extern unsigned int RTCAlarmMinuteGet(unsigned int baseAddr); extern void RTCAlarmHourSet(unsigned int baseAddr, unsigned int alrmHourVal); extern unsigned int RTCAlarmHourGet(unsigned int baseAddr); extern void RTCAlarmHourMeridiemSet(unsigned int baseAddr, unsigned int meridiemType); extern unsigned int RTCAlarmHourMeridiemGet(unsigned int baseAddr); extern void RTCAlarmTimeSet(unsigned int baseAddr, unsigned int alarmTime); extern unsigned int RTCAlarmTimeGet(unsigned int baseAddr); extern void RTCAlarmDayOfMonthSet(unsigned int baseAddr, unsigned int alarmDayValue); extern unsigned int RTCAlarmDayOfMonthGet(unsigned int baseAddr); extern void RTCAlarmMonthSet(unsigned int baseAddr, unsigned int alrmMnthVal); extern unsigned int RTCAlarmMonthGet(unsigned int baseAddr); extern void RTCAlarmYearSet(unsigned int baseAddr, unsigned int alrmYrVal); extern unsigned int RTCAlarmYearGet(unsigned int baseAddr); extern void RTCAlarmCalendarSet(unsigned int baseAddr, unsigned int calVal); extern unsigned int RTCAlarmCalendarGet(unsigned int baseAddr); extern void RTCCompensationSet(unsigned int baseAddr, unsigned int compVal); extern unsigned int RTCCompensationGet(unsigned int baseAddr); extern void RTCScratchPadSet(unsigned int baseAddr, unsigned int regNumber, unsigned int scratchValue); extern unsigned int RTCScratchPadGet(unsigned int baseAddr, unsigned int regNumber); /***************************************************************************** ** APIs specific to RTC IP of AM1808 and not applicable for that in AM335x. *****************************************************************************/ extern void RTCSoftwareReset(unsigned int baseAddr); /***************************************************************************** ** APIs specific to RTC IP of AM335x and not applicable for that in AM1808. *****************************************************************************/ extern void RTCIdleModeConfigure(unsigned int baseAdd, unsigned int modeFlag); extern void RTCWakeUpAlarmEventControl(unsigned int baseAdd, unsigned int controlFlag); extern void RTCWakeUpTimerEventControl(unsigned int baseAdd, unsigned int controlFlag); extern void RTCTestModeControl(unsigned int baseAdd, unsigned int controlFlag); extern void RTC32KClkSourceSelect(unsigned int baseAdd, unsigned int clkSrcFlag); extern void RTC32KClkClockControl(unsigned int baseAdd, unsigned int controlFlag); extern void RTCOscillatorStateControl(unsigned int baseAdd, unsigned int controlFlag); extern void RTCFeedbackResistanceSelect(unsigned int baseAdd, unsigned int selectFlag); extern void RTCConfigPmicPowerEnable(unsigned int baseAdd, unsigned int selectFlag); extern void RTCConfigPmicExtWakePolarity(unsigned int baseAdd, unsigned int extInput, unsigned int selectFlag); extern void RTCConfigPmicExtWake(unsigned int baseAdd, unsigned int extInput, unsigned int selectFlag); extern void RTCConfigPmicExtWakeDebounce(unsigned int baseAdd, unsigned int extInput, unsigned int selectFlag); extern void RTCPmicExtWakeStatusClear(unsigned int baseAdd, unsigned int extInput); extern void RTCIntAlarm2Enable(unsigned int baseAddr); extern void RTCAlarm2IntStatusClear(unsigned int baseAddr); extern void RTCAlarm2TimeSet(unsigned int baseAddr, unsigned int alarmTime); extern void RTCAlarm2CalendarSet(unsigned int baseAddr, unsigned int calVal); extern unsigned int RTCAlarm2IntStatusGet(unsigned int baseAdd); /***************************************************************************** ** Prototypes of Miscellaneous and related functions *****************************************************************************/ /* Function which helps determine the SoC(Platform) in use. */ extern unsigned int RtcVersionGet(void); typedef struct { unsigned short RTC_Year; unsigned short RTC_Month; unsigned short RTC_Day; unsigned short RTC_Hour; unsigned short RTC_Minute; unsigned short RTC_Second; unsigned long RTC_Count; unsigned long RTC_Trace; unsigned long RTC_Error; unsigned int RTC_100ms; }RTC_Time_s; extern RTC_Time_s RTC_Time; void RTC_ISR_Fun(void); void Init_RTC(void); void configWakeRTC(void); void enableRTCAlarmWake(void); void disableRTCAlarm(void); void Read_RTC(void); void Write_RTC(unsigned short *data); long Compare_RTC(unsigned short *Now,unsigned short *Comp); void check_Feb(unsigned short Year,unsigned short *Feb); unsigned short week_cnt(unsigned short *Input); unsigned short get_week_month_cnt(unsigned short *Input,unsigned short Week_Flag); unsigned long Get_Day(unsigned long year,unsigned long month,unsigned long day); unsigned long Get_Month(unsigned long year,unsigned long month); typedef struct { unsigned long Total; unsigned long Process; unsigned char Type; unsigned char Name[20]; unsigned char Percent; }TestAP_Mass_Device_s; typedef struct { unsigned long Word_Count; unsigned long Serial_Num; unsigned long Length; unsigned long Store_Addr; unsigned long Clean_Flag_Addr; unsigned long Start_Word; unsigned short Title; unsigned short Devic_Count; unsigned short Reply_Flag; long Wait_Timer; unsigned short Resend_Cnt; TestAP_Mass_Device_s Device[3]; unsigned char Run_Flag; unsigned char Cancel_Flag; }TestAP_Mass_s; extern TestAP_Mass_s TestAP_Mass; extern unsigned char Product_Tittle_Check; void TestAP_Init(void); void Test_Tx(unsigned char *data,unsigned short cnt); unsigned short Check_MCU_Title(unsigned char *data,unsigned long lth); void Update_Setup_List_Init(void); void Update_Setup_List_Set(unsigned char *info,unsigned short value); int Update_Process_Percent(unsigned char *info); void Update_Cancel(unsigned int value); void Normal_Code_Update_End(void); unsigned long DSP_Encode(unsigned short *Data,unsigned long Length,unsigned short *Out); unsigned short DSP_Decode(unsigned short *f_data, unsigned int f_length); typedef enum { TESTMUM_NONE=0, TESTNUM_TTLIN, TESTNUM_TTLOUT, TESTMUM_DDR3RAM_N, TESTMUM_DDR3RAM_S, TESTNUM_USB_N, TESTNUM_NANDFLASH_N, TESTNUM_NANDFLASH_S, TESTNUM_I2C_N, TESTNUM_I2C_S, TESTNUM_PBC_VER, TESTNUM_P_S_LED, TESTNUM_FLASH_LED, TESTNUM_RS485_N, TESTNUM_RS485_S, TESTNUM_POWER_SRC_DETECT, TESTNUM_READ_BOOT_STATE, TESTNUM_CLEAR_BOOT_STATE, TESTNUM_RTC, TESTNUM_MIC_BYPASS, TESTMUM_END }Test_Num_s; typedef struct { unsigned long Timer; unsigned long Time_Record; unsigned long Test_Times; unsigned long Test_Er; unsigned long NMI_Count; unsigned long FPGA_Boot_Count; Test_Num_s TestNum; unsigned short Test_Mode; unsigned short Step; unsigned short LED; unsigned short ReplySize; unsigned short Result; unsigned short Buff[65536]; char Reply[256]; }Test_Info_s; extern Test_Info_s Test_Info; void Test_Fun_Init(void); void Test_Polling(void); unsigned short Test_Fun(Test_Num_s num,unsigned short step); void Test_Mode_Entry(void); void Test_Mode_Exit(void); /*****************************************************************************/ /* STDIO.H v15.4.0I15142 */ /* */ /* Copyright (c) 1993-2015 Texas Instruments Incorporated */ /* http://www.ti.com/ */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* */ /* Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in */ /* the documentation and/or other materials provided with the */ /* distribution. */ /* */ /* Neither the name of Texas Instruments Incorporated nor the names */ /* of its contributors may be used to endorse or promote products */ /* derived from this software without specific prior written */ /* permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /*****************************************************************************/ /*****************************************************************************/ /* stdlib.h v15.4.0I15142 */ /* */ /* Copyright (c) 1993-2015 Texas Instruments Incorporated */ /* http://www.ti.com/ */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* */ /* Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in */ /* the documentation and/or other materials provided with the */ /* distribution. */ /* */ /* Neither the name of Texas Instruments Incorporated nor the names */ /* of its contributors may be used to endorse or promote products */ /* derived from this software without specific prior written */ /* permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /*****************************************************************************/ #pragma diag_push #pragma CHECK_MISRA("-6.3") /* standard types required for standard headers */ #pragma CHECK_MISRA("-8.5") /* need to define inline function */ #pragma CHECK_MISRA("-19.1") /* #includes required for implementation */ /*---------------------------------------------------------------------------*/ /* Attributes are only available in relaxed ANSI mode. */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* A header file conforming to ARM CLIB ABI (GENC-003539), should */ /* define _AEABI_PORTABLE when _AEABI_PORTABILITY_LEVEL is defined. */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* The macro definition that guards CLIB ABI (GENC-003539) requirements. */ /*---------------------------------------------------------------------------*/ #pragma diag_push #pragma CHECK_MISRA("-5.7") /* keep names intact */ typedef struct { int quot, rem; } div_t; typedef struct { int quot, rem; } ldiv_t; typedef struct { long long quot, rem; } lldiv_t; #pragma diag_pop typedef unsigned short wchar_t; /*---------------------------------------------------------------*/ /* NOTE - Normally, abs, labs, and fabs are expanded inline, so */ /* no formal definition is really required. However, ANSI */ /* requires that they exist as separate functions, so */ /* they are supplied in the library. The prototype is */ /* here mainly for documentation. */ /*---------------------------------------------------------------*/ #pragma diag_push #pragma CHECK_MISRA("-16.4") /* false positives due to builtin declarations */ int abs(int _val); long labs(long _val); long long llabs(long long _val); #pragma diag_pop int atoi(const char *_st); long atol(const char *_st); long long atoll(const char *_st); int ltoa(long val, char *buffer); extern double atof(const char *_st); long strtol(const char *_st, char **_endptr, int _base); unsigned long strtoul(const char *_st, char **_endptr, int _base); long long strtoll(const char *_st, char **_endptr, int _base); unsigned long long strtoull(const char *_st, char **_endptr, int _base); float strtof(const char *_st, char **_endptr); double strtod(const char *_st, char **_endptr); long double strtold(const char *_st, char **_endptr); int rand(void); void srand(unsigned _seed); void *calloc(size_t _num, size_t _size) __attribute__((malloc)); void *malloc(size_t _size) __attribute__((malloc)); void *realloc(void *_ptr, size_t _size) __attribute__((malloc)); void free(void *_ptr); void *memalign(size_t _aln, size_t _size) __attribute__((malloc)); void abort(void); typedef void (*__TI_atexit_fn)(void); int atexit(__TI_atexit_fn _func); typedef int (*__TI_compar_fn)(const void *_a,const void *_b); void *bsearch(const void *_key, const void *_base, size_t _nmemb, size_t _size, __TI_compar_fn compar); void qsort(void *_base, size_t _nmemb, size_t _size, __TI_compar_fn compar); void exit(int _status); div_t div(int _numer, int _denom); ldiv_t ldiv(long _numer, long _denom); lldiv_t lldiv(long long _numer, long long _denom); char *getenv(const char *_string); int system(const char *_name); int mblen(const char *_s, size_t _n); size_t mbstowcs(wchar_t *_dest, const char *_src, size_t _n); int mbtowc(wchar_t *_dest, const char *_src, size_t _n); size_t wcstombs(char *_dest, const wchar_t *_src, size_t _n); int wctomb(char *_s, wchar_t _wc); #pragma diag_pop #pragma diag_push /* using declarations must occur outside header guard to support including both C and C++-wrapped version of header; see _CPP_STYLE_HEADER check */ /* this code is for C++ mode only and thus also not relevant for MISRA */ #pragma CHECK_MISRA("-19.15") #pragma diag_pop #pragma diag_push /* C2000-specific additions to header implemented with #include */ #pragma CHECK_MISRA("-19.1") #pragma CHECK_MISRA("-19.15") #pragma diag_pop /*****************************************************************************/ /* string.h v15.4.0I15142 */ /* */ /* Copyright (c) 1993-2015 Texas Instruments Incorporated */ /* http://www.ti.com/ */ /* */ /* Redistribution and use in source and binary forms, with or without */ /* modification, are permitted provided that the following conditions */ /* are met: */ /* */ /* Redistributions of source code must retain the above copyright */ /* notice, this list of conditions and the following disclaimer. */ /* */ /* Redistributions in binary form must reproduce the above copyright */ /* notice, this list of conditions and the following disclaimer in */ /* the documentation and/or other materials provided with the */ /* distribution. */ /* */ /* Neither the name of Texas Instruments Incorporated nor the names */ /* of its contributors may be used to endorse or promote products */ /* derived from this software without specific prior written */ /* permission. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* */ /*****************************************************************************/ #pragma diag_push #pragma CHECK_MISRA("-6.3") /* standard types required for standard headers */ #pragma CHECK_MISRA("-19.1") /* #includes required for implementation */ #pragma diag_push #pragma CHECK_MISRA("-19.4") /* macros required for implementation */ #pragma diag_pop size_t strlen(const char *string); char *strcpy(char *dest, const char *src); char *strncpy(char *dest, const char *src, size_t n); char *strcat(char *string1, const char *string2); char *strncat(char *dest, const char *src, size_t n); char *strchr(const char *string, int c); char *strrchr(const char *string, int c); int strcmp(const char *string1, const char *string2); int strncmp(const char *string1, const char *string2, size_t n); int strcoll(const char *string1, const char *_string2); size_t strxfrm(char *to, const char *from, size_t n); char *strpbrk(const char *string, const char *chs); size_t strspn(const char *string, const char *chs); size_t strcspn(const char *string, const char *chs); char *strstr(const char *string1, const char *string2); char *strtok(char *str1, const char *str2); char *strerror(int _errno); char *strdup(const char *string); void *memmove(void *s1, const void *s2, size_t n); #pragma diag_push #pragma CHECK_MISRA("-16.4") /* false positives due to builtin declarations */ void *memcpy(void *s1, const void *s2, size_t n); #pragma diag_pop int memcmp(const void *cs, const void *ct, size_t n); void *memchr(const void *cs, int c, size_t n); void *memset(void *mem, int ch, size_t length); #pragma diag_pop #pragma diag_push /* using declarations must occur outside header guard to support including both C and C++-wrapped version of header; see _CPP_STYLE_HEADER check */ /* this code is for C++ mode only and thus also not relevant for MISRA */ #pragma CHECK_MISRA("-19.15") #pragma diag_pop unsigned long NMI_Timer=0; unsigned long Reset_Timer=0; unsigned long Reset_Wait_Timer=0; unsigned long NMI_Buff[600]; unsigned short NMI_DSP_Mute=0; unsigned short Exception_Flag=0; unsigned long Softreset_Flag=0; extern float Level_Spk; extern unsigned short specila_restart_times; void NMIIsr(void) { //unsigned long i; (*((volatile unsigned int *)((0x4804C000) + (0x13C)))) |= 0x00004000; if(NMI_Timer>100) { NMI_Buff[0]=Test_Info.NMI_Count; NMI_Buff[1]=Softreset_Flag; NMI_Buff[2]=RTC_Time.RTC_Year; NMI_Buff[3]=RTC_Time.RTC_Month; NMI_Buff[4]=RTC_Time.RTC_Day; NMI_Buff[5]=RTC_Time.RTC_Hour; NMI_Buff[6]=RTC_Time.RTC_Minute; NMI_Buff[7]=RTC_Time.RTC_Second; NMI_Buff[8]=Test_Info.FPGA_Boot_Count; Get_Log_Remain_Data((unsigned char*)&NMI_Buff[10]); Write_Flash(0x1F60000,(unsigned short *)NMI_Buff,sizeof(NMI_Buff)/2); Level_Spk = 0; } NMI_Timer=0; } void NMI_Init(void) { Register_timer_flag(&NMI_Timer, 1, 1); Register_timer_flag(&Reset_Timer, 1, 1); NMI_Timer=1000; Reset_Timer=1000; IntPrioritySet((7), 10, (0)); //IntRegister(SYS_INT_NMI, NMIIsr); //IntSystemEnable(SYS_INT_NMI); CSP_IntVectReg((7), (CPU_FNCT_PTR)NMIIsr); CSP_IntEn((7)); } void NMI_Save_Init(void) { Read_Flash(0x1F60000,(unsigned short *)NMI_Buff,sizeof(NMI_Buff)/2); Test_Info.NMI_Count=NMI_Buff[0]+1; RTC_Time.RTC_Year=NMI_Buff[2]; RTC_Time.RTC_Month=NMI_Buff[3]; RTC_Time.RTC_Day=NMI_Buff[4]; RTC_Time.RTC_Hour=NMI_Buff[5]; RTC_Time.RTC_Minute=NMI_Buff[6]; RTC_Time.RTC_Second=NMI_Buff[7]; Test_Info.FPGA_Boot_Count=NMI_Buff[8]; Set_Log_Remain_Data((unsigned char*)&NMI_Buff[10]); if(NMI_Buff[1]==0) Log_add(LOG_INFORMATIONAL,"POWER OFF"); else if(NMI_Buff[1]==1) Log_add(LOG_INFORMATIONAL,"SoftReset"); Erase_Flash(0x1F60000/NAND_BLOCKSIZE_128KB,1); } void NMI_Recovery(void) { char log[50]; if(NMI_Timer<100 && NMI_Timer>10) { sprintf(log,"NMI Recovery From:%04d/%02d/%02d %02d/%02d/%02d",NMI_Buff[2],NMI_Buff[3],NMI_Buff[4],NMI_Buff[5],NMI_Buff[6],NMI_Buff[7]); Log_add(LOG_WARNING,log); Softreset_Flag=0; Erase_Flash(0x1F60000/NAND_BLOCKSIZE_128KB,1); Level_Spk = 1; NMI_Timer=1000; } if(Reset_Timer<100 && Reset_Timer>50) Reset_Machine(0); } void Reset_Machine_Register(void) { Reset_Timer=0; } void Reset_Machine(unsigned long f_wait_flag) { OS_ERR err; while(Log_Save()); if(f_wait_flag) { OSTimeDlyHMSM(0,0,0,200,((OS_OPT)0x00u),&err); Log_add(LOG_INFORMATIONAL, "Reboot Machine"); Register_timer_flag(&Reset_Wait_Timer, 1, 1); Reset_Wait_Timer = 0; while(1) { if(Reset_Wait_Timer >= f_wait_flag) break; } } DSP_Factory_Table_Save_Back_Polling(1); Softreset_Flag=1; NMIIsr(); (*((volatile unsigned int *)(((0x44E00000) + 0xF00))))=2; while(1); } asm("EXCEP_STK_SIZE .equ 68"); asm(" .ref __STACK_END"); asm("_stackptr:"); asm(" .word __STACK_END"); asm("_exception_stk:"); asm(" .space (EXCEP_STK_SIZE)"); asm("_exception_stk_"); asm(" .word _exception_stk"); extern unsigned long _exception_stk[]; void Exception_Log(void) { unsigned short i; char log[150]; sprintf(log,"Exception: PC:%08X LR:%08X SP:%08X CPSR:%08X",_exception_stk[16],_exception_stk[15],_exception_stk[14],_exception_stk[0]); Log_add(LOG_INFORMATIONAL,log); sprintf(log,"R "); for(i=0;i<13;i++) sprintf(&log[2+i*9],"%08X ",_exception_stk[1+i]); Log_add(LOG_INFORMATIONAL,log); } void Exception_Reset_Machine(void) { if((System_Flag_Table[0x36]>>8) == (System_Flag_Table[0x35]>>8)) System_Flag_Table[0x36]++; else System_Flag_Table[0x36] = 1; System_Flag_Table[0x36] |= (RTC_Time.RTC_Hour<<8); Save_System_Table(); // if(Exception_Flag==1) { Softreset_Flag=0xFFFFFFFF; while(Log_Save()); NMIIsr(); } (*((volatile unsigned int *)(((0x44E00000) + 0xF00))))=2; while(1); } void Exception_Fun(void) { asm(" SUB LR, LR, #8"); asm(" STMFD SP!, {R0-R3}"); asm(" MRS R1, SPSR"); asm(" MOV R2, LR"); asm(" MOV R3, SP"); asm(" MSR CPSR_c, #0x93"); asm(" DSB"); asm(" MOV R0, SP"); asm(" LDR SP, _exception_stk_"); asm(" ADD SP, SP, #EXCEP_STK_SIZE"); asm(" STMFD SP!, {R2}"); //Push task's PC, asm(" STMFD SP!, {LR}"); //Push task's LR, asm(" STMFD SP!, {R0}"); //Push task's SP, asm(" STMFD SP!, {R4-R12}"); //Push task's R12-R4, asm(" LDMFD R3!, {R5-R8}"); //Move task's R3-R0 from exception stack to task's stack. asm(" STMFD SP!, {R5-R8}"); asm(" STMFD SP!, {R1}"); asm(" LDR SP, _stackptr"); if(RTC_Time.RTC_Trace) { RTC_Time.RTC_Trace=0; RTC_Time.RTC_Error=1; asm(" LDR R0, _exception_stk_"); asm(" ADD R0, R0, #20"); asm(" LDMFD R0!, {R4-R12}"); //還原R4-R12 asm(" LDMFD R0!, {SP}"); //還原SP asm(" LDMFD R0!, {R1-R2}"); //讀出PC,LR放到SP asm(" ADD R2, R2, #24"); asm(" STMFD SP!, {R1-R2}"); asm(" LDR R0, _exception_stk_"); asm(" LDMFD R0!, {R1}"); //讀出CPSR放到R1 asm(" LDMFD R0!, {R2-R3}"); //讀出R0,R1放到SP asm(" STMFD SP!, {R2-R3}"); asm(" LDMFD R0!, {R2-R3}"); //讀出R2,R3放到SP asm(" STMFD SP!, {R2-R3}"); asm(" LDMFD SP!, {R2, R3}"); asm(" MSR SPSR_cxsf, R1"); asm(" LDMFD SP!, {R0, R1, LR, PC}^"); } Exception_Flag++; if(Exception_Flag==1) Exception_Log(); Exception_Reset_Machine(); } void Exception_Init(void) { (*(CPU_INT32U *)0x4030FC24)=(CPU_INT32U)Exception_Fun; (*(CPU_INT32U *)0x4030FC28)=(CPU_INT32U)Exception_Fun; (*(CPU_INT32U *)0x4030FC2C)=(CPU_INT32U)Exception_Fun; } //===========================================================================// // Function : Abnormal_Restart_Check // Description : // Input Argv : N/A // Output Argv : N/A // Note : N/A //===========================================================================// unsigned short Abnormal_Restart_Check(void) { char log[50]; if((System_Flag_Table[0x36]&0x00FF) != (System_Flag_Table[0x35]&0x00FF)) // 次數不相同 { if((System_Flag_Table[0x36]>>8) == (System_Flag_Table[0x35]>>8)) // 同一小時內 { if((System_Flag_Table[0x36]&0x00FF) >= 10) { System_Flag_Table[0x35] = System_Flag_Table[0x36] = 0; Save_System_Table(); Log_add(LOG_INFORMATIONAL, "Function Protect"); MachineSet_Backup.Data=malloc(24*0x20000); memcpy(&MachineSet_Backup.Size,&Fun_Buff[2],4); MachineSet_Backup.Size+=6; MachineSet_Backup.Size=DSP_Encode(Fun_Buff,MachineSet_Backup.Size,(unsigned short*)&MachineSet_Backup.Data[0x20]); memset(MachineSet_Backup.Data, 0, 32); strcpy((char*)MachineSet_Backup.Data, "IP SPEAKER SYSTEM TITLE\0"); MachineSet_Backup.Size+=0x10; MachineSet_Backup.Size*=2; Delete_Function_Table(); Boot_Backup_MachineSet(); Initial_Function(); Set_All_Modify(); sprintf(log,"Abnormal restart over 6 times, clear all table"); Log_add(LOG_ERROR,log); return 1; } } else { System_Flag_Table[0x35] = System_Flag_Table[0x36] = 1; System_Flag_Table[0x35] |= (RTC_Time.RTC_Hour<<8); System_Flag_Table[0x36] |= (RTC_Time.RTC_Hour<<8); Save_System_Table(); } } if(System_Flag_Table[0x36] != System_Flag_Table[0x35]) { System_Flag_Table[0x35] = System_Flag_Table[0x36]; Save_System_Table(); } return 0; }