Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.
Matthew Yu edited this page Jul 3, 2020 · 13 revisions

Go to the source code for adc.h

Hardware Limitations

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).

Includes

  • #include "gpio.h"
  • #include "time.h"

Functions

Function Documention


InitializeADC

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

ADCRead

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

ADCBackgroundRead

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

ADCReadContinuouslyUS

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

ADCReadContinuously

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

Clone this wiki locally