From aa7cf6f72f4e8a553f892629bb3338ab8c982d57 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 21 May 2014 20:14:27 +0100 Subject: stm: Remove long-obsolete stm/ port. --- stm/gpio.c | 94 -------------------------------------------------------------- 1 file changed, 94 deletions(-) delete mode 100644 stm/gpio.c (limited to 'stm/gpio.c') diff --git a/stm/gpio.c b/stm/gpio.c deleted file mode 100644 index 9366208931..0000000000 --- a/stm/gpio.c +++ /dev/null @@ -1,94 +0,0 @@ -// This is a woefully inadequate set of bindings for GPIO control, and -// needs to be replaced with something much better. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mpconfig.h" -#include "nlr.h" -#include "misc.h" -#include "qstr.h" -#include "misc.h" -#include "parse.h" -#include "obj.h" -#include "compile.h" -#include "runtime0.h" -#include "runtime.h" -#include "systick.h" -#include "gpio.h" -#include "pin.h" - -mp_obj_t pyb_gpio(uint n_args, mp_obj_t *args) { - //assert(1 <= n_args && n_args <= 2); - - const pin_obj_t *pin = pin_map_user_obj(args[0]); - GPIO_TypeDef *port = pin->gpio; - uint16_t pin_mask = pin->pin_mask; - - if (n_args == 1) { - // get pin - if ((port->IDR & pin_mask) != (uint32_t)Bit_RESET) { - return MP_OBJ_NEW_SMALL_INT(1); - } else { - return MP_OBJ_NEW_SMALL_INT(0); - } - } else { - // set pin - if (mp_obj_is_true(args[1])) { - // set pin high - port->BSRRL = pin_mask; - } else { - // set pin low - port->BSRRH = pin_mask; - } - return mp_const_none; - } -} - -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_gpio_obj, 1, 2, pyb_gpio); - -mp_obj_t pyb_gpio_input(mp_obj_t arg_pin, mp_obj_t arg_mode) { - const pin_obj_t *pin = pin_map_user_obj(arg_pin); - GPIO_TypeDef *port = pin->gpio; - uint16_t pin_mask = pin->pin_mask; - - GPIO_InitTypeDef GPIO_InitStructure; - GPIO_InitStructure.GPIO_Pin = pin_mask; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_PuPd = mp_obj_get_int(arg_mode); - GPIO_Init(port, &GPIO_InitStructure); - - return mp_const_none; -} - -MP_DEFINE_CONST_FUN_OBJ_2(pyb_gpio_input_obj, pyb_gpio_input); - -mp_obj_t pyb_gpio_output(mp_obj_t arg_pin, mp_obj_t arg_mode) { - const pin_obj_t *pin = pin_map_user_obj(arg_pin); - GPIO_TypeDef *port = pin->gpio; - uint16_t pin_mask = pin->pin_mask; - - GPIO_InitTypeDef GPIO_InitStructure; - GPIO_InitStructure.GPIO_Pin = pin_mask; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; - GPIO_InitStructure.GPIO_Speed = GPIO_Fast_Speed; - GPIO_InitStructure.GPIO_OType = mp_obj_get_int(arg_mode); - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(port, &GPIO_InitStructure); - - return mp_const_none; -} - -MP_DEFINE_CONST_FUN_OBJ_2(pyb_gpio_output_obj, pyb_gpio_output); -- cgit v1.2.3