-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gpio] Refactor STM32 GPIO for fewer files
- Loading branch information
Showing
16 changed files
with
422 additions
and
666 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2017, 2021, Niklas Hauser | ||
* | ||
* This file is part of the modm project. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
// ---------------------------------------------------------------------------- | ||
|
||
#pragma once | ||
|
||
#include "base.hpp" | ||
#include "unused.hpp" | ||
#include <type_traits> | ||
|
||
namespace modm::platform | ||
{ | ||
|
||
/// @cond | ||
namespace detail | ||
{ | ||
|
||
template< Peripheral peripheral, Gpio::Signal signal, template<Peripheral _> class... Signals > | ||
struct GpioGetSignal; | ||
template< Peripheral peripheral, Gpio::Signal signal, template<Peripheral _> class SignalT, template<Peripheral _> class... Signals > | ||
struct GpioGetSignal<peripheral, signal, SignalT, Signals...> | ||
{ | ||
using Gpio = std::conditional_t< | ||
(SignalT<peripheral>::Signal == signal), | ||
typename SignalT<peripheral>::Gpio, | ||
typename GpioGetSignal<peripheral, signal, Signals...>::Gpio | ||
>; | ||
}; | ||
template< Peripheral peripheral, Gpio::Signal signal > | ||
struct GpioGetSignal<peripheral, signal> | ||
{ | ||
using Gpio = GpioUnused; | ||
}; | ||
|
||
} // namespace detail | ||
|
||
template< Peripheral peripheral, template<Peripheral _> class... Signals > | ||
struct GpioConnector | ||
{ | ||
template< class GpioQuery > | ||
static constexpr bool Contains = ( | ||
std::is_same_v<typename Signals<peripheral>::Gpio, typename GpioQuery::Type> or ...); | ||
|
||
template< class GpioQuery > | ||
static constexpr bool IsValid = not std::is_same_v<typename GpioQuery::Type, GpioUnused>; | ||
|
||
template< Gpio::Signal signal > | ||
using GetSignal = typename detail::GpioGetSignal<peripheral, signal, Signals...>::Gpio; | ||
|
||
inline static void | ||
connect() {} | ||
|
||
inline static void | ||
disconnect() | ||
{ | ||
(Signals<peripheral>::Gpio::disconnect(), ...); | ||
} | ||
}; | ||
/// @endcond | ||
|
||
} // namespace modm::platform | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.