File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 2020// #define IS_TEENSY_BUILTIN // Teensy boards with built-in CAN interface (e.g. Teensy 4.1). See below to select which interface to use.
2121// #define IS_ARDUINO_BUILTIN // Arduino boards with built-in CAN interface (e.g. Arduino Uno R4 Minima)
2222// #define IS_MCP2515 // Any board with external MCP2515 based extension module. See below to configure the module.
23+ // #define IS_STM32_BUILTIN // STM32 boards with built-in CAN interface (e.g. STM32F4 Discovery).
2324
2425
2526/* Board-specific includes ---------------------------------------------------*/
2627
27- #if defined(IS_TEENSY_BUILTIN) + defined(IS_ARDUINO_BUILTIN) + defined(IS_MCP2515) != 1
28+ #if defined(IS_TEENSY_BUILTIN) + defined(IS_ARDUINO_BUILTIN) + defined(IS_MCP2515) + defined(IS_STM32_BUILTIN) != 1
2829#warning "Select exactly one hardware option at the top of this file."
2930
3031#if CAN_HOWMANY > 0 || CANFD_HOWMANY > 0
5859struct ODriveStatus ; // hack to prevent teensy compile error
5960#endif // IS_TEENSY_BUILTIN
6061
62+ #ifdef IS_STM32_BUILTIN
63+ // See https://github.com/pazi88/STM32_CAN
64+ #include < STM32_CAN.h>
65+ #include " ODriveSTM32CAN.hpp"
66+ #endif // IS_STM32_BUILTIN
6167
6268
6369
@@ -138,6 +144,22 @@ bool setupCan() {
138144#endif
139145
140146
147+ /* STM32 boards with built-in CAN */
148+
149+ #ifdef IS_STM32_BUILTIN
150+
151+ STM32_CAN Can1 ( CAN1 );
152+ STM32_CAN& can_intf = Can1;
153+
154+ bool setupCan () {
155+ can_intf.begin ();
156+ can_intf.setBaudRate (CAN_BAUDRATE);
157+ return true ;
158+ }
159+
160+ #endif // IS_STM32_BUILTIN
161+
162+
141163/* Example sketch ------------------------------------------------------------*/
142164
143165// Instantiate ODrive objects
You can’t perform that action at this time.
0 commit comments