www.pudn.com > at91rm9200-rtc8025.rar > nx8025.h


/*
 * nx8025.h
 *
 * Copyright (C) 2005 Fudan Software Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 */
#ifndef NX8025_H
#define NX8025_H

#define NX8025_I2C_SLAVE_ADDR	0x32

#define NX8025_REG_ADDR_START	0x00
#define NX8025_REG_ADDR_END     0x0F
#define NX8025_REG_SIZE 	0x10

#define PROC_NX8025_NAME	"driver/rtc8025"

struct rtc_mem {
	unsigned int	loc;
	unsigned int	nr;
	unsigned char	*data;
};

#define NX8025_GETDATETIME	0
#define NX8025_SETTIME		1
#define NX8025_SETDATETIME	2
#define NX8025_GETCTRL		3
#define NX8025_SETCTRL		4
#define NX8025_MEM_READ		5
#define NX8025_MEM_WRITE	6

#define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10)
#define BIN_TO_BCD(val) ((((val)/10)<<4) + (val)%10)

#define HOURS_AP(n)		(((n)>>5)&1)
#define HOURS_12(n)		BCD_TO_BIN((n)&0x1F)
#define HOURS_24(n)		BCD_TO_BIN((n)&0x3F)

#endif