<commit_before>//! \file
//! \brief TM4C GPIO device.
#ifndef TM4C_GPIO_DEVICE_HPP_
#define TM4C_GPIO_DEVICE_HPP_

#include "aux/pin_cfg.hpp"

#include <gpio.h>

namespace ecl
{

//! Encapsulates pin usage.
//! \tparam Port GPIO port on STM32 device.
//! \tparam Pin  Pin within given port.
template<gpio_hw::port Port, gpio_hw::num Pin>
class gpio
{
public:
    //! Advertised platform port.
    static constexpr auto port = Port;

    //! Advertised platform pin.
    static constexpr auto pin = Pin;

    //! Sets output pin level to high.
    static void set();

    //! Sets output pin level to low.
    static void reset();

    //! Toggles pin level.
    static void toggle();

    //! Gets level on a pin.
    //! \return True if level is high, false if level is low.
    static bool get();
};

//------------------------------------------------------------------------------

template<gpio_hw::port Port, gpio_hw::num Pin>
void gpio<Port, Pin>::set()
{
    auto port = static_cast<std::underlying_type_t<gpio_hw::port>>(Port);
    auto pin  = static_cast<std::underlying_type_t<gpio_hw::num>>(Pin);

    GPIOPinWrite(port, pin, pin);
}

template<gpio_hw::port Port, gpio_hw::num Pin>
void gpio<Port, Pin>::reset()
{
    auto port = static_cast<std::underlying_type_t<gpio_hw::port>>(Port);
    auto pin  = static_cast<std::underlying_type_t<gpio_hw::num>>(Pin);

    GPIOPinWrite(port, pin, 0);
}

template<gpio_hw::port Port, gpio_hw::num Pin>
void gpio<Port, Pin>::toggle()
{
    auto port = static_cast<std::underlying_type_t<gpio_hw::port>>(Port);
    auto pin  = static_cast<std::underlying_type_t<gpio_hw::num>>(Pin);

    auto pin_val = GPIOPinRead(port, pin);
    pin_val ^= pin;
    GPIOPinWrite(port, pin_val, pin_val);
}

template<gpio_hw::port Port, gpio_hw::num Pin>
bool gpio<Port, Pin>::get()<commit_msg>Fixed mistype in the gpio::toggle for TM4C<commit_after>//! \file
//! \brief TM4C GPIO device.
#ifndef TM4C_GPIO_DEVICE_HPP_
#define TM4C_GPIO_DEVICE_HPP_

#include "aux/pin_cfg.hpp"

#include <gpio.h>

namespace ecl
{

//! Encapsulates pin usage.
//! \tparam Port GPIO port on STM32 device.
//! \tparam Pin  Pin within given port.
template<gpio_hw::port Port, gpio_hw::num Pin>
class gpio
{
public:
    //! Advertised platform port.
    static constexpr auto port = Port;

    //! Advertised platform pin.
    static constexpr auto pin = Pin;

    //! Sets output pin level to high.
    static void set();

    //! Sets output pin level to low.
    static void reset();

    //! Toggles pin level.
    static void toggle();

    //! Gets level on a pin.
    //! \return True if level is high, false if level is low.
    static bool get();
};

//------------------------------------------------------------------------------

template<gpio_hw::port Port, gpio_hw::num Pin>
void gpio<Port, Pin>::set()
{
    auto port = static_cast<std::underlying_type_t<gpio_hw::port>>(Port);
    auto pin  = static_cast<std::underlying_type_t<gpio_hw::num>>(Pin);

    GPIOPinWrite(port, pin, pin);
}

template<gpio_hw::port Port, gpio_hw::num Pin>
void gpio<Port, Pin>::reset()
{
    auto port = static_cast<std::underlying_type_t<gpio_hw::port>>(Port);
    auto pin  = static_cast<std::underlying_type_t<gpio_hw::num>>(Pin);

    GPIOPinWrite(port, pin, 0);
}

template<gpio_hw::port Port, gpio_hw::num Pin>
void gpio<Port, Pin>::toggle()
{
    auto port = static_cast<std::underlying_type_t<gpio_hw::port>>(Port);
    auto pin  = static_cast<std::underlying_type_t<gpio_hw::num>>(Pin);

    auto pin_val = GPIOPinRead(port, pin);
    pin_val ^= pin;
    GPIOPinWrite(port, pin, pin_val);
}

template<gpio_hw::port Port, gpio_hw::num Pin>
bool gpio<Port, Pin>::get()
{'fraction_non_alphanumeric': 0.18092909535452323, 'fraction_numerical': 0.0035316490084216245, 'mean_word_length': 3.256647398843931, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3824094', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1262, 'n_words': 323}