From 0edf96fba61c2458ff76aaf4dbbc74a21d2fe54c Mon Sep 17 00:00:00 2001 From: Glenn Ruben Bakke Date: Wed, 11 Jan 2017 17:16:32 +0100 Subject: [PATCH] nrf5/adc: Adding ADC machine module base files. Implementation missing. --- nrf5/adc.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ nrf5/adc.h | 34 +++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 nrf5/adc.c create mode 100644 nrf5/adc.h diff --git a/nrf5/adc.c b/nrf5/adc.c new file mode 100644 index 0000000000..aa1f27be6e --- /dev/null +++ b/nrf5/adc.c @@ -0,0 +1,60 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +#include "py/nlr.h" +#include "py/runtime.h" +#include "py/mphal.h" +#include "adc.h" +#include "hal_adc.h" + +#if MICROPY_PY_MACHINE_ADC + +typedef struct _machine_adc_obj_t { + mp_obj_base_t base; + ADC_HandleTypeDef *adc; +} machine_adc_obj_t; + +/******************************************************************************/ +/* MicroPython bindings for machine API */ + +STATIC mp_obj_t machine_adc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + return MP_OBJ_FROM_PTR(self); +} + +const mp_obj_type_t machine_adc_type = { + { &mp_type_type }, + .name = MP_QSTR_ADC, +#if 0 + .print = adc_print, + .make_new = machine_adc_make_new, + .locals_dict = (mp_obj_t)&machine_adc_locals_dict +#endif +}; + +#endif // MICROPY_PY_MACHINE_ADC diff --git a/nrf5/adc.h b/nrf5/adc.h new file mode 100644 index 0000000000..a9f68e73da --- /dev/null +++ b/nrf5/adc.h @@ -0,0 +1,34 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef ADC_H__ +#define ADC_H__ + +#include "hal_adc.h" + +extern const mp_obj_type_t machine_adc_type; + +#endif // ADC_H__