5 char sci_tx_buf[BUFFER_LEN];
6 volatile char sci_rx_buf[BUFFER_LEN];
7 volatile bool sci_have_packet;
8 volatile u8 sci_rx_buf_ptr;
11 /* assumes clock of 4.91Mhz */
12 _io_ports[M6811_BAUD] = 0x03; /* 9600 baud */
14 /* Setup character format 1 start, 8-bits, 1 stop. */
15 _io_ports[M6811_SCCR1] = 0;
17 /* Enable reciever and transmitter & rx interrupt. */
18 _io_ports[M6811_SCCR2] = M6811_RIE | M6811_TE | M6811_RE;
26 for (c = sci_tx_buf; *c; c++) {
27 /* wait for TX ready */
28 while (!(_io_ports[M6811_SCSR] & M6811_TDRE));
31 _io_ports[M6811_SCDR] = *c;
36 /* XXX FIXME we should do something about errors. nack? */
37 if (sci_have_packet) {
39 _io_ports[M6811_SCDR]; /* read it anyway */
42 sci_rx_buf[sci_rx_buf_ptr] = _io_ports[M6811_SCDR];
43 if (sci_rx_buf[sci_rx_buf_ptr] == '\n') {
44 sci_rx_buf[sci_rx_buf_ptr] = '\0';
49 if (sci_rx_buf_ptr >= BUFFER_LEN) {
50 sci_rx_buf[BUFFER_LEN] = '\0'; /* this is as much as we could fit */
56 void sci_interrupt_serial() {
59 if (_io_ports[M6811_SCSR] & M6811_RDRF) sci_rx_int();
61 if (_io_ports[M6811_SCSR] & M6811_OR)
62 _io_ports[M6811_SCDR]; /* declare it a lost cause */