h-tech kodlarını pbp ye cevirme hakkında yardım !!

Başlatan murat79, 01 Ocak 2006, 23:13:50

murat79

arkadaslar  elimde  bir  h-tech  ile  yazılmıs  dosya  var  bunu  pbp ile  tekrardan yazıp  derlemem  lazım  ama  h-tech de  tam olarak  neyin  ne  oldugunu  kestiremedim  buradakileri  pbp ye  cevirmek  için  hangi  yolu  izlemek  lazım  ?

#include <pic.h>

#define MYADDRESS   0X34

#define PCBUFFERSIZE    80 // 64
#define RFBUFFERSIZE    PCBUFFERSIZE
//******************************
// test için bank1 BYTE PCBuffer[PCBUFFERSIZE]={0X3C,0x32,0x31,0x2B,0x30,0x2B,0x41,0x3E};
//**********************************
bank1 BYTE PCBuffer[PCBUFFERSIZE];

const BYTE TIMEO[]="<TIME OUT>";
const BYTE READY[]="<READY->";
const BYTE OVER[]="<OVERFLOW>";
const BYTE ERROR[]="<ERROR>";

void SendOver();
void SendError();
void SendTout();
BYTE Data_Eeprom_Read(BYTE);
void Data_Eeprom_Write(BYTE,BYTE);


#define ChannelAddress  0xFF

BYTE TXReady = 0;
BYTE PCDataReady;

BYTE PCWrite    = 0;
BYTE RFRead    = 0;

BYTE CheckSum = 0;
BYTE DataLength;
BYTE Channel;

#include "modem20.h"
#include "delayibo.h
#include "rfutil20pc.c"  //"rfutlhop.c"


void interrupt ReceivePC()
{
            // Data format
//STX SRC DST DATA....EOT CHKSUM
    BYTE i;
    int count,count2=0;
   
    PCWrite = 0;
    PCDataReady = 0;
    
    RCIE = 0;// Disable Recieve Int 
    GIE = 1; // Enable it again to get Timer Int

    PCBuffer[PCWrite] = RCREG;
    CheckSum = PCBuffer[PCWrite];
   //***********************************
     if (PCBuffer[0] == 'C')
	{
		 do{
            TMR1H = 0;
            TMR1L = 0;
            TMR1ON = 1;
            do{
             	if (TMR1IF)SendTout();
            }while(!RCIF);
            TMR1ON = 0; // Disable Timer
            PCBuffer[1] = RCREG;
            if (PCBuffer[1] < 0x31 || PCBuffer[1] > 0x36 ) SendError();
            Data_Eeprom_Write(ChannelAddress, PCBuffer[1]);
            OPTION  = 0x88;
            while(1);
         }while(1);
	 }	
//*********************************
//***********************************
     if (PCBuffer[PCWrite++] != STX) SendError();
//*********************************
 do{
            TMR1H = 0;
            TMR1L = 0;
            TMR1ON = 1;
            do{
             	if (TMR1IF)SendTout();
            }while(!RCIF);
            TMR1ON = 0; // Disable Timer
            PCBuffer[PCWrite++] = RCREG;
            CheckSum += PCBuffer[PCWrite-1]; // 
            if (PCBuffer[PCWrite-1] == EOT) break;
            if(PCWrite == PCBUFFERSIZE) SendOver();
            
        }while(1);


        CheckSum -= PCBuffer[PCWrite-1]; // sub last received
        PCDataReady = 1; // PC data is ready
        RCIE = 1;
    
}
//********************************
//*********************************
void SendError()
{
   BYTE i=0;
   do {   
    	while(!TXIF);
        TXREG   = ERROR[i++];
        NOP();
        CLRWDT();
    }while(i != 7);
    OPTION  = 0x88;
    while(1);
}
//********************************
//*********************************
void SendTout()
{
   BYTE i=0;
   do {   
    	while(!TXIF);
        TXREG   = TIMEO[i++];
        NOP();
        CLRWDT();
    }while(i != 10);
    OPTION  = 0x88;
    while(1);
}
//********************************
//*********************************
void SendOver()
{
   BYTE i=0;
   do {   
    	while(!TXIF);
        TXREG   = OVER[i++];
        NOP();
        CLRWDT();
    }while(i != 10);
    OPTION  = 0x88;
    while(1);
}
//***********************************************
BYTE Data_Eeprom_Read (BYTE adr)    //OK
{
        EEADR = adr;
        EEPGD = 0;
        RD = 1;               //  /* Part of EECON1. */
        return (EEDATA);
}
//************************************************

