X-Git-Url: https://defiant.homedns.org/gitweb/?p=ros_wild_thumper.git;a=blobdiff_plain;f=avr%2Fnano%2Fmain.c;h=07e1871420dcbc433671656420ac30f6182d8189;hp=aba8aa1a2114c5b9c0d5ed433d233ceb4395e5ec;hb=8bf6f432e200f4d3fa494081837915b15015ab65;hpb=ebe8b9669caa6d895b037231c2f66c104ac648a4 diff --git a/avr/nano/main.c b/avr/nano/main.c index aba8aa1..07e1871 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,9 @@ * 0x0A Voltage LSB * 0x0B Distance forward2 MSB * 0x0C Distance forward2 LSB + * 0x0D Current MSB + * 0x0E Current LSB + * 0x0F Manipulator 12V * * 0x15 Distance forward1 MSB (read only) * 0x16 Distance forward1 LSB (read only) @@ -34,9 +41,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 +219,11 @@ ISR(TWI_vect) } ireg++; break; + case TW_SR_STOP: + TWI_ACK; + break; + case TW_NO_INFO: + break; default: TWI_RESET; } @@ -180,8 +234,9 @@ uint16_t ReadChannel(uint8_t mux) { uint8_t i; uint16_t result; - ADCSRA = (1<