main.c
来自「基于MDK的LPC1100处理器开发应用例程」· C语言 代码 · 共 104 行
C
104 行
/******** (C) COPYRIGHT 2010 UP Team,Wuhan University of Technology. *********
* 文件名: main.c
* 作者 : UP Team,Wuhan University of Technology
* 日期 : 01/18/2010
* 描述 : 主程序源文件.
*******************************************************************************
*******************************************************************************
* 历史:
* 01/18/2010 : V1.0 初始版本
*******************************************************************************/
/* Includes ------------------------------------------------------------------*/
/* LPC11xx 定义 */
#include <stdio.h>
#include "LPC11xx.h"
#include "timer16.h"
#include "gpio.h"
#include "pmu.h"
#include "uart.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
extern volatile uint32_t timer16_0_counter;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/**
* @函数名:main
* @描述:主函数
* @参数: 无
* @返回值:无
*/
int main (void) {
uint32_t regVal;
uint32_t i;
SystemInit();
/* NVIC is installed inside UARTInit file. */
UARTInit(115200);
printf("\n\r-- Basic PMU Project V1.0 --\n\r");
printf("\n\r-- EM-LPC1100 --\n\r");
printf("\n\r-- PMU sleep or deep sleep mode test --\n\r");
printf("\n\r Press 'BOOT' to wakeup system! \n\r");
for (i = 0; i < 1000; i++);
#if !TEST_POWERDOWN
/* 在睡眠或者深度睡眠之前建立唤醒中断源。现在port0.1被配置成唤醒源,下降沿触发。*/
PMU_Init();
/* 把X/Y/Z设置进入睡眠模式。*/
/* 对于LPC11xx,USB_PLL和USB_PHY位不应该触碰,好比它们不存在于现在的芯片片中。依据配置
这些位都应该仔细地选择。*/
/* 请注意:LP_REGUL_PD和MAIN_REGUL_PD不应该每一次,不能再同一时刻设置为1。*/
regVal = SYS_PLL_PD|WDT_OSC_PD|ADC_PD|BOD_PD | (0x01 << 9) | (0x01 << 11);
PMU_Sleep( MCU_DEEP_SLEEP, regVal );
#else
/* 配置PMU_PCON让MCU进入深度低功耗模式,保留通用寄存器模式。在P1.4管脚上的低信号会
从深度低功耗模式唤醒模块。*/
PMU_PowerDown();
#endif
/* TEST_TIMER_NUM是0或1对应着16位定时器0或1。*/
init_timer16(0, TIME_INTERVAL);
enable_timer16(0);
/* 设置端口port 2_0...3的位输出*/
LPC_GPIO2->DIR |= (0x1<<0)|(0x1<<1)|(0x1<<2)|(0x1<<3);
while (1) /* Loop forever */
{
/* I/O配置和LED设置为等待。*/
if ( (timer16_0_counter > 0) && (timer16_0_counter <= 200) )
{
/* 点亮LED1...8 */
LPC_GPIO2->DATA &= ~((0x1<<0)|(0x1<<1)|(0x1<<2)|(0x1<<3));
}
if ( (timer16_0_counter > 200) && (timer16_0_counter <= 400) )
{
/* 置灭LED1...8 */
LPC_GPIO2->DATA |= ((0x1<<0)|(0x1<<1)|(0x1<<2)|(0x1<<3));
}
else if ( timer16_0_counter > 400 )
{
timer16_0_counter = 0;
}
}
}
/**
* @}
*/
/**
* @}
*/
/***** (C) COPYRIGHT 2010 UP Team,Wuhan University of Technology *****文件结束*******/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?