12
12
static inline ODriveCanIntfWrapper wrap_can_intf (TIntf& intf) { \
13
13
return { \
14
14
&intf, \
15
- [](void * intf, uint32_t id, uint8_t length, const uint8_t * data) { return sendMsg (*(TIntf*)intf, id, length, data); }, \
16
- [](void * intf) { pumpEvents (*(TIntf*)intf); } \
15
+ ([](void * intf, uint32_t id, uint8_t length, const uint8_t * data) { \
16
+ return sendMsg (*(TIntf*)intf, id, length, data); \
17
+ }), \
18
+ [](void * intf) { pumpEvents (*(TIntf*)intf); }, \
17
19
}; \
18
20
}
19
21
20
22
21
23
struct ODriveCanIntfWrapper {
22
- bool sendMsg (uint32_t id, uint8_t length, const uint8_t * data) {
23
- return (*send_msg_)(can_intf_, id, length, data);
24
- }
25
- void pump_events () {
26
- (*pump_events_)(can_intf_);
27
- }
24
+ bool sendMsg (uint32_t id, uint8_t length, const uint8_t * data) { return (*send_msg_)(can_intf_, id, length, data); }
25
+ void pump_events () { (*pump_events_)(can_intf_); }
28
26
29
27
void * can_intf_;
30
28
bool (*send_msg_)(void * intf, uint32_t id, uint8_t length, const uint8_t * data);
@@ -33,8 +31,7 @@ struct ODriveCanIntfWrapper {
33
31
34
32
class ODriveCAN {
35
33
public:
36
- ODriveCAN (const ODriveCanIntfWrapper& can_intf, uint32_t node_id)
37
- : can_intf_(can_intf), node_id_(node_id) {};
34
+ ODriveCAN (const ODriveCanIntfWrapper& can_intf, uint32_t node_id) : can_intf_(can_intf), node_id_(node_id){};
38
35
39
36
/* *
40
37
* @brief Clear all errors on the ODrive.
@@ -202,8 +199,11 @@ class ODriveCAN {
202
199
/* *
203
200
* @brief Registers a callback for ODrive feedback processing.
204
201
*/
205
- void onFeedback (void (*callback)(Get_Encoder_Estimates_msg_t& feedback, void * user_data), void* user_data = nullptr) {
206
- feedback_callback_ = callback;
202
+ void onFeedback (
203
+ void (*callback)(Get_Encoder_Estimates_msg_t& feedback, void * user_data),
204
+ void* user_data = nullptr
205
+ ) {
206
+ feedback_callback_ = callback;
207
207
feedback_user_data_ = user_data;
208
208
}
209
209
@@ -234,7 +234,10 @@ class ODriveCAN {
234
234
/* *
235
235
* @brief Registers a callback for ODrive bus voltage/current feedback.
236
236
*/
237
- void onBusVI (void (*callback)(Get_Bus_Voltage_Current_msg_t& feedback, void * user_data), void* user_data = nullptr) {
237
+ void onBusVI (
238
+ void (*callback)(Get_Bus_Voltage_Current_msg_t& feedback, void * user_data),
239
+ void* user_data = nullptr
240
+ ) {
238
241
busVI_callback_ = callback;
239
242
busVI_user_data_ = user_data;
240
243
}
@@ -288,11 +291,7 @@ class ODriveCAN {
288
291
bool send (const T& msg) {
289
292
uint8_t data[8 ] = {};
290
293
msg.encode_buf (data);
291
- return can_intf_.sendMsg (
292
- (node_id_ << ODriveCAN::kNodeIdShift ) | msg.cmd_id ,
293
- msg.msg_length ,
294
- data
295
- );
294
+ return can_intf_.sendMsg ((node_id_ << ODriveCAN::kNodeIdShift ) | msg.cmd_id , msg.msg_length , data);
296
295
}
297
296
298
297
/* *
0 commit comments