Renamed getPin function to clearly differentiate it from getPIN
This commit is contained in:
parent
25bd873f94
commit
4f40aa70dc
14
io.hpp
14
io.hpp
@ -172,7 +172,7 @@ static constexpr auto getBus(const P pin)
|
|||||||
return static_cast<Bus>(port);
|
return static_cast<Bus>(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr auto getPin(const P pin)
|
static constexpr auto getPinBit(const P pin)
|
||||||
{
|
{
|
||||||
// Lower 4 bits of pin encode which pin bit it is
|
// Lower 4 bits of pin encode which pin bit it is
|
||||||
uint8_t pinBit = static_cast<uint8_t>(pin) & 0x0F;
|
uint8_t pinBit = static_cast<uint8_t>(pin) & 0x0F;
|
||||||
@ -242,7 +242,7 @@ class Pin {
|
|||||||
{
|
{
|
||||||
constexpr auto bus = detail::getBus(pin);
|
constexpr auto bus = detail::getBus(pin);
|
||||||
constexpr auto dirReg = detail::getDDR(bus);
|
constexpr auto dirReg = detail::getDDR(bus);
|
||||||
constexpr auto pinBit = detail::getPin(pin);
|
constexpr auto pinBit = detail::getPinBit(pin);
|
||||||
|
|
||||||
if (dir == Dir::IN)
|
if (dir == Dir::IN)
|
||||||
*dirReg &= ~(1 << pinBit);
|
*dirReg &= ~(1 << pinBit);
|
||||||
@ -254,7 +254,7 @@ class Pin {
|
|||||||
{
|
{
|
||||||
constexpr auto bus = detail::getBus(pin);
|
constexpr auto bus = detail::getBus(pin);
|
||||||
constexpr auto portReg = detail::getPORT(bus);
|
constexpr auto portReg = detail::getPORT(bus);
|
||||||
constexpr auto pinBit = detail::getPin(pin);
|
constexpr auto pinBit = detail::getPinBit(pin);
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
*portReg |= (1 << pinBit);
|
*portReg |= (1 << pinBit);
|
||||||
@ -266,7 +266,7 @@ class Pin {
|
|||||||
{
|
{
|
||||||
constexpr auto bus = detail::getBus(pin);
|
constexpr auto bus = detail::getBus(pin);
|
||||||
constexpr auto portReg = detail::getPORT(bus);
|
constexpr auto portReg = detail::getPORT(bus);
|
||||||
constexpr auto pinBit = detail::getPin(pin);
|
constexpr auto pinBit = detail::getPinBit(pin);
|
||||||
|
|
||||||
if (value)
|
if (value)
|
||||||
*portReg |= (1 << pinBit);
|
*portReg |= (1 << pinBit);
|
||||||
@ -279,13 +279,13 @@ class Pin {
|
|||||||
#ifdef HARDWARE_TOGGLE
|
#ifdef HARDWARE_TOGGLE
|
||||||
constexpr auto bus = detail::getBus(pin);
|
constexpr auto bus = detail::getBus(pin);
|
||||||
constexpr auto pinReg = detail::getPIN(bus);
|
constexpr auto pinReg = detail::getPIN(bus);
|
||||||
constexpr auto pinBit = detail::getPin(pin);
|
constexpr auto pinBit = detail::getPinBit(pin);
|
||||||
|
|
||||||
*pinReg |= (1 << pinBit);
|
*pinReg |= (1 << pinBit);
|
||||||
#else
|
#else
|
||||||
constexpr auto bus = detail::getBus(pin);
|
constexpr auto bus = detail::getBus(pin);
|
||||||
constexpr auto portReg = detail::getPORT(bus);
|
constexpr auto portReg = detail::getPORT(bus);
|
||||||
constexpr auto pinBit = detail::getPin(pin);
|
constexpr auto pinBit = detail::getPinBit(pin);
|
||||||
|
|
||||||
*portReg ^= (1 << pinBit);
|
*portReg ^= (1 << pinBit);
|
||||||
#endif
|
#endif
|
||||||
@ -295,7 +295,7 @@ class Pin {
|
|||||||
{
|
{
|
||||||
constexpr auto bus = detail::getBus(pin);
|
constexpr auto bus = detail::getBus(pin);
|
||||||
constexpr auto pinReg = detail::getPIN(bus);
|
constexpr auto pinReg = detail::getPIN(bus);
|
||||||
constexpr auto pinBit = detail::getPin(pin);
|
constexpr auto pinBit = detail::getPinBit(pin);
|
||||||
|
|
||||||
if (*pinReg >> pinBit & 1)
|
if (*pinReg >> pinBit & 1)
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user