Professional Documents
Culture Documents
Vibratingmotor
Vibratingmotor
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "inc/hw_sysctl.h"
#include "driverlib/sysctl.h"
#include "driverlib/pin_map.h" // Define PART_TM4C123GH6PM in project
#include "driverlib/gpio.h"
#include "ES_Port.h"
#include "termio.h"
#include "VibratingMotor.h"
#include "LEDService.h"
if ((HWREG(SYSCTL_RCGCGPIO) & BIT2HI) == 0) { //if clock has not been enabled, then
enable it
HWREG(SYSCTL_RCGCGPIO) |= BIT2HI;
while ((HWREG(SYSCTL_PRGPIO) & BIT2HI) != BIT2HI){
}
}
HWREG(GPIO_PORTC_BASE+GPIO_O_DEN) |= (BIT4HI);
HWREG(GPIO_PORTC_BASE+GPIO_O_DIR) |= (BIT4HI);
HWREG(GPIO_PORTC_BASE+(GPIO_O_DATA+ALL_BITS)) &= BIT4LO;
return true;
}
if (ThisEvent.EventType == ES_BUTTON3_PRESSED){
AreWeInTorch = 1;
ES_Timer_InitTimer(VIBRATINGMOTOR_TIMER, THIRTY_SEC);
}
else if ((ThisEvent.EventType == ES_PROX_DETECTED) && (AreWeInTorch == 1)){
HWREG(GPIO_PORTC_BASE+(GPIO_O_DATA+ALL_BITS)) |= BIT4HI;
ES_Timer_InitTimer(VIBRATINGMOTOR_TIMER, TEN_SEC);
AreWeInTorch = 0;
}
if((ThisEvent.EventType == ES_TIMEOUT) && (ThisEvent.EventParam ==
VIBRATINGMOTOR_TIMER)){
HWREG(GPIO_PORTC_BASE+(GPIO_O_DATA+ALL_BITS)) &= BIT4LO;
AreWeInTorch = 0;
}
return ReturnEvent;
}