Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<unsigned int P, unsigned char N, bool = N >= 8>
- struct GpioMode
- {
- inline static void mode(Mode::Mode_ m)
- {
- reinterpret_cast<GPIO_TypeDef*>(P)->CRH &= ~(0xf<<((N-8)*4));
- reinterpret_cast<GPIO_TypeDef*>(P)->CRH |= m<<((N-8)*4);
- }
- };
- template<unsigned int P, unsigned char N>
- struct GpioMode<P, N, false>
- {
- inline static void mode(Mode::Mode_ m)
- {
- reinterpret_cast<GPIO_TypeDef*>(P)->CRL &= ~(0xf<<(N*4));
- reinterpret_cast<GPIO_TypeDef*>(P)->CRL |= m<<(N*4);
- }
- };
- template<unsigned int P, unsigned char N>
- class Gpio
- {
- public:
- static void mode(Mode::Mode_ m)
- {
- GpioMode<P, N>::mode(m);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement