mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
OP-1477 - Remove hardcoded strings for initialization config
This commit is contained in:
parent
adc9821cd3
commit
f2058dfc7f
@ -36,9 +36,6 @@
|
||||
uint32_t lastUnsentData = 0;
|
||||
uint8_t buffer[BUFFER_SIZE];
|
||||
|
||||
// cfg-prt I2C. In UBX+RTCM, Out UBX, Slave Addr 0x42
|
||||
const char cfg_settings[] = "\xB5\x62\x06\x00\x14\x00\x00\x00\x00\x00\x84\x00\x00\x00\x00\x00\x00\x00\x07\x00\x01\x00\x00\x00\x00\x00\xA6\xC6";
|
||||
|
||||
void handleGPS()
|
||||
{
|
||||
bool completeSentenceSent = false;
|
||||
@ -80,17 +77,21 @@ typedef struct {
|
||||
const uint8_t *sentence;
|
||||
} ubx_init_sentence;
|
||||
|
||||
const ubx_init_sentence gps_config[] = {
|
||||
[0] = {
|
||||
.sentence = (uint8_t *)cfg_settings,
|
||||
.size = sizeof(cfg_settings),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
void setupGPS()
|
||||
{
|
||||
for (uint8_t i = 0; i < NELEMENTS(gps_config); i++) {
|
||||
PIOS_UBX_DDC_WriteData(PIOS_I2C_GPS, gps_config[i].sentence, gps_config[i].size);
|
||||
}
|
||||
CfgPrtPkt cfgprt;
|
||||
|
||||
cfgprt.fragments.data.portID = CFG_PRT_DATA_PORTID_DDC;
|
||||
cfgprt.fragments.data.reserved0 = 0;
|
||||
cfgprt.fragments.data.txReady = CFG_PRT_DATA_TXREADI_DISABLED;
|
||||
cfgprt.fragments.data.mode = CFG_PRT_DATA_MODE_ADDR;
|
||||
cfgprt.fragments.data.reserved3 = 0;
|
||||
cfgprt.fragments.data.inProtoMask = CFG_PRT_DATA_PROTO_UBX | CFG_PRT_DATA_PROTO_RTCM;
|
||||
cfgprt.fragments.data.outProtoMask = CFG_PRT_DATA_PROTO_UBX;
|
||||
cfgprt.fragments.data.flags = 0;
|
||||
cfgprt.fragments.data.reserved5 = 0;
|
||||
|
||||
ubx_buildPacket(&cfgprt.packet, UBX_CFG_CLASS, UBX_CFG_PRT, sizeof(CfgPrtData));
|
||||
PIOS_UBX_DDC_WriteData(PIOS_I2C_GPS, cfgprt.packet.binarystream, sizeof(CfgPrtPkt));
|
||||
}
|
||||
|
@ -31,12 +31,24 @@
|
||||
#include <pios_helpers.h>
|
||||
#include <ubx_utils.h>
|
||||
|
||||
#define UBX_OP_CUST_CLASS 0x99
|
||||
#define UBX_OP_SYS 0x01
|
||||
#define UBX_OP_MAG 0x02
|
||||
#define UBX_CFG_CLASS 0x06
|
||||
#define UBX_CFG_PRT 0x00
|
||||
#define UBX_OP_CUST_CLASS 0x99
|
||||
#define UBX_OP_SYS 0x01
|
||||
#define UBX_OP_MAG 0x02
|
||||
|
||||
#define SYS_DATA_OPTIONS_FLASH 0x01
|
||||
#define SYS_DATA_OPTIONS_MAG 0x02
|
||||
|
||||
#define SYS_DATA_OPTIONS_FLASH 0x01
|
||||
#define SYS_DATA_OPTIONS_MAG 0x02
|
||||
|
||||
#define CFG_PRT_DATA_PORTID_DDC 0x00
|
||||
#define CFG_PRT_DATA_TXREADI_DISABLED 0x00
|
||||
#define CFG_PRT_DATA_PORTID_DDC 0x00
|
||||
#define CFG_PRT_DATA_MODE_ADDR (0x42 << 1)
|
||||
#define CFG_PRT_DATA_PROTO_UBX 0x01
|
||||
#define CFG_PRT_DATA_PROTO_NMEA 0x02
|
||||
#define CFG_PRT_DATA_PROTO_RTCM 0x04
|
||||
#define CFG_PRT_DATA_FLAGS_EXTTIMEOUT 0x02
|
||||
|
||||
|
||||
typedef struct {
|
||||
@ -74,4 +86,25 @@ typedef union {
|
||||
} SysUbxPkt;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t portID;
|
||||
uint8_t reserved0;
|
||||
uint16_t txReady;
|
||||
uint32_t mode;
|
||||
uint32_t reserved3;
|
||||
uint16_t inProtoMask;
|
||||
uint16_t outProtoMask;
|
||||
uint16_t flags;
|
||||
uint16_t reserved5;
|
||||
} __attribute__((packed)) CfgPrtData;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
UBXHeader_t header;
|
||||
CfgPrtData data;
|
||||
UBXFooter_t footer;
|
||||
} fragments;
|
||||
UBXPacket_t packet;
|
||||
} CfgPrtPkt;
|
||||
|
||||
#endif /* GPSV9PROTOCOL_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user