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.
main.cpp@0:f7540c6ff050, 2015-02-25 (annotated)
- Committer:
- fvbever
- Date:
- Wed Feb 25 08:05:24 2015 +0000
- Revision:
- 0:f7540c6ff050
published for debug
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| fvbever | 0:f7540c6ff050 | 1 | #include "mbed.h" | 
| fvbever | 0:f7540c6ff050 | 2 | |
| fvbever | 0:f7540c6ff050 | 3 | Serial pc(USBTX, USBRX); | 
| fvbever | 0:f7540c6ff050 | 4 | SPI spi(D11, D12, D13); // mosi, miso, sclk | 
| fvbever | 0:f7540c6ff050 | 5 | DigitalOut cs(D10); | 
| fvbever | 0:f7540c6ff050 | 6 | |
| fvbever | 0:f7540c6ff050 | 7 | int main(){ | 
| fvbever | 0:f7540c6ff050 | 8 | pc.printf("SPI example application\r\n"); | 
| fvbever | 0:f7540c6ff050 | 9 | |
| fvbever | 0:f7540c6ff050 | 10 | // chip must be deselected | 
| fvbever | 0:f7540c6ff050 | 11 | cs=1; | 
| fvbever | 0:f7540c6ff050 | 12 | |
| fvbever | 0:f7540c6ff050 | 13 | // set up SPI | 
| fvbever | 0:f7540c6ff050 | 14 | spi.format(8,0); | 
| fvbever | 0:f7540c6ff050 | 15 | spi.frequency(1000000); | 
| fvbever | 0:f7540c6ff050 | 16 | |
| fvbever | 0:f7540c6ff050 | 17 | // select device | 
| fvbever | 0:f7540c6ff050 | 18 | cs=0; | 
| fvbever | 0:f7540c6ff050 | 19 | |
| fvbever | 0:f7540c6ff050 | 20 | spi.write(0x80); | 
| fvbever | 0:f7540c6ff050 | 21 | |
| fvbever | 0:f7540c6ff050 | 22 | int id = spi.write(0x00); | 
| fvbever | 0:f7540c6ff050 | 23 | printf("Device ID is= 0x%X\r\n",id); | 
| fvbever | 0:f7540c6ff050 | 24 | |
| fvbever | 0:f7540c6ff050 | 25 | // deselect device | 
| fvbever | 0:f7540c6ff050 | 26 | cs = 1; | 
| fvbever | 0:f7540c6ff050 | 27 | } | 
| fvbever | 0:f7540c6ff050 | 28 | |
| fvbever | 0:f7540c6ff050 | 29 | |
| fvbever | 0:f7540c6ff050 | 30 | |
| fvbever | 0:f7540c6ff050 | 31 |