/*---------------------------------------------------------------------------*
  Project:  NitroSDK - RTC - include
  File:     instruction.h

  Copyright 2003,2004 Nintendo.  All rights reserved.

  These coded instructions, statements, and computer programs contain
  proprietary information of Nintendo of America Inc. and/or Nintendo
  Company Ltd., and are protected by Federal copyright law.  They may
  not be disclosed to third parties or copied or duplicated in any form,
  in whole or in part, without the prior written consent of Nintendo.

  $Log: instruction.h,v $
  Revision 1.1  2004/05/12 02:28:12  terui
  initial upload

  $NoKeywords: $
 *---------------------------------------------------------------------------*/

#ifndef	NITRO_RTC_ARM7_INSTRUCTION_H_
#define	NITRO_RTC_ARM7_INSTRUCTION_H_

#ifdef	__cplusplus
extern "C" {
#endif

/*===========================================================================*/

#include	<nitro/rtc/common/type.h>

/*---------------------------------------------------------------------------*
	Constant definitions
 *---------------------------------------------------------------------------*/
// Instructions (Serial comms is LSB specification. Therefore LSB<->MSB defined in reverse)
#define		RTC_INSTRUCTION_READ		0x86		// <-> 0x61
#define		RTC_INSTRUCTION_WRITE		0x06		// <-> 0x60

// Parameters (Serial comms is LSB specification. Therefore LSB<->MSB defined in reverse)
#define		RTC_INSTRUCTION_STAT1		0x00		// <-> 0x00
#define		RTC_INSTRUCTION_STAT2		0x40		// <-> 0x02
#define		RTC_INSTRUCTION_FULL		0x20		// <-> 0x04
#define		RTC_INSTRUCTION_TIME		0x60		// <-> 0x06
#define		RTC_INSTRUCTION_ALARM1		0x10		// <-> 0x08
#define		RTC_INSTRUCTION_ALARM2		0x50		// <-> 0x0A
#define		RTC_INSTRUCTION_PULSE		0x10		// <-> 0x08
#define		RTC_INSTRUCTION_ADJUST		0x30		// <-> 0x0C
#define		RTC_INSTRUCTION_FREE		0x70		// <-> 0x0E


/*---------------------------------------------------------------------------*
	Function definitions
 *---------------------------------------------------------------------------*/
void	RTC_Reset( void );								// Send reset signal to device
void	RTC_SetHourFormat( u16 format );				// Set hour notation

void	RTC_ReadDateTime( RTCRawData* data );			// Read date, time
void	RTC_WriteDateTime( const RTCRawData* data );	// Write date, time
void	RTC_ReadDate( RTCRawDate* date );				// Read date
void	RTC_WriteDate( const RTCRawDate* date );		// Write date
void	RTC_ReadTime( RTCRawTime* time );				// Read time
void	RTC_WriteTime( const RTCRawTime* time );		// Write time
BOOL	RTC_ReadPulse( RTCRawPulse* pulse );			// Read frequency periodic interrupt register
BOOL	RTC_WritePulse( const RTCRawPulse* pulse );		// Write frequency periodic interrupt register
BOOL	RTC_ReadAlarm1( RTCRawAlarm* alarm );			// Read alarm 1 interrupt register
BOOL	RTC_WriteAlarm1( const RTCRawAlarm* alarm );	// Write alarm 1 interrupt register
BOOL	RTC_ReadAlarm2( RTCRawAlarm* alarm );			// Read alarm 2 interrupt register
BOOL	RTC_WriteAlarm2( const RTCRawAlarm* alarm );	// Write alarm 2 interrupt register
void	RTC_ReadStatus1( RTCRawStatus1* stat );			// Read status 1 register
void	RTC_WriteStatus1( const RTCRawStatus1* stat );	// Write status 1 register
void	RTC_ReadStatus2( RTCRawStatus2* stat );			// Read status 2 register
void	RTC_WriteStatus2( const RTCRawStatus2* stat );	// Write status 2 register
void	RTC_ReadAdjust( RTCRawAdjust* adjust );			// Read clock adjust register
void	RTC_WriteAdjust( const RTCRawAdjust* adjust );	// Write clock adjust register
void	RTC_ReadFree( RTCRawFree* free );				// Read free register
void	RTC_WriteFree( const RTCRawFree* free );		// Write free register


/*===========================================================================*/

#ifdef	__cplusplus
}		/* extern "C" */
#endif

#endif	/* NITRO_RTC_ARM7_INSTRUCTION_H_ */

/*---------------------------------------------------------------------------*
  End of file
 *---------------------------------------------------------------------------*/
