SPI receipt of an array, Slave device.

Dependencies:   mbed

main.cpp

Committer:
el15tcd
Date:
2018-05-25
Revision:
2:bee829579424
Parent:
1:c573caf40864

File content as of revision 2:bee829579424:

#include "mbed.h"

SPISlave lights(p5,p6,p7,p8);

BusOut myleds(LED4, LED3, LED2, LED1);
DigitalOut led1(LED1);
DigitalOut led2(LED2);

int i;
int j;

char v;
char ledArray[8][8];

int main()
{

    myleds = 0;
    wait(0.5);

    while(1) {
        if (lights.receive()) {
            v = lights.read();
            //lights.reply(0x02);
        }
        for (i = 0; i < 8; i++) {
            for (j = 0; j < 8; j++) {
                ledArray[i][j] = lights.read(); //read
            }
        }
        if (v == 0x01) {
            led1 = 1;
        } 

        if (ledArray[7][7] == 0x30) {
            led2 = 1;
        }
        //test array value to see if correct data is received

    }
}