1212 static inline ODriveCanIntfWrapper wrap_can_intf (TIntf& intf) { \
1313 return { \
1414 &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); }, \
1719 }; \
1820 }
1921
2022
2123struct 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_); }
2826
2927 void * can_intf_;
3028 bool (*send_msg_)(void * intf, uint32_t id, uint8_t length, const uint8_t * data);
@@ -33,8 +31,7 @@ struct ODriveCanIntfWrapper {
3331
3432class ODriveCAN {
3533public:
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){};
3835
3936 /* *
4037 * @brief Clear all errors on the ODrive.
@@ -202,8 +199,11 @@ class ODriveCAN {
202199 /* *
203200 * @brief Registers a callback for ODrive feedback processing.
204201 */
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;
207207 feedback_user_data_ = user_data;
208208 }
209209
@@ -234,7 +234,10 @@ class ODriveCAN {
234234 /* *
235235 * @brief Registers a callback for ODrive bus voltage/current feedback.
236236 */
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+ ) {
238241 busVI_callback_ = callback;
239242 busVI_user_data_ = user_data;
240243 }
@@ -288,11 +291,7 @@ class ODriveCAN {
288291 bool send (const T& msg) {
289292 uint8_t data[8 ] = {};
290293 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);
296295 }
297296
298297 /* *
0 commit comments