Revision 10936c07
Added current sensing to toolbox
toolbox/main.c | ||
---|---|---|
7 | 7 |
#include "tooltron_mb.h" |
8 | 8 |
#include "rfid.h" |
9 | 9 |
#include "led.h" |
10 |
#include "current.h" |
|
10 | 11 |
|
11 | 12 |
enum toolstate_t { |
12 | 13 |
TS_INIT, |
... | ... | |
22 | 23 |
static uint8_t coils; |
23 | 24 |
static uint8_t latest_reading[RFID_SERNO_SIZE]; |
24 | 25 |
static uint8_t current_user[RFID_SERNO_SIZE]; |
26 |
static uint16_t current; |
|
25 | 27 |
|
26 | 28 |
static inline void set_coil(char coil, char bit) { |
27 | 29 |
coils = (coils & ~(1 << coil)) | (bit << coil); |
... | ... | |
235 | 237 |
} |
236 | 238 |
|
237 | 239 |
case MB_INP_CURRENT: |
238 |
*reg_buf++ = 0;
|
|
239 |
*reg_buf++ = 0;
|
|
240 |
*reg_buf++ = (uint8_t)(current >> 8);
|
|
241 |
*reg_buf++ = (uint8_t)current;
|
|
240 | 242 |
n_regs--; |
241 | 243 |
if (n_regs == 0) { |
242 | 244 |
return MB_ENOERR; |
... | ... | |
275 | 277 |
rfid_get_serno(latest_reading); |
276 | 278 |
rfid_start_read(); |
277 | 279 |
} |
280 |
current = current_read(); |
|
278 | 281 |
tool_main(); |
279 | 282 |
eMBPoll(); |
280 |
_delay_ms(50);
|
|
283 |
_delay_ms(100);
|
|
281 | 284 |
} |
282 | 285 |
|
283 | 286 |
return 0; |
Also available in: Unified diff