Skip to content

Commit fd8b3e5

Browse files
facchinmcalvinatintel
authored andcommitted
Add digitalPinTo* macros/functions
these functions ensure compatibility with lots of existing libraries
1 parent f3f2b0b commit fd8b3e5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

variants/intel_edu_x/variant.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,28 @@ extern "C"{
129129
#define ADC_RESOLUTION 12
130130
#define ADC_CLOCK_GATE (1 << 31)
131131

132+
#define digitalPinToBitMask(P) (1 << g_APinDescription[P].ulGPIOId)
133+
134+
//static uint8_t __unused_var_POR;
135+
#define portOutputRegister(port) (uint32_t*)port
136+
#define portModeRegister(port) (uint32_t*)port
137+
138+
139+
static inline uint32_t digitalPinToPort(uint32_t pin) {
140+
uint32_t reg = 0;
141+
PinDescription *p = &g_APinDescription[pin];
142+
143+
if (p->ulGPIOType == SS_GPIO)
144+
{
145+
reg = p->ulGPIOBase + SS_GPIO_SWPORTA_DR;
146+
}
147+
else if (p->ulGPIOType == SOC_GPIO)
148+
{
149+
reg = p->ulGPIOBase + SOC_GPIO_SWPORTA_DR;
150+
}
151+
return reg;
152+
}
153+
132154
#ifdef __cplusplus
133155
}
134156
#endif

0 commit comments

Comments
 (0)