File wiring_custom.h
File List > arduino > src > wiring > wiring_custom.h
Go to the documentation of this file.
/* Copyright (c) Kuba Szczodrzyński 2022-06-06. */
#pragma once
#include <Arduino.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PIN_NONE (1 << 0)
#define PIN_GPIO (1 << 1)
#define PIN_IRQ (1 << 2)
#define PIN_PWM (1 << 3)
#define PIN_ADC (1 << 4)
#define PIN_DAC (1 << 5)
#define PIN_I2C (1 << 6)
#define PIN_I2S (1 << 7)
#define PIN_JTAG (1 << 8)
#define PIN_SPI (1 << 9)
#define PIN_SWD (1 << 10)
#define PIN_UART (1 << 11)
#define PIN_MODE_ALL 0xFFFFFFFF
typedef struct PinData_s PinData;
typedef struct {
uint32_t gpio;
uint32_t supported;
uint32_t enabled;
PinData *data;
} PinInfo;
extern PinInfo lt_arduino_pin_info_list[PINS_COUNT];
extern PinInfo *lt_arduino_pin_gpio_map[PINS_GPIO_MAX + 1];
// Custom Wiring methods
bool startMainTask(void);
void mainTask(const void *arg); // implemented in main.cpp
void runPeriodicTasks(); // implemented in wiring_custom.c
void pinModeRemove(pin_size_t pinNumber, uint32_t mask);
PinInfo *pinInfo(pin_size_t pinNumber);
PinInfo *pinByIndex(uint32_t index);
PinInfo *pinByGpio(uint32_t gpio);
uint32_t pinIndex(PinInfo *pin);
bool pinSupported(PinInfo *pin, uint32_t mask);
bool pinEnabled(PinInfo *pin, uint32_t mask);
void pinRemoveMode(PinInfo *pin, uint32_t mask);
inline void pinModeNone(pin_size_t pinNumber) {
pinModeRemove(pinNumber, PIN_MODE_ALL);
}
int analogRead(pin_size_t pinNumber);
void analogReadResolution(int res);
void analogWriteResolution(int res);
void analogWriteFrequency(int hz);
void analogWritePeriod(int us);
extern int _analogReadResolution;
extern int _analogWriteResolution;
extern int _analogWritePeriod;
uint16_t analogReadVoltage(pin_size_t pinNumber);
uint16_t analogReadMaxVoltage(pin_size_t pinNumber);
#ifdef __cplusplus
} // extern "C"
#endif