rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
adc.h
Go to the documentation of this file.
1 /* This file is part of rflpc. Copyright 2010-2014 Michael Hauspie
2  *
3  * rflpc is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * rflpc is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with rflpc. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
21 #ifndef __RFLPC_ADC_H__
22 #define __RFLPC_ADC_H__
23 
24 /*
25  Author: Christophe Bacara <christophe.bacara@etudiant.univ-lille1.fr
26 */
27 
28 #ifdef RFLPC_CONFIG_ENABLE_ADC
29 
30 #include <rflpc17xx/rflpc17xx.h>
31 #include <stdint.h>
32 
48 extern void rflpc_adc_init(rflpc_pin_t pin,
49  rflpc_clock_divider_t clock_divider);
50 
60 extern void rflpc_adc_burst_init(rflpc_clock_divider_t clock_divider, rflpc_irq_handler_t handler);
61 
67 extern void rflpc_adc_burst_enable(rflpc_pin_t pin);
68 
76 extern void rflpc_adc_burst_start();
77 
85 static inline void rflpc_adc_sample(rflpc_pin_t pin)
86 {
87  RFLPC_SET_BITS_VAL (LPC_ADC->ADCR, 24, 0x01, 3);
88 }
89 
102 uint16_t rflpc_adc_read(rflpc_pin_t pin);
103 
115 uint16_t rflpc_adc_read_global();
116 
117 
118 #endif /* RFLPC_CONFIG_ENABLE_ADC */
119 
122 #endif /* __RFLPC_ADC_H__ */
uint8_t rflpc_pin_t
Represents a pin.
Definition: pinconf.h:44
Main header file.
uint16_t rflpc_adc_read(rflpc_pin_t pin)
Read the last converted value of specified pin using dedicated data register.
static void rflpc_adc_sample(rflpc_pin_t pin)
Start an ADC conversion on specified pin.
Definition: adc.h:85
rflpc_clock_divider_t
This enums defines the different cpu clock dividers for use as peripheral clocks. ...
Definition: clock.h:38
void rflpc_adc_burst_enable(rflpc_pin_t pin)
Enable an ADC pin to be sampled in burst mode.
void rflpc_adc_init(rflpc_pin_t pin, rflpc_clock_divider_t clock_divider)
Initializes the Analog/Digital Converter on given pin.
void rflpc_adc_burst_start()
Start ADC burst mode.
uint16_t rflpc_adc_read_global()
Read the last converted value of any ADC pin, using global data register.
void rflpc_adc_burst_init(rflpc_clock_divider_t clock_divider, rflpc_irq_handler_t handler)
Initializes the Analog/Digital converter for Burst Mode.
#define RFLPC_SET_BITS_VAL(val, bit_pos, bit_val, bit_count)
Sets some bits values from the position of the LSB bit and the number of bits to set.
Definition: tools.h:45
void(* rflpc_irq_handler_t)(void)
Interrupt handler type.
Definition: interrupt.h:62