RTEMS 7.0-rc1
Loading...
Searching...
No Matches
adc-defs.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0+-with-RTEMS-exception */
2
11/*
12 * Copyright (c) 2014 Taller Technologies.
13 *
14 * @author Diaz Marcos (marcos.diaz@tallertechnologies.com)
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.org/license/LICENSE.
19 */
20#ifndef LPC176X_ADC_DEFS_H
21#define LPC176X_ADC_DEFS_H
22
23#include <bsp.h>
24#include <bsp/io.h>
25#include <bsp/lpc176x.h>
26#include <bsp/adc.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif /* __cplusplus */
31
35typedef enum {
36 ADC_0,
37 ADC_1,
38 ADC_2,
39 ADC_3,
40 ADC_4,
41 ADC_5,
42 ADC_6,
43 ADC_7,
44 ADC_DEVICES_COUNT
46
47#define MAX_ADC_CLK 13000000u
48
49#define ADC_RANGE 0xFFFu
50
51#define ADC_NUMBER_VALID( number ) ( ( (uint32_t) number ) < \
52 ADC_DEVICES_COUNT )
53
54#define ADC_CR_SEL( val ) BSP_FLD32( val, 0, 7 )
55#define ADC_CR_SEL_GET( val ) BSP_FLD32GET( val, 0, 7 )
56#define ADC_CR_SEL_SET( reg, val ) BSP_FLD32SET( reg, val, 0, 7 )
57#define ADC_CR_CLKDIV( val ) BSP_FLD32( val, 8, 15 )
58#define ADC_CR_CLKDIV_GET( reg ) BSP_FLD32GET( reg, 8, 15 )
59#define ADC_CR_CLKDIV_SET( reg, val ) BSP_FLD32SET( reg, val, 8, 15 )
60#define ADC_CR_BURST BSP_BIT32( 16 )
61#define ADC_CR_CLKS( val ) BSP_FLD32( val, 17, 19 )
62#define ADC_CR_PDN BSP_BIT32( 21 )
63#define ADC_CR_START_NOW BSP_BIT32( 24 )
64#define ADC_CR_START( val ) BSP_FLD32( val, 24, 26 )
65#define ADC_CR_EDGE BSP_BIT32( 27 )
66
67#define ADC_DR_VALUE( reg ) BSP_FLD32GET( reg, 4, 15 )
68#define ADC_DR_OVERRUN BSP_BIT32( 30 )
69#define ADC_DR_DONE BSP_BIT32( 31 )
70
71#define ADC_DATA_CONVERSION_DONE( val ) ( ( val & ADC_DR_DONE ) != 0u )
72
76typedef struct {
77 volatile uint32_t ADCR;
78 volatile uint32_t ADGDR;
79 volatile uint32_t RESERVED0;
80 volatile uint32_t ADINTEN;
81 volatile uint32_t ADDR[ ADC_DEVICES_COUNT ];
82 volatile uint32_t ADSTAT;
83 volatile uint32_t ADTRM;
85
89typedef struct {
90 uint32_t pin_number;
91 lpc176x_pin_function pin_function;
93
94#ifdef __cplusplus
95}
96#endif /* __cplusplus */
97
98#endif
lpc176x_adc_number
The ADC inputs of the board.
Definition: adc-defs.h:35
lpc176x_pin_function
Defines the functions according to the pin.
Definition: io-defs.h:70
ADC library for the lpc176x bsp.
Specific register definitions according to lpc176x family boards.
The ADC low-level device.
Definition: adc-defs.h:76
Represents the pin and function for each ADC input.
Definition: adc-defs.h:89