Skip to content
Open
29 changes: 23 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,33 @@ add_library(${PROJECT_NAME} INTERFACE)

target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_20)

# Include directory for flat "armcortex/..." includes
target_include_directories(${PROJECT_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)

target_include_directories(${PROJECT_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/intrinsics/common"
# Forwarding headers for flat include interface (IDE visibility)
target_sources(${PROJECT_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/barriers.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/bit_operations.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/bit_utils.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/byte_reversing.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/debugging.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/exceptions.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/exclusive_access.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/hints.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/intrinsics.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/mpu.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/nvic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/power_management.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/saturation.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/scb.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/scnscb.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/special_regs.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/armcortex/systick.hpp"
)

# Implementation sources (IDE visibility)
target_sources(${PROJECT_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/bit_utils.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/intrinsics/common/barriers.hpp"
Expand Down Expand Up @@ -95,6 +114,7 @@ elseif(ARM_CORTEX_M_ARCH STREQUAL "M1")
"${CMAKE_CURRENT_SOURCE_DIR}/m1/exceptions.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/m1/nvic.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/m1/scb.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/m1/scnscb.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/m1/special_regs.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/m1/systick.hpp"
)
Expand All @@ -103,9 +123,6 @@ elseif(ARM_CORTEX_M_ARCH STREQUAL "M1")
target_link_options(${PROJECT_NAME} INTERFACE -mcpu=cortex-m1)

elseif(ARM_CORTEX_M_ARCH STREQUAL "M3")
target_include_directories(${PROJECT_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/intrinsics/armv7m"
)
target_sources(${PROJECT_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/intrinsics/armv7m/bit_operations.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/intrinsics/armv7m/exclusive_access.hpp"
Expand Down
20 changes: 20 additions & 0 deletions include/armcortex/barriers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright (C) 2025 Matej Gomboc <https://github.com/MatejGomboc/ARMCortexM-CppLib>

Licensed under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance with the Licence.
You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence.
*/

#pragma once

// Forwarding header for flat include interface
#include "../../intrinsics/common/barriers.hpp"
26 changes: 26 additions & 0 deletions include/armcortex/bit_operations.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright (C) 2025 Matej Gomboc <https://github.com/MatejGomboc/ARMCortexM-CppLib>

Licensed under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance with the Licence.
You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence.
*/

#pragma once

// Forwarding header for flat include interface
// Only available on ARMv7-M architectures (Cortex-M3 and above)

#if defined(ARM_CORTEX_M3) || defined(ARM_CORTEX_M4) || defined(ARM_CORTEX_M7)
#include "../../intrinsics/armv7m/bit_operations.hpp"
#else
#error "bit_operations.hpp is only available on ARMv7-M architectures (Cortex-M3 and above)"
#endif
20 changes: 20 additions & 0 deletions include/armcortex/bit_utils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright (C) 2025 Matej Gomboc <https://github.com/MatejGomboc/ARMCortexM-CppLib>

Licensed under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance with the Licence.
You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence.
*/

#pragma once

// Forwarding header for flat include interface
#include "../../bit_utils.hpp"
20 changes: 20 additions & 0 deletions include/armcortex/byte_reversing.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright (C) 2025 Matej Gomboc <https://github.com/MatejGomboc/ARMCortexM-CppLib>

Licensed under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance with the Licence.
You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence.
*/

#pragma once

// Forwarding header for flat include interface
#include "../../intrinsics/common/byte_reversing.hpp"
20 changes: 20 additions & 0 deletions include/armcortex/debugging.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright (C) 2025 Matej Gomboc <https://github.com/MatejGomboc/ARMCortexM-CppLib>

Licensed under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance with the Licence.
You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence.
*/

#pragma once

// Forwarding header for flat include interface
#include "../../intrinsics/common/debugging.hpp"
32 changes: 32 additions & 0 deletions include/armcortex/exceptions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright (C) 2025 Matej Gomboc <https://github.com/MatejGomboc/ARMCortexM-CppLib>

Licensed under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance with the Licence.
You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence.
*/

#pragma once

// Forwarding header for flat include interface
// Selects architecture-specific implementation based on compile definitions

#if defined(ARM_CORTEX_M0)
#include "../../m0/exceptions.hpp"
#elif defined(ARM_CORTEX_M0PLUS)
#include "../../m0plus/exceptions.hpp"
#elif defined(ARM_CORTEX_M1)
#include "../../m1/exceptions.hpp"
#elif defined(ARM_CORTEX_M3)
#include "../../m3/exceptions.hpp"
#else
#error "No ARM Cortex-M architecture defined. Define one of: ARM_CORTEX_M0, ARM_CORTEX_M0PLUS, ARM_CORTEX_M1, ARM_CORTEX_M3"
#endif
26 changes: 26 additions & 0 deletions include/armcortex/exclusive_access.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright (C) 2025 Matej Gomboc <https://github.com/MatejGomboc/ARMCortexM-CppLib>

Licensed under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance with the Licence.
You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence.
*/

#pragma once

// Forwarding header for flat include interface
// Only available on ARMv7-M architectures (Cortex-M3 and above)

#if defined(ARM_CORTEX_M3) || defined(ARM_CORTEX_M4) || defined(ARM_CORTEX_M7)
#include "../../intrinsics/armv7m/exclusive_access.hpp"
#else
#error "exclusive_access.hpp is only available on ARMv7-M architectures (Cortex-M3 and above)"
#endif
20 changes: 20 additions & 0 deletions include/armcortex/hints.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright (C) 2025 Matej Gomboc <https://github.com/MatejGomboc/ARMCortexM-CppLib>

Licensed under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance with the Licence.
You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence.
*/

#pragma once

// Forwarding header for flat include interface
#include "../../intrinsics/common/hints.hpp"
34 changes: 34 additions & 0 deletions include/armcortex/intrinsics.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Copyright (C) 2025 Matej Gomboc <https://github.com/MatejGomboc/ARMCortexM-CppLib>

Licensed under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance with the Licence.
You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence.
*/

#pragma once

// Convenience header that includes all intrinsics for the target architecture

// Common intrinsics (all architectures)
#include "../../intrinsics/common/barriers.hpp"
#include "../../intrinsics/common/byte_reversing.hpp"
#include "../../intrinsics/common/debugging.hpp"
#include "../../intrinsics/common/exceptions.hpp"
#include "../../intrinsics/common/hints.hpp"
#include "../../intrinsics/common/power_management.hpp"

// ARMv7-M specific intrinsics (Cortex-M3 and above)
#if defined(ARM_CORTEX_M3) || defined(ARM_CORTEX_M4) || defined(ARM_CORTEX_M7)
#include "../../intrinsics/armv7m/bit_operations.hpp"
#include "../../intrinsics/armv7m/exclusive_access.hpp"
#include "../../intrinsics/armv7m/saturation.hpp"
#endif
30 changes: 30 additions & 0 deletions include/armcortex/mpu.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright (C) 2025 Matej Gomboc <https://github.com/MatejGomboc/ARMCortexM-CppLib>

Licensed under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance with the Licence.
You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence.
*/

#pragma once

// Forwarding header for flat include interface
// MPU is only available on Cortex-M0+, M3, and above

#if defined(ARM_CORTEX_M0PLUS)
#include "../../m0plus/mpu.hpp"
#elif defined(ARM_CORTEX_M3)
#include "../../m3/mpu.hpp"
#elif defined(ARM_CORTEX_M0) || defined(ARM_CORTEX_M1)
#error "MPU is not available on Cortex-M0 and Cortex-M1"
#else
#error "No ARM Cortex-M architecture defined. Define one of: ARM_CORTEX_M0, ARM_CORTEX_M0PLUS, ARM_CORTEX_M1, ARM_CORTEX_M3"
#endif
32 changes: 32 additions & 0 deletions include/armcortex/nvic.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright (C) 2025 Matej Gomboc <https://github.com/MatejGomboc/ARMCortexM-CppLib>

Licensed under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance with the Licence.
You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence.
*/

#pragma once

// Forwarding header for flat include interface
// Selects architecture-specific implementation based on compile definitions

#if defined(ARM_CORTEX_M0)
#include "../../m0/nvic.hpp"
#elif defined(ARM_CORTEX_M0PLUS)
#include "../../m0plus/nvic.hpp"
#elif defined(ARM_CORTEX_M1)
#include "../../m1/nvic.hpp"
#elif defined(ARM_CORTEX_M3)
#include "../../m3/nvic.hpp"
#else
#error "No ARM Cortex-M architecture defined. Define one of: ARM_CORTEX_M0, ARM_CORTEX_M0PLUS, ARM_CORTEX_M1, ARM_CORTEX_M3"
#endif
20 changes: 20 additions & 0 deletions include/armcortex/power_management.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright (C) 2025 Matej Gomboc <https://github.com/MatejGomboc/ARMCortexM-CppLib>

Licensed under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance with the Licence.
You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence.
*/

#pragma once

// Forwarding header for flat include interface
#include "../../intrinsics/common/power_management.hpp"
26 changes: 26 additions & 0 deletions include/armcortex/saturation.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright (C) 2025 Matej Gomboc <https://github.com/MatejGomboc/ARMCortexM-CppLib>

Licensed under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance with the Licence.
You may obtain a copy of the Licence at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the Licence is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the Licence for the specific language governing permissions and
limitations under the Licence.
*/

#pragma once

// Forwarding header for flat include interface
// Only available on ARMv7-M architectures (Cortex-M3 and above)

#if defined(ARM_CORTEX_M3) || defined(ARM_CORTEX_M4) || defined(ARM_CORTEX_M7)
#include "../../intrinsics/armv7m/saturation.hpp"
#else
#error "saturation.hpp is only available on ARMv7-M architectures (Cortex-M3 and above)"
#endif
Loading