mirror of
https://github.com/dougg3/mac-rom-simm-programmer.git
synced 2024-11-29 21:49:19 +00:00
Add support for GPIO pulldown control
Note that it does nothing on the AVR, which doesn't support it.
This commit is contained in:
parent
7e5639c792
commit
a4e6cf4809
@ -75,6 +75,18 @@ void GPIO_SetPullup(GPIOPin pin, bool pullup)
|
||||
GPIO_Set(pin, pullup);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets whether an input GPIO pin is pulled down
|
||||
* @param pin The pin
|
||||
* @param pulldown True if it should be pulled down, false if not
|
||||
*/
|
||||
void GPIO_SetPulldown(GPIOPin pin, bool pulldown)
|
||||
{
|
||||
(void)pin;
|
||||
(void)pulldown;
|
||||
// The AVR doesn't support pulldowns
|
||||
}
|
||||
|
||||
/** Turns a GPIO pin on (sets it high)
|
||||
*
|
||||
* @param pin The pin
|
||||
|
@ -43,6 +43,7 @@ typedef struct GPIOPin
|
||||
|
||||
void GPIO_SetDirection(GPIOPin pin, bool output);
|
||||
void GPIO_SetPullup(GPIOPin pin, bool pullup);
|
||||
void GPIO_SetPulldown(GPIOPin pin, bool pulldown);
|
||||
void GPIO_SetOn(GPIOPin pin);
|
||||
void GPIO_SetOff(GPIOPin pin);
|
||||
void GPIO_Toggle(GPIOPin pin);
|
||||
|
@ -64,13 +64,31 @@ void GPIO_SetPullup(GPIOPin pin, bool pullup)
|
||||
if (pullup)
|
||||
{
|
||||
uint32_t tmp = gpioRegs[pin.port]->PUSEL;
|
||||
tmp &= ~(2UL << 2*pin.pin);
|
||||
tmp |= (1UL << 2*pin.pin);
|
||||
gpioRegs[pin.port]->PUSEL = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
gpioRegs[pin.port]->PUSEL &= ~(3UL << 2*pin.pin);
|
||||
gpioRegs[pin.port]->PUSEL &= ~(1UL << 2*pin.pin);
|
||||
}
|
||||
}
|
||||
|
||||
/** Sets whether an input GPIO pin is pulled down
|
||||
*
|
||||
* @param pin The pin
|
||||
* @param pulldown True if it should be pulled down, false if not
|
||||
*/
|
||||
void GPIO_SetPulldown(GPIOPin pin, bool pulldown)
|
||||
{
|
||||
if (pulldown)
|
||||
{
|
||||
uint32_t tmp = gpioRegs[pin.port]->PUSEL;
|
||||
tmp |= (2UL << 2*pin.pin);
|
||||
gpioRegs[pin.port]->PUSEL = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
gpioRegs[pin.port]->PUSEL &= ~(2UL << 2*pin.pin);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user