Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: X_NUCLEO_IKS01A2 mbed-rtos mbed
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, 00023 NMEA_GPGLL, 00024 NMEA_GNGSA, 00025 NMEA_GPTXT, 00026 NMEA_GPVTG, 00027 NMEA_GPRMC, 00028 NMEA_PSTMCPU, 00029 NMEA_PSTMVER, 00030 NMEA_END__ 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 }; 00051 00052 private: 00053 DigitalOut _reset; 00054 DigitalIn _pps; 00055 DigitalOut _wakeup; 00056 00057 #define SDT_UART_BAUD 9600 00058 #define FWU_UART_BAUD 115200 00059 #define TESEO_I2C_ADDRESS 0x3A 00060 #if 1 00061 #define POWERON_STABLE_SIGNAL_DELAY_MS 150 00062 #else 00063 #define POWERON_STABLE_SIGNAL_DELAY_MS 500 00064 #endif 00065 00066 Serial _uart; 00067 bool _uart_interleaded; 00068 bool _uart_discard; 00069 #if 1 00070 Mutex _uart_mutex; 00071 #define _uart_mutex_lock() _uart_mutex.lock() 00072 #define _uart_mutex_unlock() _uart_mutex.unlock() 00073 #else 00074 #define _uart_mutex_lock() 00075 #define _uart_mutex_unlock() 00076 #endif 00077 Serial *_serial_debug; 00078 I2C *_i2c; 00079 00080 int FwWaitAck(); 00081 00082 int CRC_(char *buf, int size); 00083 00084 int SendString(char *buf, int len); 00085 00086 int ReadMessage(char *buf, unsigned long len, Timer *t = NULL, float timout = 0.0); 00087 00088 char *DetectSentence(const char *cmd, char *buf, unsigned long len); 00089 00090 Thread serialStreamThread; 00091 00092 public: 00093 enum nmea_msg_id MsgDetect(char *buf, int buf_len, Serial *serial_debug); 00094 00095 void UARTStreamProcess(Serial *serial_debug); 00096 00097 Teseo_LIV3F(PinName reset_pin, PinName wakeup_pin, PinName pps_pin, PinName uart_tx_pin, PinName uart_rx_pin, Serial *serial_debug = NULL); 00098 00099 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); 00100 00101 void SendCommand(enum Teseo_LIV3F::cmd_enum c); 00102 00103 void Reset(Serial *serial_debug = NULL); 00104 00105 bool CheckPPSWorking(); 00106 00107 int CheckI2C(); 00108 00109 void RFTest(bool enable); 00110 00111 bool WaitBooting(Timer *t, float timout = 8.0); 00112 00113 int WakeUp(); 00114 00115 int EnableLowPower(); 00116 00117 char *ReadSentence(const char *cmd, char *buf, unsigned long len); 00118 00119 bool FirmwareUpdate(bool is_recovery, char *data, unsigned int data_len, unsigned long crc, Serial *serial_debug); 00120 00121 void ReadLoop(Serial *serial_debug); 00122 00123 void startListener(Serial *serial_debug); 00124 void stopListener(Serial *serial_debug); 00125 00126 MemoryPool<struct teseo_msg, 8> mpool; 00127 Queue<struct teseo_msg, 8> queue; 00128 }; 00129 00130 #endif
Generated on Fri Jul 15 2022 01:05:54 by
1.7.2