z8530Sio.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:9k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* z8530Sio.h - header file for binary interface z8530 driver */
  2. /* Copyright 1984-1994 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01d,20may97,db  added element options to Z8530_CHAN structure to
  7.                 implement hardware options & modem control(SPR #1037).
  8. 01c,13oct95,ms  added comments for what fields need to be set by the BSP
  9. 01b,15jun95,ms updated for new driver structure
  10. 01a,20dec94,ms  written (from z8530Serial.h).
  11. */
  12. #ifndef __INCwdbz8530h
  13. #define __INCwdbz8530h
  14. #include "sioLib.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /* device and channel structures */
  19. /* The BSP must initilize all Z8530_CHAN fields which say "BSP:" */
  20. typedef struct /* Z8530_CHAN */
  21.     {
  22.     /* always goes first */
  23.     SIO_DRV_FUNCS * pDrvFuncs; /* driver functions */
  24.     /* callbacks */
  25.     STATUS (*getTxChar) (); /* pointer to xmitr function */
  26.     STATUS (*putRcvChar) (); /* pointer to rcvr functione */
  27.     void * getTxArg;
  28.     void * putRcvArg;
  29.     /* control and data register addresses */
  30.     volatile char * cr;         /* BSP: control register I/O address */
  31.     volatile char * dr;         /* BSP: data port I/O address */
  32.     /* misc values */
  33.     int         baudFreq;       /* BSP: baud clock frequency */
  34.     int baudRate; /* baud rate */
  35.     int options; /* hardware options */
  36.     char writeReg5; /* BSP: write register 5 value */
  37.     char        writeReg11;     /* BSP: write register 11 value */
  38.     char        writeReg14;     /* BSP: write register 14 value */
  39.     /* interrupt/polled mode configuration info */
  40.     uint_t      mode;           /* SIO_MODE_[INT | POLL] */
  41.     char        intVec;         /* BSP: interrupt vector address */
  42.     char        intType;        /* BSP: type of vector to supply from 8530 */
  43.     uint_t      channel;        /* channel number (0 or 1) */
  44.     } Z8530_CHAN;
  45. typedef struct
  46.     {
  47.     Z8530_CHAN portA;          /* port A device descriptor */
  48.     Z8530_CHAN portB;          /* port B device descriptor */
  49.     } Z8530_DUSART;
  50. /* channels */
  51. #define SCC_CHANNEL_A 0
  52. #define SCC_CHANNEL_B 1
  53. /* bit values for write register 0 */
  54. /* command register */
  55. #define SCC_WR0_SEL_WR0  0x00
  56. #define SCC_WR0_SEL_WR1  0x01
  57. #define SCC_WR0_SEL_WR2  0x02
  58. #define SCC_WR0_SEL_WR3  0x03
  59. #define SCC_WR0_SEL_WR4  0x04
  60. #define SCC_WR0_SEL_WR5  0x05
  61. #define SCC_WR0_SEL_WR6  0x06
  62. #define SCC_WR0_SEL_WR7  0x07
  63. #define SCC_WR0_SEL_WR8  0x08
  64. #define SCC_WR0_SEL_WR9 0x09
  65. #define SCC_WR0_SEL_WR10 0x0a
  66. #define SCC_WR0_SEL_WR11 0x0b
  67. #define SCC_WR0_SEL_WR12 0x0c
  68. #define SCC_WR0_SEL_WR13 0x0d
  69. #define SCC_WR0_SEL_WR14 0x0e
  70. #define SCC_WR0_SEL_WR15 0x0f
  71. #define SCC_WR0_NULL_CODE 0x00
  72. #define SCC_WR0_RST_INT 0x10
  73. #define SCC_WR0_SEND_ABORT 0x18
  74. #define SCC_WR0_EN_INT_RX 0x20
  75. #define SCC_WR0_RST_TX_INT 0x28
  76. #define SCC_WR0_ERR_RST 0x30
  77. #define SCC_WR0_RST_HI_IUS 0x38
  78. #define SCC_WR0_RST_RX_CRC 0x40
  79. #define SCC_WR0_RST_TX_CRC 0x80
  80. #define SCC_WR0_RST_TX_UND 0xc0
  81. /* write register 2 */
  82. /* interrupt vector */
  83. /* bit values for write register 1 */
  84. /* tx/rx interrupt and data transfer mode definition */
  85. #define SCC_WR1_EXT_INT_EN 0x01
  86. #define SCC_WR1_TX_INT_EN 0x02
  87. #define SCC_WR1_PARITY 0x04
  88. #define SCC_WR1_RX_INT_DIS 0x00
  89. #define SCC_WR1_RX_INT_FIR 0x08
  90. #define SCC_WR1_INT_ALL_RX 0x10
  91. #define SCC_WR1_RX_INT_SPE 0x18
  92. #define SCC_WR1_RDMA_RECTR 0x20
  93. #define SCC_WR1_RDMA_FUNC 0x40
  94. #define SCC_WR1_RDMA_EN 0x80
  95. /* bit values for write register 3 */
  96. /* receive parameters and control */
  97. #define SCC_WR3_RX_EN 0x01
  98. #define SCC_WR3_SYNC_CHAR 0x02
  99. #define SCC_WR3_ADR_SEARCH 0x04
  100. #define SCC_WR3_RX_CRC_EN 0x08
  101. #define SCC_WR3_ENTER_HUNT 0x10
  102. #define SCC_WR3_AUTO_EN 0x20
  103. #define SCC_WR3_RX_5_BITS 0x00
  104. #define SCC_WR3_RX_7_BITS 0x40
  105. #define SCC_WR3_RX_6_BITS 0x80
  106. #define SCC_WR3_RX_8_BITS 0xc0
  107. /* bit values for write register 4 */
  108. /* tx/rx misc parameters and modes */
  109. #define SCC_WR4_PAR_EN 0x01
  110. #define SCC_WR4_PAR_EVEN 0x02
  111. #define SCC_WR4_SYNC_EN 0x00
  112. #define SCC_WR4_1_STOP 0x04
  113. #define SCC_WR4_2_STOP 0x0c
  114. #define SCC_WR4_8_SYNC 0x00
  115. #define SCC_WR4_16_SYNC 0x10
  116. #define SCC_WR4_SDLC 0x20
  117. #define SCC_WR4_EXT_SYNC 0x30
  118. #define SCC_WR4_1_CLOCK 0x00
  119. #define SCC_WR4_16_CLOCK 0x40
  120. #define SCC_WR4_32_CLOCK 0x80
  121. #define SCC_WR4_64_CLOCK 0xc0
  122. /* bit values for write register 5 */
  123. /* transmit parameter and controls */
  124. #define SCC_WR5_TX_CRC_EN 0x01
  125. #define SCC_WR5_RTS 0x02
  126. #define SCC_WR5_SDLC 0x04
  127. #define SCC_WR5_TX_EN 0x08
  128. #define SCC_WR5_SEND_BRK 0x10
  129. #define SCC_WR5_TX_5_BITS 0x00
  130. #define SCC_WR5_TX_7_BITS 0x20
  131. #define SCC_WR5_TX_6_BITS 0x40
  132. #define SCC_WR5_TX_8_BITS 0x60
  133. #define SCC_WR5_DTR 0x80
  134. /* write register 6 */
  135. /* sync chars or sdlc address field */
  136. /* write register 7 */
  137. /* sync char or sdlc flag */
  138. /* write register 8 */
  139. /* transmit buffer */
  140. /* bit values for write register 9 */
  141. /* master interrupt control */
  142. #define SCC_WR9_VIS 0x01
  143. #define SCC_WR9_NV 0x02
  144. #define SCC_WR9_DLC 0x04
  145. #define SCC_WR9_MIE 0x08
  146. #define SCC_WR9_STATUS_HI 0x10
  147. #define SCC_WR9_NO_RST 0x00
  148. #define SCC_WR9_CH_B_RST 0x40
  149. #define SCC_WR9_CH_A_RST 0x80
  150. #define SCC_WR9_HDWR_RST 0xc0
  151. /* bit values for write register 10 */
  152. /* misc tx/rx control bits */
  153. #define SCC_WR10_6_BIT_SYNC 0x01
  154. #define SCC_WR10_LOOP_MODE 0x02
  155. #define SCC_WR10_ABORT_UND 0x04
  156. #define SCC_WR10_MARK_IDLE 0x08
  157. #define SCC_WR10_ACT_POLL 0x10
  158. #define SCC_WR10_NRZ 0x00
  159. #define SCC_WR10_NRZI 0x20
  160. #define SCC_WR10_FM1 0x40
  161. #define SCC_WR10_FM0 0x60
  162. #define SCC_WR10_CRC_PRESET 0x80
  163. /* bit values for write register 11 */
  164. /* clock mode control */
  165. #define SCC_WR11_OUT_XTAL 0x00
  166. #define SCC_WR11_OUT_TX_CLK 0x01
  167. #define SCC_WR11_OUT_BR_GEN 0x02
  168. #define SCC_WR11_OUT_DPLL 0x03
  169. #define SCC_WR11_TRXC_OI 0x04
  170. #define SCC_WR11_TX_RTXC 0x00
  171. #define SCC_WR11_TX_TRXC 0x08
  172. #define SCC_WR11_TX_BR_GEN 0x10
  173. #define SCC_WR11_TX_DPLL 0x18
  174. #define SCC_WR11_RX_RTXC 0x00
  175. #define SCC_WR11_RX_TRXC 0x20
  176. #define SCC_WR11_RX_BR_GEN 0x40
  177. #define SCC_WR11_RX_DPLL 0x60
  178. #define SCC_WR11_RTXC_XTAL 0x80
  179. /* write register 12 */
  180. /* lower byte of baud rate generator time constant */
  181. /* write register 13 */
  182. /* upper byte of baud rate generator time constant */
  183. /* bit values for write register 14 */
  184. /* misc control bits */
  185. #define SCC_WR14_BR_EN 0x01
  186. #define SCC_WR14_BR_SRC 0x02
  187. #define SCC_WR14_DTR_FUNC 0x04
  188. #define SCC_WR14_AUTO_ECHO  0x08
  189. #define SCC_WR14_LCL_LOOP 0x10
  190. #define SCC_WR14_NULL 0x00
  191. #define SCC_WR14_SEARCH 0x20
  192. #define SCC_WR14_RST_CLK 0x40
  193. #define SCC_WR14_DIS_DPLL 0x60
  194. #define SCC_WR14_SRC_BR 0x80
  195. #define SCC_WR14_SRC_RTXC 0xa0
  196. #define SCC_WR14_FM_MODE 0xc0
  197. #define SCC_WR14_NRZI 0xe0
  198. /* bit values for write register 15 */
  199. /* external/status interrupt control */
  200. #define SCC_WR15_ZERO_CNT 0x02
  201. #define SCC_WR15_CD_IE 0x08
  202. #define SCC_WR15_SYNC_IE 0x10
  203. #define SCC_WR15_CTS_IE 0x20
  204. #define SCC_WR15_TX_UND_IE 0x40
  205. #define SCC_WR15_BREAK_IE 0x80
  206. /* bit values for read register 0 */
  207. /* tx/rx buffer status and external status  */
  208. #define SCC_RR0_RX_AVAIL 0x01
  209. #define SCC_RR0_ZERO_CNT 0x02
  210. #define SCC_RR0_TX_EMPTY 0x04
  211. #define SCC_RR0_CD 0x08
  212. #define SCC_RR0_SYNC 0x10
  213. #define SCC_RR0_CTS 0x20
  214. #define SCC_RR0_TX_UND 0x40
  215. #define SCC_RR0_BREAK 0x80
  216. /* bit values for read register 1 */
  217. #define SCC_RR1_ALL_SENT 0x01
  218. #define SCC_RR1_RES_CD_2 0x02
  219. #define SCC_RR1_RES_CD_1 0x01
  220. #define SCC_RR1_RES_CD_0 0x08
  221. #define SCC_RR1_PAR_ERR 0x10
  222. #define SCC_RR1_RX_OV_ERR 0x20
  223. #define SCC_RR1_CRC_ERR 0x40
  224. #define SCC_RR1_END_FRAME 0x80
  225. /* read register 2 */
  226. /* interrupt vector */
  227. /* bit values for read register 3 */
  228. /* interrupt pending register */
  229. #define SCC_RR3_B_EXT_IP 0x01
  230. #define SCC_RR3_B_TX_IP 0x02
  231. #define SCC_RR3_B_RX_IP 0x04
  232. #define SCC_RR3_A_EXT_IP 0x08
  233. #define SCC_RR3_A_TX_IP 0x10
  234. #define SCC_RR3_A_RX_IP 0x20
  235. /* read register 8 */
  236. /* receive data register */
  237. /* bit values for read register 10 */
  238. /* misc status bits */
  239. #define SCC_RR10_ON_LOOP 0x02
  240. #define SCC_RR10_LOOP_SEND 0x10
  241. #define SCC_RR10_2_CLK_MIS 0x40
  242. #define SCC_RR10_1_CLK_MIS 0x80
  243. /* read register 12 */
  244. /* lower byte of time constant */
  245. /* read register 13 */
  246. /* upper byte of time constant */
  247. /* bit values for read register 15 */
  248. /* external/status ie bits */
  249. #define SCC_RR15_ZERO_CNT 0x02
  250. #define SCC_RR15_CD_IE 0x08
  251. #define SCC_RR15_SYNC_IE 0x10
  252. #define SCC_RR15_CTS_IE 0x20
  253. #define SCC_RR15_TX_UND_IE 0x40
  254. #define SCC_RR15_BREAK_IE 0x80
  255. #if defined(__STDC__) || defined(__cplusplus)
  256. extern void  z8530DevInit (Z8530_DUSART *pDusart); 
  257. extern void z8530IntWr (Z8530_CHAN * pChan);
  258. extern void z8530IntRd (Z8530_CHAN * pChan);
  259. extern void z8530IntEx (Z8530_CHAN * pChan);
  260. extern void z8530Int (Z8530_DUSART *pDusart);
  261. #else   /* __STDC__ */
  262. extern void  z8530DevInit ();
  263. extern void z8530IntWr ();
  264. extern void z8530IntRd ();
  265. extern void z8530IntEx ();
  266. extern void z8530Int ();
  267. #endif  /* __STDC__ */
  268. #ifdef __cplusplus
  269. }
  270. #endif
  271. #endif  /* __INCwdbz8530h */