2020-04-17 19:23:28 -04:00
|
|
|
/*
|
|
|
|
* This file is part of the Micro Python project, http://micropython.org/
|
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2020 Scott Shawcroft 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
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2021-09-18 08:48:18 -04:00
|
|
|
// DO NOT include this file directly.
|
|
|
|
// Use shared-bindings/microcontroller/Pin.h instead.
|
|
|
|
// This ensures that all necessary includes are already included.
|
2020-04-17 19:23:28 -04:00
|
|
|
|
2021-09-18 08:30:18 -04:00
|
|
|
#ifndef MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_PINS_H
|
|
|
|
#define MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_PINS_H
|
2020-04-17 19:23:28 -04:00
|
|
|
|
2021-09-18 08:48:18 -04:00
|
|
|
#include "py/obj.h"
|
2020-09-30 16:51:19 -04:00
|
|
|
|
2021-06-24 11:41:12 -04:00
|
|
|
#include "components/hal/include/hal/gpio_types.h"
|
|
|
|
#include "components/hal/include/hal/adc_types.h"
|
|
|
|
#include "components/hal/include/hal/touch_sensor_types.h"
|
2020-04-17 19:23:28 -04:00
|
|
|
|
|
|
|
typedef struct {
|
2021-09-18 08:48:18 -04:00
|
|
|
mp_obj_base_t base;
|
2020-05-19 20:46:29 -04:00
|
|
|
gpio_num_t number;
|
2021-03-15 09:57:36 -04:00
|
|
|
uint8_t adc_index : 2;
|
|
|
|
uint8_t adc_channel : 6;
|
2020-12-30 11:41:22 -05:00
|
|
|
touch_pad_t touch_channel;
|
2020-04-17 19:23:28 -04:00
|
|
|
} mcu_pin_obj_t;
|
|
|
|
|
2021-09-18 08:48:18 -04:00
|
|
|
extern const mp_obj_type_t mcu_pin_type;
|
2020-04-17 19:23:28 -04:00
|
|
|
|
2021-05-13 12:12:23 -04:00
|
|
|
#define NO_PIN (GPIO_NUM_NC)
|
|
|
|
|
2023-09-26 14:53:01 -04:00
|
|
|
#define NO_ADC SOC_ADC_PERIPH_NUM
|
2023-01-06 01:45:06 -05:00
|
|
|
#define NO_ADC_CHANNEL SOC_ADC_MAX_CHANNEL_NUM
|
2021-09-18 08:48:18 -04:00
|
|
|
|
|
|
|
#define NO_TOUCH_CHANNEL TOUCH_PAD_MAX
|
|
|
|
|
2023-08-28 18:43:45 -04:00
|
|
|
// This macro is used to simplify pin definition in peripherals/<chip>/pins.c
|
2021-09-18 08:48:18 -04:00
|
|
|
#define PIN(p_number, p_adc_index, p_adc_channel, p_touch_channel) \
|
|
|
|
{ \
|
|
|
|
{ &mcu_pin_type }, \
|
|
|
|
.number = p_number, \
|
|
|
|
.adc_index = p_adc_index, \
|
|
|
|
.adc_channel = p_adc_channel, \
|
|
|
|
.touch_channel = p_touch_channel, \
|
|
|
|
}
|
|
|
|
|
|
|
|
// Choose based on chip
|
2022-06-26 17:45:35 -04:00
|
|
|
#if defined(CONFIG_IDF_TARGET_ESP32)
|
|
|
|
#include "esp32/pins.h"
|
|
|
|
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
|
2021-09-25 14:30:00 -04:00
|
|
|
#include "esp32c3/pins.h"
|
2023-09-19 19:27:00 -04:00
|
|
|
#elif defined(CONFIG_IDF_TARGET_ESP32C6)
|
|
|
|
#include "esp32c6/pins.h"
|
|
|
|
#elif defined(CONFIG_IDF_TARGET_ESP32H2)
|
|
|
|
#include "esp32h2/pins.h"
|
2021-11-23 13:30:00 -05:00
|
|
|
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
|
2021-09-18 08:48:18 -04:00
|
|
|
#include "esp32s2/pins.h"
|
2021-11-23 13:30:00 -05:00
|
|
|
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
|
|
|
|
#include "esp32s3/pins.h"
|
2021-09-18 08:48:18 -04:00
|
|
|
#endif
|
|
|
|
|
2021-09-18 08:30:18 -04:00
|
|
|
#endif // MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_PINS_H
|