I need to send certain data to an FPGA with SPI using my LPC1769. However I don't quite understand how I should approach this. I currently have this code which ends up in the hardfault handler. I'm not allowed to use CMSIS so I had to define the registers myself.
void sendData(uint8_t *buf, uint32_t Length) {
uint32_t i;
for (i = 0; i < Length; i++) {
while (S0SPSR != (1 << 7)) {
S0SPDR = *buf;
gpio0WritePin(15, 1);
gpio0WritePin(15, 0);
buf++;
}
}
return;
}
and my main function:
uint8_t TX[16];
int main(void) {
SpiInit();
TX[0] = 0x48;
TX[1] = 0x65;
TX[2] = 0x6c;
TX[3] = 0x6c;
TX[4] = 0x6f;
while (1) {
SPI_Begin();
sendData((uint8_t*)TX, 5);
SPI_End();
}
}