by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Dependencies:   mbed

Committer:
robt
Date:
Mon Oct 15 21:24:11 2012 +0000
Revision:
0:493e035a4a1c
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
robt 0:493e035a4a1c 1 /* Program Example 7.1: Sets up the mbed as SPI master, and continuously sends
robt 0:493e035a4a1c 2 a single byte
robt 0:493e035a4a1c 3 */
robt 0:493e035a4a1c 4 #include "mbed.h"
robt 0:493e035a4a1c 5 SPI ser_port(p11, p12, p13); // mosi, miso, sclk
robt 0:493e035a4a1c 6 char switch_word ; //word we will send
robt 0:493e035a4a1c 7
robt 0:493e035a4a1c 8
robt 0:493e035a4a1c 9
robt 0:493e035a4a1c 10 int main() {
robt 0:493e035a4a1c 11 ser_port.format(8,0); // Setup the SPI for 8 bit data, Mode 0 operation
robt 0:493e035a4a1c 12 ser_port.frequency(1000000); // Clock frequency is 1MHz
robt 0:493e035a4a1c 13 while (1){
robt 0:493e035a4a1c 14 switch_word=0xA1; //set up word to be transmitted
robt 0:493e035a4a1c 15 ser_port.write(switch_word); //send switch_word
robt 0:493e035a4a1c 16 wait_us(50);
robt 0:493e035a4a1c 17 }
robt 0:493e035a4a1c 18 }
robt 0:493e035a4a1c 19