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

📄 timer.c

📁 motorola 针对coldfire 5275 评估板的Dbug bootloader源程序
💻 C
字号:
/*
 * File:        timer.c
 * Purpose:     routines for accessing integrated timer modules
 *
 * Notes:
 *
 * Modifications:
 *
 */

#include "src/include/dbug.h"
#include "src/dev/mpc5xx/timer.h"

/********************************************************************/

static mpc5xx_timer timer = {0, 0, 0, 0};

const uint8 TIMER_NETWORK = 1;

/********************************************************************/
uint32
timer_set_secs(uint8 channel, uint32 secs)
{
    uint32 ticks;
    int timer_clock;
    (void) channel;
    
    timer_clock = board_get_speed()/16;
    
    /*
     * Only allow 32-bits worth of Timer ticks before we time-out
     */
    if (secs > (uint32)(0xFFFFFFFF/timer_clock))
        return FALSE;   
    
    ticks = secs * timer_clock;
    timer.reference = ticks;
    
    /*
     * Restart the Time Base counter
     */
    mpc5xx_wr_tbl(0);
    
    return TRUE;
}

/********************************************************************/
uint32
timer_get_reference(uint8 channel)
{
    (void) channel;
    /*
     * Return value is FALSE if Timer has timed-out
     */
    return (mpc5xx_rd_tbl() < timer.reference);
}

/********************************************************************/

⌨️ 快捷键说明

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