REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
74LVC138AD.tpl.hpp
Go to the documentation of this file.
1// Copyright (c) 2024 anabrid GmbH
2// Contact: https://www.anabrid.com/licensing/
3// SPDX-License-Identifier: MIT OR GPL-2.0-or-later
4
5#pragma once
6
7#include "bus/bus.h"
8#include "metadata/metadata.h"
9
18public:
19 static const SPISettings DEFAULT_SPI_SETTINGS;
20
21 explicit MetadataMemory74LVC138AD(bus::addr_t address)
22 : metadata::MetadataMemory<256>(address, SPISettings(4'000'000, MSBFIRST, SPI_MODE0)) {}
23
25
26 size_t read_from_hardware(size_t byte_offset, size_t length, uint8_t *buffer) const override {
27 // Begin SPI communication
29
30 // Send READ command B00000011
31 bus::spi.transfer(0x3);
32 // Send byte offset
33 bus::spi.transfer(byte_offset);
34 // Read data
35 bus::spi.transfer(nullptr, buffer, length);
36
37 // Release address and stop SPI transaction
39
40 return length;
41 }
42};
43
44const SPISettings MetadataMemory74LVC138AD::DEFAULT_SPI_SETTINGS{4'000'000, MSBFIRST, SPI_MODE0};
The 74LVC138AD is a 3-Line to 8-Line decoder/Demultiplexer.
static const SPISettings DEFAULT_SPI_SETTINGS
MetadataMemory74LVC138AD(bus::addr_t address)
size_t read_from_hardware(size_t byte_offset, size_t length, uint8_t *buffer) const override
void end_communication() const
void begin_communication() const
Definition functions.cpp:19
const bus::addr_t address
Definition functions.h:23
The abstract metadata memory class allows to represent different EEPROM sizes, for instance does the ...
Definition metadata.h:20
MetadataMemory(const unsigned short address, const SPISettings &spi_settings)
Definition metadata.h:25
SPIClass & spi
Definition bus.cpp:10