2 * sci.c controls SCI for GCC/HCS12 version of FreeRTOS Demo
\r
3 * Parts taken from the CodeWarrior Demo in order to work similar.
\r
5 * Author Jefferson L Smith, Robotronics Inc.
\r
9 #include <sys/ports.h>
\r
11 //static word SerFlag; /* Flags for serial communication */
\r
12 /* Bits: 0 - OverRun error */
\r
13 /* 1 - Framing error */
\r
14 /* 2 - Parity error */
\r
15 /* 3 - Char in RX buffer */
\r
16 /* 4 - Full TX buffer */
\r
17 /* 5 - Running int from TX */
\r
18 /* 6 - Full RX buffer */
\r
19 /* 7 - Noise error */
\r
20 /* 8 - Idle character */
\r
21 /* 9 - Break detected */
\r
23 static word PrescaleValue;
\r
24 //static byte NumMode; /* Number of selected baud mode */
\r
28 * SCI_SetBaudRateMode
\r
30 * Changes the speed (baud rate).
\r
32 byte SCI_SetBaudRateMode(byte Mod)
\r
34 // wired for 24 MHz bus --jeffs
\r
35 static const word SCI_Presc[4] = {39,78,156,313};
\r
37 if(Mod >= 4) /* Is mode in baud mode list */
\r
38 return ERR_VALUE; /* If no then error */
\r
39 //NumMode = Mod; /* New baud mode */
\r
40 PrescaleValue = SCI_Presc[Mod]; /* Prescaler in high speed mode */
\r
42 /* SCI0CR1: LOOPS=0,SCISWAI=0,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */
\r
43 SCICR1 = 0x00; /* Set the SCI configuration */
\r
44 /* SCI0SR2: ??=0,??=0,??=0,??=0,??=0,BRK13=0,TXDIR=0,RAF=0 */
\r
45 SCISR2 = 0x00; /* Set the Break Character Length and Transmitter pin data direction in Single-wire mode */
\r
46 SCISR1; /* Reset interrupt request flags */
\r
47 SCIBD = PrescaleValue; /* Set prescaler bits */
\r
48 /* SCI0CR2: SCTIE=0,TCIE=0,RIE=1,ILIE=0,TE=1,RE=1,RWU=0,SBK=0 */
\r
49 SCICR2 = 0x2c; /* Disable error interrupts */
\r
51 return ERR_OK; /* OK */
\r
57 * SCI_Init (bean AsynchroSerial)
\r
63 PrescaleValue = 39; /* Precaler in high speed mode */
\r
65 /* SCI0CR1: LOOPS=0,SCISWAI=0,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */
\r
66 SCICR1 = 0x00; /* Set the SCI configuration */
\r
67 /* SCI0SR2: ??=0,??=0,??=0,??=0,??=0,BRK13=0,TXDIR=0,RAF=0 */
\r
68 SCISR2 = 0x00; /* Set the Break Character Length and Transmitter pin data direction in Single-wire mode */
\r
69 SCISR1; /* Reset interrupt request flags */
\r
70 SCIBD = PrescaleValue; /* Set prescaler bits */
\r
71 /* SCI0CR2: SCTIE=0,TCIE=0,RIE=1,ILIE=0,TE=1,RE=1,RWU=0,SBK=0 */
\r
72 SCICR2 = 0x2c; /* Disable error interrupts */
\r