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
main.cpp
- Committer:
- ryood
- Date:
- 2016-10-04
- Revision:
- 5:915a9d45c969
- Parent:
- 4:c2b67c69d048
- Child:
- 6:66955ebd56dd
File content as of revision 5:915a9d45c969:
#include "mbed.h" #include "rtos.h" #include "st7565LCD.h" #define SPI_SPEED (4000000) #define SPI_DUMMY_DATA (0x55) 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); 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); volatile bool isStepChanged = false; uint8_t prevSendVal = 0x00; void setChangeStep() { isStepChanged = true; } int main() { printf("\r\n\nNucleo rtos SPI Master Test..\r\n"); #if DEVICE_SPI_ASYNCH printf("DEVICE_SPI_ASYNCH: defined\r\n"); #else printf("DEVICE_SPI_ASYNCH: not defined\r\n"); #endif // Setup LCD gLCD.begin(0x10); gLCD.drawstring(0, 0, "SPI Master Test"); gLCD.display(); // Setup Switches Switches.mode(PullUp); /* while(1) { printf("%x\r\n", ~Switches.read() &0x3f); Thread::wait(100); } */ // Setup Interrupt stepChangeInterrupt.fall(&setChangeStep); // Setup SPI SpiMCs = 1; SpiM.format(8, 0); SpiM.frequency(SPI_SPEED); Thread::wait(1000); //gLCD.clear(); uint8_t count = 0; for (;;) { SpiMCs = 0; uint8_t receivedVal = SpiM.write(count); SpiMCs = 1; count++; if (isStepChanged) { char lineBuffer[20]; sprintf(lineBuffer, "Step: %02d", receivedVal); gLCD.drawstring(0, 0, lineBuffer); gLCD.display(); isStepChanged = false; } //Thread::wait(1); wait_us(100); } }