dreamcast/sh7091/serial.hpp
Zack Buhman 9801557535 maple: slightly refactor maple command initialization
This adopts a "writer" concept, vaguely inspired by the ta parameter
writer. This might turn out to be not a great idea if the
response/offsets for heterogenous commands are too inconvenient to
keep track of.

This breaks every example that uses maple--only
example/maple_controller is updated to use the new interface.
2024-05-21 15:05:25 -05:00

37 lines
718 B
C++

#pragma once
#include "string.hpp"
namespace serial {
void init(uint8_t bit_rate);
void character(const char c);
void string(const char * s);
void string(const uint8_t * s, uint32_t len);
void hexlify(const uint8_t n);
using hex = string::hex_type;
using dec = string::dec_type;
template <typename T, typename conv_type>
void integer(const T n, const char end, const uint32_t length);
template <typename T, typename conv_type = hex>
inline void integer(const T n, const char end)
{
constexpr uint32_t length = (sizeof (T)) * 2;
return integer<T, conv_type>(n, end, length);
}
template <typename T, typename conv_type = hex>
inline void integer(const T n)
{
return integer<T, conv_type>(n, '\n');
}
}