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

VxWorks

开发平台:

C/C++

  1. /* ivac.h - Ironics/VTC's VME Address Controller (VAC) constants */
  2. /*
  3. modification history
  4. --------------------
  5. 01f,22sep92,rrr  added support for c++
  6. 01e,07jul92,jwt  cleaned up ANSI compiler warnings.
  7. 01d,26may92,rrr  the tree shuffle
  8. 01c,04oct91,rrr  passed through the ansification filter
  9.   -fixed #else and #endif
  10.   -changed ASMLANGUAGE to _ASMLANGUAGE
  11.   -changed copyright notice
  12. 01b,31jan91,rjt  initial release to windriver after many minor fixes.
  13. 01a,25jul90,rjt  writen by modifying IV-SPRC sparcmon version.
  14. */
  15. #ifndef __INCivach
  16. #define __INCivach
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /*
  21. Assembly language files should turn off type declarations by not
  22. including those portions of this include file, this is done by
  23. placing a "#define _ASMLANGUAGE" statement before this file is
  24. included in any other files.
  25. Also, in order to incorparate stronger typing of all constants, and to
  26. allow the same constants to be typed in C files,yet usable in
  27. assembly files. An unorthadox method of TYPING is used by CONDITIONALLY
  28. #define'ing the constant TYPES. If no _ASMLANGUAGE #define is present,
  29. then the type is defined to a blank space, otherwise it is defined
  30. to be a C type. This looks weird but works nicely.
  31. */
  32. /*
  33. Naming of register names and constants was done ( or was attempted ) so that
  34. the front end of the names would indicate a related group while the tail
  35. end of the names would further define the purpose of the name. Some groups
  36. often contained sub-groups. Also some names don't follow this convention for
  37. the sake of readability and other reasons.
  38. An H_ prefix indicates that the constant is typed as a pointer to
  39. unsigned short register.
  40. An B_ prefix indicates that the constant is typed as a pointer to
  41. unsigned char register.
  42. Because of unpredictability of structure sizing and placement for
  43. different compilers, we use contants to access each register.
  44. Most constants are defined for consistancy in name AND intended usage.
  45. BIT MANIPUATION is set up so that each bit field has 3 or more defines
  46. associated with it.
  47. 1. BIT VALUE MASK
  48. 2. ASSERTED VALUE(S)
  49. 3. DEASERTED VALUE
  50. Where ASSERTED VALUE = 0 and dasserted value = 0xff for ACTIVE LOW SIGNALS
  51. or vice versa,
  52. where ASSERTED VALUE = 0xff and dasserted value = 0 for ACTIVE HIGH SIGNALS.
  53. The active high bits may also be something other than 0xff for
  54. multi-bit fields.  EG: for at 2 bit active high field there may be
  55. 4 asserted values associated with it: 0x00 0x01 0x02 0x03.
  56. the bit field should be altered as follows:
  57. new_reg_value =   (old_reg_val & ~MASK) | (MASK & VALUE )
  58. REGISTER BIT STATUS for a bit field has 2 or more defines associated with it.
  59. 1.  BIT MASK
  60. 2.  POSSIBLE BIT VALUE
  61. 3.     .
  62. 4      .
  63. returned_bit_field_status  =  MASK & reg_value
  64. Most constants are declared immediatly after the register they are used in.
  65. Some constants are shared between more than 1 register and are only defined
  66. once after the first register.
  67. */
  68. /* IMPORTANT NOTICE: NOT ALL CONSTANTS HAVE BEEN TESTED */
  69. /* The following #defines allow or disallow C types */
  70. #ifndef _ASMLANGUAGE
  71. /* C code typing */
  72. #ifndef P_VA_TYPE
  73. #define P_VA_TYPE (unsigned short *)
  74. #endif
  75. #ifndef VA_TYPE
  76. #define VA_TYPE  (unsigned short)
  77. #endif
  78. #else
  79. /* No typing allowing in assembly */
  80. #define VA_TYPE
  81. #define P_VA_TYPE
  82. #endif /* _ASMLANGUAGE */
  83. #define VAC_ADR  0xfffd0000
  84. #define VAC_TYPE unsigned short
  85. /*
  86. IMPORTANT
  87. Some boards may require a special routine to access the VAC registers.
  88. Example: a board whose cache must be bypassed to ensure register integrity.
  89. If they do, there should be  vaXetReg() macros #define'd to call that
  90. special routine. Otherwise the following vaXetReg() macros will be used.
  91. For portability reasons, it might be a good idea to only use vaXetReg()
  92. to alter any VAC registers in C code.  If this macro is insufficient
  93. then "#undef vaRegSet" and write a C routine (or another macro) to replace it.
  94. */
  95. #ifndef vaRegSet
  96. #define vaRegSet(hReg,val) (*(hReg) = (VAC_TYPE) (val))
  97. #endif /* vaRegSet */
  98. #ifndef vaRegGet
  99. #define vaRegGet(bReg) *(bReg)
  100. #endif /* vaRegGet */
  101. /*  Slave Select  mask and base registers */
  102. #define H_VAC_SLS1_MASK  P_VA_TYPE (VAC_ADR + 0x0000)
  103. #define H_VAC_SLS1_BASE  P_VA_TYPE (VAC_ADR + 0x0100)
  104. #define H_VAC_SLS0_MASK  P_VA_TYPE (VAC_ADR + 0x0200)
  105. #define H_VAC_SLS0_BASE  P_VA_TYPE (VAC_ADR + 0x0300)
  106. /*  group & module Addr. decodes for IPC Reg. */
  107. #define H_VAC_ICFSEL P_VA_TYPE(VAC_ADR + 0x0400)
  108. #define GROUP_BASE_MASK 0xff00
  109. #define MODULE_BASE_MASK 0x00ff
  110. #define GROUP_SHIFT 0x0000
  111. #define MODULE_SHIFT 0x0008
  112. /* DRAM Upper Limit Mask Register */
  113. #define H_VAC_DRAM_MASK  P_VA_TYPE (VAC_ADR + 0x0500)
  114. /* Boundry 2 Address Reg. */
  115. #define H_VAC_B2_BASE  P_VA_TYPE (VAC_ADR + 0x0600)
  116. /* Boundry 3 Address Reg. */
  117. #define H_VAC_B3_BASE  P_VA_TYPE (VAC_ADR + 0x0700 )
  118. /* A24 Base Address Reg. */
  119. #define H_VAC_A24_BASE  P_VA_TYPE (VAC_ADR + 0x0800 )
  120. /*  Region 1,2,3 Attribute Reg. */
  121. #define H_VAC_R1_ATTRIB  P_VA_TYPE (VAC_ADR + 0x0900)
  122. #define H_VAC_R2_ATTRIB  P_VA_TYPE (VAC_ADR + 0x0a00)
  123. #define H_VAC_R3_ATTRIB  P_VA_TYPE (VAC_ADR + 0x0b00 )
  124. #define ATR_DATA_SZ_MASK VA_TYPE 0x8000
  125. #define ATR_D16   VA_TYPE 0x8000
  126. #define ATR_D32   VA_TYPE 0x0
  127. #define ATR_ADR_SZ_MASK VA_TYPE 0x6000
  128. #define ATR_A16   VA_TYPE 0x2000
  129. #define ATR_A24   VA_TYPE 0x0000
  130. #define ATR_A32   VA_TYPE 0x4000
  131. #define ATR_CACHE_MASK VA_TYPE 0x1000
  132. #define ATR_CACHE_INHIBIT VA_TYPE 0x1000
  133. #define ATR_CACHE_ENABLE VA_TYPE 0x0000
  134. #define ATR_SEGMENT_MAP_MASK VA_TYPE 0x0c00
  135. #define ATR_NULL  VA_TYPE 0x0
  136. #define ATR_SHR   VA_TYPE 0x0400
  137. #define ATR_VSB   VA_TYPE 0x0800
  138. #define ATR_VME   VA_TYPE 0x0c00
  139. /*  Dsack Timing Control Reg. */
  140. #define H_VAC_IO4_DSACK_CTL  P_VA_TYPE (VAC_ADR + 0x0c00)
  141. #define H_VAC_IO5_DSACK_CTL  P_VA_TYPE (VAC_ADR + 0x0d00)
  142. #define H_VAC_SHR_DSACK_CTL  P_VA_TYPE (VAC_ADR + 0x0e00)
  143. #define H_VAC_EPROM_DSACK_CTL  P_VA_TYPE (VAC_ADR + 0x0f00)
  144. #define H_VAC_IO0_DSACK_CTL  P_VA_TYPE (VAC_ADR + 0x1000)
  145. #define H_VAC_IO1_DSACK_CTL  P_VA_TYPE (VAC_ADR + 0x1100)
  146. #define H_VAC_IO2_DSACK_CTL  P_VA_TYPE (VAC_ADR + 0x1200)
  147. #define H_VAC_IO3_DSACK_CTL  P_VA_TYPE (VAC_ADR + 0x1300)
  148. #define DSACK_DELAY_MASK 0xE000
  149. #define DSACK_DELAY_0 0x0000
  150. #define DSACK_DELAY_1 0x2000
  151. #define DSACK_DELAY_2 0x4000
  152. #define DSACK_DELAY_3 0x6000
  153. #define DSACK_DELAY_4 0x8000
  154. #define DSACK_DELAY_5 0xA000
  155. #define DSACK_DELAY_6 0xC000
  156. #define DSACK_DELAY_7 0xE000
  157. #define DSACK1_ENABLE 0x1000
  158. #define DSASK0_ENABLE 0x0800
  159. #define DSACK_RECOVERY_MASK 0x0700
  160. #define RECOVERY_DELAY_0 0x0000
  161. #define RECOVERY_DELAY_1 0x0100
  162. #define RECOVERY_DELAY_2 0x0200
  163. #define RECOVERY_DELAY_3 0x0300
  164. #define RECOVERY_DELAY_4 0x0400
  165. #define RECOVERY_DELAY_5 0x0500
  166. #define RECOVERY_DELAY_6 0x0600
  167. #define RECOVERY_DELAY_7 0x0700
  168. #define IORD_DELAY_MASK 0x00c0
  169. #define IORD_DELAY_0 0x0000
  170. #define IORD_DELAY_1 0x0040
  171. #define IORD_DELAY_2 0x0080
  172. #define IORD_DELAY_3 0x00c0
  173. #define IOWR_DELAY_MASK 0x0030
  174. #define IOWR_DELAY_0 0x0000
  175. #define IOWR_DELAY_1 0x0010
  176. #define IOWR_DELAY_2 0x0020
  177. #define IOWR_DELAY_3 0x0030
  178. #define IOSELI_DELAY_MASK 0x000c
  179. #define IOSELI_DELAY_0 0x0000
  180. #define IOSELI_DELAY_1 0x0004
  181. #define IOSELI_DELAY_2 0x0008
  182. #define IOSELI_DELAY_3 0x000c
  183. #define IORD_CYCLE_END_CTL 0x0002
  184. #define IOWR_CYCLE_END_CTL 0x0001
  185. /*  Decode Control Register */
  186. #define H_VAC_DECODE_CTL  P_VA_TYPE (VAC_ADR + 0x1400)
  187. #define SLACKDR  VA_TYPE 0x8000
  188. #define QDRAM VA_TYPE 0x4000
  189. /* slave 1 device selection */
  190. #define SL1_MASK VA_TYPE 0x3000
  191. #define SL1DS1 VA_TYPE 0x2000
  192. #define SL1DS0 VA_TYPE 0x1000
  193. #define SL1_EPROM VA_TYPE 0x0000
  194. #define SL1_VSB VA_TYPE 0x1000
  195. #define SL1_SHRCS VA_TYPE 0x2000
  196. #define SL1_DRAM VA_TYPE 0x3000
  197. #define SL1A32 VA_TYPE 0x0800
  198. #define SL1A16 VA_TYPE 0x0400
  199. #define QSL0 VA_TYPE 0x0200
  200. #define QSL1 VA_TYPE 0x0100
  201. #define QICF VA_TYPE 0x0080
  202. #define QBNDRY VA_TYPE 0x0040
  203. #define ACKDR VA_TYPE 0x0020
  204. #define REDSL1 VA_TYPE 0x0010
  205. #define REDSL0 VA_TYPE 0x0008
  206. #define DRDLY1 VA_TYPE 0x0004
  207. #define DRDLY0 VA_TYPE 0x0002
  208. #define QBFPU VA_TYPE 0x0001
  209. /* VAC interrupt status register and its bit mask constants  */
  210. #define H_VAC_IRQ_STAT  P_VA_TYPE (VAC_ADR +0x1500 )
  211. #define VAC_IRQ_PIO9 VA_TYPE 0x8000
  212. #define VAC_IRQ_PIO8 VA_TYPE 0x4000
  213. #define VAC_IRQ_PIO7 VA_TYPE 0x2000
  214. #define VAC_IRQ_PIO4 VA_TYPE 0x1000
  215. #define VAC_IRQ_MBX  VA_TYPE 0x0800
  216. #define VAC_IRQ_TMR  VA_TYPE 0x0400
  217. #define VAC_IRQ_SIOA VA_TYPE 0x0200
  218. #define VAC_IRQ_SIOB VA_TYPE 0x0100
  219. /* VAC IRQ signal map and control register  */
  220. #define H_VAC_IRQ_CTL  P_VA_TYPE (VAC_ADR +0x1600 )
  221. /*
  222. The values are designed to be used as follows.  The interrupt
  223. source on the VAC and the actual PIO signals to the VIC are
  224. combined to produce a VAC interrupt control value, or bit map,
  225. that can be used with a mask value to toggle the control bits.
  226. Example:
  227.   control bit map         IRQ pin dest     VAC IRQ source
  228. #define   IRQ_VAC_TMR_CTL_MAP (IRQ_DEST_PIO10 << IRQ_VAC_SRC_TMR)
  229. To remove a VAC interrupt you must disable and enable the VAC interrupt
  230. via the VAC Interrupt Control Register.
  231. Clear the IRQ map to disable the IRQ:
  232. sysVacFieldSet (H_VAC_IRQ_CTL,  IRQ_VAC_TMR_CTL_MASK,
  233. (IRQ_VAC_TMR_CTL_MAP & VAC_IRQ_DISABLE));
  234. Map it back in to enable the IRQ:
  235. sysVacFieldSet (H_VAC_IRQ_CTL, IRQ_VAC_TMR_CTL_MASK,
  236. (IRQ_VAC_TMR_CTL_MAP & VAC_IRQ_ENABLE));
  237. */
  238. #define IRQ_PIO9_CTL_MASK  VA_TYPE 0xc000
  239. #define IRQ_PIO8_CTL_MASK  VA_TYPE 0x3000
  240. #define IRQ_PIO7_CTL_MASK  VA_TYPE 0x0c00
  241. #define IRQ_PIO4_CTL_MASK  VA_TYPE 0x0300
  242. #define IRQ_MBX_CTL_MASK   VA_TYPE 0x00c0
  243. #define IRQ_SIOA_CTL_MASK  VA_TYPE 0x0030
  244. #define IRQ_SIOB_CTL_MASK  VA_TYPE 0x000c
  245. #define IRQ_VAC_TMR_CTL_MASK  VA_TYPE 0x0003
  246. #define VAC_IRQ_DISABLE    0
  247. #define VAC_IRQ_ENABLE     0xffff
  248. /* shift values to map the pio signal destination */
  249. #define IRQ_SRC_PIO9 VA_TYPE 0xE
  250. #define IRQ_SRC_PIO8 VA_TYPE 0xC
  251. #define IRQ_SRC_PIO7 VA_TYPE 0xA
  252. #define IRQ_SRC_PIO4 VA_TYPE 0x8
  253. #define IRQ_SRC_MBX VA_TYPE 0x6
  254. #define IRQ_SRC_SIOA VA_TYPE 0x4
  255. #define IRQ_SRC_SIOB VA_TYPE 0x2
  256. #define IRQ_SRC_VAC_TMR VA_TYPE 0x0
  257. /* pio signal destination */
  258. #define IRQ_DEST_NULL      0
  259. #define IRQ_DEST_PIO7      1
  260. #define IRQ_DEST_PIO10     2
  261. #define IRQ_DEST_PIO11     3
  262. /* device present flags  */
  263. #define H_VAC_DEVICE_LOC  P_VA_TYPE (VAC_ADR +0x1700 )
  264. #define IOSEL5_PRESENT VA_TYPE 0x0020
  265. #define IOSEL4_PRESENT VA_TYPE 0x0010
  266. #define IOSEL3_PRESENT VA_TYPE 0x0008
  267. #define IOSEL2_PRESENT VA_TYPE 0x0004
  268. #define IOSEL1_PRESENT VA_TYPE 0x0002
  269. #define IOSEL0_PRESENT VA_TYPE 0x0001
  270. /* this reg used to init pio data out values   */
  271. #define H_VAC_PIO_DATA  P_VA_TYPE (VAC_ADR +0x1800 )
  272. /* read only - contains login levels of pio pins  */
  273. #define H_VAC_PIO_PIN  P_VA_TYPE (VAC_ADR +0x1900 )
  274. /* set up the direction of pio */
  275. #define H_VAC_PIO_DIR  P_VA_TYPE (VAC_ADR + 0x1a00)
  276. /* assign functions to the pio  */
  277. #define H_VAC_PIO_FUNC  P_VA_TYPE (VAC_ADR + 0x1b00)
  278. /* pio bit mask defines */
  279. #define PIO0   VA_TYPE 0x0001
  280. #define PIO1   VA_TYPE 0x0002
  281. #define PIO2   VA_TYPE 0x0004
  282. #define PIO3   VA_TYPE 0x0008
  283. #define PIO4   VA_TYPE 0x0010
  284. #define PIO5   VA_TYPE 0x0020
  285. #define PIO6   VA_TYPE 0x0040
  286. #define PIO7   VA_TYPE 0x0080
  287. #define PIO8   VA_TYPE 0x0100
  288. #define PIO9   VA_TYPE 0x0200
  289. #define PIO10  VA_TYPE 0x0400
  290. #define PIO11  VA_TYPE 0x0800
  291. #define PIO12  VA_TYPE 0x1000
  292. #define PIO13  VA_TYPE 0x2000
  293. #define PIO9_DEBOUNCE_ENABLE   VA_TYPE 0x4000
  294. #define CPU_SPACE_EMULATE VA_TYPE 0x8000
  295. #define TXDA_TO_PIO0   VA_TYPE 0x0001
  296. #define RXTA_TO_PIO1   VA_TYPE 0x0002
  297. #define TXDB_TO_PIO2      VA_TYPE 0x0004
  298. #define TXDB_TO_PIO3      VA_TYPE 0x0008
  299. #define IORD_TO_PIO4      VA_TYPE 0x0010
  300. #define IOWR_TO_PIO5      VA_TYPE 0x0020
  301. #define IOSEL3_TO_PIO6    VA_TYPE 0x0040
  302. #define PIO7IRQ_TO_PIO7   VA_TYPE 0x0080
  303. #define IOSEL4_TO_PIO8    VA_TYPE 0x0100
  304. #define IOSEL5_TO_PIO9    VA_TYPE 0x0200
  305. #define PIO10IRQ_TO_PIO10  VA_TYPE 0x0400
  306. #define PIO11IRQ_TO_PIO10  VA_TYPE 0x0800
  307. #define SHRCS_TO_PIO12     VA_TYPE 0x1000
  308. #define IOSEL2_TO_PIO13    VA_TYPE 0x2000
  309. #define PIO9_DEBOUNCE_DISABLE         VA_TYPE 0x4000
  310. #define CPU_SPACE_EMULATE_VIA_IOSEL5 VA_TYPE 0x8000
  311. /* SIO STUFF */
  312. /*
  313. Get table for BAUD_PRESCALE_INIT VALS:
  314. NOTE
  315. The SIO baud rate divisor is dependent on CPU_CLOCK
  316. and is derived from the following formula
  317.                       /          CPU clock rate              
  318.  divisor = truncate |  ---------------------------- + 0.5  |
  319.        16 * (MAX baud rate desired)        /
  320. where divisor > 8.
  321. This value is loaded into the top byte of the VAC CPU
  322. clock divisor.
  323. The baud rate selection table will allow selection of
  324. 8 different baud rates. Each lower than the MAX baud rate
  325. by a power of 2. If 9600 baud is the MAX baud rate, then
  326. the following powers are available:
  327. baud select value           baud rate
  328. 7          76800   don't use
  329. 6        19200
  330. 5 9600
  331. 4 4800
  332. 3 2400
  333. 2 1200
  334. 1 600
  335. 0 300
  336. */
  337. /*      max rate      cpu clk   divisor   */
  338. /* check these values for roundup */
  339. #define BAUD_9600_CLK_20MHz 0x2000
  340. #define BAUD_9600_CLK_25MHz 0x2800
  341. #define BAUD_9600_CLK_32MHz 0x3400
  342. #define BAUD_9600_CLK_33MHz 0x3500
  343. #define BAUD_19200_CLK_20MHz    0x0fff /*subtract one from above formula*/
  344. #define BAUD_19200_CLK_25MHz 0x1400
  345. #define BAUD_19200_CLK_32MHz 0x1a00
  346. #define BAUD_19200_CLK_33MHz 0x1a00
  347. #define BAUD_19200_CLK_40MHz 0x2000
  348. /*Baud Rate Prescaler  used on CPU Clk. */
  349. #define H_VAC_BAUD_PRESCALE  P_VA_TYPE (VAC_ADR + 0x1c00)
  350. /* control register  */
  351. #define H_VAC_SIOA_MODE  P_VA_TYPE (VAC_ADR + 0x1d00)
  352. /* control bits for both sioa and siob */
  353. #define SIO_CTL_ENABLE  VA_TYPE 0xfcff
  354. #define SIO_CTL_DISABLE  VA_TYPE 0x0300
  355. /* the following are masks */
  356. #define PARITY_ENABLE  VA_TYPE 0x8000
  357. #define EVEN_PARITY  VA_TYPE 0x4000
  358. #define EIGHT_BITS  VA_TYPE 0x2000
  359. #define BAUD_RATE_MASK  VA_TYPE 0x1c00
  360. #define RESET_RECV  VA_TYPE 0x0200
  361. #define RESET_XMIT  VA_TYPE 0x0100
  362. #define XMITER   VA_TYPE 0x0080
  363. #define RECVER   VA_TYPE 0x0040
  364. #define SEND_BREAK   VA_TYPE 0x0020
  365. #define TXDA_TO_RXDA  VA_TYPE 0x0010
  366. /* NOTE: vac sio data bytes are taken from high 8 bits !! */
  367. /* xmit data  */
  368. #define H_VAC_SIOA_XMIT  P_VA_TYPE (VAC_ADR + 0x1e00)
  369. /* control register  */
  370. #define H_VAC_SIOB_MODE  P_VA_TYPE (VAC_ADR + 0x1f00)
  371. /* rec data */
  372. #define H_VAC_SIOA_RECV  P_VA_TYPE (VAC_ADR + 0x2000)
  373. #define H_VAC_SIOB_RECV  P_VA_TYPE (VAC_ADR + 0x2100)
  374. /* xmit data  */
  375. #define H_VAC_SIOB_XMIT  P_VA_TYPE (VAC_ADR + 0x2200)
  376. /* sio interrupt mask regs    */
  377. #define H_VAC_SIOA_IRQ_MASK  P_VA_TYPE (VAC_ADR + 0x2300)
  378. #define H_VAC_SIOB_IRQ_MASK  P_VA_TYPE (VAC_ADR + 0x2400)
  379. #define SINGLE_CHAR_RECV_MASK   VA_TYPE 0x8000
  380. #define FIFO_FULL_MASK         VA_TYPE 0x4000
  381. #define BREAK_CHANGE_MASK       VA_TYPE 0x2000
  382. #define ERROR_MASK           VA_TYPE 0x1000
  383. #define XMIT_READY_MASK         VA_TYPE 0x0800
  384. #define XMIT_EMPTY_MASK         VA_TYPE 0x0400
  385. #define SIO_MASK_ENABLE     VA_TYPE 0xffff
  386. #define SIO_MASK_DISABLE    VA_TYPE 0x0000
  387. /* sio status regs   */
  388. #define H_VAC_SIOA_STAT  P_VA_TYPE (VAC_ADR + 0x2500)
  389. #define H_VAC_SIOB_STAT  P_VA_TYPE (VAC_ADR + 0x2600)
  390. #define CHAR_READY     VA_TYPE 0x8000
  391. #define FIFO_FULL VA_TYPE 0x4000
  392. #define BREAK_CHANGE    VA_TYPE 0x2000
  393. #define PARITY_ERROR    VA_TYPE 0x1000
  394. #define FRAMING_ERROR   VA_TYPE 0x0800
  395. #define OVERRUN_ERROR   VA_TYPE 0x0400
  396. #define XMIT_READY  VA_TYPE 0x0200
  397. #define XMIT_EMPTY VA_TYPE 0x0100
  398. /* VAC TIMER STUFF */
  399. #define H_VAC_TMR_DATA  P_VA_TYPE (VAC_ADR + 0x2700)
  400. #define H_VAC_TMR_CTL  P_VA_TYPE (VAC_ADR + 0x2800)
  401. #define PRESCALER_IN_MASK     VA_TYPE 0x3f00
  402. #define PRESCALER_IN_SHIFT  8
  403. /* use this to read the instantaneous count value of prescaler */
  404. #define PRESCALER_OUT_MASK     VA_TYPE 0x003f
  405. #define  VAC_20MHZ_CPU_1MHZ_PRESCALER   (19 << PRESCALER_IN_SHIFT)
  406. #define  VAC_25MHZ_CPU_1MHZ_PRESCALER (24 << PRESCALER_IN_SHIFT)
  407. #define  VAC_33MHZ_CPU_1MHZ_PRESCALER (32 << PRESCALER_IN_SHIFT)
  408. #define  VAC_40MHZ_CPU_1MHZ_PRESCALER (39 << PRESCALER_IN_SHIFT)
  409. /* Load command disables timer and then loads the interal timer registers    */
  410. /* with the values in the prescaler control bits and the timer data register */
  411. #define RUN_LOAD_MASK VA_TYPE 0x4000
  412. #define RUN_CMD VA_TYPE 0x4000
  413. #define STOP_N_LOAD_CMD VA_TYPE 0x0000
  414. /* You can set the timer to only produce a single irq after the time  */
  415. /* has elapsed or reset the counter for continuous irqs               */
  416. #define SINGLE_CONT_MASK VA_TYPE 0x8000
  417. #define SINGLE_IRQ_CMD VA_TYPE 0x8000
  418. #define CONT_IRQ_CMD VA_TYPE 0x0000
  419. /*************************************************************************
  420. * The vac timer rate is calculated as follows:
  421. *
  422. *
  423. *           /      CPU_CLOCK      
  424. *                 |  -------------------  |
  425. *            prescaler value + 1 /
  426. *timer rate =  ------------------------------
  427. *       (65536 - time data reg. value)
  428. *
  429. *
  430. * where prescaler is set to an arbitrary value.
  431. *
  432. *
  433. *this gives us a time data register value of
  434. *
  435. *
  436. *                /      CPU_CLOCK      
  437. *       |  -------------------  |
  438. *                         prescaler value + 1 /
  439. *timer data val =   65536 -  ----------------------------
  440. * reqested timer rate
  441. *
  442. *
  443. *
  444. *
  445. *PROGRAMING EXAMPLE:
  446. *
  447. *
  448. *to get a 100Hz time rate with a 25MHz cpu clock
  449. *
  450. *  - arbitrarily set prescaler value to 24 which will produce a
  451. *    1MHz time period for each count in the time data register
  452. *
  453. *
  454. *          /  25000000 
  455. *         |  ---------  |
  456. *                     24 + 1  /
  457. * time data val = 65536 - ------------- = 55536 = 0xd8f0
  458. *            100
  459. *
  460. *
  461. * - set prescaler
  462. * *H_VAC_TMR_CTL =  (*H_VAC_TMR_CTL & ~PRSCALER_IN_MASK) |
  463. * VAC_25MHZ_CPU_1MHZ_PRESCALER ;
  464. * - set timer data register
  465. * *H_VAC_TMR_DATA = 0x8df0 ;
  466. *
  467. * - disable timer and load above values into internal registers
  468. * *H_VAC_TMR_CTL =  (*H_VAC_TMR_CTL & ~RUN_LOAD_MASK) | STOP_N_LOAD_CMD ;
  469. *
  470. * - set control for continuous operation
  471. * *H_VAC_TMR_CTL =  (*H_VAC_TMR_CTL & ~SINGLE_CONT_MASK) | CONT_CMD ;
  472. *
  473. * - start timer
  474. * *H_VAC_TMR_CTL =  (*H_VAC_TMR_CTL & ~RUN_LOAD_MASK) | RUN_CMD ;
  475. *
  476. ***************************************************************************/
  477. /* Vac ID Reg. Read to Startup  */
  478. #define H_VAC_ID_GO  P_VA_TYPE (VAC_ADR + 0x2900)
  479. /* now for some generic io Macros      */
  480. /* These macros are designed so that they can be dropped into a generic   */
  481. /* serial handler, They are intended to be the basic building blocks used */
  482. /* to port any serial handler to use the VAC.    */
  483. #ifndef _ASMLANGUAGE
  484. #define SIOA 0
  485. #define SIOB 1
  486. /*the following macros expect SIOA or SIOB for u arg-there's no error checking*/
  487. #define XMITER_EMPTY(u) ( XMIT_EMPTY & vaRegGet( H_VAC_SIOA_STAT + 
  488.    ((u)* ( H_VAC_SIOB_STAT - H_VAC_SIOA_STAT ) ) ) )
  489. #define XMITER_READY(u) ( XMIT_READY & vaRegGet( H_VAC_SIOA_STAT + 
  490.    ((u)* ( H_VAC_SIOB_STAT - H_VAC_SIOA_STAT ) ) ) )
  491. #define RECVER_READY(u) ( CHAR_READY & vaRegGet( H_VAC_SIOA_STAT + 
  492.    ((u)* ( H_VAC_SIOB_STAT - H_VAC_SIOA_STAT ) ) ) )
  493. #define XMIT_CHAR(u,ch)   vaRegSet( H_VAC_SIOA_XMIT + 
  494.    ((u)* ( H_VAC_SIOB_XMIT - H_VAC_SIOA_XMIT ) ) , 
  495. (unsigned short)( ((unsigned short)(ch))<<8 ) )
  496. #define RECV_CHAR(u,pc)    *(pc) = (unsigned char)(0x00ff & 
  497. vaRegGet( H_VAC_SIOA_RECV + 
  498.    ((u)* ( H_VAC_SIOB_RECV - H_VAC_SIOA_RECV ) ) ) )
  499. #define POLLING
  500. /* The following P_GETC and P_PUTC macros are designed for POLLING only!!!  */
  501. /* NOTE: The delay loops may need to be altered depending on the board rev. */
  502. #ifdef POLLING
  503. /* P_PUTC(u,ch) - output char "ch" to "u" where "u" is SIOA or SIOB */
  504. /* add delay, NOTE: no fifo stuff allowed */
  505. #define P_PUTC(u,ch)  
  506.     while (  ! XMITER_READY( (u) )  ) ;  
  507.     XMIT_CHAR( (u),(ch) );  
  508.     while (   XMITER_READY( (u) )  )
  509. /* P_GETC(u,pc) - input char into char pointer "pc" from */
  510. /*                "u" where "u" is SIOA or SIOB */
  511. #define P_GETC(u,pc) 
  512.     { 
  513.     int x; 
  514.     while ( ! RECVER_READY( (u) ) ) 
  515.     for(x=0;x<100;x++) ; 
  516.     RECV_CHAR( (u), (pc) )  ; 
  517.     }
  518. #endif /* POLLING */
  519. #endif /* _ASMLANGUAGE */
  520. #ifdef __cplusplus
  521. }
  522. #endif
  523. #endif /* __INCivach */