?? target.c
字號:
GPIOPinWrite(BUZ_GPIO_PORT, BUZ_PIN, ~BUZ_PIN);
}
#endif
/*********************************************************************************************************
** Function name: buzOff
** Descriptions: Switch off the buzzer 關閉蜂鳴器
** Input parameters: None 無
** Output parameters: None 無
** Returned value: None 無
** Created by: Steven Zhou 周紹剛
** Created Date: 2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by: Ni Likao 倪力考
** Modified date: 2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if TARGET_BUZ_EN > 0
void buzOff (void)
{
GPIOPinWrite(BUZ_GPIO_PORT, BUZ_PIN, BUZ_PIN);
}
#endif
/*********************************************************************************************************
** Function name: buzToggle
**
** Descriptions: Toggle the buzzer 取反蜂鳴器
** Input parameters: None 無
** Output parameters: None 無
** Returned value: None 無
** Created by: Steven Zhou 周紹剛
** Created Date: 2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by: Ni Likao 倪力考
** Modified date: 2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if TARGET_BUZ_EN > 0
void buzToggle (void)
{
GPIOPinWrite(BUZ_GPIO_PORT, BUZ_PIN, ~GPIOPinRead(BUZ_GPIO_PORT, BUZ_PIN));
}
#endif
/*********************************************************************************************************
** Function name: keyInit
** Descriptions: Initialize the target board's keys,support up to 4 keys
** 初始化目標板的按鍵,最多支持4個
** Input parameters: None 無
** Output parameters: None 無
** Returned value: None 無
** Created by: Steven Zhou 周紹剛
** Created Date: 2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by: Ni Likao 倪力考
** Modified date: 2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if (TARGET_KEY1_EN > 0) || (TARGET_KEY2_EN > 0) || (TARGET_KEY3_EN > 0) || (TARGET_KEY4_EN > 0)
void keyInit (void)
{
#if TARGET_KEY1_EN > 0
SysCtlPeripheralEnable(KEY1_SYSCTL);
GPIODirModeSet(KEY1_GPIO_PORT, KEY1_PIN, GPIO_DIR_MODE_IN);
GPIOPadConfigSet(KEY1_GPIO_PORT, KEY1_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
#endif
#if TARGET_KEY2_EN > 0
SysCtlPeripheralEnable(KEY2_SYSCTL);
GPIODirModeSet(KEY2_GPIO_PORT, KEY2_PIN, GPIO_DIR_MODE_IN);
GPIOPadConfigSet(KEY2_GPIO_PORT, KEY2_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
#endif
#if TARGET_KEY3_EN > 0
SysCtlPeripheralEnable(KEY3_SYSCTL);
GPIODirModeSet(KEY3_GPIO_PORT, KEY3_PIN, GPIO_DIR_MODE_IN);
GPIOPadConfigSet(KEY3_GPIO_PORT, KEY3_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
#endif
#if TARGET_KEY4_EN > 0
SysCtlPeripheralEnable(KEY4_SYSCTL);
GPIODirModeSet(KEY4_GPIO_PORT, KEY4_PIN, GPIO_DIR_MODE_IN);
GPIOPadConfigSet(KEY4_GPIO_PORT, KEY4_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
#endif
}
#endif
/*********************************************************************************************************
** Function name: keyRead
** Descriptions: Read the status of the keys. 讀取按鍵的狀態
** Input parameters: None 無
** Output parameters: None 無
** Returned value: 8-bit unsigned char data. Bit0-bit3 stand for the status of Key1-Key4,
** bit4-Bit7 no meaning
** 8位無符號數,位0-位3表示Key1-Key4的狀態,位4-位7無意義
** Created by: Steven Zhou 周紹剛
** Created Date: 2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by: Ni Likao 倪力考
** Modified date: 2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if (TARGET_KEY1_EN > 0) || (TARGET_KEY2_EN > 0) || (TARGET_KEY3_EN > 0) || (TARGET_KEY4_EN > 0)
INT8U keyRead (void)
{
INT8U ucTemp;
ucTemp = 0xFF;
#if TARGET_KEY1_EN > 0
if (!GPIOPinRead(KEY1_GPIO_PORT, KEY1_PIN)) {
ucTemp &= 0xFE;
}
#endif
#if TARGET_KEY2_EN > 0
if (!GPIOPinRead(KEY2_GPIO_PORT, KEY2_PIN)) {
ucTemp &= 0xFD;
}
#endif
#if TARGET_KEY3_EN > 0
if (!GPIOPinRead(KEY3_GPIO_PORT, KEY3_PIN)) {
ucTemp &= 0xFB;
}
#endif
#if TARGET_KEY4_EN > 0
if (!GPIOPinRead(KEY4_GPIO_PORT, KEY4_PIN)) {
ucTemp &= 0xF7;
}
#endif
return(ucTemp);
}
#endif
/*********************************************************************************************************
** Function name: timer0AInit
** Descriptions: Initialize Timer0A to 32bit timeout 初始化定時器0A為32位超時
** Input parameters: Tick: Number of timeout tick 超時脈沖數
Prio: Interrupt priority 中斷優先級
** Output parameters: None 無
** Returned value: None 無
** Created by: Steven Zhou 周紹剛
** Created Date: 2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by: Ni Likao 倪力考
** Modified date: 2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if TARGET_TMR0A_EN > 0
void timer0AInit (INT32U ulTick, INT8U ucPrio)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER);
TimerLoadSet(TIMER0_BASE, TIMER_A, ulTick);
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
IntEnable(INT_TIMER0A);
IntPrioritySet(INT_TIMER0A, ucPrio);
TimerEnable(TIMER0_BASE, TIMER_A);
}
#endif
/*********************************************************************************************************
** Function name: timer0AISR
** Descriptions: Timeout interrupt handler of Timer0A 定時器0A超時中斷
** Input parameters: None 無
** Output parameters: None 無
** Returned value: None 無
** Created by: Steven Zhou 周紹剛
** Created Date: 2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by: Ni Likao 倪力考
** Modified date: 2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if TARGET_TMR0A_EN > 0
void timer0AISR (void)
{
/*
* Optional Code. If you don't call any uC/OS-II's functions & variables,
* this code can be cancelled.
* 選擇代碼,如果你沒有調用任何的uC/OS-II的函數和變量,可選擇不編譯這段代碼.
*/
#if 0
#if OS_CRITICAL_METHOD == 3
OS_CPU_SR cpu_sr;
#endif
OS_ENTER_CRITICAL();
OSIntNesting++;
OS_EXIT_CRITICAL();
#endif
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); /* Clear the interrupt flag. */
/*
* Add you initialization code here.
* 在這里加入你的初始化代碼。
*/
/*
* Optional Code. If you don't call any uC/OS-II's functions & variables, this code can be
* cancelled.選擇代碼,如果你沒有調用任何的uC/OS-II的函數和變量,可選擇不編譯這段代碼.
*/
#if 0
OSIntExit();
#endif
}
#endif
/*********************************************************************************************************
** Function name: tickInit
** Descriptions: Initialize uC/OS-II's tick source(system timer),
初始化uC/OS-II的時鐘源(系統定時器)
** Input parameters: None 無
** Output parameters: None 無
** Returned value: None 無
** Created by: Steven Zhou 周紹剛
** Created Date: 2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by: Ni Likao 倪力考
** Modified date: 2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
static void tickInit (void)
{
SysTickPeriodSet((INT32U)(SysCtlClockGet() / OS_TICKS_PER_SEC) -1 );
SysTickEnable();
SysTickIntEnable();
}
/*********************************************************************************************************
** Function name: tickISRHandler
** Descriptions: Timeout interrupt handler of system timer 系統定時器超時中斷
** Input parameters: None 無
** Output parameters: None 無
** Returned value: None 無
** Created by: Steven Zhou 周紹剛
** Created Date: 2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by: Ni Likao 倪力考
** Modified date: 2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void tickISRHandler (void)
{
#if OS_CRITICAL_METHOD == 3
OS_CPU_SR cpu_sr;
#endif
OS_ENTER_CRITICAL();
OSIntNesting++;
OS_EXIT_CRITICAL();
OSTimeTick(); /* Call uC/OS-II's OSTimeTick()*/
OSIntExit();
}
/*********************************************************************************************************
** Function name: targetInit
** Descriptions: Initialize the target board 初始化目標板
** Input parameters: None 無
** Output parameters: None 無
** Returned value: None 無
** Created by: Steven Zhou 周紹剛
** Created Date: 2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by: Ni Likao 倪力考
** Modified date: 2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void targetInit (void)
{
#if PLL_EN == 0 /* Not use PLL 不使用PLL */
SysCtlClockSet(CCLK_DIV | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | EXT_CLK);
/* System clock= */
/* EXT_CLK/CCLK_DIV */
/* 系統時鐘=EXT_CLK/CCLK_DIV */
#else /* Use PLL 使用PLL */
SysCtlClockSet(CCLK_DIV | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | EXT_CLK);
/* System clock=200MHz/CCLK_DIV*/
/* 系統時鐘=200MHz/CCLK_DIV */
#endif
tickInit(); /* Initialize the uC/OS-II tick*/
/* interrupt,using the Kernal's*/
/* timer */
/*
* Add you initialization code here.
* 在這里加入你的初始化代碼。
*/
#if (TARGET_LED1_EN>0) || (TARGET_LED2_EN>0) || (TARGET_LED3_EN>0) || (TARGET_LED4_EN>0)
ledInit(); /* 初始化LED的IO口 */
#endif
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -