]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - include/sci.h
Rewritten for using one task and direct usage of interrupts
[pes-rpp/rpp-test-sw.git] / include / sci.h
1 /** @file sci.h\r
2 *   @brief SCI Driver Definition File\r
3 *   @date 15.Mar.2012\r
4 *   @version 03.01.00\r
5 *   \r
6 */\r
7 \r
8 /* (c) Texas Instruments 2009-2012, All rights reserved. */\r
9 \r
10 \r
11 #ifndef __SCI_H__\r
12 #define __SCI_H__\r
13 \r
14 #include "sys_common.h"\r
15 #include "gio.h"\r
16 \r
17 \r
18 /** @enum sciIntFlags\r
19 *   @brief Interrupt Flag Definitions\r
20 *\r
21 *   Used with sciEnableNotification, sciDisableNotification\r
22 */\r
23 enum sciIntFlags\r
24 {\r
25     SCI_FE_INT    = 0x04000000,  /* framming error */\r
26     SCI_OE_INT    = 0x02000000,  /* overrun error */\r
27     SCI_PE_INT    = 0x01000000,  /* parity error */\r
28     SCI_RX_INT    = 0x00000200,  /* receive buffer ready */\r
29     SCI_TX_INT    = 0x00000100,  /* transmit buffer ready */\r
30     SCI_WAKE_INT  = 0x00000002,  /* wakeup */\r
31     SCI_BREAK_INT = 0x00000001   /* break detect */\r
32 };\r
33 \r
34 \r
35 /** @struct sciBase\r
36 *   @brief SCI Register Definition\r
37 *\r
38 *   This structure is used to access the SCI module egisters.\r
39 */\r
40 /** @typedef sciBASE_t\r
41 *   @brief SCI Register Frame Type Definition\r
42 *\r
43 *   This type is used to access the SCI Registers.\r
44 */\r
45 \r
46 enum sciPinSelect\r
47 {\r
48     PIN_SCI_TX = 0,\r
49     PIN_SCI_RX = 1\r
50 };\r
51 \r
52 /** @struct sciBase\r
53 *   @brief SCI Base Register Definition\r
54 *\r
55 *   This structure is used to access the SCI module egisters.\r
56 */\r
57 /** @typedef sciBASE_t\r
58 *   @brief SCI Register Frame Type Definition\r
59 *\r
60 *   This type is used to access the SCI Registers.\r
61 */\r
62 typedef volatile struct sciBase\r
63 {\r
64     uint32_t GCR0;          /**< 0x0000 Global Control Register 0 */\r
65     uint32_t GCR1;          /**< 0x0004 Global Control Register 1 */\r
66     uint32_t GCR2;          /**< 0x0008 Global Control Register 2 */\r
67     uint32_t SETINT;        /**< 0x000C Set Interrupt Enable Register */\r
68     uint32_t CLRINT;        /**< 0x0010 Clear Interrupt Enable Register */\r
69     uint32_t SETINTLVL;     /**< 0x0014 Set Interrupt Level Register */\r
70     uint32_t CLRINTLVL;     /**< 0x0018 Set Interrupt Level Register */\r
71     uint32_t FLR;           /**< 0x001C Interrupt Flag Register */\r
72     uint32_t INTVECT0;      /**< 0x0020 Interrupt Vector Offset 0 */\r
73     uint32_t INTVECT1;      /**< 0x0024 Interrupt Vector Offset 1 */\r
74     uint32_t LENGTH;        /**< 0x0028 Format Control Register */\r
75     uint32_t BAUD;          /**< 0x002C Baud Rate Selection Register */\r
76 #if ((__little_endian__ == 1) || (__LITTLE_ENDIAN__ == 1))\r
77     uint8_t ED;       /**< 0x0033 Emulation Register */\r
78     uint32_t : 24U;\r
79     uint8_t RD;       /**< 0x0037 Receive Data Buffer */\r
80     uint32_t : 24U;\r
81     uint8_t TD;       /**< 0x003B Transmit Data Buffer */\r
82     uint32_t : 24U;  \r
83 #else\r
84     uint32_t : 24U;\r
85     uint8_t ED;       /**< 0x0033 Emulation Register */\r
86     uint32_t : 24U;\r
87     uint8_t RD;       /**< 0x0037 Receive Data Buffer */\r
88     uint32_t : 24U;\r
89     uint8_t TD;       /**< 0x003B Transmit Data Buffer */\r
90 #endif\r
91     uint32_t FUN;           /**< 0x003C Pin Function Register */\r
92     uint32_t DIR;           /**< 0x0040 Pin Direction Register */\r
93     uint32_t DIN;           /**< 0x0044 Pin Data In Register */\r
94     uint32_t DOUT;          /**< 0x0048 Pin Data Out Register */\r
95     uint32_t SET;           /**< 0x004C Pin Data Set Register */\r
96     uint32_t CLR;           /**< 0x0050 Pin Data Clr Register */\r
97     uint32_t ODR;           /**< 0x0054: Pin Open Drain Output Enable Register */\r
98     uint32_t PD;            /**< 0x0058: Pin Pullup/Pulldown Disable Register */\r
99     uint32_t PSL;           /**< 0x005C: Pin Pullup/Pulldown Selection Register */\r
100     uint32_t  : 32U;        /**< 0x060: Reserved                               */\r
101     uint32_t  : 32U;        /**< 0x064: Reserved                               */\r
102     uint32_t  : 32U;        /**< 0x068: Reserved                               */\r
103     uint32_t  : 32U;        /**< 0x06C: Reserved                               */\r
104     uint32_t  : 32U;        /**< 0x070: Reserved                               */\r
105     uint32_t  : 32U;        /**< 0x074: Reserved                               */\r
106     uint32_t  : 32U;        /**< 0x078: Reserved                               */\r
107     uint32_t  : 32U;        /**< 0x07C: Reserved                               */\r
108     uint32_t  : 32U;        /**< 0x080: Reserved                               */\r
109     uint32_t  : 32U;        /**< 0x084: Reserved                               */\r
110     uint32_t  : 32U;        /**< 0x088: Reserved                               */\r
111     uint32_t  : 32U;        /**< 0x08C: Reserved                               */\r
112     uint32_t IODFTCTRL;     /**< 0x0090: I/O Error Enable Register */\r
113 } sciBASE_t;\r
114 \r
115 \r
116 /** @def sciREG\r
117 *   @brief  Register Frame Pointer\r
118 *\r
119 *   This pointer is used by the SCI driver to access the sci module registers.\r
120 */\r
121 #define sciREG ((sciBASE_t *)0xFFF7E500U)\r
122 \r
123 \r
124 /** @def sciPORT\r
125 *   @brief SCI GIO Port Register Pointer\r
126 *\r
127 *   Pointer used by the GIO driver to access I/O PORT of SCI\r
128 *   (use the GIO drivers to access the port pins).\r
129 */\r
130 #define sciPORT ((gioPORT_t *)0xFFF7E540U)\r
131 \r
132 \r
133 /** @def scilinREG\r
134 *   @brief SCILIN (LIN - Compatibility Mode)  Register Frame Pointer\r
135 *\r
136 *   This pointer is used by the SCI driver to access the sci module registers.\r
137 */\r
138 #define scilinREG ((sciBASE_t *)0xFFF7E400U)\r
139 \r
140 \r
141 /** @def scilinPORT\r
142 *   @brief SCILIN (LIN - Compatibility Mode)  Register Frame Pointer\r
143 *\r
144 *   Pointer used by the GIO driver to access I/O PORT of LIN\r
145 *   (use the GIO drivers to access the port pins).\r
146 */\r
147 #define scilinPORT ((gioPORT_t *)0xFFF7E440U)\r
148 \r
149 \r
150 /* SCI Interface Functions */\r
151 void sciInit(void);\r
152 void sciSetFunctional(sciBASE_t *sci, uint32_t port);\r
153 void sciSetBaudrate(sciBASE_t *sci, uint32_t baud);\r
154 int  sciIsTxReady(sciBASE_t *sci);\r
155 void sciSendByte(sciBASE_t *sci, uint8_t byte);\r
156 void sciSend(sciBASE_t *sci, uint32_t length, uint8_t *data);\r
157 int  sciIsRxReady(sciBASE_t *sci);\r
158 int  sciRxError(sciBASE_t *sci);\r
159 int  sciReceiveByte(sciBASE_t *sci);\r
160 void sciReceive(sciBASE_t *sci, uint32_t length, uint8_t *data);\r
161 void sciEnableNotification(sciBASE_t *sci, uint32_t flags);\r
162 void sciDisableNotification(sciBASE_t *sci, uint32_t flags);\r
163 void sciEnableLoopback(sciBASE_t *sci, Loopbacktype_t Loopbacktype);\r
164 void sciDisableLoopback(sciBASE_t *sci);\r
165 \r
166 /** @fn void sciNotification(sciBASE_t *sci, uint32_t flags)\r
167 *   @brief Interrupt callback\r
168 *   @param[in] sci   - sci module base address\r
169 *   @param[in] flags - copy of error interrupt flags\r
170 *\r
171 * This is a callback that is provided by the application and is called apon\r
172 * an interrupt.  The parameter passed to the callback is a copy of the \r
173 * interrupt flag register.\r
174 */\r
175 void sciNotification(sciBASE_t *sci, uint32_t flags);\r
176 \r
177 #endif\r