This repository has been archived by the owner on Jun 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
adc.h
Matthew Yu edited this page Jul 3, 2020
·
13 revisions
Go to the source code for adc.h
ADC functionality is only supported on the following pins:
-
PB4
|PB5
-
PD0
|PD1
|PD2
|PD3
-
PE0
|PE1
|PE2
|PE3
|PE4
|PE5
View a pinout to see where these pins are located on your TM4c (or you can just look at your TM4C).
#include "gpio.h"
#include "time.h"
Initializes an ADC on a pin
tADC* InitializeADC(tPin pin);
Parameters:
-
pin
Pin plugged into a servo
Returns:
- Pointer to an initialized tADC, can be used by the ADCRead functions
Notes:
- if ADC is not supported in hardware on the given pin, then a null pointer is returned
Returns the voltage on the pin provided to InitializeADC as a % of 3.3V. (%'s are always between 0.0 and 1.0)
float ADCRead(tADC *adc);
Parameters:
-
adc
Pointer to an initialized tADC, returned by InitializeADC
Returns:
- Value measured as a percentage
Notes:
- if the ADC is not continuously reading, then the function will busy wait for the results
Sets up an ADC to be run in the background
void ADCBackgroundRead(tADC *adc, tCallback callback, void *data);
Parameters:
-
adc
Pointer to an initialized tADC, returned by InitializeADC -
callback
Function called the next time the ADC updates, in which a call to ADCRead will return with the newly obtained value immediately -
data
Argument sent to the provided callback function whenever it is called
Sets up an ADC to read indefinitely
void ADCReadContinuouslyUS(tADC *adc, tTime us);
Parameters:
-
adc
Pointer to an initialized tADC, returned by InitializeADC -
us
Time between calls to read the ADC specified in micro seconds
Notes:
- Any following calls to ADCRead will return the most recent value
- If the passed time between calls is less than the time it takes for the ADC to complete, the ADC will read as fast as possible without overlap
Sets up an ADC to read indefinitely
void ADCReadContinuously(tADC *adc, float s);
Parameters:
-
adc
Pointer to an initialized tADC, returned by InitializeADC -
s
Time between calls to read the ADC specified in seconds
Notes:
- Any following calls to ADCRead will return the most recent value
- If the passed time between calls is less than the time it takes for the ADC to complete, the ADC will read as fast as possible without overlap