-
Notifications
You must be signed in to change notification settings - Fork 0
/
UBloxGPSI2C.h
71 lines (63 loc) · 2.06 KB
/
UBloxGPSI2C.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef UBLOXGPS_I2C_H
#define UBLOXGPS_I2C_H
#include "UBloxGPS.h"
namespace UBlox
{
/**
* @brief Specialization of UBloxGPS for communication over I2C
*/
class UBloxGPSI2C : virtual public UBloxGPS
{
public:
/**
* @brief Construct an I2C UBloxGPS, using a preexisting I2C bus object.
*
* The UBloxGPSI2C class should not (and can not) be directly instantiated, since it virtually
* inherits from UBloxGPS. Instead, either ZEDF9PI2C or MAX8UI2C should be instantiated.
*
* @note This doesn't actually initialize the chip, you will need to call begin() for that.
*
* @param i2c I2C object connected to the correct %I2C bus. You must set the desired bus frequency
* on \c i2c before using the GPS.
* @param user_RSTpin Output pin connected to NRST
* @param i2cAddress I2C address. The MAX8 defaults to 0x42
*/
UBloxGPSI2C(I2C & i2c, PinName user_RSTpin, uint8_t i2cAddress = UBloxGPS_I2C_DEF_ADDRESS);
protected:
/**
* @brief I2C address of the device
*/
uint8_t i2cAddress_;
/**
* @brief I2C port
*/
I2C & i2cPort_;
private:
/**
* @brief Perform an I2C write
*
* Send the header then the data to the MAX8 on the configured I2C address
*
* @param packet buffer of bytes to send out to the chip
* @param packetLen number of bytes in packet.
*
* @return true if the write was successful, false otherwise (if the sensor does not ACK)
*/
virtual bool sendMessage(uint8_t* packet, uint16_t packetLen) final;
/**
* @brief Perform an I2C read
*
* @return ReadStatus::DONE if the read was successful
* ReadStatus::NO_DATA if there were no valid bytes available
* ReadStatus::ERR if an invalid byte or checksum was detected.
*/
virtual ReadStatus readMessage() final;
/**
* @brief Returns length of buffer in the GPS module's I2C output buffer.
*
* @returns Length of buffer, or -1 if unsuccessful.
*/
int32_t readLen();
};
};
#endif