REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
mblock.cpp
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 "native/mblock_int.h"
6#include "native/mblock_mul.h"
7
8blocks::MBlock *blocks::MBlock::from_entity_classifier(entities::EntityClassifier classifier,
9 const bus::addr_t block_address) {
10 if (!classifier or classifier.class_enum != entities::EntityClass::M_BLOCK)
11 return nullptr;
12
13 auto type = classifier.type_as<TYPES>();
14 switch (type) {
15 case TYPES::UNKNOWN:
16 // This is already checked by !classifier above
17 return nullptr;
18 case TYPES::M_MUL4_BLOCK:
19 return MMulBlock::from_entity_classifier(classifier, block_address);
20 case TYPES::M_INT8_BLOCK:
21 return MIntBlock::from_entity_classifier(classifier, block_address);
22 }
23 // Any unknown value results in a nullptr here.
24 // Adding default case to switch suppresses warnings about missing cases.
25 return nullptr;
26}