REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
mblock_mul.h
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#include <algorithm>
6#include <bitset>
7
8#include "block/mblock.h"
9
10#include <chips/AD840X.h>
11#include <chips/DAC60508.h>
12#include <chips/SR74HC16X.h>
13#include <chips/SR74HCT595.h>
14#include <entity/meta.h>
15
16namespace blocks {
17
18// TODO: Change this comment -- This is rather a MUL4 not MUL8
19//
20// ███ ███ ██ ██ ██ █████ ██████ ██ █████ ███████ ███████
21// ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
22// ██ ████ ██ ██ ██ ██ █████ ██ ██ ███████ ███████ ███████
23// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
24// ██ ██ ██████ ███████ █████ ██████ ███████ ██ ██ ███████ ███████
25
26class MMulBlockHAL_V_1_0_X : public MMulBlockHAL {
27protected:
33
34public:
35 explicit MMulBlockHAL_V_1_0_X(bus::addr_t block_address);
36
37 metadata::eui_t get_entity_eui() const override { return f_meta.read_eui(); }
38
39 bool init() override;
40
41public:
42 bool write_calibration_input_offsets(uint8_t idx, uint16_t offset_x, uint16_t offset_y) override;
43 bool write_calibration_output_offset(uint8_t idx, uint16_t offset_z) override;
44
45 static constexpr float MIN_OFFSET = -0.1f;
46 static constexpr float MAX_OFFSET = +0.1f;
47
49 static float raw_to_float_calibration(uint16_t raw) {
50 return map(static_cast<float>(raw), functions::DAC60508::RAW_ZERO, functions::DAC60508::RAW_MAX,
52 }
53
54 std::bitset<8> read_overload_flags() override;
55 void reset_overload_flags() override;
56};
57
59protected:
62
63public:
64 explicit MMulBlockHAL_V_1_M1_X(bus::addr_t block_address);
65
66 bool write_calibration_gain(uint8_t idx, uint8_t gain);
67};
68
69class MMulBlock_FullAutoCalibration : public MMulBlock {
70public:
72
73public:
74 bool calibrate(platform::Cluster *cluster, carrier::Carrier *carrier) override;
75 utils::status write_calibration_to_hardware() override;
76
77protected:
79};
80
81} // namespace blocks
std::bitset< 8 > read_overload_flags() override
const functions::TriggerFunction f_overload_flags_reset
Definition mblock_mul.h:29
metadata::eui_t get_entity_eui() const override
Definition mblock_mul.h:37
bool write_calibration_output_offset(uint8_t idx, uint16_t offset_z) override
MMulBlockHAL_V_1_0_X(bus::addr_t block_address)
static constexpr float MIN_OFFSET
Definition mblock_mul.h:45
const metadata::MetadataEditor f_meta
Definition mblock_mul.h:28
const functions::SR74HC16X f_overload_flags
Definition mblock_mul.h:30
const functions::DAC60508 f_calibration_dac_0
Definition mblock_mul.h:31
void reset_overload_flags() override
static float raw_to_float_calibration(uint16_t raw)
Takes in DAC raw value, returns voltage recieved by multiplier.
Definition mblock_mul.h:49
bool write_calibration_input_offsets(uint8_t idx, uint16_t offset_x, uint16_t offset_y) override
const functions::DAC60508 f_calibration_dac_1
Definition mblock_mul.h:32
static constexpr float MAX_OFFSET
Definition mblock_mul.h:46
functions::AD8402 f_gain_ch0_1
Definition mblock_mul.h:60
bool write_calibration_gain(uint8_t idx, uint8_t gain)
functions::AD8402 f_gain_ch2_3
Definition mblock_mul.h:61
MMulBlockHAL_V_1_M1_X(bus::addr_t block_address)
MMulBlockHAL_V_1_M1_X * hardware
Definition mblock_mul.h:78
bool calibrate(platform::Cluster *cluster, carrier::Carrier *carrier) override
utils::status write_calibration_to_hardware() override
MMulBlock_FullAutoCalibration(SLOT slot, blocks::MMulBlockHAL_V_1_M1_X *hardware)
The DAC60508 is the 12-Bit 8-channel DAC, used in the MInt-Block for the initial conditions.
Definition DAC60508.h:17
static constexpr uint16_t RAW_ZERO
Definition DAC60508.h:30
static constexpr uint16_t RAW_MAX
Definition DAC60508.h:31
A trigger function exploits the fact that setting an address on the bus triggers an action (TODO: Is ...
Definition functions.h:33
eui_t read_eui() const
Definition meta.h:26
Definition daq.h:14