Skip to content

Commit 6dba992

Browse files
committed
stmhal: Add config option to disable/enable CAN driver.
1 parent ba0383a commit 6dba992

8 files changed

Lines changed: 12 additions & 0 deletions

File tree

stmhal/boards/HYDRABUS/mpconfigboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define MICROPY_HW_ENABLE_I2C1 (1)
1717
#define MICROPY_HW_ENABLE_SPI1 (1)
1818
#define MICROPY_HW_ENABLE_SPI3 (1)
19+
#define MICROPY_HW_ENABLE_CAN (0)
1920

2021
// USRSW/UBTN (Needs Jumper UBTN) is pulled low. Pressing the button makes the input go high.
2122
#define MICROPY_HW_USRSW_PIN (pin_A0)

stmhal/boards/NETDUINO_PLUS_2/mpconfigboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define MICROPY_HW_ENABLE_I2C1 (0)
2121
#define MICROPY_HW_ENABLE_SPI1 (0)
2222
#define MICROPY_HW_ENABLE_SPI3 (0)
23+
#define MICROPY_HW_ENABLE_CAN (0)
2324

2425
// USRSW is pulled low. Pressing the button makes the input go high.
2526
#define MICROPY_HW_USRSW_PIN (pin_B11)

stmhal/boards/PYBV10/mpconfigboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define MICROPY_HW_ENABLE_I2C1 (1)
1818
#define MICROPY_HW_ENABLE_SPI1 (1)
1919
#define MICROPY_HW_ENABLE_SPI3 (0)
20+
#define MICROPY_HW_ENABLE_CAN (1)
2021

2122
// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
2223
#define MICROPY_HW_USRSW_PIN (pin_B3)

stmhal/boards/PYBV3/mpconfigboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define MICROPY_HW_ENABLE_I2C1 (1)
1717
#define MICROPY_HW_ENABLE_SPI1 (1)
1818
#define MICROPY_HW_ENABLE_SPI3 (0)
19+
#define MICROPY_HW_ENABLE_CAN (1)
1920

2021
// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
2122
#define MICROPY_HW_USRSW_PIN (pin_A13)

stmhal/boards/PYBV4/mpconfigboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define MICROPY_HW_ENABLE_I2C1 (1)
1717
#define MICROPY_HW_ENABLE_SPI1 (1)
1818
#define MICROPY_HW_ENABLE_SPI3 (0)
19+
#define MICROPY_HW_ENABLE_CAN (1)
1920

2021
// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
2122
#define MICROPY_HW_USRSW_PIN (pin_B3)

stmhal/boards/STM32F4DISC/mpconfigboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define MICROPY_HW_ENABLE_I2C1 (1)
1717
#define MICROPY_HW_ENABLE_SPI1 (1)
1818
#define MICROPY_HW_ENABLE_SPI3 (0)
19+
#define MICROPY_HW_ENABLE_CAN (1)
1920

2021
// USRSW is pulled low. Pressing the button makes the input go high.
2122
#define MICROPY_HW_USRSW_PIN (pin_A0)

stmhal/can.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#include "can.h"
4343
#include "pybioctl.h"
4444

45+
#if MICROPY_HW_ENABLE_CAN
46+
4547
/// \moduleref pyb
4648
/// \class CAN - controller area network communication bus
4749
///
@@ -451,3 +453,5 @@ const mp_obj_type_t pyb_can_type = {
451453
.stream_p = &can_stream_p,
452454
.locals_dict = (mp_obj_t)&pyb_can_locals_dict,
453455
};
456+
457+
#endif // MICROPY_HW_ENABLE_CAN

stmhal/modpyb.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,9 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
523523
{ MP_OBJ_NEW_QSTR(MP_QSTR_I2C), (mp_obj_t)&pyb_i2c_type },
524524
{ MP_OBJ_NEW_QSTR(MP_QSTR_SPI), (mp_obj_t)&pyb_spi_type },
525525
{ MP_OBJ_NEW_QSTR(MP_QSTR_UART), (mp_obj_t)&pyb_uart_type },
526+
#if MICROPY_HW_ENABLE_CAN
526527
{ MP_OBJ_NEW_QSTR(MP_QSTR_CAN), (mp_obj_t)&pyb_can_type },
528+
#endif
527529

528530
{ MP_OBJ_NEW_QSTR(MP_QSTR_ADC), (mp_obj_t)&pyb_adc_type },
529531
{ MP_OBJ_NEW_QSTR(MP_QSTR_ADCAll), (mp_obj_t)&pyb_adc_all_type },

0 commit comments

Comments
 (0)