📄 iar-
字号:
/****************************************Copyright (c)****************************************************
** Guangzhou ZHIYUAN electronics Co.,LTD.
**
** http://www.embedtools.com
**
**--------------File Info---------------------------------------------------------------------------------
** File Name: Target.c
** Last modified Date: 2007.12.12
** Last Version: v1.0
** Description: Initialization of the target board 目标板初始化
**
**--------------------------------------------------------------------------------------------------------
** Created By: Steven Zhou 周绍刚
** Created date: 2007.12.12
** Version: v1.0
** Descriptions: The original version 初始版本
**
**--------------------------------------------------------------------------------------------------------
** Modified by: Kang qinhua
** Modified date: 2008.01.02
** Version: v1.1
** Description: The second version 第二版
**
*********************************************************************************************************/
#include <includes.h>
/*********************************************************************************************************
** Function name: ledInit
** Descriptions: Initialize the target board's leds,support up to 4 leds
** 初始化目标板的LED,最多支持4个
** Input parameters: None 无
** Output parameters: None 无
** Returned value: None 无
** Created by: Steven Zhou 周绍刚
** Created Date: 2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if (TARGET_LED1_EN > 0) || (TARGET_LED2_EN > 0) || (TARGET_LED3_EN > 0) || (TARGET_LED4_EN > 0)
void ledInit (void)
{
#if TARGET_LED1_EN > 0
SysCtlPeripheralEnable(LED1_SYSCTL);
GPIODirModeSet(LED1_GPIO_PORT, LED1_PIN, GPIO_DIR_MODE_OUT);
GPIOPadConfigSet(LED1_GPIO_PORT, LED1_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
#endif
#if TARGET_LED2_EN > 0
SysCtlPeripheralEnable(LED2_SYSCTL);
GPIODirModeSet(LED2_GPIO_PORT, LED2_PIN, GPIO_DIR_MODE_OUT);
GPIOPadConfigSet(LED2_GPIO_PORT, LED2_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
#endif
#if TARGET_LED3_EN > 0
SysCtlPeripheralEnable(LED3_SYSCTL);
GPIODirModeSet(LED3_GPIO_PORT, LED3_PIN, GPIO_DIR_MODE_OUT);
GPIOPadConfigSet(LED3_GPIO_PORT, LED3_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
#endif
#if TARGET_LED4_EN > 0
SysCtlPeripheralEnable(LED4_SYSCTL);
GPIODirModeSet(LED4_GPIO_PORT, LED4_PIN, GPIO_DIR_MODE_OUT);
GPIOPadConfigSet(LED4_GPIO_PORT, LED4_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
#endif
}
#endif
/*********************************************************************************************************
** Function name: ledOn
** Descriptions: Switch on one or all of the LEDs 点亮其中一个或全部的LED
** Input parameters: led: The num.of led to be switched on, 1-4 for LED1-LED4,
** 0xFF for all leds, others no action
** led: 要点亮的LED的号码,1-4代表LED1-LED4,0xFF代表全部LED,其他值无意义。
** Output parameters: None 无
** Returned value: None 无
** Created by: Steven Zhou 周绍刚
** Created Date: 2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if (TARGET_LED1_EN > 0) || (TARGET_LED2_EN > 0) || (TARGET_LED3_EN > 0) || (TARGET_LED4_EN > 0)
void ledOn (INT8U ucLed)
{
switch (ucLed) {
case 1: /* Switch on Led1 打开Led1 */
#if TARGET_LED1_EN > 0
GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, ~LED1_PIN);
#endif
break;
case 2: /* Switch on Led2 打开Led2 */
#if TARGET_LED2_EN > 0
GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, ~LED2_PIN);
#endif
break;
case 3: /* Switch on Led3 打开Led3 */
#if TARGET_LED3_EN > 0
GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, ~LED3_PIN);
#endif
break;
case 4: /* Switch on Led4 打开Led4 */
#if TARGET_LED4_EN > 0
GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, ~LED4_PIN);
#endif
break;
case 0xFF: /* Switch on all 打开全部led */
#if TARGET_LED1_EN > 0
GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, ~LED1_PIN);
#endif
#if TARGET_LED2_EN > 0
GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, ~LED2_PIN);
#endif
#if TARGET_LED3_EN > 0
GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, ~LED3_PIN);
#endif
#if TARGET_LED4_EN > 0
GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, ~LED4_PIN);
#endif
break;
default: /* Default 默认 */
break;
}
}
#endif
/*********************************************************************************************************
** Function name: ledOff
** Descriptions: Switch off one or all of the LEDs 关闭其中一个或全部的LED
** Input parameters: led: The num.of led to be switched off, 1-4 for LED1-LED4,
** 0xFF for all leds, others no action
** led: 要关闭的LED的号码,1-4代表LED1-LED4,0xFF代表全部LED,其他值无意义。
** Output parameters: None 无
** Returned value: None 无
** Created by: Steven Zhou 周绍刚
** Created Date: 2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if (TARGET_LED1_EN > 0) || (TARGET_LED2_EN > 0) || (TARGET_LED3_EN > 0) || (TARGET_LED4_EN > 0)
void ledOff (INT8U ucLed)
{
switch (ucLed) {
case 1: /* Switch off Led1 关闭Led1 */
#if TARGET_LED1_EN > 0
GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, LED1_PIN);
#endif
break;
case 2: /* Switch off Led2 关闭Led2 */
#if TARGET_LED2_EN > 0
GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, LED2_PIN);
#endif
break;
case 3: /* Switch off Led3 关闭Led3 */
#if TARGET_LED3_EN > 0
GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, LED3_PIN);
#endif
break;
case 4: /* Switch off Led4 关闭Led4 */
#if TARGET_LED4_EN > 0
GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, LED4_PIN);
#endif
break;
case 0xFF: /* Switch off all 关闭全部led */
#if TARGET_LED1_EN > 0
GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, LED1_PIN);
#endif
#if TARGET_LED2_EN > 0
GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, LED2_PIN);
#endif
#if TARGET_LED3_EN > 0
GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, LED3_PIN);
#endif
#if TARGET_LED4_EN > 0
GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, LED4_PIN);
#endif
break;
default: /* Default 默认 */
break;
}
}
#endif
/*********************************************************************************************************
** Function name: ledToggle
** Descriptions: Toggle one or all of the LEDs 取反其中一个或全部的LED
** Input parameters: led: The num.of led to be toggled, 1-4 for LED1-LED4,
** 0xFF for all leds, others no action
** led: 要取反的LED的号码,1-4代表LED1-LED4,0xFF代表全部LED,其他值无意义。
** Output parameters: None 无
** Returned value: None 无
** Created by: Steven Zhou 周绍刚
** Created Date: 2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if (TARGET_LED1_EN > 0) || (TARGET_LED2_EN > 0) || (TARGET_LED3_EN > 0) || (TARGET_LED4_EN > 0)
void ledToggle (INT8U ucLed)
{
switch (ucLed) {
case 1: /* Toggle Led1 取反Led1 */
#if TARGET_LED1_EN > 0
GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, ~GPIOPinRead(LED1_GPIO_PORT, LED1_PIN));
#endif
break;
case 2: /* Toggle Led2 取反Led2 */
#if TARGET_LED2_EN > 0
GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, ~GPIOPinRead(LED2_GPIO_PORT, LED2_PIN));
#endif
break;
case 3: /* Toggle Led3 取反Led3 */
#if TARGET_LED3_EN > 0
GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, ~GPIOPinRead(LED3_GPIO_PORT, LED3_PIN));
#endif
break;
case 4: /* Toggle Led4 取反Led4 */
#if TARGET_LED4_EN > 0
GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, ~GPIOPinRead(LED4_GPIO_PORT, LED4_PIN));
#endif
break;
case 0xFF: /* Toggle all 取反全部led */
#if TARGET_LED1_EN > 0
GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, ~GPIOPinRead(LED1_GPIO_PORT, LED1_PIN));
#endif
#if TARGET_LED2_EN > 0
GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, ~GPIOPinRead(LED2_GPIO_PORT, LED2_PIN));
#endif
#if TARGET_LED3_EN > 0
GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, ~GPIOPinRead(LED3_GPIO_PORT, LED3_PIN));
#endif
#if TARGET_LED4_EN > 0
GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, ~GPIOPinRead(LED4_GPIO_PORT, LED4_PIN));
#endif
break;
default: /* Default 默认 */
break;
}
}
#endif
/*********************************************************************************************************
** Function name: buzInit
** Descriptions: Initialize the target board's buzzer 初始化目标板的蜂鸣器
** Input parameters: None 无
** Output parameters: None 无
** Returned value: None 无
** Created by: Steven Zhou 周绍刚
** Created Date: 2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if TARGET_BUZ_EN > 0
void buzInit (void)
{
SysCtlPeripheralEnable(BUZ_SYSCTL);
GPIODirModeSet(BUZ_GPIO_PORT, BUZ_PIN, GPIO_DIR_MODE_OUT);
GPIOPadConfigSet(BUZ_GPIO_PORT, BUZ_PIN,GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
buzOff();
}
#endif
/*********************************************************************************************************
** Function name: buzOn
** Descriptions: Switch on the buzzer 打开蜂鸣器
** Input parameters: None 无
** Output parameters: None 无
** Returned value: None 无
** Created by: Steven Zhou 周绍刚
** Created Date: 2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if TARGET_BUZ_EN > 0
void buzOn (void)
{
GPIOPinWrite(BUZ_GPIO_PORT, BUZ_PIN, ~BUZ_PIN);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -