Base code for the spi master

Dependencies:   mbed

Committer:
chaos5338
Date:
Mon Dec 14 00:59:26 2015 +0000
Revision:
0:50fdc77f2817
Base code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chaos5338 0:50fdc77f2817 1 // CECS 447 SPI Master Test
chaos5338 0:50fdc77f2817 2 #include "mbed.h"
chaos5338 0:50fdc77f2817 3
chaos5338 0:50fdc77f2817 4 // default is 8 bits, mode 1,
chaos5338 0:50fdc77f2817 5 // Instantiante Functions and Classes
chaos5338 0:50fdc77f2817 6 SPI device(p11, p12, p13);
chaos5338 0:50fdc77f2817 7 DigitalOut cs(p14);
chaos5338 0:50fdc77f2817 8 DigitalIn myButton(p23);
chaos5338 0:50fdc77f2817 9 Serial pc(USBTX, USBRX); // tx, rx
chaos5338 0:50fdc77f2817 10
chaos5338 0:50fdc77f2817 11
chaos5338 0:50fdc77f2817 12 int main(){
chaos5338 0:50fdc77f2817 13 pc.baud(9600);
chaos5338 0:50fdc77f2817 14 pc.printf("Starting transmission.\n\r");
chaos5338 0:50fdc77f2817 15 cs = 0;
chaos5338 0:50fdc77f2817 16 if (myButton){
chaos5338 0:50fdc77f2817 17 int response = device.write(0xFF);
chaos5338 0:50fdc77f2817 18 cs = 1;
chaos5338 0:50fdc77f2817 19 }
chaos5338 0:50fdc77f2817 20 }