972
edits
[unchecked revision] | [unchecked revision] |
(→Port Addresses: Added I/O Access to clarify some registers which depends on it.) |
m (Bot: Replace deprecated source tag with syntaxhighlight) |
||
Line 395:
==Example Code==
===Initialization===
<
#define PORT 0x3f8 // COM1
Line 419:
return 0;
}
</syntaxhighlight>
Notice that the initialization code above writes to [PORT + 1] twice with different values. This is once to write to the Divisor register along with [PORT + 0] and once to write to the Interrupt register as detailed in the previous section. The second write to the Line Control register [PORT + 3] clears the DLAB again as well as setting various other bits.
===Receiving data===
<
int serial_received() {
return inb(PORT + 5) & 1;
Line 434:
return inb(PORT);
}
</syntaxhighlight>
===Sending data===
<
int is_transmit_empty() {
return inb(PORT + 5) & 0x20;
Line 448:
outb(PORT,a);
}
</syntaxhighlight>
==Glossary==
|