lib/RadioHead/MGOSCompat/MGOS.cpp
/**
 * @brief Set the direction of a GPIO pin.
 * @param pin the Pin whose direction is to be set.
 * @param mode The direction of the pin (OUTPUT or INPUT)
 **/
@brief Set the direction of a GPIO pin.
@param pin the Pin whose direction is to be set.
@param mode The direction of the pin (OUTPUT or INPUT)
@brief Set the direction of a GPIO pin . @param pin the Pin whose direction is to be set . @param mode The direction of the pin ( OUTPUT or INPUT )
void pinMode(uint8_t pin, WiringPinMode mode)
{
  if( SPI.getCSGpio() != pin ) {
      if (mode == OUTPUT)
      {
        mgos_gpio_set_mode(pin, MGOS_GPIO_MODE_OUTPUT);
      }
      else if (mode == OUTPUT_OPEN_DRAIN)
      {
          mgos_gpio_set_pull(pin, MGOS_GPIO_PULL_UP);
          mgos_gpio_set_mode(pin, MGOS_GPIO_MODE_OUTPUT);
      }
      else if (mode == INPUT || mode == INPUT_FLOATING )
      {
          mgos_gpio_set_mode(pin, MGOS_GPIO_MODE_INPUT);
      }
      else if (mode == INPUT_ANALOG)
      {
          mgos_adc_enable(pin);
      }
      else if (mode == INPUT_PULLUP)
      {
          mgos_gpio_set_pull(pin, MGOS_GPIO_PULL_UP);
          mgos_gpio_set_mode(pin, MGOS_GPIO_MODE_INPUT);
      }
      else if (mode == INPUT_PULLDOWN)
      {
          mgos_gpio_set_pull(pin, MGOS_GPIO_PULL_DOWN);
          mgos_gpio_set_mode(pin, MGOS_GPIO_MODE_INPUT);
      }
      else if (mode == PWM)
      {
          mgos_pwm_set(pin, pwmFreq, pwmDutyCycle);
      }
      else if (mode == PWM_OPEN_DRAIN) {
          mgos_pwm_set(pin, pwmFreq, pwmDutyCycle);
      }
  }
}
void pinMode ( uint8_t pin , WiringPinMode mode ) { if ( SPI . getCSGpio ( ) != pin ) { if ( mode == OUTPUT ) { mgos_gpio_set_mode ( pin , MGOS_GPIO_MODE_OUTPUT ) ; } else if ( mode == OUTPUT_OPEN_DRAIN ) { mgos_gpio_set_pull ( pin , MGOS_GPIO_PULL_UP ) ; mgos_gpio_set_mode ( pin , MGOS_GPIO_MODE_OUTPUT ) ; } else if ( mode == INPUT || mode == INPUT_FLOATING ) { mgos_gpio_set_mode ( pin , MGOS_GPIO_MODE_INPUT ) ; } else if ( mode == INPUT_ANALOG ) { mgos_adc_enable ( pin ) ; } else if ( mode == INPUT_PULLUP ) { mgos_gpio_set_pull ( pin , MGOS_GPIO_PULL_UP ) ; mgos_gpio_set_mode ( pin , MGOS_GPIO_MODE_INPUT ) ; } else if ( mode == INPUT_PULLDOWN ) { mgos_gpio_set_pull ( pin , MGOS_GPIO_PULL_DOWN ) ; mgos_gpio_set_mode ( pin , MGOS_GPIO_MODE_INPUT ) ; } else if ( mode == PWM ) { mgos_pwm_set ( pin , pwmFreq , pwmDutyCycle ) ; } else if ( mode == PWM_OPEN_DRAIN ) { mgos_pwm_set ( pin , pwmFreq , pwmDutyCycle ) ; } } }
@brief Set the direction of a GPIO pin.
@brief Set the direction of a GPIO pin .
//SPI CS GPIO controlled by MGOS lib call so don't allow it to be set here