Wed, 21 Sep 2016 20:09:21 +0200
[SSD1322] add a copy_to_lcd method that accepts an area
5 | 1 | #ifndef HP34COMM_H |
2 | #define HP34COMM_H | |
3 | ||
4 | #include "mbed.h" | |
5 | #include "CircularBuffer.h" | |
6 | ||
7 | /***** HP 34970A communication class ***/ | |
8 | ||
9 | #define MAX_ERRS 10 | |
10 | #define MAX_BUFF 32 | |
11 | #define BUF_SIZE 32 | |
12 | ||
13 | class HPSerial { | |
14 | ||
15 | public: | |
16 | enum TrState { | |
17 | Idle = 0, | |
18 | Tx, | |
19 | Rx, | |
20 | }; | |
21 | typedef struct _CMD | |
22 | { | |
23 | TrState direction; | |
24 | uint8_t cmd; | |
25 | uint8_t size; | |
26 | char value[MAX_BUFF+1]; | |
27 | unsigned long id; | |
28 | } CMD; | |
29 | ||
30 | ||
31 | ||
32 | HPSerial(); | |
33 | ||
34 | bool cmd_available(void); | |
35 | bool pop(CMD& cmd); | |
36 | bool cmd_buf_full(void); | |
37 | unsigned int nerrors(uint8_t errorno); | |
38 | ||
39 | ||
40 | private: | |
41 | void reset(uint8_t errorno=0xFF); | |
42 | void handleAck(uint8_t val); | |
43 | void pushCmd(TrState direction, uint8_t cmd, uint8_t size, char *payload); | |
44 | void handleChar(uint8_t val); | |
45 | void setstatedbg(void); | |
46 | void rxIrq(void); | |
47 | void txIrq(void); | |
48 | void timeout(void); | |
49 | ||
50 | private: | |
51 | RawSerial serial_tx; | |
52 | RawSerial serial_rx; | |
53 | uint8_t buf[BUF_SIZE]; | |
54 | uint8_t head; | |
55 | uint8_t tx_state; | |
56 | uint8_t tx_cmd; | |
57 | uint8_t tx_len; | |
58 | bool tx_ack; | |
59 | CircularBuffer<CMD, 32> cmdbuf; | |
60 | unsigned long ncmd; | |
61 | unsigned int errs[MAX_ERRS]; | |
62 | Ticker timeouter; | |
63 | }; | |
64 | ||
65 | #endif |