FEP interrupt, response, ring buffer

Dependents:   087_myFEP_TX 087_myFEP_RX

Revision:
3:12dcc46fb9dc
Parent:
2:aa9a344a42a8
Child:
4:8d754f144b96
--- a/FEP.h	Sat Oct 09 13:35:40 2021 +0000
+++ b/FEP.h	Mon Oct 11 13:22:16 2021 +0000
@@ -11,7 +11,7 @@
  *  @brief Class for communicating using FEP-01, FEP-02
  *  @note  Not compatible with mbed-os 6
  */
-class myFEP{
+class myFEP : public RawSerial {
 public :
     /** constructor
      *  @param tx   SerialTX mbed pin to connect to FEP
@@ -42,13 +42,13 @@
      *  Send all data in the @brief argument
      *  @param data Array to send
      *  @return 0  Successful transmission
-     *  @return 1  Excessive amount of data
+     *  @return 1  Excessive amount of datax
      *  @return 2  command error
      *  @return 3  No response from the other party
      *  @return 4  The other party failed to receive
      *  @return -1 Not sure
      */
-    uint8_t SendData(uint8_t *data);
+    int8_t SendData(uint8_t *data);
 
     /** Send by specifying the length
      *  @brief Send   'data' of 'length' length
@@ -62,26 +62,25 @@
      *  @return 4  The other party failed to receive
      *  @return -1 Not sure
      */
-    uint8_t SendData(uint8_t *data, uint8_t length);
+    int8_t SendData(uint8_t *data, uint8_t length);
 
     /** Response acquisition function
      *  @return 0  Successful transmission
-     *  @return 1  Excessive amount of data
      *  @return 2  command error
      *  @return 3  No response from the other party
      *  @return 4  The other party failed to receive
      *  @return -1 Not sure
      */
-    uint8_t GetResponse();
+    int8_t GetResponse();
 
 private :
-    uint8_t ctoi(char c);
+    int8_t ctoi(char c);
 
-    uint8_t  addr;        //! Destination address
-    uint8_t buffer[256];  //! Array for storing received data
-    uint8_t retdata[256]; //! Data storage array for Substitution
-    uint16_t  bufindex;   //! index of buffer
-    uint16_t  retindex;   //! index of retdata
-}
+    uint8_t  addr;         //! Destination address
+    uint8_t  buffer[256];  //! Array for storing received data
+    uint8_t  retdata[256]; //! Data storage array for Substitution
+    uint16_t bufindex;     //! index of buffer
+    uint16_t retindex;     //! index of retdata
+};
 
 #endif
\ No newline at end of file