adc.c File Reference
#include "LPC17xx.h"
#include "FreeRTOS.h"
#include "semphr.h"
#include "queue.h"
#include "task.h"
Include dependency graph for adc.c:

Functions

void ADC_IRQHandler (void)
 
void adc0_init ()
 
uint16_t adc0_get_reading (uint8_t channel_num)
 

Variables

QueueHandle_t g_adc_result_queue = 0
 
SemaphoreHandle_t g_adc_mutex = 0
 This is the mutex such that only one ADC conversion is performed at a time. More...
 

Function Documentation

uint16_t adc0_get_reading ( uint8_t  channel_num)

Gets an ADC reading from a channel number between 0 - 7

Returns
12-bit ADC value read from the ADC.
Note
If FreeRTOS is running, adc conversion will use interrupts and not poll for the result.
void adc0_init ( void  )

Initializes the ADC Peripheral

Note
The PIN that will be used by ADC needs to be selected using PINSEL externally
void ADC_IRQHandler ( void  )

This is the ADC interrupt mapped to startup.cpp IRQ name. This is called by the CPU core when ADC interrupt occurs.

Variable Documentation

SemaphoreHandle_t g_adc_mutex = 0

This is the mutex such that only one ADC conversion is performed at a time.

QueueHandle_t g_adc_result_queue = 0

Once a conversion is complete, we put the result into a queue. This avoids polling as the conversion routine can just wait until the ISR inputs the value into the queue.