void Delay(uint32_t ticks)
{
volatile uint32_t i;
for (; ticks > 0; --ticks) {
for (i = 1000; i > 0; --i) {
__NOP();
}
}
}
int main(void)
{
SSP_InitTypeDef spi;
SSP_StructInit(&spi);
SSP_Init(&spi);
// spi estándar config
SSP_SetClockRate(1000000);
// clock rate a 1MHz
IOCON_PIO_CFG_Type io;
IOCON_StructInit(&io);
io.type = IOCON_PIO_0_14; IOCON_SetFunc(&io);
//sck
io.type = IOCON_PIO_0_17; IOCON_SetFunc(&io);
// mosi
SSP_Cmd(ENABLE); // (1)
while (1)
{
SSP_SendData(0xaa);
//while (SSP_GetStatus(SSP_STATUS_TFE) == RESET) ;
// I've commented this line in order no to mess right now with those flags
// Anyway they are not helping at all
Delay(100);
// I guess this is enough time for a byte to go out
// Board is running at 12MHz
}
return 0 ;
} |