I want to make functions that can get in and put out data for multiple pins at once and try to make it a use able library function.
pins[] = {2,3,4,5,6};
DataOut[] = digitalMultiRead(pins[]);
Example, DataOut[] result => HIGH,LOW,LOW,HIGH,LOW
This is goes in the wiring_digital.c in the core files.
I can't test it myself right now, but im almost certain it WON'T work, so if anyone can try it and respond back that would be great.
If it doesn't work, that fine. I just wanted to try to make a function without having to make it in my actual sketch.
int digitalMultiRead(uint8_t pin[])
{
int i = cnt = 0; //fixed
int Out[cnt]; //Edit, missed that
while(pin[i] != NULL)i++;
for( cnt = 0; cnt <=i; cnt++)
{
uint8_t timer[cnt] = digitalPinToTimer(pin[cnt]);
uint8_t bit[cnt] = digitalPinToBitMask(pin[cnt]);
uint8_t port[cnt] = digitalPinToPort(pin[cnt]);
if (port[cnt] == NOT_A_PIN) return LOW;
// If the pin that support PWM output, we need to turn it off
// before getting a digital reading.
if (timer[cnt] != NOT_ON_TIMER) turnOffPWM(timer[cnt]);
if (*portInputRegister(port[cnt]) & bit[cnt]) Out[cnt] = HIGH;
Out[cnt] = LOW;
}
return Out[];
}