50 #include <dev/button-sensor.h>
56 #define button_read PORTDbits.RD5
60 static struct timer debouncetimer;
62 static int status(
int type);
64 static uint8_t sensor_status = 0;
66 ISR(_CHANGE_NOTICE_VECTOR)
68 ENERGEST_ON(ENERGEST_TYPE_IRQ);
75 IFS1CLR = _IFS1_CNIF_MASK;
78 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
95 configure(
int type,
int value)
103 TRISDbits.TRISD5 = 1;
106 CNCONSET = 1 << _CNCON_ON_POSITION | 1 << _CNCON_SIDL_POSITION;
107 CNEN = 1 << _CNEN_CNEN14_POSITION;
108 CNPUE = 1 << _CNPUE_CNPUE14_POSITION;
110 IEC1CLR = _IEC1_CNIE_MASK;
111 IFS1CLR = _IFS1_CNIF_MASK;
113 IPC6CLR = _IPC6_CNIP_MASK;
114 IPC6SET = 6 << _IPC6_CNIP_POSITION;
116 IEC1SET = 1 << _IEC1_CNIE_POSITION;
132 return sensor_status;
135 SENSORS_SENSOR(button_sensor, BUTTON_SENSOR, value, configure, status);