File indexing completed on 2025-05-11 08:23:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef LPC176X_ADC_DEFS_H
0019 #define LPC176X_ADC_DEFS_H
0020
0021 #include <bsp.h>
0022 #include <bsp/io.h>
0023 #include <bsp/lpc176x.h>
0024 #include <bsp/adc.h>
0025
0026 #ifdef __cplusplus
0027 extern "C" {
0028 #endif
0029
0030
0031
0032
0033 typedef enum {
0034 ADC_0,
0035 ADC_1,
0036 ADC_2,
0037 ADC_3,
0038 ADC_4,
0039 ADC_5,
0040 ADC_6,
0041 ADC_7,
0042 ADC_DEVICES_COUNT
0043 } lpc176x_adc_number;
0044
0045 #define MAX_ADC_CLK 13000000u
0046
0047 #define ADC_RANGE 0xFFFu
0048
0049 #define ADC_NUMBER_VALID( number ) ( ( (uint32_t) number ) < \
0050 ADC_DEVICES_COUNT )
0051
0052 #define ADC_CR_SEL( val ) BSP_FLD32( val, 0, 7 )
0053 #define ADC_CR_SEL_GET( val ) BSP_FLD32GET( val, 0, 7 )
0054 #define ADC_CR_SEL_SET( reg, val ) BSP_FLD32SET( reg, val, 0, 7 )
0055 #define ADC_CR_CLKDIV( val ) BSP_FLD32( val, 8, 15 )
0056 #define ADC_CR_CLKDIV_GET( reg ) BSP_FLD32GET( reg, 8, 15 )
0057 #define ADC_CR_CLKDIV_SET( reg, val ) BSP_FLD32SET( reg, val, 8, 15 )
0058 #define ADC_CR_BURST BSP_BIT32( 16 )
0059 #define ADC_CR_CLKS( val ) BSP_FLD32( val, 17, 19 )
0060 #define ADC_CR_PDN BSP_BIT32( 21 )
0061 #define ADC_CR_START_NOW BSP_BIT32( 24 )
0062 #define ADC_CR_START( val ) BSP_FLD32( val, 24, 26 )
0063 #define ADC_CR_EDGE BSP_BIT32( 27 )
0064
0065 #define ADC_DR_VALUE( reg ) BSP_FLD32GET( reg, 4, 15 )
0066 #define ADC_DR_OVERRUN BSP_BIT32( 30 )
0067 #define ADC_DR_DONE BSP_BIT32( 31 )
0068
0069 #define ADC_DATA_CONVERSION_DONE( val ) ( ( val & ADC_DR_DONE ) != 0u )
0070
0071
0072
0073
0074 typedef struct {
0075 volatile uint32_t ADCR;
0076 volatile uint32_t ADGDR;
0077 volatile uint32_t RESERVED0;
0078 volatile uint32_t ADINTEN;
0079 volatile uint32_t ADDR[ ADC_DEVICES_COUNT ];
0080 volatile uint32_t ADSTAT;
0081 volatile uint32_t ADTRM;
0082 } lpc176x_adc_device;
0083
0084
0085
0086
0087 typedef struct {
0088 uint32_t pin_number;
0089 lpc176x_pin_function pin_function;
0090 } lpc176x_adc_pin_map;
0091
0092 #ifdef __cplusplus
0093 }
0094 #endif
0095
0096 #endif