Acquisition for GNSS1A1

Dependencies:   F7_Ethernet X_NUCLEO_IKS01A2 mbed-rtos mbed

Fork of Test2Boards by Simone Mentasti

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Teseo-LIV3F.h Source File

Teseo-LIV3F.h

00001 /*
00002  * -------------------------------------------------------------------------
00003  * Copyright (C) 2017  STMicroelectronics
00004  * Author: Francesco M. Virlinzi  <francesco.virlinzi@st.com>
00005  *
00006  * May be copied or modified under the terms of the GNU General Public
00007  * License V.2 ONLY.  See linux/COPYING for more information.
00008  *
00009  * -------------------------------------------------------------------------
00010  */
00011 #ifndef __TESEO_LIV3F_H__
00012 #define __TESEO_LIV3F_H__
00013 
00014 #include "mbed.h"
00015 #include "rtos/rtos.h"
00016 
00017 extern char _OK[];
00018 extern char _Failed[];
00019 extern char X_Nucleo_name[];
00020 
00021 enum nmea_msg_id {
00022     NMEA_GPGGA,     //0
00023     NMEA_GPGLL,     //1 
00024     NMEA_GNGSA,     //2
00025     NMEA_GPTXT,     //3
00026     NMEA_GPVTG,     //4
00027     NMEA_GPRMC,     //5
00028     NMEA_PSTMCPU,   //6
00029     NMEA_PSTMVER,   //7
00030     NMEA_END__      //8
00031 };
00032 
00033 #define TESEO_RXBUF_LEN 128
00034 
00035 struct teseo_msg {
00036     unsigned char len;
00037     char buf[TESEO_RXBUF_LEN];
00038 };
00039 
00040 
00041 class Teseo_LIV3F {
00042 public:
00043     enum cmd_enum {
00044         GETSWVER,
00045         FORCESTANDBY,
00046         RFTESTON,
00047         RFTESTOFF,
00048         LOWPOWER,
00049         FWUPDATE,
00050         ENABLEALL,
00051         SAVE,
00052         REBOOT,
00053         ENABLEALL2,
00054     };
00055     
00056     
00057         Serial      _uart;
00058     bool        _uart_interleaded;
00059     bool        _uart_discard;
00060 
00061 private:
00062     DigitalOut   _reset;
00063     DigitalIn    _pps;
00064     DigitalOut   _wakeup;
00065 
00066 #define SDT_UART_BAUD                   9600
00067 #define FWU_UART_BAUD                   115200
00068 #define TESEO_I2C_ADDRESS               0x3A
00069 #if 1
00070 #define POWERON_STABLE_SIGNAL_DELAY_MS  150
00071 #else
00072 #define POWERON_STABLE_SIGNAL_DELAY_MS  500
00073 #endif
00074 
00075 
00076 #if 1
00077     Mutex   _uart_mutex;
00078 #define _uart_mutex_lock()      _uart_mutex.lock()
00079 #define _uart_mutex_unlock()    _uart_mutex.unlock()
00080 #else
00081 #define _uart_mutex_lock()
00082 #define _uart_mutex_unlock()
00083 #endif
00084     Serial      *_serial_debug;
00085     I2C         *_i2c;
00086 
00087     int FwWaitAck();
00088 
00089     int CRC_(char *buf, int size);
00090 
00091     int SendString(char *buf, int len);
00092 
00093     int ReadMessage(char *buf, unsigned long len, Timer *t = NULL, float timout = 0.0);
00094 
00095     char *DetectSentence(const char *cmd, char *buf, unsigned long len);
00096 
00097     Thread serialStreamThread;
00098 
00099 public:
00100     enum nmea_msg_id MsgDetect(char *buf, int buf_len, Serial *serial_debug);
00101 
00102     void UARTStreamProcess(Serial *serial_debug);
00103 
00104     Teseo_LIV3F(PinName reset_pin, PinName wakeup_pin, PinName pps_pin, PinName uart_tx_pin, PinName uart_rx_pin, Serial *serial_debug = NULL);
00105 
00106     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);
00107 
00108     void SendCommand(enum Teseo_LIV3F::cmd_enum c);
00109 
00110     void Reset(Serial *serial_debug = NULL);
00111 
00112     bool CheckPPSWorking();
00113 
00114     int CheckI2C();
00115 
00116     void RFTest(bool enable);
00117 
00118     bool WaitBooting(Timer *t, float timout = 8.0);
00119 
00120     int WakeUp();
00121 
00122     int EnableLowPower();
00123 
00124     char *ReadSentence(const char *cmd, char *buf, unsigned long len);
00125 
00126     bool FirmwareUpdate(bool is_recovery, char *data, unsigned int data_len, unsigned long crc, Serial *serial_debug);
00127 
00128     void ReadLoop(Serial *serial_debug);
00129 
00130     void startListener(Serial *serial_debug);
00131     void stopListener(Serial *serial_debug);
00132 
00133     MemoryPool<struct teseo_msg, 8> mpool;
00134     Queue<struct teseo_msg, 8>      queue;
00135 };
00136 
00137 #endif