target/linux/at91/image/dfboot/src/at45.c
/*----------------------------------------------------------------------------*/
/* \fn    AT91F_SpiEnable                                                     */
/* \brief Enable SPI chip select                                              */
/*----------------------------------------------------------------------------*/
\fn    AT91F_SpiEnable
\brief Enable SPI chip select
\ fn AT91F_SpiEnable \ brief Enable SPI chip select
static void AT91F_SpiEnable(int cs) {
	switch(cs) {
	case 0:	
		AT91C_BASE_SPI->SPI_MR &= 0xFFF0FFFF;
		AT91C_BASE_SPI->SPI_MR |= ((AT91C_SPI_PCS0_SERIAL_DATAFLASH << 16) & AT91C_SPI_PCS);
		break;
	case 3:	
		AT91C_BASE_PIOB->PIO_PER = AT91C_PIO_PB7;	
		AT91C_BASE_PIOB->PIO_OER = AT91C_PIO_PB7;	
		AT91C_BASE_PIOB->PIO_CODR = AT91C_PIO_PB7;
		AT91C_BASE_SPI->SPI_MR &= 0xFFF0FFFF;
		AT91C_BASE_SPI->SPI_MR |= ((AT91C_SPI_PCS3_DATAFLASH_CARD<<16) & AT91C_SPI_PCS);
		break;
	}
	AT91C_BASE_SPI->SPI_CR = AT91C_SPI_SPIEN;
}
static void AT91F_SpiEnable ( int cs ) { switch ( cs ) { case 0 : AT91C_BASE_SPI -> SPI_MR &= 0xFFF0FFFF ; AT91C_BASE_SPI -> SPI_MR |= ( ( AT91C_SPI_PCS0_SERIAL_DATAFLASH << 16 ) & AT91C_SPI_PCS ) ; break ; case 3 : AT91C_BASE_PIOB -> PIO_PER = AT91C_PIO_PB7 ; AT91C_BASE_PIOB -> PIO_OER = AT91C_PIO_PB7 ; AT91C_BASE_PIOB -> PIO_CODR = AT91C_PIO_PB7 ; AT91C_BASE_SPI -> SPI_MR &= 0xFFF0FFFF ; AT91C_BASE_SPI -> SPI_MR |= ( ( AT91C_SPI_PCS3_DATAFLASH_CARD << 16 ) & AT91C_SPI_PCS ) ; break ; } AT91C_BASE_SPI -> SPI_CR = AT91C_SPI_SPIEN ; }
\fn    AT91F_SpiEnable
\brief Enable SPI chip select
\ fn AT91F_SpiEnable \ brief Enable SPI chip select
/* Configure SPI CS0 for Serial DataFlash AT45DBxx */ /* Configure SPI CS3 for Serial DataFlash Card */ /* Set up PIO SDC_TYPE to switch on DataFlash Card and not MMC/SDCard */ /* Set in PIO mode */ /* Configure in output */ /* Clear Output */ /* Configure PCS */ /* SPI_Enable */