skullc-peripherals/Inc/peripherals_io.hpp

39 lines
578 B
C++

/*
* IO.h
*
* Created on: Feb 24, 2021
* Author: erki
*/
#ifndef PERIPHERALS_IO_HPP_
#define PERIPHERALS_IO_HPP_
#include <peripherals_config.hpp>
#include <cstdint>
#include <gpio.h>
namespace Peripherals
{
struct IO
{
GPIO_TypeDef* port;
std::uint16_t pin;
IO() = default;
IO(GPIO_TypeDef* port, const unsigned short pin);
void Set(const bool state);
void Toggle();
bool Read();
#ifdef PERIPHERALS_USE_DELAY_US
void SetDelayUs(const bool state, const std::uint32_t micros);
#endif
};
} /* namespace Peripherals */
#endif /* PERIPHERALS_IO_HPP_ */