maix.peripheral.gpio

maix.peripheral.gpio module

You can use maix.peripheral.gpio to access this module with MaixPy
This module is generated from MaixPy and MaixCDK

Module

No module

Enum

Mode

GPIO mode

item describe
values IN: input mode
OUT: output mode
OUT_OD: output open drain mode
MODE_MAX:

C++ defination code:

enum Mode
    {
        IN     = 0x01,     // input mode
        OUT    = 0x02,     // output mode
        OUT_OD = 0x03,     // output open drain mode
        MODE_MAX
    }

Pull

GPIO pull mode

item describe
values PULL_NONE: pull none mode
PULL_UP: pull up mode
PULL_DOWN: pull down mode
PULL_MAX:

C++ defination code:

enum Pull
    {
        PULL_NONE = 0x00,  // pull none mode
        PULL_UP   = 0x01,  // pull up mode
        PULL_DOWN = 0x02,  // pull down mode
        PULL_MAX
    }

Variable

Function

Class

GPIO

Peripheral gpio class

C++ defination code:

class GPIO

__init__

def __init__(self, pin: str, mode: Mode = ..., pull: Pull = ...) -> None

GPIO constructor

item description
type func
param pin: direction [in], gpio pin name, string type the same as board's pin name, e.g. "B14" or "GPIOB14", or number string like "10" if board no gpiochipe name.
mode: direction [in], gpio mode. gpio.Mode type, default is gpio.Mode.IN (input) mode.
pull: direction [in], gpio pull. gpio.Pull type, default is gpio.Pull.PULL_NONE (pull none) mode.
For input mode, this will set gpio default status(value), if set to gpio.Pull.PULL_NONE, gpio value will be floating.
For output mode, this will set gpio default status(value), if set to gpio.Pull.PULL_UP, gpio value will be 1, else 0.
throw err::Exception if open gpio device failed.
static False

C++ defination code:

GPIO(std::string pin, gpio::Mode mode = gpio::Mode::IN, gpio::Pull pull = gpio::Pull::PULL_NONE)

value

def value(self, value: int = -1) -> int

set and get gpio value

item description
type func
param value: direction [in], gpio value. int type.
0, means write gpio to low level
1, means write gpio to high level
-1, means read gpio value, not set
return int type, return gpio value, can be 0 or 1
static False

C++ defination code:

int value(int value = -1)

high

def high(self) -> None

set gpio high (value to 1)

item description
type func
static False

C++ defination code:

void high()

low

def low(self) -> None

set gpio low (value to 0)

item description
type func
static False

C++ defination code:

void low()

toggle

def toggle(self) -> None

gpio toggle

item description
type func
static False

C++ defination code:

void toggle()

get_mode

def get_mode(self) -> Mode

gpio get mode

item description
type func
static False

C++ defination code:

gpio::Mode get_mode()

get_pull

def get_pull(self) -> Pull

get gpio pull

item description
type func
return gpio::Pull type
static False

C++ defination code:

gpio::Pull get_pull()

reset

def reset(self, mode: Mode, pull: Pull) -> maix.err.Err

reset gpio

item description
type func
param mode: direction [in], gpio mode. gpio.Mode type
pull: direction [in], gpio pull. gpio.Pull type
For input mode, this will set gpio default status(value), if set to gpio.Pull.PULL_NONE, gpio value will be floating.
For output mode, this will set gpio default status(value), if set to gpio.Pull.PULL_UP, gpio value will be 1, else 0.
return err::Err type
static False

C++ defination code:

err::Err reset(gpio::Mode mode, gpio::Pull pull)