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.
main.cpp@4:a091b8f8216d, 2014-05-04 (annotated)
- Committer:
- sNICKer1103
- Date:
- Sun May 04 20:41:10 2014 +0000
- Revision:
- 4:a091b8f8216d
- Parent:
- 3:da30c350c339
- Child:
- 5:e4ed6c5baf89
Refactoring part 3
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| sNICKer1103 | 0:333c9abcd919 | 1 | #include "mbed.h" |
| sNICKer1103 | 2:f2700008c9d9 | 2 | #include "I2CDriver.h" |
| sNICKer1103 | 2:f2700008c9d9 | 3 | #include "SPIDriver.h" |
| sNICKer1103 | 2:f2700008c9d9 | 4 | #include "LedCube.h" |
| sNICKer1103 | 3:da30c350c339 | 5 | #include "rtos.h" |
| sNICKer1103 | 0:333c9abcd919 | 6 | |
| sNICKer1103 | 4:a091b8f8216d | 7 | const int FRAMES = 700; |
| sNICKer1103 | 4:a091b8f8216d | 8 | const int SPIFREQ = 10000000; //frequency of SPI interface |
| sNICKer1103 | 4:a091b8f8216d | 9 | const char ADDRESS = 0xA0; //address van I2C interface |
| sNICKer1103 | 0:333c9abcd919 | 10 | |
| sNICKer1103 | 3:da30c350c339 | 11 | LedCube* ledcube = new LedCube(); |
| sNICKer1103 | 4:a091b8f8216d | 12 | SPIDriver* spidriver = new SPIDriver(p5, NC, p7, p8, p10, SPIFREQ); |
| sNICKer1103 | 4:a091b8f8216d | 13 | I2CDriver* i2cdriver = new I2CDriver(p28, p27, ADDRESS); |
| sNICKer1103 | 0:333c9abcd919 | 14 | //DigitalOut blank(p9); |
| sNICKer1103 | 0:333c9abcd919 | 15 | |
| sNICKer1103 | 4:a091b8f8216d | 16 | void streamThread(void const* args); |
| sNICKer1103 | 4:a091b8f8216d | 17 | void inputThread(void const* args); |
| sNICKer1103 | 0:333c9abcd919 | 18 | |
| sNICKer1103 | 0:333c9abcd919 | 19 | int main() |
| sNICKer1103 | 0:333c9abcd919 | 20 | { |
| sNICKer1103 | 4:a091b8f8216d | 21 | spidriver->testPhase(FRAMES); |
| sNICKer1103 | 4:a091b8f8216d | 22 | |
| sNICKer1103 | 4:a091b8f8216d | 23 | printf("Initiating stream from following matrices\n\r"); |
| sNICKer1103 | 4:a091b8f8216d | 24 | ledcube->printAll(); |
| sNICKer1103 | 4:a091b8f8216d | 25 | printf("Streaming...\n\r"); |
| sNICKer1103 | 4:a091b8f8216d | 26 | |
| sNICKer1103 | 4:a091b8f8216d | 27 | Thread thread1(streamThread); |
| sNICKer1103 | 4:a091b8f8216d | 28 | Thread thread2(inputThread); |
| sNICKer1103 | 3:da30c350c339 | 29 | |
| sNICKer1103 | 4:a091b8f8216d | 30 | while(true){} |
| sNICKer1103 | 0:333c9abcd919 | 31 | }//end main |
| sNICKer1103 | 0:333c9abcd919 | 32 | |
| sNICKer1103 | 4:a091b8f8216d | 33 | void streamThread(void const* args) |
| sNICKer1103 | 4:a091b8f8216d | 34 | { |
| sNICKer1103 | 4:a091b8f8216d | 35 | while(true) { |
| sNICKer1103 | 4:a091b8f8216d | 36 | spidriver->sendFrame(ledcube); |
| sNICKer1103 | 4:a091b8f8216d | 37 | } |
| sNICKer1103 | 1:53b8c6b13010 | 38 | } |
| sNICKer1103 | 1:53b8c6b13010 | 39 | |
| sNICKer1103 | 4:a091b8f8216d | 40 | void inputThread(void const* args) |
| sNICKer1103 | 1:53b8c6b13010 | 41 | { |
| sNICKer1103 | 4:a091b8f8216d | 42 | while(true) { |
| sNICKer1103 | 4:a091b8f8216d | 43 | i2cdriver->pollForInput(ledcube); |
| sNICKer1103 | 1:53b8c6b13010 | 44 | } |
| sNICKer1103 | 0:333c9abcd919 | 45 | } |