[TI-H] Re: memory expansion


[Prev][Next][Index][Thread]

[TI-H] Re: memory expansion



CRACK: yes, a cracked version of the OS, search ticalc.org for it.

Memory expander:  YES!  I wrote one that will work with 512k eeprom's ($10), 
but never got around to finishing the GUI.   I did finish all the 
send/recieve byte routines, so it shouldn't be hard to finish...I attached 
it.  Please give me credit if you use it with anything.  It is I2C 
protocall.


>From: jeff <jefromi42@yahoo.com>
>Reply-To: ti-hardware@lists.ticalc.org
>To: ti-hardware@lists.ticalc.org
>Subject: [TI-H] memory expansion
>Date: Mon, 21 May 2001 18:44:29 -0700 (PDT)
>
>
>Is anyone out there working on an external memory expander, or even just 
>porting the software for
>the Expander2 that's linked to on ticalc?  I know the 89 has a lot of 
>memory, but it runs out
>pretty fast when you start putting ebooks and huge game on it...
>Also, I haven't found anything anywhere on the web about this: is there a 
>section of the Flash
>allocated only for APPS?  My calc seems to give an error memory whenever I 
>get down to about 400K
>of archive and try to archive something.  (I have HW1)  Is there a crack to 
>fix this?
>thanks
>jeff
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Auctions - buy the things you want at great prices
>http://auctions.yahoo.com/
>
>


-TenorDave
TenorDave@Hotmail.com
Tenordave@home.com
UIN:11290012
AIM ID:RYDRDave
MSN ID:TenorDave
Yahoo ID:RydrDave

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


-- Attached file included as plaintext by Listar --
-- File: eeprom.c

// Original source by Dave Watson --- TenorDave@hotmail.com
// Created 6/10/2000; 11:00:44 AM
//
// Modifications by Stephan Effelsberg --- b012414@dvz.fh-koeln.de
// 06-Dec-2000

// Compile without optimisation because of delay() if defined !!!

// #define USE_GRAY_PATCH
#define USE_LONGMUL_PATCH
#define USE_LONGDIV_PATCH
#define USE_INITS_PATCH

#define ESC_ROW 0xffbf
#define ESC_KEY 1

//#define delay

#define SAVE_SCREEN

#include <nostub.h>
#include <tigcclib.h>

void I2C_Init(void);
void I2C_Start(void);
void I2C_Stop(void);
void I2C_SDA(char state);
void I2C_SCK(char state);
void I2C_Clock(void);
int  I2C_ReadSDA(void);
char I2C_Poll(char address);
void I2C_PutByte(char buf);
char I2C_GetByte(void);
void I2C_GiveACK(void);
void I2C_GiveNOTACK(void);
int  I2C_GetACK(void);
int  I2C_Read(char address,unsigned int Number_of_bytes, char* data);
int  I2C_ReadRep(char address,unsigned int Number_of_bytes, char* data);
int  I2C_Write(char address,unsigned char Number_of_bytes, char* data);
int  I2C_WriteRep(char address,unsigned char Number_of_bytes, char* data);
void reset(void);
void delay(void);

void Draw_Statusbar(unsigned long memused,unsigned long totalmem);
char Format_Device(void);
char Send_Files(char * file);
char Send_File(SYM_ENTRY *symptr);

void VarLinkDialog (void);
void VarLinkHandler (EVENT *ev);

int _ti89;

static char *const point=(char *)0x60000C;
static char *const point2=(char *)0x60000E;

unsigned int eaddress=0xa0,pages=512;
unsigned char pagesize=128;

char VarBuffer[20] = "";

///////////////////////////////////////////////////////////
// MAIN ///////////////////////////////////////////////////
///////////////////////////////////////////////////////////

