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: Adafruit_GFX_nano SPI_Demo_Nano
main.cpp@7:029f4ce1f8b2, 2015-02-25 (annotated)
- Committer:
- tsh
- Date:
- Wed Feb 25 22:56:59 2015 +0000
- Revision:
- 7:029f4ce1f8b2
- Parent:
- 4:9decf12340fa
remove pc printf
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| tsh | 0:057ae71e1b6f | 1 | /* |
| tsh | 0:057ae71e1b6f | 2 | |
| tsh | 0:057ae71e1b6f | 3 | Copyright (c) 2012-2014 RedBearLab |
| tsh | 0:057ae71e1b6f | 4 | |
| tsh | 0:057ae71e1b6f | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
| tsh | 0:057ae71e1b6f | 6 | and associated documentation files (the "Software"), to deal in the Software without restriction, |
| tsh | 0:057ae71e1b6f | 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| tsh | 0:057ae71e1b6f | 8 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, |
| tsh | 0:057ae71e1b6f | 9 | subject to the following conditions: |
| tsh | 0:057ae71e1b6f | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
| tsh | 0:057ae71e1b6f | 11 | |
| tsh | 0:057ae71e1b6f | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, |
| tsh | 0:057ae71e1b6f | 13 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
| tsh | 0:057ae71e1b6f | 14 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE |
| tsh | 0:057ae71e1b6f | 15 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| tsh | 0:057ae71e1b6f | 16 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| tsh | 0:057ae71e1b6f | 17 | |
| tsh | 0:057ae71e1b6f | 18 | */ |
| tsh | 0:057ae71e1b6f | 19 | |
| tsh | 0:057ae71e1b6f | 20 | #include "mbed.h" |
| tsh | 0:057ae71e1b6f | 21 | #include "spi_master.h" |
| tsh | 3:6122dfbc9d9e | 22 | #include "Adafruit_SSD1306.h" |
| tsh | 0:057ae71e1b6f | 23 | |
| tsh | 4:9decf12340fa | 24 | //DigitalOut spi_cs(P0_10); |
| tsh | 4:9decf12340fa | 25 | DigitalOut rst(A3); |
| tsh | 4:9decf12340fa | 26 | DigitalOut dc(A4); |
| tsh | 4:9decf12340fa | 27 | DigitalOut cs(D2); |
| tsh | 4:9decf12340fa | 28 | DigitalOut led(D13); |
| tsh | 0:057ae71e1b6f | 29 | |
| tsh | 0:057ae71e1b6f | 30 | SPIClass SPI1(NRF_SPI1); |
| tsh | 0:057ae71e1b6f | 31 | |
| tsh | 4:9decf12340fa | 32 | //Adafruit_SSD1306_nrf gOled1(&SPI1,A4,A3,D2);// SPI, DC, RST, CS |
| tsh | 0:057ae71e1b6f | 33 | |
| tsh | 0:057ae71e1b6f | 34 | int main(void) |
| tsh | 0:057ae71e1b6f | 35 | { |
| tsh | 4:9decf12340fa | 36 | led = 1; // off |
| tsh | 0:057ae71e1b6f | 37 | //SPI1.begin(); |
| tsh | 2:7e5609174292 | 38 | SPI1.begin(P0_8, P0_9, P0_11);//SCK, MOSI, MISO |
| tsh | 4:9decf12340fa | 39 | rst = 1; |
| tsh | 4:9decf12340fa | 40 | // VDD (3.3V) goes high at start, lets just chill for a ms |
| tsh | 4:9decf12340fa | 41 | wait_ms(1); |
| tsh | 4:9decf12340fa | 42 | // bring reset low |
| tsh | 4:9decf12340fa | 43 | rst = 0; |
| tsh | 4:9decf12340fa | 44 | // wait 10ms |
| tsh | 4:9decf12340fa | 45 | wait_ms(10); |
| tsh | 4:9decf12340fa | 46 | // bring out of reset |
| tsh | 4:9decf12340fa | 47 | rst = 1; |
| tsh | 4:9decf12340fa | 48 | // turn on VCC (9V?) |
| tsh | 4:9decf12340fa | 49 | SPI1.transfer(0xAE);// SSD1306_DISPLAYOFF |
| tsh | 4:9decf12340fa | 50 | SPI1.transfer(0xD5);// SSD1306_SETDISPLAYCLOCKDIV |
| tsh | 4:9decf12340fa | 51 | SPI1.transfer(0x80);// // the suggested ratio 0x80 |
| tsh | 7:029f4ce1f8b2 | 52 | |
| tsh | 4:9decf12340fa | 53 | led = 0; // on |
| tsh | 4:9decf12340fa | 54 | wait(1); |
| tsh | 4:9decf12340fa | 55 | led = 1; |
| tsh | 4:9decf12340fa | 56 | wait(1); |
| tsh | 4:9decf12340fa | 57 | led = 0; |
| tsh | 0:057ae71e1b6f | 58 | } |
| tsh | 0:057ae71e1b6f | 59 | |
| tsh | 0:057ae71e1b6f | 60 | |
| tsh | 0:057ae71e1b6f | 61 | |
| tsh | 0:057ae71e1b6f | 62 | |
| tsh | 0:057ae71e1b6f | 63 | |
| tsh | 0:057ae71e1b6f | 64 | |
| tsh | 0:057ae71e1b6f | 65 |