What functions should an embedded hardware driver module usually include?

An embedded hardware driver module should usually include the following functions:

(1) Interrupt Service Routine ISR


(2) Hardware initialization
A. Modify registers and set hardware parameters (such as UART should set its baud rate, AD/DA device should set its sampling rate, etc.);
B. Write the interrupt service routine entry address into the interrupt vector table:
/* Set up the interrupt vector table */
m_myPtr = make_far_pointer(0l); /* return void far pointer void far * */
m_myPtr += ITYPE_UART; /* ITYPE_UART: uart interrupt service routine */
/* Offset relative to the first address of the interrupt vector table */
*m_myPtr = &UART _Isr; /* UART _Isr: UART interrupt service routine*/


(3) Set the CPU control line for the hardware
a. If the control line can be used as PIO (programmable I/O) and control signal, set the corresponding register inside the CPU to use it as a control signal;

b. Set the interrupt mask bit for the device inside the CPU, and set the interrupt mode (level-triggered or edge-triggered).


(4) Provide a series of operation interface functions for the device. For example, for LCD, its driver module should provide functions such as drawing pixels, lines, matrices, and displaying character dot matrix; while for real-time clock, its driver module should provide functions such as acquiring
time and setting time.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325522058&siteId=291194637