/* H8/300 data types, system control and exception handling.
   Last updated 24.6.00
*/

#ifndef   H8_H_DEFINED
#define   H8_H_DEFINED

/***** Data types *****/

/* Section 2, CPU, 2.3 Data Formats. */
#define TRUE    1
#define FALSE   0

typedef unsigned char      byte;
typedef unsigned short int word;
typedef short int          int16;
typedef unsigned short int uint16;

#define bit0    (1 << 0)
#define bit1    (1 << 1)
#define bit2    (1 << 2)
#define bit3    (1 << 3)
#define bit4    (1 << 4)
#define bit5    (1 << 5)
#define bit6    (1 << 6)
#define bit7    (1 << 7)

/***** System control *****/

/* Section 3, MCU Operating Modes and Address Space. */
#define SYSCR   *((volatile byte *) 0xffc4) /* System Control Register, p 54. */


/***** Exception Handling *****/

/* Condition Code Register, bit7 = global Interrupt mask bit, 
   0 enable, 1 disable */

void Enable( void ){  
  asm(" andc #0x7f, ccr ");
}

void Disable( void ){  
  asm(" orc  #0x80, ccr ");
}

/* I/0 port 4, bit2-bit0 can also be used to initiate
   external interrupts IRQ0-IRQ2. These
   external interrupts are controlled by two registers, ISCR
   and IER, Section 4, Exception Handling, p. 61.
 */
#define ISCR  *((volatile byte *) 0xffc6) /* IRQ Sense Control Register, p. 66 */
#define IER   *((volatile byte *) 0xffc7) /* IRQ Enable Register, p. 67 */


#endif /* H8_H_DEFINED */ 
