not working

This commit is contained in:
Matt Land 2018-05-17 12:14:51 -04:00
parent 30c625ff46
commit 4fd4adf974
4 changed files with 35 additions and 4 deletions

View File

@ -26,6 +26,8 @@
#include "shared-bindings/busio/I2C.h" #include "shared-bindings/busio/I2C.h"
#include "shared-bindings/busio/SPI.h" #include "shared-bindings/busio/SPI.h"
//#include "shared-bindings/busio/UART.h"
#include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Pin.h"
#include "mpconfigboard.h" #include "mpconfigboard.h"
#include "pins.h" #include "pins.h"
@ -34,13 +36,10 @@
#if !defined(DEFAULT_I2C_BUS_SDA) || !defined(DEFAULT_I2C_BUS_SCL) #if !defined(DEFAULT_I2C_BUS_SDA) || !defined(DEFAULT_I2C_BUS_SCL)
STATIC mp_obj_t board_i2c(void) { STATIC mp_obj_t board_i2c(void) {
//board_i2c_obj = NULL;
mp_raise_NotImplementedError("No default I2C bus"); mp_raise_NotImplementedError("No default I2C bus");
return NULL; return NULL;
} }
#else #else
STATIC mp_obj_t i2c_singleton = NULL; STATIC mp_obj_t i2c_singleton = NULL;
@ -59,7 +58,6 @@
} }
#endif #endif
MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c); MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c);
#if !defined(DEFAULT_SPI_BUS_SCK) || !defined(DEFAULT_SPI_BUS_MISO) || !defined(DEFAULT_SPI_BUS_MOSI) #if !defined(DEFAULT_SPI_BUS_SCK) || !defined(DEFAULT_SPI_BUS_MISO) || !defined(DEFAULT_SPI_BUS_MOSI)
@ -88,3 +86,28 @@ MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c);
} }
#endif #endif
MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi); MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi);
#if !defined(DEFAULT_SERIAL_BUS_RX) || !defined(DEFAULT_SERIAL_BUS_TX)
STATIC mp_obj_t board_serial(void) {
mp_raise_NotImplementedError("No default serial bus");
return NULL;
}
#else
STATIC mp_obj_t serial_singleton = NULL;
STATIC mp_obj_t board_serial(void) {
if (serial_singleton == NULL) {
//busio_uart_obj_t *self = m_new_obj(busio_uart_obj_t);
//self->base.type = &busio_uart_type;
assert_pin_free(DEFAULT_SERIAL_BUS_RX);
assert_pin_free(DEFAULT_SERIAL_BUS_TX);
//common_hal_busio_uart_construct(self, DEFAULT_SERIAL_BUS_TX, DEFAULT_SERIAL_BUS_RX, 9600, 8, PARITY_NONE, 1, 1000, 64);
//serial_singleton = (mp_obj_t)self;
serial_singleton = NULL;
}
return serial_singleton;
}
#endif
MP_DEFINE_CONST_FUN_OBJ_0(board_serial_obj, board_serial);

View File

@ -33,4 +33,7 @@ extern mp_obj_fun_builtin_fixed_t board_i2c_obj;
void board_spi(void); void board_spi(void);
extern mp_obj_fun_builtin_fixed_t board_spi_obj; extern mp_obj_fun_builtin_fixed_t board_spi_obj;
void board_serial(void);
extern mp_obj_fun_builtin_fixed_t board_serial_obj;
#endif // MICROPY_INCLUDED_ATMEL_SAMD_BOARD_BUSSES_H #endif // MICROPY_INCLUDED_ATMEL_SAMD_BOARD_BUSSES_H

View File

@ -15,6 +15,10 @@
#define DEFAULT_I2C_BUS_SCL (&pin_PA05) #define DEFAULT_I2C_BUS_SCL (&pin_PA05)
#define DEFAULT_I2C_BUS_SDA (&pin_PA04) #define DEFAULT_I2C_BUS_SDA (&pin_PA04)
#define DEFAULT_SERIAL_BUS_RX (&pin_PA05)
#define DEFAULT_SERIAL_BUS_TX (&pin_PA04)
#include "internal_flash.h" #include "internal_flash.h"
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000) #define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)

View File

@ -22,5 +22,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_PA01) }, { MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_PA01) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
{ MP_ROM_QSTR(MP_QSTR_SERIAL), MP_ROM_PTR(&board_i2c_obj) },
}; };
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);