📄 cpu_core.h
字号:
/*
*********************************************************************************************************
* uC/CPU
* CPU CONFIGURATION & PORT LAYER
*
* (c) Copyright 2004-2010; 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.27
* Programmer(s) : SR
* ITJ
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* MODULE
*********************************************************************************************************
*/
#ifndef CPU_CORE_MODULE_PRESENT
#define CPU_CORE_MODULE_PRESENT
/*$PAGE*/
/*
*********************************************************************************************************
* CORE CPU MODULE VERSION NUMBER
*
* Note(s) : (1) (a) The core CPU 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
*********************************************************************************************************
*/
#define CPU_CORE_VERSION 127u /* See Note #1. */
/*
*********************************************************************************************************
* EXTERNS
*********************************************************************************************************
*/
#ifdef CPU_CORE_MODULE
#define CPU_CORE_EXT
#else
#define CPU_CORE_EXT extern
#endif
/*
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*/
#include <cpu.h>
#include <lib_def.h>
#include <cpu_cfg.h>
#include <lib_mem.h>
#include <lib_str.h>
/*$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'.
*********************************************************************************************************
*/
#ifdef CPU_CFG_TS_EN
#undef CPU_CFG_TS_EN
#endif
#if ((CPU_CFG_TS_32_EN == DEF_ENABLED) || \
(CPU_CFG_TS_64_EN == DEF_ENABLED))
#define CPU_CFG_TS_EN DEF_ENABLED
#else
#define CPU_CFG_TS_EN DEF_DISABLED
#endif
#if ((CPU_CFG_TS_EN == DEF_ENABLED) || \
(defined(CPU_CFG_INT_DIS_MEAS_EN)))
#define CPU_CFG_TS_TMR_EN DEF_ENABLED
#else
#define CPU_CFG_TS_TMR_EN DEF_DISABLED
#endif
/*
*********************************************************************************************************
* DEFINES
*********************************************************************************************************
*/
#define CPU_TIME_MEAS_NBR_MIN 1u
#define CPU_TIME_MEAS_NBR_MAX 128u
/*
*********************************************************************************************************
* CPU ERROR CODES
*********************************************************************************************************
*/
#define CPU_ERR_NONE 0u
#define CPU_ERR_NULL_PTR 10u
#define CPU_ERR_NAME_SIZE 1000u
#define CPU_ERR_TS_FREQ_INVALID 2000u
/*$PAGE*/
/*
*********************************************************************************************************
* DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* CPU ERROR CODES DATA TYPE
*********************************************************************************************************
*/
typedef CPU_INT16U 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. */
#if (CPU_CFG_TS_TMR_EN == DEF_ENABLED) /* CPU ts tmr defined to cfg'd word size (see Note #1). */
#if (CPU_CFG_TS_TMR_SIZE == CPU_WORD_SIZE_08)
typedef CPU_INT08U CPU_TS_TMR;
#elif (CPU_CFG_TS_TMR_SIZE == CPU_WORD_SIZE_16)
typedef CPU_INT16U CPU_TS_TMR;
#elif (CPU_CFG_TS_TMR_SIZE == CPU_WORD_SIZE_64)
typedef CPU_INT64U CPU_TS_TMR;
#else /* CPU ts tmr dflt size = 32-bits. */
typedef CPU_INT32U CPU_TS_TMR;
#endif
#endif
/*
*********************************************************************************************************
* CPU TIMESTAMP TIMER FREQUENCY DATA TYPE
*********************************************************************************************************
*/
typedef CPU_INT32U CPU_TS_TMR_FREQ;
/*
*********************************************************************************************************
* GLOBAL VARIABLES
*********************************************************************************************************
*/
#if (CPU_CFG_NAME_EN == DEF_ENABLED)
CPU_CORE_EXT CPU_CHAR CPU_Name[CPU_CFG_NAME_SIZE]; /* CPU host name. */
#endif
#if ((CPU_CFG_TS_32_EN == DEF_ENABLED) && \
(CPU_CFG_TS_TMR_SIZE < CPU_WORD_SIZE_32))
CPU_CORE_EXT CPU_TS32 CPU_TS_32_Accum; /* 32-bit accum'd ts (in ts tmr cnts). */
CPU_CORE_EXT CPU_TS_TMR CPU_TS_32_TmrPrev; /* 32-bit ts prev tmr (in ts tmr cnts). */
#endif
#if ((CPU_CFG_TS_64_EN == DEF_ENABLED) && \
(CPU_CFG_TS_TMR_SIZE < CPU_WORD_SIZE_64))
CPU_CORE_EXT CPU_TS64 CPU_TS_64_Accum; /* 64-bit accum'd ts (in ts tmr cnts). */
CPU_CORE_EXT CPU_TS_TMR CPU_TS_64_TmrPrev; /* 64-bit ts prev tmr (in ts tmr cnts). */
#endif
#if (CPU_CFG_TS_TMR_EN == DEF_ENABLED)
CPU_CORE_EXT CPU_TS_TMR_FREQ CPU_TS_TmrFreq_Hz; /* CPU ts tmr freq (in Hz). */
#endif
#ifdef CPU_CFG_INT_DIS_MEAS_EN
CPU_CORE_EXT CPU_INT16U CPU_IntDisMeasCtr; /* Nbr tot ints dis'd ctr. */
CPU_CORE_EXT CPU_INT16U CPU_IntDisNestCtr; /* Nbr nested ints dis'd ctr. */
/* Ints dis'd time (in ts tmr cnts) : ... */
CPU_CORE_EXT CPU_TS_TMR CPU_IntDisMeasStart_cnts; /* ... start time. */
CPU_CORE_EXT CPU_TS_TMR CPU_IntDisMeasStop_cnts; /* ... stop time. */
CPU_CORE_EXT CPU_TS_TMR CPU_IntDisMeasOvrhd_cnts; /* ... time meas ovrhd. */
CPU_CORE_EXT CPU_TS_TMR CPU_IntDisMeasMaxCur_cnts; /* ... resetable max time dis'd. */
CPU_CORE_EXT CPU_TS_TMR CPU_IntDisMeasMax_cnts; /* ... non-resetable max time dis'd. */
#endif
/*$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)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -