![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Chrono TIR
mbed_genie.h@0:f38ea4ed5621, 2020-01-22 (annotated)
- Committer:
- pathae
- Date:
- Wed Jan 22 10:26:34 2020 +0000
- Revision:
- 0:f38ea4ed5621
chrono_TIR_V1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pathae | 0:f38ea4ed5621 | 1 | #undef GENIE_DEBUG |
pathae | 0:f38ea4ed5621 | 2 | |
pathae | 0:f38ea4ed5621 | 3 | #define GENIE_VERSION "GenieMbed 17-Nov-2013" |
pathae | 0:f38ea4ed5621 | 4 | |
pathae | 0:f38ea4ed5621 | 5 | // Genie commands & replys: |
pathae | 0:f38ea4ed5621 | 6 | |
pathae | 0:f38ea4ed5621 | 7 | #define GENIE_ACK 0x06 |
pathae | 0:f38ea4ed5621 | 8 | #define GENIE_NAK 0x15 |
pathae | 0:f38ea4ed5621 | 9 | |
pathae | 0:f38ea4ed5621 | 10 | #define TIMEOUT_PERIOD 500 |
pathae | 0:f38ea4ed5621 | 11 | #define RESYNC_PERIOD 100 |
pathae | 0:f38ea4ed5621 | 12 | |
pathae | 0:f38ea4ed5621 | 13 | #define GENIE_READ_OBJ 0 |
pathae | 0:f38ea4ed5621 | 14 | #define GENIE_WRITE_OBJ 1 |
pathae | 0:f38ea4ed5621 | 15 | #define GENIE_WRITE_STR 2 |
pathae | 0:f38ea4ed5621 | 16 | #define GENIE_WRITE_STRU 3 |
pathae | 0:f38ea4ed5621 | 17 | #define GENIE_WRITE_CONTRAST 4 |
pathae | 0:f38ea4ed5621 | 18 | #define GENIE_REPORT_OBJ 5 |
pathae | 0:f38ea4ed5621 | 19 | #define GENIE_REPORT_EVENT 7 |
pathae | 0:f38ea4ed5621 | 20 | |
pathae | 0:f38ea4ed5621 | 21 | // Objects |
pathae | 0:f38ea4ed5621 | 22 | // the manual says: |
pathae | 0:f38ea4ed5621 | 23 | // Note: Object IDs may change with future releases; it is not |
pathae | 0:f38ea4ed5621 | 24 | // advisable to code their values as constants. |
pathae | 0:f38ea4ed5621 | 25 | |
pathae | 0:f38ea4ed5621 | 26 | #define GENIE_OBJ_DIPSW 0 |
pathae | 0:f38ea4ed5621 | 27 | #define GENIE_OBJ_KNOB 1 |
pathae | 0:f38ea4ed5621 | 28 | #define GENIE_OBJ_ROCKERSW 2 |
pathae | 0:f38ea4ed5621 | 29 | #define GENIE_OBJ_ROTARYSW 3 |
pathae | 0:f38ea4ed5621 | 30 | #define GENIE_OBJ_SLIDER 4 |
pathae | 0:f38ea4ed5621 | 31 | #define GENIE_OBJ_TRACKBAR 5 |
pathae | 0:f38ea4ed5621 | 32 | #define GENIE_OBJ_WINBUTTON 6 |
pathae | 0:f38ea4ed5621 | 33 | #define GENIE_OBJ_ANGULAR_METER 7 |
pathae | 0:f38ea4ed5621 | 34 | #define GENIE_OBJ_COOL_GAUGE 8 |
pathae | 0:f38ea4ed5621 | 35 | #define GENIE_OBJ_CUSTOM_DIGITS 9 |
pathae | 0:f38ea4ed5621 | 36 | #define GENIE_OBJ_FORM 10 |
pathae | 0:f38ea4ed5621 | 37 | #define GENIE_OBJ_GAUGE 11 |
pathae | 0:f38ea4ed5621 | 38 | #define GENIE_OBJ_IMAGE 12 |
pathae | 0:f38ea4ed5621 | 39 | #define GENIE_OBJ_KEYBOARD 13 |
pathae | 0:f38ea4ed5621 | 40 | #define GENIE_OBJ_LED 14 |
pathae | 0:f38ea4ed5621 | 41 | #define GENIE_OBJ_LED_DIGITS 15 |
pathae | 0:f38ea4ed5621 | 42 | #define GENIE_OBJ_METER 16 |
pathae | 0:f38ea4ed5621 | 43 | #define GENIE_OBJ_STRINGS 17 |
pathae | 0:f38ea4ed5621 | 44 | #define GENIE_OBJ_THERMOMETER 18 |
pathae | 0:f38ea4ed5621 | 45 | #define GENIE_OBJ_USER_LED 19 |
pathae | 0:f38ea4ed5621 | 46 | #define GENIE_OBJ_VIDEO 20 |
pathae | 0:f38ea4ed5621 | 47 | #define GENIE_OBJ_STATIC_TEXT 21 |
pathae | 0:f38ea4ed5621 | 48 | #define GENIE_OBJ_SOUND 22 |
pathae | 0:f38ea4ed5621 | 49 | #define GENIE_OBJ_TIMER 23 |
pathae | 0:f38ea4ed5621 | 50 | #define GENIE_OBJ_SPECTRUM 24 |
pathae | 0:f38ea4ed5621 | 51 | #define GENIE_OBJ_SCOPE 25 |
pathae | 0:f38ea4ed5621 | 52 | #define GENIE_OBJ_TANK 26 |
pathae | 0:f38ea4ed5621 | 53 | #define GENIE_OBJ_USERIMAGES 27 |
pathae | 0:f38ea4ed5621 | 54 | #define GENIE_OBJ_PINOUTPUT 28 |
pathae | 0:f38ea4ed5621 | 55 | #define GENIE_OBJ_PININPUT 29 |
pathae | 0:f38ea4ed5621 | 56 | #define GENIE_OBJ_4DBUTTON 30 |
pathae | 0:f38ea4ed5621 | 57 | #define GENIE_OBJ_ANIBUTTON 31 |
pathae | 0:f38ea4ed5621 | 58 | #define GENIE_OBJ_COLORPICKER 32 |
pathae | 0:f38ea4ed5621 | 59 | #define GENIE_OBJ_USERBUTTON 33 |
pathae | 0:f38ea4ed5621 | 60 | |
pathae | 0:f38ea4ed5621 | 61 | // Structure to store replys returned from a display |
pathae | 0:f38ea4ed5621 | 62 | |
pathae | 0:f38ea4ed5621 | 63 | #define GENIE_FRAME_SIZE 6 |
pathae | 0:f38ea4ed5621 | 64 | struct genieFrameReportObj { |
pathae | 0:f38ea4ed5621 | 65 | uint8_t cmd; |
pathae | 0:f38ea4ed5621 | 66 | uint8_t object; |
pathae | 0:f38ea4ed5621 | 67 | uint8_t index; |
pathae | 0:f38ea4ed5621 | 68 | uint8_t data_msb; |
pathae | 0:f38ea4ed5621 | 69 | uint8_t data_lsb; |
pathae | 0:f38ea4ed5621 | 70 | }; |
pathae | 0:f38ea4ed5621 | 71 | |
pathae | 0:f38ea4ed5621 | 72 | ///////////////////////////////////////////////////////////////////// |
pathae | 0:f38ea4ed5621 | 73 | // The Genie frame definition |
pathae | 0:f38ea4ed5621 | 74 | // |
pathae | 0:f38ea4ed5621 | 75 | // The union allows the data to be referenced as an array of uint8_t |
pathae | 0:f38ea4ed5621 | 76 | // or a structure of type genieFrameReportObj, eg |
pathae | 0:f38ea4ed5621 | 77 | // |
pathae | 0:f38ea4ed5621 | 78 | // genieFrame f; |
pathae | 0:f38ea4ed5621 | 79 | // f.bytes[4]; |
pathae | 0:f38ea4ed5621 | 80 | // f.reportObject.data_lsb |
pathae | 0:f38ea4ed5621 | 81 | // |
pathae | 0:f38ea4ed5621 | 82 | // both methods get the same byte |
pathae | 0:f38ea4ed5621 | 83 | // |
pathae | 0:f38ea4ed5621 | 84 | union genieFrame { |
pathae | 0:f38ea4ed5621 | 85 | uint8_t bytes[GENIE_FRAME_SIZE]; |
pathae | 0:f38ea4ed5621 | 86 | genieFrameReportObj reportObject; |
pathae | 0:f38ea4ed5621 | 87 | }; |
pathae | 0:f38ea4ed5621 | 88 | |
pathae | 0:f38ea4ed5621 | 89 | #define MAX_GENIE_EVENTS 16 // MUST be a power of 2 |
pathae | 0:f38ea4ed5621 | 90 | #define MAX_GENIE_FATALS 10 |
pathae | 0:f38ea4ed5621 | 91 | |
pathae | 0:f38ea4ed5621 | 92 | struct genieEventQueueStruct { |
pathae | 0:f38ea4ed5621 | 93 | genieFrame frames[MAX_GENIE_EVENTS]; |
pathae | 0:f38ea4ed5621 | 94 | uint8_t rd_index; |
pathae | 0:f38ea4ed5621 | 95 | uint8_t wr_index; |
pathae | 0:f38ea4ed5621 | 96 | uint8_t n_events; |
pathae | 0:f38ea4ed5621 | 97 | }; |
pathae | 0:f38ea4ed5621 | 98 | |
pathae | 0:f38ea4ed5621 | 99 | typedef void (*geniePutCharFuncPtr) (uint8_t c, uint32_t baud); |
pathae | 0:f38ea4ed5621 | 100 | typedef uint16_t (*genieGetCharFuncPtr) (void); |
pathae | 0:f38ea4ed5621 | 101 | typedef void (*genieUserEventHandlerPtr) (void); |
pathae | 0:f38ea4ed5621 | 102 | |
pathae | 0:f38ea4ed5621 | 103 | #define ERROR_NONE 0 |
pathae | 0:f38ea4ed5621 | 104 | #define ERROR_TIMEOUT -1 // 255 0xFF |
pathae | 0:f38ea4ed5621 | 105 | #define ERROR_NOHANDLER -2 // 254 0xFE |
pathae | 0:f38ea4ed5621 | 106 | #define ERROR_NOCHAR -3 // 253 0xFD |
pathae | 0:f38ea4ed5621 | 107 | #define ERROR_NAK -4 // 252 0xFC |
pathae | 0:f38ea4ed5621 | 108 | #define ERROR_REPLY_OVR -5 // 251 0xFB |
pathae | 0:f38ea4ed5621 | 109 | #define ERROR_RESYNC -6 // 250 0xFA |
pathae | 0:f38ea4ed5621 | 110 | #define ERROR_NODISPLAY -7 // 249 0xF9 |
pathae | 0:f38ea4ed5621 | 111 | #define ERROR_BAD_CS -8 // 248 0xF8 |
pathae | 0:f38ea4ed5621 | 112 | |
pathae | 0:f38ea4ed5621 | 113 | #define GENIE_LINK_IDLE 0 |
pathae | 0:f38ea4ed5621 | 114 | #define GENIE_LINK_WFAN 1 // waiting for Ack or Nak |
pathae | 0:f38ea4ed5621 | 115 | #define GENIE_LINK_WF_RXREPORT 2 // waiting for a report frame |
pathae | 0:f38ea4ed5621 | 116 | #define GENIE_LINK_RXREPORT 3 // receiving a report frame |
pathae | 0:f38ea4ed5621 | 117 | #define GENIE_LINK_RXEVENT 4 // receiving an event frame |
pathae | 0:f38ea4ed5621 | 118 | #define GENIE_LINK_SHDN 5 |
pathae | 0:f38ea4ed5621 | 119 | |
pathae | 0:f38ea4ed5621 | 120 | #define GENIE_EVENT_NONE 0 |
pathae | 0:f38ea4ed5621 | 121 | #define GENIE_EVENT_RXCHAR 1 |
pathae | 0:f38ea4ed5621 | 122 | |
pathae | 0:f38ea4ed5621 | 123 | #ifndef TRUE |
pathae | 0:f38ea4ed5621 | 124 | #define TRUE (1==1) |
pathae | 0:f38ea4ed5621 | 125 | #define FALSE (!TRUE) |
pathae | 0:f38ea4ed5621 | 126 | #endif |
pathae | 0:f38ea4ed5621 | 127 | |
pathae | 0:f38ea4ed5621 | 128 | void SetupGenie(void); |
pathae | 0:f38ea4ed5621 | 129 | void genieAttachEventHandler (genieUserEventHandlerPtr handler); |
pathae | 0:f38ea4ed5621 | 130 | extern bool genieDequeueEvent (genieFrame * buff); |
pathae | 0:f38ea4ed5621 | 131 | extern bool genieEventIs (genieFrame * e, uint8_t cmd, uint8_t object, uint8_t index); |
pathae | 0:f38ea4ed5621 | 132 | extern uint16_t genieGetEventData (genieFrame * e); |
pathae | 0:f38ea4ed5621 | 133 | extern uint16_t genieWriteObject (uint16_t object, uint16_t index, uint16_t data); |
pathae | 0:f38ea4ed5621 | 134 | extern uint16_t genieWriteStr (uint16_t index, char *string); |
pathae | 0:f38ea4ed5621 | 135 | extern void genieWriteContrast (uint16_t value); |
pathae | 0:f38ea4ed5621 | 136 |