/* this is a generic bare minimum derivative definition file,
   which can used for your own extensions */

#ifndef _GENERIC_HCS08_H
#define _GENERIC_HCS08_H

/* Types definition */
typedef unsigned char byte;
typedef unsigned int word;
typedef unsigned long dword;
typedef unsigned long dlong[2];

#ifdef _lint
  #define __RESET_WATCHDOG() /* empty */
#else
  #define __RESET_WATCHDOG() {asm sta SRS;} /* just write a byte to feed the dog */
#endif

#pragma MESSAGE DISABLE C1106 /* WARNING C1106: Non-standard bitfield type */

/*** PTAD - Port A Data Register ***/
typedef union {
  byte Byte;
  struct {
    byte PTAD0    :1;           /* Port A Data Bit 0 */
    byte PTAD1    :1;           /* Port A Data Bit 1, Keyboard interrupt pin 1 */
    byte PTAD2    :1;           /* Port A Data Bit 2, Keyboard interrupt pin 2 */
    byte PTAD3    :1;           /* Port A Data Bit 3, Keyboard interrupt pin 3 */
    byte PTAD4    :1;           /* Port A Data Bit 4, Keyboard interrupt pin 4 */
    byte PTAD5    :1;           /* Port A Data Bit 5, Keyboard interrupt pin 5 */
    byte PTAD6    :1;           /* Port A Data Bit 6, Keyboard interrupt pin 6 */
    byte PTAD7    :1;           /* Port A Data Bit 7 */
  } Bits;
  struct {
    byte PTAD_    :8;
  } MergedBits;
} PTADSTR;
extern volatile PTADSTR _PTAD;
#define PTAD _PTAD.Byte
#define PTAD_PTAD0 _PTAD.Bits.PTAD0
#define PTAD_PTAD1 _PTAD.Bits.PTAD1
#define PTAD_PTAD2 _PTAD.Bits.PTAD2
#define PTAD_PTAD3 _PTAD.Bits.PTAD3
#define PTAD_PTAD4 _PTAD.Bits.PTAD4
#define PTAD_PTAD5 _PTAD.Bits.PTAD5
#define PTAD_PTAD6 _PTAD.Bits.PTAD6
#define PTAD_PTAD7 _PTAD.Bits.PTAD7
#define PTAD_PTAD _PTAD.MergedBits.PTAD_

/*** PTADD - Data Direction Register A ***/
typedef union {
  byte Byte;
  struct {
    byte PTADD0   :1;           /* Data Direction Register A Bit 0 */
    byte PTADD1   :1;           /* Data Direction Register A Bit 1 */
    byte PTADD2   :1;           /* Data Direction Register A Bit 2 */
    byte PTADD3   :1;           /* Data Direction Register A Bit 3 */
    byte PTADD4   :1;           /* Data Direction Register A Bit 4 */
    byte PTADD5   :1;           /* Data Direction Register A Bit 5 */
    byte PTADD6   :1;           /* Data Direction Register A Bit 6 */
    byte PTADD7   :1;           /* Data Direction Register A Bit 7 */
  } Bits;
  struct {
    byte PTADD_    :8;
  } MergedBits;
} PTADDSTR;
extern volatile PTADDSTR _PTADD;
#define PTADD _PTADD.Byte
#define PTADD_PTADD0 _PTADD.Bits.PTADD0
#define PTADD_PTADD1 _PTADD.Bits.PTADD1
#define PTADD_PTADD2 _PTADD.Bits.PTADD2
#define PTADD_PTADD3 _PTADD.Bits.PTADD3
#define PTADD_PTADD4 _PTADD.Bits.PTADD4
#define PTADD_PTADD5 _PTADD.Bits.PTADD5
#define PTADD_PTADD6 _PTADD.Bits.PTADD6
#define PTADD_PTADD7 _PTADD.Bits.PTADD7
#define PTADD_PTADD _PTADD.MergedBits.PTADD_

/*** SRS - System Reset Status Register; COP controlled by bit 5 ***/
typedef union {
  byte Byte;
  struct {
    byte BIT0    :1;           /* Bit 0 */
    byte BIT1    :1;           /* Bit 1 */
    byte BIT2    :1;           /* Bit 2 */
    byte BIT3    :1;           /* Bit 3 */
    byte BIT4    :1;           /* Bit 4 */
    byte BIT5    :1;           /* Bit 5 */
    byte BIT6    :1;           /* Bit 6 */
    byte BIT7    :1;           /* Bit 7 */
  } Bits;
  struct {
    byte BIT_     :8;
  } MergedBits;
} SRSSTR;
extern volatile SRSSTR _SRS;
#define SRS _SRS.Byte
#define SRS_BIT0 _SRS.Bits.BIT0
#define SRS_BIT1 _SRS.Bits.BIT1
#define SRS_BIT2 _SRS.Bits.BIT2
#define SRS_BIT3 _SRS.Bits.BIT3
#define SRS_BIT4 _SRS.Bits.BIT4
#define SRS_BIT5 _SRS.Bits.BIT5
#define SRS_BIT6 _SRS.Bits.BIT6
#define SRS_BIT7 _SRS.Bits.BIT7
#define SRS_BIT _SRS.MergedBits.BIT_

#endif
