- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

# include/hardware/usart.h

Go to the documentation of this file.

    00001
    00041 #ifndef USART_REGS_H_INCLUDED
    00042 #define USART_REGS_H_INCLUDED
    00043
    00044 #include <types.h>
    00045
    00046 /* USART register offsets */
    00047 struct usart_regs {
    00048         uint32_t        CR;
    00049         uint32_t        MR;
    00050         uint32_t        IER;
    00051         uint32_t        IDR;
    00052         uint32_t        IMR;
    00053         uint32_t        CSR;
    00054         uint32_t        RHR;
    00055         uint32_t        THR;
    00056         uint32_t        BRGR;
    00057         uint32_t        RTOR;
    00058         uint32_t        TTGR;
    00059         uint32_t        __reserved0[5];
    00060         uint32_t        FIDI;
    00061         uint32_t        NER;
    00062         uint32_t        XXR;
    00063         uint32_t        IFR;
    00064 };
    00065
    00066 /* Bitfields in CR */
    00067 #define USART_RSTRX_OFFSET                      2
    00068 #define USART_RSTRX_SIZE                        1
    00069 #define USART_RSTTX_OFFSET                      3
    00070 #define USART_RSTTX_SIZE                        1
    00071 #define USART_RXEN_OFFSET                       4
    00072 #define USART_RXEN_SIZE                         1
    00073 #define USART_RXDIS_OFFSET                      5
    00074 #define USART_RXDIS_SIZE                        1
    00075 #define USART_TXEN_OFFSET                       6
    00076 #define USART_TXEN_SIZE                         1
    00077 #define USART_TXDIS_OFFSET                      7
    00078 #define USART_TXDIS_SIZE                        1
    00079 #define USART_RSTSTA_OFFSET                     8
    00080 #define USART_RSTSTA_SIZE                       1
    00081 #define USART_STTBRK_OFFSET                     9
    00082 #define USART_STTBRK_SIZE                       1
    00083 #define USART_STPBRK_OFFSET                     10
    00084 #define USART_STPBRK_SIZE                       1
    00085 #define USART_STTTO_OFFSET                      11
    00086 #define USART_STTTO_SIZE                        1
    00087 #define USART_SENDA_OFFSET                      12
    00088 #define USART_SENDA_SIZE                        1
    00089 #define USART_RSTIT_OFFSET                      13
    00090 #define USART_RSTIT_SIZE                        1
    00091 #define USART_RSTNACK_OFFSET                    14
    00092 #define USART_RSTNACK_SIZE                      1
    00093 #define USART_RETTO_OFFSET                      15
    00094 #define USART_RETTO_SIZE                        1
    00095 #define USART_DTREN_OFFSET                      16
    00096 #define USART_DTREN_SIZE                        1
    00097 #define USART_DTRDIS_OFFSET                     17
    00098 #define USART_DTRDIS_SIZE                       1
    00099 #define USART_RTSEN_OFFSET                      18
    00100 #define USART_RTSEN_SIZE                        1
    00101 #define USART_RTSDIS_OFFSET                     19
    00102 #define USART_RTSDIS_SIZE                       1
    00103 #define USART_COMM_TX_OFFSET                    30
    00104 #define USART_COMM_TX_SIZE                      1
    00105 #define USART_COMM_RX_OFFSET                    31
    00106 #define USART_COMM_RX_SIZE                      1
    00107
    00108 /* Bitfields in MR */
    00109 #define USART_MODE_OFFSET                       0
    00110 #define USART_MODE_SIZE                         4
    00111 #define USART_USCLKS_OFFSET                     4
    00112 #define USART_USCLKS_SIZE                       2
    00113 #define USART_CHRL_OFFSET                       6
    00114 #define USART_CHRL_SIZE                         2
    00115 #define USART_SYNC_OFFSET                       8
    00116 #define USART_SYNC_SIZE                         1
    00117 #define USART_PAR_OFFSET                        9
    00118 #define USART_PAR_SIZE                          3
    00119 #define USART_NBSTOP_OFFSET                     12
    00120 #define USART_NBSTOP_SIZE                       2
    00121 #define USART_CHMODE_OFFSET                     14
    00122 #define USART_CHMODE_SIZE                       2
    00123 #define USART_MSBF_OFFSET                       16
    00124 #define USART_MSBF_SIZE                         1
    00125 #define USART_MODE9_OFFSET                      17
    00126 #define USART_MODE9_SIZE                        1
    00127 #define USART_CLKO_OFFSET                       18
    00128 #define USART_CLKO_SIZE                         1
    00129 #define USART_OVER_OFFSET                       19
    00130 #define USART_OVER_SIZE                         1
    00131 #define USART_INACK_OFFSET                      20
    00132 #define USART_INACK_SIZE                        1
    00133 #define USART_DSNACK_OFFSET                     21
    00134 #define USART_DSNACK_SIZE                       1
    00135 #define USART_MAX_ITERATION_OFFSET              24
    00136 #define USART_MAX_ITERATION_SIZE                3
    00137 #define USART_FILTER_OFFSET                     28
    00138 #define USART_FILTER_SIZE                       1
    00139
    00140 /* Bitfields in CSR */
    00141 #define USART_RXRDY_OFFSET                      0
    00142 #define USART_RXRDY_SIZE                        1
    00143 #define USART_TXRDY_OFFSET                      1
    00144 #define USART_TXRDY_SIZE                        1
    00145 #define USART_RXBRK_OFFSET                      2
    00146 #define USART_RXBRK_SIZE                        1
    00147 #define USART_ENDRX_OFFSET                      3
    00148 #define USART_ENDRX_SIZE                        1
    00149 #define USART_ENDTX_OFFSET                      4
    00150 #define USART_ENDTX_SIZE                        1
    00151 #define USART_OVRE_OFFSET                       5
    00152 #define USART_OVRE_SIZE                         1
    00153 #define USART_FRAME_OFFSET                      6
    00154 #define USART_FRAME_SIZE                        1
    00155 #define USART_PARE_OFFSET                       7
    00156 #define USART_PARE_SIZE                         1
    00157 #define USART_TIMEOUT_OFFSET                    8
    00158 #define USART_TIMEOUT_SIZE                      1
    00159 #define USART_TXEMPTY_OFFSET                    9
    00160 #define USART_TXEMPTY_SIZE                      1
    00161 #define USART_ITERATION_OFFSET                  10
    00162 #define USART_ITERATION_SIZE                    1
    00163 #define USART_TXBUFE_OFFSET                     11
    00164 #define USART_TXBUFE_SIZE                       1
    00165 #define USART_RXBUFF_OFFSET                     12
    00166 #define USART_RXBUFF_SIZE                       1
    00167 #define USART_NACK_OFFSET                       13
    00168 #define USART_NACK_SIZE                         1
    00169 #define USART_RIIC_OFFSET                       16
    00170 #define USART_RIIC_SIZE                         1
    00171 #define USART_DSRIC_OFFSET                      17
    00172 #define USART_DSRIC_SIZE                        1
    00173 #define USART_DCDIC_OFFSET                      18
    00174 #define USART_DCDIC_SIZE                        1
    00175 #define USART_CTSIC_OFFSET                      19
    00176 #define USART_CTSIC_SIZE                        1
    00177 #define USART_RI_OFFSET                         20
    00178 #define USART_RI_SIZE                           1
    00179 #define USART_DSR_OFFSET                        21
    00180 #define USART_DSR_SIZE                          1
    00181 #define USART_DCD_OFFSET                        22
    00182 #define USART_DCD_SIZE                          1
    00183 #define USART_CTS_OFFSET                        23
    00184 #define USART_CTS_SIZE                          1
    00185
    00186 /* Bitfields in RHR */
    00187 #define USART_RXCHR_OFFSET                      0
    00188 #define USART_RXCHR_SIZE                        9
    00189
    00190 /* Bitfields in THR */
    00191 #define USART_TXCHR_OFFSET                      0
    00192 #define USART_TXCHR_SIZE                        9
    00193
    00194 /* Bitfields in BRGR */
    00195 #define USART_CD_OFFSET                         0
    00196 #define USART_CD_SIZE                           16
    00197 #define USART_FP_OFFSET                         16
    00198 #define USART_FP_SIZE                           3
    00199
    00200 /* Bitfields in RTOR */
    00201 #define USART_TO_OFFSET                         0
    00202 #define USART_TO_SIZE                           16
    00203
    00204 /* Bitfields in TTGR */
    00205 #define USART_TG_OFFSET                         0
    00206 #define USART_TG_SIZE                           8
    00207
    00208 /* Bitfields in FIDI */
    00209 #define USART_FI_DI_RATIO_OFFSET                0
    00210 #define USART_FI_DI_RATIO_SIZE                  11
    00211
    00212 /* Bitfields in NER */
    00213 #define USART_NB_ERRORS_OFFSET                  0
    00214 #define USART_NB_ERRORS_SIZE                    8
    00215
    00216 /* Bitfields in XXR */
    00217 #define USART_XOFF_OFFSET                       0
    00218 #define USART_XOFF_SIZE                         8
    00219 #define USART_XON_OFFSET                        8
    00220 #define USART_XON_SIZE                          8
    00221
    00222 /* Bitfields in IFR */
    00223 #define USART_IRDA_FILTER_OFFSET                0
    00224 #define USART_IRDA_FILTER_SIZE                  8
    00225
    00226 /* Bitfields in RCR */
    00227 #define USART_RXCTR_OFFSET                      0
    00228 #define USART_RXCTR_SIZE                        16
    00229
    00230 /* Bitfields in TCR */
    00231 #define USART_TXCTR_OFFSET                      0
    00232 #define USART_TXCTR_SIZE                        16
    00233
    00234 /* Bitfields in RNCR */
    00235 #define USART_RXNCR_OFFSET                      0
    00236 #define USART_RXNCR_SIZE                        16
    00237
    00238 /* Bitfields in TNCR */
    00239 #define USART_TXNCR_OFFSET                      0
    00240 #define USART_TXNCR_SIZE                        16
    00241
    00242 /* Bitfields in PTCR */
    00243 #define USART_RXTEN_OFFSET                      0
    00244 #define USART_RXTEN_SIZE                        1
    00245 #define USART_RXTDIS_OFFSET                     1
    00246 #define USART_RXTDIS_SIZE                       1
    00247 #define USART_TXTEN_OFFSET                      8
    00248 #define USART_TXTEN_SIZE                        1
    00249 #define USART_TXTDIS_OFFSET                     9
    00250 #define USART_TXTDIS_SIZE                       1
    00251
    00252 /* Constants for USART_MODE */
    00253 #define USART_MODE_NORMAL                       0
    00254 #define USART_MODE_RS485                        1
    00255 #define USART_MODE_HARDWARE                     2
    00256 #define USART_MODE_MODEM                        3
    00257 #define USART_MODE_ISO7816_T0                   4
    00258 #define USART_MODE_ISO7816_T1                   6
    00259 #define USART_MODE_IRDA                         8
    00260
    00261 /* Constants for USCLKS */
    00262 #define USART_USCLKS_MCK                        0
    00263 #define USART_USCLKS_MCK_DIV                    1
    00264 #define USART_USCLKS_SCK                        3
    00265
    00266 /* Constants for CHRL */
    00267 #define USART_CHRL_5                            0
    00268 #define USART_CHRL_6                            1
    00269 #define USART_CHRL_7                            2
    00270 #define USART_CHRL_8                            3
    00271
    00272 /* Constants for PAR */
    00273 #define USART_PAR_EVEN                          0
    00274 #define USART_PAR_ODD                           1
    00275 #define USART_PAR_SPACE                         2
    00276 #define USART_PAR_MARK                          3
    00277 #define USART_PAR_NONE                          4
    00278 #define USART_PAR_MULTI                         6
    00279
    00280 /* Constants for NBSTOP */
    00281 #define USART_NBSTOP_1                          0
    00282 #define USART_NBSTOP_1_5                        1
    00283 #define USART_NBSTOP_2                          2
    00284
    00285 /* Constants for CHMODE */
    00286 #define USART_CHMODE_NORMAL                     0
    00287 #define USART_CHMODE_ECHO                       1
    00288 #define USART_CHMODE_LOCAL_LOOP                 2
    00289 #define USART_CHMODE_REMOTE_LOOP                3
    00290
    00291 /* Constants for MSBF */
    00292 #define USART_MSBF_LSBF                         0
    00293 #define USART_MSBF_MSBF                         1
    00294
    00295 /* Constants for OVER */
    00296 #define USART_OVER_X16                          0
    00297 #define USART_OVER_X8                           1
    00298
    00299 /* Constants for CD */
    00300 #define USART_CD_DISABLE                        0
    00301 #define USART_CD_BYPASS                         1
    00302
    00303 /* Constants for TO */
    00304 #define USART_TO_DISABLE                        0
    00305
    00306 /* Constants for TG */
    00307 #define USART_TG_DISABLE                        0
    00308
    00309 /* Constants for FI_DI_RATIO */
    00310 #define USART_FI_DI_RATIO_DISABLE               0
    00311
    00312 /* Bit manipulation macros */
    00313 #define USART_BIT(name)                                 \
    00314         (1 << USART_##name##_OFFSET)
    00315 #define USART_BF(name,value)                            \
    00316         (((value) & ((1 << USART_##name##_SIZE) - 1))   \
    00317          << USART_##name##_OFFSET)
    00318 #define USART_BFEXT(name,value)                         \
    00319         (((value) >> USART_##name##_OFFSET)             \
    00320          & ((1 << USART_##name##_SIZE) - 1))
    00321 #define USART_BFINS(name,value,old)                     \
    00322         (((old) & ~(((1 << USART_##name##_SIZE) - 1)    \
    00323                     << USART_##name##_OFFSET))          \
    00324          | USART_BF(name,value))
    00325
    00326 /* Register access macros */
    00327 #define usart_read(regs, reg)                                           \
    00328         (((volatile struct usart_regs *)regs)->reg)
    00329 #define usart_write(regs, reg, value)                                   \
    00330         (((volatile struct usart_regs *)regs)->reg = (value))
    00331
    00332 #endif /* USART_REGS_H_INCLUDED */