Trond Enger / d7a_1x

Fork of d7a_1x by WizziLab

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers d7a_modem.h Source File

d7a_modem.h

00001 #ifndef _D7A_MODEM_H_
00002 #define _D7A_MODEM_H_
00003 
00004 
00005 //======================================================================
00006 // MODEM commands over COM port
00007 //======================================================================
00008 typedef enum
00009 {    //============================================
00010     // COMMANDS
00011     //============================================
00012     // Soft-reset Modem Device
00013     // ARGS: none
00014     WM_CMD_RST                      = 0x01,
00015 
00016     // Start D7A communication stack
00017     // ARGS: none TODO: pass number of fifos ?
00018     WM_CMD_D7A_STACK_START          = 0x02,
00019 
00020     // Stop D7A communication stack
00021     // ARGS: none
00022     WM_CMD_D7A_STACK_STOP           = 0x03,
00023 
00024     // Register a File for notification
00025     // ARGS: register_file_param_t
00026     WM_CMD_REGISTER_FILE            = 0x04,
00027 
00028     // Notify a (previously registered) file
00029     // ARGS: notify_file_param_t
00030     WM_CMD_NOTIFY_FILE              = 0x05,
00031 
00032     // Command that will be instantly answered with WM_OK
00033     // ARGS: none
00034     WM_CMD_READY                    = 0x06,
00035 
00036     //============================================
00037     // RESPONSES
00038     //============================================
00039     // Send by the Modem Device after a command has been executed/taken
00040     // into account, and the Modem is ready to handle a new command.
00041     // ARGS: none
00042     WM_OK                           = 0x80,
00043 
00044     // Send by the Modem Device after a (re)boot.
00045     // ARGS: boot_status_t
00046     WM_BOOT                         = 0x81,
00047 
00048     // Send by the Modem Device in case of failing command
00049     // ARGS: wm_error_code_t (u8)
00050     WM_ERROR                        = 0x82,
00051 
00052     // Send by the Modem Device upon the end of a File notification.
00053     // This response is generated depending on ALP's Retry-Policy ('respond' field set)
00054     // ARGS: wm_notif_result_t
00055     WM_NOTIF_DONE                   = 0x83,
00056 } wm_cmd_t;
00057 
00058 typedef enum {
00059     WM_ERR_NONE             = 0,
00060     WM_ERR_NOT_READY        = 1,
00061     WM_ERR_COM_LINK         = 2,
00062     WM_ERR_ILLEGAL_FID      = 3,
00063     WM_ERR_ILLEGAL_FILE_DEF = 4,
00064 
00065     WM_ERR_UNKNOWN     = 0xff
00066 } wm_error_code_t;
00067 
00068 typedef union {
00069     uint32_t w;
00070     struct {
00071         uint32_t cause          : 8;
00072         uint32_t rfu            : 8;
00073         uint32_t nb_boot        :16;
00074     } bf;
00075 } boot_status_t;
00076 
00077 typedef struct {
00078     union {
00079         uint8_t      b[8];
00080         uint32_t     w[2];
00081     } uid;
00082     uint8_t calib;
00083 } wm_status_t;
00084 
00085 
00086 TYPEDEF_STRUCT_PACKED {
00087     uint8_t  fid;
00088     uint8_t  type;
00089     uint8_t  afid;
00090     uint8_t  ifid;
00091     uint8_t  prop;
00092     uint8_t  perm;
00093     uint32_t size;
00094     uint32_t alloc;
00095 } register_file_param_t;
00096 
00097 typedef union {
00098     uint32_t w;
00099     struct {
00100         uint32_t fid            : 8;
00101         uint32_t offset         : 12;
00102         uint32_t size           : 12;
00103     } bf;
00104 } notify_file_param_t;
00105 
00106 
00107 d7a_errors_t d7a_modem_open(PinName reset_pin, NotifDoneFunction nd);
00108 d7a_errors_t d7a_modem_close(void);
00109 d7a_errors_t d7a_modem_reset(void);
00110 d7a_errors_t d7a_modem_wait_ready(uint32_t millisec = osWaitForever);
00111 void d7a_modem_new_pkt(d7a_com_rx_msg_t* pkt);
00112 d7a_com_rx_msg_t* d7a_modem_wait_pkt(uint32_t millisec = osWaitForever);
00113 void d7a_modem_msg(uint8_t value, uint8_t* buf, uint8_t len);
00114 d7a_errors_t d7a_modem_register(register_file_param_t* file_infos);
00115 d7a_errors_t d7a_modem_notify(notify_file_param_t* notif);
00116 d7a_errors_t d7a_modem_start(void);
00117 d7a_errors_t d7a_modem_stop(void);
00118 
00119 
00120 #endif