Merge remote-tracking branch 'upstream/master' into stm32-uart
This commit is contained in:
commit
ed3e377390
|
@ -25,3 +25,6 @@ CIRCUITPY_I2CSLAVE = 0
|
|||
CIRCUITPY_NETWORK = 0
|
||||
CIRCUITPY_TOUCHIO = 0
|
||||
CIRCUITPY_PS2IO = 0
|
||||
|
||||
# Enable micropython.native
|
||||
CIRCUITPY_ENABLE_MPY_NATIVE = 1
|
||||
|
|
|
@ -25,12 +25,13 @@
|
|||
*/
|
||||
|
||||
#include "boards/board.h"
|
||||
#include "mpconfigboard.h"
|
||||
|
||||
void board_init(void) {
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset_board(void) {
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Glenn Ruben Bakke
|
||||
* Copyright (c) 2018 Dan Halbert for Adafruit Industries
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -41,3 +40,13 @@
|
|||
#define SPI_FLASH_MISO_PIN &pin_PB04
|
||||
#define SPI_FLASH_SCK_PIN &pin_PB03
|
||||
#define SPI_FLASH_CS_PIN &pin_PA15
|
||||
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_PB06)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_PB07)
|
||||
|
||||
#define DEFAULT_SPI_BUS_SCK (&pin_PB13)
|
||||
#define DEFAULT_SPI_BUS_MOSI (&pin_PB15)
|
||||
#define DEFAULT_SPI_BUS_MISO (&pin_PB14)
|
||||
|
||||
#define DEFAULT_UART_BUS_RX (&pin_PB11)
|
||||
#define DEFAULT_UART_BUS_TX (&pin_PB10)
|
||||
|
|
|
@ -25,5 +25,9 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
|||
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) },
|
||||
|
||||
{ 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_UART), MP_ROM_PTR(&board_uart_obj) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Glenn Ruben Bakke
|
||||
* Copyright (c) 2018 Dan Halbert for Adafruit Industries
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -34,4 +33,7 @@
|
|||
#define FLASH_PAGE_SIZE (0x4000)
|
||||
|
||||
#define AUTORESET_DELAY_MS 500
|
||||
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000)
|
||||
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000)
|
||||
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_PB06)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_PB07)
|
||||
|
|
|
@ -46,5 +46,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
|||
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Glenn Ruben Bakke
|
||||
* Copyright (c) 2018 Dan Halbert for Adafruit Industries
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Glenn Ruben Bakke
|
||||
* Copyright (c) 2018 Dan Halbert for Adafruit Industries
|
||||
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -36,3 +35,5 @@
|
|||
#define AUTORESET_DELAY_MS 500
|
||||
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000)
|
||||
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_PB10)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_PB09)
|
||||
|
|
|
@ -88,5 +88,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
|||
{ MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_PE01) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED3), MP_ROM_PTR(&pin_PE02) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED4), MP_ROM_PTR(&pin_PE03) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
||||
|
|
|
@ -40,12 +40,12 @@
|
|||
#include "stm32f4xx_hal.h"
|
||||
|
||||
//DAC is shared between both channels.
|
||||
//TODO: store as struct with channel info, automatically turn it off if unused
|
||||
//on both channels for power save?
|
||||
#if HAS_DAC
|
||||
DAC_HandleTypeDef handle;
|
||||
#endif
|
||||
|
||||
STATIC bool dac_on[2];
|
||||
|
||||
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
|
||||
const mcu_pin_obj_t *pin) {
|
||||
#if !(HAS_DAC)
|
||||
|
@ -53,8 +53,10 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
|
|||
#else
|
||||
if (pin == &pin_PA04) {
|
||||
self->channel = DAC_CHANNEL_1;
|
||||
self->dac_index = 0;
|
||||
} else if (pin == &pin_PA05) {
|
||||
self->channel = DAC_CHANNEL_2;
|
||||
self->dac_index = 1;
|
||||
} else {
|
||||
mp_raise_ValueError(translate("Invalid DAC pin supplied"));
|
||||
}
|
||||
|
@ -82,22 +84,27 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
|
|||
mp_raise_ValueError(translate("DAC Channel Init Error"));
|
||||
}
|
||||
|
||||
dac_on[self->dac_index] = true;
|
||||
self->pin = pin;
|
||||
self->deinited = false;
|
||||
claim_pin(pin);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
|
||||
return self->deinited;
|
||||
return !dac_on[self->dac_index];
|
||||
}
|
||||
|
||||
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
|
||||
#if HAS_DAC
|
||||
reset_pin_number(self->pin->port,self->pin->number);
|
||||
self->pin = mp_const_none;
|
||||
self->deinited = true;
|
||||
//TODO: if both are de-inited, should we turn off the DAC?
|
||||
dac_on[self->dac_index] = false;
|
||||
|
||||
//turn off the DAC if both channels are off
|
||||
if(dac_on[0] == false && dac_on[1] == false) {
|
||||
__HAL_RCC_DAC_CLK_DISABLE();
|
||||
HAL_DAC_DeInit(&handle);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ typedef struct {
|
|||
#endif
|
||||
const mcu_pin_obj_t * pin;
|
||||
uint8_t channel;
|
||||
bool deinited;
|
||||
uint8_t dac_index:1;
|
||||
} analogio_analogout_obj_t;
|
||||
|
||||
void analogout_reset(void);
|
||||
|
|
|
@ -56,8 +56,8 @@
|
|||
#define MICROPY_COMP_MODULE_CONST (1)
|
||||
#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
|
||||
#define MICROPY_DEBUG_PRINTERS (0)
|
||||
#define MICROPY_EMIT_INLINE_THUMB (0)
|
||||
#define MICROPY_EMIT_THUMB (0)
|
||||
#define MICROPY_EMIT_INLINE_THUMB (CIRCUITPY_ENABLE_MPY_NATIVE)
|
||||
#define MICROPY_EMIT_THUMB (CIRCUITPY_ENABLE_MPY_NATIVE)
|
||||
#define MICROPY_EMIT_X64 (0)
|
||||
#define MICROPY_ENABLE_DOC_STRING (0)
|
||||
#define MICROPY_ENABLE_FINALISER (1)
|
||||
|
|
|
@ -294,3 +294,10 @@ ifndef CIRCUITPY_BITBANG_APA102
|
|||
CIRCUITPY_BITBANG_APA102 = 0
|
||||
endif
|
||||
CFLAGS += -DCIRCUITPY_BITBANG_APA102=$(CIRCUITPY_BITBANG_APA102)
|
||||
|
||||
|
||||
# Enabled micropython.native decorator (experimental)
|
||||
ifndef CIRCUITPY_ENABLE_MPY_NATIVE
|
||||
CIRCUITPY_ENABLE_MPY_NATIVE = 0
|
||||
endif
|
||||
CFLAGS += -DCIRCUITPY_ENABLE_MPY_NATIVE=$(CIRCUITPY_ENABLE_MPY_NATIVE)
|
||||
|
|
|
@ -3207,7 +3207,7 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
|
|||
}
|
||||
if (pass > MP_PASS_SCOPE) {
|
||||
mp_int_t bytesize = MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0]);
|
||||
for (uint j = 1; j < n_args; j++) {
|
||||
for (int j = 1; j < n_args; j++) {
|
||||
if (!MP_PARSE_NODE_IS_SMALL_INT(pn_arg[j])) {
|
||||
compile_syntax_error(comp, nodes[i], translate("'data' requires integer arguments"));
|
||||
return;
|
||||
|
|
|
@ -58,6 +58,22 @@
|
|||
#define DEBUG_printf(...) (void)0
|
||||
#endif
|
||||
|
||||
#ifndef N_X64
|
||||
#define N_X64 (0)
|
||||
#endif
|
||||
#ifndef N_X86
|
||||
#define N_X86 (0)
|
||||
#endif
|
||||
#ifndef N_THUMB
|
||||
#define N_THUMB (0)
|
||||
#endif
|
||||
#ifndef N_ARM
|
||||
#define N_ARM (0)
|
||||
#endif
|
||||
#ifndef N_XTENSA
|
||||
#define N_XTENSA (0)
|
||||
#endif
|
||||
|
||||
// wrapper around everything in this file
|
||||
#if N_X64 || N_X86 || N_THUMB || N_ARM || N_XTENSA
|
||||
|
||||
|
@ -443,10 +459,12 @@ STATIC void emit_native_end_pass(emit_t *emit) {
|
|||
type_sig |= (emit->local_vtype[i] & 0xf) << (i * 4 + 4);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
mp_emit_glue_assign_native(emit->scope->raw_code,
|
||||
emit->do_viper_types ? MP_CODE_NATIVE_VIPER : MP_CODE_NATIVE_PY,
|
||||
f, f_len, (mp_uint_t*)((byte*)f + emit->const_table_offset),
|
||||
emit->scope->num_pos_args, emit->scope->scope_flags, type_sig);
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -546,7 +546,7 @@ STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
|
|||
STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_obj_fun_asm_t *self = self_in;
|
||||
|
||||
mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false);
|
||||
mp_arg_check_num_kw_array(n_args, n_kw, self->n_args, self->n_args, false);
|
||||
|
||||
void *fun = MICROPY_MAKE_POINTER_CALLABLE(self->fun_data);
|
||||
|
||||
|
|
|
@ -42,20 +42,7 @@
|
|||
void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t* self,
|
||||
busio_i2c_obj_t* i2c, uint16_t device_address, const mcu_pin_obj_t* reset) {
|
||||
|
||||
// Probe the bus to see if a device acknowledges the given address.
|
||||
if (!common_hal_busio_i2c_probe(i2c, device_address)) {
|
||||
mp_raise_ValueError_varg(translate("Unable to find I2C Display at %x"), device_address);
|
||||
}
|
||||
|
||||
// Write to the device and return 0 on success or an appropriate error code from mperrno.h
|
||||
self->bus = i2c;
|
||||
common_hal_busio_i2c_never_reset(self->bus);
|
||||
// Our object is statically allocated off the heap so make sure the bus object lives to the end
|
||||
// of the heap as well.
|
||||
gc_never_free(self->bus);
|
||||
|
||||
self->address = device_address;
|
||||
|
||||
// Reset the display before probing
|
||||
self->reset.base.type = &mp_type_NoneType;
|
||||
if (reset != NULL) {
|
||||
self->reset.base.type = &digitalio_digitalinout_type;
|
||||
|
@ -64,6 +51,20 @@ void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t* self,
|
|||
never_reset_pin_number(reset->number);
|
||||
common_hal_displayio_i2cdisplay_reset(self);
|
||||
}
|
||||
|
||||
// Probe the bus to see if a device acknowledges the given address.
|
||||
if (!common_hal_busio_i2c_probe(i2c, device_address)) {
|
||||
mp_raise_ValueError_varg(translate("Unable to find I2C Display at %x"), device_address);
|
||||
}
|
||||
|
||||
// Write to the device and return 0 on success or an appropriate error code from mperrno.h
|
||||
self->bus = i2c;
|
||||
common_hal_busio_i2c_never_reset(self->bus);
|
||||
// Our object is statically allocated off the heap so make sure the bus object lives to the end
|
||||
// of the heap as well.
|
||||
gc_never_free(self->bus);
|
||||
|
||||
self->address = device_address;
|
||||
}
|
||||
|
||||
void common_hal_displayio_i2cdisplay_deinit(displayio_i2cdisplay_obj_t* self) {
|
||||
|
|
Loading…
Reference in New Issue