etienne maillet
/
GNSS1A1_FINAL
GNSS1A1 polytech grenoble
Teseo-LIV3F/Teseo-LIV3F.h@1:2f8deb2a7fe1, 2019-02-28 (annotated)
- Committer:
- etiene32
- Date:
- Thu Feb 28 18:41:10 2019 +0000
- Revision:
- 1:2f8deb2a7fe1
- Parent:
- 0:4e088cbb2dbf
polytech grenoble etienne
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 | 0:4e088cbb2dbf | 22 | NMEA_GPGGA, |
nirnakern | 0:4e088cbb2dbf | 23 | NMEA_GPGLL, |
nirnakern | 0:4e088cbb2dbf | 24 | NMEA_GNGSA, |
nirnakern | 0:4e088cbb2dbf | 25 | NMEA_GPTXT, |
nirnakern | 0:4e088cbb2dbf | 26 | NMEA_GPVTG, |
nirnakern | 0:4e088cbb2dbf | 27 | NMEA_GPRMC, |
nirnakern | 0:4e088cbb2dbf | 28 | NMEA_PSTMCPU, |
nirnakern | 0:4e088cbb2dbf | 29 | NMEA_PSTMVER, |
nirnakern | 0:4e088cbb2dbf | 30 | NMEA_END__ |
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 | 0:4e088cbb2dbf | 50 | }; |
nirnakern | 0:4e088cbb2dbf | 51 | |
nirnakern | 0:4e088cbb2dbf | 52 | private: |
nirnakern | 0:4e088cbb2dbf | 53 | DigitalOut _reset; |
nirnakern | 0:4e088cbb2dbf | 54 | DigitalIn _pps; |
nirnakern | 0:4e088cbb2dbf | 55 | DigitalOut _wakeup; |
nirnakern | 0:4e088cbb2dbf | 56 | |
nirnakern | 0:4e088cbb2dbf | 57 | #define SDT_UART_BAUD 9600 |
nirnakern | 0:4e088cbb2dbf | 58 | #define FWU_UART_BAUD 115200 |
nirnakern | 0:4e088cbb2dbf | 59 | #define TESEO_I2C_ADDRESS 0x3A |
nirnakern | 0:4e088cbb2dbf | 60 | #if 1 |
nirnakern | 0:4e088cbb2dbf | 61 | #define POWERON_STABLE_SIGNAL_DELAY_MS 150 |
nirnakern | 0:4e088cbb2dbf | 62 | #else |
nirnakern | 0:4e088cbb2dbf | 63 | #define POWERON_STABLE_SIGNAL_DELAY_MS 500 |
nirnakern | 0:4e088cbb2dbf | 64 | #endif |
nirnakern | 0:4e088cbb2dbf | 65 | |
nirnakern | 0:4e088cbb2dbf | 66 | Serial _uart; |
nirnakern | 0:4e088cbb2dbf | 67 | bool _uart_interleaded; |
nirnakern | 0:4e088cbb2dbf | 68 | bool _uart_discard; |
nirnakern | 0:4e088cbb2dbf | 69 | #if 1 |
nirnakern | 0:4e088cbb2dbf | 70 | Mutex _uart_mutex; |
nirnakern | 0:4e088cbb2dbf | 71 | #define _uart_mutex_lock() _uart_mutex.lock() |
nirnakern | 0:4e088cbb2dbf | 72 | #define _uart_mutex_unlock() _uart_mutex.unlock() |
nirnakern | 0:4e088cbb2dbf | 73 | #else |
nirnakern | 0:4e088cbb2dbf | 74 | #define _uart_mutex_lock() |
nirnakern | 0:4e088cbb2dbf | 75 | #define _uart_mutex_unlock() |
nirnakern | 0:4e088cbb2dbf | 76 | #endif |
nirnakern | 0:4e088cbb2dbf | 77 | Serial *_serial_debug; |
nirnakern | 0:4e088cbb2dbf | 78 | I2C *_i2c; |
nirnakern | 0:4e088cbb2dbf | 79 | |
nirnakern | 0:4e088cbb2dbf | 80 | int FwWaitAck(); |
nirnakern | 0:4e088cbb2dbf | 81 | |
nirnakern | 0:4e088cbb2dbf | 82 | int CRC_(char *buf, int size); |
nirnakern | 0:4e088cbb2dbf | 83 | |
nirnakern | 0:4e088cbb2dbf | 84 | int SendString(char *buf, int len); |
nirnakern | 0:4e088cbb2dbf | 85 | |
nirnakern | 0:4e088cbb2dbf | 86 | int ReadMessage(char *buf, unsigned long len, Timer *t = NULL, float timout = 0.0); |
nirnakern | 0:4e088cbb2dbf | 87 | |
nirnakern | 0:4e088cbb2dbf | 88 | char *DetectSentence(const char *cmd, char *buf, unsigned long len); |
nirnakern | 0:4e088cbb2dbf | 89 | |
nirnakern | 0:4e088cbb2dbf | 90 | Thread serialStreamThread; |
nirnakern | 0:4e088cbb2dbf | 91 | |
nirnakern | 0:4e088cbb2dbf | 92 | public: |
nirnakern | 0:4e088cbb2dbf | 93 | enum nmea_msg_id MsgDetect(char *buf, int buf_len, Serial *serial_debug); |
nirnakern | 0:4e088cbb2dbf | 94 | |
nirnakern | 0:4e088cbb2dbf | 95 | void UARTStreamProcess(Serial *serial_debug); |
nirnakern | 0:4e088cbb2dbf | 96 | |
nirnakern | 0:4e088cbb2dbf | 97 | 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 | 98 | |
nirnakern | 0:4e088cbb2dbf | 99 | 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 | 100 | |
nirnakern | 0:4e088cbb2dbf | 101 | void SendCommand(enum Teseo_LIV3F::cmd_enum c); |
nirnakern | 0:4e088cbb2dbf | 102 | |
nirnakern | 0:4e088cbb2dbf | 103 | void Reset(Serial *serial_debug = NULL); |
nirnakern | 0:4e088cbb2dbf | 104 | |
nirnakern | 0:4e088cbb2dbf | 105 | bool CheckPPSWorking(); |
nirnakern | 0:4e088cbb2dbf | 106 | |
nirnakern | 0:4e088cbb2dbf | 107 | int CheckI2C(); |
nirnakern | 0:4e088cbb2dbf | 108 | |
nirnakern | 0:4e088cbb2dbf | 109 | void RFTest(bool enable); |
nirnakern | 0:4e088cbb2dbf | 110 | |
nirnakern | 0:4e088cbb2dbf | 111 | bool WaitBooting(Timer *t, float timout = 8.0); |
nirnakern | 0:4e088cbb2dbf | 112 | |
nirnakern | 0:4e088cbb2dbf | 113 | int WakeUp(); |
nirnakern | 0:4e088cbb2dbf | 114 | |
nirnakern | 0:4e088cbb2dbf | 115 | int EnableLowPower(); |
nirnakern | 0:4e088cbb2dbf | 116 | |
nirnakern | 0:4e088cbb2dbf | 117 | char *ReadSentence(const char *cmd, char *buf, unsigned long len); |
nirnakern | 0:4e088cbb2dbf | 118 | |
nirnakern | 0:4e088cbb2dbf | 119 | bool FirmwareUpdate(bool is_recovery, char *data, unsigned int data_len, unsigned long crc, Serial *serial_debug); |
nirnakern | 0:4e088cbb2dbf | 120 | |
nirnakern | 0:4e088cbb2dbf | 121 | void ReadLoop(Serial *serial_debug); |
nirnakern | 0:4e088cbb2dbf | 122 | |
nirnakern | 0:4e088cbb2dbf | 123 | void startListener(Serial *serial_debug); |
nirnakern | 0:4e088cbb2dbf | 124 | void stopListener(Serial *serial_debug); |
nirnakern | 0:4e088cbb2dbf | 125 | |
nirnakern | 0:4e088cbb2dbf | 126 | MemoryPool<struct teseo_msg, 8> mpool; |
nirnakern | 0:4e088cbb2dbf | 127 | Queue<struct teseo_msg, 8> queue; |
nirnakern | 0:4e088cbb2dbf | 128 | }; |
nirnakern | 0:4e088cbb2dbf | 129 | |
nirnakern | 0:4e088cbb2dbf | 130 | #endif |