Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

removing commented-out code, documentation

  • Loading branch information...
commit 6e3dd8bccafde1d439cf90b9e85cd689a382e69b 1 parent 7a17520
@BlackBears authored
View
BIN  AM861_I2C_SLAVE_ADC.atsuo
Binary file not shown
View
26 AM861_I2C_SLAVE_ADC/AM861_I2C_SLAVE_ADC.c
@@ -1,33 +1,23 @@
/***************************************************************************
*
-* Dan Gates
+* Alan K Duncan
*
-* File : I2C_Slave.c
-* Compiler : AVRstudio 4
+* File : AM861_I2C_SLAVE_ADC.c
+* Compiler : AVRStudio 6
* Revision : 1.0
-* Date : Tuesday, June 11, 2007
-* Revised by : Dan Gates
+* Date : March 22, 2013
+* Revised by : Alan Duncan, original code by Dan Gates. Adapted for ATtiny861
*
*
-* Target device : ATtiny45
+* Target device : ATtiny861
*
* AppNote : AVR312 - Using the USI module as a I2C slave.
*
* Description : Program for returning Analog data over an I2C port.
-* : This program assumes that you have an analog sensor
-* : attached to PB4 (ADC2). Other inputs are digital and
-* : were used to set the slave address (not used in this sample).
*
* Connections
*
-* AT tiny 45
-* +--------------------------------+
-* Address select1 | 1 pb5 reset VCC 8 |
-* Address select2 | 2 pb3 SCL pb2 7 | SCL
-* In from analog | 3 pb4 ADC2 pb1 6 | Address select3
-* | 4 GND SDA pb0 5 | SDA
-* +--------------------------------+
****************************************************************************/
#include <avr/io.h>
@@ -72,15 +62,11 @@ int main(void)
// read selected channel with 10-bit precision
uint16_t read_adc(uint8_t chan) {
// if 8-bit precision only is required, then set the ADLAR bit and just read ADCH
- //ADMUX = (chan & ~0b00001111) | (1<<REFS0);
- //ADMUX = (1<<ADLAR) | chan;
- //ADMUX = (1<<ADLAR) | (1<<MUX1);
ADMUX = chan;
ADCSRA = (1<<ADEN) | (1<<ADSC);
asm volatile ("NOP" ::);
asm volatile ("NOP" ::);
while ( ADCSRA & ( 1 << ADSC ) );
- //return ADCH;
uint8_t result_l = ADCL;
uint8_t result_h = ADCH;
return (result_h << 8) | result_l;
Please sign in to comment.
Something went wrong with that request. Please try again.