mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-07-14 11:40:49 +02:00
second Review
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <fmt/format.h>
|
||||
#include <string_view>
|
||||
|
||||
namespace sls {
|
||||
@@ -32,6 +34,12 @@ struct RegisterField {
|
||||
template <typename T>
|
||||
void setRegisterField(uint32_t ®istervalue, const RegisterField ®_field,
|
||||
T field_value) {
|
||||
|
||||
if (field_value > reg_field.bitmask) {
|
||||
throw std::invalid_argument(
|
||||
fmt::format("Value {} cannot fit in field with bitmask {}",
|
||||
field_value, reg_field.bitmask));
|
||||
}
|
||||
// Clear the bits corresponding to the field
|
||||
registervalue &= ~(reg_field.bitmask << reg_field.bit_position);
|
||||
// Set the new value for the field
|
||||
|
||||
Reference in New Issue
Block a user