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

#ifndef _GENERIC_H
#define _GENERIC_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 COPCTL;} /* just write a byte to feed the dog */
#endif

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

/*** PTA - Port A Data Register ***/
typedef union {
  byte Byte;
  struct {
    byte PTA0    :1;           /* Port A Data Bit 0 */
    byte PTA1    :1;           /* Port A Data Bit 1, Keyboard interrupt pin 1 */
    byte PTA2    :1;           /* Port A Data Bit 2, Keyboard interrupt pin 2 */
    byte PTA3    :1;           /* Port A Data Bit 3, Keyboard interrupt pin 3 */
    byte PTA4    :1;           /* Port A Data Bit 4, Keyboard interrupt pin 4 */
    byte PTA5    :1;           /* Port A Data Bit 5, Keyboard interrupt pin 5 */
    byte PTA6    :1;           /* Port A Data Bit 6, Keyboard interrupt pin 6 */
    byte PTA7    :1;           /* Port A Data Bit 7 */
  } Bits;
  struct {
    byte PTA_     :8;
  } MergedBits;
} PTASTR;
extern volatile PTASTR _PTA;
#define PTA _PTA.Byte
#define PTA_PTA0 _PTA.Bits.PTA0
#define PTA_PTA1 _PTA.Bits.PTA1
#define PTA_PTA2 _PTA.Bits.PTA2
#define PTA_PTA3 _PTA.Bits.PTA3
#define PTA_PTA4 _PTA.Bits.PTA4
#define PTA_PTA5 _PTA.Bits.PTA5
#define PTA_PTA6 _PTA.Bits.PTA6
#define PTA_PTA7 _PTA.Bits.PTA7
#define PTA_PTA _PTA.MergedBits.PTA_

/*** DDRA - Data Direction Register A ***/
typedef union {
  byte Byte;
  struct {
    byte DDRA0   :1;           /* Data Direction Register A Bit 0 */
    byte DDRA1   :1;           /* Data Direction Register A Bit 1 */
    byte DDRA2   :1;           /* Data Direction Register A Bit 2 */
    byte DDRA3   :1;           /* Data Direction Register A Bit 3 */
    byte DDRA4   :1;           /* Data Direction Register A Bit 4 */
    byte DDRA5   :1;           /* Data Direction Register A Bit 5 */
    byte DDRA6   :1;           /* Data Direction Register A Bit 6 */
    byte DDRA7   :1;           /* Data Direction Register A Bit 7 */
  } Bits;
  struct {
    byte DDRA_    :8;
  } MergedBits;
} DDRASTR;
extern volatile DDRASTR _DDRA;
#define DDRA _DDRA.Byte
#define DDRA_DDRA0 _DDRA.Bits.DDRA0
#define DDRA_DDRA1 _DDRA.Bits.DDRA1
#define DDRA_DDRA2 _DDRA.Bits.DDRA2
#define DDRA_DDRA3 _DDRA.Bits.DDRA3
#define DDRA_DDRA4 _DDRA.Bits.DDRA4
#define DDRA_DDRA5 _DDRA.Bits.DDRA5
#define DDRA_DDRA6 _DDRA.Bits.DDRA6
#define DDRA_DDRA7 _DDRA.Bits.DDRA7
#define DDRA_DDRA _DDRA.MergedBits.DDRA_

/*** COPCTL - COP Control Register ***/
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;
} COPCTLSTR;
extern volatile COPCTLSTR _COPCTL;
#define COPCTL _COPCTL.Byte
#define COPCTL_BIT0 _COPCTL.Bits.BIT0
#define COPCTL_BIT1 _COPCTL.Bits.BIT1
#define COPCTL_BIT2 _COPCTL.Bits.BIT2
#define COPCTL_BIT3 _COPCTL.Bits.BIT3
#define COPCTL_BIT4 _COPCTL.Bits.BIT4
#define COPCTL_BIT5 _COPCTL.Bits.BIT5
#define COPCTL_BIT6 _COPCTL.Bits.BIT6
#define COPCTL_BIT7 _COPCTL.Bits.BIT7
#define COPCTL_BIT _COPCTL.MergedBits.BIT_

#endif
