The
stm_ds1103_drv_ADC()
function is used by the model for I/O access. It is called at a defined polling rate. The implementation of this function should be very efficient.The
stm_ds1103_drv_ADC()
function performs the following tasks:The first 16 ADC pins of the DS1103 hardware are handled by 4 multiplexers. The function changes the multiplexer active channels as necessary. The multiplexers’ active channels are stored in the variable
active_channel
.After setting the multiplexer, the function reads the value of the specified ADC channel. The read value, which is always between –1.0f and 1.0f, is translated to the user-defined range (specified in the file
stm_ds1103_conf.c
) using two previously calculated constants. The result is stored in the Rational Statemate element data structure.