Main Content

Device Driver I/O Interfaces

Device drivers interact with hardware directly. They depend on characteristics of the hardware. For example, a device driver for an analog-to-digital converter initializes, reads data from, and writes data to hardware registers. Hardware differences and dependencies concern data type size, endianess, shift operations, compiler directives, and optimized function and operator support. Other application code interfaces with device drivers by using a programming interface and data mapped to specific memory addresses. Typically, simulation on a development computer is not possible. Reading from and writing to a register during simulation on a development computer produces unexpected and unwanted results.

Device drivers for communication protocols and target hardware are essential to real-time development projects. For example, you can have a working device driver that you want to integrate with algorithmic code that reads data from and writes data to an I/O device that the driver supports. The code generator can produce a single set of application source files from an algorithm model and integrated driver code.

This figure shows an application that requires integration of existing driver code for hardware devices. The core software algorithms and logic can be a combination of code modules for external reusable algorithms integrated into the Simulink environment and code generated as part of an overall model design.

Embedded system project that requires device driver support

Integrate device driver code in a component model by using one of these methods:

  • Import driver function code into a C Caller block.

  • Generate an S-function, compile and link the generated S-function, and create a mask for calling the generated S-function by using the Legacy Code Tool.

Related Topics