1 #include <twr_module_gps.h>
2 #include <twr_tca9534a.h>
6 twr_module_gps_event_handler_t *event_handler;
20 static void _twr_module_gps_led_init(
twr_led_t *
self);
21 static void _twr_module_gps_led_on(
twr_led_t *
self);
22 static void _twr_module_gps_led_off(
twr_led_t *
self);
29 memset(&_twr_module_gps, 0,
sizeof(_twr_module_gps));
31 _twr_module_gps.sam_m8q_driver.on = _twr_module_gps_sam_m8q_on;
32 _twr_module_gps.sam_m8q_driver.off = _twr_module_gps_sam_m8q_off;
62 _twr_module_gps.event_handler = event_handler;
63 _twr_module_gps.event_param = event_param;
110 .
init = _twr_module_gps_led_init,
111 .on = _twr_module_gps_led_on,
112 .off = _twr_module_gps_led_off,
115 return &twr_module_gps_led_driver;
118 static void _twr_module_gps_led_init(
twr_led_t *
self)
123 static void _twr_module_gps_led_on(
twr_led_t *
self)
125 if (!
twr_tca9534a_write_pin(&_twr_module_gps.tca9534, _twr_module_gps_led_pin_lut[self->_channel.virtual], self->_idle_state ? 0 : 1))
131 static void _twr_module_gps_led_off(
twr_led_t *
self)
133 if (!
twr_tca9534a_write_pin(&_twr_module_gps.tca9534, _twr_module_gps_led_pin_lut[self->_channel.virtual], self->_idle_state ? 1 : 0))
144 if (_twr_module_gps.event_handler == NULL)
@ TWR_I2C_I2C0
I2C channel I2C0.
struct twr_led_t twr_led_t
LED instance.
void twr_module_gps_set_event_handler(twr_module_gps_event_handler_t event_handler, void *event_param)
Set callback function.
void twr_module_gps_stop(void)
Stop tracking.
bool twr_module_gps_get_altitude(twr_module_gps_altitude_t *altitude)
Get altitude.
bool twr_module_gps_get_quality(twr_module_gps_quality_t *quality)
Get quality.
bool twr_module_gps_init(void)
Initialize HARDWARIO GPS Module.
void twr_module_gps_invalidate(void)
Invalidate navigation data.
void twr_module_gps_start(void)
Start tracking.
const twr_led_driver_t * twr_module_gps_get_led_driver(void)
Get LED driver.
bool twr_module_gps_get_accuracy(twr_module_gps_accuracy_t *accuracy)
Get accuracy.
bool twr_module_gps_get_time(twr_module_gps_time_t *time)
Get time.
bool twr_module_gps_get_position(twr_module_gps_position_t *position)
Get position.
@ TWR_MODULE_GPS_LED_GREEN
LCD green LED channel.
@ TWR_MODULE_GPS_LED_RED
LCD red LED channel.
@ TWR_MODULE_GPS_EVENT_UPDATE
Update event.
@ TWR_MODULE_GPS_EVENT_STOP
Stop event.
@ TWR_MODULE_GPS_EVENT_START
Start event.
@ TWR_MODULE_GPS_EVENT_ERROR
Error event.
void twr_sam_m8q_stop(twr_sam_m8q_t *self)
Stop navigation module.
void twr_sam_m8q_invalidate(twr_sam_m8q_t *self)
Invalidate navigation data.
void twr_sam_m8q_start(twr_sam_m8q_t *self)
Start navigation module.
void twr_sam_m8q_init(twr_sam_m8q_t *self, twr_i2c_channel_t channel, uint8_t i2c_address, const twr_sam_m8q_driver_t *driver)
Initialize SAM-M8Q module driver.
void twr_sam_m8q_set_event_handler(twr_sam_m8q_t *self, twr_sam_m8q_event_handler_t event_handler, void *event_param)
Set callback function.
bool twr_sam_m8q_get_quality(twr_sam_m8q_t *self, twr_sam_m8q_quality_t *quality)
Get quality.
bool twr_sam_m8q_get_accuracy(twr_sam_m8q_t *self, twr_sam_m8q_accuracy_t *accuracy)
Get accuracy.
struct twr_sam_m8q_t twr_sam_m8q_t
SAM-M8Q instance.
twr_sam_m8q_event_t
Callback events.
bool twr_sam_m8q_get_time(twr_sam_m8q_t *self, twr_sam_m8q_time_t *time)
Get time.
bool twr_sam_m8q_get_position(twr_sam_m8q_t *self, twr_sam_m8q_position_t *position)
Get position.
bool twr_sam_m8q_get_altitude(twr_sam_m8q_t *self, twr_sam_m8q_altitude_t *altitude)
Get altitude.
@ TWR_SAM_M8Q_EVENT_ERROR
Error event.
@ TWR_SAM_M8Q_EVENT_STOP
Stop event.
@ TWR_SAM_M8Q_EVENT_START
Start event.
@ TWR_SAM_M8Q_EVENT_UPDATE
Update event.
bool twr_tca9534a_write_port(twr_tca9534a_t *self, uint8_t state)
Write state to all pins.
twr_tca9534a_pin_t
Individual pin names.
bool twr_tca9534a_init(twr_tca9534a_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize TCA9534A.
bool twr_tca9534a_set_port_direction(twr_tca9534a_t *self, uint8_t direction)
Set direction of all pins.
bool twr_tca9534a_write_pin(twr_tca9534a_t *self, twr_tca9534a_pin_t pin, int state)
Write pin state.
void(* init)(twr_led_t *self)
Callback for initialization.