home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / dobbs / v16n10 / embedcp.exe / MIO.EXE / MIO.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-23  |  6.6 KB  |  222 lines

  1. /* Register definitions for MIO
  2.  * ----------------------------
  3.  *
  4.  * Written : March 10th, 1991
  5.  * By      : Stuart G. Phillips
  6.  *
  7.  * Register address definitions/bit definitions for MIO and MIO library
  8.  * routine templates
  9.  *
  10.  */
  11.  
  12.  
  13. /* Control register bit definitions
  14.  * Note register is WRITE only
  15.  */
  16.  
  17. #define HOLD    0x00
  18. #define RUN        0x80
  19. #define WC800    0x00
  20. #define WCC00    0x08
  21. #define WD800    0x10
  22. #define WDC00    0x18
  23. #define W8K        0x00
  24. #define    W64K    0x04
  25. #define MIRQ2   0x00
  26. #define MIRQ3    0x01
  27. #define MIRQ5    0x02
  28. #define    MIRQ7    0x03
  29.  
  30.  
  31. /* V40 Control registers - literal definitions
  32.  * See NEC publication "uPD70208/216 V40/50 User's Manual"
  33.  * Publication number NECEL-000652
  34.  * for detailed information.
  35.  *
  36.  * Registers OPCN, OPHA, WCY1, WCY2, WMB, RFC are initialized by the
  37.  * MIO Boot PROM and normally shouldnt be changed.  Their values are
  38.  * set as follows:
  39.  *
  40.  * OPCN:
  41.  *        0xf0    - INT1/INT2 from INTP1/INTP2 pins
  42.  *                - Pin function select 0
  43.  *
  44.  * OPHA:
  45.  *        0x00    - I/O block for internal peripherals at 0x00 -> 0xff
  46.  *
  47.  * WCY1:
  48.  *         0x00    - Zero wait states for all RAM
  49.  *
  50.  * WCY2:
  51.  *        0x00    - Zero wait states for refresh or DMA
  52.  *
  53.  * WMB:
  54.  *        0x77    - Upper + lower memory block size = 512K
  55.  *
  56.  * RFC:
  57.  *        0x8d    - Refresh enable and timer divisor
  58.  *
  59.  */
  60.  
  61. #define    OPCN    0xfffe            /* On-chip Peripheral Connection register */
  62. #define OPSEL    0xfffd            /* On-chip Peripheral Selection register */
  63. #define OPHA    0xfffc            /* On-chip Peripheral High address */
  64. #define DULA    0xfffb            /* DMA low address register */
  65. #define IULA    0xfffa            /* ICU low address register */
  66. #define TULA    0xfff9            /* TCU low address register */
  67. #define SULA    0xfff8            /* SCU low address register */
  68. #define WCY2    0xfff6            /* Wait cycle register 2 */
  69. #define WCY1    0xfff5            /* Wait cycle register 1 */
  70. #define WMB        0xfff4            /* Wait state memory boundary */
  71. #define RFC        0xfff2            /* Refresh control register */
  72. #define TCKS    0xfff0            /* Timer clock selection register */
  73.  
  74.  
  75. /* I/O Memory map for internal peripherals */
  76.  
  77. #define TCUBASE    0x40            /* Timer */
  78. #define ICUBASE 0x50            /* Interrupt control (PIC) */
  79. #define DMABASE 0x60            /* DMA */
  80. #define IVEC    0x50            /* Interrupt vector base for ICU */
  81.  
  82. /* Peripheral selects in OPSEL */
  83.  
  84. #define DMAU    0x01            /* DMA Unit */
  85. #define ICU        0x02            /* Interrupt Unit */
  86. #define TCU        0x04            /* Timer Unit */
  87. #define SCU        0x08            /* Serial Unit */
  88. /* Timer control literals */
  89.  
  90. #define TMD        TCUBASE+3         /* Timer mode register address */
  91. #define TCT0    TCUBASE            /* Timer count 0 */
  92. #define TST0    TCUBASE            /* Timer status 0 */
  93. #define TCT1    TCUBASE+1        /* Timer count 1 */
  94. #define TST1    TCUBASE+1        /* Timer status 1 */
  95. #define TCT2    TCUBASE+2        /* Timer count 2 */
  96. #define TST2    TCUBASE+2        /* Timer status 2 */
  97.  
  98. /* Timer mode register - TCUBASE + 3 */
  99.  
  100. #define STCT0    0x00            /* Select timer 0 */
  101. #define STCT1    0x40            /* Select timer 1 */
  102. #define STCT2    0x80            /* Select timer 2 */
  103. #define SMLC    0xc0            /* Multiple latch */
  104. #define TCLC    0x00            /* Counter latch command */
  105. #define TLBO    0x10            /* Lower byte only */
  106. #define THBO    0x20            /* Higher byte only */
  107. #define TLFH    0x30            /* Lower byte followed by higher byte */
  108. #define TMOD0    0x00            /* Timer mode - 0 */
  109. #define TMOD1    0x02            /* Timer mode - 1 */
  110. #define TMOD2    0x04            /* Timer mode - 2 */
  111. #define TMOD3    0x06            /* Timer mode - 3 */
  112. #define TMOD4    0x08            /* Timer mode - 4 */
  113. #define TMOD5    0x0a            /* Timer mode - 5 */
  114. #define TCBCD    0x01            /* Count value in BCD */
  115. #define TCHEX    0x00            /* Count value in HEX */
  116.  
  117.  
  118. /* Control bits for use with Multiple latch command */
  119.  
  120. #define TC0NS    0x00            /* Counter 0 NOT selected */
  121. #define TC0S    0x02            /* Counter 0 selected */
  122. #define TC1NS    0x00            /* Counter 1 NOT selected */
  123. #define TC1S    0x04            /* Counter 1 selected */
  124. #define TC2NS    0x00            /* Counter 2 NOT selected */
  125. #define TC2S    0x08            /* Counter 2 selected */
  126. #define TSL        0x00            /* Status latched */
  127. #define TSNL    0x10            /* Status NOT latched */
  128. #define TCL        0x00            /* Count latched */
  129. #define TCNL    0x20            /* Count NOT latched */
  130. #define TNCV    0x00            /* Null count valid */
  131. #define TNCIV    0x40            /* Null count invalid */
  132. #define TOLL    0x00            /* Output level low */
  133. #define TOLH    0x80            /* Output level high */
  134.  
  135.  
  136. /* Interrupt Control Unit - literals */
  137.  
  138. #define IMDW    ICUBASE            /* Interrupt Mode word */
  139. #define IMKW    ICUBASE+1        /* Interrupt Mask word */
  140.  
  141.  
  142. /* Interrupt initialization words */
  143.  
  144. #define IIW1    0x10            /* IIW1 selector */
  145. #define IIW4NR    0x00            /* IIW4 NOT required */
  146. #define IIW4R    0x01            /* IIW4 required */
  147. #define IEM        0x00            /* Extended mode - slave controllers */
  148. #define ISM        0x02            /* Single mode - no slave controllers */
  149. #define IET        0x00            /* Edge triggered */
  150. #define ILT        0x08            /* Level triggered */
  151. #define IIW4    0x00            /* IIW4 select */
  152. #define IFI        0x00            /* FI Command mode 8/
  153. #define ISFI    0x02            /* Self finish mode */
  154. #define INN        0x00            /* Normal nesting */
  155. #define IEN        0x10            /* Extended nesting */
  156. #define SI1        0x02            /* IRQ1 is slave */
  157. #define SI2        0x04            /* IRQ2 is slave */
  158. #define SI3        0x08            /* IRQ3 is slave */
  159. #define SI4        0x10            /* IRQ4 is slave */
  160. #define SI5        0x20            /* IRQ5 is slave */
  161. #define SI6        0x40            /* IRQ6 is slave */
  162. #define SI7        0x80            /* IRQ7 is slave */
  163.  
  164. #define ISEOI    0x20            /* Specific End of Interrupt */
  165. #define IRQ0    0x00            /* IRQ 0 */
  166. #define IRQ1    0x01            /* IRQ 1 */
  167. #define IRQ2    0x02            /* IRQ 2 */
  168. #define IRQ3    0x03            /* IRQ 3 */
  169. #define IRQ4    0x04            /* IRQ 4 */
  170. #define IRQ5    0x05            /* IRQ 5 */
  171. #define IRQ6    0x06            /* IRQ 6 */
  172. #define IRQ7    0x07            /* IRQ 7 */
  173.  
  174.  
  175. /* Address of ROM monitor control field in shared memory window
  176.  * Field is set to 0xF4 when the monitor is active.
  177.  * Change the field to 0x90 causes the monitor to jump to 0000:0100
  178.  * and begin execution from that address
  179.  */
  180.  
  181. #define BOOTCTL 0x9f
  182. #define WAITING    0xf4
  183. #define MON_GO    0x90
  184.  
  185.  
  186. /* Addresses of SCC bases */
  187.  
  188. #define SCC1    0x0f40
  189. #define SCC2    0x0f44
  190.  
  191. #define CHANA    0x02
  192. #define CHANB    0x00
  193. #define    CMD        0x00
  194. #define DATA    0x01
  195.  
  196.  
  197. /* Inline procedure definitions */
  198.  
  199. #define disable() __emit__((char)(0xfa))
  200. #define enable()  __emit__((char)(0xfb))
  201.  
  202. unsigned char     __inportb__(int __portid);
  203. void                __outportb__(int __portid,unsigned char __value);
  204.  
  205. #define inportb         __inportb__
  206. #define outportb        __outportb__
  207.  
  208.  
  209. /* Library procedure templates */
  210.  
  211. /* SCC.C */
  212.  
  213. void scc_write (unsigned short,unsigned short,unsigned short);
  214. unsigned char scc_read (unsigned short,unsigned short);
  215. unsigned char scc_rdata (unsigned short);
  216. void scc_wdata(unsigned short,unsigned short);
  217.  
  218.  
  219. /* VECT.C */
  220.  
  221. void setvect(int interruptno,void interrupt(far *isr)());
  222.