ExploreEmbedded / Explore-M3

Explore M3 For Arduino
https://www.exploreembedded.com/
13 stars 10 forks source link

digitalPinToPort #9

Open Xplorer001 opened 8 years ago

Xplorer001 commented 8 years ago

Macros to map arduino pins to their ports is required in various libraries like the nokia 5110 display. We can directly specify the port however, there are numerous libraries that are using this convention, so need to fix it in the core.

Xplorer001 commented 8 years ago

Review this commit https://github.com/ExploreEmbedded/Explore-M3/commit/92a2ecabb9c79fb1dafec8b75aaf8b71c706ef2f . Libraries also use portOutputRegister(); like portOutputRegister(digitalPinToPort(_mosi)). I think this is used to differentiate between input and output register. @SaheblalBagwan review this and add a dummy function, if required. The function data types also need to be checked.

Tested with the code below:

define LED 13

volatile uint32_t *ledPort; uint32_t ledPinMask;

void setup() { Serial.begin(9600); delay(2000); pinMode(LED, OUTPUT);

ledPort = digitalPinToPort(LED); ledPinMask = digitalPinToBitMask(LED); //Serial.println(ledPort); Serial.println(ledPinMask, BIN); } void loop() { ledPort |= ledPinMask ; // Make all the Port pins as high
delay(1000);
ledPort &= ~ledPinMask; // Make all the Port pins as low
delay(1000);
}