19.8.2.2.2 Workflow

  1. Read data from SPI master.
    while(spi_read_buffer_wait(&spi_slave_instance, buffer_rx, BUF_LENGTH,
        0x00) != STATUS_OK) {
        /* Wait for transfer from the master */
    }
    
  2. Compare the received data with the transmitted data from SPI master.
    for (uint8_t i = 0; i < BUF_LENGTH; i++) {
        if(buffer_rx[i] != buffer_expect[i]) {
            result++;
        }
    }
    
  3. Infinite loop. If the data is matched, LED0 will flash slowly. Otherwise, LED will flash quickly.
    while (true) {
        /* Infinite loop */     
        if (result) {
            port_pin_toggle_output_level(LED_0_PIN);
            /* Add a short delay to see LED toggle */
            volatile uint32_t delay = 30000;
            while(delay--) {
            }
        } else {
            port_pin_toggle_output_level(LED_0_PIN);
            /* Add a short delay to see LED toggle */
            volatile uint32_t delay = 600000;
            while(delay--) {
            }
        }
    }