void _main(void)
{
	int key=0;
	unsigned char state=1;
	unsigned long memoryused=65538,totalmemory;

	*point=0x40;

	totalmemory=(long)pages*(long)pagesize;

	do
	{
		ClrScr();
		Draw_Statusbar(memoryused,totalmemory);

		if(key==KEY_F2)
		{
			VarLinkDialog();
			ClrScr();
			Draw_Statusbar(memoryused,totalmemory);
			state=Send_Files(VarBuffer);
		}
		else if(key==KEY_F3)
		{
			if (DlgMessage("Format Device", "Are you sure you want to format the 
EEPROM?   All memory will be erased!", BT_CANCEL, BT_OK)==13)
				state=Format_Device();
		}

		if(state==0)
			DlgMessage("Error!", "Device not responding!   Please check all 
connections and settings carefully.",BT_NONE, BT_OK);
		else if(state==2)
			DlgMessage("Error!", "File Folder not found!",BT_NONE, BT_OK);
	  state=1;
		Draw_Statusbar(memoryused,totalmemory);
		GKeyFlush();
		key=ngetchx();
	}
	while(key!=KEY_ESC && key!=KEY_F5);

	reset();
	return;
}

///////////////////////////////////////////////////////////
// My Routines ////////////////////////////////////////////
///////////////////////////////////////////////////////////

char Send_File(SYM_ENTRY *symptr)
{

}

char Send_Files(char * file)
{
	char *elimbracket;
	char tmpstr[25],state=1;
	unsigned char ypos=0;
	SYM_ENTRY *symptr;

	elimbracket=strchr(file,'(');
	if(elimbracket!=NULL)
		*elimbracket=0;

	tmpstr[0] = 0;
	sprintf(tmpstr+1,"%s",file);
            //find file or folder
	symptr = DerefSym(SymFind(tmpstr+strlen(file)+1));
	if(symptr)
	{
		printf_xy(0,6*ypos++,"Sending:%s",file);
		state=Send_File(symptr);
		//FIXME error check
	}
	else
	{
		symptr=SymFindFirst(tmpstr+strlen(file)+1,17);
		symptr=SymFindNext();
		if(!symptr)
			return(2);
		else
		{
			while(symptr)
			{
				printf_xy(0,6*ypos++,"Sending:%s",symptr->name);
				state=Send_File(symptr);
				//FIXME error check
				if(ypos>12)
				{
					ScrRectScroll(&(SCR_RECT){{0,0,159,99}},&(SCR_RECT){{0,0,159,80}},6,A_NORMAL);
					ypos--;
				}
				symptr=SymFindNext();
			}
		}
	}

	if(state=1)//FIXME
		printf_xy(0,6*ypos++,"File(s) Sent Successfully!");

	return(1);
}

char Format_Device(void)
{
  char data[pagesize+2];
	unsigned int i,x;

	memset(data,0,pagesize+2);
	FontSetSys(F_4x6);
	for(i=0;i<pages;i++)
	{
		x=0;
retryf:
		x++;
		if(x>10)
			return(0);
		printf_xy(0,0,"Page:%i",i+1);
		if(!I2C_Write(eaddress,sizeof(data),data))
			goto retryf;
		if(!I2C_Poll(eaddress))
			goto retryf;
		if((int)data[1]+(int)pagesize>=256)
			data[1]+=pagesize-256,data[0]++;
		else
			data[1]+=pagesize;
	}
	printf_xy(0,6,"Erase Complete!");

	return(1);
}

void Draw_Statusbar(unsigned long memused,unsigned long totalmem)
{
	SCR_RECT infobarrect = {0,93,159,100};
	SCR_RECT fullscreen={0,0,160,100};
	char tmpstr[80];
	unsigned long percent;

	FontSetSys(F_4x6);

	//draw bottom info bar
  ScrRectFill(&infobarrect,&fullscreen,A_NORMAL);
  sprintf(tmpstr, "Device:0x%x Mem:%ld/%ld",eaddress,memused,totalmem);
  DrawStrXY(115,87,"[X] for help",A_NORMAL);
  DrawStrXY(1,87,tmpstr,A_NORMAL);
  DrawStrXY(2,94," Read ",A_REVERSE);
  DrawStrXY(34,94," Send ",A_REVERSE);
  DrawStrXY(66,94," Format ",A_REVERSE);
  DrawStrXY(107,94," Mode ",A_REVERSE);
  DrawStrXY(140,94," Quit ",A_REVERSE);
}

void VarLinkHandler (EVENT *ev)
{
  if (ev->Type == CM_HSTRING)
    strcpy (VarBuffer, HeapDeref (ev->extra.hPasteText));
  EV_defaultHandler (ev);
}

void VarLinkDialog(void)
{
  EVENT ev;
  EVENT_HANDLER OldHandler = EV_captureEvents (VarLinkHandler);
  ev.Type = CM_KEYPRESS;
  ev.extra.Key.Code = KEY_VARLNK;
  EV_defaultHandler (&ev);
  EV_captureEvents (OldHandler);
}

///////////////////////////////////////////////////////////
// I2C Routines ///////////////////////////////////////////
///////////////////////////////////////////////////////////

void reset(void){
	*point2=0x50;
	*point=0x8D;
}

void delay(void){
	int i, d=1;
	for(i=5; i>0; --i) d*=2;
}

int I2C_ReadSDA(void){
	return !((*point2&0x04)>>2);
}

void I2C_SDA(char state){
	if(state==1)
		*point2&=0xFE;
	else
		*point2|=0x01;
#ifdef delay
	delay();
#endif
}

void I2C_SCK(char state){
	if(state==1)
		*point2&=0xFD;
	else
		*point2|=0x02;
#ifdef delay
	delay();
#endif
}

void I2C_Clock(void){
	I2C_SCK(1);
	I2C_SCK(0);
}

// it seems that this is not needed
void I2C_Init(void){ // call this immediately after power-on
	int n;
	I2C_SDA(1);
	I2C_SCK(0);
	for(n=0; n<4; ++n){
		I2C_Stop();
	}
}

void I2C_Start(void){
	I2C_SDA(1);
	I2C_SCK(1);
	I2C_SDA(0);
	I2C_SCK(0);
}

void I2C_Stop(void){
	I2C_SDA(0);
	I2C_SCK(1);
	I2C_SDA(1);
}

void I2C_PutByte(char buf){
	int n;
	for (n=7; n>=0; --n){
		I2C_SDA((buf>>n)&0x01);
		I2C_Clock();
	}
	I2C_SDA(1);
}

char I2C_GetByte(void){
	char buf=0;
	int n;
	for (n=7; n>=0;--n){
		I2C_SCK(1);
		buf |= I2C_ReadSDA()<<n;
		I2C_SCK(0);
	}
	I2C_SDA(1);
	return buf;
}

void I2C_GiveACK(void){
	I2C_SDA(0);
	I2C_Clock();
	I2C_SDA(1);
}

void I2C_GiveNOTACK(void){
	I2C_SDA(1);
	I2C_Clock();
}

int I2C_GetACK(void){
	int i;
	I2C_SDA(1);
	I2C_SCK(1);
	// don't wait for ACK, but give slow components some time
	// to respond
	// however, I don't think that this is needed, the slave should
	// respond immediately after the 8th bit
	for(i=10; i>0; --i){
		if(I2C_ReadSDA()==0){
			I2C_SCK(0);
			return(1);
		}
	}
	I2C_SCK(0);
	return 0;
}

char I2C_Poll(char address)
{
	unsigned int x=0;
	char retval=0;
//acknowledge polling
	do
	{
		I2C_Start();
		I2C_PutByte(address&0xfe);
		x++;
	}
	while(!(retval=I2C_GetACK()) && x<1000);
	I2C_Stop();
	return retval;
}

/* this concludes the low-level set of instructions for the I2C driver
The next functions will handle the telegram formatting on a higher level */

// a complete read sequence with Stop
int I2C_Read(char address,unsigned int Number_of_bytes, char* data){
	int state;
	state=I2C_ReadRep(address, Number_of_bytes, data);
	I2C_Stop();
	return state;
}

// a read sequence without Stop, allows for Repeated Start
int I2C_ReadRep(char address, unsigned int Number_of_bytes, char* data){
	int x;

	I2C_Start();
	I2C_PutByte(address|0x01);
	if(!I2C_GetACK()){
		return 0;
	}
	for(x=0; x<Number_of_bytes; x++){
		data[x]=I2C_GetByte();
		if (x<Number_of_bytes-1)
			I2C_GiveACK();
		else
			I2C_GiveNOTACK();
	}
	return 1;
}

// a complete write sequence with Stop
int I2C_Write(char address, unsigned char Number_of_bytes, char* data){
	int state;
	state=I2C_WriteRep(address, Number_of_bytes, data);
	I2C_Stop();
	return state;
}

// a write sequence without Stop, allows for Repeated Start
int I2C_WriteRep(char address, unsigned char Number_of_bytes, char* data){
	int x,i=0;
retryw:
	i++;
	if (i>10)
		return(0);
	I2C_Start();
	I2C_PutByte(address&0xfe);
	if(!I2C_GetACK())
		goto retryw;
	for(x=0; x<Number_of_bytes; ++x){
		I2C_PutByte(data[x]);
		if(!I2C_GetACK())
			goto retryw;
	}
	return 1;
}





Follow-Ups: