AdaCore / Ada_Drivers_Library

Ada source code and complete sample GNAT projects for selected bare-board platforms supported by GNAT.
BSD 3-Clause "New" or "Revised" License
240 stars 141 forks source link

Don't require pin to be an output before setting or clearing. #242

Closed pat-rogers closed 6 years ago

pat-rogers commented 6 years ago

Otherwise we cannot "pre-set" the pin state before setting the pin to be an output. The issue is that the pin comes up with a default 1/0 value and that default value is what is applied immediately when we set the mode to output. If we want the non-default pin (bit) value immediately on setting the mode it is too late if we have to set the mode first, because setting the mode to output applies whatever the current bit value is. If we cannot set the bit before the output mode, the initial applied value will always be the default value and that is sometimes undesirable. (Found when bit-banging an I2C device, where a zero pin output value actively drives the line low, claiming it, but 1 passively allows it to float high.)

pat-rogers commented 6 years ago

Appveyor just ran out of time.