📄 bsp.c
字号:
default:
break;
}
}
/*
*********************************************************************************************************
* SevenSegment_Init()
*
* Description : This function is called from BSP_Init() and initializes the GPIO to use
* with the onboard 7 segment display.
*
* Arguments : none
*********************************************************************************************************
*/
static void SevenSegment_Init (void)
{
INT8U gppo_data;
INT8U set_data;
/* LED-control(set output mode) LOW-6bits */
gppo_data = get_value(PM5);
set_data = ((gppo_data & PIOF_MASK_PATTERN) | PIOF_PATTERN);
put_value(PM5, set_data);
/* LED-control(set output mode) HI-2bits */
gppo_data = get_value(PM3);
set_data = ((gppo_data & PIOD_MASK_PATTERN) | PIOD_PATTERN);
put_value(PM3, set_data);
}
/*
*********************************************************************************************************
* SevenSegment_Show()
*
* Description : This function displays one of the SEVSEG_PATTERN[]'s on the 7 segment display
*
* Arguments : none
*********************************************************************************************************
*/
void SevenSegment_Show (INT8U pattern)
{
INT8U gppo_data;
INT8U set_data;
gppo_data = get_value(PO3);
set_data = ((gppo_data & PIOD_MASK_PATTERN) | ((pattern & INPUT_PIOD_PATTERN) >> 3 ) );
put_value(PO3, set_data);
gppo_data = get_value(PO5);
set_data = ((gppo_data & PIOF_MASK_PATTERN) | (pattern & PIOF_PATTERN));
put_value(PO5, set_data);
}
/*
*********************************************************************************************************
* IRQ ISR HANDLER
*
* Description : This function is called by OS_CPU_IRQ_ISR() to determine the source of the interrupt
* and process it accordingly.
*
* Arguments : none
*********************************************************************************************************
*/
void OS_CPU_IRQ_ISR_Handler (void)
{
BSP_FNCT_PTR pfnct;
INT32U VecNum;
VecNum = get_wvalue(IRN); /* Get the interrupt source number */
pfnct = BSP_IRQ[VecNum]; /* Get the function pointer from the array */
if (pfnct != (BSP_FNCT_PTR)0) { /* Make sure we dont have a null pointer */
(*pfnct)(); /* Execute the ISR for the interrupting device */
}
}
/*
*********************************************************************************************************
* FIQ ISR HANDLER
*
* Description : This function is called by OS_CPU_FIQ_ISR() to determine the source of the interrupt
* and process it accordingly.
*
* Arguments : none
*********************************************************************************************************
*/
void OS_CPU_FIQ_ISR_Handler (void)
{
BSP_FNCT_PTR pfnct;
INT32U VecNum;
VecNum = get_wvalue(IRN); /* Get the interrupt source number */
pfnct = BSP_FIQ[VecNum]; /* Get the function pointer from the array */
if (pfnct != (BSP_FNCT_PTR)0) { /* Make sure we dont have a null pointer */
(*pfnct)(); /* Execute the ISR for the interrupting device */
}
}
/*
*********************************************************************************************************
* TICKER INITIALIZATION
*
* Description : This function is called to initialize uC/OS-II's tick source (typically a timer generating
* interrupts every 1 to 100 mS).
*
* Arguments : none
*********************************************************************************************************
*/
static void Tmr_TickInit (void)
{
/* Set the OS Tick Interrupt Handler */
BSP_Set_IRQ_Vector(INT_SYSTEM_TIMER, Tmr_TickISR_Handler);
set_wbit(ILC0, ILC0_ILR0 & ILC0_INT_LV1); /* Set the OS Tick interrupt to level 1 */
put_wvalue(TMEN, 0); /* Disable timer (write '0' in TMEN[0]) */
put_wvalue(TMOVF, 1); /* Clear overflow register (write '1' in TMOVF[0]) */
/* Write the timer reload value into TMRLR */
put_wvalue(TMRLR, (0xFFFF - (OSCCLK / (16 * OS_TICKS_PER_SEC))));
put_wvalue(TMEN, 1); /* Start the timer */
}
/*
*********************************************************************************************************
* TIMER #0 IRQ HANDLER
*
* Description : This function handles the timer interrupt that is used to generate TICKs for uC/OS-II.
*
* Arguments : none
*********************************************************************************************************
*/
void Tmr_TickISR_Handler (void)
{
put_wvalue(CILCL, 0x00); /* Clear the interrupt */
put_wvalue(TMOVF, 0x01); /* Clear TMOVF register (write '1' in TMOVF[0]) */
OSTimeTick(); /* Call uC/OS-II's OSTimeTick() */
}
/*
*********************************************************************************************************
* Interrupt Controller - Set IRQ Vector
*********************************************************************************************************
*/
void BSP_Set_IRQ_Vector (INT8U VecNum, BSP_FNCT_PTR BSP_IRQ_VEC)
{
if (VecNum < 32) {
BSP_IRQ[VecNum] = BSP_IRQ_VEC;
}
}
/*
*********************************************************************************************************
* Interrupt Controller - Set FIQ Vector
*********************************************************************************************************
*/
void BSP_Set_FIQ_Vector (INT8U VecNum, BSP_FNCT_PTR BSP_IRQ_VEC)
{
if (VecNum < 32) {
BSP_IRQ[VecNum] = BSP_IRQ_VEC;
}
}
/*
*********************************************************************************************************
* ISR code called when a spurious interrupt occurs
*
* Note: Check SpurousInt for interrupt source vector number
*********************************************************************************************************
*/
static void Normal_ISR_Dummy (void)
{
volatile INT32U VecNum;
VecNum = get_wvalue(IRN); /* Get the interrupt source number */
while (TRUE) {
;
}
}
/*
*********************************************************************************************************
* FIQ ISR code called when a spurious interrupt occurs
*
* Note: Check SpurousInt for interrupt source vector number
*********************************************************************************************************
*/
static void FAST_ISR_Dummy (void)
{
volatile INT32U VecNum;
VecNum = get_wvalue(IRN); /* Get the interrupt source number */
while (TRUE) {
;
}
}
/*
*********************************************************************************************************
* Disable Processor Wide Interrupts
*********************************************************************************************************
*/
void BSP_Dis_Int(void)
{
}
/*
*********************************************************************************************************
* Enable Processor Wide Interrupts
*********************************************************************************************************
*/
void BSP_En_Int(void)
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -