Trond Enger / d7a_1x

Fork of d7a_1x by WizziLab

Revision:
55:5ea18a3a01b9
Parent:
54:540b327bfa14
Child:
56:da34fc11e760
--- a/include/d7a.h	Tue Sep 06 15:49:19 2016 +0000
+++ b/include/d7a.h	Wed Sep 07 09:32:01 2016 +0000
@@ -10,6 +10,9 @@
 
 #define D7A_UID_LEN     (8)
 
+#define D7A_XCL_ENDPOINT    (0x01)
+#define D7A_XCL_GATEWAY     (0x21)
+
 
 //======================================================================
 // Enums
@@ -21,7 +24,7 @@
 /// File "Storage Class"
 //======================================================================
 typedef enum {
-    /// No data is keeped. Can only write in it.
+    /// No data is keeped. Write only!
     /// Ex: Use for commands.
     TRANSIENT = 0,
     /// Data is stocked in RAM and initialized at 0.
@@ -121,23 +124,66 @@
     D7A_ERR_ILLEGAL_FILE_DEF            ,// The FILE parameters specified are illegal
     D7A_ERR_CMD_TO                      ,// The command expired
     D7A_ERR_TX_FAILED                   ,// Transmission failed
-    
-
 } d7a_errors_t;
 
-// Types of retry policies
+
+/// Types of retry policies
+/// Respond: When finished the host will be notified
+/// Persist: When finished on error data is kept in the queue for next transmission
+/// Depth:   Number of commands kept in the queue
+/// Bulk:    Notifications sent only when the queue is full
+/// Retries: Number of retries after initial transmission
+/// Slot:    Time between retries (sec)
 typedef enum {
+    /// Respond: true
+    /// Persist: false
+    /// Depth:   1
+    /// Bulk:    false
+    /// Retries: 0
+    /// Slot:    0
     ALP_RPOL_ONESHOT         = 0,
+    /// Respond: true
+    /// Persist: false
+    /// Depth:   1
+    /// Bulk:    false
+    /// Retries: 3
+    /// Slot:    2
     ALP_RPOL_SINGLE          = 1,
+    /// Respond: true
+    /// Persist: false
+    /// Depth:   1
+    /// Bulk:    false
+    /// Retries: 3
+    /// Slot:    2
     ALP_RPOL_REPORT          = 2,
+    /// Respond: false
+    /// Persist: true
+    /// Depth:   4
+    /// Bulk:    false
+    /// Retries: 16
+    /// Slot:    20
     ALP_RPOL_REPORT_CHECKED  = 3,
+    /// Respond: true
+    /// Persist: false
+    /// Depth:   4
+    /// Bulk:    true
+    /// Retries: 0
+    /// Slot:    1
     ALP_RPOL_BULK            = 4,
-    ALP_RPOL_SPARE_1         = 5,
-    ALP_RPOL_SPARE_2         = 6,
-    ALP_RPOL_SPARE_3         = 7,
+    
+    //ALP_RPOL_SPARE_1         = 5,
+    //ALP_RPOL_SPARE_2         = 6,
+    //ALP_RPOL_SPARE_3         = 7,
+} alp_rpol_t;
 
-    ALP_RPOL_QTY,
-} alp_rpol_t;
+/// Action when file notifying
+typedef enum {
+    D7A_ACTION_NONE = 0,
+    /// Notify the whole file
+    D7A_NOTIFICATION_FULL = 100,
+    /// Notify only part of the file
+    D7A_NOTIFICATION_PART
+} d7a_action_t;
 
 //======================================================================
 // Structures
@@ -313,7 +359,9 @@
 /// @param callbacks            File system callbacks (You cannot use local files if this is not specified)
 /// @return d7a_errors_t        Error code
 //======================================================================
-d7a_errors_t d7a_open(const d7a_com_config_t* com_config, PinName reset_pin, const d7a_callbacks_t* callbacks);
+d7a_errors_t d7a_open(const d7a_com_config_t* com_config, 
+                      PinName reset_pin, 
+                      const d7a_callbacks_t* callbacks);
 
 //======================================================================
 // d7a_close
