Commit 4b37e775 authored by Damien George's avatar Damien George
Browse files

extmod/machine_i2c: Redo mp_hal_pin macros to use open_drain and od_low.

mp_hal_pin_config_od is renamed mp_hal_pin_open_drain, and mp_hal_pin_low
is mp_hal_pin_od_low.
parent a3dc2c60
......@@ -216,7 +216,7 @@ void mp_hal_signal_dupterm_input(void) {
system_os_post(DUPTERM_TASK_ID, 0, 0);
}
void mp_hal_pin_config_od(mp_hal_pin_obj_t pin_id) {
void mp_hal_pin_open_drain(mp_hal_pin_obj_t pin_id) {
const pyb_pin_obj_t *pin = &pyb_pin_obj[pin_id];
if (pin->phys_port == 16) {
......
......@@ -70,8 +70,8 @@ void ets_event_poll(void);
#define mp_hal_get_pin_obj(o) mp_obj_get_pin(o)
void mp_hal_pin_input(mp_hal_pin_obj_t pin);
void mp_hal_pin_output(mp_hal_pin_obj_t pin);
void mp_hal_pin_config_od(mp_hal_pin_obj_t pin);
#define mp_hal_pin_low(p) do { \
void mp_hal_pin_open_drain(mp_hal_pin_obj_t pin);
#define mp_hal_pin_od_low(p) do { \
if ((p) == 16) { WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1) | 1); } \
else { gpio_output_set(0, 1 << (p), 1 << (p), 0); } \
} while (0)
......
......@@ -48,7 +48,7 @@ STATIC void mp_hal_i2c_delay(machine_i2c_obj_t *self) {
}
STATIC void mp_hal_i2c_scl_low(machine_i2c_obj_t *self) {
mp_hal_pin_low(self->scl);
mp_hal_pin_od_low(self->scl);
}
STATIC void mp_hal_i2c_scl_release(machine_i2c_obj_t *self) {
......@@ -56,7 +56,7 @@ STATIC void mp_hal_i2c_scl_release(machine_i2c_obj_t *self) {
}
STATIC void mp_hal_i2c_sda_low(machine_i2c_obj_t *self) {
mp_hal_pin_low(self->sda);
mp_hal_pin_od_low(self->sda);
}
STATIC void mp_hal_i2c_sda_release(machine_i2c_obj_t *self) {
......@@ -91,8 +91,8 @@ STATIC void mp_hal_i2c_init(machine_i2c_obj_t *self, uint32_t freq) {
if (self->us_delay == 0) {
self->us_delay = 1;
}
mp_hal_pin_config_od(self->scl);
mp_hal_pin_config_od(self->sda);
mp_hal_pin_open_drain(self->scl);
mp_hal_pin_open_drain(self->sda);
mp_hal_i2c_stop(self);
}
......
......@@ -45,7 +45,7 @@ void mp_hal_set_interrupt_char(int c); // -1 to disable
#include "stmhal/pin.h"
#define mp_hal_pin_obj_t pin_obj_t*
#define mp_hal_get_pin_obj(o) (pin_obj_t*)pin_find(o)
#define mp_hal_pin_config_od(p) mp_hal_gpio_config((p)->gpio, (p)->pin, 5, 0, 0)
#define mp_hal_pin_low(p) GPIO_clear_pin((p)->gpio, (p)->pin_mask)
#define mp_hal_pin_open_drain(p) mp_hal_gpio_config((p)->gpio, (p)->pin, 5, 0, 0)
#define mp_hal_pin_od_low(p) GPIO_clear_pin((p)->gpio, (p)->pin_mask)
#define mp_hal_pin_od_high(p) GPIO_set_pin((p)->gpio, (p)->pin_mask)
#define mp_hal_pin_read(p) GPIO_read_pin((p)->gpio, (p)->pin)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment