Skip to content

Commit

Permalink
[rp] fix gpio functional
Browse files Browse the repository at this point in the history
  • Loading branch information
andryblack committed Oct 23, 2024
1 parent 6a4aeaf commit cedb3aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
7 changes: 0 additions & 7 deletions src/modm/platform/gpio/rp/base.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ struct Gpio
PushPull
};

enum class
OutputSpeed
{
Slow = 0,
Fast = 1,
};

enum class
DriveStrength
{
Expand Down
11 changes: 8 additions & 3 deletions src/modm/platform/gpio/rp/set.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ public:
setOutput();
}

static void setOutput(OutputType type, OutputSpeed speed = OutputSpeed::Slow)
static void setOutput(OutputType type, SlewRate speed = SlewRate::Slow)
{
setOutput();
configure(type, speed);
}

static void configure(OutputType, OutputSpeed speed = OutputSpeed::Slow)
static void configure(OutputType, SlewRate speed = SlewRate::Slow)
{
(PortRegs<Gpios::port>::set_speed(Gpios::pin, speed), ...);
(PortRegs<Gpios::port>::set_slewrate(Gpios::pin, uint8_t(speed)), ...);
}

static void setInput()
Expand All @@ -96,6 +96,11 @@ public:
(PortRegs<Gpios::port>::set_slewrate(Gpios::pin, uint8_t(rate)), ...);
}

static void setDriveStrength(DriveStrength drive)
{
(PortRegs<Gpios::port>::set_drive(Gpios::pin, uint8_t(drive)), ...);
}

static void set()
{
%% for port, id in ports.items()
Expand Down
6 changes: 3 additions & 3 deletions src/modm/platform/gpio/rp/static.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public:

static void setFunction(uint8_t func) { Regs::set_funcsel(pin, func); }
static void setDriveStrength(DriveStrength strength)
{ Regs::set_drive(pin, strength); }
{ Regs::set_drive(pin, uint8_t(strength)); }

public:
static void setOutput() { PinSet::setOutput(); }
static void setOutput(bool value) { PinSet::setOutput(value); }
static void setOutput(OutputType type, OutputSpeed speed=OutputSpeed::Slow)
static void setOutput(OutputType type, SlewRate speed=SlewRate::Slow)
{ PinSet::setOutput(type, speed); }
static void configure(OutputType type, OutputSpeed speed=OutputSpeed::Slow)
static void configure(OutputType type, SlewRate speed=SlewRate::Slow)
{ PinSet::configure(type, speed); }

static void set() { PinSet::set(); }
Expand Down

0 comments on commit cedb3aa

Please sign in to comment.