00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00033
00034
00035
00036 #ifndef SCI_H
00037 #define SCI_H
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00049 typedef enum {
00050 SCIA=0,
00051 SCIB=1,
00052 SCIC=2
00053 } SCI_PORT;
00054
00056 typedef enum {
00057 ONE_STOP_BIT=0,
00058 TWO_STOP_BIT=1
00059 } SCI_STOPBIT;
00060
00063 typedef enum {
00064 ODD_PARITY=0,
00065 EVEN_PARITY=1
00066 } SCI_PARITY;
00067
00069 typedef enum {
00070 PARITY_DISABLED=0,
00071 PARITY_ENABLED=1
00072 } SCI_PARITY_ENABLE;
00073
00074
00076
00077
00078
00079
00081
00082
00083
00084
00085 void ConfigureSCI(interruptFCN,
00086 SCI_PORT SciPort, Uint32 speed, SCI_STOPBIT StopBit , SCI_PARITY parity,
00087 SCI_PARITY_ENABLE SciParityEnable, Uint16 nbit);
00088 void SciFifoInit(volatile struct SCI_REGS* sciRegs);
00089 void InitSCIGpio(SCI_PORT sciPort);
00090 void EnableSCITXInterrupt(SCI_PORT sciPort, interruptFCN, unsigned char fifoLevel);
00091 void DisableSCITXInterrupt(SCI_PORT sciPort);
00092
00093
00094
00095 static inline void SCIARxPIEAck(void);
00096 static inline void SCIATxPIEAck(void);
00097
00098 static inline void SciXmit(volatile struct SCI_REGS* sciRegs, int a);
00099 static inline void SciMsg(volatile struct SCI_REGS* sciRegs, char *msg);
00100 static inline void SendDataChar(volatile struct SCI_REGS* sciRegs, volatile char *a);
00101 static inline void SendDataCharNow(volatile struct SCI_REGS* sciRegs, volatile char *a);
00102 static inline void SendDataInt(volatile struct SCI_REGS* sciRegs, volatile Uint16 *a);
00103 static inline void SendDataIntNow(volatile struct SCI_REGS* sciRegs, volatile Uint16 *a);
00104 static inline void SendDataIQ(volatile struct SCI_REGS* sciRegs, volatile Uint32 *a);
00105 static inline void SendDataIQNow(volatile struct SCI_REGS* sciRegs, volatile Uint32 *a);
00106
00107 static inline void SciaXmit(int a);
00108 static inline void SciaMsg(char *msg);
00109 static inline void SendDataCharSciA(volatile char *a);
00110 static inline void SendDataCharSciANow(volatile char *a);
00111 static inline void SendDataIntSciA(volatile Uint16 *a);
00112 static inline void SendDataIntSciANow(volatile Uint16 *a);
00113 static inline void SendDataIQSciA(volatile Uint32 *a);
00114 static inline void SendDataIQSciANow(volatile Uint32 *a);
00115
00116 static inline void ScibXmit(int a);
00117 static inline void ScibMsg(char *msg);
00118 static inline void SendDataCharSciB(volatile char *a);
00119 static inline void SendDataCharSciBNow(volatile char *a);
00120 static inline void SendDataIntSciB(volatile Uint16 *a);
00121 static inline void SendDataIntSciBNow(volatile Uint16 *a);
00122 static inline void SendDataIQSciB(volatile Uint32 *a);
00123 static inline void SendDataIQSciBNow(volatile Uint32 *a);
00124
00125
00126
00127 static inline void SCIARxPIEAck(void)
00128 {
00129 SciaRegs.SCIFFRX.bit.RXFFOVRCLR = 1;
00130 SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1;
00131 PieCtrlRegs.PIEACK.all |= PIEACK_GROUP9;
00132 }
00133
00134
00135
00136 static inline void SCIATxPIEAck(void)
00137 {
00138 SciaRegs.SCIFFTX.bit.TXFFINTCLR = 1;
00139 PieCtrlRegs.PIEACK.all |= PIEACK_GROUP9;
00140 }
00141
00142
00143
00144 static inline void SciXmit(volatile struct SCI_REGS* sciRegs, int a)
00145 {
00146 while (sciRegs->SCIFFTX.bit.TXFFST != 0) {}
00147 sciRegs->SCITXBUF=a;
00148 }
00149
00150
00151
00152 static inline void SciMsg(volatile struct SCI_REGS* sciRegs, char *msg)
00153 {
00154 int i=0;
00155 while(msg[i] != '\0') {
00156 SciXmit(sciRegs, msg[i]);
00157 i++;
00158 }
00159 }
00160
00161
00162
00163 static inline void SendDataChar(volatile struct SCI_REGS* sciRegs, volatile char *a)
00164 {
00165
00166 while (sciRegs->SCIFFTX.bit.TXFFST != 0) {}
00167 sciRegs->SCITXBUF = *a;
00168 }
00169
00170
00171
00172 static inline void SendDataInt(volatile struct SCI_REGS* sciRegs, volatile Uint16 *a)
00173 {
00174
00175 int i;
00176 for(i=0;i<2;i++) {
00177 while (sciRegs->SCIFFTX.bit.TXFFST != 0) {}
00178 sciRegs->SCITXBUF = (*a >> 8*i & 0x00FF);
00179 }
00180 }
00181
00182
00183
00184 static inline void SendDataIQ(volatile struct SCI_REGS* sciRegs, volatile Uint32 *a)
00185 {
00186
00187 int i;
00188 for(i=0;i<4;i++) {
00189 while (sciRegs->SCIFFTX.bit.TXFFST != 0) {}
00190 sciRegs->SCITXBUF = (*a >> 8*i & 0x00FF);
00191 }
00192 }
00193
00194
00195
00196 static inline void SendDataCharNow(volatile struct SCI_REGS* sciRegs, volatile char *a)
00197 {
00198
00199 sciRegs->SCITXBUF = *a;
00200 }
00201
00202
00203
00204 static inline void SendDataIntNow(volatile struct SCI_REGS* sciRegs, volatile Uint16 *a)
00205 {
00206
00207 int i;
00208 for(i=0;i<2;i++) {
00209 sciRegs->SCITXBUF = (*a >> 8*i & 0x00FF);
00210 }
00211 }
00212
00213
00214
00215 static inline void SendDataIQNow(volatile struct SCI_REGS* sciRegs, volatile Uint32 *a)
00216 {
00217
00218 int i;
00219 for(i=0;i<4;i++) {
00220 sciRegs->SCITXBUF = (*a >> 8*i & 0x00FF);
00221 }
00222 }
00223
00224
00225
00228 static inline void SciaXmit(int a)
00229 {
00230 SciXmit(&SciaRegs,a);
00231 }
00232
00233
00234
00235
00236 static inline void SciaMsg(char * msg)
00237 {
00238 SciMsg(&SciaRegs,msg);
00239 }
00240
00241
00242
00244 static inline void SendDataCharSciA(volatile char *a)
00245 {
00246 SendDataChar(&SciaRegs, a);
00247
00248 }
00249
00250
00251
00253 static inline void SendDataIntSciA(volatile Uint16 *a)
00254 {
00255 SendDataInt(&SciaRegs, a);
00256 }
00257
00258
00259
00261 static inline void SendDataIQSciA(volatile Uint32 *a)
00262 {
00263 SendDataIQ(&SciaRegs, a);
00264 }
00265
00266
00267
00268 static inline void SendDataCharSciANow(volatile char *a)
00269 {
00270 SendDataCharNow(&SciaRegs, a);
00271 }
00272
00273
00274
00275 static inline void SendDataIntSciANow(volatile Uint16 *a)
00276 {
00277 SendDataIntNow(&SciaRegs, a);
00278 }
00279
00280
00281
00282 static inline void SendDataIQSciANow(volatile Uint32 *a)
00283 {
00284 SendDataIQNow(&SciaRegs, a);
00285 }
00286
00287
00288
00291 static inline void ScibXmit(int a)
00292 {
00293 SciXmit(&ScibRegs,a);
00294 }
00295
00296
00297
00298
00299 static inline void ScibMsg(char * msg)
00300 {
00301 SciMsg(&ScibRegs,msg);
00302 }
00303
00304
00305
00307 static inline void SendDataCharSciB(volatile char *a)
00308 {
00309 SendDataChar(&ScibRegs, a);
00310
00311 }
00312
00313
00314
00316 static inline void SendDataIntSciB(volatile Uint16 *a)
00317 {
00318 SendDataInt(&ScibRegs, a);
00319 }
00320
00321
00322
00324 static inline void SendDataIQSciB(volatile Uint32 *a)
00325 {
00326 SendDataIQ(&ScibRegs, a);
00327 }
00328
00329
00330
00331 static inline void SendDataCharSciBNow(volatile char *a)
00332 {
00333 SendDataCharNow(&ScibRegs, a);
00334 }
00335
00336
00337
00338 static inline void SendDataIntSciBNow(volatile Uint16 *a)
00339 {
00340 SendDataIntNow(&ScibRegs, a);
00341 }
00342
00343
00344
00345 static inline void SendDataIQSciBNow(volatile Uint32 *a)
00346 {
00347 SendDataIQNow(&ScibRegs, a);
00348 }
00349
00350
00351
00352 #endif
00353
00354
00355