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_modem.h@34:1311cc53201a, 2016-08-22 (annotated)
- Committer:
- Jeej
- Date:
- Mon Aug 22 13:47:39 2016 +0000
- Revision:
- 34:1311cc53201a
- Parent:
- 30:d775c1409849
- Child:
- 43:28202405094d
Working version with mbed rev 120
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Jeej | 25:aac250164497 | 1 | #ifndef _D7A_MODEM_H_ |
| Jeej | 25:aac250164497 | 2 | #define _D7A_MODEM_H_ |
| Jeej | 25:aac250164497 | 3 | |
| Jeej | 30:d775c1409849 | 4 | |
| Jeej | 30:d775c1409849 | 5 | enum { |
| Jeej | 30:d775c1409849 | 6 | WM_ERR_COM_LINK=10, |
| Jeej | 30:d775c1409849 | 7 | WM_ERR_NOT_READY, |
| Jeej | 30:d775c1409849 | 8 | }; |
| Jeej | 30:d775c1409849 | 9 | // Msg/Cmd exchanged on CMD FLOW ID |
| Jeej | 30:d775c1409849 | 10 | enum { |
| Jeej | 30:d775c1409849 | 11 | WM_READY, |
| Jeej | 30:d775c1409849 | 12 | }; |
| Jeej | 30:d775c1409849 | 13 | |
| Jeej | 30:d775c1409849 | 14 | |
| Jeej | 25:aac250164497 | 15 | //====================================================================== |
| Jeej | 25:aac250164497 | 16 | // MODEM commands over COM port |
| Jeej | 25:aac250164497 | 17 | //====================================================================== |
| Jeej | 25:aac250164497 | 18 | typedef enum |
| Jeej | 25:aac250164497 | 19 | { |
| Jeej | 29:8e7c5c1e9aab | 20 | /// Soft-reset Modem Device |
| Jeej | 29:8e7c5c1e9aab | 21 | /// ARGS: none |
| Jeej | 29:8e7c5c1e9aab | 22 | WM_CMD_RST = 0x01, |
| Jeej | 29:8e7c5c1e9aab | 23 | /// Start D7A communication stack |
| Jeej | 29:8e7c5c1e9aab | 24 | /// ARGS: none TODO: pass number of fifos ? |
| Jeej | 29:8e7c5c1e9aab | 25 | WM_CMD_D7A_STACK_START = 0x02, |
| Jeej | 29:8e7c5c1e9aab | 26 | /// Stop D7A communication stack |
| Jeej | 29:8e7c5c1e9aab | 27 | /// ARGS: none |
| Jeej | 29:8e7c5c1e9aab | 28 | WM_CMD_D7A_STACK_STOP = 0x03, |
| Jeej | 29:8e7c5c1e9aab | 29 | /// Register a File for notification |
| Jeej | 29:8e7c5c1e9aab | 30 | /// ARGS: register_file_param_t |
| Jeej | 29:8e7c5c1e9aab | 31 | WM_CMD_REGISTER_FILE = 0x04, |
| Jeej | 29:8e7c5c1e9aab | 32 | /// Notify a (previously registered) file |
| Jeej | 29:8e7c5c1e9aab | 33 | /// ARGS: notify_file_param_t |
| Jeej | 29:8e7c5c1e9aab | 34 | WM_CMD_NOTIFY_FILE = 0x05, |
| Jeej | 25:aac250164497 | 35 | |
| Jeej | 29:8e7c5c1e9aab | 36 | /// Send by the Modem Device after a command has been executed/taken |
| Jeej | 29:8e7c5c1e9aab | 37 | /// into account, and the Modem is ready to handle a new command. |
| Jeej | 29:8e7c5c1e9aab | 38 | /// Can be used as a command that will be instantly answered with WM_CMD_READY |
| Jeej | 29:8e7c5c1e9aab | 39 | /// ARGS: none |
| Jeej | 29:8e7c5c1e9aab | 40 | WM_CMD_READY = 0x80, |
| Jeej | 25:aac250164497 | 41 | |
| Jeej | 29:8e7c5c1e9aab | 42 | /// Send by the Modem Device after a (re)boot. |
| Jeej | 29:8e7c5c1e9aab | 43 | /// ARGS: boot_status_t |
| Jeej | 29:8e7c5c1e9aab | 44 | WM_CMD_BOOT = 0x81, |
| Jeej | 30:d775c1409849 | 45 | |
| Jeej | 30:d775c1409849 | 46 | } wm_cmd_t; |
| Jeej | 25:aac250164497 | 47 | |
| Jeej | 30:d775c1409849 | 48 | typedef union { |
| Jeej | 30:d775c1409849 | 49 | uint32_t w; |
| Jeej | 30:d775c1409849 | 50 | struct { |
| Jeej | 30:d775c1409849 | 51 | uint32_t cause : 8; |
| Jeej | 30:d775c1409849 | 52 | uint32_t rfu : 8; |
| Jeej | 30:d775c1409849 | 53 | uint32_t nb_boot :16; |
| Jeej | 30:d775c1409849 | 54 | } bf; |
| Jeej | 30:d775c1409849 | 55 | } boot_status_t; |
| Jeej | 26:9f0b9833cac6 | 56 | |
| Jeej | 25:aac250164497 | 57 | typedef union { |
| Jeej | 25:aac250164497 | 58 | uint32_t w; |
| Jeej | 25:aac250164497 | 59 | struct { |
| Jeej | 25:aac250164497 | 60 | uint32_t fid : 8; |
| Jeej | 30:d775c1409849 | 61 | uint32_t retry_policy : 8; |
| Jeej | 25:aac250164497 | 62 | } bf; |
| Jeej | 25:aac250164497 | 63 | } register_file_param_t; |
| Jeej | 25:aac250164497 | 64 | |
| Jeej | 25:aac250164497 | 65 | typedef union { |
| Jeej | 25:aac250164497 | 66 | uint32_t w; |
| Jeej | 25:aac250164497 | 67 | struct { |
| Jeej | 25:aac250164497 | 68 | uint32_t fid : 8; |
| Jeej | 25:aac250164497 | 69 | uint32_t offset : 12; |
| Jeej | 25:aac250164497 | 70 | uint32_t size : 12; |
| Jeej | 25:aac250164497 | 71 | } bf; |
| Jeej | 25:aac250164497 | 72 | } notify_file_param_t; |
| Jeej | 25:aac250164497 | 73 | |
| Jeej | 30:d775c1409849 | 74 | typedef struct { |
| Jeej | 30:d775c1409849 | 75 | union { |
| Jeej | 30:d775c1409849 | 76 | uint8_t b[8]; |
| Jeej | 30:d775c1409849 | 77 | uint32_t w[2]; |
| Jeej | 30:d775c1409849 | 78 | } uid; |
| Jeej | 30:d775c1409849 | 79 | uint8_t calib; |
| Jeej | 30:d775c1409849 | 80 | } wm_status_t; |
| Jeej | 30:d775c1409849 | 81 | |
| Jeej | 30:d775c1409849 | 82 | |
| Jeej | 27:934ab7455115 | 83 | //====================================================================== |
| Jeej | 27:934ab7455115 | 84 | // Firmware version Structure |
| Jeej | 27:934ab7455115 | 85 | // |
| Jeej | 27:934ab7455115 | 86 | // Used within the revision structure |
| Jeej | 27:934ab7455115 | 87 | //====================================================================== |
| Jeej | 27:934ab7455115 | 88 | TYPEDEF_STRUCT_PACKED |
| Jeej | 27:934ab7455115 | 89 | { |
| Jeej | 27:934ab7455115 | 90 | uint8_t id; |
| Jeej | 27:934ab7455115 | 91 | uint8_t major; |
| Jeej | 27:934ab7455115 | 92 | uint8_t minor; |
| Jeej | 27:934ab7455115 | 93 | uint16_t patch; |
| Jeej | 27:934ab7455115 | 94 | uint32_t hash; |
| Jeej | 27:934ab7455115 | 95 | } fw_version_t; |
| Jeej | 27:934ab7455115 | 96 | |
| Jeej | 27:934ab7455115 | 97 | //====================================================================== |
| Jeej | 27:934ab7455115 | 98 | // Revision Structure |
| Jeej | 27:934ab7455115 | 99 | // |
| Jeej | 27:934ab7455115 | 100 | // Usage within D7B server: |
| Jeej | 27:934ab7455115 | 101 | // An XML describing the File system of a device is associated to a |
| Jeej | 27:934ab7455115 | 102 | // couple manufacturer_id/device_id (==Device). |
| Jeej | 27:934ab7455115 | 103 | // Different versions of the Device's XML can exist and can be mapped |
| Jeej | 27:934ab7455115 | 104 | // according to fw_version |
| Jeej | 27:934ab7455115 | 105 | //====================================================================== |
| Jeej | 27:934ab7455115 | 106 | TYPEDEF_STRUCT_PACKED |
| Jeej | 27:934ab7455115 | 107 | { |
| Jeej | 27:934ab7455115 | 108 | /// Manufacturer ID: provided by Wizzilab |
| Jeej | 27:934ab7455115 | 109 | // comes from: here |
| Jeej | 27:934ab7455115 | 110 | uint32_t manufacturer_id; |
| Jeej | 27:934ab7455115 | 111 | /// Device ID: Arbitrary number, at user/customer choice |
| Jeej | 27:934ab7455115 | 112 | // comes from: application |
| Jeej | 27:934ab7455115 | 113 | uint32_t device_id; |
| Jeej | 27:934ab7455115 | 114 | /// Hardware Board ID: |
| Jeej | 27:934ab7455115 | 115 | // comes from: board definition |
| Jeej | 27:934ab7455115 | 116 | uint32_t hw_version; |
| Jeej | 27:934ab7455115 | 117 | /// Firmware Version: made of |
| Jeej | 27:934ab7455115 | 118 | /// - major,minor and patch indexes : comes from versioning tool |
| Jeej | 27:934ab7455115 | 119 | /// - fw_id : "build-flavour" : comes from build setup |
| Jeej | 27:934ab7455115 | 120 | /// FW_ID | MAJOR | MINOR | PATCH | HASH | |
| Jeej | 27:934ab7455115 | 121 | // 1B | 1B | 1B | 2B | 4B | |
| Jeej | 27:934ab7455115 | 122 | fw_version_t fw_version; |
| Jeej | 27:934ab7455115 | 123 | /// "file-system" signature XXX: to be worked out |
| Jeej | 27:934ab7455115 | 124 | // comes from: application |
| Jeej | 27:934ab7455115 | 125 | uint32_t fs_crc; |
| Jeej | 27:934ab7455115 | 126 | } revision_t; |
| Jeej | 27:934ab7455115 | 127 | |
| Jeej | 25:aac250164497 | 128 | |
| Jeej | 26:9f0b9833cac6 | 129 | void d7a_modem_open( PinName reset_pin ); |
| Jeej | 30:d775c1409849 | 130 | void d7a_modem_reset( void ); |
| Jeej | 30:d775c1409849 | 131 | bool d7a_modem_wait_ready( uint32_t millisec = osWaitForever ); |
| Jeej | 25:aac250164497 | 132 | void d7a_modem_new_pkt(d7a_com_rx_msg_t* pkt); |
| Jeej | 25:aac250164497 | 133 | d7a_com_rx_msg_t* d7a_modem_wait_pkt( uint32_t millisec = osWaitForever ); |
| Jeej | 30:d775c1409849 | 134 | void d7a_modem_msg(uint8_t value, uint8_t* buf, uint8_t len); |
| Jeej | 34:1311cc53201a | 135 | bool d7a_modem_register_file(uint8_t fid, uint8_t retry_policy = 0); |
| Jeej | 25:aac250164497 | 136 | void d7a_modem_notify_file(uint8_t fid, uint32_t offset, uint32_t length); |
| Jeej | 30:d775c1409849 | 137 | void d7a_modem_print_infos(void); |
| Jeej | 25:aac250164497 | 138 | |
| Jeej | 25:aac250164497 | 139 | |
| Jeej | 25:aac250164497 | 140 | #endif |
