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.
Fork of d7a_1x by
include/d7a_alp.h
- Committer:
- Jeej
- Date:
- 2016-09-08
- Revision:
- 56:da34fc11e760
- Parent:
- 52:c7a58fc48bd2
- Child:
- 58:38a366236bda
File content as of revision 56:da34fc11e760:
#ifndef _D7A_ALP_H_ #define _D7A_ALP_H_ #define ALP_CTRL_GROUP 0x80 #define ALP_CTRL_RESP 0x40 #define ALP_CTRL_OVERLOAD 0x80 #define ALP_CTRL_INDIRECT 0x40 #define ALP_CTRL_EOP 0x80 #define ALP_CTRL_ERR 0x40 typedef enum { // OPCODE | OPERAND ALP_OPCODE_NOP = 0, //| - ALP_OPCODE_F_RD_DATA = 1, //| FDR ALP_OPCODE_F_RD_PROP = 2, //| FID ALP_OPCODE_F_WR_DATA = 4, //| FD ALP_OPCODE_F_WR_FLUSH = 5, //| FD ALP_OPCODE_F_WR_PROP = 6, //| FD ALP_OPCODE_QUERY = 8, //| Q ALP_OPCODE_QBREAK = 9, //| Q ALP_OPCODE_PERM_REQ = 10, //| P ALP_OPCODE_CRC_CHECK = 11, //| Q ALP_OPCODE_F_EXIST = 16, //| FID ALP_OPCODE_F_CREATE = 17, //| FD ALP_OPCODE_F_DELETE = 18, //| FID ALP_OPCODE_F_RESTORE = 19, //| FID ALP_OPCODE_F_FLUSH = 20, //| FID ALP_OPCODE_F_OPEN = 21, //| FID ALP_OPCODE_F_CLOSE = 22, //| FID ALP_OPCODE_F_COPY = 23, //| 2xFID ALP_OPCODE_F_EXECUTE = 31, //| FID ALP_OPCODE_RSP_F_DATA = 32, //| FD ALP_OPCODE_RSP_F_PROP = 33, //| FH ALP_OPCODE_RSP_STATUS = 34, //| S ALP_OPCODE_RSP_ISTATUS = ALP_OPCODE_RSP_STATUS + (1 << 6), //| SI ALP_OPCODE_RSP_TAG = 35, //| PID ALP_OPCODE_RSP_EOPTAG = ALP_OPCODE_RSP_TAG + (2 << 6), //| PID ALP_OPCODE_RSP_ERRTAG = ALP_OPCODE_RSP_TAG + (1 << 6), //| PID ALP_OPCODE_CHUNK = 48, //| - ALP_OPCODE_LOGIC = 49, //| - ALP_OPCODE_FORWARD = 50, //| I ALP_OPCODE_IFORWARD = 51, //| IFID ALP_OPCODE_TAG = 52, //| PID ALP_OPCODE_EXT = 63, //| RFU // Modifiers ALP_OPCODE_RESP = 0x40, ALP_OPCODE_GROUP = 0x80, ALP_OPCODE_ERR = 0x40, ALP_OPCODE_EOP = 0x80, ALP_OPCODE_INDIRECT = 0x40, ALP_OPCODE_OVERLOAD = 0x80, } alp_opcodes_t; // ======================================================================= // d7a_id_t // ----------------------------------------------------------------------- // Identifier types enumerator // ======================================================================= typedef enum { // Void identifier (broadcast) // with indication of number of reached devices D7A_ID_NBID = 0, // Void identifier (broadcast) D7A_ID_NOID = 1, // Unique Identifier D7A_ID_UID = 2, // Virtual identifier D7A_ID_VID = 3, } d7a_id_t; typedef enum { ALP_RESP_TYPE_UNKNOWN = 0, ALP_RESP_TYPE_F_DATA = ALP_OPCODE_RSP_F_DATA, ALP_RESP_TYPE_F_PROP = ALP_OPCODE_RSP_F_PROP, ALP_RESP_TYPE_ISTATUS = ALP_OPCODE_RSP_ISTATUS, ALP_RESP_TYPE_STATUS = ALP_OPCODE_RSP_STATUS, 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 union { struct { uint32_t length; uint32_t offset; uint8_t fid; } f_data; struct { uint32_t length; uint32_t offset; uint8_t fid; } f_prop; struct { uint8_t code; uint8_t id; // Action ID } status; struct { uint32_t length; uint8_t type; } itf; struct { uint8_t id; uint8_t eop; uint8_t err; } tag; } meta; } alp_uns_resp_parsed_t; TYPEDEF_STRUCT_PACKED { uint8_t aid; int8_t status; } d7a_alp_rsp_status_t; TYPEDEF_STRUCT_PACKED { uint8_t tag; uint8_t tag_status; uint8_t nb_status; d7a_alp_rsp_status_t status[5]; uint32_t length; 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; d7a_errors_t d7a_alp_open(void); d7a_errors_t d7a_alp_close(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); 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_