nucleo側のプログラム

Dependents:   serial_connected_mcu_nucleo serial_connected_mcu_nucleo

Fork of serial_connected_mcu by tarou yamada

Committer:
kachikyun
Date:
Sun Jul 10 07:37:00 2016 +0000
Revision:
5:77d6f1ddf2e4
Parent:
4:1323ef48a984
Child:
11:6f8e34a71c7e

        

Who changed what in which revision?

UserRevisionLine numberNew 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 4:1323ef48a984 11 enum read_id {
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 4:1323ef48a984 18 enum write_id {
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:
kachikyun 5:77d6f1ddf2e4 35 static const PinName PIN_SERIAL_TX;
kachikyun 5:77d6f1ddf2e4 36 static const PinName PIN_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 4:1323ef48a984 46 }
inst 4:1323ef48a984 47
inst 4:1323ef48a984 48 #endif