Commit 8e94b3ef authored by Projects's avatar Projects

light sensor: Interrupts cause events.

parent 98f36877
......@@ -28,6 +28,12 @@
#include "light_sensor.h"
#include "i2cdrv.h"
#include <em_gpio.h>
// Interrupt pin (active low)
#define LS_INT_PORT gpioPortA
#define LS_INT_PIN 4
// Writes a register
static uint8_t max44009_write_reg(uint8_t reg_add, uint8_t value)
{
......@@ -151,3 +157,10 @@ uint8_t light_sensor_set_thres_timer(uint8_t timer)
{
return 0;
}*/
void light_sensor_init(void)
{
GPIO_PinModeSet(LS_INT_PORT, LS_INT_PIN, gpioModeInputPull, 1);
GPIO_IntConfig(LS_INT_PORT, LS_INT_PORT, false, true, true);
}
......@@ -67,7 +67,7 @@ enum charger_state {
* Sensor interrupts.
*/
enum sensor_type {
// LIGHT, // disabled for the time being
LIGHT,
MAGNETOMETER,
ACCELEROMETER
};
......
......@@ -78,11 +78,10 @@ static portBASE_TYPE gpio_irq_dispatcher(uint32_t flags)
break;
// Sensors
// There is a conflict with the bottom-left button interrupt
// case (1 << 6): // PA6
// evt.type = SENSOR_INT;
// evt.data.sensor = LIGHT;
// break;
case (1 << 4): // PA4
evt.type = SENSOR_INT;
evt.data.sensor = LIGHT;
break;
case (1 << 10): // PA10
evt.type = SENSOR_INT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment