Hilscher netX microcontroller driver
V0.0.5.0
Documentation of the netX driver package
|
This is the ADC driver, defined by DRV_ADC_HANDLE_T. More...
Data Structures | |
struct | DRV_ADC_SEQ_MEAS_T |
Measurement structure. More... | |
struct | DRV_ADC_SEQ_BUFFER_T |
Structure for the buffers used for the sequencers data io. More... | |
struct | DRV_ADC_STATE_T |
Structure containing the state of the adc sequencer. More... | |
struct | DRV_ADC_SEQ_CONFIGURATION_T |
The configuration of the driver. More... | |
struct | DRV_ADC_STATIC_CFG_T |
Type definition of the separate ADC configuration structure. More... | |
struct | DRV_ADC_SEQ_HANDLE_T |
The handle of the ADC driver. More... | |
struct | DRV_ADC_CONFIGURATION_T |
The configuration of the driver. More... | |
struct | DRV_ADC_HANDLE_T |
The handle of the driver. More... | |
Macros | |
#define | DRV_ADC_CONFIG_DEFAULT |
Default parameter for the initialization of DRV_ADC_CONFIGURATION_T. More... | |
#define | DRV_ADC_SEQ_MEAS_CONFIG_DEFAULT |
Default parameter for the initialization of DRV_ADC_MEAS_CONFIGURATION_T. More... | |
#define | DRV_ADC_SEQ_CONFIG_DEFAULT |
Default parameter for the initialization of DRV_ADC_SEQ_CONFIGURATION_T. More... | |
#define | DRV_ADC_SEQ_CATCHED_NO_RESULT 0xffff |
Result was not accessible after the measurement. More... | |
#define | DRV_ADC_INITIALIZER (DRV_ADC_HANDLE_T){0, {0, 0, 0, 0}, DRV_ADC_CONFIG_DEFAULT, DRV_LOCK_INITIALIZER_VALUE} |
Default settings for adc device driver. More... | |
#define | DRV_ADC_SEQ_INITIALIZER (DRV_ADC_SEQ_HANDLE_T){0, 0, DRV_ADC_SEQ_CONFIG_DEFAULT, DRV_LOCK_INITIALIZER_VALUE, {0, 0, 0, 0, 0, 0}} |
Default settings for adc sequencer. More... | |
#define | DRV_ACD_IRQHandler_Generator(id, _) DRV_Default_IRQHandler_Function_Generator(MADC ## id ## _IRQHandler ,DRV_ACD_IRQ_Inline_Handler,DRV_ADC_SEQ_DEVICE_ID_ADC ## id) |
Typedefs | |
typedef struct DRV_ADC_SEQ_HANDLE_Ttag | DRV_ADC_SEQ_HANDLE_T |
Type definition of the adc sequencer handle structure. More... | |
typedef struct DRV_ADC_HANDLE_Ttag | DRV_ADC_HANDLE_T |
Type definition of the adc handle structure. More... | |
Variables | |
static DRV_ADC_DEVICE_T *const | s_apDeviceAddressTable [DRV_ADC_DEVICE_COUNT] = DRV_ADC_DEVICE_LIST |
Table of the device addresses. More... | |
static DRV_ADC_SEQ_DEVICE_T *const | s_apSubDeviceAddressTable [DRV_ADC_SEQ_DEVICE_COUNT] = DRV_ADC_SEQ_DEVICE_LIST |
Table of the sequencer addresses. More... | |
static IRQn_Type const | s_apHandleIRQnTable [DRV_ADC_SEQ_DEVICE_COUNT] = DRV_ADC_SEQ_DEVICE_IRQ_LIST |
Table of the IRQ vector numbers. More... | |
static DRV_ADC_SEQ_HANDLE_T * | s_apHandleAddressTable [DRV_ADC_SEQ_DEVICE_COUNT] = { 0 } |
Used for mapping the handle to an interrupt. More... | |
This is the ADC driver, defined by DRV_ADC_HANDLE_T.
The ADC driver is used to interact with the ADC hardware component. The driver is a set of convenience functions to interact with the devices registers.
There are severeal applications of the adc that come to mind.
As every other driver component of the package a context object has to be created first. This objects configuration has to be modified for the task ahead and then the device will be initialized by calling the initialize function on the context.
#define DRV_ACD_IRQHandler_Generator | ( | id, | |
_ | |||
) | DRV_Default_IRQHandler_Function_Generator(MADC ## id ## _IRQHandler ,DRV_ACD_IRQ_Inline_Handler,DRV_ADC_SEQ_DEVICE_ID_ADC ## id) |
Definition at line 1152 of file netx_drv_adc.c.
#define DRV_ADC_CONFIG_DEFAULT |
Default parameter for the initialization of DRV_ADC_CONFIGURATION_T.
Definition at line 45 of file netx_drv_adc.h.
#define DRV_ADC_INITIALIZER (DRV_ADC_HANDLE_T){0, {0, 0, 0, 0}, DRV_ADC_CONFIG_DEFAULT, DRV_LOCK_INITIALIZER_VALUE} |
Default settings for adc device driver.
Use this define for initialize the adc driver structure with default values.
Definition at line 104 of file netx_drv_adc.h.
#define DRV_ADC_SEQ_CATCHED_NO_RESULT 0xffff |
Result was not accessible after the measurement.
Possible reason is that the next measurement has already over written the result, before the callback or the irq had the chance to save it.
Definition at line 97 of file netx_drv_adc.h.
#define DRV_ADC_SEQ_CONFIG_DEFAULT |
Default parameter for the initialization of DRV_ADC_SEQ_CONFIGURATION_T.
Definition at line 67 of file netx_drv_adc.h.
#define DRV_ADC_SEQ_INITIALIZER (DRV_ADC_SEQ_HANDLE_T){0, 0, DRV_ADC_SEQ_CONFIG_DEFAULT, DRV_LOCK_INITIALIZER_VALUE, {0, 0, 0, 0, 0, 0}} |
Default settings for adc sequencer.
Use this define for initialize the adc sequencer structure with default values.
Definition at line 111 of file netx_drv_adc.h.
#define DRV_ADC_SEQ_MEAS_CONFIG_DEFAULT |
Default parameter for the initialization of DRV_ADC_MEAS_CONFIGURATION_T.
Definition at line 57 of file netx_drv_adc.h.
typedef struct DRV_ADC_HANDLE_Ttag DRV_ADC_HANDLE_T |
Type definition of the adc handle structure.
Definition at line 501 of file netx_drv_adc.h.
typedef struct DRV_ADC_SEQ_HANDLE_Ttag DRV_ADC_SEQ_HANDLE_T |
Type definition of the adc sequencer handle structure.
Definition at line 496 of file netx_drv_adc.h.
enum DRV_ADC_CLK_PERIOD_E |
Max value of global ADC synchronization counter:
ADCs running at same adcclk might interfere. Therefore the ADCs should be able to run in different clk-phases. Adcclk generation will be done within the ADC sequencers. This value is used to configure a global counter for clock phase reference. It's value should be the same or an natural numbered multiple of the value configured in ADC sequencers.
Enumerator | |
---|---|
DRV_ADC_CLK_PERIOD_DEFAULT |
The default value. |
DRV_ADC_CLK_PERIOD_MIN |
Min value for boundary checks. |
DRV_ADC_CLK_PERIOD_MAX |
Max value for boundary checks. |
Definition at line 372 of file netx_drv_adc.h.
enum DRV_ADC_DEADTIME_E |
Dead time delay configuration of the ADCs.
Delay in steps of system clock (10ns) between Dead Time EVenT from PWM module and trigger. In case of 2nd DTEVT within delay time, the second DTEVT will be lost.
Enumerator | |
---|---|
DRV_ADC_DEADTIME_DEFAULT |
Dead time delay of 100ns (Default). |
DRV_ADC_DEADTIME_MIN |
Min value for boundary checks. |
DRV_ADC_DEADTIME_MAX |
Max value for boundary checks. |
Definition at line 424 of file netx_drv_adc.h.
enum DRV_ADC_POWER_DOWN_E |
Power-down mode configuration of the ADCs.
Definition at line 410 of file netx_drv_adc.h.
The copy engine only uses 32bit addresses and DWord access. This mode wastes memory but speeds up the copy by not running read-modify-write cycles. If deactivated, the default 16bit addresses and Word access is used.
Definition at line 160 of file netx_drv_adc.h.
Base address for writing the measurement results.
Word (16 bit) aligned address, LSB is ignored. In case of DRV_ADC_SEQ_32Bit_MODE_ENABLED, bit 1 will be ignored.
Enumerator | |
---|---|
DRV_ADC_SEQ_BASE_ADDRESS_MIN |
Min value for boundary checks. |
DRV_ADC_SEQ_BASE_ADDRESS_MAX |
Max value for boundary checks. |
Definition at line 359 of file netx_drv_adc.h.
ADC sample extension for input channel 0.
Length of 2nd adcclk in steps of 10ns system clock(~ delay of 3rd adcclk edge). The capacitor inside ADC needs time to be charged depending on the driving strength of the external signal. For 12 bit precision, this time should be 9*(Rint+Rext)*C, with Rint=1kOhm and C=7.5pF. The total formula for this value is: tt_add = ceil((6,75 x Rext/kOhm) + 6,75) - adcclk_period/10ns - 2 Set tt_add=4 if calculated value is smaller 4. The total ADC cycle time results in: tcycle = 14 * adcclk_period + clock_sync_delay (max 1 adcclk_period) + tt_add * 10ns.
Definition at line 225 of file netx_drv_adc.h.
Duration of an adcclk period in system clock cycles-1.
Enumerator | |
---|---|
DRV_ADC_SEQ_CLK_PERIOD_DEFAULT |
Default setting of the device. |
DRV_ADC_SEQ_CLK_PERIOD_MIN |
Min value for boundary checks. |
DRV_ADC_SEQ_CLK_PERIOD_MAX |
Max value for boundary checks. |
Definition at line 207 of file netx_drv_adc.h.
Generation of the rising edge of the adcclk is delayed until the global clk_phase counter matches this value. NOTE: The rising edge of the adcclk ending the first sample period of a triggered measurement is NEVER delayed.
Enumerator | |
---|---|
DRV_ADC_SEQ_CLK_PHASE_DEFAULT |
Default setting of the device. |
DRV_ADC_SEQ_CLK_PHASE_MIN |
Min value for boundary checks. |
DRV_ADC_SEQ_CLK_PHASE_MAX |
Max value for boundary checks . |
Definition at line 195 of file netx_drv_adc.h.
Synchronization of the adc clocks.
Definition at line 182 of file netx_drv_adc.h.
Continuous or Single Shot mode of the device and api.
Definition at line 345 of file netx_drv_adc.h.
The adc sequencer device IDs.
They are used to identify the adc sequencer devices in the driver context.
Definition at line 118 of file netx_drv_adc.h.
Enable or Disable the DMA mode.
If DMA mode disabled, results are not written to memory and can only access by the result register.
Definition at line 148 of file netx_drv_adc.h.
Address offset specified in 16 bit words where the sum will be stored.
In case of DRV_ADC_SEQ_32Bit_MODE_ENABLED, this value will be interpreted as 32-bit address.
Enumerator | |
---|---|
DRV_ADC_SEQ_BASE_ADR_OFFSET_NONE |
None address offset. |
DRV_ADC_SEQ_BASE_ADR_OFFSET_MIN |
Min value for boundary checks. |
DRV_ADC_SEQ_BASE_ADR_OFFSET_MAX |
Max value for boundary checks. |
Definition at line 267 of file netx_drv_adc.h.
Enable measurement configuration.
A measurement sequence consists of up to 8 measurements
Definition at line 254 of file netx_drv_adc.h.
Input channel multiplexer setting.
The input multiplexer will always be set 1 system clock (10ns) before SOF. It will be reset after sampling to ensure a not-connected phase at the one-hot-coded multiplexer switches.
Definition at line 280 of file netx_drv_adc.h.
Number of samples minus one to sum for this measurement i.e. 0:sum 1 samples, 1:sum 2 samples, ...
Definition at line 297 of file netx_drv_adc.h.
Trigger condition for measurement.
Definition at line 314 of file netx_drv_adc.h.
Measurements of the sequencer.
Definition at line 235 of file netx_drv_adc.h.
Use core voltage of 3.3V as reference or use Vref of the adc (which can be external or 2.6V).
Definition at line 171 of file netx_drv_adc.h.
enum DRV_ADC_SOFT_RESET_E |
Soft-Reset configuration of the ADCs.
Definition at line 399 of file netx_drv_adc.h.
The enumeration for the available measurements.
Definition at line 382 of file netx_drv_adc.h.
Use internal 2.6V reference:
This mode requires an external capacitor at pin ADC_VREF, which will be driven to 2.6V from internal vref_buffer. To enable this mode set this bit to 1 and static_cfg-vref=0 inside the related MADC_SEQ module. Use external reference: Use any external reference voltage (<3.3V) at pin ADC_VREF. To enable this mode set this bit to 0 and static_cfg-vref=0 inside the related MADC_SEQ module.
Definition at line 135 of file netx_drv_adc.h.
|
private |
This function is the true interrupt service routine or interrupt handler of the ADC device interrupts. The interrupt handlers called by the controller should inline this handler and the constant eDeviceID should define the specific device in compile time. For debug and development purposes a check of the pointers is performed in front that is not necessary for release. It is necessary because a debugger stopped controller does not perform a reset of the interrupt vector and so the ISR shall cope with the not initialized handle pointer.
[in,out] | eDeviceID | The given id of the drivers class |
Definition at line 1111 of file netx_drv_adc.c.
|
private |
In-line function for save the result of a single measurement and if necessary, execute the corresponding callback.
[in] | ptSequencer | ADC sequencer |
[in] | eMeasurement | The number of completed measurement |
Definition at line 1049 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Driver_DeInit | ( | DRV_ADC_HANDLE_T *const | ptDriver | ) |
Deinitializes the adc device and handle.
Deinitializes the adc driver device and handle.
[in] | ptDriver | Handle of ADC driver |
Definition at line 154 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Driver_Init | ( | DRV_ADC_HANDLE_T *const | ptDriver | ) |
Initializes the adc device and handle by the given configuration.
The function takes a DRV_SPI_HANDLE_T pointer which contains a DRV_ADC_ATTRIBUTES_T structure.
[in] | ptDriver | Handle of ADC driver |
Definition at line 88 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Seq_DeInit | ( | DRV_ADC_SEQ_HANDLE_T *const | ptSequencer | ) |
Deinitializes the adc sequencer and its handle.
Deinitializes the adc sequencer device and handle.
[in] | ptSequencer | Handle of ADC sequencer |
Definition at line 612 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Seq_GetLastSample | ( | DRV_ADC_SEQ_HANDLE_T *const | ptSequencer, |
uint32_t *const | pulSample, | ||
uint8_t *const | pbMeasNr | ||
) |
Stores the last sample of the the given adc.
Get the last acquired sample of the the given adc.
[in] | ptSequencer | Handle of ADC sequencer |
[out] | pulSample | Value of the last sample |
[out] | pbMeasNr | Number of measurement |
Definition at line 960 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Seq_GetSample | ( | DRV_ADC_SEQ_HANDLE_T *const | ptSequencer, |
uint32_t *const | pulSample, | ||
uint8_t *const | pbMeasNr | ||
) |
Stores the current acquired sample of the the given adc.
Get the acquired sample of the the given adc. It may be that the retrieved value is not the final result, but only an intermediate value. In this case the return value is DRV_BUSY instead of DRV_OK.
[in] | ptSequencer | Handle of ADC sequencer |
[out] | pulSample | Value of the current sample |
[out] | pbMeasNr | Number of measurement |
Definition at line 912 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Seq_GetState | ( | DRV_ADC_SEQ_HANDLE_T *const | ptSequencer, |
DRV_ADC_STATE_T *const | ptState | ||
) |
Aquires the state of the given adc sequencer.
Aquires the state of the given adc sequencer.
[in] | ptSequencer | Handle of ADC sequencer |
[out] | ptState | State of the ADC sequencer |
Definition at line 874 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Seq_Init | ( | DRV_ADC_SEQ_HANDLE_T *const | ptSequencer, |
DRV_ADC_HANDLE_T *const | ptDriver | ||
) |
Initializes the adc sequencer and its handle by the given configuration.
Initializes the adc sequencer and its handle by the given configuration..
[in] | ptSequencer | Handle of the ADC sequencer |
[in] | ptDriver | Handle of ADC driver |
Definition at line 409 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Seq_Meas_ChangeConfig | ( | DRV_ADC_SEQ_HANDLE_T *const | ptSequencer, |
DRV_ADC_SEQ_MEASUREMENT_E | eMeasurement, | ||
DRV_ADC_SEQ_MEAS_INPUT_CHANNEL_E | eInputChannel, | ||
DRV_ADC_SEQ_MEAS_OVERSAMPLING_E | eOversampling, | ||
DRV_ADC_SEQ_MEAS_TRIGGER_E | eTrigger | ||
) |
Changes the parameters of the given adc sequencer measurement.
Changes the parameters of the given adc sequencer measurement.
[in] | ptSequencer | Handle of ADC sequencer |
[in] | eMeasurement | Measurement |
[in] | eInputChannel | Input channel multiplexer setting |
[in] | eOversampling | Number of samples minus one to sum for this measurement |
[in] | eTrigger | Trigger condition for measurement |
Definition at line 781 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Seq_Reset | ( | DRV_ADC_SEQ_HANDLE_T *const | ptSequencer | ) |
Reset the given adc sequencer.
Reset the given adc sequencer.
[in] | ptSequencer | Handle of ADC sequencer |
Definition at line 752 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Seq_SetMode | ( | DRV_ADC_SEQ_HANDLE_T *const | ptSequencer, |
DRV_ADC_SEQ_CONTINUOUS_MODE_E | eMode | ||
) |
Set mode of the sequencer.
set mode of the sequencer.
[in] | ptSequencer | Handle of ADC sequencer |
[in] | eMode | Sequencer mode |
Definition at line 648 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Seq_SetSampleSeriesBuffer | ( | DRV_ADC_SEQ_HANDLE_T *const | ptSequencer, |
uint16_t * | pulSampleSeries, | ||
size_t | tSize, | ||
DRV_CALLBACK_F | fnCallback, | ||
void * | pUser | ||
) |
Stores a series of aquired sample of the given adc.
Set a buffer memory to record a series of samples This function do automatically enable the buffer and after next start of the sequencer, every recored sample will stored continuously into the buffer area. The buffer works like a ring buffer. After every round of filling the buffer, it is possible to execute a callback. Reseting the sequencer will deactivate the buffer. The buffer only works together with the interrupt mode. The buffer memory is word based. (2bytes need for every sample)
[in] | ptSequencer | Handle of ADC sequencer |
[out] | pulSampleSeries | Pointer to the sample buffer |
[in] | tSize | Size of buffer in byte |
[in] | fnCallback | the users callback function |
[in] | pUser | pointer to user resources to pass through |
Definition at line 1015 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Seq_Start | ( | DRV_ADC_SEQ_HANDLE_T *const | ptSequencer | ) |
Starts the given adc sequencer.
Starts the given adc sequencer.
[in] | ptSequencer | Handle of ADC sequencer |
Definition at line 678 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Seq_Stop | ( | DRV_ADC_SEQ_HANDLE_T *const | ptSequencer | ) |
Stops the given adc sequencer.
Stops the given adc sequencer.
[in] | ptSequencer | Handle of ADC sequencer |
Definition at line 723 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Start | ( | DRV_ADC_HANDLE_T *const | ptDriver, |
DRV_ADC_SEQ_DEVICE_MSK_E | eSequencerMask | ||
) |
Starts the sequencers given by the mask (software trigger).
Starts the sequencers given by the mask (software trigger). Not configured sequencers will be ignored.
[in] | ptDriver | Handle of ADC driver |
[in] | eSequencerMask | Mask of sequencers to start |
Definition at line 183 of file netx_drv_adc.c.
DRV_STATUS_E DRV_ADC_Stop | ( | DRV_ADC_HANDLE_T *const | ptDriver, |
DRV_ADC_SEQ_DEVICE_MSK_E | eSequencerMask | ||
) |
Stops the sequencers given by the mask.
Stops the sequencers given by the mask.
[in] | ptDriver | Handle of ADC driver |
[in] | eSequencerMask | Mask of sequencers to stop |
Definition at line 338 of file netx_drv_adc.c.
|
static |
Table of the device addresses.
Used to identify the device addresses by the device id.
Definition at line 55 of file netx_drv_adc.c.
|
static |
Used for mapping the handle to an interrupt.
Threadsafe and reentrant because its is only written in normal context an used in interrupt context of the specific interrupt.
Definition at line 76 of file netx_drv_adc.c.
|
static |
Table of the IRQ vector numbers.
Used to identify the interrupt channels by the device id.
Definition at line 69 of file netx_drv_adc.c.
|
static |
Table of the sequencer addresses.
Used to identify the sequencer addresses by the sequencer id.
Definition at line 62 of file netx_drv_adc.c.