📄 bsp_ram.c
字号:
** BSP_ERROR otherwise.
**
**---------------------------------------------------------------------------
*/
{
/*--- Write port ---*/
switch( PortNr )
{
case 0x00:
/*--- Port 0 ---*/
IO0CLR = (~Value & BitMask); /* Clear bits using CLEAR register */
IO0SET = (Value & BitMask); /* Set bits using SET register */
break;
case 0x01:
/*--- Port 1 ---*/
IO1CLR = (~Value & BitMask); /* Clear bits using CLEAR register */
IO1SET = (Value & BitMask); /* Set bits using SET register */
break;
case 0x02:
/*--- Port 2 ---*/
IO2CLR = (~Value & BitMask); /* Clear bits using CLEAR register */
IO2SET = (Value & BitMask); /* Set bits using SET register */
break;
case 0x03:
/*--- Port 3 ---*/
IO3CLR = (~Value & BitMask); /* Clear bits using CLEAR register */
IO3SET = (Value & BitMask); /* Set bits using SET register */
break;
default:
return BSP_ERROR;
}
return BSP_OK;
} /* BSP_WritePort_GPIO */
/*
*********************************************************************************************************
* GET 'PUSH BUTTON' STATUS
*
* Description : This function is used to get the status of any push button on the board.
*
* Arguments : push_button is the number of the push button to probe
* 1 probe the push button B1
* 2 probe the push button B2
*********************************************************************************************************
*/
BOOLEAN PB_GetStatus (INT8U push_button_id)
{
BOOLEAN status;
status = FALSE;
switch (push_button_id) {
case 1:
if ((IO0PIN & (1 << 15)) == 0) {
return (TRUE);
}
break;
case 2:
if ((IO0PIN & (1 << 16)) == 0) {
return (TRUE);
}
break;
default:
break;
}
return (status);
}
/*
*********************************************************************************************************
* 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_PFNCT pfnct;
pfnct = (BSP_PFNCT)VICVectAddr; /* Read the interrupt vector from the VIC */
while (pfnct != (BSP_PFNCT)0) { /* Make sure we don't have a NULL pointer */
(*pfnct)(); /* Execute the ISR for the interrupting device */
pfnct = (BSP_PFNCT)VICVectAddr; /* Read the interrupt vector from the VIC */
}
}
/*
*********************************************************************************************************
* 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_PFNCT pfnct;
pfnct = (BSP_PFNCT)VICVectAddr; /* Read the interrupt vector from the VIC */
while (pfnct != (BSP_PFNCT)0) { /* Make sure we don't have a NULL pointer */
(*pfnct)(); /* Execute the ISR for the interrupting device */
pfnct = (BSP_PFNCT)VICVectAddr; /* Read the interrupt vector from the VIC */
}
}
/*
*********************************************************************************************************
* INITIALIZE TIMER FOR uC/OS-View
*
* Description : This function is called to by uC/OS-View to initialize the free running timer that is
* used to make time measurements.
*
* Arguments : none
*
* Returns ; none
*
* Note(s) : This function is EMPTY because the timer is initialized elsewhere.
*********************************************************************************************************
*/
#if OS_VIEW_MODULE > 0
void OSView_TmrInit (void)
{
}
#endif
/*
*********************************************************************************************************
* READ TIMER FOR uC/OS-View
*
* Description : This function is called to read the current counts of a 32 bit free running timer.
*
* Timer #0 of the LPC2000 is used. This is an UP-timer.
*
* Arguments : none
*
* Returns ; The 32 bit counts of the timer assuming the timer (MUST be an UP counter).
*********************************************************************************************************
*/
#if OS_VIEW_MODULE > 0
INT32U OSView_TmrRd (void)
{
return ((INT32U)T0TC);
}
#endif
/*
*********************************************************************************************************
* 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
*
* Note(s) : 1) The timer is setup for output compare mode BUT 'MUST' also 'freerun' so that the timer
* count goes from 0x00000000 to 0xFFFFFFFF to ALSO be able to read the free running count.
* The reason this is needed is because we use the free-running count in uC/OS-View.
*********************************************************************************************************
*/
static void Tmr_TickInit (void)
{
INT32U peripheral_clk_freq;
VICIntSelect &= ~(1 << VIC_TIMER0); /* Enable interrupts */
VICVectAddr2 = (INT32U)Tmr_TickISR_Handler; /* Set the vector address */
VICVectCntl2 = 0x20 | VIC_TIMER0; /* Enable vectored interrupts */
VICIntEnable = (1 << VIC_TIMER0); /* Enable Interrupts */
peripheral_clk_freq = BSP_CPU_ClkFreqPeripheral();
Tmr_ReloadCnts = peripheral_clk_freq / OS_TICKS_PER_SEC;
T0TCR = 0; /* Disable timer 0. */
T0PC = 0; /* Prescaler is set to no division. */
T0MR0 = Tmr_ReloadCnts; /* Count up to this value. */
T0MCR = 3; /* Reset and interrupt on MR0 (match register 0). */
T0CCR = 0; /* Capture is disabled. */
T0EMR = 0; /* No external match output. */
T0TCR = 1; /* Enable timer 0 */
}
/*
*********************************************************************************************************
* TIMER #0 IRQ HANDLER
*
* Description : This function handles the timer interrupt that is used to generate TICKs for uC/OS-II.
*
* Arguments : none
*
* Note(s) : 1) The timer is 'reloaded' with the count at compare + the time for the next interrupt.
* Since we are using 'unsigned' integer math, overflows are irrelevant.
*********************************************************************************************************
*/
void Tmr_TickISR_Handler (void)
{
T0IR = 0xFF; /* Clear timer #0 interrupt */
/* Reload 'relative' to current interrupt time */
VICVectAddr = 0;
OSTimeTick(); /* Call uC/OS-II's OSTimeTick() */
}
/*
*********************************************************************************************************
* Vectored Interrupt Controller
*********************************************************************************************************
*/
static void VIC_Init (void)
{
VICIntEnClear = 0xFFFFFFFF; /* Disable ALL interrupts */
VICProtection = 0; /* Setup interrupt controller */
VICVectAddr1 = (INT32U)VIC_DummyWDT; /* Set the vector address */
VICVectAddr2 = (INT32U)VIC_DummyTIMER0;
VICVectAddr3 = (INT32U)VIC_DummyTIMER1;
VICVectAddr4 = (INT32U)VIC_DummyUART0;
VICVectAddr5 = (INT32U)VIC_DummyUART1;
VICVectAddr6 = (INT32U)VIC_DummySPI0;
VICVectAddr7 = (INT32U)VIC_DummyRTC;
VICVectAddr8 = (INT32U)VIC_DummyEINT0;
VICVectAddr9 = (INT32U)VIC_DummyEINT1;
VICVectAddr10 = (INT32U)VIC_DummyEINT2;
VICVectAddr11 = (INT32U)VIC_DummyEINT3;
}
static void VIC_Dummy (void)
{
while (1) {
(void)VIC_SpuriousInt;
}
}
static void VIC_DummyWDT (void)
{
VIC_SpuriousInt = VIC_WDT;
VIC_Dummy();
}
static void VIC_DummyTIMER0 (void)
{
VIC_SpuriousInt = VIC_TIMER0;
VIC_Dummy();
}
static void VIC_DummyTIMER1 (void)
{
VIC_SpuriousInt = VIC_TIMER1;
VIC_Dummy();
}
static void VIC_DummyUART0 (void)
{
VIC_SpuriousInt = VIC_UART0;
VIC_Dummy();
}
static void VIC_DummyUART1 (void)
{
VIC_SpuriousInt = VIC_UART1;
VIC_Dummy();
}
static void VIC_DummySPI0 (void)
{
VIC_SpuriousInt = VIC_SPI0;
VIC_Dummy();
}
static void VIC_DummyRTC (void)
{
VIC_SpuriousInt = VIC_RTC;
VIC_Dummy();
}
static void VIC_DummyEINT0 (void)
{
VIC_SpuriousInt = VIC_EINT0;
VIC_Dummy();
}
static void VIC_DummyEINT1 (void)
{
VIC_SpuriousInt = VIC_EINT1;
VIC_Dummy();
}
static void VIC_DummyEINT2 (void)
{
VIC_SpuriousInt = VIC_EINT2;
VIC_Dummy();
}
static void VIC_DummyEINT3 (void)
{
VIC_SpuriousInt = VIC_EINT3;
VIC_Dummy();
}
/*
*********************************************************************************************************
* END OF FILE
*********************************************************************************************************
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -