@@ -29,7 +29,7 @@ static bool get_i2c_address(DeckInfo* info, uint8_t* address) {
2929 return true;
3030}
3131
32- bool deckctrl_gpio_set_direction (DeckInfo * info , DeckCtrlGPIOPin pin , bool output ) {
32+ bool deckctrl_gpio_set_direction (DeckInfo * info , DeckCtrlGPIOPin pin , uint32_t direction ) {
3333 if (pin >= DECKCTRL_GPIO_PIN_MAX ) {
3434 return false;
3535 }
@@ -49,13 +49,13 @@ bool deckctrl_gpio_set_direction(DeckInfo* info, DeckCtrlGPIOPin pin, bool outpu
4949 uint16_t direction_reg = buffer [0 ] | (buffer [1 ] << 8 );
5050
5151 // Set or clear the bit for this pin
52- if (output ) {
52+ if (direction != INPUT ) {
5353 direction_reg |= (1 << pin );
5454 } else {
5555 direction_reg &= ~(1 << pin );
5656 }
5757
58- DEBUG_PRINT ("Setting GPIO pin %d direction to %s (reg=0x%04x)\n" , pin , output ? "output" : "input" , direction_reg );
58+ DEBUG_PRINT ("Setting GPIO pin %d direction to %s (reg=0x%04x)\n" , pin , ( direction != INPUT ) ? "output" : "input" , direction_reg );
5959
6060 // Convert back to bytes and write
6161 buffer [0 ] = direction_reg & 0xFF ;
@@ -66,7 +66,7 @@ bool deckctrl_gpio_set_direction(DeckInfo* info, DeckCtrlGPIOPin pin, bool outpu
6666 return result ;
6767}
6868
69- bool deckctrl_gpio_write (DeckInfo * info , DeckCtrlGPIOPin pin , bool value ) {
69+ bool deckctrl_gpio_write (DeckInfo * info , DeckCtrlGPIOPin pin , uint32_t value ) {
7070 if (pin >= DECKCTRL_GPIO_PIN_MAX ) {
7171 return false;
7272 }
@@ -86,7 +86,7 @@ bool deckctrl_gpio_write(DeckInfo* info, DeckCtrlGPIOPin pin, bool value) {
8686 uint16_t value_reg = buffer [0 ] | (buffer [1 ] << 8 );
8787
8888 // Set or clear the bit for this pin
89- if (value ) {
89+ if (value != LOW ) {
9090 value_reg |= (1 << pin );
9191 } else {
9292 value_reg &= ~(1 << pin );
@@ -99,7 +99,7 @@ bool deckctrl_gpio_write(DeckInfo* info, DeckCtrlGPIOPin pin, bool value) {
9999 return i2cdevWriteReg16 (I2C1_DEV , i2c_address , DECKCTRL_GPIO_VALUE_REG , 2 , buffer );
100100}
101101
102- bool deckctrl_gpio_read (DeckInfo * info , DeckCtrlGPIOPin pin , bool * value ) {
102+ bool deckctrl_gpio_read (DeckInfo * info , DeckCtrlGPIOPin pin , uint32_t * value ) {
103103 if (pin >= DECKCTRL_GPIO_PIN_MAX || value == NULL ) {
104104 return false;
105105 }
@@ -119,7 +119,7 @@ bool deckctrl_gpio_read(DeckInfo* info, DeckCtrlGPIOPin pin, bool* value) {
119119 uint16_t value_reg = buffer [0 ] | (buffer [1 ] << 8 );
120120
121121 // Extract the bit for this pin
122- * value = (value_reg & (1 << pin )) != 0 ;
122+ * value = (( value_reg & (1 << pin )) != 0 )? HIGH : LOW ;
123123
124124 return true;
125125}
0 commit comments