Пример #1
0
void c6747_spi_init()
{
	Uint32 spidat1;

	SPI_SPIGCR0=0;
	C6747_wait(0xff);
	SPI_SPIGCR0=1;

	SPI_SPIGCR1=0
	    |(0<<24)
	    |(0<<16)
	    |(1<<1)
	    |(1<<0);

//	spidat1=0
//	    |(0<<28)
//	    |(0<<24)
//	    |(2<<16)// CSRN [only CS0 enabled]
//	    |(0<<0);

	spidat1=0
	    |(0<<28)
	    |(0<<24)
	    |(0<<16)// CSRN [only CS0 enabled]
	    |(0<<0);
	SPI_SPIDAT1=spidat1;

	SPI_SPIDEF=0
//	    |(1<<1)
	    |(1<<0);  //define the state of the SPIx_SCS[n] pins when no transmissions are performed.

	SPI_SPIFMT0=0
	    |(0<<20)  //most significant bit is shifted our first
	    |(0<<17)
	    |(1<<16)  //mode 1——数据在第一个SPIx_CLK的上升沿之前的半个周期输出;在SPIx_CLK的上升沿锁存
	    |(3<<8)   //SPIclk=25*30/2/2/4
	    |(8<<0);  //SPI data word length 8bits

	SPI_SPIDELAY=0
	    |(18<<24)
	    |(18<<16);

	SPI_SPIINT=0
	    |(0<<16)
	    |(0<<8)
	    |(0<<6)
	    |(1<<4);//enables interrupt on the error

	SPI_SPILVL=0
	    |(0<<8) //Receive interrupt is mapped to interrupt line INT1 it is 1;(reserved)
	    |(0<<6) //Receive overrun interrupt is mapped to interrupt line INT1 it is 1;(reserved)
	    |(0<<4);//Bit error interrupt is mapped to the interrupt the INT1 if it is 1;(reserved)

	SPI_SPIPC0=0
	    |(1<<11)
	    |(1<<10)
	    |(1<<9)
	    |(0<<8)
	    |(1<<0);

//	SPI_SPIPC1=0
//	    |(1<<11)
//	    |(1<<10)
//	    |(1<<9)
//	    |(0<<8)
//	    |(1<<0);


	SPI_SPIGCR1|=(1<<24);
}
Пример #2
0
/************************************************************************** *
 *                                                                          *
 *  C6747_waitusec( usec )                                                  *                                                                          *
 *      Wait in a software loop for 'x' microseconds                        *
 *                                                                          *
 * ************************************************************************ */
void C6747_waitusec( Uint32 usec )
{
    C6747_wait( usec * 3 );
}