📄 target.c
字号:
/****************************************Copyright (c)**************************************************
** Guangzhou ZHIYUAN electronics Co.,LTD.
**
** http://www.embedtools.com
**
**--------------File Info-------------------------------------------------------------------------------
** File Name: Target.c
** Last modified Date: 2007-01-18
** Last Version: 1.0
** Description: Initialization of the target board 目标板初始化
**
**------------------------------------------------------------------------------------------------------
** Created By: Steven Zhou 周绍刚
** Created date: 2007-01-18
** Version: 1.0
** Descriptions: The original version 初始版本
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Description:
**
********************************************************************************************************/
#include <includes.h>
/*********************************************************************************************************
** Function name: IntDisAll
**
** Descriptions: Disable all interrupts from the interrupt controller 关闭中断控制器的所有中断
**
** Input parameters: None 无
** Returned value: None 无
**
** Used global variables: None 无
** Calling modules: None 无
**
** Created by: Steven Zhou 周绍刚
** Created Date: 2007-01-18
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
__asm void IntDisAll(void)
{
CPSID I
}
/*********************************************************************************************************
** Function name: Led_Init
**
** Descriptions: Initialize the target board's leds,support up to 4 leds
** 初化目标板的LED,最多支持4个
**
** Input parameters: None 无
** Returned value: None 无
**
** Used global variables: None 无
** Calling modules: SysCtlPeripheralEnable,GPIODirModeSet
**
** Created by: Steven Zhou 周绍刚
** Created Date: 2007-01-18
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#if (TARGET_LED1_EN>0) || (TARGET_LED2_EN>0) || (TARGET_LED3_EN>0) || (TARGET_LED4_EN>0)
void Led_Init (void)
{
#if TARGET_LED1_EN > 0
SysCtlPeripheralEnable(LED1_SYSCTL);
GPIODirModeSet(LED1_GPIO_PORT, LED1_PIN, GPIO_DIR_MODE_OUT);
#endif
#if TARGET_LED2_EN > 0
SysCtlPeripheralEnable(LED2_SYSCTL);
GPIODirModeSet(LED2_GPIO_PORT, LED2_PIN, GPIO_DIR_MODE_OUT);
#endif
#if TARGET_LED3_EN > 0
SysCtlPeripheralEnable(LED3_SYSCTL);
GPIODirModeSet(LED3_GPIO_PORT, LED3_PIN, GPIO_DIR_MODE_OUT);
#endif
#if TARGET_LED4_EN > 0
SysCtlPeripheralEnable(LED4_SYSCTL);
GPIODirModeSet(LED4_GPIO_PORT, LED4_PIN, GPIO_DIR_MODE_OUT);
#endif
}
#endif
/*********************************************************************************************************
** Function name: Led_On
**
** 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,其他值无意义。
** Returned value: None 无
**
** Used global variables: None 无
** Calling modules: GPIOPinWrite
**
** Created by: Steven Zhou 周绍刚
** Created Date: 2007-01-18
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#if (TARGET_LED1_EN>0) || (TARGET_LED2_EN>0) || (TARGET_LED3_EN>0) || (TARGET_LED4_EN>0)
void Led_On (uint8 led)
{
switch (led)
{
case 1:
#if TARGET_LED1_EN > 0
GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, ~LED1_PIN);
#endif
break;
case 2:
#if TARGET_LED2_EN > 0
GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, ~LED2_PIN);
#endif
break;
case 3:
#if TARGET_LED3_EN > 0
GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, ~LED3_PIN);
#endif
break;
case 4:
#if TARGET_LED4_EN > 0
GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, ~LED4_PIN);
#endif
break;
case 0xFF:
#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:
break;
}
}
#endif
/*********************************************************************************************************
** Function name: Led_Off
**
** 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,其他值无意义。
** Returned value: None 无
**
** Used global variables: None 无
** Calling modules: GPIOPinWrite
**
** Created by: Steven Zhou 周绍刚
** Created Date: 2007-01-18
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#if (TARGET_LED1_EN>0) || (TARGET_LED2_EN>0) || (TARGET_LED3_EN>0) || (TARGET_LED4_EN>0)
void Led_Off (uint8 led)
{
switch (led)
{
case 1:
#if TARGET_LED1_EN > 0
GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, LED1_PIN);
#endif
break;
case 2:
#if TARGET_LED2_EN > 0
GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, LED2_PIN);
#endif
break;
case 3:
#if TARGET_LED3_EN > 0
GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, LED3_PIN);
#endif
break;
case 4:
#if TARGET_LED4_EN > 0
GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, LED4_PIN);
#endif
break;
case 0xFF:
#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:
break;
}
}
#endif
/*********************************************************************************************************
** Function name: Led_Toggle
**
** 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,其他值无意义。
** Returned value: None 无
**
** Used global variables: None 无
** Calling modules: GPIOPinWrite,GPIOPinRead
**
** Created by: Steven Zhou 周绍刚
** Created Date: 2007-01-18
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#if (TARGET_LED1_EN>0) || (TARGET_LED2_EN>0) || (TARGET_LED3_EN>0) || (TARGET_LED4_EN>0)
void Led_Toggle (uint8 led)
{
switch (led)
{
case 1:
#if TARGET_LED1_EN > 0
GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, ~GPIOPinRead(LED1_GPIO_PORT, LED1_PIN));
#endif
break;
case 2:
#if TARGET_LED2_EN > 0
GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, ~GPIOPinRead(LED2_GPIO_PORT, LED2_PIN));
#endif
break;
case 3:
#if TARGET_LED3_EN > 0
GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, ~GPIOPinRead(LED3_GPIO_PORT, LED3_PIN));
#endif
break;
case 4:
#if TARGET_LED4_EN > 0
GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, ~GPIOPinRead(LED4_GPIO_PORT, LED4_PIN));
#endif
break;
case 0xFF:
#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:
break;
}
}
#endif
/*********************************************************************************************************
** Function name: Buz_Init
**
** Descriptions: Initialize the target board's buzzer 初始化目标板的蜂鸣器
**
** Input parameters: None 无
** Returned value: None 无
**
** Used global variables: None 无
** Calling modules: SysCtlPeripheralEnable,GPIODirModeSet,Buz_Off
**
** Created by: Steven Zhou 周绍刚
** Created Date: 2007-01-18
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#if TARGET_BUZ_EN > 0
void Buz_Init (void)
{
SysCtlPeripheralEnable(BUZ_SYSCTL);
GPIODirModeSet(BUZ_GPIO_PORT, BUZ_PIN, GPIO_DIR_MODE_OUT);
Buz_Off();
}
#endif
/*********************************************************************************************************
** Function name: Buz_On
**
** Descriptions: Switch on the buzzer 打开蜂鸣器
**
** Input parameters: None 无
** Returned value: None 无
**
** Used global variables: None 无
** Calling modules: GPIOPinWrite
**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -