2 ******************************************************************************
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
6 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
7 * @addtogroup GCSPlugins GCS Plugins
9 * @addtogroup Uploader Serial and USB Uploader Plugin
11 * @brief The USB and Serial protocol uploader plugin
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 /** LOCAL DEFINITIONS **/
47 #define SSP_TX_IDLE 0 // not expecting a ACK packet (no current transmissions in progress)
48 #define SSP_TX_WAITING 1 // waiting for a valid ACK to arrive
49 #define SSP_TX_TIMEOUT 2 // failed to receive a valid ACK in the timeout period, after retrying.
50 #define SSP_TX_ACKED 3 // valid ACK received before timeout period.
51 #define SSP_TX_BUFOVERRUN 4 // amount of data to send execeds the transmission buffer sizeof
52 #define SSP_TX_BUSY 5 // Attempted to start a transmission while a transmission was already in progress.
53 // #define SSP_TX_FAIL - failure...
56 #define SSP_RX_RECEIVING 1
57 #define SSP_RX_COMPLETE 2
59 // types of packet that can be received
62 #define SSP_RX_SYNCH 7
72 uint8_t *rxBuf
; // Buffer used to store rcv data
73 uint16_t rxBufSize
; // rcv buffer size.
74 uint8_t *txBuf
; // Length of data in buffer
75 uint16_t txBufSize
; // CRC for data in Packet buff
76 uint16_t max_retry
; // Maximum number of retrys for a single transmit.
77 int32_t timeoutLen
; // how long to wait for each retry to succeed
78 // function returns time in number of seconds that has elapsed from a given reference point
83 /** EXTERNAL FUNCTIONS **/
90 // static void sf_SendSynchPacket( Port_t *thisport );
91 uint16_t sf_crc16(uint16_t crc
, uint8_t data
);
92 void sf_write_byte(uint8_t c
);
93 void sf_SetSendTimeout();
94 uint16_t sf_CheckTimeout();
95 int16_t sf_DecodeState(uint8_t c
);
96 int16_t sf_ReceiveState(uint8_t c
);
99 void sf_SendAckPacket(uint8_t seqNumber
);
100 void sf_MakePacket(uint8_t *buf
, const uint8_t *pdata
, uint16_t length
, uint8_t seqNo
);
101 int16_t sf_ReceivePacket();
102 uint16_t ssp_SendDataBlock(uint8_t *data
, uint16_t length
);
105 qssp(port
*info
, bool debug
);
107 int16_t ssp_ReceiveProcess();
108 int16_t ssp_SendProcess();
109 uint16_t ssp_SendString(char *str
);
110 int16_t ssp_SendData(const uint8_t *data
, const uint16_t length
);
111 void ssp_Init(const PortConfig_t
*const info
);
112 int16_t ssp_ReceiveByte();
113 uint16_t ssp_Synchronise();
115 virtual void pfCallBack(uint8_t *, uint16_t); // call back function that is called when a full packet has been received