Make chip select pin configurable

This commit is contained in:
BlackMark 2022-05-26 14:58:47 +02:00
parent 70aabc07f6
commit bb78d2291d
2 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,7 @@
#pragma once
#include "../io/io.hpp"
namespace spi {
enum class ClockDiv {
@ -32,12 +34,13 @@ enum class BitOrder {
};
template <ClockDiv freq = ClockDiv::DIV_128, Mode mode = Mode::MODE_0, Side side = Side::MASTER,
BitOrder bitOrder = BitOrder::MSB_FIRST, bool pullup = false>
BitOrder bitOrder = BitOrder::MSB_FIRST, io::P ssPin = io::P::B2, bool pullup = false>
struct Config {
static constexpr auto FREQ = freq;
static constexpr auto MODE = mode;
static constexpr auto SIDE = side;
static constexpr auto BIT_ORDER = bitOrder;
static constexpr auto SS_PIN = ssPin;
static constexpr auto PULLUP = pullup;
};

View File

@ -52,7 +52,7 @@ class Hardware {
static io::Pin<io::P::B5> sm_sck;
static io::Pin<io::P::B4> sm_miso;
static io::Pin<io::P::B3> sm_mosi;
static io::Pin<io::P::B2> sm_ss;
static io::Pin<Cfg::SS_PIN> sm_ss;
static void setClockDiv()
{