Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hal] Support 16bit transfers for Spi #690

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/modm/architecture/interface/spi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,24 @@
*/
// ----------------------------------------------------------------------------

#ifndef MODM_INTERFACE_SPI_HPP
#define MODM_INTERFACE_SPI_HPP
#pragma once

#include <modm/architecture/interface/peripheral.hpp>

namespace modm
{
namespace spi
{

template<class Spi>
concept Support_DataSize_Bit16 = requires
{ Spi::DataSize::Bit16; };

template<class Spi>
concept Support_DataSize_Bit32 = requires
{ Spi::DataSize::Bit32; };

} // namespace spi

/// @ingroup modm_architecture_spi
struct Spi
Expand All @@ -43,8 +54,7 @@ struct Spi
MsbFirst = 0b0,
LsbFirst = 0b1,
};

};

} // namespace modm

#endif // MODM_INTERFACE_SPI_HPP
21 changes: 17 additions & 4 deletions src/modm/architecture/interface/spi_master.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
*/
// ----------------------------------------------------------------------------

#ifndef MODM_INTERFACE_SPI_MASTER_HPP
#define MODM_INTERFACE_SPI_MASTER_HPP
#pragma once

#include <modm/processing/resumable.hpp>
#include "spi.hpp"
Expand Down Expand Up @@ -156,8 +155,22 @@ class SpiMaster : public ::modm::PeripheralDriver, public Spi
static modm::ResumableResult<void>
transfer(const uint8_t *tx, uint8_t *rx, std::size_t length);
#endif

public:
enum State : uint8_t {
Idle = Bit6, // Transaction is running
Repeat = Bit7, // Send same tx multiple times
};
MODM_FLAGS8(State);

enum DataType : uint8_t {
Byte = 0, // 1 byte
HalfWord = 1, // 2 bytes
Word = 2, // 4 bytes
// WordWord = 3 // 8 bytes
};
typedef Value<State_t, 2> DataType_t;

};

} // namespace modm

#endif // MODM_INTERFACE_SPI_MASTER_HPP
6 changes: 2 additions & 4 deletions src/modm/driver/display/ili9341.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,9 @@ struct ili9341
};

/// @ingroup modm_driver_ili9341
template <class Interface, class Reset, class Backlight, std::size_t BufferSize = 320>
template <class Interface, class Reset, class Backlight>
class Ili9341 : public Interface, public modm::ColorGraphicDisplay
{
static_assert(BufferSize >= 16, "at least a small buffer is required");

static constexpr uint16_t Width = 240;
static constexpr uint16_t Height = 320;
using BatchHandle = typename Interface::BatchHandle;
Expand Down Expand Up @@ -298,7 +296,7 @@ class Ili9341 : public Interface, public modm::ColorGraphicDisplay

Orientation orientation{Orientation::Landscape0};

uint8_t buffer[BufferSize * 2]{0};
uint8_t buffer[4];
};

} // namespace modm
Expand Down
Loading