?? bsp.c.2007-06-08.08-03-02.6250
字號:
/*
*********************************************************************************************************
* LED ON
*
* Description : This function is used to control any or all the LEDs on the board.
*
* Arguments : led is the number of the LED to control
* 0 indicates that you want ALL the LEDs to be ON
* 1 turns ON user LED on the board
*
* Returns ; none
*********************************************************************************************************
*/
void LED_On (CPU_INT08U led)
{
switch (led) {
case 0:
case 1:
GPIOPinWrite(GPIO_PORTF_BASE, GPIOF_PWM0, 0);
break;
default:
break;
}
}
/*
*********************************************************************************************************
* LED OFF
*
* Description : This function is used to control any or all the LEDs on the board.
*
* Arguments : led is the number of the LED to turn OFF
* 0 indicates that you want ALL the LEDs to be OFF
* 1 turns OFF user LED on the board
*
* Returns ; none
*********************************************************************************************************
*/
void LED_Off (CPU_INT08U led)
{
switch (led) {
case 0:
case 1:
GPIOPinWrite(GPIO_PORTF_BASE, GPIOF_PWM0, 1);
break;
default:
break;
}
}
/*
*********************************************************************************************************
* LED TOGGLE
*
* Description : This function is used to toggle any or all the LEDs on the board.
*
* Arguments : led is the number of the LED to control
* 0 indicates that you want to toggle ALL the LEDs
* 1 toggles user LED on the board
*
* Returns ; none
*********************************************************************************************************
*/
void LED_Toggle (CPU_INT08U led)
{
CPU_INT32U pins;
switch (led) {
case 0:
case 1:
pins = GPIOPinRead(GPIO_PORTF_BASE, GPIOF_PWM0);
if ((pins & GPIOF_PWM0) == 0) {
GPIOPinWrite(GPIO_PORTF_BASE, GPIOF_PWM0, 1);
} else {
GPIOPinWrite(GPIO_PORTF_BASE, GPIOF_PWM0, 0);
}
break;
default:
break;
}
}
/*
******************************************************************************************************************************
******************************************************************************************************************************
* uC/Probe Plug-In for uC/OS-II Functions
******************************************************************************************************************************
******************************************************************************************************************************
*/
/*
******************************************************************************************************************************
******************************************************************************************************************************
* uC/Probe Plug-In for uC/OS-II Functions
******************************************************************************************************************************
******************************************************************************************************************************
*/
/*
*********************************************************************************************************
* INITIALIZE TIMER FOR uC/Probe Plug-In for uC/OS-II
*
* Description : This function is called to by uC/Probe Plug-In for uC/OS-II 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 (uC_PROBE_OS_PLUGIN > 0) && (OS_PROBE_HOOKS_EN == 1)
void OSProbe_TmrInit (void)
{
#if (OS_PROBE_TIMER_SEL == 0)
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER);
TimerPrescaleSet(TIMER0_BASE, TIMER_A, 0);
TimerEnable(TIMER0_BASE, TIMER_A);
#elif (OS_PROBE_TIMER_SEL == 1)
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
TimerConfigure(TIMER1_BASE, TIMER_CFG_32_BIT_PER);
TimerPrescaleSet(TIMER1_BASE, TIMER_A, 0);
TimerEnable(TIMER1_BASE, TIMER_A);
#elif (OS_PROBE_TIMER_SEL == 2)
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
TimerConfigure(TIMER2_BASE, TIMER_CFG_32_BIT_PER);
TimerPrescaleSet(TIMER2_BASE, TIMER_A, 0);
TimerEnable(TIMER2_BASE, TIMER_A);
#elif (OS_PROBE_TIMER_SEL == 3)
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3);
TimerConfigure(TIMER3_BASE, TIMER_CFG_32_BIT_PER);
TimerPrescaleSet(TIMER3_BASE, TIMER_A, 0);
TimerEnable(TIMER3_BASE, TIMER_A);
#endif
OSProbeTmrInited = DEF_TRUE;
}
#endif
/*
*********************************************************************************************************
* READ TIMER FOR uC/Probe Plug-In for uC/OS-II
*
* Description : This function is called to read the current counts of a 16 bit free running timer.
*
* Arguments : none
*
* Returns : The 16 or 32 bit count of the timer assuming the timer is an UP counter.
*********************************************************************************************************
*/
#if (uC_PROBE_OS_PLUGIN > 0) && (OS_PROBE_HOOKS_EN == 1)
CPU_INT32U OSProbe_TmrRd (void)
{
#if (OS_PROBE_TIMER_SEL == 0)
if (OSProbeTmrInited == DEF_TRUE) {
return (~(TimerValueGet(TIMER0_BASE, TIMER_BOTH)));
} else {
return (0);
}
#elif (OS_PROBE_TIMER_SEL == 1)
if (OSProbeTmrInited == DEF_TRUE) {
return (~(TimerValueGet(TIMER1_BASE, TIMER_BOTH)));
} else {
return (0);
}
#elif (OS_PROBE_TIMER_SEL == 2)
if (OSProbeTmrInited == DEF_TRUE) {
return (~(TimerValueGet(TIMER2_BASE, TIMER_BOTH)));
} else {
return (0);
}
#elif (OS_PROBE_TIMER_SEL == 3)
if (OSProbeTmrInited == DEF_TRUE) {
return (~(TimerValueGet(TIMER3_BASE, TIMER_A)));
} else {
return (0);
}
#endif
}
#endif
/*
******************************************************************************************************************************
******************************************************************************************************************************
** uC/OS-II Timer Functions
******************************************************************************************************************************
******************************************************************************************************************************
*/
/*
*********************************************************************************************************
* 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)
{
CPU_INT32U cnts;
cnts = (CPU_INT32U)SysCtlClockGet() / OS_TICKS_PER_SEC;
SysTickPeriodSet(cnts);
SysTickEnable();
SysTickIntEnable();
}
/*
*********************************************************************************************************
* TIMER 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)
{
OS_CPU_SR cpu_sr;
OS_ENTER_CRITICAL(); /* Tell uC/OS-II that we are starting an ISR */
OSIntNesting++;
OS_EXIT_CRITICAL();
OSTimeTick(); /* Call uC/OS-II's OSTimeTick() */
OSIntExit(); /* Tell uC/OS-II that we are leaving the ISR */
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -