Fork of serial_connected_mcu by
serial_connected_mcu_slave.hpp@3:c927b60f053c, 2016-07-10 (annotated)
- Committer:
- inst
- Date:
- Sun Jul 10 06:53:44 2016 +0000
- Revision:
- 3:c927b60f053c
- Child:
- 4:1323ef48a984
add serial_connected_mcu_slave;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
inst | 3:c927b60f053c | 1 | #ifndef SERIAL_CONNECTED_MCU_SLAVE_ |
inst | 3:c927b60f053c | 2 | #define SERIAL_CONNECTED_MCU_SLAVE_ |
inst | 3:c927b60f053c | 3 | |
inst | 3:c927b60f053c | 4 | #include "mbed.h" |
inst | 3:c927b60f053c | 5 | #include <stdint.h> |
inst | 3:c927b60f053c | 6 | #include <string> |
inst | 3:c927b60f053c | 7 | #include <stdlib.h> |
inst | 3:c927b60f053c | 8 | #include <sstream> |
inst | 3:c927b60f053c | 9 | |
inst | 3:c927b60f053c | 10 | namespace serial_connected_mcu{ |
inst | 3:c927b60f053c | 11 | enum{ |
inst | 3:c927b60f053c | 12 | ESC1, |
inst | 3:c927b60f053c | 13 | ESC2, |
inst | 3:c927b60f053c | 14 | ESC3, |
inst | 3:c927b60f053c | 15 | SIZE_OF_READ_DATA |
inst | 3:c927b60f053c | 16 | }; |
inst | 3:c927b60f053c | 17 | |
inst | 3:c927b60f053c | 18 | enum{ |
inst | 3:c927b60f053c | 19 | ENCODER1, |
inst | 3:c927b60f053c | 20 | ENCODER2, |
inst | 3:c927b60f053c | 21 | ENCODER3, |
inst | 3:c927b60f053c | 22 | POTENTIONMETER1, |
inst | 3:c927b60f053c | 23 | POTENTIONMETER2, |
inst | 3:c927b60f053c | 24 | POTENTIONMETER3, |
inst | 3:c927b60f053c | 25 | SIZE_OF_WRITE_DATA |
inst | 3:c927b60f053c | 26 | }; |
inst | 3:c927b60f053c | 27 | |
inst | 3:c927b60f053c | 28 | class serial_connected_mcu_slave{ |
inst | 3:c927b60f053c | 29 | public: |
inst | 3:c927b60f053c | 30 | serial_connected_mcu_slave(); |
inst | 3:c927b60f053c | 31 | ~serial_connected_mcu_slave(); |
inst | 3:c927b60f053c | 32 | void set(int index_of_data, int16_t setting_data); |
inst | 3:c927b60f053c | 33 | int16_t get(int index_of_data); |
inst | 3:c927b60f053c | 34 | private: |
inst | 3:c927b60f053c | 35 | static const PinName PIN_SERIAL_TX = SERIAL_TX; |
inst | 3:c927b60f053c | 36 | static const PinName PIN_SERIAL_RX = SERIAL_RX; |
inst | 3:c927b60f053c | 37 | static const int BAUDRATE = 9600; |
inst | 3:c927b60f053c | 38 | int16_t* array_of_read_data; |
inst | 3:c927b60f053c | 39 | int16_t* array_of_write_data; |
inst | 3:c927b60f053c | 40 | std::string received_buffer; |
inst | 3:c927b60f053c | 41 | Serial* port; |
inst | 3:c927b60f053c | 42 | bool is_locking; |
inst | 3:c927b60f053c | 43 | void on_received(); |
inst | 3:c927b60f053c | 44 | void string_to_int(); |
inst | 3:c927b60f053c | 45 | }; |
inst | 3:c927b60f053c | 46 | } |