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-rtos mbed st7565LCD
Diff: main.cpp
- Revision:
- 3:2b2c6c0e9f1d
- Parent:
- 2:95204570426c
- Child:
- 4:c2b67c69d048
--- a/main.cpp Thu Sep 29 07:46:45 2016 +0000 +++ b/main.cpp Sat Oct 01 14:10:19 2016 +0000 @@ -1,9 +1,9 @@ #include "mbed.h" #include "rtos.h" +#include "st7565LCD.h" #define SPI_SPEED (10000000) -BusOut Leds(PA_8, PB_10, PB_4, PB_5); BusIn Switches(PA_0, PA_1, PA_4, PB_0, PC_1, PC_0); SPI SpiM(PA_7, PA_6, PA_5); // mosi, miso, sclk @@ -11,6 +11,10 @@ InterruptIn stepChangeInterrupt(PC_7); +//ST7565(PinName mosi, PinName sclk, PinName cs, PinName rst, PinName a0); +ST7565 gLCD(PB_15, PB_13, PB_12, PB_2, PB_1); +PwmOut LCDBackLight(PA_11); + volatile bool isStepChanged = false; uint8_t prevSendVal = 0x00; @@ -23,14 +27,15 @@ { printf("\r\n\nNucleo rtos SPI Master Test..\r\n"); - // LED Check - for (int i = 0; i < 5; i++) { - Leds.write(0x0f); - Thread::wait(100); - Leds.write(0x00); - Thread::wait(100); - } + // Setup LCD + LCDBackLight.period_ms(10); + LCDBackLight = 0.6f; + Thread::wait(10); + gLCD.begin(0x10); + gLCD.drawstring(0, 0, "SPI Master Test"); + gLCD.display(); + // Setup Switches Switches.mode(PullUp); /* @@ -59,7 +64,10 @@ prevSendVal = sendVal; if (isStepChanged) { - Leds.write(receivedVal & 0x0f); + char lineBuffer[32]; + sprintf(lineBuffer, "Step: %02d", receivedVal); + gLCD.drawstring(0, 1, lineBuffer); + gLCD.display(); isStepChanged = false; } }