mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
043e8cc88e
- Rename all `arduino_pinmap.h` to `arduino_iomap.h` - An empty `arduino_pinmap.h` that just includes `arduino_iomap.h` is provided for backward compatibility - Move all info from `arduino_board.h` into the new file as trivial macros, so that they can also be used outside of sketches - The new name reflects the fact not just pin mappings, but also other I/O features such as PWMs are mapped - Drop all `arduino_board.h` - `arduino_board.h` and `arduino_iomap.h` now provide the exact same information, just in a different format - a generic `arduino_board.h` is provided instead that just uses the info in `arduinio_iomap.h` and provides them in the format the code in `sys/arduino` expects it - Add fine grained features to indicate for mappings - availability of mappings for analog pins, DAC pins, PWM pins, UART devices, SPI/I2C buses to the corresponding RIOT identification can now be expressed: - `arduino_pins`: `ARDUINO_PIN_0` etc. are available - `arduino_analog`: `ARDUINO_A0` etc. are available - `arduino_pwm`: `ARDUINO_PIN_13_PWM_DEV` etc. are available - `arduino_dac`: `ARDUINO_DAC0` etc. are available - `arduino_uart`: `ARDUINO_UART_D0D1` or similar are available - `arduino_spi`: `ARDUINO_SPI_ISP` or similar are available - `arduino_i2c`: `ARDUINO_I2C_UNO` or similar are available - mechanical/electrical compatibility with specific form factors can now be expressed as features: - `aruino_shield_nano`: Arduino NANO compatible headers - `aruino_shield_uno`: Arduino UNO compatible headers - `aruino_shield_mega`: Arduino MEGA compatible headers - `aruino_shield_isp`: ISP header is available This provides the groundwork to implement shield support as modules that can rely on the I/O mappings, rather than having to provide a configuration per board.
165 lines
3.7 KiB
C
165 lines
3.7 KiB
C
/*
|
|
* Copyright (C) 2023 Otto-von-Guericke-Universität Magdeburg
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
* directory for more details.
|
|
*/
|
|
|
|
/**
|
|
* @ingroup sys_arduino
|
|
* @{
|
|
*
|
|
* @file
|
|
* @brief Arduino analog pin map
|
|
*
|
|
* @note The contents of this file are mostly generated using the
|
|
* python snippets documented. Do not edit these parts by hand,
|
|
* but rather adjust the python snippets and regenerate.
|
|
*
|
|
* @author Marian Buschsieweke <marian.buschsieweke@ovgu.de>
|
|
*/
|
|
|
|
#ifndef ARDUINO_BOARD_ANALOG_H
|
|
#define ARDUINO_BOARD_ANALOG_H
|
|
|
|
#include "periph/adc.h"
|
|
#include "arduino_iomap.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifdef DOXYGEN
|
|
/**
|
|
* @brief Number of the last analog pin
|
|
*
|
|
* E.g. 5 if A5 is the analog pin with the highest number.
|
|
*/
|
|
#define ARDUINO_ANALOG_PIN_LAST /* board specific number */
|
|
#endif /* DOXYGEN */
|
|
|
|
/* A board may not have any analog pins. But if it has any, it MUST define
|
|
* ARDUINO_ANALOG_PIN_LAST. */
|
|
#if !defined(ARDUINO_ANALOG_PIN_LAST) && (defined(ARDUINO_A0) || defined(ARDUINO_A1))
|
|
# error "ARDUINO_PIN_LAST undefined despite analog pins available"
|
|
#endif
|
|
|
|
/* A board not having A0 and A1, but having e.g. A3 would also trigger this.
|
|
* Extend as needed when porting new boards. */
|
|
#if defined(ARDUINO_ANALOG_PIN_LAST) && !defined(ARDUINO_A0) && !defined(ARDUINO_A1)
|
|
# error "ARDUINO_PIN_LAST defined but no analog pins available"
|
|
#endif
|
|
|
|
#if defined(ARDUINO_ANALOG_PIN_LAST) || defined(DOXYGEN)
|
|
/**
|
|
* @brief Look-up table for the Arduino's analog pins
|
|
*
|
|
* Generate using
|
|
*
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.py}
|
|
* format = """#ifdef ARDUINO_A{0:}
|
|
* ARDUINO_A{0:},
|
|
* #elif ARDUINO_ANALOG_PIN_LAST > {0:}
|
|
* ADC_UNDEF,
|
|
* #endif"""
|
|
* for i in range(16):
|
|
* print(format.format(i))
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
*
|
|
* The Arduino MEGA 2560 has A0 to A15, so 16 Analog inputs is the largest
|
|
* as of now.
|
|
*/
|
|
static const adc_t arduino_analog_map[] = {
|
|
#ifndef DOXYGEN
|
|
#ifdef ARDUINO_A0
|
|
ARDUINO_A0,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 0
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A1
|
|
ARDUINO_A1,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 1
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A2
|
|
ARDUINO_A2,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 2
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A3
|
|
ARDUINO_A3,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 3
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A4
|
|
ARDUINO_A4,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 4
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A5
|
|
ARDUINO_A5,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 5
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A6
|
|
ARDUINO_A6,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 6
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A7
|
|
ARDUINO_A7,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 7
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A8
|
|
ARDUINO_A8,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 8
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A9
|
|
ARDUINO_A9,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 9
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A10
|
|
ARDUINO_A10,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 10
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A11
|
|
ARDUINO_A11,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 11
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A12
|
|
ARDUINO_A12,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 12
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A13
|
|
ARDUINO_A13,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 13
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A14
|
|
ARDUINO_A14,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 14
|
|
ADC_UNDEF,
|
|
#endif
|
|
#ifdef ARDUINO_A15
|
|
ARDUINO_A15,
|
|
#elif ARDUINO_ANALOG_PIN_LAST > 15
|
|
ADC_UNDEF,
|
|
#endif
|
|
#endif /* DOXYGEN */
|
|
};
|
|
#endif /* defined(ARDUINO_ANALOG_PIN_LAST) */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* ARDUINO_BOARD_ANALOG_H */
|
|
/** @} */
|