Skip to content

Commit a0721fc

Browse files
committed
Merge remote-tracking branch 'adafruit/master' into ld-cleanup
2 parents 40434d6 + 12f64c7 commit a0721fc

7 files changed

Lines changed: 135 additions & 12 deletions

File tree

ports/stm32f4/common-hal/busio/I2C.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "common-hal/microcontroller/Pin.h"
3737

3838
STATIC bool reserved_i2c[3];
39+
STATIC bool never_reset[3];
3940

4041
void i2c_reset(void) {
4142
//Note: I2Cs are also forcibly reset in construct, due to silicon error
@@ -48,11 +49,24 @@ void i2c_reset(void) {
4849
__HAL_RCC_I2C2_CLK_DISABLE();
4950
#endif
5051
#ifdef I2C3
51-
reserved_i2c[3] = false;
52+
reserved_i2c[2] = false;
5253
__HAL_RCC_I2C3_CLK_DISABLE();
5354
#endif
5455
}
5556

57+
void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) {
58+
for (size_t i = 0 ; i < MP_ARRAY_SIZE(mcu_i2c_banks); i++) {
59+
if (self->handle.Instance == mcu_i2c_banks[i]) {
60+
never_reset[i] = true;
61+
62+
never_reset_pin_number(self->scl->pin->port, self->scl->pin->number);
63+
never_reset_pin_number(self->sda->pin->port, self->scl->pin->number);
64+
break;
65+
}
66+
}
67+
}
68+
69+
5670
void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
5771
const mcu_pin_obj_t* scl, const mcu_pin_obj_t* sda, uint32_t frequency, uint32_t timeout) {
5872

@@ -166,19 +180,22 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) {
166180
}
167181
#ifdef I2C1
168182
if(self->handle.Instance==I2C1) {
169-
reserved_i2c[0] = 0;
183+
never_reset[0] = false;
184+
reserved_i2c[0] = false;
170185
__HAL_RCC_I2C1_CLK_DISABLE();
171186
}
172187
#endif
173188
#ifdef I2C2
174189
if(self->handle.Instance==I2C2) {
175-
reserved_i2c[1] = 0;
190+
never_reset[1] = false;
191+
reserved_i2c[1] = false;
176192
__HAL_RCC_I2C2_CLK_DISABLE();
177193
}
178194
#endif
179195
#ifdef I2C3
180196
if(self->handle.Instance==I2C3) {
181-
reserved_i2c[3] = 0;
197+
never_reset[2] = false;
198+
reserved_i2c[2] = false;
182199
__HAL_RCC_I2C3_CLK_DISABLE();
183200
}
184201
#endif

ports/stm32f4/common-hal/busio/SPI.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
165165
self->baudrate = (get_busclock(SPIx)/16);
166166
self->prescaler = 16;
167167
self->polarity = 0;
168-
self->phase = 1;
168+
self->phase = 0;
169169
self->bits = 8;
170170

171171
claim_pin(sck);
@@ -191,7 +191,8 @@ bool common_hal_busio_spi_deinited(busio_spi_obj_t *self) {
191191

192192
void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
193193
spi_clock_disable(1<<(self->sck->spi_index - 1));
194-
reserved_spi[self->sck->spi_index - 1] = true;
194+
reserved_spi[self->sck->spi_index - 1] = false;
195+
never_reset_spi[self->sck->spi_index - 1] = false;
195196

196197
reset_pin_number(self->sck->pin->port,self->sck->pin->number);
197198
reset_pin_number(self->mosi->pin->port,self->mosi->pin->number);
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "shared-bindings/displayio/ParallelBus.h"
28+
29+
#include <stdint.h>
30+
31+
#include "common-hal/microcontroller/Pin.h"
32+
#include "py/runtime.h"
33+
#include "shared-bindings/digitalio/DigitalInOut.h"
34+
#include "shared-bindings/microcontroller/__init__.h"
35+
36+
#include "tick.h"
37+
38+
void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self,
39+
const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select,
40+
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) {
41+
42+
mp_raise_NotImplementedError(translate("ParallelBus not yet supported"));
43+
}
44+
45+
void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t* self) {
46+
47+
}
48+
49+
bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) {
50+
return false;
51+
}
52+
53+
bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) {
54+
return false;
55+
}
56+
57+
bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) {
58+
59+
return false;
60+
}
61+
62+
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length) {
63+
64+
}
65+
66+
void common_hal_displayio_parallelbus_end_transaction(mp_obj_t obj) {
67+
68+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H
28+
#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H
29+
30+
#include "common-hal/digitalio/DigitalInOut.h"
31+
32+
typedef struct {
33+
mp_obj_base_t base;
34+
} displayio_parallelbus_obj_t;
35+
36+
#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H

ports/stm32f4/mpconfigport.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ ifndef CIRCUITPY_NEOPIXEL_WRITE
6565
CIRCUITPY_NEOPIXEL_WRITE = 1
6666
endif
6767

68+
ifndef
69+
CIRCUITPY_DISPLAYIO = 1
70+
endif
6871

6972
#ifeq ($(MCU_SUB_VARIANT), stm32f412zx)
7073
#endif

shared-bindings/_bleio/Connection.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,12 @@ STATIC void ensure_connected(bleio_connection_obj_t *self) {
8080
//|
8181
//| .. method:: disconnect()
8282
//|
83-
//| Disconnects from the remote peripheral.
83+
//| Disconnects from the remote peripheral. Does nothing if already disconnected.
8484
//|
8585
STATIC mp_obj_t bleio_connection_disconnect(mp_obj_t self_in) {
8686
bleio_connection_obj_t *self = MP_OBJ_TO_PTR(self_in);
87-
ensure_connected(self);
88-
87+
// common_hal_bleio_connection_disconnect() does nothing if already disconnected.
8988
common_hal_bleio_connection_disconnect(self->connection);
90-
9189
return mp_const_none;
9290
}
9391
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_disconnect_obj, bleio_connection_disconnect);

shared-module/displayio/FourWire.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t* self,
4949
gc_never_free(self->bus);
5050

5151
self->frequency = baudrate;
52-
self->polarity = common_hal_busio_spi_get_polarity(spi);
53-
self->phase = common_hal_busio_spi_get_phase(spi);
52+
self->polarity = 0;
53+
self->phase = 0;
5454

5555
common_hal_digitalio_digitalinout_construct(&self->command, command);
5656
common_hal_digitalio_digitalinout_switch_to_output(&self->command, true, DRIVE_MODE_PUSH_PULL);

0 commit comments

Comments
 (0)