Program Listing for File gpio-wiced.cpp
↰ Return to documentation for file (src/framework/wiced-43xxx/pal/gpio-wiced.cpp)
#include "gpio-wiced.hpp"
#if (TLE5012_FRAMEWORK == TLE5012_FRMWK_WICED)
using namespace tle5012;
GPIOWiced::GPIOWiced(wiced_gpio_t pin, wiced_gpio_config_t config, VLogic_t logic)
: pin(pin), config(config), logic(logic)
{
}
GPIOWiced::GPIOWiced() : pin(WICED_GPIO_1), config(INPUT_HIGH_IMPEDANCE), logic(POSITIVE)
{
}
GPIOWiced::~GPIOWiced()
{
disable();
deinit();
}
inline GPIOWiced::Error_t GPIOWiced::init()
{
GPIOWiced::Error_t err = GPIOWiced::OK;
if (WICED_SUCCESS != wiced_gpio_init(pin, config))
err = GPIOWiced::INTF_ERROR;
return err;
}
inline GPIOWiced::Error_t GPIOWiced::deinit()
{
GPIOWiced::Error_t err = GPIOWiced::OK;
if (WICED_SUCCESS != wiced_gpio_deinit(pin))
err = GPIOWiced::INTF_ERROR;
return err;
}
inline GPIOWiced::VLevel_t GPIOWiced::read()
{
return (VLevel_t)wiced_gpio_input_get(pin);
}
inline GPIOWiced::Error_t GPIOWiced::write(VLevel_t level)
{
GPIOWiced::Error_t err = GPIOWiced::OK;
if (GPIO_LOW == level)
{
if (WICED_SUCCESS != wiced_gpio_output_low(pin))
err = GPIOWiced::INTF_ERROR;
}
else if (GPIO_HIGH == level)
{
if (WICED_SUCCESS != wiced_gpio_output_high(pin))
err = GPIOWiced::INTF_ERROR;
}
return err;
}
inline GPIOWiced::Error_t GPIOWiced::enable()
{
GPIOWiced::Error_t err = GPIOWiced::OK;
if (this->logic == POSITIVE)
{
if (WICED_SUCCESS != wiced_gpio_output_high(pin))
err = GPIOWiced::INTF_ERROR;
}
else if (this->logic == NEGATIVE)
{
if (WICED_SUCCESS != wiced_gpio_output_low(pin))
err = GPIOWiced::INTF_ERROR;
}
return err;
}
inline GPIOWiced::Error_t GPIOWiced::disable()
{
GPIOWiced::Error_t err = GPIOWiced::OK;
if (this->logic == POSITIVE)
{
if (WICED_SUCCESS != wiced_gpio_output_low(pin))
err = GPIOWiced::INTF_ERROR;
}
else if (this->logic == NEGATIVE)
{
if (WICED_SUCCESS != wiced_gpio_output_high(pin))
err = GPIOWiced::INTF_ERROR;
}
return err;
}
#endif