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:
- 1:74e13cd94576
- Parent:
- 0:36cebc939c49
- Child:
- 2:95204570426c
diff -r 36cebc939c49 -r 74e13cd94576 main.cpp --- a/main.cpp Thu Sep 29 05:55:59 2016 +0000 +++ b/main.cpp Thu Sep 29 07:41:01 2016 +0000 @@ -9,8 +9,31 @@ SPI SpiM(PA_7, PA_6, PA_5); // mosi, miso, sclk DigitalOut SpiMCs(PB_6); +InterruptIn stepChangeInterrupt(PC_7); +//DigitalOut myled(PA_10); + +volatile bool isStepChanged = false; uint8_t prevSendVal = 0x00; +//float delay = 1.0f; + +void setChangeStep() +{ + isStepChanged = true; + /* + static uint8_t f = 0x0f; + + Leds.write(f); + f = ~f & 0x0f; + */ + /* + if (delay == 1.0) + delay = 0.2; // 200 ms + else + delay = 1.0; // 1 sec + */ +} + int main() { printf("\r\n\nNucleo rtos SPI Master Test..\r\n"); @@ -32,6 +55,9 @@ } */ + // Setup Interrupt + stepChangeInterrupt.fall(&setChangeStep); + // Setup SPI SpiMCs = 1; SpiM.format(8, 0); @@ -39,15 +65,19 @@ for (;;) { uint8_t sendVal = ~Switches.read(); + static uint8_t receivedVal; - if (prevSendVal != sendVal) { + //if (prevSendVal != sendVal) { SpiMCs = 0; - uint8_t receivedVal = SpiM.write(sendVal); + receivedVal = SpiM.write(sendVal); SpiMCs = 1; prevSendVal = sendVal; - + //} + + if (isStepChanged) { Leds.write(receivedVal & 0x0f); + isStepChanged = false; } } }