#include "adc_pm.h"
#include "power.h"
#include "rit.h"
#include <LPC17xx.h>
Go to the source code of this file.
|
ADC_PMError | ADC_PMInit (u8 options, u8 clock_divider, u8 int_priority) |
| Initializes the 12bit ADC peripheral, which on this board is wired to the Potentiometer (PM). More specifically, the ADC peripheral is wired to the channel 5 of the ADC. Hence, the library does not handle other channels.
|
|
bool | ADC_PMIsInitialized (void) |
|
void | ADC_PMDeinit (void) |
|
void | ADC_PMGetSample (void) |
| Retrieves a single sample from the PM, and triggers the interrupt.
|
|
void | ADC_PMSDisableSampling (void) |
|
◆ ADC_CH5
◆ ADC_GLOBAL_INTEN
#define ADC_GLOBAL_INTEN (1 << 8) |
◆ ADC_PMDeinit()
void ADC_PMDeinit |
( |
void |
| ) |
|
Definition at line 44 of file adc_pm.c.
45{
48
49 NVIC_DisableIRQ(ADC_IRQn);
50 LPC_ADC->ADCR = 0;
51 LPC_ADC->ADINTEN = 0;
53}
void ADC_PMGetSample(void)
Retrieves a single sample from the PM, and triggers the interrupt.
_PRIVATE bool initialized
void POWER_TurnOffPeripheral(u8 bit)
Turns off a peripheral.
RIT_Error RIT_RemoveJob(RIT_Job job)
Removes a job from the RIT interrupt handler job queue.
◆ ADC_PMGetSample()
void ADC_PMGetSample |
( |
void |
| ) |
|
Retrieves a single sample from the PM, and triggers the interrupt.
- Note
- This function does NOT repetitively sample the PM. It only retrieves a single sample. This is because we are not handling the BURST mode of the ADC. In order to keep retrieving samples, the function must be called repeatedly.
-
As of now, only the basic conversion (001) is implemented.
Definition at line 55 of file adc_pm.c.
56{
58}
#define SET_BIT(reg, bit)
◆ ADC_PMInit()
Initializes the 12bit ADC peripheral, which on this board is wired to the Potentiometer (PM). More specifically, the ADC peripheral is wired to the channel 5 of the ADC. Hence, the library does not handle other channels.
- Parameters
-
options | ADC PM options from the ADC_PMConfig enum |
clock_divider | The clock divider to be used by the ADC (division is performed by clock_divider+1) |
int_priority | The priority of the ADC interrupt. If the priority is set to INT_PRIO_DEF, the default priority will be used. |
Definition at line 13 of file adc_pm.c.
14{
16
17 SET_BITS(LPC_PINCON->PINSEL3, 0x3, 30);
18 LPC_ADC->ADCR = (1 << 21) | (clock_divider << 8) |
ADC_CH5;
19
21 NVIC_EnableIRQ(ADC_IRQn);
22
24 NVIC_SetPriority(ADC_IRQn, int_priority);
25
27 {
30
33 }
34
37}
@ ADC_PM_ERR_OK
No error occurred.
@ ADC_PM_RIT_UNINIT
The ADC was initialized with the SAMPLE_WITH_RIT option, but the RIT peripheral was not initialized.
void POWER_TurnOnPeripheral(u8 bit)
Turns on a peripheral.
RIT_Error RIT_EnableJob(RIT_Job job)
Include this job in the RIT handler queue.
RIT_Error RIT_AddJob(RIT_Job job, u8 multiplier_factor)
bool RIT_IsEnabled(void)
Returns whether the RIT is counting or not.
#define RIT_NO_DIVIDER
Tells the RIT that the specified job needs to be executed at exactly the interval of interrupts chose...
#define IS_DEF_PRIORITY(prio)
#define IS_BETWEEN_EQ(value, low, hi)
#define SET_BITS(reg, value, bit)
◆ ADC_PMIsInitialized()
bool ADC_PMIsInitialized |
( |
void |
| ) |
|
◆ ADC_PMSDisableSampling()
void ADC_PMSDisableSampling |
( |
void |
| ) |
|
Definition at line 60 of file adc_pm.c.
61{
63}
#define CLR_BIT(reg, bit)
◆ initialized