Acquisition for GNSS1A1
Dependencies: F7_Ethernet X_NUCLEO_IKS01A2 mbed-rtos mbed
Fork of Test2Boards by
Teseo-LIV3F/Teseo-LIV3F.h@3:0fb5321d73fb, 2018-10-01 (annotated)
- Committer:
- nirnakern
- Date:
- Mon Oct 01 14:33:56 2018 +0000
- Revision:
- 3:0fb5321d73fb
- Parent:
- 1:ef1bbf9b6205
First Commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nirnakern | 0:4e088cbb2dbf | 1 | /* |
nirnakern | 0:4e088cbb2dbf | 2 | * ------------------------------------------------------------------------- |
nirnakern | 0:4e088cbb2dbf | 3 | * Copyright (C) 2017 STMicroelectronics |
nirnakern | 0:4e088cbb2dbf | 4 | * Author: Francesco M. Virlinzi <francesco.virlinzi@st.com> |
nirnakern | 0:4e088cbb2dbf | 5 | * |
nirnakern | 0:4e088cbb2dbf | 6 | * May be copied or modified under the terms of the GNU General Public |
nirnakern | 0:4e088cbb2dbf | 7 | * License V.2 ONLY. See linux/COPYING for more information. |
nirnakern | 0:4e088cbb2dbf | 8 | * |
nirnakern | 0:4e088cbb2dbf | 9 | * ------------------------------------------------------------------------- |
nirnakern | 0:4e088cbb2dbf | 10 | */ |
nirnakern | 0:4e088cbb2dbf | 11 | #ifndef __TESEO_LIV3F_H__ |
nirnakern | 0:4e088cbb2dbf | 12 | #define __TESEO_LIV3F_H__ |
nirnakern | 0:4e088cbb2dbf | 13 | |
nirnakern | 0:4e088cbb2dbf | 14 | #include "mbed.h" |
nirnakern | 0:4e088cbb2dbf | 15 | #include "rtos/rtos.h" |
nirnakern | 0:4e088cbb2dbf | 16 | |
nirnakern | 0:4e088cbb2dbf | 17 | extern char _OK[]; |
nirnakern | 0:4e088cbb2dbf | 18 | extern char _Failed[]; |
nirnakern | 0:4e088cbb2dbf | 19 | extern char X_Nucleo_name[]; |
nirnakern | 0:4e088cbb2dbf | 20 | |
nirnakern | 0:4e088cbb2dbf | 21 | enum nmea_msg_id { |
nirnakern | 1:ef1bbf9b6205 | 22 | NMEA_GPGGA, //0 |
nirnakern | 1:ef1bbf9b6205 | 23 | NMEA_GPGLL, //1 |
nirnakern | 1:ef1bbf9b6205 | 24 | NMEA_GNGSA, //2 |
nirnakern | 1:ef1bbf9b6205 | 25 | NMEA_GPTXT, //3 |
nirnakern | 1:ef1bbf9b6205 | 26 | NMEA_GPVTG, //4 |
nirnakern | 1:ef1bbf9b6205 | 27 | NMEA_GPRMC, //5 |
nirnakern | 1:ef1bbf9b6205 | 28 | NMEA_PSTMCPU, //6 |
nirnakern | 1:ef1bbf9b6205 | 29 | NMEA_PSTMVER, //7 |
nirnakern | 1:ef1bbf9b6205 | 30 | NMEA_END__ //8 |
nirnakern | 0:4e088cbb2dbf | 31 | }; |
nirnakern | 0:4e088cbb2dbf | 32 | |
nirnakern | 0:4e088cbb2dbf | 33 | #define TESEO_RXBUF_LEN 128 |
nirnakern | 0:4e088cbb2dbf | 34 | |
nirnakern | 0:4e088cbb2dbf | 35 | struct teseo_msg { |
nirnakern | 0:4e088cbb2dbf | 36 | unsigned char len; |
nirnakern | 0:4e088cbb2dbf | 37 | char buf[TESEO_RXBUF_LEN]; |
nirnakern | 0:4e088cbb2dbf | 38 | }; |
nirnakern | 0:4e088cbb2dbf | 39 | |
nirnakern | 0:4e088cbb2dbf | 40 | |
nirnakern | 0:4e088cbb2dbf | 41 | class Teseo_LIV3F { |
nirnakern | 0:4e088cbb2dbf | 42 | public: |
nirnakern | 0:4e088cbb2dbf | 43 | enum cmd_enum { |
nirnakern | 0:4e088cbb2dbf | 44 | GETSWVER, |
nirnakern | 0:4e088cbb2dbf | 45 | FORCESTANDBY, |
nirnakern | 0:4e088cbb2dbf | 46 | RFTESTON, |
nirnakern | 0:4e088cbb2dbf | 47 | RFTESTOFF, |
nirnakern | 0:4e088cbb2dbf | 48 | LOWPOWER, |
nirnakern | 0:4e088cbb2dbf | 49 | FWUPDATE, |
nirnakern | 3:0fb5321d73fb | 50 | ENABLEALL, |
nirnakern | 3:0fb5321d73fb | 51 | SAVE, |
nirnakern | 3:0fb5321d73fb | 52 | REBOOT, |
nirnakern | 3:0fb5321d73fb | 53 | ENABLEALL2, |
nirnakern | 0:4e088cbb2dbf | 54 | }; |
nirnakern | 1:ef1bbf9b6205 | 55 | |
nirnakern | 1:ef1bbf9b6205 | 56 | |
nirnakern | 1:ef1bbf9b6205 | 57 | Serial _uart; |
nirnakern | 1:ef1bbf9b6205 | 58 | bool _uart_interleaded; |
nirnakern | 1:ef1bbf9b6205 | 59 | bool _uart_discard; |
nirnakern | 0:4e088cbb2dbf | 60 | |
nirnakern | 0:4e088cbb2dbf | 61 | private: |
nirnakern | 0:4e088cbb2dbf | 62 | DigitalOut _reset; |
nirnakern | 0:4e088cbb2dbf | 63 | DigitalIn _pps; |
nirnakern | 0:4e088cbb2dbf | 64 | DigitalOut _wakeup; |
nirnakern | 0:4e088cbb2dbf | 65 | |
nirnakern | 0:4e088cbb2dbf | 66 | #define SDT_UART_BAUD 9600 |
nirnakern | 0:4e088cbb2dbf | 67 | #define FWU_UART_BAUD 115200 |
nirnakern | 0:4e088cbb2dbf | 68 | #define TESEO_I2C_ADDRESS 0x3A |
nirnakern | 0:4e088cbb2dbf | 69 | #if 1 |
nirnakern | 0:4e088cbb2dbf | 70 | #define POWERON_STABLE_SIGNAL_DELAY_MS 150 |
nirnakern | 0:4e088cbb2dbf | 71 | #else |
nirnakern | 0:4e088cbb2dbf | 72 | #define POWERON_STABLE_SIGNAL_DELAY_MS 500 |
nirnakern | 0:4e088cbb2dbf | 73 | #endif |
nirnakern | 0:4e088cbb2dbf | 74 | |
nirnakern | 1:ef1bbf9b6205 | 75 | |
nirnakern | 0:4e088cbb2dbf | 76 | #if 1 |
nirnakern | 0:4e088cbb2dbf | 77 | Mutex _uart_mutex; |
nirnakern | 0:4e088cbb2dbf | 78 | #define _uart_mutex_lock() _uart_mutex.lock() |
nirnakern | 0:4e088cbb2dbf | 79 | #define _uart_mutex_unlock() _uart_mutex.unlock() |
nirnakern | 0:4e088cbb2dbf | 80 | #else |
nirnakern | 0:4e088cbb2dbf | 81 | #define _uart_mutex_lock() |
nirnakern | 0:4e088cbb2dbf | 82 | #define _uart_mutex_unlock() |
nirnakern | 0:4e088cbb2dbf | 83 | #endif |
nirnakern | 0:4e088cbb2dbf | 84 | Serial *_serial_debug; |
nirnakern | 0:4e088cbb2dbf | 85 | I2C *_i2c; |
nirnakern | 0:4e088cbb2dbf | 86 | |
nirnakern | 0:4e088cbb2dbf | 87 | int FwWaitAck(); |
nirnakern | 0:4e088cbb2dbf | 88 | |
nirnakern | 0:4e088cbb2dbf | 89 | int CRC_(char *buf, int size); |
nirnakern | 0:4e088cbb2dbf | 90 | |
nirnakern | 0:4e088cbb2dbf | 91 | int SendString(char *buf, int len); |
nirnakern | 0:4e088cbb2dbf | 92 | |
nirnakern | 0:4e088cbb2dbf | 93 | int ReadMessage(char *buf, unsigned long len, Timer *t = NULL, float timout = 0.0); |
nirnakern | 0:4e088cbb2dbf | 94 | |
nirnakern | 0:4e088cbb2dbf | 95 | char *DetectSentence(const char *cmd, char *buf, unsigned long len); |
nirnakern | 0:4e088cbb2dbf | 96 | |
nirnakern | 0:4e088cbb2dbf | 97 | Thread serialStreamThread; |
nirnakern | 0:4e088cbb2dbf | 98 | |
nirnakern | 0:4e088cbb2dbf | 99 | public: |
nirnakern | 0:4e088cbb2dbf | 100 | enum nmea_msg_id MsgDetect(char *buf, int buf_len, Serial *serial_debug); |
nirnakern | 0:4e088cbb2dbf | 101 | |
nirnakern | 0:4e088cbb2dbf | 102 | void UARTStreamProcess(Serial *serial_debug); |
nirnakern | 0:4e088cbb2dbf | 103 | |
nirnakern | 0:4e088cbb2dbf | 104 | Teseo_LIV3F(PinName reset_pin, PinName wakeup_pin, PinName pps_pin, PinName uart_tx_pin, PinName uart_rx_pin, Serial *serial_debug = NULL); |
nirnakern | 0:4e088cbb2dbf | 105 | |
nirnakern | 0:4e088cbb2dbf | 106 | Teseo_LIV3F(PinName reset_pin, PinName wakeup_pin, PinName pps_pin, PinName uart_tx_pin, PinName uart_rx_pin, I2C *i2c_bus, Serial *serial_debug = NULL); |
nirnakern | 0:4e088cbb2dbf | 107 | |
nirnakern | 0:4e088cbb2dbf | 108 | void SendCommand(enum Teseo_LIV3F::cmd_enum c); |
nirnakern | 0:4e088cbb2dbf | 109 | |
nirnakern | 0:4e088cbb2dbf | 110 | void Reset(Serial *serial_debug = NULL); |
nirnakern | 0:4e088cbb2dbf | 111 | |
nirnakern | 0:4e088cbb2dbf | 112 | bool CheckPPSWorking(); |
nirnakern | 0:4e088cbb2dbf | 113 | |
nirnakern | 0:4e088cbb2dbf | 114 | int CheckI2C(); |
nirnakern | 0:4e088cbb2dbf | 115 | |
nirnakern | 0:4e088cbb2dbf | 116 | void RFTest(bool enable); |
nirnakern | 0:4e088cbb2dbf | 117 | |
nirnakern | 0:4e088cbb2dbf | 118 | bool WaitBooting(Timer *t, float timout = 8.0); |
nirnakern | 0:4e088cbb2dbf | 119 | |
nirnakern | 0:4e088cbb2dbf | 120 | int WakeUp(); |
nirnakern | 0:4e088cbb2dbf | 121 | |
nirnakern | 0:4e088cbb2dbf | 122 | int EnableLowPower(); |
nirnakern | 0:4e088cbb2dbf | 123 | |
nirnakern | 0:4e088cbb2dbf | 124 | char *ReadSentence(const char *cmd, char *buf, unsigned long len); |
nirnakern | 0:4e088cbb2dbf | 125 | |
nirnakern | 0:4e088cbb2dbf | 126 | bool FirmwareUpdate(bool is_recovery, char *data, unsigned int data_len, unsigned long crc, Serial *serial_debug); |
nirnakern | 0:4e088cbb2dbf | 127 | |
nirnakern | 0:4e088cbb2dbf | 128 | void ReadLoop(Serial *serial_debug); |
nirnakern | 0:4e088cbb2dbf | 129 | |
nirnakern | 0:4e088cbb2dbf | 130 | void startListener(Serial *serial_debug); |
nirnakern | 0:4e088cbb2dbf | 131 | void stopListener(Serial *serial_debug); |
nirnakern | 0:4e088cbb2dbf | 132 | |
nirnakern | 0:4e088cbb2dbf | 133 | MemoryPool<struct teseo_msg, 8> mpool; |
nirnakern | 0:4e088cbb2dbf | 134 | Queue<struct teseo_msg, 8> queue; |
nirnakern | 0:4e088cbb2dbf | 135 | }; |
nirnakern | 0:4e088cbb2dbf | 136 | |
nirnakern | 0:4e088cbb2dbf | 137 | #endif |