EFM32例程——EMU

硬件:EFM32GG230512
工具:keil5

EMU实验
EMU测试,进入em4休眠和唤醒

main

/*********************************************Copyright (c)***********************************************
** File name:             	  	main.c
** Created by:					Gui              
** Version:               		V1.0.0        
** Descriptions:            	EMU测试,进入em4休眠和唤醒
*********************************************************************************************************/
#include "system.h"
#include "em_device.h"
#include "em_chip.h"
#include "em_cmu.h"
#include "em_emu.h"
#include "delay.h"
#include "bsp_led.h"

int main(){
	uint32_t em4_wake_up = 0;
	uint32_t g_chip_tick = 0;
	g_rtc_rtcFreq = 0;
	
	CMU_ClockEnable(cmuClock_HFPER, true); //前置芯片设置
	CMU_ClockEnable(cmuClock_GPIO, true);
	if(SysTick_Config(SystemCoreClockGet()/1000))while(1);//1ms的systick中断
	em4_wake_up = GPIO_EM4GetPinWakeupCause();//获取唤醒IO
	
	led_init();//PD4 PD5
	
    GPIO_PinModeSet(gpioPortA,6,gpioModeInputPullFilter ,1);    /* 初始化引脚使能滤波*/
    GPIO_EM4EnablePinWakeup(GPIO_EM4WUEN_EM4WUEN_A6, 0);     	/* 使能低电平唤醒EM4*/
	GPIO_PinModeSet(gpioPortC,9,gpioModeInputPullFilter ,1);     
	GPIO_EM4EnablePinWakeup(GPIO_EM4WUEN_EM4WUEN_C9, 0); 
	if(em4_wake_up == 0x02){//PA6唤醒
		LED0_ON;
	}
	if(em4_wake_up == 0x04){//PC9唤醒
		LED1_ON;
	}
	while(1){
		if(g_rtc_rtcFreq - g_chip_tick > 5000){
			LED0_OFF;LED1_OFF;
			EMU_EnterEM4();
		}
	}
}


你可能感兴趣的:(EFM32)