void sspInit(void)
{
// SSP1 (SPI) init sequense
PCONP |= (1<<10); // PCSSP1 - power on
PINSEL0 |= (2<<(7*2)) | (2<<(8*2)) | (2<<(9*2)) | (2<<(6*2)); // configure SPI1 pinouts
// Serial Clock Rate: PCLK/CPSDVSR
SSP1CR1 = 0x0 ; // disable SSP, must be off during changes
SSP1CR0 = (8-1); // | (1<<6) /* CPOL */ | (1<<7) /* CPHA */; // | SSP_CR0_CPOL | SSP_CR0_CPHA; // DataSizeSelect=8, CPOL=1,CPHA=1
SSP1CPSR = 8; // SPICLK = PCLK/8 = 18MHz/8 = 2.25MHz
SSP1IMSC = 0; // INTs disabled
SSP1DMACR = 0; // no DMA
// SSP1ICR = SSP_ICLR_RORIC | SSP_ICLR_RTIC; // Clear RxOverflow,TxTimeout INTs
SSP1CR1 = (1<<1); // enable SSP, Master mode
}
// Flash Excel Semiconductor ES25M80A
int flashGetJEDEC(void)
{
char flash_jedec_manufactured;
char flash_jedec_memtype;
char flash_jedec_capacity;
FIO0CLR = (1<<5);
SSP1DR = 0x9F;
SSP1DR = 0xFF;
SSP1DR = 0xFF;
SSP1DR = 0xFF;
while ( (SSP1SR & (1<<4)) ); // Wait while busy - BSY
int dummy = SSP1DR;
flash_jedec_manufactured = SSP1DR;
flash_jedec_memtype = SSP1DR;
flash_jedec_capacity = SSP1DR;
FIO0SET = (1<<5);
return (flash_jedec_manufactured<<16) | (flash_jedec_memtype<<8) | flash_jedec_capacity;
}
comments powered by