Пример #1
0
Файл: pit.c Проект: MorS25/amcfc
void pit_init(uint8 pitno,uint32 timeout)
{
    SIM_SCGC6|=SIM_SCGC6_PIT_MASK;              //使能PIT时钟
    PIT_MCR&=~(PIT_MCR_MDIS_MASK);              //调试模式下禁止
    PIT_MCR|=PIT_MCR_FRZ_MASK;                  //使能PIT模块时钟
    PIT_LDVAL(pitno)=timeout;                   //设置周期
    PIT_TCTRL(pitno)|=PIT_TCTRL_TEN_MASK;       //使能pit模块运行
    PIT_TCTRL(pitno)&=~(PIT_TCTRL_TIE_MASK);    //关pit中断
}
Пример #2
0
Файл: pit.c Проект: MorS25/amcfc
void disable_pit_interrupt(uint8 pitno)
{
    PIT_TCTRL(pitno)&=~(PIT_TCTRL_TIE_MASK);//关pit中断
    switch(pitno)
    {
        case 0:
            disable_irq(68);	              //关接收引脚的IRQ中断
            break;
        case 1:
            disable_irq(69);		      //关接收引脚的IRQ中断
            break;
        case 2:
            disable_irq(70);		      //关接收引脚的IRQ中断
            break;
        case 3:
            disable_irq(71);		      //关接收引脚的IRQ中断
            break;
    }
}
Пример #3
0
Файл: pit.c Проект: MorS25/amcfc
void enable_pit_interrupt(uint8 pitno)
{
    PIT_TCTRL(pitno)|=(PIT_TCTRL_TIE_MASK); //开pit中断
    switch(pitno)
    {
        case 0:
            enable_irq(68);			      //开接收引脚的IRQ中断
            break;
        case 1:
            enable_irq(69);			      //开接收引脚的IRQ中断
            break;
        case 2:
            enable_irq(70);			      //开接收引脚的IRQ中断
            break;
        case 3:
            enable_irq(71);			      //开接收引脚的IRQ中断
            break;
    }
}
Пример #4
0
/*************************************************************************
*                             野火嵌入式開發工作室
*
*  函數名稱:pit_init
*  功能說明:PITn定時中斷
*  參數說明:PITn        模塊號(PIT0~PIT3)
             cnt         延時時間(單位為bus時鐘周期)
*  函數返回:無
*  修改時間:2012-1-24
*  備    注:
*************************************************************************/
void pit_init(PITn pitn,u32 cnt)
{
    //PIT 用的是 Bus Clock 總線頻率
    //溢出計數 = 總線頻率 * 時間

    /* 開啟時鐘*/
    SIM_SCGC6       |=SIM_SCGC6_PIT_MASK;                             //使能PIT時鐘

    /* PIT模塊控制 PIT Module Control Register (PIT_MCR) */
    PIT_MCR         &=~(PIT_MCR_MDIS_MASK | PIT_MCR_FRZ_MASK );       //使能PIT定時器時鐘 ,調試模式下繼續運行

    /* 定時器加載值設置 Timer Load Value Register (PIT_LDVALn) */
    PIT_LDVAL(pitn)  =cnt;                                           //設置溢出中斷時間

    //定時時間到了後,TIF 置 1 。寫1的時候就會清0
    PIT_Flag_Clear(pitn);                                             //清中斷標志位

    /* 定時器控制寄存器 Timer Control Register (PIT_TCTRL0) */
    PIT_TCTRL(pitn) |=( PIT_TCTRL_TEN_MASK | PIT_TCTRL_TIE_MASK );    //使能 PITn定時器,並開PITn中斷

    enable_irq(pitn+68);			                                  //開接收引腳的IRQ中斷
}
Пример #5
0
Файл: pit.c Проект: pkaar/x-AHRS
/*******************************************************************************
 * void pit_init(uint32_t pit, uint32_t frq, uint32_t interrupt)
 *
 * Description:
 *  Initialize specified periodic interrupt timer (PIT) with specified
 *  repetition frequency.
 *
 * Parameters:
 *  pit             PIT channel to be initialized (PIT0, PIT1, PIT2, PIT3)
 *  frq             PIT repetition frequency in Hz
 *  interrupt       PIT interrupt generation (ENABLE_INT, DISABLE_INT)
 *
 * Return:
 *  none
 *
 * Example:
 *  pit_init(PIT0, 1000000, ENABLE_INT);
 *  Initialize PIT0 with a repetition frequency of 1000000 Hz. After the
 *  expiration of a period, PIT0 interrupt service routine calls PIT0 callback
 *  function.
 *
 * Notes:
 *  PIT module is clocked by bus clock.
 *
 * History:
 *  pka, 27/AUG/2014, removed automatic start of PIT module
 *  pka, 25/MAR/2014, initial code
*******************************************************************************/
void pit_init(uint32_t pit, uint32_t frq, uint32_t interrupt)
{
    /* Enable PIT module clock. */
    SIM_SCGC6 |= SIM_SCGC6_PIT_MASK;

    /* Enable PIT module. PIT_MCR[MDIS] bit MUST be enabled before any other
     * bit manipulation is done. */
    PIT_MCR &= ~PIT_MCR_MDIS_MASK;

    /* Set timer start value. The timer counts down until it reaches 0. When 0
     * is reached an interrupt will be generated. */
    PIT_LDVAL(pit) = PIT_CLK / frq - 1;

    /* Check if interrupts are enabled. */
    if (interrupt)
    {
        /* Enable timer interrupt. */
        PIT_TCTRL(pit) |= PIT_TCTRL_TIE_MASK;

        /* Enable PIT interrupt. */
        enable_int(INT_PIT);
    }
}
Пример #6
0
Файл: pit.c Проект: pkaar/x-AHRS
/*******************************************************************************
 * void pit_restart(uint32_t pit)
 *
 * Description:
 *  Restart specified periodic interrupt timer (PIT).
 *
 * Parameters:
 *  pit             PIT channel to be stopped
 *
 * Return:
 *  none
 *
 * Example:
 *  pit_restart(PIT0);
 *  Restart PIT0 module.
 *
 * Notes:
 *  Restart only PIT modules which have been properly initialized. Restarting a
 *  PIT module which has not been initialized may cause unexpected errors.
 *  Restarting a PIT module causes the timer value to be set to its default
 *  starting value.
 *
 * History:
 *  pka, 27/AUG/2014, initial code
*******************************************************************************/
void pit_restart(uint32_t pit)
{
    PIT_TCTRL(pit) &= ~PIT_TCTRL_TEN_MASK;
    PIT_TCTRL(pit) |= PIT_TCTRL_TEN_MASK;
}
Пример #7
0
Файл: pit.c Проект: pkaar/x-AHRS
/*******************************************************************************
 * void pit_stop(uint32_t pit)
 *
 * Description:
 *  Stop specified periodic interrupt timer (PIT).
 *
 * Parameters:
 *  pit             PIT channel to be stopped
 *
 * Return:
 *  none
 *
 * Example:
 *  pit_stop(PIT0);
 *  Stop PIT0 module.
 *
 * Notes:
 *  Stop only PIT modules which have been properly initialized. Stopping a PIT
 *  module which has not been initialized may cause unexpected errors.
 *
 * History:
 *  pka, 27/AUG/2014, initial code
*******************************************************************************/
void pit_stop(uint32_t pit)
{
    PIT_TCTRL(pit) &= ~PIT_TCTRL_TEN_MASK;
}
Пример #8
0
Файл: pit.c Проект: pkaar/x-AHRS
/*******************************************************************************
 * void pit_start(uint32_t pit)
 *
 * Description:
 *  Start specified periodic interrupt timer (PIT).
 *
 * Parameters:
 *  pit             PIT channel to be started
 *
 * Return:
 *  none
 *
 * Example:
 *  pit_start(PIT0);
 *  Start PIT0 module. After the expiration of a period, PIT0 interrupt service
 *  routine calls PIT0 callback function.
 *
 * Notes:
 *  Start only PIT modules which have been properly initialized. Starting a PIT
 *  module which has not been initialized may cause unexpected errors.
 *  Starting a PIT module which has been stopped earlier, causes the timer value
 *  to be set to its default starting value.
 *
 * History:
 *  pka, 27/AUG/2014, initial code
*******************************************************************************/
void pit_start(uint32_t pit)
{
    PIT_TCTRL(pit) |= PIT_TCTRL_TEN_MASK;
}