@@ -348,11 +396,17 @@
 /// @param perm                 Access permissions
 /// @param size                 Length of the created file
 /// @param alloc                Maximum size of the file
-/// @param action_file          File ID to an eventual Action file
-/// @param interface            File ID to an eventual Interface file
+/// @param action               Type of action to trigger
+/// @param retry                Index to the retry policy to use when notifying
 /// @return d7a_errors_t        Error code
 //======================================================================
-d7a_errors_t d7a_create(const uint8_t file_id, d7a_fs_storage_t prop, d7a_fs_perm_t perm, uint32_t size, uint32_t alloc, uint8_t action_file = 0, uint8_t interface = 0);
+d7a_errors_t d7a_create(const uint8_t file_id,
+                        d7a_fs_storage_t prop,
+                        d7a_fs_perm_t perm, 
+                        uint32_t size, 
+                        uint32_t alloc, 
+                        d7a_action_t action = D7A_ACTION_NONE, 
+                        alp_rpol_t retry = ALP_RPOL_ONESHOT);
 
 //======================================================================
 // d7a_declare
@@ -363,11 +417,17 @@
 /// @param perm                 Access permissions
 /// @param size                 Length of the created file
 /// @param alloc                Maximum size of the file
-/// @param action_file          File ID to an eventual Action file
-/// @param interface            File ID to an eventual Interface file
+/// @param action               Type of action to trigger
+/// @param retry                Index to the retry policy to use when notifying
 /// @return d7a_errors_t        Error code
 //======================================================================
-d7a_errors_t d7a_declare(const uint8_t file_id, d7a_fs_storage_t prop, d7a_fs_perm_t perm, uint32_t size, uint32_t alloc, uint8_t action_file = 0, uint8_t interface = 0);
+d7a_errors_t d7a_declare(const uint8_t file_id, 
+                         d7a_fs_storage_t prop, 
+                         d7a_fs_perm_t perm, 
+                         uint32_t size, 
+                         uint32_t alloc, 
+                         d7a_action_t action = D7A_ACTION_NONE, 
+                         alp_rpol_t retry = ALP_RPOL_ONESHOT);
 
 //======================================================================
 // d7a_read
@@ -381,7 +441,12 @@
 /// @param retry                Index to the retry policy to use
 /// @return d7a_errors_t        Error code
 //======================================================================
-d7a_errors_t d7a_read(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* buf, d7a_addressee_t* addressee = NULL, alp_rpol_t retry = ALP_RPOL_ONESHOT);
+d7a_errors_t d7a_read(const uint8_t file_id, 
+                      const uint32_t offset, 
+                      const uint32_t size, 
+                      const uint8_t* buf, 
+                      d7a_addressee_t* addressee = NULL, 
+                      alp_rpol_t retry = ALP_RPOL_ONESHOT);
 
 //======================================================================
 // d7a_write
@@ -396,7 +461,13 @@
 /// @param resp                 Wait to see if write is OK
 /// @return d7a_errors_t        Error code
 //======================================================================
-d7a_errors_t d7a_write(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* const buf, d7a_addressee_t* addressee = NULL, alp_rpol_t retry = ALP_RPOL_ONESHOT, bool resp = true);
+d7a_errors_t d7a_write(const uint8_t file_id, 
+                       const uint32_t offset, 
+                       const uint32_t size, 
+                       const uint8_t* const buf, 
+                       d7a_addressee_t* addressee = NULL, 
+                       alp_rpol_t retry = ALP_RPOL_ONESHOT, 
+                       bool resp = true);
 
 //======================================================================
 // d7a_notify
@@ -407,7 +478,9 @@
 /// @param size                 Size of data to write
 /// @return d7a_errors_t        Error code
 //======================================================================
-d7a_errors_t d7a_notify(const uint8_t file_id, const uint32_t offset, const uint32_t size);
+d7a_errors_t d7a_notify(const uint8_t file_id, 
+                        const uint32_t offset = 0, 
+                        const uint32_t size = 0);
 
 
 //======================================================================