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

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* Program Example 7.1: Sets up the mbed as SPI master, and continuously sends   
00002 a single byte           
00003                                                                              */
00004 #include "mbed.h"
00005 SPI ser_port(p11, p12, p13); // mosi, miso, sclk
00006 char switch_word ;           //word we will send
00007 
00008 
00009 
00010 int main() {
00011   ser_port.format(8,0);        // Setup the SPI for 8 bit data, Mode 0 operation
00012   ser_port.frequency(1000000); // Clock frequency is 1MHz
00013   while (1){
00014     switch_word=0xA1;            //set up word to be transmitted
00015     ser_port.write(switch_word);  //send switch_word
00016     wait_us(50);
00017   }    
00018 }
00019