Raspberry Pio Pico Drivers project
Loading...
Searching...
No Matches
Public Member Functions
rpp_driver::GpioBasic Class Reference

Basic GPIO driver class. More...

#include <gpiobasic.hpp>

Public Member Functions

 GpioBasic (SdkWrapper &sdk, uint pin)
 Initialize the given GPIO pin and setup the pins.
 
virtual ~GpioBasic ()
 deinit the GPIO by SdkWrapper::gpio_deinit();
 
virtual void SetDir (bool out)
 Set a single GPIO direction.
 
virtual void SetInputEnabled (bool enabled)
 Enable GPIO input.
 
virtual void Put (bool value)
 Drive a single GPIO high/low.
 
virtual bool Get ()
 Get state of a single GPIO.
 
virtual void Toggle ()
 Toggle the output level of this GPIO.
 
virtual void PullUp ()
 Set this GPIO to be pulled up. .
 
virtual void PullDown ()
 Set this GPIO to be pulled down.
 
virtual void DisablePulls ()
 Unset pulls on this GPIO.
 

Detailed Description

Basic GPIO driver class.

This class provides the handy way to control GPIO. To use this class, pass a GPIO pin# through the constructor. So, this class initialize and deinitialize that pin in the constructor and destructor, respectively.

Usage of mock

In the case of the testing of the user program which uses this class, a programmer can use the pre-defined mock class ::rpp_driver::MockGpioBasic. inside gpiobasic.hpp.

#include <gmock/gmock.h>
#include <gtest/gtest.h>
using ::testing::_;
class UserCodeTest : public ::testing::Test {
protected:
::rpp_driver::MockSdkWrapper mock_sdk_;
::rpp_driver::MockGpioBasic* mock_gpio_;
virtual void SetUp() {
EXPECT_CALL(mock_sdk_, gpio_init(_)).Times(1);
mock_gpio_ = new ::rpp_driver::MockGpioBasic(mock_sdk_);
}
virtual void TearDown() {
EXPECT_CALL(mock_sdk_, gpio_deinit(_)).Times(1);
delete (mock_gpio_);
}
};
TEST_F(UserCodeTest, foo) {
// Write Test code here.
}
basic GPIO controller.
Wrapper for RasPi Pico SDK API.

Constructor & Destructor Documentation

◆ GpioBasic()

rpp_driver::GpioBasic::GpioBasic ( SdkWrapper sdk,
uint  pin 
)

Initialize the given GPIO pin and setup the pins.

Parameters
sdkSdk wrapper to inject the dependency.
pinGPIO pin number.

Receive the GPIO pin. And then, init it by SdkWrapper::gpio_init().

Member Function Documentation

◆ DisablePulls()

virtual void rpp_driver::GpioBasic::DisablePulls ( )
virtual

Unset pulls on this GPIO.

◆ Get()

virtual bool rpp_driver::GpioBasic::Get ( )
virtual

Get state of a single GPIO.

Returns
Current state of this GPIO. 0 for low, non-zero for high

◆ Put()

virtual void rpp_driver::GpioBasic::Put ( bool  value)
virtual

Drive a single GPIO high/low.

Parameters
valueIf false clear the GPIO, otherwise set it.

◆ SetDir()

virtual void rpp_driver::GpioBasic::SetDir ( bool  out)
virtual

Set a single GPIO direction.

Parameters
outtrue for out, false for in.

◆ SetInputEnabled()

virtual void rpp_driver::GpioBasic::SetInputEnabled ( bool  enabled)
virtual

Enable GPIO input.

Parameters
enabledtrue to enable input on this GPIO.

◆ Toggle()

virtual void rpp_driver::GpioBasic::Toggle ( )
virtual

Toggle the output level of this GPIO.

If the current level is "H", set it to "L". If the current level is "L", set it to "H".


The documentation for this class was generated from the following file: