The
stm_ds1103_global_initialize()
function “attaches” some data structure to theuser_data
field of the Rational Statematereport_elem
data structure.The global variable
stm_ds1103_conf_var
is of typestm_ds1103_conf
, which is defined as follows:typedef struct stm_ds1103_conf {
stm_ds1103_ADC_signal adc[20];
stm_ds1103_SLAVE_PWM_type slave_pwm_t;
stm_ds1103_SLAVE_PWM_signal slave_pwm[8];
stm_ds1103_SLAVE_DF_type slave_df_t;
stm_ds1103_SLAVE_DF_signal slave_df[4];
stm_ds1103_SLAVE_FD_signal slave_fd[4];
stm_ds1103_SLAVE_PWMD_signal slave_pwmd[4];
stm_ds1103_SLAVE_IOP_type slave_iop_t;
This data structure, defined in the file
stm_ds1103_types.h
, stores the user-defined card configuration. To change the card configuration, edit the filestm_ds1103_conf.h
(as documented within the file itself).As you can see in the
stm_ds1103_conf
structure declaration, there are 20 separately configured channels in an ADC signal. Therefore, the data structure includes an array of 20 elements of typestm_ds1103_ADC_signal
.The
stm_ds1103_ADC_signal
data structure is defined as follows:typedef struct stm_ds1103_ADC_signal {
The fields of the
stm_ds1103_ADC_signal
structure are as follows:
●type
- Points to a common part for all ADC signals. This part is used by the driver function for storing information regarding the current status of the ADC.
The relevant structure declaration is as follows:
typedef struct stm_ds1103_ADC_type {
●
●norm_const_A
andnorm_const_B
- Used for normalization of the signal. This is necessary because the card returns values between –1.0f and 1.0f only.The global variable
conf
stores lists of pointers to the I/O- mapped Rational Statemate elements. Each list stores the elements, which are mapped to the same signal type. It is used for configuration check and initialization.After pin processing, the driver calls the initialization routines. The ADC signals are initialized by the
stm_ds1103_init_ADC()
function.The following figure shows the result of the data structure allocation and attachment process performed by the initialization function.