⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpu_core.lst

📁 stm32+ucos-ii
💻 LST
📖 第 1 页 / 共 5 页
字号:
    514          *                                   Time measured           Amount of time measured, in seconds
    515          *
    516          *                   See also 'cpu_core.h  FUNCTION PROTOTYPES  CPU_TS_TmrRd()  Note #2c1'.
    517          *
    518          *               (2) In case the CPU timestamp timer has lower precision than the 64-bit CPU timestamp;
    519          *                   its precision is extended via periodic updates by accumulating the deltas of the
    520          *                   timestamp timer count values into the higher-precision 64-bit CPU timestamp.
    521          *
    522          *               (3) After initialization, 'CPU_TS_64_Accum' & 'CPU_TS_64_TmrPrev' MUST ALWAYS
    523          *                   be accessed AND updated exclusively with interrupts disabled -- but NOT
    524          *                   with critical sections.
    525          *********************************************************************************************************
    526          */
    527          
    528          #if (CPU_CFG_TS_64_EN == DEF_ENABLED)
    529          CPU_TS64  CPU_TS_Get64 (void)
    530          {
    531              CPU_TS64    ts;
    532          #if (CPU_CFG_TS_TMR_SIZE <  CPU_WORD_SIZE_64)
    533              CPU_TS_TMR  tmr_cur;
    534              CPU_TS_TMR  tmr_delta;
    535              CPU_SR_ALLOC();
    536          #endif
    537          
    538          
    539          #if (CPU_CFG_TS_TMR_SIZE >= CPU_WORD_SIZE_64)
    540              ts = (CPU_TS64)CPU_TS_TmrRd();                                  /* Get cur ts tmr val (in 64-bit ts cnts).          */
    541          
    542          #else
    543              CPU_INT_DIS();
    544              tmr_cur            = (CPU_TS_TMR) CPU_TS_TmrRd();               /* Get cur ts tmr val (in ts tmr cnts).             */
    545              tmr_delta          = (CPU_TS_TMR)(tmr_cur - CPU_TS_64_TmrPrev); /* Calc      delta ts tmr cnts.                     */
    546              CPU_TS_64_Accum   += (CPU_TS64  ) tmr_delta;                    /* Inc ts by delta ts tmr cnts (see Note #2).       */
    547              CPU_TS_64_TmrPrev  = (CPU_TS_TMR) tmr_cur;                      /* Save cur ts tmr cnts for next update.            */
    548              ts                 = (CPU_TS64  ) CPU_TS_64_Accum;
    549              CPU_INT_EN();
    550          #endif
    551          
    552              return (ts);
    553          }
    554          #endif
    555          
    556          
    557          /*$PAGE*/
    558          /*
    559          *********************************************************************************************************
    560          *                                           CPU_TS_Update()
    561          *
    562          * Description : Update current CPU timestamp(s).
    563          *
    564          * Argument(s) : none.
    565          *
    566          * Return(s)   : none.
    567          *
    568          * Caller(s)   : Application/BSP periodic time handler (see Note #1).
    569          *
    570          *               This function is a CPU timestamp BSP function & SHOULD be called only by appropriate
    571          *               application/BSP function(s).
    572          *
    573          * Note(s)     : (1) (a) CPU timestamp(s) MUST be updated periodically by some application (or BSP) time
    574          *                       handler in order to (adequately) maintain CPU timestamp(s)' time.
    575          *
    576          *                   (b) CPU timestamp(s) MUST be updated more frequently than the CPU timestamp timer
    577          *                       overflows; otherwise, CPU timestamp(s) will lose time.
    578          *
    579          *                       See also 'cpu_core.h  FUNCTION PROTOTYPES  CPU_TS_TmrRd()  Note #2c2'.
    580          *********************************************************************************************************
    581          */
    582          
    583          #if (CPU_CFG_TS_EN == DEF_ENABLED)
    584          void  CPU_TS_Update (void)
    585          {
    586          #if ((CPU_CFG_TS_32_EN    == DEF_ENABLED)  && \
    587               (CPU_CFG_TS_TMR_SIZE <  CPU_WORD_SIZE_32))
    588             (void)CPU_TS_Get32();
    589          #endif
    590          
    591          #if ((CPU_CFG_TS_64_EN    == DEF_ENABLED)  && \
    592               (CPU_CFG_TS_TMR_SIZE <  CPU_WORD_SIZE_64))
    593             (void)CPU_TS_Get64();
    594          #endif
    595          }
    596          #endif
    597          
    598          
    599          /*$PAGE*/
    600          /*
    601          *********************************************************************************************************
    602          *                                         CPU_TS_TmrFreqGet()
    603          *
    604          * Description : Get CPU timestamp's timer frequency.
    605          *
    606          * Argument(s) : p_err       Pointer to variable that will receive the return error code from this function :
    607          *
    608          *                               CPU_ERR_NONE                    CPU timestamp's timer frequency successfully
    609          *                                                                   returned.
    610          *                               CPU_ERR_TS_FREQ_INVALID         CPU timestamp's timer frequency invalid &/or
    611          *                                                                   NOT yet configured.
    612          *
    613          * Return(s)   : CPU timestamp's timer frequency (in Hertz), if NO error(s).
    614          *
    615          *               0,                                          otherwise.
    616          *
    617          * Caller(s)   : Application.
    618          *
    619          *               This function is a CPU module application interface (API) function & MAY be called by
    620          *               application function(s).
    621          *
    622          * Note(s)     : none.
    623          *********************************************************************************************************
    624          */
    625          
    626          #if (CPU_CFG_TS_TMR_EN == DEF_ENABLED)
    627          CPU_TS_TMR_FREQ  CPU_TS_TmrFreqGet (CPU_ERR  *p_err)
    628          {
    629              CPU_TS_TMR_FREQ  freq_hz;
    630          
    631          
    632              if (p_err == (CPU_ERR *)0) {
    633                  CPU_SW_EXCEPTION(;);
    634              }
    635          
    636              freq_hz =  CPU_TS_TmrFreq_Hz;
    637             *p_err   = (freq_hz != 0u) ? CPU_ERR_NONE : CPU_ERR_TS_FREQ_INVALID;
    638          
    639              return (freq_hz);
    640          }
    641          #endif
    642          
    643          
    644          /*$PAGE*/
    645          /*
    646          *********************************************************************************************************
    647          *                                         CPU_TS_TmrFreqSet()
    648          *
    649          * Description : Set CPU timestamp's timer frequency.
    650          *
    651          * Argument(s) : freq_hz     Frequency (in Hertz) to set for CPU timestamp's timer.
    652          *
    653          * Return(s)   : none.
    654          *
    655          * Caller(s)   : CPU_TS_TmrInit(),
    656          *               Application/BSP initialization function(s).
    657          *
    658          *               This function is a CPU module BSP function & SHOULD be called only by appropriate
    659          *               application/BSP function(s) [see Note #1].
    660          *
    661          * Note(s)     : (1) (a) (1) CPU timestamp timer frequency is NOT required for internal CPU timestamp
    662          *                           operations but may OPTIONALLY be configured by CPU_TS_TmrInit() or other
    663          *                           application/BSP initialization functions.
    664          *
    665          *                       (2) CPU timestamp timer frequency MAY be used with optional CPU_TSxx_to_uSec()
    666          *                           to convert CPU timestamps from timer counts into microseconds.
    667          *
    668          *                           See also 'cpu_core.h  FUNCTION PROTOTYPES  CPU_TSxx_to_uSec()  Note #2a'.
    669          *
    670          *                   (b) CPU timestamp timer period SHOULD be less than the typical measured time but MUST
    671          *                       be less than the maximum measured time; otherwise, timer resolution inadequate to
    672          *                       measure desired times.
    673          *
    674          *                       See also 'cpu_core.h  FUNCTION PROTOTYPES  CPU_TSxx_to_uSec()  Note #2b'.
    675          *********************************************************************************************************
    676          */
    677          
    678          #if (CPU_CFG_TS_TMR_EN == DEF_ENABLED)
    679          void  CPU_TS_TmrFreqSet (CPU_TS_TMR_FREQ  freq_hz)
    680          {
    681              CPU_TS_TmrFreq_Hz = freq_hz;
    682          }
    683          #endif
    684          
    685          
    686          /*$PAGE*/
    687          /*
    688          *********************************************************************************************************
    689          *                                     CPU_IntDisMeasMaxCurReset()
    690          *
    691          * Description : Reset current maximum interrupts disabled time.
    692          *
    693          * Argument(s) : none.
    694          *
    695          * Return(s)   : Maximum interrupts disabled time (in CPU timestamp timer counts) before resetting.
    696          *
    697          *               See also 'cpu_core.h  FUNCTION PROTOTYPES  CPU_TS_TmrRd()      Note #2c'
    698          *                      & 'cpu_core.h  FUNCTION PROTOTYPES  CPU_TSxx_to_uSec()  Note #2'.
    699          *
    700          * Caller(s)   : Application.
    701          *
    702          *               This function is a CPU module application interface (API) function & MAY be called
    703          *               by application function(s).
    704          *
    705          * Note(s)     : (1) After initialization, 'CPU_IntDisMeasMaxCur_cnts' MUST ALWAYS be accessed
    706          *                   exclusively with interrupts disabled -- but NOT with critical sections.
    707          *********************************************************************************************************
    708          */
    709          
    710          #ifdef  CPU_CFG_INT_DIS_MEAS_EN
    711          CPU_TS_TMR  CPU_IntDisMeasMaxCurReset (void)
    712          {
    713              CPU_TS_TMR  time_max_cnts;
    714              CPU_SR_ALLOC();
    715          
    716          
    717              time_max_cnts             = CPU_IntDisMeasMaxCurGet();
    718              CPU_INT_DIS();
    719              CPU_IntDisMeasMaxCur_cnts = 0u;
    720              CPU_INT_EN();
    721          
    722              return (time_max_cnts);
    723          }
    724          #endif
    725          
    726          
    727          /*$PAGE*/
    728          /*
    729          *********************************************************************************************************
    730          *                                      CPU_IntDisMeasMaxCurGet()
    731          *
    732          * Description : Get current maximum interrupts disabled time.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -