/*************************************************************************** * * [url=home.php?mod=space&uid=247401]@brief[/url] providing GPIO demo * *******************************************************************************/ #include "common.h" #include "ics.h" #include "rtc.h" #include "uart.h" #include "gpio.h" #include "sysinit.h" #include "start.h" /****************************************************************************** * Global variables ******************************************************************************/ volatile uint32_t Switch = 1; /****************************************************************************** * Constants and macros ******************************************************************************/ /****************************************************************************** * Local types ******************************************************************************/ /****************************************************************************** * Local function prototypes ******************************************************************************/ /****************************************************************************** * Local variables ******************************************************************************/ /****************************************************************************** * Local functions ******************************************************************************/ int main (void); void RTC_Task(void); /****************************************************************************** * Global functions ******************************************************************************/ /********************************************************************/ int main (void) { /* Perform processor initialization */ sysinit(); cpu_identify(); RTC_ConfigType sRTCConfig; RTC_ConfigType *pRTCConfig = &sRTCConfig; printf("\nRunning the GPIO_demo project.\n"); /* configure RTC to 1Hz interrupt frequency */ pRTCConfig->u16ModuloValue = 9; pRTCConfig->bInterruptEn = RTC_INTERRUPT_ENABLE; /* enable interrupt */ pRTCConfig->bClockSource = RTC_CLKSRC_1KHZ; /*clock source is 1khz*/ pRTCConfig->bClockPresaler = RTC_CLK_PRESCALER_100; /*prescaler is 100*/ RTC_SetCallback(RTC_Task); RTC_Init(pRTCConfig); /* way 1. GPIO initialize by multiple pin mask */ GPIO_Init(GPIOB, GPIO_PTE7_MASK, GPIO_PinOutput); /* way 2. GPIO initialize single pin name */ /* GPIO_PinInit(GPIO_PTE7, GPIO_PinOutput); */ while (1) { }; } /*****************************************************************************//*! * * [url=home.php?mod=space&uid=247401]@brief[/url] callback routine of RTC driver which does what you want to do at * every RTC period. * * @param none * * [url=home.php?mod=space&uid=266161]@return[/url] none * * [url=home.php?mod=space&uid=72445]@[/url] Pass/ Fail criteria: none *****************************************************************************/ void RTC_Task(void) { /* toggle LED1 */ /* way 1. toggle LED1 by multiple pin mask */ /* GPIO_Toggle(GPIOB, GPIO_PTE7_MASK); */ /* way2. toggle LED by single pin name */ /* GPIO_PinToggle(GPIO_PTE7); */ if (Switch == 0) GPIO_PinClear(GPIO_PTE7); if (Switch == 1) GPIO_PinSet(GPIO_PTE7); Switch ++; if (Switch == 2) {Switch = 0;} } /********************************************************************/
收藏0 举报
本版积分规则 发表回复 回帖并转播 回帖后跳转到最后一页
发帖类勋章
时间类勋章
人才类勋章
等级类勋章
45
769
4
扫码关注 21ic 官方微信
扫码关注嵌入式微处理器
扫码关注电源系统设计
扫码关注21ic项目外包
扫码浏览21ic手机版
本站介绍 | 申请友情链接 | 欢迎投稿 | 隐私声明 | 广告业务 | 网站地图 | 联系我们 | 诚聘英才
京公网安备 11010802024343号