bool CSerialFlash::WriteDisable(void) { NssLow(); m_spi.Send(FLASH_WriteDisable); NssHigh(); return !(ReadSR() & 0x02); }
void CalibrateSensors(void) { printf("Front Right: %u\n", ReadFR()); printf("Front Left: %u\n", ReadFL()); printf("Side Right: %u\n", ReadSR()); printf("Side Left: %u\n\n", ReadSL()); __delay_ms(1000); }
void iWriteSEE( long address, int data) { // write a 16-bit value starting at an even address // wait until any work in progress is completed while ( ReadSR() & 0x1); // check the WIP flag // Set the Write Enable Latch WriteEnable(); // perform a 16-bit write sequence (2 byte page write) CSEE = 0; // select the Serial EEPROM WriteSPI2( SEE_WRITE); // write command WriteSPI2( address>>8); // address MSB first WriteSPI2( address & 0xfe); // address LSB (word aligned) WriteSPI2( data >>8); // send msb WriteSPI2( data & 0xff); // send lsb CSEE = 1; }//iWriteSEE
int iReadSEE( long address) { // read a 16-bit value starting at an even address int lsb, msb; // wait until any work in progress is completed while ( ReadSR() & 0x1); // check the WIP flag // perform a 16-bit read sequence (two byte sequential read) CSEE = 0; // select the Serial EEPROM WriteSPI2( SEE_READ); // read command WriteSPI2( address>>8); // address MSB first WriteSPI2( address & 0xfe); // address LSB (word aligned) msb = WriteSPI2( 0); // send dummy, read msb lsb = WriteSPI2( 0); // send dummy, read lsb CSEE = 1; return ( (msb<<8)+ lsb); }//iReadSEE