void Data_Eeprom_Write (BYTE adr, BYTE dat) //OK
{
    while(WR);
    EEADR = adr;
    EEDATA = dat;
    EEPGD = 0;                   
    WREN = 1;  
    GIE = 0;        // /*if using interrupts. */
    EECON2 = 0x55;
    EECON2 = 0xaa;
    WR = 1;
    WREN = 0;
    GIE = 1; ///*if using interrupts. */
    EEIF = 0;
}
//*********************************
//*********************************
void InitBoard()
{
    PORTA=PORTB=PORTC=INTCON=0;

    INTCON  = 0xC0;
    PIE1    = 0;
    T2CON=0b01111011;	//TMR2 1/16 prescaler , 1/16 postscaler
    PR2=255; // @ 4Mhz 800ms //39; 104usn int periyodu , @ 20MHz
    T1CON = 0x00;
    ADCON1  = 0x06;
    OPTION  = 0x8F;//0E/0A
    TRISA   = 0x07;
    TRISC   = 0xD0;
    TRISB   = 0X00;
    RCSTA   = 0;
    T1CON = 0b00110000;
 	PIE1=0b00100000;    // TMR1, TX int. disabled  ,TMR2,RX enabled
	TMR2ON =0;          // Disable it at begging 
        
}

void USARTInit()
{
    RCSTA   = 0x80;
    BRGH    = 1;
    SPBRG   = 0x19; // 0x67; 2.4 //0x19; //9.6 Kbit
    RCIE    = 1; // Set Receive Int.
    TXIE    = 0; // Disable Transmit Int.
    
    TXEN    = 1; // Enable Transmit
    CREN    = 1; // Enable Receive
}

void StartToTransmit()
{
    BYTE i,t;

    TXKUR();

    	DelayMs(50);
    	SNCGONDER();
    	for (i=0;i<PCWrite;i++)
    	{
        	CLRWDT();
        	GONDER(PCBuffer[i]);
    	}     
    	while(DCLK);
    	DIO = 0;
	
	PCDataReady = 0;
   	TXReady = 0;
    POWERDOWNCHP();
    OPTION  = 0x88;
    while(1); //reset
   //RXKUR();
}


void ProcessRFData()
{
    BYTE i, RFReadByte;

    RFRead = 0;

    RCIE = 0; // Disable Receive Int
 
    // We may need to look RSSI
    RFReadByte = DATAOKURF();
    if(RFReadByte != STX)
    {
        RCIE = 1; // enable it again
        return;
    }
    PCBuffer[RFRead++] = RFReadByte;
    CheckSum = RFReadByte;
    for(i=0; i<2; i++)
    {
        PCBuffer[RFRead++] = DATAOKURF();
        CheckSum += PCBuffer[RFRead-1];
    }

    if(PCBuffer[2] != MYADDRESS) // for different Address
    {
        RCIE = 1;
        return;
    }


    do
    {
        CLRWDT();
        PCBuffer[RFRead++] = DATAOKURF();
        if(PCBuffer[RFRead-1] == EOT) break;
        CheckSum += PCBuffer[RFRead-1];
        if ( RFRead > PCBUFFERSIZE ) {
        RCIE = 1; 
        // inform other side to send it back
        return;
        }
    }while(1);
    
    for (i=0; i<RFRead; i++)
    {
        while(!TXIF); 
        TXREG = PCBuffer[i]; 
        CLRWDT();
    }
    OPTION  = 0x88;
    while(1);
    RCIE = 1; // enable it again
}

void main()
{
    BYTE i,OK1,OK2;

    PCWrite    = 0;
    RFRead     = 0;
    PCDataReady = 0;

    InitBoard();
    USARTInit();
   
//*****************************
//      TEST İÇİN SÜREKLİ GÖNDERME DE OLUR.
//    PCDataReady = 1; //test
//    PCWrite = 8;//test
//******************************
    TMR2ON = 0; // disbale int2
	Channel = 0x34;
      
    TXKUR(); 
    while(1) CLRWDT();
}


yardımlarınız  için şimdiden  teşekkürler
------------------------------------------------------- Kim Ne Derse Desin Kim Ne Söylerse Söylesin  Sen Gel Ne Olursan Ol Yine Gel