source: rtems/c/src/lib/libbsp/m68k/ods68302/startup/m68302scc.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*****************************************************************************/
2/*
3  M68302 SCC Polled Driver
4
5 */
6/*****************************************************************************/
7
8#include <bsp.h>
9#include <rtems/m68k/m68302.h>
10#include <m68302scc.h>
11
12#define M68302_SCC_COUNT (3)
13
14static volatile m302_SCC_t *scc[M68302_SCC_COUNT] = { 0, 0, 0 };
15static volatile m302_SCC_Registers_t *scc_reg[M68302_SCC_COUNT] = { 0, 0, 0 };
16static int scc_translate[M68302_SCC_COUNT] = { 0, 0, 0 };
17
18static const uint16_t         baud_clocks[] =
19{
20  (SYSTEM_CLOCK / (  4800 * 16)),
21  (SYSTEM_CLOCK / (  9600 * 16)),
22  (SYSTEM_CLOCK / ( 19200 * 16)),
23  (SYSTEM_CLOCK / ( 38400 * 16)),
24  (SYSTEM_CLOCK / ( 57600 * 16)),
25  (SYSTEM_CLOCK / (115700 * 16))
26};
27
28void scc_initialise(int channel, int baud, int translate)
29{
30  uint16_t         scon;
31
32  if (channel < M68302_SCC_COUNT)
33  {
34    scc[channel] = &m302.scc1 + channel;
35    scc_reg[channel] = &m302.reg.scc[channel];
36    scc_translate[channel] = translate;
37
38    scon  = (baud_clocks[baud] & 0xF800) == 0 ? 0 : 1;
39    scon |= (((baud_clocks[baud] / (1 + scon * 3)) - 1) << 1) & 0x0FFE;
40
41    scc_reg[channel]->scon = scon;
42    scc_reg[channel]->scm = 0x0171;
43
44    scc[channel]->bd.tx[0].status = 0x2000;
45    scc[channel]->bd.tx[0].length = 0;
46    scc[channel]->bd.tx[0].buffer =
47      (uint8_t*) &(scc[channel]->bd.tx[1].buffer);
48
49    scc[channel]->bd.rx[0].status = 0x2000;
50    scc[channel]->bd.rx[0].length = 0;
51    scc[channel]->bd.rx[0].buffer =
52      (uint8_t*) &(scc[channel]->bd.rx[1].buffer);
53
54    scc[channel]->parm.rfcr = 0x50;
55    scc[channel]->parm.tfcr = 0x50;
56
57    scc[channel]->parm.mrblr = 0x0001;
58    scc[channel]->prot.uart.max_idl = 0x0004;
59    scc[channel]->prot.uart.brkcr = 1;
60    scc[channel]->prot.uart.parec = 0;
61    scc[channel]->prot.uart.frmec = 0;
62    scc[channel]->prot.uart.nosec = 0;
63    scc[channel]->prot.uart.brkec = 0;
64    scc[channel]->prot.uart.uaddr1 = 0;
65    scc[channel]->prot.uart.uaddr2 = 0;
66    scc[channel]->prot.uart.character[0] = 0x0003;
67    scc[channel]->prot.uart.character[1] = 0x8000;
68
69    scc_reg[channel]->scce = 0xFF;
70    scc_reg[channel]->sccm = 0x15;
71
72    scc_reg[channel]->scm = 0x17d;
73  }
74}
75
76unsigned char scc_status(int channel, unsigned char status)
77{
78  uint16_t         rx_status;
79
80  m302.reg.wcn = 0;
81
82  if ((channel < M68302_SCC_COUNT) && scc[channel])
83  {
84    rx_status = scc[channel]->bd.rx[0].status;
85
86    if ((rx_status & 0x8000) == 0)
87    {
88      if (rx_status & 0x003B)
89      {
90        return 2;
91      }
92      if (status == 0)
93      {
94        return 1;
95      }
96    }
97  }
98
99  return 0;
100}
101
102unsigned char scc_in(int channel)
103{
104  m302.reg.wcn = 0;
105
106  if ((channel < M68302_SCC_COUNT) && scc[channel])
107  {
108    if ((scc[channel]->bd.rx[0].status & 0x8000) == 0)
109    {
110      unsigned char c;
111
112      c = *(scc[channel]->bd.rx[0].buffer);
113
114      scc[channel]->bd.rx[0].status = 0xa000;
115
116      return c;
117    }
118  }
119
120  return 0;
121}
122
123void scc_out(int channel, unsigned char character)
124{
125  if ((channel < M68302_SCC_COUNT) && scc[channel])
126  {
127    do
128    {
129      m302.reg.wcn = 0;
130    }
131    while (scc[channel]->bd.tx[0].status & 0x8000);
132
133    *(scc[channel]->bd.tx[0].buffer) = character;
134
135    scc[channel]->bd.tx[0].length = 1;
136    scc[channel]->bd.tx[0].status = 0xa000;
137
138    if (scc_translate[channel])
139    {
140      if (character == '\n')
141      {
142        scc_out(channel, '\r');
143      }
144    }
145  }
146}
Note: See TracBrowser for help on using the repository browser.