Commit 1dddb566 authored by Martin Vítek's avatar Martin Vítek
Browse files

GPIO - PINxCTRL is not working

parent 2a84f0aa
......@@ -21,6 +21,14 @@ enum directions
OUTPUT
};
enum interrupt_levels
{
IRQ_LEVEL_OFF = 0x00,
IRQ_LEVEL_LOW = 0x01,
IRQ_LEVEL_MEDIUM = 0x02,
IRQ_LEVEL_HIGH = 0x03
};
class gpio
{
private:
......@@ -41,16 +49,32 @@ class gpio
else return;
}
[[deprecated("Not working")]]
void set_mode(modes mode)
{
*(&port.PIN0CTRL+pin_bm) &= (0x38);
*(&port.PIN0CTRL+pin_bm) |= mode;
uint8_t position;
for (position=0; position<8; position++)
{
if (pin_bm & (1<<position)) break;
}
*(&(port.PIN0CTRL)+position) &= (0x38);
*(&(port.PIN0CTRL)+position) |= mode;
}
[[deprecated("Not working")]]
void set_invert(bool state)
{
if (state) *(&port.PIN0CTRL+pin_bm) |= PORT_INVEN_bm;
else *(&port.PIN0CTRL+pin_bm) &= ~PORT_INVEN_bm;
uint8_t position;
for (position=0; position<8; position++)
{
if (pin_bm & (1<<position)) break;
}
if (state) *(&port.PIN0CTRL+position) |= PORT_INVEN_bm;
else *(&port.PIN0CTRL+position) &= ~PORT_INVEN_bm;
}
void on()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment