Prusa MINI Firmware overview
Gpio Class Reference

#include <Gpio.h>

Collaboration diagram for Gpio:

Static Public Member Functions

static bool valid_pin (pin_type pin)
 
static void set (pin_type pin)
 
static void set (pin_type pin, uint16_t value)
 
static uint16_t get (pin_type pin)
 
static void clear (pin_type pin)
 
static void setMode (pin_type pin, uint8_t value)
 
static uint8_t getMode (pin_type pin)
 
static void setDir (pin_type pin, uint8_t value)
 
static uint8_t getDir (pin_type pin)
 
static void attachPeripheral (pin_type pin, Peripheral *per)
 
static void attachLogger (IOLogger *logger)
 

Static Public Attributes

static const pin_type pin_count = 255
 
static pin_data pin_map [pin_count+1]
 

Member Function Documentation

◆ valid_pin()

static bool Gpio::valid_pin ( pin_type  pin)
static
76  {
77  return pin >= 0 && pin <= pin_count;
78  }
Here is the caller graph for this function:

◆ set() [1/2]

static void Gpio::set ( pin_type  pin)
static
80  {
81  set(pin, 1);
82  }
Here is the caller graph for this function:

◆ set() [2/2]

static void Gpio::set ( pin_type  pin,
uint16_t  value 
)
static
84  {
85  if (!valid_pin(pin)) return;
86  GpioEvent::Type evt_type = value > 1 ? GpioEvent::SET_VALUE : value > pin_map[pin].value ? GpioEvent::RISE : value < pin_map[pin].value ? GpioEvent::FALL : GpioEvent::NOP;
87  pin_map[pin].value = value;
88  GpioEvent evt(Clock::nanos(), pin, evt_type);
89  if (pin_map[pin].cb != nullptr) {
90  pin_map[pin].cb->interrupt(evt);
91  }
92  if (Gpio::logger != nullptr) Gpio::logger->log(evt);
93  }
Here is the call graph for this function:

◆ get()

static uint16_t Gpio::get ( pin_type  pin)
static
95  {
96  if (!valid_pin(pin)) return 0;
97  return pin_map[pin].value;
98  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

static void Gpio::clear ( pin_type  pin)
static
100  {
101  set(pin, 0);
102  }
Here is the call graph for this function:

◆ setMode()

static void Gpio::setMode ( pin_type  pin,
uint8_t  value 
)
static
104  {
105  if (!valid_pin(pin)) return;
106  pin_map[pin].mode = value;
107  GpioEvent evt(Clock::nanos(), pin, GpioEvent::Type::SETM);
108  if (pin_map[pin].cb != nullptr) pin_map[pin].cb->interrupt(evt);
109  if (Gpio::logger != nullptr) Gpio::logger->log(evt);
110  }
Here is the call graph for this function:

◆ getMode()

static uint8_t Gpio::getMode ( pin_type  pin)
static
112  {
113  if (!valid_pin(pin)) return 0;
114  return pin_map[pin].mode;
115  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDir()

static void Gpio::setDir ( pin_type  pin,
uint8_t  value 
)
static
117  {
118  if (!valid_pin(pin)) return;
119  pin_map[pin].dir = value;
120  GpioEvent evt(Clock::nanos(), pin, GpioEvent::Type::SETD);
121  if (pin_map[pin].cb != nullptr) pin_map[pin].cb->interrupt(evt);
122  if (Gpio::logger != nullptr) Gpio::logger->log(evt);
123  }
Here is the call graph for this function:

◆ getDir()

static uint8_t Gpio::getDir ( pin_type  pin)
static
125  {
126  if (!valid_pin(pin)) return 0;
127  return pin_map[pin].dir;
128  }
Here is the call graph for this function:

◆ attachPeripheral()

static void Gpio::attachPeripheral ( pin_type  pin,
Peripheral per 
)
static
130  {
131  if (!valid_pin(pin)) return;
132  pin_map[pin].cb = per;
133  }
Here is the call graph for this function:

◆ attachLogger()

static void Gpio::attachLogger ( IOLogger logger)
static
135  {
136  Gpio::logger = logger;
137  }

Member Data Documentation

◆ pin_count

const pin_type Gpio::pin_count = 255
static

◆ pin_map

pin_data Gpio::pin_map[pin_count+1]
static
Gpio::valid_pin
static bool valid_pin(pin_type pin)
Definition: Gpio.h:76
Gpio::set
static void set(pin_type pin)
Definition: Gpio.h:80
GpioEvent::RISE
Definition: Gpio.h:34
GpioEvent::Type
Type
Definition: Gpio.h:31
pin_data::cb
Peripheral * cb
Definition: Gpio.h:67
pin_data::dir
uint8_t dir
Definition: Gpio.h:64
pin_data::mode
uint8_t mode
Definition: Gpio.h:65
GpioEvent::FALL
Definition: Gpio.h:33
Gpio::pin_count
static const pin_type pin_count
Definition: Gpio.h:73
GpioEvent::NOP
Definition: Gpio.h:32
Peripheral::interrupt
virtual void interrupt(GpioEvent ev)=0
IOLogger::log
virtual void log(GpioEvent ev)=0
GpioEvent::SET_VALUE
Definition: Gpio.h:35
Gpio::pin_map
static pin_data pin_map[pin_count+1]
Definition: Gpio.h:74
Clock::nanos
static uint64_t nanos()
Definition: Clock.h:47
GpioEvent
Definition: Gpio.h:30
pin_data::value
uint16_t value
Definition: Gpio.h:66