To: | <> |
---|---|
Subject: | RE: [ts-7000] I need Memory Map for RTC TS-5620 |
From: | "Daniel Perron" <> |
Date: | Tue, 18 Apr 2006 15:01:43 -0400 |
This
is a little code I wrote long time ago to get the rtc memory on the
TS7200.
#include <unistd.h>#include <sys/types.h>#include <sys/mman.h>#include <stdio.h>#include <fcntl.h>#include <assert.h>#include "peekpoke.h"#include "rtc.h"
volatile unsigned char * RtcAddress=NULL;volatile unsigned char * RtcData=NULL;int RtcHandle=-1;
int InitRtc(void){ RtcHandle = open( "/dev/mem",O_RDWR); if(RtcHandle<0) return(0);
RtcAddress= ( unsigned char *) mmap(0,getpagesize(),PROT_WRITE|PROT_READ,MAP_SHARED,RtcHandle,0x10800000UL); if(RtcAddress == NULL){ CloseRtc(); return(0);} RtcData = ( unsigned char *) mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, RtcHandle, 0x11700000UL); if(RtcData == NULL){ CloseRtc(); return(0);} return(1);}
void CloseRtc(void){ if(RtcAddress){ munmap(( void *)RtcAddress,getpagesize());RtcAddress= NULL;} if(RtcData){ munmap(( void *)RtcData,getpagesize());RtcData= NULL;} if(RtcHandle>=0){ close(RtcHandle); RtcHandle=-1; } }
unsigned char ReadRtc(unsigned char address){ *RtcAddress= address; return(*RtcData);}
void WriteRtc(unsigned char address, unsigned char value){ *RtcAddress= address; *RtcData = value; }
int ReadRtcBlock(unsigned char address,unsigned char size,unsigned char * block){ short loop; short endp= (short) address + (short) size; if(endp>128) //can we change that to a bigger value?{ endp=128; size= endp - address; } for(loop=address;loop<endp;loop++)*(block++)= ReadRtc(loop); return(size);} int WriteRtcBlock(unsigned char address,unsigned char size,unsigned char * block){ short loop; short endp= (short) address + (short) size; if(endp>128){ endp=128; size= endp - address; } for(loop=address;loop<endp;loop++)WriteRtc(loop,*(block++)); return(size);}
YAHOO! GROUPS LINKS
|
<Prev in Thread] | Current Thread | [Next in Thread> |
---|---|---|
|
Previous by Date: | [ts-7000] Re: NetBSD on TS-7300, epsiloncubed |
---|---|
Next by Date: | [ts-7000] Re: 983.04 Khz timer, Jesse Off |
Previous by Thread: | Re: [ts-7000] I need Memory Map for RTC TS-5620, Don W. Carr |
Next by Thread: | [ts-7000] Re: I need Memory Map for RTC TS-5620, parayam2006 |
Indexes: | [Date] [Thread] [Top] [All Lists] |
Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU