2020-02-21 16:48:31 +01:00
|
|
|
#pragma once
|
2020-02-21 16:47:47 +01:00
|
|
|
|
2020-02-21 17:10:49 +01:00
|
|
|
#include "config.hpp"
|
|
|
|
#include "hardware.hpp"
|
2022-05-28 15:43:42 +02:00
|
|
|
#include "software.hpp"
|
2020-02-21 16:49:22 +01:00
|
|
|
|
2020-02-21 17:10:49 +01:00
|
|
|
#include "../io/io.hpp"
|
2020-02-21 16:47:47 +01:00
|
|
|
|
2020-02-21 16:49:22 +01:00
|
|
|
namespace spi {
|
|
|
|
|
2020-02-21 17:10:49 +01:00
|
|
|
template <class Driver>
|
2022-05-28 17:03:40 +02:00
|
|
|
struct Spi {
|
|
|
|
using word_t = typename Driver::word_t;
|
|
|
|
|
|
|
|
static inline void init()
|
2020-02-21 17:01:56 +01:00
|
|
|
{
|
2020-02-21 17:26:14 +01:00
|
|
|
Driver::init();
|
2020-02-21 16:47:47 +01:00
|
|
|
}
|
|
|
|
|
2022-05-28 17:03:40 +02:00
|
|
|
static inline word_t transfer(const word_t data)
|
2020-02-21 17:01:56 +01:00
|
|
|
{
|
2022-05-28 17:03:40 +02:00
|
|
|
return Driver::transfer(data);
|
2020-02-21 16:47:47 +01:00
|
|
|
}
|
2020-02-21 17:01:56 +01:00
|
|
|
|
2022-05-28 17:03:40 +02:00
|
|
|
static inline void select(const bool selectState)
|
2020-02-21 17:01:56 +01:00
|
|
|
{
|
2022-05-28 17:03:40 +02:00
|
|
|
Driver::select(selectState);
|
2020-02-21 16:47:47 +01:00
|
|
|
}
|
2020-02-21 17:01:56 +01:00
|
|
|
};
|
2020-02-21 16:49:22 +01:00
|
|
|
|
|
|
|
} // namespace spi
|