UART Command Parser Time Manager Data Store for SD Card for stm32l476 [it's not Licensed as BSD/GPLx]
Dependencies: mbed SDFileSystem
main.cpp@9:c81d0df866f5, 2019-05-13 (annotated)
- Committer:
- Inscape_ao
- Date:
- Mon May 13 02:56:39 2019 +0000
- Revision:
- 9:c81d0df866f5
- Parent:
- 7:9ab8809f9693
- Child:
- 10:db2be22bc2f9
add DeviceDriver Interface; add Response (XDS, XFD)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Inscape_ao | 0:c347f602596d | 1 | /** --- Includes --- */ |
Inscape_ao | 0:c347f602596d | 2 | #include "mbed.h" |
Inscape_ao | 2:a694440145e9 | 3 | #include "SDFileSystem.h" |
Inscape_ao | 2:a694440145e9 | 4 | #include "TimeManager.h" |
Inscape_ao | 0:c347f602596d | 5 | #include "UartReceiver.h" |
Inscape_ao | 0:c347f602596d | 6 | #include "CommandParser.h" |
Inscape_ao | 5:a37e3a15444b | 7 | #include "SDDataStore.h" |
Inscape_ao | 0:c347f602596d | 8 | #include "global.h" |
Inscape_ao | 0:c347f602596d | 9 | #include "string.h" |
Inscape_ao | 7:9ab8809f9693 | 10 | #include "DeviceRepeater.h" |
Inscape_ao | 7:9ab8809f9693 | 11 | #include "DummyDevice.h" |
Inscape_ao | 0:c347f602596d | 12 | |
Inscape_ao | 0:c347f602596d | 13 | /** --- Global Variables --- */ |
Inscape_ao | 0:c347f602596d | 14 | Serial pc(SERIAL_TX, SERIAL_RX); |
Inscape_ao | 0:c347f602596d | 15 | DigitalOut myled(LED1); |
Inscape_ao | 1:71c9c97c9f3d | 16 | |
Inscape_ao | 0:c347f602596d | 17 | /** --- main --- */ |
Inscape_ao | 0:c347f602596d | 18 | int main() |
Inscape_ao | 0:c347f602596d | 19 | { |
Inscape_ao | 0:c347f602596d | 20 | /** UART Initalizer */ |
Inscape_ao | 0:c347f602596d | 21 | /* setup UART 115200, 8bit, Parity=None, stopbit:1bit */ |
Inscape_ao | 0:c347f602596d | 22 | /* https://os.mbed.com/users/okini3939/notebook/Serial_jp/ */ |
Inscape_ao | 0:c347f602596d | 23 | pc.baud(115200); |
Inscape_ao | 0:c347f602596d | 24 | pc.format(8, Serial::None, 1); |
Inscape_ao | 0:c347f602596d | 25 | |
Inscape_ao | 2:a694440145e9 | 26 | /* new timer manager */ |
Inscape_ao | 2:a694440145e9 | 27 | pTM = new TimeManager(); |
Inscape_ao | 5:a37e3a15444b | 28 | /* Generate SDDataStore */ |
Inscape_ao | 5:a37e3a15444b | 29 | pSds = new SDDataStore(pTM); |
Inscape_ao | 0:c347f602596d | 30 | /* Receive Buffer Control */ |
Inscape_ao | 0:c347f602596d | 31 | pUR = new UartReceiver(&pc); |
Inscape_ao | 9:c81d0df866f5 | 32 | |
Inscape_ao | 9:c81d0df866f5 | 33 | /* create Device */ |
Inscape_ao | 9:c81d0df866f5 | 34 | pDevRept = new DeviceRepeater(&DummyDev); |
Inscape_ao | 9:c81d0df866f5 | 35 | |
Inscape_ao | 0:c347f602596d | 36 | /* Generate Command parser as DeviceID = 0, ParsingRule = rules */ |
Inscape_ao | 2:a694440145e9 | 37 | pCP = new CommandParser(pUR, 0, rules, getNumOfRules); |
Inscape_ao | 0:c347f602596d | 38 | pCP->run(); |
Inscape_ao | 6:81a3d517fd56 | 39 | |
Inscape_ao | 7:9ab8809f9693 | 40 | pc.printf(":0 ACK 0004 0000\n"); |
Inscape_ao | 4:bec3f80dc49c | 41 | |
Inscape_ao | 0:c347f602596d | 42 | while(1) { |
Inscape_ao | 0:c347f602596d | 43 | wait(1); |
Inscape_ao | 0:c347f602596d | 44 | } |
Inscape_ao | 0:c347f602596d | 45 | } |