xwrust::xwds::soc

Trait Gpio

source
pub trait Gpio {
    // Required methods
    fn gpio_req(&self, port: GpioPort, pinmsk: XwSq) -> XwEr;
    fn gpio_rls(&self, port: GpioPort, pinmsk: XwSq) -> XwEr;
    fn gpio_cfg(&self, port: GpioPort, pinmsk: XwSq, cfg: *mut c_void) -> XwEr;
    fn gpio_set(&self, port: GpioPort, pinmsk: XwSq) -> XwEr;
    fn gpio_reset(&self, port: GpioPort, pinmsk: XwSq) -> XwEr;
    fn gpio_toggle(&self, port: GpioPort, pinmsk: XwSq) -> XwEr;
    fn gpio_output(&self, port: GpioPort, pinmsk: XwSq, out: XwSq) -> XwEr;
    fn gpio_input(&self, port: GpioPort, pinmsk: XwSq) -> (XwEr, XwSq);
}
Expand description

SOC的特性:GPIO

Required Methods§

source

fn gpio_req(&self, port: GpioPort, pinmsk: XwSq) -> XwEr

申请GPIO

§参数说明
  • port: GPIO端口,取值 GpioPort
  • pinmsk: GPIO引脚掩码,每一位代表一个引脚,可通过 pin!() 宏生成
§错误码
source

fn gpio_rls(&self, port: GpioPort, pinmsk: XwSq) -> XwEr

释放GPIO

§参数说明
  • port: GPIO端口,取值 GpioPort
  • pinmsk: GPIO引脚掩码,每一位代表一个引脚,可通过 pin!() 宏生成
§错误码
source

fn gpio_cfg(&self, port: GpioPort, pinmsk: XwSq, cfg: *mut c_void) -> XwEr

配置GPIO

§参数说明
  • port: GPIO端口,取值 GpioPort
  • pinmsk: GPIO引脚掩码,每一位代表一个引脚,可通过 pin!() 宏生成
  • cfg: 配置数据,配置结构体的定义与平台相关
§错误码
source

fn gpio_set(&self, port: GpioPort, pinmsk: XwSq) -> XwEr

将GPIO设置为高电平

§参数说明
  • port: GPIO端口,取值 GpioPort
  • pinmsk: GPIO引脚掩码,每一位代表一个引脚,可通过 pin!() 宏生成
§错误码
source

fn gpio_reset(&self, port: GpioPort, pinmsk: XwSq) -> XwEr

将GPIO设置为低电平

§参数说明
  • port: GPIO端口,取值 GpioPort
  • pinmsk: GPIO引脚掩码,每一位代表一个引脚,可通过 pin!() 宏生成
§错误码
source

fn gpio_toggle(&self, port: GpioPort, pinmsk: XwSq) -> XwEr

翻转GPIO的电平

§参数说明
  • port: GPIO端口,取值 GpioPort
  • pinmsk: GPIO引脚掩码,每一位代表一个引脚,可通过 pin!() 宏生成
§错误码
source

fn gpio_output(&self, port: GpioPort, pinmsk: XwSq, out: XwSq) -> XwEr

写GPIO

输出的值 = pinmsk & out

§参数说明
  • port: GPIO端口,取值 GpioPort
  • pinmsk: GPIO引脚掩码,每一位代表一个引脚,可通过 pin!() 宏生成
  • out: 输出值,可通过 pin!() 宏生成
§错误码
source

fn gpio_input(&self, port: GpioPort, pinmsk: XwSq) -> (XwEr, XwSq)

读取GPIO

读取的值 = pinmsk & GPIO的端口电平状态

§参数说明
  • port: GPIO端口,取值 GpioPort
  • pinmsk: GPIO引脚掩码,每一位代表一个引脚,可通过 pin!() 宏生成
§错误码

Implementors§

source§

impl Gpio for Soc