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