Exemple #1
0
bool threadCompareFileAndChip(int Index)
{
    bool result = true;
//    bool is_greater_than_5_0_0 = is_BoardVersionGreaterThan_5_0_0(Index);

//    if(is_greater_than_5_0_0)
//        SetLEDOnOff(SITE_BUSY,Index);

    SetIOMode(false,Index);

    if(g_ulFileSize==0)
        result = false;

    if( result && (!ValidateProgramParameters(Index)) )
        result = false;

    if( result )
    {
        ReadChip(DownloadAddrRange,Index);

        size_t offset = min(DownloadAddrRange.length,g_ulFileSize);
        unsigned int crcFile = CRC32(pBufferforLoadedFile,offset);
        unsigned int crcChip = CRC32(pBufferForLastReadData,offset);
        unsigned int i=0;
        #if 0
        for(i=0; i<10; i++)
        {
            if(pBufferforLoadedFile[i] != pBufferForLastReadData[i])
                printf("Data deferent at %X, pBufferforLoadedFile[i]=%x,pBufferForLastReadData[i]=%x\r\n",i,pBufferforLoadedFile[i],pBufferForLastReadData[i]);
        }
        #endif

        result = (crcChip == crcFile);
    }

//    if(is_greater_than_5_0_0)
//        SetLEDOnOff(result? SITE_OK:SITE_ERROR,Index);

    g_is_operation_successful = result;
    return result;
}
Exemple #2
0
__attribute__((noreturn)) void main(void){
	cli();
	//set-up serial communications
	DDRD=28;//3 serial pins on d.2 to d.4 d.5 to d.7 contain msbs for flash data d.0 to d.4 is in port C
	DDRB=62;//serial clocks (B.1 SHCP) (B.2 Latch) (B.3 CE#) (B.4 OE#) (B.5 WE#)
	UBRR0H=0;
	UBRR0L=3;//set to 0.5M baud
	UCSR0A|=2;//double speed aysnc
	UCSR0B = (1<<RXEN0)|(1<<TXEN0);//Enable receiver and transmitter
	UCSR0C=6;//async 1 stop bit 8bit char no parity bits
	_delay_ms(50);
	StringPgm(PSTR("RDY"));
	USART_Receive();//wait for handshake
	char mode = USART_Receive();//wait for mode
	StringPgm(PSTR("RDY"));
	serialWrB(readId(0));
	uint8_t cap=readId(1);
	serialWrB(cap);
	__uint24 capacity=524288L;
	switch(cap){
		case 0xB5:
			capacity=131072L;
		case 0xB6:
			capacity=262144L;
		break;
	}
	if(mode=='W'){
		chipErase();
		serialWrB('D');
		verifyF(capacity);
		__uint24 x;
		for (x=0;x<capacity;++x){
			pgmB(x,USART_Receive());
			serialWrB(readB(x));
		}
	}else if(mode=='R')
		ReadChip(capacity);
	while(1);
}