CuriousScientist0 / ADS1256

An Arduino-compatible library for the ADS1256 24-bit analog-to-digital converter.
MIT License
31 stars 11 forks source link

I changed the GPIO Functions in my copy to allow one PIN changed at a time #8

Open Karl-Heinz-L opened 7 months ago

Karl-Heinz-L commented 7 months ago

A.writeGPIO(2, 2, 1, 0); // pin 2 is set to 1 pin 3 is set to 0 the rest is unchanged.

void ADS1256::setGPIO(uint8_t dir0, uint8_t dir1, uint8_t dir2, uint8_t dir3) //Setting GPIO {
_GPIO = readRegister(IO_REG); //Read the most recent value of the register

//Default: 11100000 - DEC: 224 - Ref: p32 I/O section
//Sets D3-D0 as input or output
uint8_t GPIO_bit7, GPIO_bit6, GPIO_bit5, GPIO_bit4;

//Bit7: DIR3 if (dir3 != 2) { if(dir3 == 1) { GPIO_bit7 = 1; //D3 is input (default) } else { GPIO_bit7 = 0; //D3 is output }
bitWrite(_GPIO, 7, GPIO_bit7); //----------------------------------------------------- } if (dir2 != 2) { //Bit6: DIR2 if(dir2 == 1) { GPIO_bit6 = 1; //D2 is input (default) } else { GPIO_bit6 = 0; //D2 is output } bitWrite(_GPIO, 6, GPIO_bit6);

}
//-----------------------------------------------------
//Bit5: DIR1 
if (dir1 != 2) {
    if(dir1 == 1)
    {
        GPIO_bit5 = 1; //D1 is input (default) 
    }
    else
    {
        GPIO_bit5 = 0; //D1 is output
    }
    bitWrite(_GPIO, 5, GPIO_bit5);
}
//-----------------------------------------------------
//Bit4: DIR0
if (dir0 != 2) {
    if(dir0 == 1)
    {
        GPIO_bit4 = 1; //D0 is input
    }
    else
    {
        GPIO_bit4 = 0; //D0 is output (default)
    }
    bitWrite(_GPIO, 4, GPIO_bit4);
}
//-----------------------------------------------------
CuriousScientist0 commented 7 months ago

Where is the issue? I do not really understand what you are trying to say.