An embedded hardware driver module should usually include the following functions:
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:
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;
time and setting time.
(1) Interrupt Service Routine ISR
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*/
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).
time and setting time.