Added files from first programming course at OSU

This commit is contained in:
2019-07-09 18:14:25 -07:00
parent 4a591de966
commit 8c92e250d9
48 changed files with 2858 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
/**
@file adc.c
@brief Wunderboard ADC Helper Functions
@version .01
@section intro Code Overview
This is the code for the Wunderboard ADC helper functions.
*/
#include "adc.h"
unsigned char read_adc(uint8_t channel){
unsigned char test;
ADMUX = 0x60 | channel; // Set the channel to the one we want
ADCSRA = 0b11000110; // Start a new sample.
while ((ADCSRA & 0b00010000) == 0 ); // Wait for a Valid Sample
ADCSRA |= 0b00010000; // Tell ADC you have the sample you want.
ADCSRA |= 0b01000000; // Start a new sample.
while ((ADCSRA & 0b00010000) == 0 ); // Wait for a Valid Sample
ADCSRA |= 0b00010000; // Tell ADC you have the sample you want.
test = ADCH;
ADCSRA = 0x00; // Disable the ADC
return (test);
}