Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- Brianmic
- Date:
- 2014-01-20
- Revision:
- 0:b48d39f6877c
File content as of revision 0:b48d39f6877c:
#include "mbed.h" DigitalOut redLed( LED_RED ); // Led used to signal errors DigitalOut greenLed( LED_GREEN ); DigitalOut spiSS( PTD0 ); // Slave select is handled by GPIO Serial PC (USBTX, USBRX); int main() { redLed = 1; greenLed = 1; // Create SPI master instance, 8bit, CPOL=0, CPHA=1, 100kHz SPI spiMaster( PTD2, PTD3, PTD1 ); // mosi, miso, sclk spiMaster.format( 8, 1 ); spiMaster.frequency( 100000 ); PC.baud(115200); // Deselect slave spiSS = 1; // Forever wait(1); while( 1 ) { uint8_t data[16]; // Burst write spiSS = 0; spiMaster.write( '#' ); spiMaster.write( 0x07 ); // write RAM burst spiMaster.write( 0x01 ); // AA1 spiMaster.write( 0x02 ); // AA2 spiMaster.write( 0x03 ); // AA3 spiMaster.write( 0x01 ); spiMaster.write( 0x01 ); spiMaster.write( 0x55 ); //buco spiMaster.write( 0x55 ); //@ spiMaster.write( 0x02 ); spiMaster.write( 0x02 ); spiMaster.write( 0x55 ); //buco spiMaster.write( 0x55 ); //@ spiMaster.write( 0x03 ); spiMaster.write( 0x03 ); spiMaster.write( 0x55 ); //buco spiMaster.write( 0x55 ); //@ spiMaster.write( '#' ); //# spiSS = 1; wait(1); spiSS = 0; spiMaster.write( '#' ); spiMaster.write( 0x05 ); // write RAM burst spiMaster.write( 0x01 ); // AA1 spiMaster.write( 0x02 ); // AA2 spiMaster.write( 0x03 ); // AA3 spiMaster.write( 0x01 ); //buco spiMaster.write( 0x01 ); //@ data[0] = spiMaster.write( 0x55 ); //DD1 1 data[1] = spiMaster.write( 0x55 ); //DD2 1 spiMaster.write( 0x01 ); //buco spiMaster.write( 0x01 ); //@ data[2] = spiMaster.write( 0x55 ); //DD1 2 data[3] = spiMaster.write( 0x55 ); //DD2 2 spiMaster.write( 0x01 ); //buco spiMaster.write( 0x01 ); //@ data[4] = spiMaster.write( 0x55 ); //DD1 3 data[5] = spiMaster.write( '#' ); //DD2 3 for(int i = 0; i<3 ; i++) { PC.printf("%d.%d\r\n", data[2*i], data[2*i+1]); } spiSS = 1; wait(2); } }