#ifndef _PIT_H
#define _PIT_H

/*
 * This file and its contents are supplied under the terms of the
 * Mozilla Public License (MPL) version 2.0.  You may only use this
 * file in accordance with the terms of version 2.0 of the MPL.
 *
 * A full copy of the text of the MPL should have accompanied this
 * source.  A copy of the MPL is also available via the Internet at
 * https://www.mozilla.org/en-CA/MPL/2.0.
 *
 * This Source Code Form is "Incompatible With Secondary Licenses",
 * as defined by the Mozilla Public License, v. 2.0.
 *
 * This is the header file for the Fight Board Parallel Interface/Timer
 * (PI/T) chip, the MC68230.
 *
 * pit_struct is a bit iffy as it relies on the word-length of the
 * machine, i.e., unsigned shorts being 16 bits.  A more modern
 * solution would be to use uint16_ts, but the cc68 compiler
 * originally used predates * stdint.h.
 *
 * (C) Copyright Rich Teer 1990, 2023, 2026.
 */

typedef struct pit_struct {
	unsigned short pgcr;			/* Port General Control Register */
	unsigned short psrr;			/* Port Service Request Register */
	unsigned short paddr;			/* Port A Data Direction Register */
	unsigned short pbddr;			/* Port B Data Direction Register */
	unsigned short pcddr;			/* Port C Data Direction Register */
	unsigned short pivr;			/* Port Interrupt Vector Register */
	unsigned short pacr;			/* Port A Control Register */
	unsigned short pbcr;			/* Port B Control Register */
	unsigned short padr;			/* Port A Data Register */
	unsigned short pbdr;			/* Port B Data Register */
	unsigned short paar;			/* Port A Alternate Register */
	unsigned short pbar;			/* Port B Alternate Register */
	unsigned short pcdr;			/* Port C Data Register */
	unsigned short psr;				/* Port Status Register */
	unsigned int dummy1;			/* To account for a gap */
	unsigned short tcr;				/* Timer Control Register */
	unsigned short tivr;			/* Timer Interrupt Vector Register */
	unsigned short dummy2;			/* Another gap! */
	unsigned short cprh;			/* Counter Preload Register High */
	unsigned short cprm;			/* Counter Preload Register Middle */
	unsigned short cprl;			/* Counter Preload Register Low */
	unsigned short dummy3;			/* Yet another gap! */
	unsigned short cntrh;			/* Count Register High */
	unsigned short cntrm;			/* Count Register Middle */
	unsigned short cntrl;			/* Count Register Low */
	unsigned short tsr;				/* Timer Status Register */
} pit_t;

#endif
