Created
July 9, 2014 23:56
-
-
Save hadleyrich/d7393f1385ba03aacfcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "global.h" | |
#include <avr/io.h> | |
#include <avr/interrupt.h> | |
#include <util/delay.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include "adc.h" | |
#include "usart.h" | |
#include "clock.h" | |
int16_t reading; | |
int main(void) { | |
sysclk_init(); | |
sei(); | |
usart_init(usart_d0, 128, 128); | |
usart_conf(usart_d0, 9600, 8, none, 1, 0, NULL); | |
usart_map_stdio(usart_d0); | |
usart_run(usart_d0); | |
adc_init(adc_signed, adc_vref_intvcc16, 12, adc_div512); | |
PORTE.DIRSET = PIN3_bm; | |
while (1) { | |
adc_conf(0, adc_singleend, 1, 0); | |
reading = adc_conv_blocking(0, 10, 10); | |
printf("PA1 reading: %i\r\n", reading); | |
adc_conf(0, adc_singleend, 2, 0); | |
reading = adc_conv_blocking(0, 10, 10); | |
printf("PA2 reading: %i\r\n", reading); | |
adc_conf(0, adc_singleend, 3, 0); | |
reading = adc_conv_blocking(0, 10, 10); | |
printf("PA3 reading: %i\r\n", reading); | |
PORTE.OUTTGL = PIN3_bm; | |
_delay_ms(1000); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment