mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Add functions for direct IO register access
This commit is contained in:
parent
fba488ac6d
commit
811031cbd6
@ -137,10 +137,12 @@ void loop(void);
|
|||||||
// Get the bit location within the hardware port of the given virtual pin.
|
// Get the bit location within the hardware port of the given virtual pin.
|
||||||
// This comes from the pins_*.c file for the active board configuration.
|
// This comes from the pins_*.c file for the active board configuration.
|
||||||
|
|
||||||
|
uint32_t digitalPinToPort(uint32_t pin);
|
||||||
|
uint32_t digitalPinToBitMask(uint32_t pin);
|
||||||
#define analogInPinToBit(P) (P)
|
#define analogInPinToBit(P) (P)
|
||||||
|
volatile uint32_t* portOutputRegister(uint32_t port);
|
||||||
// On the ATmega1280, the addresses of some of the port registers are
|
volatile uint32_t* portInputRegister(uint32_t port);
|
||||||
// greater than 255, so we can't store them in uint8_t's.
|
volatile uint32_t* portModeRegister(uint32_t port);
|
||||||
|
|
||||||
|
|
||||||
#define NOT_A_PIN 0
|
#define NOT_A_PIN 0
|
||||||
|
@ -67,6 +67,32 @@ static const uint32_t g_pin_funcs[PINCOUNT] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t digitalPinToPort(uint32_t pin)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t digitalPinToBitMask(uint32_t pin)
|
||||||
|
{
|
||||||
|
return 1 << pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
volatile uint32_t* portOutputRegister(uint32_t port)
|
||||||
|
{
|
||||||
|
return (volatile uint32_t*) (PERIPHS_GPIO_BASEADDR + GPIO_OUT_ADDRESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
volatile uint32_t* portInputRegister(uint32_t port)
|
||||||
|
{
|
||||||
|
return (volatile uint32_t*) (PERIPHS_GPIO_BASEADDR + GPIO_IN_ADDRESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
volatile uint32_t* portModeRegister(uint32_t port)
|
||||||
|
{
|
||||||
|
return (volatile uint32_t*) (PERIPHS_GPIO_BASEADDR + GPIO_ENABLE_ADDRESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
enum PinFunction { GPIO, PWM };
|
enum PinFunction { GPIO, PWM };
|
||||||
static uint32_t g_gpio_function[PINCOUNT] = {
|
static uint32_t g_gpio_function[PINCOUNT] = {
|
||||||
GPIO
|
GPIO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user