Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cores/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,23 @@ void noInterrupts(void);

int digitalPinToInterrupt(pin_size_t pin);

// These defines can be overridden by variant.h if implemented
#define digitalPinToPort(x) (x)
#define digitalPinToBitMask(x) (x)
#define portOutputRegister(x) (x)
#define portInputRegister(x) (x)

const struct device *digitalPinToPortDevice(pin_size_t pinNumber);
int digitalPinToPinIndex(pin_size_t pinNumber);

#if defined(CONFIG_PWM) || defined(CONFIG_DAC)
void analogWriteResolution(int bits);
#endif

#if defined(__arm__)
#define F_CPU (SystemCoreClock)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split the F cpu change into its own commit.

#endif
Comment thread
soburi marked this conversation as resolved.

#include <variant.h>

#if !defined(LED_BUILTIN) && defined(ZARD_LED_BUILTIN)
Expand Down
12 changes: 12 additions & 0 deletions cores/arduino/zephyrCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ void yield(void) {
k_yield();
}

const struct device *digitalPinToPortDevice(pin_size_t pinNumber) {
RETURN_ON_INVALID_PIN(pinNumber, nullptr);

return arduino_pins[pinNumber].port;
}

int digitalPinToPinIndex(pin_size_t pinNumber) {
RETURN_ON_INVALID_PIN(pinNumber, -1);
Comment thread
soburi marked this conversation as resolved.

return arduino_pins[pinNumber].pin;
}

/*
* The ACTIVE_HIGH flag is set so that A low physical
* level on the pin will be interpreted as value 0.
Expand Down
Loading