Trond Enger / d7a_1x

Fork of d7a_1x by WizziLab

Revision:
46:665391110051
Parent:
45:b85384e7d825
Child:
49:81d5bddb02f0
--- a/include/d7a_alp.h	Thu Sep 01 09:35:27 2016 +0000
+++ b/include/d7a_alp.h	Thu Sep 01 18:13:46 2016 +0000
@@ -93,6 +93,34 @@
     ALP_RESP_TYPE_TAG     = ALP_OPCODE_RSP_TAG,
 } alp_resp_type_t;
 
+// =======================================================================
+// d7a_resp_t
+// -----------------------------------------------------------------------
+/// Enumerator of the D7ASP Response types
+// =======================================================================
+typedef enum
+{
+    /// No response requested
+    D7A_RESP_NO = 0,
+    /// Get all responses in response period
+    D7A_RESP_ALL,
+    /// Get at least one acknowledgement per request during response period
+    D7A_RESP_ANY,
+    /// RFU
+    D7A_RESP_RFU_1,
+    /// No response requested, repeat 3 times
+    D7A_RESP_NO_RPT,
+    /// Get all responses in response period, only Responders having not received packets respond
+    D7A_RESP_ON_ERR,
+    /// Get at least one acknowledgement per request during response period. 
+    /// Stick to a single responder when possible
+    D7A_RESP_PREFERRED,
+    /// RFU
+    D7A_RESP_RFU_2,
+
+} d7a_resp_t;
+
+
 typedef struct {
     uint8_t              type;
     uint8_t*             data;   // data
@@ -132,21 +160,6 @@
 
 TYPEDEF_STRUCT_PACKED 
 {
-    uint8_t ctrl;
-    uint8_t fid;
-    uint32_t offset;
-    uint32_t length;
-    uint8_t data[1];
-} d7a_alp_rsp_f_data_t;
-
-TYPEDEF_STRUCT_PACKED 
-{
-    uint8_t tag;
-} d7a_alp_rsp_tag_t;
-
-
-TYPEDEF_STRUCT_PACKED 
-{
     uint8_t tag;
     uint8_t tag_status;
     uint8_t nb_status;
@@ -155,10 +168,84 @@
     uint8_t* data;
 } d7a_alp_rsp_t;
 
+// =======================================================================
+// d7a_ctf_t
+// -----------------------------------------------------------------------
+/// DLL compressed time format
+// =======================================================================
+typedef union
+{
+    // bit access fields
+    struct {
+        /// Mantissa
+        uint8_t mant : 5;
+        /// Exponent
+        uint8_t exp  : 3;
+    } bf;
+
+    // byte access
+    uint8_t byte;
+
+} d7a_ctf_t;
+
+// =======================================================================
+// d7a_qos_t
+// -----------------------------------------------------------------------
+/// Bitfield structure of the D7ASP Quality of Service control byte
+// =======================================================================
+typedef union
+{
+    // bit access fields
+    struct {
+        /// Response mode
+        uint8_t resp         : 3;
+        /// Retry mode
+        uint8_t retry        : 3;
+        /// Responder has to keep the ACK template (TPL status file)
+        uint8_t record       : 1;
+         /// Stop D7ASP on not acknowledged request
+        uint8_t stop_on_err  : 1;
+
+    } bf;
+
+    // byte access
+    uint8_t byte;
+
+} d7a_qos_t;
+
+// =======================================================================
+// d7a_sp_cfg_t
+// -----------------------------------------------------------------------
+/// Structure of the D7ASP Configuration
+// =======================================================================
+TYPEDEF_STRUCT_PACKED
+{
+    /// D7ASP QoS
+    d7a_qos_t qos;
+    /// Dormant Timeout (0, no timeout)
+    d7a_ctf_t dorm_to;
+    /// Addressee
+    d7a_addressee_t addressee;
+
+} d7a_sp_cfg_t;
+
+
+// =======================================================================
+// alp_d7a_itf_t
+// -----------------------------------------------------------------------
+/// ALP/D7A Interface file TODO:should be in alp_d7a.h when/if it exists
+///                             but not in alp.h as it requires D7A
+// ====================================================================
+TYPEDEF_STRUCT_PACKED {
+    uint8_t type;
+    d7a_sp_cfg_t cfg;
+} alp_d7a_itf_t;
+
+
 void d7a_alp_open(void);
 void d7a_alp_new_pkt(d7a_com_rx_msg_t* pkt);
 d7a_com_rx_msg_t* d7a_alp_wait_pkt(uint32_t millisec = osWaitForever);
-int8_t d7a_alp_write_file(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* const buf, d7a_addressee_t* addressee = NULL, uint8_t retry = 0, bool resp = true);
-int8_t d7a_alp_read_file(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* const buf, d7a_addressee_t* addressee = NULL, uint8_t retry = 0);
+d7a_errors_t d7a_alp_write_file(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* const buf, d7a_addressee_t* addressee = NULL, uint8_t retry = 0, bool resp = true);
+d7a_errors_t d7a_alp_read_file(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* const buf, d7a_addressee_t* addressee = NULL, uint8_t retry = 0);
 
 #endif // _D7A_ALP_H_