User`s guide
Implementing Device Drivers
10-9
- Reading values from an I/O device and assigning these values to the
block’s output vector
y (ifitisanADC)
- Writing values from the block’s input vector
u,toanI/Odevice(ifitisa
DAC)
• Terminating the program (e.g., zeroing the DAC outputs)
Required Functions
The S-function API requires you to define these functions:
• Functions called during initialization
mdlInitializeSizes
mdlInitializeSampleTimes
mdlInitializeConditions
• Function called to calculate block outputs
mdlOutputs
• Function called to reset the hardware when the program terminates
mdlTerminate
The sections that follow describe how to implement these functions.
S-Function File Format
S-functions also require certain defined values and include files. The diagram
on the next page illustrates the format of a device driver S-function.