contain lorawan with serial_rx enabled
Dependencies: pulga-lorawan-drv SPI_MX25R Si1133 BME280
gps.h@63:4ec1808fb547, 2021-02-26 (annotated)
- Committer:
- ruschigo
- Date:
- Fri Feb 26 18:11:06 2021 +0000
- Revision:
- 63:4ec1808fb547
- Child:
- 65:4090220e19d2
insert serial rx by interrupt
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ruschigo | 63:4ec1808fb547 | 1 | #ifndef __GPS_H |
ruschigo | 63:4ec1808fb547 | 2 | |
ruschigo | 63:4ec1808fb547 | 3 | #define __GPS_H |
ruschigo | 63:4ec1808fb547 | 4 | |
ruschigo | 63:4ec1808fb547 | 5 | #include "mbed.h" |
ruschigo | 63:4ec1808fb547 | 6 | |
ruschigo | 63:4ec1808fb547 | 7 | #define SYNC1 0xB5 |
ruschigo | 63:4ec1808fb547 | 8 | #define SYNC2 0x62 |
ruschigo | 63:4ec1808fb547 | 9 | |
ruschigo | 63:4ec1808fb547 | 10 | |
ruschigo | 63:4ec1808fb547 | 11 | #define MAXIMUM_PACKET_SIZE 60 |
ruschigo | 63:4ec1808fb547 | 12 | |
ruschigo | 63:4ec1808fb547 | 13 | //GPS DEclaration |
ruschigo | 63:4ec1808fb547 | 14 | extern SPI spi_2; // mosi, miso, sclk |
ruschigo | 63:4ec1808fb547 | 15 | extern DigitalOut cs; |
ruschigo | 63:4ec1808fb547 | 16 | extern DigitalOut gps_reset; |
ruschigo | 63:4ec1808fb547 | 17 | extern DigitalOut gps_int; |
ruschigo | 63:4ec1808fb547 | 18 | extern DigitalOut gps_DSEL; |
ruschigo | 63:4ec1808fb547 | 19 | |
ruschigo | 63:4ec1808fb547 | 20 | static int lat; |
ruschigo | 63:4ec1808fb547 | 21 | static int lon; |
ruschigo | 63:4ec1808fb547 | 22 | |
ruschigo | 63:4ec1808fb547 | 23 | |
ruschigo | 63:4ec1808fb547 | 24 | typedef struct |
ruschigo | 63:4ec1808fb547 | 25 | { |
ruschigo | 63:4ec1808fb547 | 26 | uint8_t cls; |
ruschigo | 63:4ec1808fb547 | 27 | uint8_t id; |
ruschigo | 63:4ec1808fb547 | 28 | uint16_t len; //Length of the payload. Does not include cls, id, or checksum bytes |
ruschigo | 63:4ec1808fb547 | 29 | uint8_t *payload; |
ruschigo | 63:4ec1808fb547 | 30 | uint8_t checksumA; //Given to us from module. Checked against the rolling calculated A/B checksums. |
ruschigo | 63:4ec1808fb547 | 31 | uint8_t checksumB; |
ruschigo | 63:4ec1808fb547 | 32 | } gps_ubxPacket; |
ruschigo | 63:4ec1808fb547 | 33 | |
ruschigo | 63:4ec1808fb547 | 34 | typedef struct |
ruschigo | 63:4ec1808fb547 | 35 | { |
ruschigo | 63:4ec1808fb547 | 36 | uint32_t iTOW=0; |
ruschigo | 63:4ec1808fb547 | 37 | uint16_t year=0; |
ruschigo | 63:4ec1808fb547 | 38 | uint8_t month=0; |
ruschigo | 63:4ec1808fb547 | 39 | uint8_t day=0; |
ruschigo | 63:4ec1808fb547 | 40 | uint8_t hour=0; |
ruschigo | 63:4ec1808fb547 | 41 | uint8_t min=0; |
ruschigo | 63:4ec1808fb547 | 42 | uint8_t sec=0; |
ruschigo | 63:4ec1808fb547 | 43 | int8_t valid=0; |
ruschigo | 63:4ec1808fb547 | 44 | uint32_t tAcc=0; |
ruschigo | 63:4ec1808fb547 | 45 | int32_t nano=0; |
ruschigo | 63:4ec1808fb547 | 46 | uint8_t fixtype=0; |
ruschigo | 63:4ec1808fb547 | 47 | int8_t flags=0; |
ruschigo | 63:4ec1808fb547 | 48 | int8_t flags2=0; |
ruschigo | 63:4ec1808fb547 | 49 | uint8_t numSV=0; |
ruschigo | 63:4ec1808fb547 | 50 | int32_t lon=0; |
ruschigo | 63:4ec1808fb547 | 51 | int32_t lat=0; |
ruschigo | 63:4ec1808fb547 | 52 | int32_t height=0; |
ruschigo | 63:4ec1808fb547 | 53 | int32_t hMSL=0; |
ruschigo | 63:4ec1808fb547 | 54 | uint32_t hAcc=0; |
ruschigo | 63:4ec1808fb547 | 55 | uint32_t vAcc=0; |
ruschigo | 63:4ec1808fb547 | 56 | int32_t velN=0; |
ruschigo | 63:4ec1808fb547 | 57 | int32_t velE=0; |
ruschigo | 63:4ec1808fb547 | 58 | int32_t velD=0; |
ruschigo | 63:4ec1808fb547 | 59 | int32_t gSpeed=0; |
ruschigo | 63:4ec1808fb547 | 60 | int32_t headMot=0; |
ruschigo | 63:4ec1808fb547 | 61 | uint32_t sAcc=0; |
ruschigo | 63:4ec1808fb547 | 62 | uint32_t headAcc=0; |
ruschigo | 63:4ec1808fb547 | 63 | uint16_t pDOP=0; |
ruschigo | 63:4ec1808fb547 | 64 | int32_t headVeh; |
ruschigo | 63:4ec1808fb547 | 65 | int16_t magDec; |
ruschigo | 63:4ec1808fb547 | 66 | uint16_t magAcc; |
ruschigo | 63:4ec1808fb547 | 67 | |
ruschigo | 63:4ec1808fb547 | 68 | |
ruschigo | 63:4ec1808fb547 | 69 | } gps_navPVT; |
ruschigo | 63:4ec1808fb547 | 70 | |
ruschigo | 63:4ec1808fb547 | 71 | |
ruschigo | 63:4ec1808fb547 | 72 | extern void gps_leBootMsg(); |
ruschigo | 63:4ec1808fb547 | 73 | |
ruschigo | 63:4ec1808fb547 | 74 | extern void gps_le_envia_linha(); |
ruschigo | 63:4ec1808fb547 | 75 | |
ruschigo | 63:4ec1808fb547 | 76 | extern gps_ubxPacket gps_calcula_check(gps_ubxPacket Packet); |
ruschigo | 63:4ec1808fb547 | 77 | |
ruschigo | 63:4ec1808fb547 | 78 | extern void send_gps_packet(gps_ubxPacket packet); |
ruschigo | 63:4ec1808fb547 | 79 | |
ruschigo | 63:4ec1808fb547 | 80 | extern gps_navPVT le_nav_pvt (); |
ruschigo | 63:4ec1808fb547 | 81 | |
ruschigo | 63:4ec1808fb547 | 82 | extern void send_nav_pvt(); |
ruschigo | 63:4ec1808fb547 | 83 | |
ruschigo | 63:4ec1808fb547 | 84 | extern void send_gps_data(uint8_t *packet, uint8_t size); |
ruschigo | 63:4ec1808fb547 | 85 | |
ruschigo | 63:4ec1808fb547 | 86 | extern void wait_packet_byte (uint8_t *header, uint8_t byte); |
ruschigo | 63:4ec1808fb547 | 87 | |
ruschigo | 63:4ec1808fb547 | 88 | extern void gps_wait_same_packet(); |
ruschigo | 63:4ec1808fb547 | 89 | |
ruschigo | 63:4ec1808fb547 | 90 | extern void gps_config_gnss(); |
ruschigo | 63:4ec1808fb547 | 91 | |
ruschigo | 63:4ec1808fb547 | 92 | extern void gps_print_local (); |
ruschigo | 63:4ec1808fb547 | 93 | |
ruschigo | 63:4ec1808fb547 | 94 | extern void gps_get_lat_lon(int *latitude, int *logitude); |
ruschigo | 63:4ec1808fb547 | 95 | |
ruschigo | 63:4ec1808fb547 | 96 | extern void gps_config(); |
ruschigo | 63:4ec1808fb547 | 97 | |
ruschigo | 63:4ec1808fb547 | 98 | extern int get_latitude(); |
ruschigo | 63:4ec1808fb547 | 99 | |
ruschigo | 63:4ec1808fb547 | 100 | extern int get_longitude(); |
ruschigo | 63:4ec1808fb547 | 101 | |
ruschigo | 63:4ec1808fb547 | 102 | #endif |