21 #include "pedigree/kernel/Log.h" 23 Gpio Gpio::m_Instance;
25 void Gpio::clearpin(
int pin)
33 "GPIO::clearpin - no GPIO found for pin " <<
Dec << pin <<
Hex 39 gpio[0x24] = (1 << base);
42 void Gpio::drivepin(
int pin)
50 "GPIO::drivepin - no GPIO found for pin " <<
Dec << pin <<
Hex 58 gpio[0x25] = (1 << base);
61 bool Gpio::pinstate(
int pin)
69 "GPIO::pinstate - no GPIO found for pin " <<
Dec << pin <<
Hex 74 return (gpio[0x25] & (1 << base));
77 int Gpio::capturepin(
int pin)
85 "GPIO::capturepin - no GPIO found for pin " <<
Dec << pin <<
Hex 91 return (gpio[0xE] & (1 << base)) >> (base ? base - 1 : 0);
94 void Gpio::enableoutput(
int pin)
102 "GPIO::enableoutput - no GPIO found for pin " <<
Dec << pin <<
Hex 108 if (gpio[0xD] & (1 << base))
109 gpio[0xD] ^= (1 << base);
118 unsigned int rev = gpio[0];
120 "GPIO" <<
Dec << n <<
Hex <<
" at " << reinterpret_cast<uintptr_t>(gpio)
121 <<
": revision " <<
Dec << ((rev & 0xF0) >> 4) <<
"." 122 << (rev & 0xF) <<
Hex <<
".");
126 while (!(gpio[0x5] & 1))
139 volatile uint32_t *gpio = 0;
143 gpio =
reinterpret_cast<volatile uint32_t *
>(m_Gpio1.
virtualAddress());
145 else if ((pin >= 34) && (pin < 64))
148 gpio =
reinterpret_cast<volatile uint32_t *
>(m_Gpio2.
virtualAddress());
150 else if ((pin >= 64) && (pin < 96))
153 gpio =
reinterpret_cast<volatile uint32_t *
>(m_Gpio3.
virtualAddress());
155 else if ((pin >= 96) && (pin < 128))
158 gpio =
reinterpret_cast<volatile uint32_t *
>(m_Gpio4.
virtualAddress());
160 else if ((pin >= 128) && (pin < 160))
163 gpio =
reinterpret_cast<volatile uint32_t *
>(m_Gpio5.
virtualAddress());
165 else if ((pin >= 160) && (pin < 192))
168 gpio =
reinterpret_cast<volatile uint32_t *
>(m_Gpio6.
virtualAddress());
void initspecific(int n, volatile uint32_t *gpio)
Initialises a specific GPIO to a given set of defaults.
volatile uint32_t * getGpioForPin(int pin, int *bit)
void * virtualAddress() const