Anonymous user
Serial Ports: Difference between revisions
m
Syntax highlighting
[unchecked revision] | [unchecked revision] |
(→Related Links: Prove and archive using webcite) |
m (Syntax highlighting) |
||
Line 160:
==Example Code==
===Initialization===
<source lang="C">
#define PORT 0x3f8 /* COM1 */
Line 172:
outb(PORT + 4, 0x0B); // IRQs enabled, RTS/DSR set
}
</
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===
<source lang="C">
int serial_received() {
return inb(PORT + 5) & 1;
Line 187:
return inb(PORT);
}
</
===Sending data===
<source lang="C">
int is_transmit_empty() {
return inb(PORT + 5) & 0x20;
Line 201:
outb(PORT,a);
}
</
==Glossary==
|