/* * main.c: the main file * NXP --> LPC1768 * * * Author : light * Date : 2012-4-16 * */ #includevolatile uint32_t msTicks; /* counts 1ms timeTicks */ /*---------------------------------------------------------------------------- SysTick_Handler *----------------------------------------------------------------------------*/ / Descriptions :SysTick interrupt handle parameters :None Returned value :None */ void SysTick_Handler(void) { msTicks++; /* increment counter necessary in Delay() */ } /*------------------------------------------------------------------------------ delays number of tick Systicks (happens every 1 ms) *------------------------------------------------------------------------------*/ __INLINE static void Delay (uint32_t dlyTicks) { uint32_t curTicks; curTicks = msTicks; // 获取当前值 while ((msTicks - curTicks) < dlyTicks); //等待,即延时 } / Descriptions :Function that initializes LEDs parameters :None Returned value :None */ void DelayMs(unsigned int m) { int i,j; for(i=m;i>0;i--) { for(j=3000;j>0;j--); } } / Descriptions :Function that initializes LEDs parameters :None Returned value :None */ void LedInit(void) { // PINSEL4,PINSEL5 设定P2.0 -- P2.32 端口功能(00,01,10,11) LPC_PINCON->PINSEL4 = 0XFC000000; // p2.0--p2.13设置为IO LPC_PINCON->PINMODE4 = 0XFC000000; // p2.0--p2.13设置为上拉电阻使能 LPC_GPIO2->FIODIR = 0X000000FF; // p2.0--p2.7设置为输出 } / Descriptions :Function that LED on parameters :n , which led is on Returned value :None */ void LedNOn(unsigned int n) { LPC_GPIO2->FIOSET = (1< FIOCLR = (1< =0;loc--) { LedNOn(loc); Delay(1000); LedNOff(loc); Delay(1000); } } }
上一篇:STM32之系统滴答定时器
下一篇:STM32学习笔记一时钟和定时器
推荐阅读最新更新时间:2024-03-16 14:54