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.
Dependents: 2019_SwitchNode_AR ArmNode 2919_LineSensor 2019_MD ... more
Diff: Mycan.h
- Revision:
- 4:7aa2809ad177
- Parent:
- 3:055c2d38132f
- Child:
- 5:4bdeff035517
--- a/Mycan.h Mon Aug 06 05:40:22 2018 +0000 +++ b/Mycan.h Fri Aug 30 03:08:08 2019 +0000 @@ -2,57 +2,47 @@ #define MYCAN_H #include "mbed.h" +#include <map> + +using namespace std; class Mycan { public: - Mycan(PinName _pin_rd, PinName _pin_td);//※最小IDを.cppの”min_id”で1にセットしている, ”read_val[→ここ][]”の数はIDの個数(結局IDは1~10の設定になっている) + Mycan(PinName _rd, PinName _td, float freq = 1000000); - void set (unsigned int _id, int _num, short int _data);//Messageの設定をする, numは1~7とする + void setI (uint32_t _id, int _num, int16_t _data); + void setF (uint32_t _id, int _num, float _data); - bool send ();//書き込み + bool send (); - void read ();//読み込み + void readI (); + void readF (); - float get(unsigned int _id, int _num);//readした値を持ってくる, IDやnumはコンストラクタと一緒 + float get(uint32_t _id, int _num); //get data private: CAN can; - unsigned int rd_id, td_id; - int rd_num, td_num; - unsigned int min_id; - short int data; - static short int write_val[8]; - static short int read_val[10][8]; - void _expressAbsoluteValue(); - void _expressSignVal(unsigned int); + uint32_t rd_id, td_id; + int rd_num, td_num; + bool write_type, read_type; + + struct can_integer { + char value[8]; + }; + can_integer td_integer, rd_integer; - typedef struct - { - char writeVal_0; - char writeVal_1; - char writeVal_2; - char writeVal_3; - char writeVal_4; - char writeVal_5; - char writeVal_6; - char writeVal_7; - }write_can; - - write_can td_data; + struct can_integer2 { + int16_t value[8]; + }; + can_integer2 rd_storage; - typedef struct - { - char readVal_0; - char readVal_1; - char readVal_2; - char readVal_3; - char readVal_4; - char readVal_5; - char readVal_6; - char readVal_7; - }read_can; + struct can_decimal { + float value[2]; + }; + can_decimal td_decimal, rd_decimal, rd2_storage; - read_can rd_data; + map<uint32_t, can_integer2> integer_values_storage; + map<uint32_t, can_decimal> decimal_values_storage; }; -#endif \ No newline at end of file +#endif