Compare commits
2 Commits
stk500v2-l
...
a5f8e8e3d7
| Author | SHA1 | Date | |
|---|---|---|---|
| a5f8e8e3d7 | |||
| 119de32445 |
16
hardware.hpp
16
hardware.hpp
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "../clock.hpp"
|
#include "../clock.hpp"
|
||||||
|
|
||||||
#include "../type/type.hpp"
|
#include "../util/type.hpp"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -67,10 +67,12 @@ class Hardware {
|
|||||||
constexpr uint8_t ControlRegB = DataBitsValues.regBVal | EnableRx | EnableTx | InterruptVal;
|
constexpr uint8_t ControlRegB = DataBitsValues.regBVal | EnableRx | EnableTx | InterruptVal;
|
||||||
constexpr uint8_t ControlRegC = DataBitsValues.regCVal | ParityVal | StopBitsVal | ModeVal;
|
constexpr uint8_t ControlRegC = DataBitsValues.regCVal | ParityVal | StopBitsVal | ModeVal;
|
||||||
|
|
||||||
|
auto ctrlStatRegA = getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>();
|
||||||
|
|
||||||
if constexpr (UseDoubleSpeed)
|
if constexpr (UseDoubleSpeed)
|
||||||
*getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>() |= (1 << CtrlFlagsA::SPEED_2X);
|
*ctrlStatRegA = *ctrlStatRegA | (1 << CtrlFlagsA::SPEED_2X);
|
||||||
else
|
else
|
||||||
*getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>() &= ~(1 << CtrlFlagsA::SPEED_2X);
|
*ctrlStatRegA = *ctrlStatRegA & ~(1 << CtrlFlagsA::SPEED_2X);
|
||||||
|
|
||||||
*getRegPtr<Registers::CTRL_STAT_REG_B_ADDR>() = ControlRegB;
|
*getRegPtr<Registers::CTRL_STAT_REG_B_ADDR>() = ControlRegB;
|
||||||
*getRegPtr<Registers::CTRL_STAT_REG_C_ADDR>() = ControlRegC;
|
*getRegPtr<Registers::CTRL_STAT_REG_C_ADDR>() = ControlRegC;
|
||||||
@@ -130,12 +132,14 @@ class Hardware {
|
|||||||
|
|
||||||
static void enableDataRegEmptyInt() FORCE_INLINE
|
static void enableDataRegEmptyInt() FORCE_INLINE
|
||||||
{
|
{
|
||||||
*getRegPtr<Registers::CTRL_STAT_REG_B_ADDR>() |= (1 << CtrlFlagsB::DATA_REG_EMPTY_INT_ENABLE);
|
auto ctrlStatRegB = getRegPtr<Registers::CTRL_STAT_REG_B_ADDR>();
|
||||||
|
*ctrlStatRegB = *ctrlStatRegB | (1 << CtrlFlagsB::DATA_REG_EMPTY_INT_ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void disableDataRegEmptyInt() FORCE_INLINE
|
static void disableDataRegEmptyInt() FORCE_INLINE
|
||||||
{
|
{
|
||||||
*getRegPtr<Registers::CTRL_STAT_REG_B_ADDR>() &= ~(1 << CtrlFlagsB::DATA_REG_EMPTY_INT_ENABLE);
|
auto ctrlStatRegB = getRegPtr<Registers::CTRL_STAT_REG_B_ADDR>();
|
||||||
|
*ctrlStatRegB = *ctrlStatRegB & ~(1 << CtrlFlagsB::DATA_REG_EMPTY_INT_ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -294,7 +298,7 @@ class BlockingHardware {
|
|||||||
|
|
||||||
static bool peek(data_t &) FORCE_INLINE
|
static bool peek(data_t &) FORCE_INLINE
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<data_t>, "Peek with data is not supported in blocking mode");
|
static_assert(util::always_false_v<data_t>, "Peek with data is not supported in blocking mode");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
|
||||||
#include "../io/io.hpp"
|
#include "../io/io.hpp"
|
||||||
#include "../type/type.hpp"
|
#include "../util/type.hpp"
|
||||||
|
|
||||||
namespace uart {
|
namespace uart {
|
||||||
|
|
||||||
template <io::P rxPin, io::P txPin, class cfg = Config<>>
|
template <io::P rxPin, io::P txPin, class cfg = Config<>>
|
||||||
class Software {
|
class Software {
|
||||||
static_assert(type::always_false_v<cfg>, "Not implemented");
|
static_assert(util::always_false_v<cfg>, "Not implemented");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using data_t = typename cfg::data_t;
|
using data_t = typename cfg::data_t;
|
||||||
|
|||||||
42
uart.hpp
42
uart.hpp
@@ -33,8 +33,8 @@ static constexpr size_t cntDigits()
|
|||||||
template <typename T, size_t Base>
|
template <typename T, size_t Base>
|
||||||
static constexpr size_t maxNumDigits()
|
static constexpr size_t maxNumDigits()
|
||||||
{
|
{
|
||||||
constexpr T MinVal = type::numeric_limits<T>::min();
|
constexpr T MinVal = util::numeric_limits<T>::min();
|
||||||
constexpr T MaxVal = type::numeric_limits<T>::max();
|
constexpr T MaxVal = util::numeric_limits<T>::max();
|
||||||
|
|
||||||
constexpr T MinDigits = cntDigits<T, MinVal, Base>();
|
constexpr T MinDigits = cntDigits<T, MinVal, Base>();
|
||||||
constexpr T MaxDigits = cntDigits<T, MaxVal, Base>();
|
constexpr T MaxDigits = cntDigits<T, MaxVal, Base>();
|
||||||
@@ -112,7 +112,7 @@ class Uart {
|
|||||||
template <typename T, size_t Base = 10, size_t Padding = 0, char PadChar = '0', bool LowerCase = true>
|
template <typename T, size_t Base = 10, size_t Padding = 0, char PadChar = '0', bool LowerCase = true>
|
||||||
static void txNumber(const T &val)
|
static void txNumber(const T &val)
|
||||||
{
|
{
|
||||||
static_assert(type::is_integral_v<T>, "Only supported on integral types");
|
static_assert(util::is_integral_v<T>, "Only supported on integral types");
|
||||||
static_assert(Base >= 2, "Numbers with base less than 2 make no sense");
|
static_assert(Base >= 2, "Numbers with base less than 2 make no sense");
|
||||||
static_assert(Base <= 16, "Numbers with base higher than 16 are not supported");
|
static_assert(Base <= 16, "Numbers with base higher than 16 are not supported");
|
||||||
static_assert(Padding <= detail::maxNumDigits<T, Base>(), "Cannot pad more than maximum length of number");
|
static_assert(Padding <= detail::maxNumDigits<T, Base>(), "Cannot pad more than maximum length of number");
|
||||||
@@ -234,19 +234,19 @@ class Uart {
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(float) const
|
Uart &operator<<(float) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not supported by hardware");
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(double) const
|
Uart &operator<<(double) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not supported by hardware");
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(long double) const
|
Uart &operator<<(long double) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not supported by hardware");
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
Uart &operator<<(const bool &val)
|
Uart &operator<<(const bool &val)
|
||||||
@@ -268,91 +268,91 @@ class Uart {
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(char &) const
|
Uart &operator>>(char &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned char &) const
|
Uart &operator>>(unsigned char &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(short &) const
|
Uart &operator>>(short &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned short &) const
|
Uart &operator>>(unsigned short &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(int &) const
|
Uart &operator>>(int &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned int &) const
|
Uart &operator>>(unsigned int &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(long &) const
|
Uart &operator>>(long &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned long &) const
|
Uart &operator>>(unsigned long &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(long long &) const
|
Uart &operator>>(long long &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned long long &) const
|
Uart &operator>>(unsigned long long &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(float &) const
|
Uart &operator>>(float &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not supported by hardware");
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(double &) const
|
Uart &operator>>(double &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not supported by hardware");
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(long double &) const
|
Uart &operator>>(long double &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not supported by hardware");
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(bool &) const
|
Uart &operator>>(bool &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(const void *&) const
|
Uart &operator>>(const void *&) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user