Hi guys,
I am looking an ADC driver and I found a definition that I do not understand how is expanded.
Code:
define NRF_SAADC_BASE 0x40007000UL
Code:
typedef struct { /*!< (@ 0x40007000) SAADC Structure */
__OM uint32_t TASKS_START; /*!< (@ 0x00000000) Starts the SAADC and prepares the result buffer
in RAM */
__OM uint32_t TASKS_SAMPLE; /*!< (@ 0x00000004) Takes one SAADC sample */
__OM uint32_t TASKS_STOP; /*!< (@ 0x00000008) Stops the SAADC and terminates all on-going conversions */
__OM uint32_t TASKS_CALIBRATEOFFSET; /*!< (@ 0x0000000C) Starts offset auto-calibration */
__IM uint32_t RESERVED[60];
__IOM uint32_t EVENTS_STARTED; /*!< (@ 0x00000100) The SAADC has started */
__IOM uint32_t EVENTS_END; /*!< (@ 0x00000104) The SAADC has filled up the result buffer */
} NRF_SAADC_Type; /*!< Size = 1592 (0x638)
This is the definition I do not understand. It is like creating a pointer NRF_SAADC to struct NRF_SAADC_Type and then initialize with NRF_SAADC_BASE? Could you re-write the following definition into a non-macro style function to understand how this expands?
Code:
#define NRF_SAADC ((NRF_SAADC_Type*) NRF_SAADC_BASE)
Then he accesses the NRF_SAADC_Type struct to set a specific register like this:
Code:
NRF_SAADC->INTENSET = SAADC_INTENSET_END_Msk;
Thanks Nick