GR712RC unit tests 1.0
Bare-metal C++ hardware tests for the PLATO DPU (IAA-CSIC, 2019)
Loading...
Searching...
No Matches
mcal_reg_dynamic_access_template.h
Go to the documentation of this file.
1
2// Copyright Christopher Kormanyos 2013.
3// Distributed under the Boost Software License,
4// Version 1.0. (See accompanying file LICENSE_1_0.txt
5// or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7
8#ifndef _MCAL_REG_DYNAMIC_ACCESS_TEMPLATE_2013_12_13_H_
9 #define _MCAL_REG_DYNAMIC_ACCESS_TEMPLATE_2013_12_13_H_
10
11 namespace mcal
12 {
13 namespace reg
14 {
15 template<typename register_address_type,
16 typename register_value_type>
18 {
19 static register_value_type reg_get(const register_address_type address) { return *reinterpret_cast<volatile register_value_type*>(address); }
20
21 static void reg_set(const register_address_type address, const register_value_type value) { *reinterpret_cast<volatile register_value_type*>(address) = value; }
22 static void reg_and(const register_address_type address, const register_value_type value) { *reinterpret_cast<volatile register_value_type*>(address) &= value; }
23 static void reg_or (const register_address_type address, const register_value_type value) { *reinterpret_cast<volatile register_value_type*>(address) |= value; }
24 static void reg_not(const register_address_type address, const register_value_type value) { *reinterpret_cast<volatile register_value_type*>(address) &= register_value_type(~value); }
25 static void reg_msk(const register_address_type address, const register_value_type value, const register_value_type mask_value)
26 {
27 *reinterpret_cast<volatile register_value_type*>(address) = register_value_type(register_value_type(reg_get(address) & register_value_type(~mask_value)) | register_value_type(value & mask_value));
28 }
29
30 static void bit_set(const register_address_type address, const register_value_type value) { *reinterpret_cast<volatile register_value_type*>(address) |= static_cast<register_value_type>(1UL << value); }
31 static void bit_clr(const register_address_type address, const register_value_type value) { *reinterpret_cast<volatile register_value_type*>(address) &= static_cast<register_value_type>(~static_cast<register_value_type>(1UL << value)); }
32 static void bit_not(const register_address_type address, const register_value_type value) { *reinterpret_cast<volatile register_value_type*>(address) ^= static_cast<register_value_type>(1UL << value); }
33 static bool bit_get(const register_address_type address, const register_value_type value) { return (static_cast<volatile register_value_type>(reg_get(address) & static_cast<register_value_type>(1UL << value)) != static_cast<register_value_type>(0U)); }
34 };
35 }
36 }
37
38#endif // _MCAL_REG_DYNAMIC_ACCESS_TEMPLATE_2013_12_13_H_
static void reg_and(const register_address_type address, const register_value_type value)
static void reg_or(const register_address_type address, const register_value_type value)
static register_value_type reg_get(const register_address_type address)
static void bit_set(const register_address_type address, const register_value_type value)
static void bit_not(const register_address_type address, const register_value_type value)
static void bit_clr(const register_address_type address, const register_value_type value)
static bool bit_get(const register_address_type address, const register_value_type value)
static void reg_msk(const register_address_type address, const register_value_type value, const register_value_type mask_value)
static void reg_set(const register_address_type address, const register_value_type value)
static void reg_not(const register_address_type address, const register_value_type value)