remove instance parameter

This commit is contained in:
microDev 2022-01-05 12:24:48 +05:30
parent 96c6271134
commit 2f6ef766ea
No known key found for this signature in database
GPG Key ID: 2C0867BE60967730
2 changed files with 18 additions and 12 deletions

View File

@ -64,9 +64,8 @@ STATIC mp_int_t board_get_instance(size_t n_args, const mp_obj_t *args, const mp
}
#endif
//| def I2C(instance: Optional[int] = 0) -> busio.I2C:
//| def I2C() -> busio.I2C:
//| """Returns the `busio.I2C` object for the board's designated I2C bus(es).
//| If there is more than one default I2C bus, the buses are numbered starting at 0.
//| The object created is a singleton, and uses the default parameter values for `busio.I2C`."""
//| ...
//|
@ -85,11 +84,13 @@ mp_obj_t board_i2c(size_t n_args, const mp_obj_t *args) {
return MP_ROM_NONE;
}
#endif
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(board_i2c_obj, 0, 1, board_i2c);
STATIC mp_obj_t board_i2c_0(void) {
return board_i2c(0, NULL);
}
MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c_0);
//| def SPI(instance: Optional[int] = 0) -> busio.SPI:
//| def SPI() -> busio.SPI:
//| """Returns the `busio.SPI` object for the board's designated SPI bus(es).
//| If there is more than one default SPI bus, the buses are numbered starting at 0.
//| The object created is a singleton, and uses the default parameter values for `busio.SPI`."""
//| ...
//|
@ -108,11 +109,13 @@ mp_obj_t board_spi(size_t n_args, const mp_obj_t *args) {
return MP_ROM_NONE;
}
#endif
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(board_spi_obj, 0, 1, board_spi);
STATIC mp_obj_t board_spi_0(void) {
return board_spi(0, NULL);
}
MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi_0);
//| def UART(instance: Optional[int] = 0) -> busio.UART:
//| def UART() -> busio.UART:
//| """Returns the `busio.UART` object for the board's designated UART bus(es).
//| If there is more than one default UART bus, the buses are numbered starting at 0.
//| The object created is a singleton, and uses the default parameter values for `busio.UART`."""
//| ...
//|
@ -131,7 +134,10 @@ mp_obj_t board_uart(size_t n_args, const mp_obj_t *args) {
return MP_ROM_NONE;
}
#endif
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(board_uart_obj, 0, 1, board_uart);
STATIC mp_obj_t board_uart_0(void) {
return board_uart(0, NULL);
}
MP_DEFINE_CONST_FUN_OBJ_0(board_uart_obj, board_uart_0);
const mp_obj_module_t board_module = {
.base = { &mp_type_module },

View File

@ -39,19 +39,19 @@ bool common_hal_board_is_i2c(mp_obj_t obj);
mp_obj_t common_hal_board_get_i2c(const mp_int_t instance);
mp_obj_t common_hal_board_create_i2c(const mp_int_t instance);
mp_obj_t board_i2c(size_t n_args, const mp_obj_t *args);
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(board_i2c_obj);
MP_DECLARE_CONST_FUN_OBJ_0(board_i2c_obj);
bool common_hal_board_is_spi(mp_obj_t obj);
mp_obj_t common_hal_board_get_spi(const mp_int_t instance);
mp_obj_t common_hal_board_create_spi(const mp_int_t instance);
mp_obj_t board_spi(size_t n_args, const mp_obj_t *args);
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(board_spi_obj);
MP_DECLARE_CONST_FUN_OBJ_0(board_spi_obj);
bool common_hal_board_is_uart(mp_obj_t obj);
mp_obj_t common_hal_board_get_uart(const mp_int_t instance);
mp_obj_t common_hal_board_create_uart(const mp_int_t instance);
mp_obj_t board_uart(size_t n_args, const mp_obj_t *args);
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(board_uart_obj);
MP_DECLARE_CONST_FUN_OBJ_0(board_uart_obj);
#define CIRCUITPY_BOARD_BUS_SINGLETON(name, bus, instance) \
STATIC mp_obj_t board_##name(void) { \