├── .gitignore ├── LICENSE.txt ├── README.html ├── README.md ├── README_svd2regbits.html ├── README_svd2regbits.md ├── RELEASE_NOTES.txt ├── regbits.hxx ├── svd2regbits.py └── unittest ├── Makefile ├── arm ├── Makefile.arm ├── cortex_m0plus │ └── nxp │ │ └── lpc824 │ │ ├── Makefile │ │ ├── O1 │ │ ├── bitfield.o.dmp │ │ ├── raw.elf.dmp │ │ ├── raw.o.dmp │ │ ├── regbits.elf.dmp │ │ ├── regbits.o.dmp │ │ ├── results.txt │ │ ├── struct.elf.dmp │ │ └── struct.o.dmp │ │ ├── O2 │ │ ├── bitfield.o.dmp │ │ ├── raw.elf.dmp │ │ ├── raw.o.dmp │ │ ├── regbits.elf.dmp │ │ ├── regbits.o.dmp │ │ ├── results.txt │ │ ├── struct.elf.dmp │ │ └── struct.o.dmp │ │ ├── O3 │ │ ├── bitfield.o.dmp │ │ ├── raw.elf.dmp │ │ ├── raw.o.dmp │ │ ├── regbits.elf.dmp │ │ ├── regbits.o.dmp │ │ ├── results.txt │ │ ├── struct.elf.dmp │ │ └── struct.o.dmp │ │ ├── include │ │ ├── LPC8xx.h │ │ ├── cmsis_gcc.h │ │ ├── core_cm0plus.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ └── system_LPC8xx.h │ │ ├── lpc824_ram.ld │ │ ├── lpc8xx_ram_init.c │ │ └── mcu.h ├── cortex_m3 │ └── stm │ │ └── stm32f103xb │ │ ├── Makefile │ │ ├── O1 │ │ ├── bitfield.elf.dmp │ │ ├── bitfield.o.dmp │ │ ├── raw.elf.dmp │ │ ├── raw.o.dmp │ │ ├── regbits.elf.dmp │ │ ├── regbits.o.dmp │ │ ├── results.txt │ │ ├── struct.elf.dmp │ │ └── struct.o.dmp │ │ ├── O2 │ │ ├── bitfield.elf.dmp │ │ ├── bitfield.o.dmp │ │ ├── raw.elf.dmp │ │ ├── raw.o.dmp │ │ ├── regbits.elf.dmp │ │ ├── regbits.o.dmp │ │ ├── results.txt │ │ ├── struct.elf.dmp │ │ └── struct.o.dmp │ │ ├── O3 │ │ ├── bitfield.elf.dmp │ │ ├── bitfield.o.dmp │ │ ├── raw.elf.dmp │ │ ├── raw.o.dmp │ │ ├── regbits.elf.dmp │ │ ├── regbits.o.dmp │ │ ├── results.txt │ │ ├── struct.elf.dmp │ │ └── struct.o.dmp │ │ ├── include │ │ ├── cmsis_gcc.h │ │ ├── core_cm3.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ ├── stm32f103_vectors_handlers.h │ │ ├── stm32f103xb.h │ │ └── system_stm32f1xx.h │ │ ├── mcu.h │ │ ├── stm32f103_ram.ld │ │ └── stm32f103_ram_init.c ├── cortex_m7 │ └── stm │ │ └── stm32f767xx │ │ ├── Makefile │ │ ├── O1 │ │ ├── bitfield.elf.dmp │ │ ├── bitfield.o.dmp │ │ ├── raw.elf.dmp │ │ ├── raw.o.dmp │ │ ├── regbits.elf.dmp │ │ ├── regbits.o.dmp │ │ ├── results.txt │ │ ├── struct.elf.dmp │ │ └── struct.o.dmp │ │ ├── O2 │ │ ├── bitfield.elf.dmp │ │ ├── bitfield.o.dmp │ │ ├── raw.elf.dmp │ │ ├── raw.o.dmp │ │ ├── regbits.elf.dmp │ │ ├── regbits.o.dmp │ │ ├── results.txt │ │ ├── struct.elf.dmp │ │ └── struct.o.dmp │ │ ├── O3 │ │ ├── bitfield.elf.dmp │ │ ├── bitfield.o.dmp │ │ ├── raw.elf.dmp │ │ ├── raw.o.dmp │ │ ├── regbits.elf.dmp │ │ ├── regbits.o.dmp │ │ ├── results.txt │ │ ├── struct.elf.dmp │ │ └── struct.o.dmp │ │ ├── include │ │ ├── cmsis_gcc.h │ │ ├── core_cm7.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ ├── core_cmSimd.h │ │ ├── stm32f767xx.h │ │ └── system_stm32f7xx.h │ │ ├── mcu.h │ │ ├── stm32f767xx_ram.ld │ │ └── stm32f767xx_ram_init.c ├── main.c └── unittest.gdb ├── bad ├── arm │ └── Makefile ├── array_range.cxx ├── bits_bits_assign.cxx ├── bits_bits_ctor.cxx ├── bits_copy_equ.cxx ├── bits_copy_neq.cxx ├── bits_equ.cxx ├── bits_implicit.cxx ├── bits_mskd_assign.cxx ├── bits_mskd_ctor.cxx ├── bits_neq.cxx ├── bits_or_bits_diff.cxx ├── bits_or_bits_same.cxx ├── bits_range.cxx ├── bits_reg_assign.cxx ├── bits_reg_ctor.cxx ├── bits_reg_equ.cxx ├── bits_reg_neq.cxx ├── call_bits_diff.cxx ├── call_bits_same.cxx ├── call_mskd_diff.cxx ├── call_mskd_same.cxx ├── call_pos_diff.cxx ├── call_pos_same.cxx ├── cmp_pos_diff.cxx ├── cmp_pos_same.cxx ├── copy.cxx ├── copy_from_word.cxx ├── copy_shifted.cxx ├── copy_shifted_op.cxx ├── linux │ └── Makefile ├── mskd_bits_assign.cxx ├── mskd_bits_ctor.cxx ├── mskd_copy_equ.cxx ├── mskd_copy_geq.cxx ├── mskd_copy_gtr.cxx ├── mskd_copy_leq.cxx ├── mskd_copy_lss.cxx ├── mskd_copy_neq.cxx ├── mskd_equ.cxx ├── mskd_geq.cxx ├── mskd_gtr.cxx ├── mskd_leq.cxx ├── mskd_lss.cxx ├── mskd_mskd_assign.cxx ├── mskd_mskd_ctor.cxx ├── mskd_neq.cxx ├── mskd_or_mskd_diff.cxx ├── mskd_or_mskd_same.cxx ├── mskd_range.cxx ├── mskd_reg_assign.cxx ├── mskd_reg_ctor.cxx ├── mskd_reg_equ.cxx ├── mskd_reg_geq.cxx ├── mskd_reg_gtr.cxx ├── mskd_reg_leq.cxx ├── mskd_reg_lss.cxx ├── mskd_reg_neq.cxx ├── pos_assign.cxx ├── pos_equ.cxx ├── pos_neq.cxx ├── reg_bits_diff.cxx ├── reg_bits_same.cxx ├── reg_clr_bits.cxx ├── reg_clr_mskd.cxx ├── reg_flp_bits.cxx ├── reg_flp_mskd.cxx ├── reg_ins_bits.cxx ├── reg_ins_mskd.cxx ├── reg_mskd_diff.cxx ├── reg_mskd_same.cxx ├── reg_set_bits.cxx ├── reg_set_mskd.cxx ├── reg_shifted.cxx ├── reg_shifted_op.cxx └── shft_shft_assign.cxx ├── bitfield.c ├── bitfield.gdb ├── bitops.h ├── do_tests.inl ├── linux ├── Makefile ├── bitfield.elf.dmp ├── bitfield.o.dmp ├── bitfield.out ├── main.c ├── raw.elf.dmp ├── raw.o.dmp ├── raw.out ├── regbits.elf.dmp ├── regbits.o.dmp ├── regbits.out ├── results.txt ├── struct.elf.dmp ├── struct.o.dmp ├── struct.out └── unittest.gdb ├── mcu_bitfield.h ├── mcu_raw.h ├── mcu_regbits.hxx ├── mcu_struct.h ├── raw.c ├── raw.gdb ├── regbits.cxx ├── regbits.gdb ├── struct.c ├── struct.gdb └── unittest.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.o 3 | 4 | # Executables 5 | *.elf 6 | -------------------------------------------------------------------------------- /RELEASE_NOTES.txt: -------------------------------------------------------------------------------- 1 | 1.1.0 (regbits) 0.1.4 (svd2regbits.py) 2021 Feb 02 2 | ----------------------------------------------------- 3 | * svd2regbits.py: Support multiple "" tags in "" 4 | * regbits.hxx: (no changes) 5 | 6 | 1.1.0 (regbits) 0.1.3 (svd2regbits.py) 2021 Jan 13 7 | ----------------------------------------------------- 8 | * svd2regbits.py: 9 | * Removed nested arm namespace in .hxx output 10 | * Fix for 11 | * regbits.hxx: (no changes) 12 | 13 | 1.1.0 (regbits) 0.1.2 (svd2regbits.py) 2021 Jan 07 14 | ----------------------------------------------------- 15 | * svd2regbits.py: Handle "" for clusters 16 | * regbits.hxx: (no changes) 17 | 18 | 1.1.0 (regbits) 0.1.1 (svd2regbits.py) 2020 Dec 27 19 | ----------------------------------------------------- 20 | * svd2regbits.py: Handle "" 21 | * regbits.hxx: (no changes) 22 | 23 | 1.1.0 2020 Dec 23 24 | ------------------- 25 | * Added REGBITS_MSKD_UNSGN for WORD sizes wider than unsigned 26 | * Small fix to REGBITS_ARRAY_RANGE constexpr static_assert 27 | * New svd2regbits.py utility, and README_svd2regbits.md 28 | 29 | 1.0.2 2020 Nov 10 30 | ------------------- 31 | * Minor change in regbits.hxx (Reg::zero constexpr) 32 | * Major rewrite of unittest build system: 33 | - top-level Makefile with make/cleanbin/clean targets 34 | - bad/{arm,linux} makefiles build both pass and intentional fail tests 35 | - rework capture of arm subdirs compilation results 36 | 37 | 1.0.1 2020 Jan 19 38 | ------------------- 39 | * Reg extractors return Bits or Mskd instead of Reg 40 | * Added bool Reg::all(Bits mask, Bits bits) 41 | * Added "explicit" keyword to additional constructors 42 | * "= default" copy constructors (required for GCC 9) 43 | * Version numbering 44 | -------------------------------------------------------------------------------- /unittest/Makefile: -------------------------------------------------------------------------------- 1 | # regbits: C++ templates for type-safe bit manipulation 2 | # Copyright (C) 2019,2020 Mark R. Rubin 3 | # 4 | # This file is part of regbits. 5 | # 6 | # The regbits program is free software: you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License as 8 | # published by the Free Software Foundation, either version 3 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # The regbits program is distributed in the hope that it will be 12 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public 17 | # License (LICENSE.txt) along with the regbits program. If not, see 18 | # 19 | 20 | MAKEFLAGS += --no-print-directory 21 | 22 | all: 23 | @ echo make in linux 24 | @ (cd linux ; make ) 25 | 26 | @ for dir in bad/linux bad/arm ; do \ 27 | echo make in $$dir ; \ 28 | (cd $$dir ; make) ; \ 29 | done 30 | 31 | @ for dir in cortex_m0plus/nxp/lpc824 \ 32 | cortex_m3/stm/stm32f103xb \ 33 | cortex_m7/stm/stm32f767xx ; do \ 34 | echo make in arm/$$dir ; \ 35 | (cd arm/$$dir ; make) ; \ 36 | done 37 | 38 | clean: 39 | @ echo make clean in linux 40 | @ (cd linux ; make clean ) 41 | 42 | @ for dir in bad/linux bad/arm ; do \ 43 | echo make clean in $$dir ; \ 44 | (cd $$dir ; make clean) ; \ 45 | done 46 | 47 | @ for dir in cortex_m0plus/nxp/lpc824 \ 48 | cortex_m3/stm/stm32f103xb \ 49 | cortex_m7/stm/stm32f767xx ; do \ 50 | echo make clean in arm/$$dir ; \ 51 | (cd arm/$$dir ; make clean) ; \ 52 | done 53 | 54 | cleanbin: 55 | @ echo make cleanbin in linux 56 | @ (cd linux ; make cleanbin ) 57 | 58 | @ for dir in bad/linux bad/arm ; do \ 59 | echo make clean in $$dir ; \ 60 | (cd $$dir ; make clean) ; \ 61 | done 62 | 63 | @ for dir in cortex_m0plus/nxp/lpc824 \ 64 | cortex_m3/stm/stm32f103xb \ 65 | cortex_m7/stm/stm32f767xx ; do \ 66 | echo make cleanbin arm/$$dir ; \ 67 | (cd arm/$$dir ; make cleanbin) ; \ 68 | done 69 | -------------------------------------------------------------------------------- /unittest/arm/Makefile.arm: -------------------------------------------------------------------------------- 1 | # regbits: C++ templates for type-safe bit manipulation 2 | # Copyright (C) 2019,2020 Mark R. Rubin 3 | # 4 | # This file is part of regbits. 5 | # 6 | # The regbits program is free software: you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License as 8 | # published by the Free Software Foundation, either version 3 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # The regbits program is distributed in the hope that it will be 12 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public 17 | # License (LICENSE.txt) along with the regbits program. If not, see 18 | # 19 | 20 | 21 | ifndef GCC_ARM_ROOT 22 | $(error set GCC_ARM_ROOT environment variable) 23 | endif 24 | 25 | .SUFFIXES: 26 | 27 | CXX_STANDARD ?= c++17 28 | # OPTIMIZE ?= -O1 29 | DEBUG ?= -g3 30 | GCC_ARM_BUG ?= -DGCC_ARM_BUG 31 | EXTRA_CC ?= 32 | EXTRA_CXX ?= 33 | 34 | THUMB_ARM ?= -mthumb 35 | MCU ?= 36 | ACPU ?= cortex-m0plus 37 | TUNE ?= 38 | ARCH ?= 39 | TPCS ?= 40 | # aapcs aapcs-linux apcs-gnu atpcs iwmmxt 41 | ABI ?= apcs-gnu 42 | 43 | CC = arm-none-eabi-gcc 44 | CXX = arm-none-eabi-g++ 45 | OBJDUMP = arm-none-eabi-objdump 46 | READELF = arm-none-eabi-readelf 47 | 48 | export PATH := $(GCC_ARM_ROOT)/bin:$(PATH) 49 | 50 | 51 | C_ELFS = $(subst ../../../../,,$(wildcard ../../../../*.c)) 52 | CXX_ELFS = $(subst ../../../../,,$(wildcard ../../../../*.cxx)) 53 | ELFS = $(subst .c,.elf,$(C_ELFS)) $(subst .cxx,.elf,$(CXX_ELFS)) 54 | DMPS = $(subst .elf,.elf.dmp,$(ELFS)) $(subst .elf,.o.dmp,$(ELFS)) 55 | RLFS = $(subst .elf,.elf.rdelf,$(ELFS)) 56 | OUTS = $(subst .elf,.out,$(ELFS)) 57 | INL_FILE = ../../../../do_tests.inl 58 | 59 | 60 | o_all: o1 o2 o3 61 | 62 | # gdb: $(OUTS) main.o $(INL_FILE) $(INIT_FILE).o $(ELFS) $(DMPS) $(RLFS) 63 | # @ if [ -z $$GDB_OPENOCD ] ; then \ 64 | # echo Set 'GDB_OPENOCD' environment variable and attach hardware \ 65 | # to make '"gdb"' target. ; \ 66 | # else \ 67 | # ../../../../unittest.py arm '$(MCU) $(ACPU) $(ABI) $(TUNE) $(ARCH) $(TPCS) $(OPTIMIZE) $(DEBUG) $(GCC_ARM_BUG) $(EXTRA_CXX) $(CXX_STANDARD)' ../../../../do_tests.inl *.o.dmp *.out ; \ 68 | # fi 69 | # 70 | # o_gdb: 71 | # @ rm -f $(OPT_LEVEL)/* 72 | # @ make --no-print-directory clean 73 | # @ make OPTIMIZE=-$(OPT_LEVEL) --no-print-directory gdb | tee $(OPT_LEVEL)/make.out 74 | 75 | 76 | o1: O1/results.txt 77 | o2: O2/results.txt 78 | o3: O3/results.txt 79 | 80 | 81 | .PHONY: clean cleanbin 82 | clean: cleanbin 83 | @ rm -f O?/*.dmp O?/*.map O?/*.out O?/*.rdelf O?/*.dmp O?/make.out O?/results.txt 84 | cleanbin: 85 | @ rm -f O?/*.o O?/*.elf O?/*.map 86 | 87 | .PRECIOUS: O1/%.o O1/%.elf O2/%.o O2/%.elf O3/%.o O3/%.elf 88 | 89 | INCLUDES = -I. -I../../../.. -I../../../../.. -Iinclude 90 | vpath %c ../../../.. ../../.. 91 | vpath %cxx ../../../.. 92 | 93 | ARM_OPTS = $(THUMB_ARM) 94 | 95 | ifdef ACPU 96 | ARM_OPTS += -mcpu=$(ACPU) 97 | endif 98 | 99 | ifdef TUNE 100 | ARM_OPTS += -mtune=$(TUNE) 101 | endif 102 | 103 | ifdef ARCH 104 | ARM_OPTS += -march=$(ARCH) 105 | endif 106 | 107 | ifdef TPCS 108 | ARM_OPTS += -m$(TPCS) 109 | endif 110 | 111 | ifdef ABI 112 | ARM_OPTS += -mabi=$(ABI) 113 | endif 114 | 115 | # otherwise won't link without non-existent "unwind" library 116 | ARM_OPTS += -fno-exceptions -fno-unwind-tables 117 | 118 | 119 | CCOPTS = -Wall \ 120 | $(OPTIMIZE) \ 121 | $(DEBUG) \ 122 | $(INCLUDES) \ 123 | -D__VTOR_PRESENT \ 124 | $(ARM_OPTS) \ 125 | $(EXTRA_CC) \ 126 | -DREGBITS_PERIPH_BASE=$(PERIPH_BASE) 127 | 128 | CXXOPTS = -Wall \ 129 | -std=$(CXX_STANDARD) \ 130 | $(OPTIMIZE) \ 131 | $(DEBUG) \ 132 | $(INCLUDES) \ 133 | -fno-threadsafe-statics \ 134 | $(ARM_OPTS) \ 135 | $(GCC_ARM_BUG) \ 136 | $(EXTRA_CXX) \ 137 | -DREGBITS_PERIPH_BASE=$(PERIPH_BASE) 138 | 139 | LDOPTS = -marmelf -static -M --print-memory-usage # -nostdlib 140 | 141 | 142 | # $(OPT_LEVEL)/%.out: %.elf 143 | # @ if [ -z $$GDB_OPENOCD ] ; then \ 144 | # if [ -x $< ] ; then \ 145 | # echo Set 'GDB_OPENOCD' environment variable and attach hardware \ 146 | # to make '"gdb"' target. ; \ 147 | # else \ 148 | # rm -f $@ ; \ 149 | # $$GDB_OPENOCD $< -q -x ../../../../$(subst .elf,.gdb,$^) -x ../../../unittest.gdb > /dev/null ; \ 150 | # sleep 2 ; \ 151 | # fi ; \ 152 | # fi 153 | 154 | # $$GDB_OPENOCD $< -x ../../../../$(subst .elf,.gdb,$^) -x ../../../unittest.gdb ; \ 155 | 156 | 157 | define OPTIMIZE_DIR_RULES 158 | $(1)/%.o: %.c 159 | @- $(CC) -c -$(1) $(CCOPTS) $$< -o $$@ 160 | 161 | $(1)/%.o: %.cxx 162 | @- $(CXX) -c -$(1) $(CXXOPTS) $$< -o $$@ 163 | 164 | $(1)/results.txt: $(addprefix $(1)/,$(DMPS)) 165 | @ tail --lines=3 $(1)/*.map > $(1)/results.txt 166 | @ ../../../../unittest.py arm '$(MCU) $(ACPU) $(ABI) $(TUNE) $(ARCH) $(TPCS) $(OPTIMIZE) $(DEBUG) $(GCC_ARM_BUG) $(EXTRA_CXX) $(CXX_STANDARD) -$(1)' ../../../../do_tests.inl $(1)/*.o.dmp >> $(1)/results.txt 167 | 168 | $(1)/%.elf.rdelf: $(1)/%.elf 169 | @- $(READELF) -a $$< > $$@ 170 | 171 | $(1)/%.o.dmp: $(1)/%.o 172 | @- $(OBJDUMP) -dC -j.text -j.rodata -j.data -j.bss $$< > $$@ 173 | 174 | $(1)/%.elf.dmp: $(1)/%.elf 175 | @- if [ -f $$< ] ; then \ 176 | $(OBJDUMP) -dC -j.text -j.rodata -j.data -j.bss $$< > $$@ ; \ 177 | fi 178 | 179 | $(1)/%.elf: $(1)/%.o $(1)/main.o $(1)/$(INIT_FILE).o 180 | @- $(LD) -o $$@ \ 181 | $$^ \ 182 | $(LDOPTS) \ 183 | $(GNU_ARM_LIBDIRS) \ 184 | $(LDLIBS) \ 185 | -T $(LD_SCRIPT) \ 186 | > $$@.map 187 | endef 188 | 189 | $(foreach dir,O1 O2 O3,$(eval $(call OPTIMIZE_DIR_RULES,$(dir)))) 190 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m0plus/nxp/lpc824/Makefile: -------------------------------------------------------------------------------- 1 | # regbits: C++ templates for type-safe bit manipulation 2 | # Copyright (C) 2019 Mark R. Rubin 3 | # 4 | # This file is part of regbits. 5 | # 6 | # The regbits program is free software: you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License as 8 | # published by the Free Software Foundation, either version 3 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # The regbits program is distributed in the hope that it will be 12 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public 17 | # License (LICENSE.txt) along with the regbits program. If not, see 18 | # 19 | 20 | MCU ?= lpc824 21 | ACPU ?= cortex-m0plus 22 | 23 | INIT_FILE = lpc8xx_ram_init 24 | LD_SCRIPT = lpc824_ram.ld 25 | 26 | PERIPH_BASE ?= 0x10001b00 27 | 28 | include ../../../Makefile.arm 29 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m0plus/nxp/lpc824/include/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m0plus/nxp/lpc824/include/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m0plus/nxp/lpc824/include/system_LPC8xx.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file: system_LPC8xx.h 3 | * @purpose: CMSIS Cortex-M0+ Device Peripheral Access Layer Header File 4 | * for the NXP LPC8xx Device Series 5 | * @version: V1.0 6 | * @date: 16. Aug. 2012 7 | *---------------------------------------------------------------------------- 8 | * 9 | * Copyright (C) 2012 ARM Limited. All rights reserved. 10 | * 11 | * ARM Limited (ARM) is supplying this software for use with Cortex-M0+ 12 | * processor based microcontrollers. This file can be freely distributed 13 | * within development tools that are supporting such ARM based processors. 14 | * 15 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED 16 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF 17 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. 18 | * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR 19 | * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. 20 | * 21 | ******************************************************************************/ 22 | 23 | 24 | #ifndef __SYSTEM_LPC8xx_H 25 | #define __SYSTEM_LPC8xx_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | #include 32 | 33 | /* 34 | //-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ 35 | */ 36 | 37 | /*--------------------- Clock Configuration ---------------------------------- 38 | // 39 | // Clock Configuration 40 | // System Oscillator Control Register (SYSOSCCTRL) 41 | // BYPASS: System Oscillator Bypass Enable 42 | // If enabled then PLL input (sys_osc_clk) is fed 43 | // directly from XTALIN and XTALOUT pins. 44 | // FREQRANGE: System Oscillator Frequency Range 45 | // Determines frequency range for Low-power oscillator. 46 | // <0=> 1 - 20 MHz 47 | // <1=> 15 - 25 MHz 48 | // 49 | // 50 | // Watchdog Oscillator Control Register (WDTOSCCTRL) 51 | // DIVSEL: Select Divider for Fclkana 52 | // wdt_osc_clk = Fclkana/ (2 � (1 + DIVSEL)) 53 | // <0-31> 54 | // FREQSEL: Select Watchdog Oscillator Analog Output Frequency (Fclkana) 55 | // <0=> Undefined 56 | // <1=> 0.5 MHz 57 | // <2=> 0.8 MHz 58 | // <3=> 1.1 MHz 59 | // <4=> 1.4 MHz 60 | // <5=> 1.6 MHz 61 | // <6=> 1.8 MHz 62 | // <7=> 2.0 MHz 63 | // <8=> 2.2 MHz 64 | // <9=> 2.4 MHz 65 | // <10=> 2.6 MHz 66 | // <11=> 2.7 MHz 67 | // <12=> 2.9 MHz 68 | // <13=> 3.1 MHz 69 | // <14=> 3.2 MHz 70 | // <15=> 3.4 MHz 71 | // 72 | // 73 | // System PLL Control Register (SYSPLLCTRL) 74 | // F_clkout = M * F_clkin = F_CCO / (2 * P) 75 | // F_clkin must be in the range of 10 MHz to 25 MHz 76 | // F_CCO must be in the range of 156 MHz to 320 MHz 77 | // MSEL: Feedback Divider Selection 78 | // M = MSEL + 1 79 | // <0-31> 80 | // PSEL: Post Divider Selection 81 | // <0=> P = 1 82 | // <1=> P = 2 83 | // <2=> P = 4 84 | // <3=> P = 8 85 | // 86 | // 87 | // System PLL Clock Source Select Register (SYSPLLCLKSEL) 88 | // SEL: System PLL Clock Source 89 | // <0=> IRC Oscillator 90 | // <1=> System Oscillator 91 | // <2=> Reserved 92 | // <3=> CLKIN pin 93 | // 94 | // 95 | // Main Clock Source Select Register (MAINCLKSEL) 96 | // SEL: Clock Source for Main Clock 97 | // <0=> IRC Oscillator 98 | // <1=> Input Clock to System PLL 99 | // <2=> WDT Oscillator 100 | // <3=> System PLL Clock Out 101 | // 102 | // 103 | // System AHB Clock Divider Register (SYSAHBCLKDIV) 104 | // DIV: System AHB Clock Divider 105 | // Divides main clock to provide system clock to core, memories, and peripherals. 106 | // 0 = is disabled 107 | // <0-255> 108 | // 109 | // 110 | */ 111 | 112 | // 30 MHz main clock via PLL and internal RC oscillator 113 | // According to the NXP tech support to access time of the internal flash 114 | // is 24ns and zero waitstate access is still possible at 30 Mhz. 115 | // 116 | // PLL is set to 60 MHz 117 | // AHBClkdiv divides the clock by 2 118 | 119 | #define CLOCK_SETUP 1 120 | #define SYSOSCCTRL_Val 0x00000000 // Reset: 0x000 121 | #define WDTOSCCTRL_Val 0x00000000 // Reset: 0x000 122 | #define SYSPLLCTRL_Val 0x00000024 // Reset: 0x000 123 | #define SYSPLLCLKSEL_Val 0x00000000 // Reset: 0x000 124 | #define MAINCLKSEL_Val 0x00000003 // Reset: 0x000 125 | #define SYSAHBCLKDIV_Val 0x00000002 // Reset: 0x001 126 | 127 | 128 | 129 | /* 130 | //-------- <<< end of configuration section >>> ------------------------------ 131 | */ 132 | 133 | /*---------------------------------------------------------------------------- 134 | Check the register settings 135 | *----------------------------------------------------------------------------*/ 136 | #define CHECK_RANGE(val, min, max) ((val < min) || (val > max)) 137 | #define CHECK_RSVD(val, mask) (val & mask) 138 | 139 | /* Clock Configuration -------------------------------------------------------*/ 140 | #if (CHECK_RSVD((SYSOSCCTRL_Val), ~0x00000003)) 141 | #error "SYSOSCCTRL: Invalid values of reserved bits!" 142 | #endif 143 | 144 | #if (CHECK_RSVD((WDTOSCCTRL_Val), ~0x000001FF)) 145 | #error "WDTOSCCTRL: Invalid values of reserved bits!" 146 | #endif 147 | 148 | #if (CHECK_RANGE((SYSPLLCLKSEL_Val), 0, 3)) 149 | #error "SYSPLLCLKSEL: Value out of range!" 150 | #endif 151 | 152 | #if (CHECK_RSVD((SYSPLLCTRL_Val), ~0x000001FF)) 153 | #error "SYSPLLCTRL: Invalid values of reserved bits!" 154 | #endif 155 | 156 | #if (CHECK_RSVD((MAINCLKSEL_Val), ~0x00000003)) 157 | #error "MAINCLKSEL: Invalid values of reserved bits!" 158 | #endif 159 | 160 | #if (CHECK_RANGE((SYSAHBCLKDIV_Val), 0, 255)) 161 | #error "SYSAHBCLKDIV: Value out of range!" 162 | #endif 163 | 164 | 165 | /*---------------------------------------------------------------------------- 166 | DEFINES 167 | *----------------------------------------------------------------------------*/ 168 | 169 | /*---------------------------------------------------------------------------- 170 | Define clocks 171 | *----------------------------------------------------------------------------*/ 172 | #define __XTAL (12000000UL) /* Oscillator frequency */ 173 | #define __SYS_OSC_CLK ( __XTAL) /* Main oscillator frequency */ 174 | #define __IRC_OSC_CLK (12000000UL) /* Internal RC oscillator frequency */ 175 | #define __CLKIN_CLK (12000000UL) /* CLKIN pin frequency */ 176 | 177 | 178 | #define __FREQSEL ((WDTOSCCTRL_Val >> 5) & 0x0F) 179 | #define __DIVSEL (((WDTOSCCTRL_Val & 0x1F) << 1) + 2) 180 | 181 | #if (CLOCK_SETUP) /* Clock Setup */ 182 | #if (__FREQSEL == 0) 183 | #define __WDT_OSC_CLK ( 0) /* undefined */ 184 | #elif (__FREQSEL == 1) 185 | #define __WDT_OSC_CLK ( 500000 / __DIVSEL) 186 | #elif (__FREQSEL == 2) 187 | #define __WDT_OSC_CLK ( 800000 / __DIVSEL) 188 | #elif (__FREQSEL == 3) 189 | #define __WDT_OSC_CLK (1100000 / __DIVSEL) 190 | #elif (__FREQSEL == 4) 191 | #define __WDT_OSC_CLK (1400000 / __DIVSEL) 192 | #elif (__FREQSEL == 5) 193 | #define __WDT_OSC_CLK (1600000 / __DIVSEL) 194 | #elif (__FREQSEL == 6) 195 | #define __WDT_OSC_CLK (1800000 / __DIVSEL) 196 | #elif (__FREQSEL == 7) 197 | #define __WDT_OSC_CLK (2000000 / __DIVSEL) 198 | #elif (__FREQSEL == 8) 199 | #define __WDT_OSC_CLK (2200000 / __DIVSEL) 200 | #elif (__FREQSEL == 9) 201 | #define __WDT_OSC_CLK (2400000 / __DIVSEL) 202 | #elif (__FREQSEL == 10) 203 | #define __WDT_OSC_CLK (2600000 / __DIVSEL) 204 | #elif (__FREQSEL == 11) 205 | #define __WDT_OSC_CLK (2700000 / __DIVSEL) 206 | #elif (__FREQSEL == 12) 207 | #define __WDT_OSC_CLK (2900000 / __DIVSEL) 208 | #elif (__FREQSEL == 13) 209 | #define __WDT_OSC_CLK (3100000 / __DIVSEL) 210 | #elif (__FREQSEL == 14) 211 | #define __WDT_OSC_CLK (3200000 / __DIVSEL) 212 | #else 213 | #define __WDT_OSC_CLK (3400000 / __DIVSEL) 214 | #endif 215 | 216 | /* sys_pllclkin calculation */ 217 | #if ((SYSPLLCLKSEL_Val & 0x03) == 0) 218 | #define __SYS_PLLCLKIN (__IRC_OSC_CLK) 219 | #elif ((SYSPLLCLKSEL_Val & 0x03) == 1) 220 | #define __SYS_PLLCLKIN (__SYS_OSC_CLK) 221 | #elif ((SYSPLLCLKSEL_Val & 0x03) == 3) 222 | #define __SYS_PLLCLKIN (__CLKIN_CLK) 223 | #else 224 | #define __SYS_PLLCLKIN (0) 225 | #endif 226 | 227 | #define __SYS_PLLCLKOUT (__SYS_PLLCLKIN * ((SYSPLLCTRL_Val & 0x01F) + 1)) 228 | 229 | /* main clock calculation */ 230 | #if ((MAINCLKSEL_Val & 0x03) == 0) 231 | #define __MAIN_CLOCK (__IRC_OSC_CLK) 232 | #elif ((MAINCLKSEL_Val & 0x03) == 1) 233 | #define __MAIN_CLOCK (__SYS_PLLCLKIN) 234 | #elif ((MAINCLKSEL_Val & 0x03) == 2) 235 | #if (__FREQSEL == 0) 236 | #error "MAINCLKSEL: WDT Oscillator selected but FREQSEL is undefined!" 237 | #else 238 | #define __MAIN_CLOCK (__WDT_OSC_CLK) 239 | #endif 240 | #elif ((MAINCLKSEL_Val & 0x03) == 3) 241 | #define __MAIN_CLOCK (__SYS_PLLCLKOUT) 242 | #else 243 | #define __MAIN_CLOCK (0) 244 | #endif 245 | 246 | #define __SYSTEM_CLOCK (__MAIN_CLOCK / SYSAHBCLKDIV_Val) 247 | 248 | #else 249 | #define __SYSTEM_CLOCK (__IRC_OSC_CLK) 250 | #endif // CLOCK_SETUP 251 | 252 | 253 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 254 | 255 | /** 256 | * Initialize the system 257 | * 258 | * @param none 259 | * @return none 260 | * 261 | * @brief Setup the microcontroller system. 262 | * Initialize the System and update the SystemCoreClock variable. 263 | */ 264 | extern void SystemInit (void); 265 | 266 | /** 267 | * Update SystemCoreClock variable 268 | * 269 | * @param none 270 | * @return none 271 | * 272 | * @brief Updates the SystemCoreClock with current core Clock 273 | * retrieved from cpu registers. 274 | */ 275 | extern void SystemCoreClockUpdate (void); 276 | 277 | #ifdef __cplusplus 278 | } 279 | #endif 280 | 281 | #endif /* __SYSTEM_LPC8xx_H */ 282 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m0plus/nxp/lpc824/lpc824_ram.ld: -------------------------------------------------------------------------------- 1 | /* 2 | regbits: C++ templates for type-safe bit manipulation 3 | Copyright (C) 2019,2020 Mark R. Rubin 4 | 5 | This file is part of regbits. 6 | 7 | The regbits program is free software: you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License 9 | as published by the Free Software Foundation, either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The regbits program is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | (LICENSE.txt) along with the regbits program. If not, see 19 | 20 | */ 21 | 22 | 23 | /* Linker script for NXP LPC824 */ 24 | 25 | ENTRY(init) 26 | 27 | MEMORY 28 | { 29 | FLASH (rx) : org = 0x00000000, LENGTH = 32K 30 | RAM (rwx) : org = 0x10000000, LENGTH = 8K 31 | } 32 | 33 | PROVIDE(MINIMUM_STACK_SIZE = 32); 34 | 35 | SECTIONS 36 | { 37 | . = ORIGIN(RAM); 38 | .text : { 39 | *(.isr_vectors); /* The interrupt vectors */ 40 | *(.text); 41 | } > RAM 42 | 43 | .data : { 44 | . = ALIGN(4); 45 | *(.data); 46 | } > RAM 47 | 48 | BSS_START = .; 49 | .bss : { 50 | . = ALIGN(4); 51 | *(.bss); 52 | } > RAM 53 | BSS_END = .; 54 | 55 | end = .; /* for gnu-arm libc.a */ 56 | 57 | RAM_BASE_ADDR = ORIGIN(RAM); 58 | FLASH_BASE_ADDR = ORIGIN(FLASH); 59 | TOP_OF_STACK = ORIGIN(RAM) + LENGTH(RAM); 60 | 61 | ASSERT(end + MINIMUM_STACK_SIZE < TOP_OF_STACK, "too big to fit in RAM") 62 | 63 | } 64 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m0plus/nxp/lpc824/mcu.h: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | #include 21 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m3/stm/stm32f103xb/Makefile: -------------------------------------------------------------------------------- 1 | # regbits: C++ templates for type-safe bit manipulation 2 | # Copyright (C) 2019 Mark R. Rubin 3 | # 4 | # This file is part of regbits. 5 | # 6 | # The regbits program is free software: you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License as 8 | # published by the Free Software Foundation, either version 3 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # The regbits program is distributed in the hope that it will be 12 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public 17 | # License (LICENSE.txt) along with the regbits program. If not, see 18 | # 19 | 20 | MCU ?= stm32f103 21 | ACPU ?= cortex-m3 22 | 23 | INIT_FILE = stm32f103_ram_init 24 | LD_SCRIPT = stm32f103_ram.ld 25 | 26 | PERIPH_BASE ?= 0x200021c0 27 | 28 | include ../../../Makefile.arm 29 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m3/stm/stm32f103xb/include/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m3/stm/stm32f103xb/include/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m3/stm/stm32f103xb/include/stm32f103xb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thanks4opensource/regbits/18c1640a83dbddebc4dde6a853de6bdbd50fa7bd/unittest/arm/cortex_m3/stm/stm32f103xb/include/stm32f103xb.h -------------------------------------------------------------------------------- /unittest/arm/cortex_m3/stm/stm32f103xb/include/system_stm32f1xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f10x.h 4 | * @author MCD Application Team 5 | * @version V4.2.0 6 | * @date 31-March-2017 7 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2017 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /** @addtogroup CMSIS 39 | * @{ 40 | */ 41 | 42 | /** @addtogroup stm32f10x_system 43 | * @{ 44 | */ 45 | 46 | /** 47 | * @brief Define to prevent recursive inclusion 48 | */ 49 | #ifndef __SYSTEM_STM32F10X_H 50 | #define __SYSTEM_STM32F10X_H 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | /** @addtogroup STM32F10x_System_Includes 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | /** @addtogroup STM32F10x_System_Exported_types 66 | * @{ 67 | */ 68 | 69 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 70 | extern const uint8_t AHBPrescTable[16U]; /*!< AHB prescalers table values */ 71 | extern const uint8_t APBPrescTable[8U]; /*!< APB prescalers table values */ 72 | 73 | /** 74 | * @} 75 | */ 76 | 77 | /** @addtogroup STM32F10x_System_Exported_Constants 78 | * @{ 79 | */ 80 | 81 | /** 82 | * @} 83 | */ 84 | 85 | /** @addtogroup STM32F10x_System_Exported_Macros 86 | * @{ 87 | */ 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /** @addtogroup STM32F10x_System_Exported_Functions 94 | * @{ 95 | */ 96 | 97 | extern void SystemInit(void); 98 | extern void SystemCoreClockUpdate(void); 99 | /** 100 | * @} 101 | */ 102 | 103 | #ifdef __cplusplus 104 | } 105 | #endif 106 | 107 | #endif /*__SYSTEM_STM32F10X_H */ 108 | 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 117 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m3/stm/stm32f103xb/mcu.h: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | typedef enum { 21 | SysTick_IRQn = -1, 22 | } IRQn_Type; 23 | 24 | #define __NVIC_PRIO_BITS 4 25 | 26 | #include 27 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m3/stm/stm32f103xb/stm32f103_ram.ld: -------------------------------------------------------------------------------- 1 | /* 2 | regbits: C++ templates for type-safe bit manipulation 3 | Copyright (C) 2019,2020 Mark R. Rubin 4 | 5 | This file is part of regbits. 6 | 7 | The regbits program is free software: you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License 9 | as published by the Free Software Foundation, either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The regbits program is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | (LICENSE.txt) along with the regbits program. If not, see 19 | 20 | */ 21 | 22 | 23 | /* Linker script for STM32F103 ("BluePill") */ 24 | 25 | ENTRY(init) 26 | 27 | MEMORY 28 | { 29 | /* 30 | /usr/local/doc/hardware/st/STM32F103x8,B_datasheet.pdf 31 | p.10 2.1 32 | Table 2. STM32F103xx medium-density device features and peripheral 33 | counts 34 | STM32F103Tx 35 | Flash - Kybytes 64 or 128 36 | SRAM - Kybytes 20 37 | p.34 4 Memory mapping 38 | Figure 11. Memory map 39 | (SRAM and Flash base addresses, except Flash, SRAM, or System Memory 40 | can alias to 0x00000000 depending on BOOT configuration) 41 | */ 42 | FLASH (rx) : org = 0x08000000, LENGTH = 64k 43 | RAM (rwx) : org = 0x20000000, LENGTH = 20K 44 | } 45 | 46 | SECTIONS 47 | { 48 | . = ORIGIN(RAM); 49 | .text : { 50 | *(.vectors); /* The interrupt vectors */ 51 | *(.text); 52 | } > RAM 53 | 54 | .data : { 55 | . = ALIGN(4); 56 | *(.data); 57 | } > RAM 58 | 59 | BSS_START = .; 60 | .bss : { 61 | . = ALIGN(4); 62 | *(.bss); 63 | } > RAM 64 | BSS_END = .; 65 | 66 | end = .; /* for gnu-arm libc.a */ 67 | 68 | TOP_OF_STACK = ORIGIN(RAM) + LENGTH(RAM); 69 | } 70 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m3/stm/stm32f103xb/stm32f103_ram_init.c: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019,2020 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it 7 | // and/or modify it under the terms of the GNU General Public License 8 | // as published by the Free Software Foundation, either version 3 of 9 | // the License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include 22 | 23 | #include 24 | 25 | void init(void); // for 2nd entry in vector table 26 | // The following are 'declared' in the linker script 27 | extern uint8_t BSS_START; 28 | extern uint8_t BSS_END; 29 | extern uint8_t TOP_OF_STACK; 30 | #define INTERRUPT_VECTORS_CONST 31 | #include "stm32f103_vectors_handlers.h" 32 | 33 | 34 | 35 | int main(void); 36 | 37 | 38 | void __attribute__ ((isr)) init() 39 | { 40 | uint8_t *dest; 41 | uint32_t len; 42 | 43 | // zero out the uninitialized global/static variables 44 | dest = &BSS_START; 45 | len = &BSS_END - &BSS_START; 46 | while (len--) 47 | *dest++=0; 48 | 49 | // set CPU's vector table address 50 | SCB->VTOR = (uint32_t)INTERRUPT_VECTORS; 51 | 52 | // start program 53 | main(); 54 | } 55 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m7/stm/stm32f767xx/Makefile: -------------------------------------------------------------------------------- 1 | # regbits: C++ templates for type-safe bit manipulation 2 | # Copyright (C) 2019 Mark R. Rubin 3 | # 4 | # This file is part of regbits. 5 | # 6 | # The regbits program is free software: you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License as 8 | # published by the Free Software Foundation, either version 3 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # The regbits program is distributed in the hope that it will be 12 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public 17 | # License (LICENSE.txt) along with the regbits program. If not, see 18 | # 19 | 20 | MCU ?= stm32f767xx 21 | ACPU ?= cortex-m7 22 | 23 | INIT_FILE = stm32f767xx_ram_init 24 | LD_SCRIPT = stm32f767xx_ram.ld 25 | 26 | PERIPH_BASE ?= 0x20022400 27 | 28 | include ../../../Makefile.arm 29 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m7/stm/stm32f767xx/include/core_cmFunc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmFunc.h 3 | * @brief CMSIS Cortex-M Core Function Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMFUNC_H 42 | #define __CORE_CMFUNC_H 43 | 44 | 45 | /* ########################### Core Function Access ########################### */ 46 | /** \ingroup CMSIS_Core_FunctionInterface 47 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@} end of CMSIS_Core_RegAccFunctions */ 86 | 87 | #endif /* __CORE_CMFUNC_H */ 88 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m7/stm/stm32f767xx/include/core_cmInstr.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmInstr.h 3 | * @brief CMSIS Cortex-M Core Instruction Access Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMINSTR_H 42 | #define __CORE_CMINSTR_H 43 | 44 | 45 | /* ########################## Core Instruction Access ######################### */ 46 | /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface 47 | Access to dedicated instructions 48 | @{ 49 | */ 50 | 51 | /*------------------ RealView Compiler -----------------*/ 52 | #if defined ( __CC_ARM ) 53 | #include "cmsis_armcc.h" 54 | 55 | /*------------------ ARM Compiler V6 -------------------*/ 56 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 57 | #include "cmsis_armcc_V6.h" 58 | 59 | /*------------------ GNU Compiler ----------------------*/ 60 | #elif defined ( __GNUC__ ) 61 | #include "cmsis_gcc.h" 62 | 63 | /*------------------ ICC Compiler ----------------------*/ 64 | #elif defined ( __ICCARM__ ) 65 | #include 66 | 67 | /*------------------ TI CCS Compiler -------------------*/ 68 | #elif defined ( __TMS470__ ) 69 | #include 70 | 71 | /*------------------ TASKING Compiler ------------------*/ 72 | #elif defined ( __TASKING__ ) 73 | /* 74 | * The CMSIS functions have been implemented as intrinsics in the compiler. 75 | * Please use "carm -?i" to get an up to date list of all intrinsics, 76 | * Including the CMSIS ones. 77 | */ 78 | 79 | /*------------------ COSMIC Compiler -------------------*/ 80 | #elif defined ( __CSMC__ ) 81 | #include 82 | 83 | #endif 84 | 85 | /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ 86 | 87 | #endif /* __CORE_CMINSTR_H */ 88 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m7/stm/stm32f767xx/include/core_cmSimd.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file core_cmSimd.h 3 | * @brief CMSIS Cortex-M SIMD Header File 4 | * @version V4.30 5 | * @date 20. October 2015 6 | ******************************************************************************/ 7 | /* Copyright (c) 2009 - 2015 ARM LIMITED 8 | 9 | All rights reserved. 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | - Neither the name of ARM nor the names of its contributors may be used 18 | to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | * 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 25 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | ---------------------------------------------------------------------------*/ 33 | 34 | 35 | #if defined ( __ICCARM__ ) 36 | #pragma system_include /* treat file as system include file for MISRA check */ 37 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 38 | #pragma clang system_header /* treat file as system include file */ 39 | #endif 40 | 41 | #ifndef __CORE_CMSIMD_H 42 | #define __CORE_CMSIMD_H 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | 49 | /* ################### Compiler specific Intrinsics ########################### */ 50 | /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics 51 | Access to dedicated SIMD instructions 52 | @{ 53 | */ 54 | 55 | /*------------------ RealView Compiler -----------------*/ 56 | #if defined ( __CC_ARM ) 57 | #include "cmsis_armcc.h" 58 | 59 | /*------------------ ARM Compiler V6 -------------------*/ 60 | #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 61 | #include "cmsis_armcc_V6.h" 62 | 63 | /*------------------ GNU Compiler ----------------------*/ 64 | #elif defined ( __GNUC__ ) 65 | #include "cmsis_gcc.h" 66 | 67 | /*------------------ ICC Compiler ----------------------*/ 68 | #elif defined ( __ICCARM__ ) 69 | #include 70 | 71 | /*------------------ TI CCS Compiler -------------------*/ 72 | #elif defined ( __TMS470__ ) 73 | #include 74 | 75 | /*------------------ TASKING Compiler ------------------*/ 76 | #elif defined ( __TASKING__ ) 77 | /* 78 | * The CMSIS functions have been implemented as intrinsics in the compiler. 79 | * Please use "carm -?i" to get an up to date list of all intrinsics, 80 | * Including the CMSIS ones. 81 | */ 82 | 83 | /*------------------ COSMIC Compiler -------------------*/ 84 | #elif defined ( __CSMC__ ) 85 | #include 86 | 87 | #endif 88 | 89 | /*@} end of group CMSIS_SIMD_intrinsics */ 90 | 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __CORE_CMSIMD_H */ 97 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m7/stm/stm32f767xx/include/stm32f767xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thanks4opensource/regbits/18c1640a83dbddebc4dde6a853de6bdbd50fa7bd/unittest/arm/cortex_m7/stm/stm32f767xx/include/stm32f767xx.h -------------------------------------------------------------------------------- /unittest/arm/cortex_m7/stm/stm32f767xx/include/system_stm32f7xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f7xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M7 Device System Source File for STM32F7xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2016 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /** @addtogroup CMSIS 37 | * @{ 38 | */ 39 | 40 | /** @addtogroup stm32f7xx_system 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Define to prevent recursive inclusion 46 | */ 47 | #ifndef __SYSTEM_STM32F7XX_H 48 | #define __SYSTEM_STM32F7XX_H 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | /** @addtogroup STM32F7xx_System_Includes 55 | * @{ 56 | */ 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | 63 | /** @addtogroup STM32F7xx_System_Exported_Variables 64 | * @{ 65 | */ 66 | /* The SystemCoreClock variable is updated in three ways: 67 | 1) by calling CMSIS function SystemCoreClockUpdate() 68 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 69 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 70 | Note: If you use this function to configure the system clock; then there 71 | is no need to call the 2 first functions listed above, since SystemCoreClock 72 | variable is updated automatically. 73 | */ 74 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 75 | 76 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 77 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 78 | 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @addtogroup STM32F7xx_System_Exported_Constants 85 | * @{ 86 | */ 87 | 88 | /** 89 | * @} 90 | */ 91 | 92 | /** @addtogroup STM32F7xx_System_Exported_Macros 93 | * @{ 94 | */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** @addtogroup STM32F7xx_System_Exported_Functions 101 | * @{ 102 | */ 103 | 104 | extern void SystemInit(void); 105 | extern void SystemCoreClockUpdate(void); 106 | /** 107 | * @} 108 | */ 109 | 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | 114 | #endif /*__SYSTEM_STM32F7XX_H */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | /** 121 | * @} 122 | */ 123 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 124 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m7/stm/stm32f767xx/mcu.h: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | typedef enum { 21 | SysTick_IRQn = -1, 22 | } IRQn_Type; 23 | 24 | #define __NVIC_PRIO_BITS 4 25 | 26 | #include 27 | -------------------------------------------------------------------------------- /unittest/arm/cortex_m7/stm/stm32f767xx/stm32f767xx_ram.ld: -------------------------------------------------------------------------------- 1 | /* 2 | regbits: C++ templates for type-safe bit manipulation 3 | Copyright (C) 2019,2020 Mark R. Rubin 4 | 5 | This file is part of regbits. 6 | 7 | The regbits program is free software: you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License 9 | as published by the Free Software Foundation, either version 3 of 10 | the License, or (at your option) any later version. 11 | 12 | The regbits program is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | (LICENSE.txt) along with the regbits program. If not, see 19 | 20 | */ 21 | 22 | 23 | /* Linker script for STM32F767xx */ 24 | 25 | ENTRY(init) 26 | 27 | MEMORY 28 | { 29 | ITCM_RAM (rwx) : org = 0x00000000, LENGTH = 16K 30 | DTCM_RAM (rwx) : org = 0x20000000, LENGTH = 128K 31 | SRAM1 (rwx) : org = 0x20020000, LENGTH = 368K 32 | SRAM2 (rwx) : org = 0x2007C000, LENGTH = 16K 33 | } 34 | 35 | PROVIDE(MINIMUM_STACK_SIZE = 1K); 36 | 37 | SECTIONS 38 | { 39 | . = ORIGIN(ITCM_RAM); 40 | .fast_text : { 41 | } > ITCM_RAM 42 | 43 | . = ORIGIN(DTCM_RAM); 44 | .fast_data : { 45 | } > DTCM_RAM 46 | 47 | . = ORIGIN(SRAM1); 48 | .text : { 49 | *(.vectors); /* The interrupt vectors */ 50 | *(.text); 51 | } > SRAM1 52 | 53 | .data : { 54 | . = ALIGN(4); 55 | *(.data); 56 | } > SRAM1 57 | 58 | BSS_START = .; 59 | .bss : { 60 | . = ALIGN(4); 61 | *(.bss); 62 | } > SRAM1 63 | BSS_END = .; 64 | 65 | end = .; /* for gnu-arm libc.a */ 66 | 67 | TOP_OF_STACK = ORIGIN(SRAM1) + LENGTH(SRAM1); 68 | 69 | ASSERT(end + MINIMUM_STACK_SIZE < TOP_OF_STACK, "too big to fit in RAM") 70 | } 71 | -------------------------------------------------------------------------------- /unittest/arm/main.c: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include 22 | #include 23 | 24 | #include "mcu.h" 25 | 26 | 27 | extern void run(); 28 | 29 | 30 | #define NUM_TESTS_DEFINE 116 31 | 32 | static const unsigned NUM_TESTS __attribute__((unused)) = NUM_TESTS_DEFINE, 33 | REPEATS = 1 ; 34 | 35 | uint32_t results[NUM_TESTS_DEFINE * 2]; 36 | 37 | 38 | // needed for -O3 39 | // inefficient, but only used by init() 40 | void *memset( 41 | void *mem, 42 | int val, 43 | size_t siz) 44 | { 45 | volatile uint8_t *ptr = (uint8_t*)mem, 46 | *end = ptr + siz; 47 | 48 | while (ptr < end) 49 | *ptr++ = val; 50 | 51 | return mem; 52 | } 53 | 54 | 55 | 56 | uint32_t __attribute__((unused)) elapsed_time = 0; 57 | 58 | 59 | 60 | void do_test( 61 | void (*test)(), 62 | volatile uint32_t* const regster, 63 | const uint32_t testnum) 64 | { 65 | uint32_t start, 66 | finish; 67 | 68 | SysTick->CTRL = 0; // halt 69 | SysTick->VAL = 0; // ensure will start from LOAD value 70 | SysTick->CTRL = SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk; 71 | SysTick->LOAD = 0xffffff; // is 24 bits, max 72 | 73 | // wait for SysTick to start up 74 | while (SysTick->VAL == 0) 75 | asm("nop"); 76 | 77 | start = SysTick->VAL; 78 | 79 | *regster = 0x00000000; 80 | test(); 81 | results[testnum * 2] = *regster; 82 | 83 | *regster = 0xffffffff; 84 | test(); 85 | results[testnum * 2 + 1] = *regster; 86 | 87 | finish = SysTick->VAL; 88 | 89 | elapsed_time += start - finish; 90 | } 91 | 92 | 93 | 94 | int main() 95 | { 96 | uint32_t repeat; 97 | for (repeat = 0 ; repeat < REPEATS ; ++repeat) run(); 98 | 99 | exit: asm("nop"); // for GDB breakpoint 100 | goto exit; // if no breakpoint 101 | } 102 | -------------------------------------------------------------------------------- /unittest/arm/unittest.gdb: -------------------------------------------------------------------------------- 1 | # regbits: C++ templates for type-safe bit manipulation 2 | # Copyright (C) 2019 Mark R. Rubin 3 | # 4 | # This file is part of regbits. 5 | # 6 | # The regbits program is free software: you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License as 8 | # published by the Free Software Foundation, either version 3 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # The regbits program is distributed in the hope that it will be 12 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public 17 | # License (LICENSE.txt) along with the regbits program. If not, see 18 | # 19 | 20 | 21 | set height 0 22 | set logging on 23 | printf "size: %d\n", &run - &zero_reg 24 | printf "repeats: %d\n", REPEATS 25 | 26 | set logging off 27 | break main:exit 28 | continue 29 | 30 | set logging on 31 | printf "time: %d\n", elapsed_time 32 | 33 | set var $ndx = 0 34 | while $ndx < NUM_TESTS * 2 35 | printf "%-2d %08x %08x\n", \ 36 | $ndx / 2, \ 37 | results[$ndx ], \ 38 | results[$ndx + 1] 39 | set var $ndx = $ndx + 2 40 | end 41 | 42 | set logging off 43 | set logging file /dev/null 44 | set logging on 45 | mon reset halt 46 | quit 47 | -------------------------------------------------------------------------------- /unittest/bad/arm/Makefile: -------------------------------------------------------------------------------- 1 | # regbits: C++ templates for type-safe bit manipulation 2 | # Copyright (C) 2019,2020 Mark R. Rubin 3 | # 4 | # This file is part of regbits. 5 | # 6 | # The regbits program is free software: you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License as 8 | # published by the Free Software Foundation, either version 3 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # The regbits program is distributed in the hope that it will be 12 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public 17 | # License (LICENSE.txt) along with the regbits program. If not, see 18 | # 19 | 20 | 21 | ifndef GCC_ARM_ROOT 22 | $(error set GCC_ARM_ROOT environment variable) 23 | endif 24 | 25 | export PATH := $(GCC_ARM_ROOT)/bin:$(PATH) 26 | 27 | CXX = arm-none-eabi-g++ 28 | 29 | CXX_STANDARD ?= c++11 30 | OPTIMIZE ?= -O1 31 | DEBUG ?= 32 | THUMB_ARM ?= -mthumb 33 | ARM_PCS ?= -mabi=apcs-gnu 34 | ACPU ?= 35 | TUNE ?= 36 | ARCH ?= 37 | TPCS ?= 38 | ABI ?= 39 | EXTRA_CXX ?= 40 | PERIPH_BASE ?= 0x20001000 41 | 42 | ARM_OPTS = $(THUMB_ARM) $(ARM_PCS) 43 | 44 | ifdef ACPU 45 | ARM_OPTS += -mcpu=$(ACPU) 46 | endif 47 | 48 | ifdef TUNE 49 | ARM_OPTS += -mtune=$(TUNE) 50 | endif 51 | 52 | ifdef ARCH 53 | ARM_OPTS += -march=$(ARCH) 54 | endif 55 | 56 | ifdef TPCS 57 | ARM_OPTS += -m$(TPCS) 58 | endif 59 | 60 | ifdef ABI 61 | ARM_OPTS += -mabi=$(ABI) 62 | endif 63 | 64 | 65 | SRCS = $(subst ../,,$(wildcard ../*.cxx)) 66 | OBJS = $(SRCS:.cxx=.o) 67 | 68 | unittest: $(OBJS) 69 | 70 | .PHONY: clean 71 | clean: 72 | rm -f *.o 73 | 74 | 75 | INCLUDES = -I../.. -I../../.. 76 | vpath %.cxx .. 77 | 78 | CXXOPTS = -Wall \ 79 | -std=$(CXX_STANDARD) \ 80 | $(OPTIMIZE) \ 81 | $(DEBUG) \ 82 | $(INCLUDES) \ 83 | $(EXTRA_CXX) \ 84 | $(ARM_OPTS) \ 85 | -DREGBITS_PERIPH_BASE=$(PERIPH_BASE) 86 | 87 | 88 | %.o: %.cxx 89 | @ if $(CXX) -c $(CXXOPTS) -UGOOD $< -o $@ > /dev/null 2>&1 ; \ 90 | then \ 91 | echo "$< -UGOOD compiled but should have failed" ; \ 92 | fi ; \ 93 | rm -f $@ ; \ 94 | if ! $(CXX) -c $(CXXOPTS) -DGOOD $< -o $@ > /dev/null 2>&1 ; \ 95 | then \ 96 | echo "$< -DGOOD failed but should have compiled" ; \ 97 | fi \ 98 | -------------------------------------------------------------------------------- /unittest/bad/array_range.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_range() 27 | { 28 | #ifdef GOOD 29 | gpio1->words.WORDS<22>() = 127; 30 | #else 31 | gpio1->words.WORDS<23>() = 127; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/bits_bits_assign.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_bits_assign() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::bits_t bits; 30 | bits = Serial::Config::POLARITY; 31 | #else 32 | Serial::Config::bits_t bits; 33 | bits = Serial::Control::ENABLE; 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /unittest/bad/bits_bits_ctor.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_bits_ctor() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::bits_t bits(Serial::Config::POLARITY); 30 | #else 31 | Serial::Config::bits_t bits(Serial::Control::ENABLE); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/bits_copy_equ.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_copy_equ() 27 | { 28 | Serial::config_t copy(serial2->config); 29 | #ifdef GOOD 30 | copy.any(Serial::Config::ENDIAN); 31 | #else 32 | copy.any(Serial::Control::ENABLE); 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /unittest/bad/bits_copy_neq.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_copy_equ() 27 | { 28 | Serial::config_t copy(serial2->config); 29 | #ifdef GOOD 30 | copy.all(Serial::Config::ENDIAN); 31 | #else 32 | copy.all(Serial::Control::ENABLE); 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /unittest/bad/bits_equ.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_equ() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::ENDIAN == Serial::Config::POLARITY; 30 | #else 31 | Serial::Config::ENDIAN == Serial::Control::ENABLE; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/bits_implicit.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | void pass_bits( 26 | Timer::Control::bits_t bits) 27 | { 28 | return timer1->control = bits; 29 | } 30 | 31 | 32 | 33 | void bits_implicit() 34 | { 35 | #ifdef GOOD 36 | pass_bits(Timer::Control::bits_t(0)); 37 | #else 38 | pass_bits(0); 39 | #endif 40 | } 41 | -------------------------------------------------------------------------------- /unittest/bad/bits_mskd_assign.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_mskd_assign() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::bits_t bits; 30 | bits = Serial::Config::DATALEN_16_BITS; 31 | #else 32 | Serial::Config::bits_t bits; 33 | bits = Timer::Control::CLOCK_SOURCE_PLL; 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /unittest/bad/bits_mskd_ctor.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_mskd_ctor() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::bits_t bits(Serial::Config::DATALEN_16_BITS); 30 | #else 31 | Serial::Config::bits_t bits(Timer::Control::CLOCK_SOURCE_PLL); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/bits_neq.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_neq() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::ENDIAN != Serial::Config::POLARITY; 30 | #else 31 | Serial::Config::ENDIAN != Serial::Control::ENABLE; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/bits_or_bits_diff.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_or_bits_diff() 27 | { 28 | #ifdef GOOD 29 | Serial::Control::ENABLE | Serial::Control::RECV; 30 | #else 31 | Serial::Control::ENABLE | Timer::Control::ENABLE; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/bits_or_bits_same.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_or_bits_same() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::ENDIAN | Serial::Config::POLARITY; 30 | #else 31 | Serial::Config::ENDIAN | Serial::Control::ENABLE; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/bits_range.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_range() 27 | { 28 | #ifdef GOOD 29 | gpio1->set |= Gpio::Set::SET<31>(); 30 | #else 31 | gpio1->set |= Gpio::Set::SET<32>(); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/bits_reg_assign.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_reg_assign() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::bits_t bits; 30 | bits = serial2->config; 31 | #else 32 | Serial::Config::bits_t bits; 33 | bits = serial2-control; 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /unittest/bad/bits_reg_ctor.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_reg_ctor() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::bits_t bits(serial2->config); 30 | #else 31 | Serial::Config::bits_t bits(serial2-control); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/bits_reg_equ.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_reg_equ() 27 | { 28 | #ifdef GOOD 29 | serial2->config.any(Serial::Config::ENDIAN); 30 | #else 31 | serial2->control.any(Serial::Config::ENDIAN); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/bits_reg_neq.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void bits_reg_neq() 27 | { 28 | #ifdef GOOD 29 | !serial2->config.any(Serial::Config::ENDIAN); 30 | #else 31 | !serial2->control.any(Serial::Config::ENDIAN); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/call_bits_diff.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | void bits_diff( 26 | Serial::Control::bits_t bits) 27 | { 28 | } 29 | 30 | 31 | 32 | void call_bits_diff() 33 | { 34 | #ifdef GOOD 35 | bits_diff(Serial::Control::ENABLE); 36 | #else 37 | bits_diff(Timer::Control::ENABLE); 38 | #endif 39 | } 40 | -------------------------------------------------------------------------------- /unittest/bad/call_bits_same.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | void bits_same( 26 | Serial::Config::bits_t bits) 27 | { 28 | } 29 | 30 | 31 | 32 | void call_bits_same() 33 | { 34 | #ifdef GOOD 35 | bits_same(Serial::Config::ENDIAN); 36 | #else 37 | bits_same(Serial::Control::ENABLE); 38 | #endif 39 | } 40 | -------------------------------------------------------------------------------- /unittest/bad/call_mskd_diff.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | void mskd_diff( 26 | Timer::Control::mskd_t mskd) 27 | { 28 | } 29 | 30 | 31 | 32 | void call_mskd_diff() 33 | { 34 | #ifdef GOOD 35 | mskd_diff(Timer::Control::CLOCK_SOURCE_PLL); 36 | #else 37 | mskd_diff(Serial::Config::DATALEN_16_BITS); 38 | #endif 39 | } 40 | -------------------------------------------------------------------------------- /unittest/bad/call_mskd_same.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | void mskd_same( 26 | Timer::Prescale::mskd_t mskd) 27 | { 28 | } 29 | 30 | 31 | 32 | void call_mskd_same() 33 | { 34 | #ifdef GOOD 35 | mskd_same(Timer::Prescale::PRESCALER_HIGH<11>()); 36 | #else 37 | mskd_same(Timer::Control::CLOCK_SOURCE_PLL); 38 | #endif 39 | } 40 | -------------------------------------------------------------------------------- /unittest/bad/call_pos_diff.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | void pos_diff( 26 | Serial::Control::pos_t pos) 27 | { 28 | } 29 | 30 | 31 | 32 | void call_pos_diff() 33 | { 34 | #ifdef GOOD 35 | pos_diff(Serial::Control::ENABLE_POS); 36 | #else 37 | pos_diff(Timer::Control::ENABLE_POS); 38 | #endif 39 | } 40 | -------------------------------------------------------------------------------- /unittest/bad/call_pos_same.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | void pos_same( 26 | Serial::Config::pos_t pos) 27 | { 28 | } 29 | 30 | 31 | 32 | void call_pos_same() 33 | { 34 | #ifdef GOOD 35 | pos_same(Serial::Config::ENDIAN_POS); 36 | #else 37 | pos_same(Serial::Control::ENABLE_POS); 38 | #endif 39 | } 40 | -------------------------------------------------------------------------------- /unittest/bad/cmp_pos_diff.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void cmp_pos_diff() 27 | { 28 | #ifdef GOOD 29 | Serial::Control::ENABLE_POS == Serial::Control::RECV_POS; 30 | #else 31 | Serial::Control::ENABLE_POS == Timer::Control::ENABLE_POS; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/cmp_pos_same.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void cmp_pos_same() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::MODE_POS == Serial::Config::POLARITY_POS; 30 | #else 31 | Serial::Config::MODE_POS == Serial::Control::ENABLE_POS; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/copy.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void copy() 27 | { 28 | #ifdef GOOD 29 | Serial::config_t copy(serial2->config); 30 | #else 31 | Serial::control_t copy(serial2->config); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/copy_from_word.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | bool copy( 26 | Timer::control_t control) 27 | { 28 | return control.all(Timer::Control::CLOCK_SOURCE_PLL); 29 | } 30 | 31 | 32 | 33 | void copy_from_word() 34 | { 35 | #ifdef GOOD 36 | copy(Timer::control_t(0)); 37 | #else 38 | copy(0); 39 | #endif 40 | } 41 | -------------------------------------------------------------------------------- /unittest/bad/copy_shifted.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void copy_shifted() 27 | { 28 | Serial::config_t copy(serial2->config); 29 | 30 | #ifdef GOOD 31 | volatile uint32_t extracted = copy.shifted(Serial::Config::RXPORT_SHFT); 32 | #else 33 | volatile uint32_t 34 | extracted = copy.shifted(Timer::Prescale::PRESCALER_LOW_SHFT); 35 | #endif 36 | } 37 | -------------------------------------------------------------------------------- /unittest/bad/copy_shifted_op.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void copy_shifted_op() 27 | { 28 | Serial::config_t copy(serial2->config); 29 | 30 | #ifdef GOOD 31 | volatile uint32_t extracted = copy >> Serial::Config::RXPORT_SHFT; 32 | #else 33 | volatile uint32_t 34 | extracted = copy >> Timer::Prescale::PRESCALER_LOW_SHFT; 35 | #endif 36 | } 37 | -------------------------------------------------------------------------------- /unittest/bad/linux/Makefile: -------------------------------------------------------------------------------- 1 | # regbits: C++ templates for type-safe bit manipulation 2 | # Copyright (C) 2019,2020 Mark R. Rubin 3 | # 4 | # This file is part of regbits. 5 | # 6 | # The regbits program is free software: you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License as 8 | # published by the Free Software Foundation, either version 3 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # The regbits program is distributed in the hope that it will be 12 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public 17 | # License (LICENSE.txt) along with the regbits program. If not, see 18 | # 19 | 20 | 21 | CXX_STANDARD ?= c++11 22 | OPTIMIZE ?= -O1 23 | DEBUG ?= 24 | EXTRA_CXX ?= 25 | PERIPH_BASE ?= 0x100000 26 | 27 | SRCS = $(subst ../,,$(wildcard ../*.cxx)) 28 | OBJS = $(SRCS:.cxx=.o) 29 | 30 | unittest: $(OBJS) 31 | 32 | .PHONY: clean 33 | clean: 34 | rm -f *.o 35 | 36 | INCLUDES = -I../.. -I../../.. 37 | vpath %.cxx .. 38 | 39 | CXXOPTS = -Wall \ 40 | -std=$(CXX_STANDARD) \ 41 | $(OPTIMIZE) \ 42 | $(DEBUG) \ 43 | $(INCLUDES) \ 44 | $(EXTRA_CXX) \ 45 | -DREGBITS_PERIPH_BASE=$(PERIPH_BASE) 46 | 47 | 48 | %.o: %.cxx 49 | @ if $(CXX) -c $(CXXOPTS) -UGOOD $< -o $@ > /dev/null 2>&1 ; \ 50 | then \ 51 | echo "$< -UGOOD compiled but should have failed" ; \ 52 | fi ; \ 53 | rm -f $@ ; \ 54 | if ! $(CXX) -c $(CXXOPTS) -DGOOD $< -o $@ > /dev/null 2>&1 ; \ 55 | then \ 56 | echo "$< -DGOOD failed but should have compiled" ; \ 57 | fi \ 58 | -------------------------------------------------------------------------------- /unittest/bad/mskd_bits_assign.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_bits_assign() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::mskd_t mskd; 30 | mskd = Serial::Config::POLARITY; 31 | #else 32 | Serial::Config::mskd_t mskd; 33 | mskd = Serial::Control::ENABLE; 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /unittest/bad/mskd_bits_ctor.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_bits_assign() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::mskd_t mskd(Serial::Config::POLARITY); 30 | #else 31 | Serial::Config::mskd_t mskd(Serial::Control::ENABLE); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_copy_equ.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_copy_equ() 27 | { 28 | Timer::prescale_t copy(timer1->prescale); 29 | #ifdef GOOD 30 | copy.all(Timer::Prescale::PRESCALER_HIGH<13>()); 31 | #else 32 | copy.all(Timer::Control::CLOCK_SOURCE_PLL); 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /unittest/bad/mskd_copy_geq.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_copy_geq() 27 | { 28 | Timer::prescale_t copy(timer1->prescale); 29 | #ifdef GOOD 30 | copy >= Timer::Prescale::PRESCALER_HIGH<13>(); 31 | #else 32 | copy >= Timer::Control::CLOCK_SOURCE_PLL; 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /unittest/bad/mskd_copy_gtr.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_copy_gtr() 27 | { 28 | Timer::prescale_t copy(timer1->prescale); 29 | #ifdef GOOD 30 | copy > Timer::Prescale::PRESCALER_HIGH<13>(); 31 | #else 32 | copy > Timer::Control::CLOCK_SOURCE_PLL; 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /unittest/bad/mskd_copy_leq.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_copy_leq() 27 | { 28 | Timer::prescale_t copy(timer1->prescale); 29 | #ifdef GOOD 30 | copy <= Timer::Prescale::PRESCALER_HIGH<13>(); 31 | #else 32 | copy <= Timer::Control::CLOCK_SOURCE_PLL; 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /unittest/bad/mskd_copy_lss.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_copy_lss() 27 | { 28 | Timer::prescale_t copy(timer1->prescale); 29 | #ifdef GOOD 30 | copy < Timer::Prescale::PRESCALER_HIGH<13>(); 31 | #else 32 | copy < Timer::Control::CLOCK_SOURCE_PLL; 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /unittest/bad/mskd_copy_neq.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_copy_neq() 27 | { 28 | Timer::prescale_t copy(timer1->prescale); 29 | #ifdef GOOD 30 | copy.all(Timer::Prescale::PRESCALER_HIGH<13>()); 31 | #else 32 | copy.all(Timer::Control::CLOCK_SOURCE_PLL); 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /unittest/bad/mskd_equ.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_equ() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::DATALEN_16_BITS == Serial::Config::DATALEN_32_BITS; 30 | #else 31 | Serial::Config::DATALEN_16_BITS == Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_geq.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_geq() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::DATALEN_16_BITS >= Serial::Config::DATALEN_32_BITS; 30 | #else 31 | Serial::Config::DATALEN_16_BITS >= Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_gtr.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_gtr() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::DATALEN_16_BITS > Serial::Config::DATALEN_32_BITS; 30 | #else 31 | Serial::Config::DATALEN_16_BITS > Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_leq.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_leq() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::DATALEN_16_BITS <= Serial::Config::DATALEN_32_BITS; 30 | #else 31 | Serial::Config::DATALEN_16_BITS <= Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_lss.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_lss() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::DATALEN_16_BITS < Serial::Config::DATALEN_32_BITS; 30 | #else 31 | Serial::Config::DATALEN_16_BITS < Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_mskd_assign.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_mskd_assign() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::mskd_t mskd; 30 | mskd = Serial::Config::DATALEN_16_BITS; 31 | #else 32 | Serial::Config::mskd_t mskd; 33 | mskd = Timer::Control::CLOCK_SOURCE_PLL; 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /unittest/bad/mskd_mskd_ctor.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_mskd_ctor() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::mskd_t mskd(Serial::Config::DATALEN_16_BITS); 30 | #else 31 | Serial::Config::mskd_t mskd(Timer::Control::CLOCK_SOURCE_PLL); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_neq.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_neq() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::DATALEN_16_BITS != Serial::Config::DATALEN_32_BITS; 30 | #else 31 | Serial::Config::DATALEN_16_BITS != Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_or_mskd_diff.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_or_mskd_diff() 27 | { 28 | #ifdef GOOD 29 | Serial::Control::ENABLE | Serial::Control::RECV; 30 | #else 31 | Timer::Interrupts::TIMEOUT_POS | Timer::Control::CLOCK_SOURCE_EXTERN; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_or_mskd_same.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_or_mskd_diff() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::DATALEN_16_BITS | Serial::Config::PARITY_EVEN; 30 | #else 31 | Timer::Control::CLOCK_SOURCE_PLL | Timer::Prescale::PRESCALER_HIGH<1>(); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_range.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_range() 27 | { 28 | #ifdef GOOD 29 | timer1->prescale /= Timer::Prescale::PRESCALER_LOW<127>(); 30 | #else 31 | timer1->prescale /= Timer::Prescale::PRESCALER_LOW<128>(); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_reg_assign.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_reg_assign() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::mskd_t mskd; 30 | mskd = serial2->config; 31 | #else 32 | Serial::Config::mskd_t mskd; 33 | mskd = serial2->control; 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /unittest/bad/mskd_reg_ctor.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_reg_ctor() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::mskd_t mskd(serial2->config); 30 | #else 31 | Serial::Config::mskd_t mskd(serial2->control); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_reg_equ.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_reg_equ() 27 | { 28 | #ifdef GOOD 29 | timer1->prescale.all(Timer::Prescale::PRESCALER_HIGH<13>()); 30 | #else 31 | timer1->prescale.all(Timer::Control::CLOCK_SOURCE_PLL); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_reg_geq.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_reg_geq() 27 | { 28 | #ifdef GOOD 29 | timer1->prescale >= Timer::Prescale::PRESCALER_HIGH<13>(); 30 | #else 31 | timer1->prescale >= Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_reg_gtr.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_reg_gtr() 27 | { 28 | #ifdef GOOD 29 | timer1->prescale > Timer::Prescale::PRESCALER_HIGH<13>(); 30 | #else 31 | timer1->prescale > Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_reg_leq.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_reg_leq() 27 | { 28 | #ifdef GOOD 29 | timer1->prescale <= Timer::Prescale::PRESCALER_HIGH<13>(); 30 | #else 31 | timer1->prescale <= Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_reg_lss.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_reg_lss() 27 | { 28 | #ifdef GOOD 29 | timer1->prescale < Timer::Prescale::PRESCALER_HIGH<13>(); 30 | #else 31 | timer1->prescale < Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/mskd_reg_neq.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void mskd_reg_neq() 27 | { 28 | #ifdef GOOD 29 | timer1->prescale.all(Timer::Prescale::PRESCALER_HIGH<13>()); 30 | #else 31 | timer1->prescale.all(Timer::Control::CLOCK_SOURCE_PLL); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/pos_assign.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void pos_assign() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::pos_t polarity = Serial::Config::POLARITY_POS; 30 | #else 31 | Serial::Config::pos_t enable = Serial::Control::ENABLE_POS; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/pos_equ.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void pos_equ() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::ENDIAN_POS == Serial::Config::POLARITY_POS; 30 | #else 31 | Serial::Config::ENDIAN_POS == Serial::Control::ENABLE_POS; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/pos_neq.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void pos_neq() 27 | { 28 | #ifdef GOOD 29 | Serial::Config::ENDIAN_POS != Serial::Config::POLARITY_POS; 30 | #else 31 | Serial::Config::ENDIAN_POS != Serial::Control::ENABLE_POS; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/reg_bits_diff.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_bits_diff() 27 | { 28 | #ifdef GOOD 29 | timer1 ->control = Timer ::Control::ENABLE; 30 | #else 31 | serial2->control = Timer::Control::ENABLE; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/reg_bits_same.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_bits_same() 27 | { 28 | #ifdef GOOD 29 | serial2->config = Serial::Config::ENDIAN; 30 | #else 31 | serial2->config = Serial::Control::ENABLE; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/reg_clr_bits.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_clr_bits() 27 | { 28 | #ifdef GOOD 29 | serial2->control -= Serial::Control::ENABLE; 30 | #else 31 | serial2->control -= Timer::Control::ENABLE; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/reg_clr_mskd.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_clr_mskd() 27 | { 28 | #ifdef GOOD 29 | serial2->config -= Serial::Config::DATALEN_16_BITS; 30 | #else 31 | serial2->control -= Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/reg_flp_bits.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_flp_bits() 27 | { 28 | #ifdef GOOD 29 | serial2->control ^= Serial::Control::ENABLE; 30 | #else 31 | serial2->control ^= Timer::Control::ENABLE; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/reg_flp_mskd.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_flp_mskd() 27 | { 28 | #ifdef GOOD 29 | serial2->config ^= Serial::Config::DATALEN_16_BITS; 30 | #else 31 | serial2->control ^= Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/reg_ins_bits.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_ins_bits() 27 | { 28 | #ifdef GOOD 29 | serial2->control /= Serial::Control::ENABLE; 30 | #else 31 | serial2->control /= Timer::Control::ENABLE; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/reg_ins_mskd.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_ins_mskd() 27 | { 28 | #ifdef GOOD 29 | serial2->config /= Serial::Config::DATALEN_16_BITS; 30 | #else 31 | serial2->control /= Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/reg_mskd_diff.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_mskd_diff() 27 | { 28 | #ifdef GOOD 29 | timer1->control = Timer::Control::CLOCK_SOURCE_PLL; 30 | #else 31 | timer1->control = Serial::Config::DATALEN_16_BITS; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/reg_mskd_same.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_mskd_same() 27 | { 28 | #ifdef GOOD 29 | timer1->control = Timer::Control::CLOCK_SOURCE_PLL; 30 | #else 31 | timer1->control = Timer::Prescale::PRESCALER_HIGH<11>(); 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/reg_set_bits.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_set_bits() 27 | { 28 | #ifdef GOOD 29 | serial2->control |= Serial::Control::ENABLE; 30 | #else 31 | serial2->control |= Timer::Control::ENABLE; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/reg_set_mskd.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_set_mskd() 27 | { 28 | #ifdef GOOD 29 | serial2->config |= Serial::Config::DATALEN_16_BITS; 30 | #else 31 | serial2->control |= Timer::Control::CLOCK_SOURCE_PLL; 32 | #endif 33 | } 34 | -------------------------------------------------------------------------------- /unittest/bad/reg_shifted.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_shifted() 27 | { 28 | #ifdef GOOD 29 | volatile uint32_t 30 | extracted = serial2->config.shifted(Serial::Config::RXPORT_SHFT); 31 | #else 32 | volatile uint32_t 33 | extracted = serial2->config.shifted(Timer::Prescale::PRESCALER_LOW_SHFT); 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /unittest/bad/reg_shifted_op.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void reg_shifted_op() 27 | { 28 | #ifdef GOOD 29 | volatile uint32_t 30 | extracted = serial2->config >> Serial::Config::RXPORT_SHFT; 31 | #else 32 | volatile uint32_t 33 | extracted = serial2->config >> Timer::Prescale::PRESCALER_LOW_SHFT; 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /unittest/bad/shft_shft_assign.cxx: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include "mcu_regbits.hxx" 22 | 23 | using namespace mcu; 24 | 25 | 26 | void shft_shft_assign() 27 | { 28 | #ifdef GOOD 29 | Timer::Prescale::shft_t shft; 30 | shft = Timer::Prescale::PRESCALER_HIGH_SHFT; 31 | #else 32 | Timer::Prescale::shft_t shft; 33 | shft = Timer::Autoreload::AUTORELOADER_SHFT; 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /unittest/bitfield.gdb: -------------------------------------------------------------------------------- 1 | set logging file bitfield.out 2 | -------------------------------------------------------------------------------- /unittest/bitops.h: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #ifndef BITOPS_H 22 | #define BITOPS_H 23 | 24 | #define CHG_BITS(REGISTER, MASK, BITS) \ 25 | ((REGISTER) = ((REGISTER) & ~(MASK)) | (BITS)) 26 | 27 | #endif // #ifndef BITOPS_H 28 | -------------------------------------------------------------------------------- /unittest/do_tests.inl: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | do_test(zero_reg , serial2_config , testnum++); 22 | do_test(zero_array , serial2_config , testnum++); 23 | do_test(set_singl_bits_operator , serial2_config , testnum++); 24 | do_test(set_singl_bits_method , serial2_config , testnum++); 25 | do_test(clr_singl_bits_operator , serial2_config , testnum++); 26 | do_test(clr_singl_bits_method , serial2_config , testnum++); 27 | do_test(set_singl_mskd_operator , serial2_config , testnum++); 28 | do_test(set_singl_mskd_method , serial2_config , testnum++); 29 | do_test(clr_singl_mskd_operator , serial2_config , testnum++); 30 | do_test(clr_singl_mskd_method , serial2_config , testnum++); 31 | do_test(equ_singl_bits_operator , serial2_config , testnum++); 32 | do_test(equ_singl_bits_method , serial2_config , testnum++); 33 | do_test(equ_singl_mskd_operator , serial2_config , testnum++); 34 | do_test(equ_singl_mskd_method , serial2_config , testnum++); 35 | do_test(flp_singl_bits_operator , serial2_config , testnum++); 36 | do_test(flp_singl_bits_method , serial2_config , testnum++); 37 | do_test(flp_singl_mskd_operator , serial2_config , testnum++); 38 | do_test(flp_singl_mskd_method , serial2_config , testnum++); 39 | do_test(ins_singl_mskd_operator , serial2_config , testnum++); 40 | do_test(ins_singl_mskd_method , serial2_config , testnum++); 41 | do_test(set_multi_bits_operator , serial2_config , testnum++); 42 | do_test(set_multi_bits_method , serial2_config , testnum++); 43 | do_test(ins_multi_mskd_operator , serial2_config , testnum++); 44 | do_test(ins_multi_mskd_method , serial2_config , testnum++); 45 | do_test(equ_multi_bits_operator , serial2_config , testnum++); 46 | do_test(equ_multi_bits_method , serial2_config , testnum++); 47 | do_test(equ_multi_mskd_operator , serial2_config , testnum++); 48 | do_test(equ_multi_mskd_method , serial2_config , testnum++); 49 | do_test(equ_bits_mskd_operator , serial2_config , testnum++); 50 | do_test(equ_bits_mskd_method , serial2_config , testnum++); 51 | do_test(equ_mskd_bits_operator , serial2_config , testnum++); 52 | do_test(equ_mskd_bits_method , serial2_config , testnum++); 53 | do_test(equ_bits_var , serial2_config , testnum++); 54 | do_test(equ_mskd_var , serial2_config , testnum++); 55 | do_test(cmp_equ_zero , serial2_config , testnum++); 56 | do_test(cmp_neq_zero , serial2_config , testnum++); 57 | do_test(cmp_equ_bits , serial2_config , testnum++); 58 | do_test(cmp_neq_bits , timer1_prescale, testnum++); 59 | do_test(cmp_equ_multi_bits , timer1_prescale, testnum++); 60 | do_test(cmp_neq_multi_bits , timer1_prescale, testnum++); 61 | do_test(cmp_equ_mskd , serial2_config , testnum++); 62 | do_test(cmp_neq_mskd , serial2_config , testnum++); 63 | do_test(cmp_equ_reg , serial2_config , testnum++); 64 | do_test(cmp_neq_reg , serial2_config , testnum++); 65 | do_test(constexpr_bits_array , serial2_config , testnum++); 66 | do_test(runtime_bits_array , gpio1_words_3 , testnum++); 67 | do_test(call_bits_val_const , serial2_config , testnum++); 68 | do_test(call_bits_val_var , serial2_config , testnum++); 69 | do_test(call_bits_val_zero , serial2_config , testnum++); 70 | do_test(call_bits_ref_const , serial2_config , testnum++); 71 | do_test(call_bits_ref_var , serial2_config , testnum++); 72 | do_test(call_bits_ref_zero , serial2_config , testnum++); 73 | do_test(call_mskd_val_const , serial2_config , testnum++); 74 | do_test(call_mskd_val_var , serial2_config , testnum++); 75 | do_test(call_mskd_ref_const , serial2_config , testnum++); 76 | do_test(call_mskd_ref_var , serial2_config , testnum++); 77 | do_test(call_periph_bits , serial2_config , testnum++); 78 | do_test(call_periph_bits_val , serial2_config , testnum++); 79 | do_test(call_reg_bits_val , serial2_config , testnum++); 80 | do_test(call_periph_bits_ref , serial2_config , testnum++); 81 | do_test(call_reg_bits_ref , serial2_config , testnum++); 82 | do_test(call_periph_mskd , serial2_config , testnum++); 83 | do_test(call_periph_mskd_val , serial2_config , testnum++); 84 | do_test(call_reg_mskd_val , serial2_config , testnum++); 85 | do_test(call_periph_mskd_ref , serial2_config , testnum++); 86 | do_test(call_reg_mskd_ref , serial2_config , testnum++); 87 | do_test(call_return_bits , timer1_prescale, testnum++); 88 | do_test(call_return_mskd , timer1_prescale, testnum++); 89 | do_test(call_return_reg , timer1_prescale, testnum++); 90 | do_test(call_return_periph , serial2_config , testnum++); 91 | do_test(call_pos_val , gpio1_words_3 , testnum++); 92 | do_test(call_pos_ref , gpio1_words_3 , testnum++); 93 | do_test(call_range_val_port , serial2_config , testnum++); 94 | do_test(call_range_ref_port , serial2_config , testnum++); 95 | do_test(prescaler_low , gpio1_words_3 , testnum++); 96 | do_test(prescaler_high , gpio1_words_3 , testnum++); 97 | do_test(reg_mskd_lss , serial2_config , testnum++); 98 | do_test(reg_mskd_leq , serial2_config , testnum++); 99 | do_test(reg_mskd_gtr , serial2_config , testnum++); 100 | do_test(reg_mskd_geq , serial2_config , testnum++); 101 | do_test(pos_cmp_eq , serial2_config , testnum++); 102 | do_test(pos_cmp_ne , serial2_config , testnum++); 103 | do_test(bits_extract_eq , serial2_config , testnum++); 104 | do_test(bits_extract_eq , serial2_config , testnum++); 105 | do_test(mskd_extract_eq , serial2_config , testnum++); 106 | do_test(mskd_extract_ne , serial2_config , testnum++); 107 | do_test(mskd_extract_lss , serial2_config , testnum++); 108 | do_test(mskd_extract_leq , serial2_config , testnum++); 109 | do_test(mskd_extract_gtr , serial2_config , testnum++); 110 | do_test(mskd_extract_leq , serial2_config , testnum++); 111 | do_test(set_bits_global , serial2_config , testnum++); 112 | do_test(ins_mskd_global , serial2_config , testnum++); 113 | do_test(assign_array_global , gpio1_words_3 , testnum++); 114 | do_test(shifted_global , gpio1_words_3 , testnum++); 115 | do_test(assign_register_global , serial2_config , testnum++); 116 | do_test(call_pos_val_global , gpio1_words_3 , testnum++); 117 | do_test(call_pos_ref_global , gpio1_words_3 , testnum++); 118 | do_test(call_bits_val_global , serial2_config , testnum++); 119 | do_test(call_bits_ref_global , serial2_config , testnum++); 120 | do_test(call_mskd_val_global , serial2_config , testnum++); 121 | do_test(call_mskd_ref_global , serial2_config , testnum++); 122 | do_test(call_shifted_const_val , gpio1_words_3 , testnum++); 123 | do_test(call_shifted_var_val , gpio1_words_3 , testnum++); 124 | do_test(call_shifted_global_val , gpio1_words_3 , testnum++); 125 | do_test(call_shifted_const_ref , gpio1_words_3 , testnum++); 126 | do_test(call_shifted_var_ref , gpio1_words_3 , testnum++); 127 | do_test(call_shifted_global_ref , gpio1_words_3 , testnum++); 128 | do_test(copy_bits_equ , serial2_config , testnum++); 129 | do_test(copy_bits_neq , serial2_config , testnum++); 130 | do_test(copy_mskd_equ , serial2_config , testnum++); 131 | do_test(copy_mskd_neq , serial2_config , testnum++); 132 | do_test(copy_mskd_lss , serial2_config , testnum++); 133 | do_test(copy_mskd_leq , serial2_config , testnum++); 134 | do_test(copy_mskd_gtr , serial2_config , testnum++); 135 | do_test(copy_mskd_geq , serial2_config , testnum++); 136 | do_test(copy_shifted , serial2_config , testnum++); 137 | do_test(call_copy_bits_val , serial2_config , testnum++); 138 | do_test(call_copy_bits_ref , serial2_config , testnum++); 139 | -------------------------------------------------------------------------------- /unittest/linux/Makefile: -------------------------------------------------------------------------------- 1 | # regbits: C++ templates for type-safe bit manipulation 2 | # Copyright (C) 2019,2020 Mark R. Rubin 3 | # 4 | # This file is part of regbits. 5 | # 6 | # The regbits program is free software: you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License as 8 | # published by the Free Software Foundation, either version 3 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # The regbits program is distributed in the hope that it will be 12 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public 17 | # License (LICENSE.txt) along with the regbits program. If not, see 18 | # 19 | 20 | 21 | CXX_STANDARD ?= c++11 22 | OPTIMIZE ?= -O1 23 | DEBUG ?= -g3 24 | GCC_ARM_BUG ?= -DGCC_ARM_BUG 25 | EXTRA_CC ?= 26 | EXTRA_CXX ?= 27 | PERIPH_BASE ?= 0x700000 28 | BRK ?= 0x800000 29 | BRK_MALLOC ?= -DUSE_BRK 30 | 31 | C_ELFS = $(subst ../,,$(wildcard ../*.c)) 32 | CXX_ELFS = $(subst ../,,$(wildcard ../*.cxx)) 33 | ELFS = $(subst .c,.elf,$(C_ELFS)) $(subst .cxx,.elf,$(CXX_ELFS)) 34 | DMPS = $(subst .elf,.elf.dmp,$(ELFS)) $(subst .elf,.o.dmp,$(ELFS)) 35 | OUTS = $(subst .elf,.out,$(ELFS)) 36 | 37 | unittest: main.o ../do_tests.inl $(ELFS) $(DMPS) $(OUTS) 38 | @ ../unittest.py intel '$(OPTIMIZE) $(DEBUG) $(GCC_ARM_BUG) $(EXTRA_CXX) $(CXX_STANDARD)' ../do_tests.inl *.out *.o.dmp > results.txt 39 | 40 | # manual check that all tests change at least one tracked register 41 | uniq: regbits.out 42 | uniq -f 1 --group regbits.out 43 | 44 | .PHONY: clean cleanbin 45 | clean: cleanbin 46 | @ rm -f *.dmp *.out results.txt 47 | cleanbin: 48 | @ rm -f *.o *.elf 49 | 50 | 51 | .PRECIOUS: %.o %.elf 52 | 53 | INCLUDES = -I.. -I../.. 54 | vpath %c .. 55 | vpath %cxx .. 56 | 57 | CCOPTS = -Wall \ 58 | -Wno-unused-const-variable \ 59 | $(OPTIMIZE) \ 60 | $(DEBUG) \ 61 | $(INCLUDES) \ 62 | $(EXTRA_CC) \ 63 | -DBRK=$(BRK) \ 64 | $(BRK_MALLOC) \ 65 | -DREGBITS_PERIPH_BASE=$(PERIPH_BASE) 66 | 67 | CXXOPTS = -Wall \ 68 | -std=$(CXX_STANDARD) \ 69 | $(OPTIMIZE) \ 70 | $(DEBUG) \ 71 | $(INCLUDES) \ 72 | $(GCC_ARM_BUG) \ 73 | $(EXTRA_CXX) \ 74 | -DREGBITS_PERIPH_BASE=$(PERIPH_BASE) 75 | 76 | 77 | 78 | %.elf: %.o main.o 79 | @ $(CXX) -o $@ $^ 80 | 81 | %.elf.dmp: %.elf 82 | @ objdump -dC -j.text -j.rodata -j.data $< > $@ 83 | 84 | %.out: %.elf 85 | @ rm -f $@ 86 | @ gdb -q -x ../$(subst .elf,.gdb,$^) -x unittest.gdb $< > /dev/null 87 | 88 | %.o.dmp: %.o 89 | @ objdump -dC -j.text -j.rodata -j.data $< > $@ 90 | 91 | %.o: %.c 92 | @ $(CC) -c $(CCOPTS) $< -o $@ 93 | 94 | %.o: %.cxx 95 | @ $(CXX) -c $(CXXOPTS) $< -o $@ 96 | -------------------------------------------------------------------------------- /unittest/linux/bitfield.out: -------------------------------------------------------------------------------- 1 | size: 10705 2 | repeats: 100000 3 | time: 0.110524524 4 | 0 00000000 00000000 5 | 1 00000000 ffffffff 6 | 2 00000040 ffffffff 7 | 3 00000040 ffffffff 8 | 4 00000000 ffffffbf 9 | 5 00000000 ffffffbf 10 | 6 00000002 ffffffff 11 | 7 00000002 ffffffff 12 | 8 00000000 fffffffd 13 | 9 00000000 fffffffd 14 | 10 00000040 00000040 15 | 11 00000040 00000040 16 | 12 00000002 00000002 17 | 13 00000002 00000002 18 | 14 00000040 ffffffbf 19 | 15 00000040 ffffffbf 20 | 16 00000002 fffffffd 21 | 17 00000002 fffffffd 22 | 18 00000004 fffffffd 23 | 19 00000004 fffffffd 24 | 20 00000021 ffffffff 25 | 21 00000021 ffffffff 26 | 22 00000182 fffff1fb 27 | 23 00000182 fffff1fb 28 | 24 00000060 00000060 29 | 25 00000060 00000060 30 | 26 00000308 00000308 31 | 27 00000308 00000308 32 | 28 00000022 00000022 33 | 29 00000022 00000022 34 | 30 00000044 00000044 35 | 31 00000044 00000044 36 | 32 00000001 00000001 37 | 33 00000180 00000180 38 | 34 00000000 00000000 39 | 35 00000020 00000020 40 | 36 00000040 00000040 41 | 37 00000000 ffffffff 42 | 38 22000000 22000000 43 | 39 3e000000 3e000000 44 | 40 0001d000 0001d000 45 | 41 0001d004 0001d004 46 | 42 00000022 00000022 47 | 43 00000020 00000020 48 | 44 00000000 ffffffff 49 | 45 00000021 00000021 50 | 46 00000040 00000040 51 | 47 00000040 00000040 52 | 48 00000000 00000000 53 | 49 00000001 00000001 54 | 50 00000001 00000001 55 | 51 00000000 00000000 56 | 52 00000002 fffffffb 57 | 53 00000002 fffffffb 58 | 54 00000004 fffffffd 59 | 55 00000002 fffffffb 60 | 56 00000040 ffffffff 61 | 57 00000040 ffffffff 62 | 58 00000040 ffffffff 63 | 59 00000040 ffffffff 64 | 60 00000040 ffffffff 65 | 61 00000002 fffffffb 66 | 62 00000002 fffffffb 67 | 63 00000002 fffffffb 68 | 64 00000002 fffffffb 69 | 65 00000002 fffffffb 70 | 66 2a000000 2a000000 71 | 67 22000000 22000000 72 | 68 1e000000 1e000000 73 | 69 00000040 00000040 74 | 70 00000044 00000044 75 | 71 00000066 00000066 76 | 72 0001f000 ffffffff 77 | 73 0000c000 fffecfff 78 | 74 00000077 00000077 79 | 75 0000001d 0000001d 80 | 76 00000002 00000002 81 | 77 00000002 00000002 82 | 78 00000002 00000002 83 | 79 00000002 00000002 84 | 80 00000002 00000002 85 | 81 00000002 00000002 86 | 82 00000002 00000002 87 | 83 00000002 00000002 88 | 84 00000020 00000020 89 | 85 00000040 00000040 90 | 86 00000020 00000020 91 | 87 00000020 00000020 92 | 88 00000020 00000020 93 | 89 00000020 00000020 94 | 90 00000040 ffffffff 95 | 91 00000002 fffffffb 96 | 92 000000bd 000000bd 97 | 93 00000017 00000017 98 | 94 00000004 00000004 99 | 95 00000044 00000044 100 | 96 00000077 00000077 101 | 97 00000040 00000040 102 | 98 00000040 00000040 103 | 99 00000002 fffffffb 104 | 100 00000002 fffffffb 105 | 101 00000017 00000017 106 | 102 00000017 00000017 107 | 103 00000017 00000017 108 | 104 00000017 00000017 109 | 105 00000017 00000017 110 | 106 00000017 00000017 111 | 107 00000002 00000002 112 | 108 00000004 00000004 113 | 109 00000002 00000002 114 | 110 00000004 00000004 115 | 111 00000002 00000002 116 | 112 00000002 00000002 117 | 113 00000002 00000002 118 | 114 00000002 00000002 119 | 115 00000002 00000002 120 | -------------------------------------------------------------------------------- /unittest/linux/main.c: -------------------------------------------------------------------------------- 1 | // regbits: C++ templates for type-safe bit manipulation 2 | // Copyright (C) 2019 Mark R. Rubin 3 | // 4 | // This file is part of regbits. 5 | // 6 | // The regbits program is free software: you can redistribute it and/or 7 | // modify it under the terms of the GNU General Public License as 8 | // published by the Free Software Foundation, either version 3 of the 9 | // License, or (at your option) any later version. 10 | // 11 | // The regbits program is distributed in the hope that it will be 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | // General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public 17 | // License (LICENSE.txt) along with the regbits program. If not, see 18 | // 19 | 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | extern void run(); 30 | 31 | 32 | #define NUM_TESTS_DEFINE 116 33 | 34 | static const unsigned NUM_TESTS = NUM_TESTS_DEFINE, 35 | REPEATS = 100000 ; 36 | 37 | uint32_t results[NUM_TESTS_DEFINE * 2]; 38 | 39 | 40 | 41 | 42 | void do_test( 43 | void (*test)(), 44 | volatile uint32_t* const regster, 45 | const uint32_t testnum) 46 | { 47 | *regster = 0x00000000; 48 | test(); 49 | results[testnum * 2] = *regster; 50 | 51 | *regster = 0xffffffff; 52 | test(); 53 | results[testnum * 2 + 1] = *regster; 54 | } 55 | 56 | 57 | 58 | 59 | 60 | int main() 61 | { 62 | if (brk((void*)BRK) != 0) { 63 | fprintf(stdout, 64 | "brk(0x%x) failed: %s(%d)\n", 65 | BRK, 66 | strerror(errno), 67 | errno); 68 | return 1; 69 | } 70 | 71 | struct timespec start, 72 | finish; 73 | unsigned repeat; 74 | 75 | clock_gettime(CLOCK_REALTIME, &start); 76 | for (repeat = 0 ; repeat < REPEATS ; ++repeat) run(); 77 | clock_gettime(CLOCK_REALTIME, &finish); 78 | 79 | goto exit; // silence compiler warning 80 | exit: return 0; // for GDB breakpoint 81 | } 82 | -------------------------------------------------------------------------------- /unittest/linux/raw.out: -------------------------------------------------------------------------------- 1 | size: 6652 2 | repeats: 100000 3 | time: 0.084844969 4 | 0 00000000 00000000 5 | 1 00000000 ffffffff 6 | 2 00000040 ffffffff 7 | 3 00000040 ffffffff 8 | 4 00000000 ffffffbf 9 | 5 00000000 ffffffbf 10 | 6 00000002 ffffffff 11 | 7 00000002 ffffffff 12 | 8 00000000 fffffffd 13 | 9 00000000 fffffffd 14 | 10 00000040 00000040 15 | 11 00000040 00000040 16 | 12 00000002 00000002 17 | 13 00000002 00000002 18 | 14 00000040 ffffffbf 19 | 15 00000040 ffffffbf 20 | 16 00000002 fffffffd 21 | 17 00000002 fffffffd 22 | 18 00000004 fffffffd 23 | 19 00000004 fffffffd 24 | 20 00000021 ffffffff 25 | 21 00000021 ffffffff 26 | 22 00000182 fffff1fb 27 | 23 00000182 fffff1fb 28 | 24 00000060 00000060 29 | 25 00000060 00000060 30 | 26 00000308 00000308 31 | 27 00000308 00000308 32 | 28 00000022 00000022 33 | 29 00000022 00000022 34 | 30 00000044 00000044 35 | 31 00000044 00000044 36 | 32 00000001 00000001 37 | 33 00000180 00000180 38 | 34 00000000 00000000 39 | 35 00000020 00000020 40 | 36 00000040 00000040 41 | 37 00000000 ffffffff 42 | 38 22000000 22000000 43 | 39 3e000000 3e000000 44 | 40 0001d000 0001d000 45 | 41 0001d004 0001d004 46 | 42 00000022 00000022 47 | 43 00000020 00000020 48 | 44 00000000 ffffffff 49 | 45 00000021 00000021 50 | 46 00000040 00000040 51 | 47 00000040 00000040 52 | 48 00000000 00000000 53 | 49 00000001 00000001 54 | 50 00000001 00000001 55 | 51 00000000 00000000 56 | 52 00000002 fffffffb 57 | 53 00000002 fffffffb 58 | 54 00000004 fffffffd 59 | 55 00000002 fffffffb 60 | 56 00000040 ffffffff 61 | 57 00000040 ffffffff 62 | 58 00000040 ffffffff 63 | 59 00000040 ffffffff 64 | 60 00000040 ffffffff 65 | 61 00000002 fffffffb 66 | 62 00000002 fffffffb 67 | 63 00000002 fffffffb 68 | 64 00000002 fffffffb 69 | 65 00000002 fffffffb 70 | 66 2a000000 2a000000 71 | 67 22000000 22000000 72 | 68 1e000000 1e000000 73 | 69 00000040 00000040 74 | 70 00000044 00000044 75 | 71 00000066 00000066 76 | 72 0001f000 ffffffff 77 | 73 0000c000 fffecfff 78 | 74 00000077 00000077 79 | 75 0000001d 0000001d 80 | 76 00000002 00000002 81 | 77 00000002 00000002 82 | 78 00000002 00000002 83 | 79 00000002 00000002 84 | 80 00000002 00000002 85 | 81 00000002 00000002 86 | 82 00000002 00000002 87 | 83 00000002 00000002 88 | 84 00000020 00000020 89 | 85 00000040 00000040 90 | 86 00000020 00000020 91 | 87 00000020 00000020 92 | 88 00000020 00000020 93 | 89 00000020 00000020 94 | 90 00000040 ffffffff 95 | 91 00000002 fffffffb 96 | 92 000000bd 000000bd 97 | 93 00000017 00000017 98 | 94 00000004 00000004 99 | 95 00000044 00000044 100 | 96 00000077 00000077 101 | 97 00000040 00000040 102 | 98 00000040 00000040 103 | 99 00000002 fffffffb 104 | 100 00000002 fffffffb 105 | 101 00000017 00000017 106 | 102 00000017 00000017 107 | 103 00000017 00000017 108 | 104 00000017 00000017 109 | 105 00000017 00000017 110 | 106 00000017 00000017 111 | 107 00000002 00000002 112 | 108 00000004 00000004 113 | 109 00000002 00000002 114 | 110 00000004 00000004 115 | 111 00000002 00000002 116 | 112 00000002 00000002 117 | 113 00000002 00000002 118 | 114 00000002 00000002 119 | 115 00000002 00000002 120 | -------------------------------------------------------------------------------- /unittest/linux/regbits.out: -------------------------------------------------------------------------------- 1 | size: 6967 2 | repeats: 100000 3 | time: 0.089070258 4 | 0 00000000 00000000 5 | 1 00000000 ffffffff 6 | 2 00000040 ffffffff 7 | 3 00000040 ffffffff 8 | 4 00000000 ffffffbf 9 | 5 00000000 ffffffbf 10 | 6 00000002 ffffffff 11 | 7 00000002 ffffffff 12 | 8 00000000 fffffffd 13 | 9 00000000 fffffffd 14 | 10 00000040 00000040 15 | 11 00000040 00000040 16 | 12 00000002 00000002 17 | 13 00000002 00000002 18 | 14 00000040 ffffffbf 19 | 15 00000040 ffffffbf 20 | 16 00000002 fffffffd 21 | 17 00000002 fffffffd 22 | 18 00000004 fffffffd 23 | 19 00000004 fffffffd 24 | 20 00000021 ffffffff 25 | 21 00000021 ffffffff 26 | 22 00000182 fffff1fb 27 | 23 00000182 fffff1fb 28 | 24 00000060 00000060 29 | 25 00000060 00000060 30 | 26 00000308 00000308 31 | 27 00000308 00000308 32 | 28 00000022 00000022 33 | 29 00000022 00000022 34 | 30 00000044 00000044 35 | 31 00000044 00000044 36 | 32 00000001 00000001 37 | 33 00000180 00000180 38 | 34 00000000 00000000 39 | 35 00000020 00000020 40 | 36 00000040 00000040 41 | 37 00000000 ffffffff 42 | 38 22000000 22000000 43 | 39 3e000000 3e000000 44 | 40 0001d000 0001d000 45 | 41 0001d004 0001d004 46 | 42 00000022 00000022 47 | 43 00000020 00000020 48 | 44 00000000 ffffffff 49 | 45 00000021 00000021 50 | 46 00000040 00000040 51 | 47 00000040 00000040 52 | 48 00000000 00000000 53 | 49 00000001 00000001 54 | 50 00000001 00000001 55 | 51 00000000 00000000 56 | 52 00000002 fffffffb 57 | 53 00000002 fffffffb 58 | 54 00000004 fffffffd 59 | 55 00000002 fffffffb 60 | 56 00000040 ffffffff 61 | 57 00000040 ffffffff 62 | 58 00000040 ffffffff 63 | 59 00000040 ffffffff 64 | 60 00000040 ffffffff 65 | 61 00000002 fffffffb 66 | 62 00000002 fffffffb 67 | 63 00000002 fffffffb 68 | 64 00000002 fffffffb 69 | 65 00000002 fffffffb 70 | 66 2a000000 2a000000 71 | 67 22000000 22000000 72 | 68 1e000000 1e000000 73 | 69 00000040 00000040 74 | 70 00000044 00000044 75 | 71 00000066 00000066 76 | 72 0001f000 ffffffff 77 | 73 0000c000 fffecfff 78 | 74 00000077 00000077 79 | 75 0000001d 0000001d 80 | 76 00000002 00000002 81 | 77 00000002 00000002 82 | 78 00000002 00000002 83 | 79 00000002 00000002 84 | 80 00000002 00000002 85 | 81 00000002 00000002 86 | 82 00000002 00000002 87 | 83 00000002 00000002 88 | 84 00000020 00000020 89 | 85 00000040 00000040 90 | 86 00000020 00000020 91 | 87 00000020 00000020 92 | 88 00000020 00000020 93 | 89 00000020 00000020 94 | 90 00000040 ffffffff 95 | 91 00000002 fffffffb 96 | 92 000000bd 000000bd 97 | 93 00000017 00000017 98 | 94 00000004 00000004 99 | 95 00000044 00000044 100 | 96 00000077 00000077 101 | 97 00000040 00000040 102 | 98 00000040 00000040 103 | 99 00000002 fffffffb 104 | 100 00000002 fffffffb 105 | 101 00000017 00000017 106 | 102 00000017 00000017 107 | 103 00000017 00000017 108 | 104 00000017 00000017 109 | 105 00000017 00000017 110 | 106 00000017 00000017 111 | 107 00000002 00000002 112 | 108 00000004 00000004 113 | 109 00000002 00000002 114 | 110 00000004 00000004 115 | 111 00000002 00000002 116 | 112 00000002 00000002 117 | 113 00000002 00000002 118 | 114 00000002 00000002 119 | 115 00000002 00000002 120 | -------------------------------------------------------------------------------- /unittest/linux/results.txt: -------------------------------------------------------------------------------- 1 | 2 | compile: -O1 -g3 -DGCC_ARM_BUG c++11 3 | regbits struct raw bitfield 4 | 0 * .rodata 5 | 12 * 12 * 12 * 12 * assign_array_global 6 | 12 * 12 * 12 * 32 assign_register_global 7 | 47 * 47 * 47 * 81 bits_extract_eq 8 | 47 * 47 * 47 * 81 bits_extract_ne 9 | 10 * 10 * 10 * 202 bits_ref 10 | 8 * 8 * 8 * 163 bits_val 11 | 26 * 26 * 26 * 38 call_bits_ref_const 12 | 26 * 26 * 26 * 38 call_bits_ref_global 13 | 26 * 26 * 26 * 38 call_bits_ref_var 14 | 26 * 26 * 26 * 38 call_bits_ref_zero 15 | 12 * 12 * 12 * 17 call_bits_val_const 16 | 12 * 12 * 12 * 17 call_bits_val_global 17 | 12 * 12 * 12 * 17 call_bits_val_var 18 | 12 * 12 * 12 * 17 call_bits_val_zero 19 | 41 * 41 * 41 * 65 call_copy_bits_ref 20 | 25 * 25 * 25 * 49 call_copy_bits_val 21 | 33 * 33 * 33 * 38 call_mskd_ref_const 22 | 33 * 33 * 33 * 38 call_mskd_ref_global 23 | 33 * 33 * 33 * 38 call_mskd_ref_var 24 | 17 * 32 32 32 call_mskd_val_const 25 | 17 * 17 * 17 * 17 * call_mskd_val_global 26 | 17 * 32 32 32 call_mskd_val_var 27 | 12 * 12 * 12 * 12 * call_periph_bits 28 | 31 * 31 * 31 * 31 * call_periph_bits_ref 29 | 17 * 17 * 17 * 17 * call_periph_bits_val 30 | 12 * 12 * 12 * 12 * call_periph_mskd 31 | 22 * 38 38 31 call_periph_mskd_ref 32 | 22 22 22 17 * call_periph_mskd_val 33 | 43 34 * 34 * 36 call_pos_ref 34 | 26 24 * 24 * 26 call_pos_ref_global 35 | 22 * 22 * 22 * 22 * call_pos_val 36 | 12 * 12 * 12 * 12 * call_pos_val_global 37 | 21 * 39 39 23 call_range_ref 38 | 12 * 12 * 12 * 12 * call_range_ref_port 39 | 21 23 23 11 * call_range_val 40 | 12 * 12 * 12 * 12 * call_range_val_port 41 | 31 * 31 * 31 * 31 * call_reg_bits_ref 42 | 17 * 17 * 17 * 17 * call_reg_bits_val 43 | 22 * 38 38 31 call_reg_mskd_ref 44 | 22 22 22 17 * call_reg_mskd_val 45 | 34 * 39 39 71 call_return_bits 46 | 43 * 62 62 99 call_return_mskd 47 | 37 * 42 42 67 call_return_periph 48 | 36 * 41 41 77 call_return_reg 49 | 33 33 33 26 * call_shifted_const_ref 50 | 17 17 17 12 * call_shifted_const_val 51 | 33 33 33 26 * call_shifted_global_ref 52 | 17 17 17 12 * call_shifted_global_val 53 | 33 33 33 26 * call_shifted_var_ref 54 | 17 17 17 12 * call_shifted_var_val 55 | 29 * 29 * 29 * 29 * check_array_range_fail 56 | 29 * 29 * 29 * 29 * check_array_range_pass 57 | 29 * 29 * 29 * 29 * check_bits_range_fail 58 | 29 * 29 * 29 * 29 * check_bits_range_pass 59 | 29 * 29 * 29 * 29 * check_mskd_range_fail 60 | 29 * 29 * 29 * 29 * check_mskd_range_pass 61 | 18 * 18 * 18 * 18 * clr_singl_bits_method 62 | 18 * 18 * 18 * 18 * clr_singl_bits_operator 63 | 18 * 18 * 18 * 39 clr_singl_mskd_method 64 | 18 * 18 * 18 * 39 clr_singl_mskd_operator 65 | 46 * 46 * 46 * 92 cmp_equ_bits 66 | 80 * 80 * 80 * 103 cmp_equ_mskd 67 | 50 * 50 * 50 * 145 cmp_equ_multi_bits 68 | 47 * 47 * 47 * 224 cmp_equ_reg 69 | 46 * 46 * 46 * 83 cmp_equ_zero 70 | 46 * 46 * 46 * 103 cmp_neq_bits 71 | 69 * 69 * 69 * 92 cmp_neq_mskd 72 | 50 * 50 * 50 * 140 cmp_neq_multi_bits 73 | 47 * 47 * 47 * 213 cmp_neq_reg 74 | 46 * 46 * 46 * 61 cmp_neq_zero 75 | 23 * 23 * 23 * 40 constexpr_bits_array 76 | 46 * 46 * 46 * 95 copy_bits_equ 77 | 46 * 46 * 46 * 95 copy_bits_neq 78 | 29 * 29 * 29 * 58 copy_bits_ref 79 | 30 * 30 * 30 * 58 copy_bits_val 80 | 54 * 54 * 54 * 106 copy_mskd_equ 81 | 54 * 54 * 54 * 106 copy_mskd_geq 82 | 54 * 54 * 54 * 106 copy_mskd_gtr 83 | 54 * 54 * 54 * 106 copy_mskd_leq 84 | 54 * 54 * 54 * 106 copy_mskd_lss 85 | 54 * 54 * 54 * 106 copy_mskd_neq 86 | 53 * 53 * 53 * 106 copy_shifted 87 | 12 * 12 * 12 * 49 equ_bits_mskd_method 88 | 12 * 12 * 12 * 49 equ_bits_mskd_operator 89 | 23 * 23 * 23 * 57 equ_bits_var 90 | 12 * 12 * 12 * 49 equ_mskd_bits_method 91 | 12 * 12 * 12 * 49 equ_mskd_bits_operator 92 | 23 * 23 * 23 * 67 equ_mskd_var 93 | 12 * 12 * 12 * 46 equ_multi_bits_method 94 | 12 * 12 * 12 * 46 equ_multi_bits_operator 95 | 12 * 12 * 12 * 54 equ_multi_mskd_method 96 | 12 * 12 * 12 * 54 equ_multi_mskd_operator 97 | 12 * 12 * 12 * 29 equ_singl_bits_method 98 | 12 * 12 * 12 * 29 equ_singl_bits_operator 99 | 12 * 12 * 12 * 32 equ_singl_mskd_method 100 | 12 * 12 * 12 * 32 equ_singl_mskd_operator 101 | 18 * 18 * 18 * 43 flp_singl_bits_method 102 | 18 * 18 * 18 * 43 flp_singl_bits_operator 103 | 18 * 18 * 18 * 39 flp_singl_mskd_method 104 | 18 * 18 * 18 * 39 flp_singl_mskd_operator 105 | 21 * 21 * 21 * 21 * ins_mskd_global 106 | 25 * 25 * 25 * 45 ins_multi_mskd_method 107 | 25 * 25 * 25 * 45 ins_multi_mskd_operator 108 | 21 * 21 * 21 * 21 * ins_singl_mskd_method 109 | 21 * 21 * 21 * 21 * ins_singl_mskd_operator 110 | 47 * 50 50 83 mskd_extract_eq 111 | 49 * 54 54 112 mskd_extract_geq 112 | 49 * 54 54 99 mskd_extract_gtr 113 | 49 * 54 54 112 mskd_extract_leq 114 | 49 * 54 54 99 mskd_extract_lss 115 | 47 * 50 50 94 mskd_extract_ne 116 | 24 * 24 * 24 * 436 mskd_ref 117 | 27 21 * 21 * 338 mskd_val 118 | 10 * 10 * 10 * 10 * periph_bits 119 | 9 * 9 * 9 * 16 periph_bits_ref 120 | 9 * 9 * 9 * 16 periph_bits_val 121 | 13 * 13 * 13 * 13 * periph_mskd 122 | 19 16 * 16 * 19 periph_mskd_ref 123 | 19 13 * 13 * 19 periph_mskd_val 124 | 12 * 12 * 12 * 32 pos_cmp_eq 125 | 12 * 12 * 12 * 32 pos_cmp_ne 126 | 48 47 * 47 * 48 pos_ref 127 | 46 * 48 48 46 * pos_val 128 | 32 * 32 * 32 * 46 prescaler_high 129 | 29 * 29 * 29 * 42 prescaler_low 130 | 7 * 7 * 7 * 14 reg_bits_ref 131 | 7 * 7 * 7 * 14 reg_bits_val 132 | 73 * 73 * 73 * 113 reg_mskd_geq 133 | 54 * 54 * 54 * 95 reg_mskd_gtr 134 | 73 * 73 * 73 * 113 reg_mskd_leq 135 | 54 * 54 * 54 * 95 reg_mskd_lss 136 | 17 14 * 14 * 17 reg_mskd_ref 137 | 17 11 * 11 * 17 reg_mskd_val 138 | 6 * 6 * 6 * 6 * return_bits 139 | 11 * 13 13 13 return_mskd 140 | 17 * 17 * 17 * 34 return_periph 141 | 17 * 17 * 17 * 34 return_reg 142 | 2782 2369 * 2369 * 2369 * run 143 | 25 * 29 25 * 29 runtime_bits_array 144 | 27 24 * 24 * 32 runtime_range_ref 145 | 27 21 * 21 * 31 runtime_range_val 146 | 18 * 18 * 18 * 18 * set_bits_global 147 | 18 * 18 * 18 * 35 set_multi_bits_method 148 | 18 * 18 * 18 * 35 set_multi_bits_operator 149 | 18 * 18 * 18 * 18 * set_singl_bits_method 150 | 18 * 18 * 18 * 18 * set_singl_bits_operator 151 | 18 * 18 * 18 * 39 set_singl_mskd_method 152 | 18 * 18 * 18 * 39 set_singl_mskd_operator 153 | 32 * 32 * 32 * 46 shifted_global 154 | 33 * 33 * 33 * 65 shifted_ref 155 | 37 32 * 32 * 65 shifted_val 156 | 12 * 12 * 12 * 12 * zero_array 157 | 12 * 12 * 12 * 12 * zero_reg 158 | compile: -O1 -g3 -DGCC_ARM_BUG c++11 159 | regbits struct raw bitfield 160 | 43 34 * 34 * 36 call_pos_ref 161 | 26 24 * 24 * 26 call_pos_ref_global 162 | 27 21 * 21 * 338 mskd_val 163 | 19 16 * 16 * 19 periph_mskd_ref 164 | 19 13 * 13 * 19 periph_mskd_val 165 | 48 47 * 47 * 48 pos_ref 166 | 17 14 * 14 * 17 reg_mskd_ref 167 | 17 11 * 11 * 17 reg_mskd_val 168 | 2782 2369 * 2369 * 2369 * run 169 | 27 24 * 24 * 32 runtime_range_ref 170 | 27 21 * 21 * 31 runtime_range_val 171 | 37 32 * 32 * 65 shifted_val 172 | 173 | compile: -O1 -g3 -DGCC_ARM_BUG c++11 174 | bitfield.out size: 10705 time: 0.110524524 175 | raw.out size: 6652 time: 0.084844969 176 | regbits.out size: 6967 time: 0.089070258 177 | struct.out size: 6656 time: 0.087068734 178 | -------------------------------------------------------------------------------- /unittest/linux/struct.out: -------------------------------------------------------------------------------- 1 | size: 6656 2 | repeats: 100000 3 | time: 0.087068734 4 | 0 00000000 00000000 5 | 1 00000000 ffffffff 6 | 2 00000040 ffffffff 7 | 3 00000040 ffffffff 8 | 4 00000000 ffffffbf 9 | 5 00000000 ffffffbf 10 | 6 00000002 ffffffff 11 | 7 00000002 ffffffff 12 | 8 00000000 fffffffd 13 | 9 00000000 fffffffd 14 | 10 00000040 00000040 15 | 11 00000040 00000040 16 | 12 00000002 00000002 17 | 13 00000002 00000002 18 | 14 00000040 ffffffbf 19 | 15 00000040 ffffffbf 20 | 16 00000002 fffffffd 21 | 17 00000002 fffffffd 22 | 18 00000004 fffffffd 23 | 19 00000004 fffffffd 24 | 20 00000021 ffffffff 25 | 21 00000021 ffffffff 26 | 22 00000182 fffff1fb 27 | 23 00000182 fffff1fb 28 | 24 00000060 00000060 29 | 25 00000060 00000060 30 | 26 00000308 00000308 31 | 27 00000308 00000308 32 | 28 00000022 00000022 33 | 29 00000022 00000022 34 | 30 00000044 00000044 35 | 31 00000044 00000044 36 | 32 00000001 00000001 37 | 33 00000180 00000180 38 | 34 00000000 00000000 39 | 35 00000020 00000020 40 | 36 00000040 00000040 41 | 37 00000000 ffffffff 42 | 38 22000000 22000000 43 | 39 3e000000 3e000000 44 | 40 0001d000 0001d000 45 | 41 0001d004 0001d004 46 | 42 00000022 00000022 47 | 43 00000020 00000020 48 | 44 00000000 ffffffff 49 | 45 00000021 00000021 50 | 46 00000040 00000040 51 | 47 00000040 00000040 52 | 48 00000000 00000000 53 | 49 00000001 00000001 54 | 50 00000001 00000001 55 | 51 00000000 00000000 56 | 52 00000002 fffffffb 57 | 53 00000002 fffffffb 58 | 54 00000004 fffffffd 59 | 55 00000002 fffffffb 60 | 56 00000040 ffffffff 61 | 57 00000040 ffffffff 62 | 58 00000040 ffffffff 63 | 59 00000040 ffffffff 64 | 60 00000040 ffffffff 65 | 61 00000002 fffffffb 66 | 62 00000002 fffffffb 67 | 63 00000002 fffffffb 68 | 64 00000002 fffffffb 69 | 65 00000002 fffffffb 70 | 66 2a000000 2a000000 71 | 67 22000000 22000000 72 | 68 1e000000 1e000000 73 | 69 00000040 00000040 74 | 70 00000044 00000044 75 | 71 00000066 00000066 76 | 72 0001f000 ffffffff 77 | 73 0000c000 fffecfff 78 | 74 00000077 00000077 79 | 75 0000001d 0000001d 80 | 76 00000002 00000002 81 | 77 00000002 00000002 82 | 78 00000002 00000002 83 | 79 00000002 00000002 84 | 80 00000002 00000002 85 | 81 00000002 00000002 86 | 82 00000002 00000002 87 | 83 00000002 00000002 88 | 84 00000020 00000020 89 | 85 00000040 00000040 90 | 86 00000020 00000020 91 | 87 00000020 00000020 92 | 88 00000020 00000020 93 | 89 00000020 00000020 94 | 90 00000040 ffffffff 95 | 91 00000002 fffffffb 96 | 92 000000bd 000000bd 97 | 93 00000017 00000017 98 | 94 00000004 00000004 99 | 95 00000044 00000044 100 | 96 00000077 00000077 101 | 97 00000040 00000040 102 | 98 00000040 00000040 103 | 99 00000002 fffffffb 104 | 100 00000002 fffffffb 105 | 101 00000017 00000017 106 | 102 00000017 00000017 107 | 103 00000017 00000017 108 | 104 00000017 00000017 109 | 105 00000017 00000017 110 | 106 00000017 00000017 111 | 107 00000002 00000002 112 | 108 00000004 00000004 113 | 109 00000002 00000002 114 | 110 00000004 00000004 115 | 111 00000002 00000002 116 | 112 00000002 00000002 117 | 113 00000002 00000002 118 | 114 00000002 00000002 119 | 115 00000002 00000002 120 | -------------------------------------------------------------------------------- /unittest/linux/unittest.gdb: -------------------------------------------------------------------------------- 1 | # regbits: C++ templates for type-safe bit manipulation 2 | # Copyright (C) 2019 Mark R. Rubin 3 | # 4 | # This file is part of regbits. 5 | # 6 | # The regbits program is free software: you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License as 8 | # published by the Free Software Foundation, either version 3 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # The regbits program is distributed in the hope that it will be 12 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public 17 | # License (LICENSE.txt) along with the regbits program. If not, see 18 | # 19 | 20 | 21 | set height 0 22 | set logging on 23 | printf "size: %d\n", &do_test - &zero_reg 24 | printf "repeats: %d\n", REPEATS 25 | 26 | set logging off 27 | break main:exit 28 | run 29 | 30 | set logging on 31 | if start.tv_nsec > finish.tv_nsec 32 | set var finish.tv_sec -= 1 33 | set var finish.tv_nsec += 1000000000 34 | end 35 | printf "time: %d.%09d\n", \ 36 | finish.tv_sec - start.tv_sec, \ 37 | finish.tv_nsec - start.tv_nsec 38 | 39 | set var $ndx = 0 40 | while $ndx < NUM_TESTS * 2 41 | printf "%-2d %08x %08x\n", \ 42 | $ndx / 2, \ 43 | results[$ndx ], \ 44 | results[$ndx + 1] 45 | set var $ndx = $ndx + 2 46 | end 47 | 48 | set logging off 49 | continue 50 | quit 51 | -------------------------------------------------------------------------------- /unittest/raw.gdb: -------------------------------------------------------------------------------- 1 | set logging file raw.out 2 | -------------------------------------------------------------------------------- /unittest/regbits.gdb: -------------------------------------------------------------------------------- 1 | set logging file regbits.out 2 | -------------------------------------------------------------------------------- /unittest/struct.gdb: -------------------------------------------------------------------------------- 1 | set logging file struct.out 2 | -------------------------------------------------------------------------------- /unittest/unittest.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # regbits: C++ templates for type-safe bit manipulation 4 | # Copyright (C) 2019,2020 Mark R. Rubin 5 | # 6 | # This file is part of regbits. 7 | # 8 | # The regbits program is free software: you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License as 10 | # published by the Free Software Foundation, either version 3 of the 11 | # License, or (at your option) any later version. 12 | # 13 | # The regbits program is distributed in the hope that it will be 14 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | # General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public 19 | # License (LICENSE.txt) along with the regbits program. If not, see 20 | # 21 | 22 | 23 | import os 24 | import sys 25 | 26 | 27 | 28 | architecture = sys.argv[1] 29 | compile_flags = sys.argv[2] 30 | 31 | outs = [] 32 | funcs = [] 33 | 34 | found_run = False 35 | with open(sys.argv[3], 'r') as file: 36 | for line in file: 37 | if 'do_test(' in line: 38 | funcs.append(line.split()[0].split('(')[1]) 39 | 40 | for filename in [name for name in sys.argv[4:] if name.endswith('.out')]: 41 | with open(filename, 'r') as file: 42 | lines = file.readlines() 43 | outs.append((os.path.basename(filename), lines)) 44 | 45 | sizes = [] 46 | times = [] 47 | 48 | print() 49 | for (name, lines) in outs: 50 | sizes.append(lines[0].split()[1]) 51 | times.append(lines[2].split()[1]) 52 | 53 | if outs: 54 | for line in range(3, len(outs[0][1])): 55 | matched = True 56 | current = outs[0][1][line] 57 | for out in range(1, len(outs)): 58 | if outs[out][1][line] != current: 59 | matched = False 60 | break 61 | current = outs[out][1][line] 62 | if not matched: 63 | print('\t', funcs[int(outs[0][1][line].split()[0])]) 64 | for out in range(len(outs)): 65 | print("%-16s\t%s" % (outs[out][0], outs[out][1][line]), end='') 66 | print() 67 | 68 | dmp_names = [name for name in sys.argv[4:] if name.endswith('.o.dmp')] 69 | if not dmp_names: sys.exit(0) 70 | 71 | dump_sizes = {} 72 | funcs = set() 73 | 74 | for dmp_name in dmp_names: 75 | name_sizes = {} 76 | with open(dmp_name, 'r') as file: 77 | size = -1 78 | for line in file: 79 | if line.endswith('>:\n'): 80 | func = line.split()[1] 81 | func = func[1:-len('>:')] 82 | if '(' in func: 83 | func = func[:func.find('(')] 84 | splits = line.split() 85 | if splits[-2] == '[clone': 86 | func += splits[-1][:-3] 87 | funcs.add(func) 88 | size = 0 89 | elif line == '\n' and size > 0: 90 | name_sizes[func] = size 91 | size = -1 92 | elif size >= 0 and len(line) > 15: 93 | if architecture == 'arm': 94 | size += 2 if line[15] == " " else 4 95 | elif architecture == 'intel': 96 | size += len(line[10:30].split()) 97 | name_sizes[func] = size 98 | dump_sizes[os.path.basename(dmp_name)[:-len('.o.dmp')]] = name_sizes 99 | 100 | print('compile:', " ".join(compile_flags.split())) 101 | for name in ('regbits', 'struct', 'raw', 'bitfield'): 102 | if name in dump_sizes: 103 | print(" %8s" % name, end='') 104 | print() 105 | func_list = list(funcs) 106 | func_list.sort() 107 | for func in func_list: 108 | best = 0xffffffff 109 | for name in ('regbits', 'struct', 'raw', 'bitfield'): 110 | if name in dump_sizes and func in dump_sizes[name]: 111 | if dump_sizes[name][func] < best: 112 | best = dump_sizes[name][func] 113 | for name in ('regbits', 'struct', 'raw', 'bitfield'): 114 | if name in dump_sizes and func in dump_sizes[name]: 115 | size = dump_sizes[name][func] 116 | print( "%8d%s" 117 | % (size, " *" if size == best else " "), 118 | end='') 119 | else: 120 | print(" ", end='') 121 | print(" %s" % func) 122 | 123 | print('compile:', " ".join(compile_flags.split())) 124 | for name in ('regbits', 'struct', 'raw', 'bitfield'): 125 | if name in dump_sizes: 126 | print(" %8s" % name, end='') 127 | print() 128 | func_list = list(funcs) 129 | func_list.sort() 130 | for func in func_list: 131 | best = 0xffffffff 132 | for name in ('regbits', 'struct', 'raw', 'bitfield'): 133 | if name in dump_sizes and func in dump_sizes[name]: 134 | if dump_sizes[name][func] < best: 135 | best = dump_sizes[name][func] 136 | if ( func in dump_sizes['regbits'] 137 | and func in dump_sizes['struct' ] 138 | and dump_sizes['regbits'][func] 139 | > dump_sizes['struct' ][func] ) \ 140 | or ( func in dump_sizes['regbits'] 141 | and func in dump_sizes['raw' ] 142 | and dump_sizes['regbits'][func] 143 | > dump_sizes['raw' ][func]): 144 | for name in ('regbits', 'struct', 'raw', 'bitfield'): 145 | if name in dump_sizes and func in dump_sizes[name]: 146 | size = dump_sizes[name][func] 147 | print( "%8d%s" 148 | % (size, " *" if size == best else " "), 149 | end='') 150 | else: 151 | print(" ", end='') 152 | print(" %s" % func) 153 | 154 | if outs: 155 | print() 156 | print('compile:', " ".join(compile_flags.split())) 157 | for ndx in range(len(sizes)): 158 | print( "%-16s\tsize: %s\ttime: %s" 159 | % (outs[ndx][0], sizes[ndx], times[ndx])) 160 | --------------------------------------------------------------------------------