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
Revision 0:36cebc939c49, committed 2016-09-29
- Comitter:
- ryood
- Date:
- Thu Sep 29 05:55:59 2016 +0000
- Child:
- 1:74e13cd94576
- Commit message:
- first commit
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 29 05:55:59 2016 +0000 @@ -0,0 +1,53 @@ +#include "mbed.h" +#include "rtos.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 +DigitalOut SpiMCs(PB_6); + +uint8_t prevSendVal = 0x00; + +int main() +{ + 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 Switches + Switches.mode(PullUp); + /* + while(1) { + printf("%x\r\n", ~Switches.read() &0x3f); + Thread::wait(100); + } + */ + + // Setup SPI + SpiMCs = 1; + SpiM.format(8, 0); + SpiM.frequency(SPI_SPEED); + + for (;;) { + uint8_t sendVal = ~Switches.read(); + + if (prevSendVal != sendVal) { + SpiMCs = 0; + uint8_t receivedVal = SpiM.write(sendVal); + SpiMCs = 1; + + prevSendVal = sendVal; + + Leds.write(receivedVal & 0x0f); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Thu Sep 29 05:55:59 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#4c105b8d7cae
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Sep 29 05:55:59 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file