void SPI_Begin(void) { // initialize the SPI pins pinMode(SCK_PIN, OUTPUT); pinMode(MOSI_PIN, OUTPUT); pinMode(MISO_PIN, INPUT); pinMode(SS_PIN, OUTPUT); digitalWrite(SS_PIN, HIGH); // enable SPI Master, MSB, SPI mode 0, FOSC/4 SPI_mode(0); }
////////////////////////////////////////////////////////////////////////////////// // LED-Strip Writer ////////////////////////////////////////////////////////////////////////////////// void lw_setup() { // start by writting zeros to wake-up latch(s) lw_state = LW_S_WAIT_TO_WRITE_ZEROS; lw_pixelIndex = 0; lw_zeroCounter = ZEROS_NEEDED; SPI_init(); /* 10mhz - faster is not working */ SPI_clock(GetSystemClock() / SPI_PBCLOCK_DIV8); SPI_mode(SPI_MASTER); BUFFER = 0x00; // Trigger STATRX }