]> rtime.felk.cvut.cz Git - sysless.git/blob - board/h8300/hi_cpu2/defines/system_def_hi_cpu2.h
It is 12 years after C99 standardization - switch to stdint.h and its types.
[sysless.git] / board / h8300 / hi_cpu2 / defines / system_def_hi_cpu2.h
1 /*******************************************************************
2   Components for embedded applications builded for
3   laboratory and medical instruments firmware  
4  
5   system_def_hi_cpu2.h - definition of hardware adresses and registers
6  
7   Copyright (C) 2002 by Pavel Pisa pisa@cmp.felk.cvut.cz
8             (C) 2002 by PiKRON Ltd. http://www.pikron.com
9
10  *******************************************************************/
11
12 #ifndef _SYSTEM_DEF_HW01_H_
13 #define _SYSTEM_DEF_HW01_H_
14
15 //#define CPU_REF_HZ  11059200l /* reference clock frequency      */
16 //#define CPU_SYS_HZ  11059200l /* default system clock frequency */
17
18 //#define CPU_REF_HZ 18423000l  /* reference clock for EDK2638    */
19 //#define CPU_SYS_HZ 18423000l  /* default system  for EDK2638    */
20
21 #define CPU_REF_HZ  5000000l    /* reference clock for HI_CPU2    */
22 #define CPU_SYS_HZ 20000000l    /* default system  for HI_CPU2    */
23
24
25 unsigned long cpu_ref_hz;       /* actual external XTAL reference */
26 unsigned long cpu_sys_hz;       /* actual system clock frequency  */
27
28 volatile unsigned long msec_time;
29
30 #define SCI_RS232_CHAN_DEFAULT 1
31
32 /* Keyboard KL41 (CS3) */
33 #define KL41_LCD_INST  (volatile uint8_t * const)(0x700000)
34 #define KL41_LCD_STAT  (volatile uint8_t * const)(0x700001)
35 #define KL41_LCD_WDATA (volatile uint8_t * const)(0x700002)
36 #define KL41_LCD_RDATA (volatile uint8_t * const)(0x700003)
37 #define KL41_LED_WR    (volatile uint8_t * const)(0x700001)
38 #define KL41_KBD_WR    (volatile uint8_t * const)(0x700003)
39 #define KL41_KBD_RD    (volatile uint8_t * const)(0x700004)
40
41 #define KL41_SUPPORT_ENABLED
42
43
44
45 /* SGM Small graphics LCD module 240x64 (CS3) */
46 #define SGM_LCD_DATA   (volatile uint8_t * const)(0x700000)
47 #define SGM_LCD_CMD    (volatile uint8_t * const)(0x700001)
48 #define SGM_LCD_STAT   (volatile uint8_t * const)(0x700001)
49 /* Keyboard on MO_KBD1 */
50 #define SGM_KBDI       (volatile uint8_t * const)(0x700002)
51 #define SGM_KBDO       (volatile uint8_t * const)(0x700002)
52
53 //#define SGM_SUPPORT_ENABLED
54
55 /* XRAM 1 MB (CS2) */
56 #define XRAM_START    (volatile uint8_t * const)(0x500000)
57
58 #define XRAM_SUPPORT_ENABLED
59
60 /* SRAM 32 kB (CSx) */
61 //#define SRAM_START    (volatile uint8_t * const)(0x610000)
62
63 /* AUXPORT (CS1) */
64 #define AUXPORT_START   (volatile uint8_t * const)(0x200000)
65
66 #if 0
67 #define ISR_USB_INTV            EXCPTVEC_IRQ2   /* pin IRQ2 on PF.0 */
68 #define PDIUSB_TEST_IRQ()       (!(*DIO_PORTF & 1))
69 #define PDIUSB_READ_DATA_ADDR   (volatile uint8_t * const)(0x500000)
70 #define PDIUSB_WRITE_DATA_ADDR  (volatile uint8_t * const)(0x500000)
71 #define PDIUSB_COMMAND_ADDR     (volatile uint8_t * const)(0x500001)
72
73 /* P1.0 .. DACK_N/DMACK0, P7.0 .. DMREQ/DREQ0, P7.2 .. EOT_N/TEND0 */
74 #undef  PDIUSB_WITH_ADD_IRQ_HANDLER
75 #define PDIUSB_WITH_EXCPTVECT_SET
76 #define PDIUSB_SUPPORT_ENABLED
77 #endif 
78
79
80
81 /* IDE (CS4) (CS5) powered by PF2 */
82 #define SIDE_START1   (volatile uint8_t * const)(0x800000)
83 #define SIDE_START2   (volatile uint8_t * const)(0xA00000)
84 #define IDE0_DATA     (volatile uint16_t * const)(SIDE_START1+0) /* DATA */
85 #define IDE0_ERROR     (SIDE_START1+2)  /* Error/Features RO/WO */
86 #define IDE0_NSECTOR   (SIDE_START1+4)  /* Sector Count R/W */
87 #define IDE0_SECTOR    (SIDE_START1+6)  /* SN, LBA 0-7 */
88 #define IDE0_LCYL      (SIDE_START1+8)  /* CL, LBA 8-15 */
89 #define IDE0_HCYL      (SIDE_START1+10) /* CH, LBA 16-23 */
90 #define IDE0_CURRENT   (SIDE_START1+12) /* 1L1DHHHH , LBA 24-27 */
91 #define IDE0_STATUS    (SIDE_START1+14) /* Status */
92 #define IDE0_SELECT  IDE0_CURRENT
93 #define IDE0_FEATURE IDE0_ERROR
94 #define IDE0_COMMAND IDE0_STATUS        /* Command */
95
96 #define IDE0_DEVCTRL   (SIDE_START2+12) /* used for resets */
97 #define IDE0_ALTSTATUS (SIDE_START2+14) /* IDE0_STATUS - no clear irq */
98
99 #define IDE0_SETPWR(pwr) do{ \
100                         if(pwr) atomic_clear_mask_b1(4,DIO_PFDR); \
101                         else atomic_set_mask_b1(4,DIO_PFDR); \
102                 }while(0)
103
104 #define IDE0_PRESENT_M() ((*DIO_PORT9)&0x20)
105
106 #if (HW_VER_MAJOR == 0) && (HW_VER_MINOR == 2)
107   #define IDE_SWAP_BYTES
108 #endif
109
110 #define IDE0_SUPPORT_ENABLED
111
112
113
114 /* IRAM 16 kB of on-chip memory */
115 /* 0xffb000-0xffcfff .. 8 kB free */
116 /* 0xffd000-0xffdfff .. 4 kB for Flash emulation */
117 /* 0xffe000-0xffffc0 .. 4 kB - 64 B free*/
118 /* 0xffffc0-0xffffff .. 64 B free*/
119 #define IRAM_START    (volatile uint8_t * const)(0xffb000)
120 #define IRAM_START1   (volatile uint8_t * const)(0xffe000)
121 #define FRAM_START    (volatile uint8_t * const)(0xffffc0)
122
123 /* SCI0 - IrDA */
124 /* SCI1 - IIC0 (P34, P35) */
125 /* SCI2 - Boot */
126 /* SCI3 - SPI */
127 /* SCI4 - RS232/485 */
128
129 /* IRQ0 - RTC */
130 /* IRQ1 - Index mark */
131 /* IRQ6 - IDE */
132
133 /* Some registers are read only on H8S processors */
134 /* We use shadow registers for some of them */
135 #define SHADOW_REG_ALT(_reg,_mask,_xor) \
136     (*(_reg)=_reg##_shadow=(_reg##_shadow&~(_mask))^(_xor))
137
138 #define SHADOW_REG_SET(_reg,_mask) \
139     (*(_reg)=_reg##_shadow|=(_mask))
140
141 #define SHADOW_REG_CLR(_reg,_mask) \
142     (*(_reg)=_reg##_shadow&=~(_mask))
143
144 #define SHADOW_REG_RD(_reg) \
145     (_reg##_shadow)
146
147 #define SHADOW_REG_WR(_reg,_val) \
148     (*(_reg)=_reg##_shadow=(_val))
149
150 uint8_t DIO_P1DDR_shadow;
151 uint8_t DIO_P3DDR_shadow;
152 uint8_t DIO_PFDDR_shadow;
153 uint8_t DIO_PJDDR_shadow;
154
155 #define DEB_LED_INIT() \
156         do {\
157         *DIO_PJDR=0x00;\
158         SHADOW_REG_SET(DIO_PJDDR,0xee); /* set PJ.1, PJ.2, PJ.3 LED output */ \
159         } while (0)
160
161 #define DEB_LED_OFF(num) \
162     (*DIO_PJDR |= PJDR_PJ1DRm << (num))
163 #define DEB_LED_ON(num) \
164     (*DIO_PJDR &=~(PJDR_PJ1DRm << (num)))
165
166
167 #endif /* _SYSTEM_DEF_HW01_H_ */