X-Git-Url: https://defiant.homedns.org/gitweb/?p=ros_wild_thumper.git;a=blobdiff_plain;f=avr%2Fnano%2Fmain.c;h=935ce4994d4ae418a1333a13aa44045210e1518b;hp=5ba30821e26227f6e936fede523b2d80b3dd4964;hb=7e8cc0303c358a8882f5b9f12df4357b63429288;hpb=ed122a75c49ea77b0bcf8e33e1be03e4eecd36a7 diff --git a/avr/nano/main.c b/avr/nano/main.c index 5ba3082..935ce49 100644 --- a/avr/nano/main.c +++ b/avr/nano/main.c @@ -5,6 +5,10 @@ #include #include #include +#include +#include +#include +#include #include "uart.h" /* @@ -22,6 +26,8 @@ * 0x0A Voltage LSB * 0x0B Distance forward2 MSB * 0x0C Distance forward2 LSB + * 0x0D Current MSB + * 0x0E Current LSB * * 0x15 Distance forward1 MSB (read only) * 0x16 Distance forward1 LSB (read only) @@ -34,9 +40,36 @@ */ -#define TWI_ACK TWCR = (1<>8; + TWI_ACK; + break; + case 0x0E: // Current LSB + TWDR = tmp16; + TWI_ACK; + break; case 0x15: // Distance forward1 MSB tmp16 = dist_forward1; TWDR = tmp16>>8; @@ -170,6 +213,11 @@ ISR(TWI_vect) } ireg++; break; + case TW_SR_STOP: + TWI_ACK; + break; + case TW_NO_INFO: + break; default: TWI_RESET; } @@ -180,8 +228,9 @@ uint16_t ReadChannel(uint8_t mux) { uint8_t i; uint16_t result; - ADCSRA = (1<