Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_sam_m8q.h
1 #ifndef _BC_SAM_M8Q
2 #define _BC_SAM_M8Q
3 
4 #include <bc_i2c.h>
5 #include <bc_scheduler.h>
6 
10 
12 
13 typedef enum
14 {
17 
20 
23 
26 
28 
30 
31 typedef struct bc_sam_m8q_t bc_sam_m8q_t;
32 
34 
35 typedef struct
36 {
38  bool (*on)(bc_sam_m8q_t *self);
39 
41  bool (*off)(bc_sam_m8q_t *self);
42 
44 
46 
47 typedef struct
48 {
50  int year;
51 
53  int month;
54 
56  int day;
57 
59  int hours;
60 
62  int minutes;
63 
65  int seconds;
66 
68 
70 
71 typedef struct
72 {
74  float latitude;
75 
77  float longitude;
78 
80 
82 
83 typedef struct
84 {
86  float altitude;
87 
89  char units;
90 
92 
94 
95 typedef struct
96 {
99 
102 
104 
106 
107 typedef struct
108 {
110  float horizontal;
111 
113  float vertical;
114 
116 
118 
119 typedef enum
120 {
121  BC_SAM_M8Q_STATE_ERROR = -1,
122  BC_SAM_M8Q_STATE_START = 0,
123  BC_SAM_M8Q_STATE_READ = 1,
124  BC_SAM_M8Q_STATE_UPDATE = 2,
125  BC_SAM_M8Q_STATE_STOP = 3
126 
127 } bc_sam_m8q_state_t;
128 
129 typedef void (bc_sam_m8q_event_handler_t)(bc_sam_m8q_t *, bc_sam_m8q_event_t, void *);
130 
131 struct bc_sam_m8q_t
132 {
133  bc_i2c_channel_t _i2c_channel;
134  uint8_t _i2c_address;
135  const bc_sam_m8q_driver_t *_driver;
136  bc_scheduler_task_id_t _task_id;
137  bc_sam_m8q_event_handler_t *_event_handler;
138  void *_event_param;
139  bool _running;
140  bool _configured;
141  bc_sam_m8q_state_t _state;
142  uint8_t _ddc_buffer[64];
143  size_t _ddc_length;
144  char _line_buffer[128];
145  size_t _line_length;
146  bool _line_clipped;
147  struct
148  {
149  bool valid;
150  struct
151  {
152  int year;
153  int month;
154  int day;
155  } date;
156  struct
157  {
158  int hours;
159  int minutes;
160  int seconds;
161  } time;
162  float latitude;
163  float longitude;
164  } _rmc;
165  struct
166  {
167  bool valid;
168  int fix_quality;
169  float altitude;
170  char altitude_units;
171  } _gga;
172  struct
173  {
174  bool valid;
175  float h_accuracy;
176  float v_accuracy;
177  float speed;
178  float course;
179  int satellites;
180  } _pubx;
181 };
182 
184 
190 
191 void bc_sam_m8q_init(bc_sam_m8q_t *self, bc_i2c_channel_t channel, uint8_t i2c_address, const bc_sam_m8q_driver_t *driver);
192 
197 
198 void bc_sam_m8q_set_event_handler(bc_sam_m8q_t *self, bc_sam_m8q_event_handler_t event_handler, void *event_param);
199 
202 
203 void bc_sam_m8q_start(bc_sam_m8q_t *self);
204 
207 
208 void bc_sam_m8q_stop(bc_sam_m8q_t *self);
209 
211 
213 
219 
221 
227 
229 
235 
237 
243 
245 
251 
253 
254 #endif // _BC_SAM_M8Q
void bc_sam_m8q_init(bc_sam_m8q_t *self, bc_i2c_channel_t channel, uint8_t i2c_address, const bc_sam_m8q_driver_t *driver)
Initialize SAM-M8Q module driver.
Definition: bc_sam_m8q.c:13
int seconds
Seconds.
Definition: bc_sam_m8q.h:65
void bc_sam_m8q_set_event_handler(bc_sam_m8q_t *self, bc_sam_m8q_event_handler_t event_handler, void *event_param)
Set callback function.
Definition: bc_sam_m8q.c:26
bool bc_sam_m8q_get_accuracy(bc_sam_m8q_t *self, bc_sam_m8q_accuracy_t *accuracy)
Get accuracy.
Definition: bc_sam_m8q.c:124
int month
Month.
Definition: bc_sam_m8q.h:53
void bc_sam_m8q_start(bc_sam_m8q_t *self)
Start navigation module.
Definition: bc_sam_m8q.c:32
float horizontal
Horizontal accuracy estimate.
Definition: bc_sam_m8q.h:110
void bc_sam_m8q_invalidate(bc_sam_m8q_t *self)
Invalidate navigation data.
Definition: bc_sam_m8q.c:53
Stop event.
Definition: bc_sam_m8q.h:25
struct bc_sam_m8q_t bc_sam_m8q_t
SAM-M8Q instance.
Definition: bc_sam_m8q.h:31
int satellites_tracked
Number of satellites tracked.
Definition: bc_sam_m8q.h:101
Quality data structure.
Definition: bc_sam_m8q.h:95
float altitude
Altitude.
Definition: bc_sam_m8q.h:86
void bc_sam_m8q_stop(bc_sam_m8q_t *self)
Stop navigation module.
Definition: bc_sam_m8q.c:43
bool bc_sam_m8q_get_time(bc_sam_m8q_t *self, bc_sam_m8q_time_t *time)
Get time.
Definition: bc_sam_m8q.c:60
float latitude
Latitude.
Definition: bc_sam_m8q.h:74
float longitude
Longitude.
Definition: bc_sam_m8q.h:77
int hours
Hours.
Definition: bc_sam_m8q.h:59
bool bc_sam_m8q_get_altitude(bc_sam_m8q_t *self, bc_sam_m8q_altitude_t *altitude)
Get altitude.
Definition: bc_sam_m8q.c:94
size_t bc_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: bc_scheduler.h:18
int year
Year.
Definition: bc_sam_m8q.h:50
Accuracy data structure.
Definition: bc_sam_m8q.h:107
bool bc_sam_m8q_get_position(bc_sam_m8q_t *self, bc_sam_m8q_position_t *position)
Get position.
Definition: bc_sam_m8q.c:79
bc_i2c_channel_t
I2C channels.
Definition: bc_i2c.h:15
char units
Units of altitude.
Definition: bc_sam_m8q.h:89
Update event.
Definition: bc_sam_m8q.h:22
int minutes
Minutes.
Definition: bc_sam_m8q.h:62
int fix_quality
Fix quality.
Definition: bc_sam_m8q.h:98
Position data structure.
Definition: bc_sam_m8q.h:71
Error event.
Definition: bc_sam_m8q.h:16
Time data structure.
Definition: bc_sam_m8q.h:47
Start event.
Definition: bc_sam_m8q.h:19
Altitude data structure.
Definition: bc_sam_m8q.h:83
float vertical
Vertical accuracy estimate.
Definition: bc_sam_m8q.h:113
bc_sam_m8q_event_t
Callback events.
Definition: bc_sam_m8q.h:13
bool bc_sam_m8q_get_quality(bc_sam_m8q_t *self, bc_sam_m8q_quality_t *quality)
Get quality.
Definition: bc_sam_m8q.c:109
SAM-M8Q driver.
Definition: bc_sam_m8q.h:35