Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2 | Rev 3 | ||
|---|---|---|---|
| Line 22... | Line 22... | ||
| 22 | /// Data Format : |
22 | /// Data Format : |
| 23 | /// byte0 = AFR*10 (so 148 = 14.8 AFR) |
23 | /// byte0 = AFR*10 (so 148 = 14.8 AFR) |
| 24 | /// byte1 = Temp in C of the sensor |
24 | /// byte1 = Temp in C of the sensor |
| 25 | /// byte2-7 = not used |
25 | /// byte2-7 = not used |
| 26 | /// The TinyWB is based on the SLCFree by 14point7 |
26 | /// The TinyWB is based on the SLCFree by 14point7 |
| 27 | /// actually this is rubbish - decode from using protocol analyser. |
27 | /// actually this document is wrong - below is the decode from using protocol analyser. |
| 28 | /// when the sensor is not connected, the unit outputs something like 1,200 gap of 50mS and repeats# |
28 | /// when the lambda sensor is not connected, the unit outputs something like 1,200 gap of 50mS and repeats# |
| 29 | /// |
29 | /// |
| 30 | // when the sensor is connected, the unit outputs this pattern |
30 | /// when the lambda sensor is connected, the unit outputs this pattern |
| 31 | 31 | ||
| 32 | //[0] 0.0000000000,1,, sync ? |
32 | //[0] 0.0000000000,1,, sync ? |
| 33 | //[1] 0.0000867750,200,, afr |
33 | //[1] 0.0000867750,200,, afr |
| 34 | //[2] 0.0001735250,41,, temperature |
34 | //[2] 0.0001735250,41,, temperature |
| 35 | //[3] 0.0002603000,2,, filler |
35 | //[3] 0.0002603000,2,, filler |
| Line 46... | Line 46... | ||
| 46 | static char tempCode = 0; |
46 | static char tempCode = 0; |
| 47 | 47 | ||
| 48 | char pollTinyWB(struct usart_ctl *instance, float *AFRvalue, float *temperature) |
48 | char pollTinyWB(struct usart_ctl *instance, float *AFRvalue, float *temperature) |
| 49 | { |
49 | { |
| 50 | int valid = 0; |
50 | int valid = 0; |
| - | 51 | // PollSerial returns non zero if characters are in the serial input buffer |
|
| 51 | while (PollSerial(instance)) |
52 | while (PollSerial(instance)) |
| 52 | { |
53 | { |
| 53 | // deal with time-based synchronisation - 8 byte bursts with gaps |
54 | // deal with time-based synchronisation - 8 byte bursts with gaps |
| 54 | uint32_t now = HAL_GetTick(); |
55 | uint32_t now = HAL_GetTick(); |
| 55 | if (now - lastCharTime > GAP_TIME_MS) |
56 | if (now - lastCharTime > GAP_TIME_MS) |
| 56 | { |
57 | { |
| 57 | characterIndex = 0; |
58 | characterIndex = 0; |
| 58 | } |
59 | } |
| 59 | lastCharTime = now; |
60 | lastCharTime = now; |
| - | 61 | // GetCharSerial is implemented as a blocking read from a USART : but because it is |
|
| - | 62 | // only called when PollSerial is true, it is never going to block. |
|
| 60 | char c = GetCharSerial(instance); |
63 | char c = GetCharSerial(instance); |
| 61 | if (characterIndex < CHARS_PER_FRAME) |
64 | if (characterIndex < CHARS_PER_FRAME) |
| 62 | 65 | ||
| 63 | switch (characterIndex) |
66 | switch (characterIndex) |
| 64 | { |
67 | { |