]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/HCS12_GCC_banked/sci.c
Update version number in readiness for V10.3.0 release. Sync SVN with reviewed releas...
[freertos] / FreeRTOS / Demo / HCS12_GCC_banked / sci.c
1 /** \r
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
4  *\r
5  * Author Jefferson L Smith, Robotronics Inc.\r
6  */\r
7 \r
8 #include "sci.h"\r
9 #include <sys/ports.h>\r
10 \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
22                                        /*      10 - Unused */\r
23 static word PrescaleValue;\r
24 //static byte NumMode;                   /* Number of selected baud mode */\r
25 \r
26 \r
27 /**\r
28  * SCI_SetBaudRateMode\r
29  *\r
30  * Changes the speed (baud rate).\r
31  */\r
32 byte SCI_SetBaudRateMode(byte Mod)\r
33 {\r
34   // wired for 24 MHz bus --jeffs\r
35   static const word SCI_Presc[4] = {39,78,156,313};\r
36 \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
41 \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
50 \r
51   return ERR_OK;                       /* OK */\r
52 }\r
53 \r
54 #if 0  //(not used)\r
55 \r
56 /**\r
57  * SCI_Init (bean AsynchroSerial)\r
58  *\r
59  * This enables SCI.\r
60  */\r
61 void SCI_Init(void)\r
62 {\r
63   PrescaleValue = 39;                      /* Precaler in high speed mode */\r
64 \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
73 }\r
74 #endif\r
75 \r