Rev 41 | Rev 44 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 41 | Rev 42 | ||
|---|---|---|---|
| Line 70... | Line 70... | ||
| 70 | tim3triggered = 0; |
70 | tim3triggered = 0; |
| 71 | if (chtTimer >= 3) // every 300mS |
71 | if (chtTimer >= 3) // every 300mS |
| 72 | { |
72 | { |
| 73 | chtTimer = 0; |
73 | chtTimer = 0; |
| 74 | 74 | ||
| - | 75 | resetTempCS(); |
|
| 75 | for (int instance = 0; instance < 2; instance++) |
76 | for (int instance = 0; instance < NUM_SPI_TEMP_SENS; instance++) |
| 76 | { |
77 | { |
| 77 | uint8_t buffer[2]; |
78 | uint8_t buffer[2]; |
| 78 | uint16_t Pin = |
- | |
| 79 | (instance == 0) ? SPI_NS_Temp_Pin : SPI_NS_Temp2_Pin; |
- | |
| 80 | - | ||
| 81 | HAL_GPIO_WritePin (SPI_NS_Temp_GPIO_Port, Pin, GPIO_PIN_RESET); |
- | |
| 82 | 79 | ||
| - | 80 | nextTempCS(); |
|
| 83 | HAL_SPI_Receive (&hspi1, buffer, 2, 2); |
81 | HAL_SPI_Receive (&hspi1, buffer, 2, 2); |
| 84 | 82 | ||
| 85 | HAL_GPIO_WritePin (SPI_NS_Temp_GPIO_Port, Pin, GPIO_PIN_SET); |
- | |
| 86 | 83 | ||
| 87 | uint16_t obs = (buffer[0] << 8) | buffer[1]; |
84 | uint16_t obs = (buffer[0] << 8) | buffer[1]; |
| 88 | 85 | ||
| 89 | // good observation if the status bit is clear, and the reading is less than 1023 |
86 | // good observation if the status bit is clear, and the reading is less than 1023 |
| 90 | 87 | ||
| Line 92... | Line 89... | ||
| 92 | 89 | ||
| 93 | uint8_t good = ((obs & 7) == 0) && (temp_c > 0) && (temp_c < 250); |
90 | uint8_t good = ((obs & 7) == 0) && (temp_c > 0) && (temp_c < 250); |
| 94 | 91 | ||
| 95 | if (good) |
92 | if (good) |
| 96 | { |
93 | { |
| 97 | CHT_Observations[instance] = temp_c; |
94 | Temp_Observations[instance] = temp_c; |
| 98 | } |
95 | } |
| 99 | } |
96 | } |
| - | 97 | nextTempCS(); // clock CS one more time to deselect all chips |
|
| 100 | } |
98 | } |
| 101 | } |
99 | } |
| 102 | } |
100 | } |
| 103 | 101 | ||
| 104 | // 100mS periodic sampler handler |
102 | // 100mS periodic sampler handler |