继电器控制实验
#include "relay.h"void Relay_Init(void)
{EALLOW;SysCtrlRegs.PCLKCR3.bit.GPIOINENCLK = 1;// 开启GPIO时钟//继电器端口配置GpioCtrlRegs.GPAMUX1.bit.GPIO15=0;GpioCtrlRegs.GPADIR.bit.GPIO15=1;GpioCtrlRegs.GPAPUD.bit.GPIO15=0;EDIS;GpioDataRegs.GPACLEAR.bit.GPIO15=1;
}
#ifndef RELAY_H_
#define RELAY_H_#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"#define RELAY_ON (GpioDataRegs.GPASET.bit.GPIO15=1)
#define RELAY_OFF (GpioDataRegs.GPACLEAR.bit.GPIO15=1)void Relay_Init(void);#endif /* APP_RELAY_RELAY_H_ */
#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
#include "leds.h"
#include "beep.h"
#include "relay.h"void main()
{int i = 0;InitSysCtrl();//系统时钟初始化,默认已开启F28335所有外设时钟LED_Init();BEEP_Init();Relay_Init();RELAY_ON;while(1){i++;if(i%200){LED1_TOGGLE;}DELAY_US(1000);//系统的延迟函数单位是us 此处为延迟100us}
}