📄 bsp.c
字号:
/*
*********************************************************************************************************
* Atmel ATmega128
* Board Support Package
*
* (c) Copyright 2005, Micrium, Weston, FL
* All Rights Reserved
*
*
* File : BSP.C
* By : Jean J. Labrosse
*********************************************************************************************************
*/
#include <includes.h>
/*
*********************************************************************************************************
* PROTOTYPES
*********************************************************************************************************
*/
static void BSP_InitTickISR(void);
static void LED_Init(void);
/*
*********************************************************************************************************
* BSP INITIALIZATION
*
* Description : This function should be called by your application code before you make use of any of the
* functions found in this module.
*
* Arguments : none
*********************************************************************************************************
*/
void BSP_Init (void)
{
LED_Init();
BSP_InitTickISR();
}
/*
*********************************************************************************************************
* SETUP THE TICK RATE
*
* Note(s): 1) OCR0 = CPU_CLK_FREQ / (2 * Prescaler * OC_freq) - 1
* 2) The equation actually performs rounding by multiplying by 2, adding 1 and then divising by 2
* in integer math, this is equivalent to adding 0.5
*********************************************************************************************************
*/
static void BSP_InitTickISR (void)
{
INT32U num;
INT32U denom;
TCCR0 = 0x0E; /* Set TIMER0 prescaler to CTC Mode, CLK/256 */
TCNT0 = 0; /* Start TCNT at 0 for a new cycle */
num = (INT32U)CPU_CLK_FREQ;
denom = 2 * 256 * (INT32U)OS_TICKS_PER_SEC;
OCR0 = (INT8U)((2 * num / denom + 1) / 2 - 1);
TIFR |= 0x02; /* Clear TIMER0 compare Interrupt Flag */
TIMSK |= 0x02; /* Enable TIMER0 compare Interrupt */
}
/*
*********************************************************************************************************
* HANDLE THE TICK INTERRUPT
*
* Note(s): 1) No need to clear the interrupt source since we use output compare mode for Timer #0 and
* the interrupt is automatically cleard in hardware when the ISR runs.
*********************************************************************************************************
*/
void BSP_TickISR_Handler (void)
{
OSTimeTick();
}
/*
*********************************************************************************************************
* BSP INITIALIZATION
*
* Description : This function should be called by your application code before you make use of any of the
* functions found in this module.
*
* Arguments : none
*********************************************************************************************************
*/
static void LED_Init (void)
{
PORTE |= LED_WORK_STATE;
DDRE |= LED_WORK_STATE;
}
/*********************************************************************************************************
** End Of File
********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -