📄 main.c
字号:
/******************** (C) COPYRIGHT 2010 Embest Info&Tech Co.,LTD. ************
* 文件名: main.c
* 作者 : Wuhan R&D Center, Embest
* 日期 : 01/18/2010
* 描述 : 主程序源文件.
*******************************************************************************
*******************************************************************************
* 历史:
* 01/18/2010 : V1.0 初始版本
*******************************************************************************/
/* Includes ------------------------------------------------------------------*/
/* LPC11xx 定义 */
#include "LPC11xx.h"
#include "timer32.h"
#include "gpio.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* 0 或 1 选择32-位定时器 */
#define TEST_TIMER_NUM 0
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
extern volatile uint32_t timer32_0_counter;
extern volatile uint32_t timer32_1_counter;
/**
* @函数名:main
* @描述:主函数
* @参数: 无
* @返回值:无
*/
int main (void) {
SystemInit();
/* TEST_TIMER_NUM是0或1对应着32位定时器0或1。*/
init_timer32(TEST_TIMER_NUM, TIME_INTERVAL);
enable_timer32(TEST_TIMER_NUM);
/* 使能AHB时钟到GPIO域。*/
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
/* 设置端口2的0位输出*/
GPIOSetDir( 2, 0, 1 );
/* 永远循环 */
while (1)
{
#if TEST_TIMER_NUM
/* 循环定时闪烁LED灯D4。*/
if ( (timer32_1_counter > 0) && (timer32_1_counter <= 50) )
{
GPIOSetValue( 2, 0, 0 );
}
if ( (timer32_1_counter > 50) && (timer32_1_counter <= 100) )
{
GPIOSetValue( 2, 0, 1 );
}
else if ( timer32_1_counter > 100 )
{
timer32_1_counter = 0;
}
#else
/* 循环定时闪烁LED灯D5。*/
if ( (timer32_0_counter > 0) && (timer32_0_counter <= 50) )
{
GPIOSetValue( 2, 0, 0 );
}
if ( (timer32_0_counter > 50) && (timer32_0_counter <= 100) )
{
GPIOSetValue( 2, 0, 1 );
}
else if ( timer32_0_counter > 100 )
{
timer32_0_counter = 0;
}
#endif
}
}
/**
* @}
*/
/**
* @}
*/
/************* (C) COPYRIGHT 2010 Wuhan R&D Center, Embest *****文件结束*******/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -