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
241 stars 142 forks source link

IO expander MCP23x08 reports GPIO mode always as Output #412

Closed RREE closed 2 years ago

RREE commented 2 years ago

The function

overriding
function Mode (This : MCP23_GPIO_Point) return HAL.GPIO.GPIO_Mode is
   pragma Unreferenced (This);
begin
   return HAL.GPIO.Output;
end Mode;

seems to have been neglected when implemented (file mcp23x08.adb starting at line 303).

It could be written as

overriding
function Mode (This : MCP23_GPIO_Point) return HAL.GPIO.GPIO_Mode is
begin
   return (if This.Device.Is_Output (This.Pin) then HAL.GPIO.Output else HAL.GPIO.Input);
end Mode;

Untested

Fabien-Chouteau commented 2 years ago

Hi @RREE, indeed this could be improved. Don't hesitate to submit a patch :)