2011-10-31 04:24:47 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the libopencm3 project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Piotr Esden-Tempski <piotr@esden.net>
|
|
|
|
* Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
|
|
|
|
*
|
2012-03-02 10:23:11 +00:00
|
|
|
* This library is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
2011-10-31 04:24:47 +00:00
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2012-03-02 10:23:11 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2011-10-31 04:24:47 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2012-03-02 10:23:11 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2011-10-31 04:24:47 +00:00
|
|
|
*
|
2012-03-02 10:23:11 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2011-10-31 04:24:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LIBOPENCM3_SCB_H
|
|
|
|
#define LIBOPENCM3_SCB_H
|
|
|
|
|
2018-09-09 15:21:02 +00:00
|
|
|
/**
|
|
|
|
* @defgroup cm_scb Cortex-M System Control Block
|
|
|
|
* @ingroup CM3_defines
|
2019-10-18 22:38:16 +00:00
|
|
|
*
|
|
|
|
* The System Control Block is a section of the System Control Space.
|
|
|
|
* Other members of the SCS are, for instance, DWT, ITM, SYSTICKK.
|
|
|
|
* The exact details of the SCB are defined in the "Architecture Reference
|
|
|
|
* Manual" for either ARMv7-M or ARMV6-m.
|
2018-09-09 15:21:02 +00:00
|
|
|
* @{
|
|
|
|
*/
|
2012-10-18 19:42:12 +00:00
|
|
|
#include <libopencm3/cm3/memorymap.h>
|
2011-10-31 04:24:47 +00:00
|
|
|
#include <libopencm3/cm3/common.h>
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** @defgroup cm_scb_registers SCB Registers
|
|
|
|
* @ingroup cm_scb
|
|
|
|
* @{
|
|
|
|
*/
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** CPUID: CPUID base register */
|
2011-10-31 15:11:03 +00:00
|
|
|
#define SCB_CPUID MMIO32(SCB_BASE + 0x00)
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ICSR: Interrupt Control State Register */
|
2011-10-31 15:11:03 +00:00
|
|
|
#define SCB_ICSR MMIO32(SCB_BASE + 0x04)
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** VTOR: Vector Table Offset Register */
|
2011-10-31 15:11:03 +00:00
|
|
|
#define SCB_VTOR MMIO32(SCB_BASE + 0x08)
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** AIRCR: Application Interrupt and Reset Control Register */
|
2011-10-31 15:11:03 +00:00
|
|
|
#define SCB_AIRCR MMIO32(SCB_BASE + 0x0C)
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** SCR: System Control Register */
|
2011-10-31 15:11:03 +00:00
|
|
|
#define SCB_SCR MMIO32(SCB_BASE + 0x10)
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** CCR: Configuration Control Register */
|
2011-10-31 15:11:03 +00:00
|
|
|
#define SCB_CCR MMIO32(SCB_BASE + 0x14)
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2019-10-18 22:33:23 +00:00
|
|
|
/** System Handler Priority 8 bits Registers, SHPR1/2/3.
|
|
|
|
* @note: 12 8bit Registers
|
|
|
|
* @note: 2 32bit Registers on CM0, requires word access,
|
|
|
|
* (shpr1 doesn't actually exist)
|
2018-09-09 15:26:43 +00:00
|
|
|
*/
|
2019-10-18 22:33:23 +00:00
|
|
|
#if defined(__ARM_ARCH_6M__)
|
|
|
|
#define SCB_SHPR32(ipr_id) MMIO32(SCS_BASE + 0xD18 + ((ipr_id) * 4))
|
|
|
|
#else
|
|
|
|
#define SCB_SHPR(ipr_id) MMIO8(SCS_BASE + 0xD18 + (ipr_id))
|
|
|
|
#endif
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** SHCSR: System Handler Control and State Register */
|
2011-10-31 15:11:03 +00:00
|
|
|
#define SCB_SHCSR MMIO32(SCB_BASE + 0x24)
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** DFSR: Debug Fault Status Register */
|
2016-12-13 19:55:54 +00:00
|
|
|
#define SCB_DFSR MMIO32(SCB_BASE + 0x30)
|
|
|
|
|
|
|
|
/* Those defined only on ARMv7 and above */
|
|
|
|
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** CFSR: Configurable Fault Status Registers */
|
2011-10-31 15:11:03 +00:00
|
|
|
#define SCB_CFSR MMIO32(SCB_BASE + 0x28)
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** HFSR: Hard Fault Status Register */
|
2011-10-31 15:11:03 +00:00
|
|
|
#define SCB_HFSR MMIO32(SCB_BASE + 0x2C)
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** MMFAR: Memory Manage Fault Address Register */
|
2011-10-31 15:11:03 +00:00
|
|
|
#define SCB_MMFAR MMIO32(SCB_BASE + 0x34)
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** BFAR: Bus Fault Address Register */
|
2011-10-31 15:11:03 +00:00
|
|
|
#define SCB_BFAR MMIO32(SCB_BASE + 0x38)
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** AFSR: Auxiliary Fault Status Register */
|
2011-10-31 15:11:03 +00:00
|
|
|
#define SCB_AFSR MMIO32(SCB_BASE + 0x3C)
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ID_PFR0: Processor Feature Register 0 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_ID_PFR0 MMIO32(SCB_BASE + 0x40)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ID_PFR1: Processor Feature Register 1 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_ID_PFR1 MMIO32(SCB_BASE + 0x44)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ID_DFR0: Debug Features Register 0 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_ID_DFR0 MMIO32(SCB_BASE + 0x48)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ID_AFR0: Auxiliary Features Register 0 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_ID_AFR0 MMIO32(SCB_BASE + 0x4C)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ID_MMFR0: Memory Model Feature Register 0 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_ID_MMFR0 MMIO32(SCB_BASE + 0x50)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ID_MMFR1: Memory Model Feature Register 1 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_ID_MMFR1 MMIO32(SCB_BASE + 0x54)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ID_MMFR2: Memory Model Feature Register 2 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_ID_MMFR2 MMIO32(SCB_BASE + 0x58)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ID_MMFR3: Memory Model Feature Register 3 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_ID_MMFR3 MMIO32(SCB_BASE + 0x5C)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ID_ISAR0: Instruction Set Attributes Register 0 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_ID_ISAR0 MMIO32(SCB_BASE + 0x60)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ID_ISAR1: Instruction Set Attributes Register 1 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_ID_ISAR1 MMIO32(SCB_BASE + 0x64)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ID_ISAR2: Instruction Set Attributes Register 2 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_ID_ISAR2 MMIO32(SCB_BASE + 0x68)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ID_ISAR3: Instruction Set Attributes Register 3 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_ID_ISAR3 MMIO32(SCB_BASE + 0x6C)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ID_ISAR4: Instruction Set Attributes Register 4 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_ID_ISAR4 MMIO32(SCB_BASE + 0x70)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** CPACR: Coprocessor Access Control Register */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_CPACR MMIO32(SCB_BASE + 0x88)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** FPCCR: Floating-Point Context Control Register */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_FPCCR MMIO32(SCB_BASE + 0x234)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** FPCAR: Floating-Point Context Address Register */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_FPCAR MMIO32(SCB_BASE + 0x238)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** FPDSCR: Floating-Point Default Status Control Register */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_FPDSCR MMIO32(SCB_BASE + 0x23C)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** MVFR0: Media and Floating-Point Feature Register 0 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_MVFR0 MMIO32(SCB_BASE + 0x240)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** MVFR1: Media and Floating-Point Feature Register 1 */
|
2012-08-22 04:05:07 +00:00
|
|
|
#define SCB_MVFR1 MMIO32(SCB_BASE + 0x244)
|
2013-07-22 16:43:16 +00:00
|
|
|
#endif
|
2012-08-22 04:05:07 +00:00
|
|
|
|
2020-12-19 19:41:54 +00:00
|
|
|
/* Those defined only on ARMv7EM and above */
|
|
|
|
#if defined(__ARM_ARCH_7EM__)
|
|
|
|
/** CLIDR: Cache Level ID Register */
|
|
|
|
#define SCB_CLIDR MMIO32(SCB_BASE + 0x78)
|
|
|
|
|
|
|
|
/** CTR: Cache Type Register */
|
|
|
|
#define SCB_CTR MMIO32(SCB_BASE + 0x7C)
|
|
|
|
|
|
|
|
/** CCSIDR: Cache Size ID Registers */
|
|
|
|
#define SCB_CCSIDR MMIO32(SCB_BASE + 0x80)
|
|
|
|
|
|
|
|
/** CSSELR: Cache Size Selection Register */
|
|
|
|
#define SCB_CCSELR MMIO32(SCB_BASE + 0x84)
|
|
|
|
|
|
|
|
/** ICIALLU: I-cache invalidate all to Point of Unification */
|
|
|
|
#define SCB_ICIALLU MMIO32(SCB_BASE + 0x250)
|
|
|
|
|
|
|
|
/** ICIMVAU: I-cache invalidate by MVA to Point of Unification */
|
|
|
|
#define SCB_ICIMVAU MMIO32(SCB_BASE + 0x258)
|
|
|
|
|
|
|
|
/** DCIMVAC: D-cache invalidate by MVA to Point of Coherency */
|
|
|
|
#define SCB_DCIMVAC MMIO32(SCB_BASE + 0x25C)
|
|
|
|
|
|
|
|
/** DCISW: D-cache invalidate by set-way */
|
|
|
|
#define SCB_DCISW MMIO32(SCB_BASE + 0x260)
|
|
|
|
|
|
|
|
/** DCCMVAU: D-cache clean by MVA to Point of Unification */
|
|
|
|
#define SCB_DCCMVAU MMIO32(SCB_BASE + 0x264)
|
|
|
|
|
|
|
|
/** DCCMVAC: D-cache clean by MVA to Point of Coherency */
|
|
|
|
#define SCB_DCCMVAC MMIO32(SCB_BASE + 0x268)
|
|
|
|
|
|
|
|
/** DCISW: D-cache clean by set-way */
|
|
|
|
#define SCB_DCCSW MMIO32(SCB_BASE + 0x26C)
|
|
|
|
|
|
|
|
/** DCCIMVAC: D-cache clean and invalidate by MVA to Point of Coherency */
|
|
|
|
#define SCB_DCCIMVAC MMIO32(SCB_BASE + 0x270)
|
|
|
|
|
|
|
|
/** DCCISW: D-cache clean and invalidate by set-way */
|
|
|
|
#define SCB_DCCISW MMIO32(SCB_BASE + 0x274)
|
|
|
|
|
|
|
|
/** BPIALL: Branch predictor invalidate all */
|
|
|
|
#define SCB_BPIALL MMIO32(SCB_BASE + 0x278)
|
|
|
|
#endif
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/**@}*/
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/* --- SCB values ---------------------------------------------------------- */
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/**
|
|
|
|
* @defgroup cm3_scb_cpuid_values SCB_CPUID Values
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
/** Implementer[31:24]: Implementer code */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_CPUID_IMPLEMENTER_LSB 24
|
|
|
|
#define SCB_CPUID_IMPLEMENTER (0xFF << SCB_CPUID_IMPLEMENTER_LSB)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** Variant[23:20]: Variant number */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_CPUID_VARIANT_LSB 20
|
|
|
|
#define SCB_CPUID_VARIANT (0xF << SCB_CPUID_VARIANT_LSB)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** Constant[19:16]
|
|
|
|
* Reads as 0xF (ARMv7-M) M3, M4
|
|
|
|
* Reads as 0xC (ARMv6-M) M0, M0+
|
|
|
|
*/
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_CPUID_CONSTANT_LSB 16
|
|
|
|
#define SCB_CPUID_CONSTANT (0xF << SCB_CPUID_CONSTANT_LSB)
|
|
|
|
#define SCB_CPUID_CONSTANT_ARMV6 (0xC << SCB_CPUID_CONSTANT_LSB)
|
|
|
|
#define SCB_CPUID_CONSTANT_ARMV7 (0xF << SCB_CPUID_CONSTANT_LSB)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** PartNo[15:4]: Part number of the processor */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_CPUID_PARTNO_LSB 4
|
|
|
|
#define SCB_CPUID_PARTNO (0xFFF << SCB_CPUID_PARTNO_LSB)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** Revision[3:0]: Revision number */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_CPUID_REVISION_LSB 0
|
|
|
|
#define SCB_CPUID_REVISION (0xF << SCB_CPUID_REVISION_LSB)
|
2018-09-09 15:26:43 +00:00
|
|
|
/**@}*/
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/**
|
|
|
|
* @defgroup cm3_scb_icsr_values SCB_ICSR Values
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
/** NMIPENDSET: NMI set-pending bit */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_ICSR_NMIPENDSET (1 << 31)
|
2011-10-31 04:24:47 +00:00
|
|
|
/* Bits [30:29]: reserved - must be kept cleared */
|
2018-09-09 15:26:43 +00:00
|
|
|
/** PENDSVSET: PendSV set-pending bit */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_ICSR_PENDSVSET (1 << 28)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** PENDSVCLR: PendSV clear-pending bit */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_ICSR_PENDSVCLR (1 << 27)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** PENDSTSET: SysTick exception set-pending bit */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_ICSR_PENDSTSET (1 << 26)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** PENDSTCLR: SysTick exception clear-pending bit */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_ICSR_PENDSTCLR (1 << 25)
|
2011-10-31 04:24:47 +00:00
|
|
|
/* Bit 24: reserved - must be kept cleared */
|
2018-09-09 15:26:43 +00:00
|
|
|
/** Bit 23: reserved for debug - reads as 0 when not in debug mode */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_ICSR_ISRPREEMPT (1 << 23)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ISRPENDING: Interrupt pending flag, excluding NMI and Faults */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_ICSR_ISRPENDING (1 << 22)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** VECTPENDING[21:12] Pending vector */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_ICSR_VECTPENDING_LSB 12
|
|
|
|
#define SCB_ICSR_VECTPENDING (0x1FF << SCB_ICSR_VECTPENDING_LSB)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** RETOBASE: Return to base level */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_ICSR_RETOBASE (1 << 11)
|
2011-10-31 04:24:47 +00:00
|
|
|
/* Bits [10:9]: reserved - must be kept cleared */
|
2018-09-09 15:26:43 +00:00
|
|
|
/** VECTACTIVE[8:0] Active vector */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_ICSR_VECTACTIVE_LSB 0
|
|
|
|
#define SCB_ICSR_VECTACTIVE (0x1FF << SCB_ICSR_VECTACTIVE_LSB)
|
2018-09-09 15:26:43 +00:00
|
|
|
/**@}*/
|
2013-07-22 16:43:16 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/**
|
|
|
|
* @defgroup cm3_scb_vtor_values SCB_VTOR Values
|
|
|
|
* @{
|
|
|
|
*/
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2013-07-22 16:43:16 +00:00
|
|
|
/* IMPLEMENTATION DEFINED */
|
|
|
|
|
|
|
|
#if defined(__ARM_ARCH_6M__)
|
|
|
|
|
|
|
|
#define SCB_VTOR_TBLOFF_LSB 7
|
|
|
|
#define SCB_VTOR_TBLOFF (0x1FFFFFF << SCB_VTOR_TBLOFF_LSB)
|
|
|
|
|
|
|
|
#elif defined(CM1)
|
|
|
|
/* VTOR not defined there */
|
|
|
|
|
|
|
|
#elif defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
|
|
|
|
2011-10-31 04:24:47 +00:00
|
|
|
/* Bits [31:30]: reserved - must be kept cleared */
|
|
|
|
/* TBLOFF[29:9]: Vector table base offset field */
|
2013-06-13 04:00:50 +00:00
|
|
|
/* inconsistent datasheet - LSB could be 11 */
|
2013-07-22 16:43:16 +00:00
|
|
|
/* BUG: TBLOFF is in the ARMv6 Architecture reference manual defined from b7 */
|
|
|
|
#define SCB_VTOR_TBLOFF_LSB 9
|
|
|
|
#define SCB_VTOR_TBLOFF (0x7FFFFF << SCB_VTOR_TBLOFF_LSB)
|
|
|
|
|
|
|
|
#endif
|
2018-09-09 15:26:43 +00:00
|
|
|
/**@}*/
|
2011-10-31 04:24:47 +00:00
|
|
|
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/**
|
|
|
|
* @defgroup cm3_scb_aicr_values SCB_AICR Values
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
/** VECTKEYSTAT[31:16]/ VECTKEY[31:16] Register key */
|
2013-07-22 16:43:16 +00:00
|
|
|
#define SCB_AIRCR_VECTKEYSTAT_LSB 16
|
|
|
|
#define SCB_AIRCR_VECTKEYSTAT (0xFFFF << SCB_AIRCR_VECTKEYSTAT_LSB)
|
|
|
|
#define SCB_AIRCR_VECTKEY (0x05FA << SCB_AIRCR_VECTKEYSTAT_LSB)
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** ENDIANNESS Data endianness bit */
|
2011-10-31 04:24:47 +00:00
|
|
|
#define SCB_AIRCR_ENDIANESS (1 << 15)
|
2013-07-22 16:43:16 +00:00
|
|
|
|
|
|
|
/* Those defined only on ARMv7 and above */
|
|
|
|
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
2011-10-31 04:24:47 +00:00
|
|
|
/* Bits [14:11]: reserved - must be kept cleared */
|
2018-09-09 15:26:43 +00:00
|
|
|
/** PRIGROUP[10:8]: Interrupt priority grouping field */
|
2012-02-25 00:21:23 +00:00
|
|
|
#define SCB_AIRCR_PRIGROUP_GROUP16_NOSUB (0x3 << 8)
|
|
|
|
#define SCB_AIRCR_PRIGROUP_GROUP8_SUB2 (0x4 << 8)
|
|
|
|
#define SCB_AIRCR_PRIGROUP_GROUP4_SUB4 (0x5 << 8)
|
|
|
|
#define SCB_AIRCR_PRIGROUP_GROUP2_SUB8 (0x6 << 8)
|
|
|
|
#define SCB_AIRCR_PRIGROUP_NOGROUP_SUB16 (0x7 << 8)
|
|
|
|
#define SCB_AIRCR_PRIGROUP_MASK (0x7 << 8)
|
|
|
|
#define SCB_AIRCR_PRIGROUP_SHIFT 8
|
2011-10-31 04:24:47 +00:00
|
|
|
/* Bits [7:3]: reserved - must be kept cleared */
|
2013-07-22 16:43:16 +00:00
|
|
|
#endif
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** SYSRESETREQ System reset request */
|
2011-10-31 04:24:47 +00:00
|
|
|
#define SCB_AIRCR_SYSRESETREQ (1 << 2)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** VECTCLRACTIVE clears state information for exceptions */
|
2011-10-31 04:24:47 +00:00
|
|
|
#define SCB_AIRCR_VECTCLRACTIVE (1 << 1)
|
2013-07-22 16:43:16 +00:00
|
|
|
|
|
|
|
/* Those defined only on ARMv7 and above */
|
|
|
|
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** VECTRESET cause local system reset */
|
2011-10-31 04:24:47 +00:00
|
|
|
#define SCB_AIRCR_VECTRESET (1 << 0)
|
2013-07-22 16:43:16 +00:00
|
|
|
#endif
|
2018-09-09 15:26:43 +00:00
|
|
|
/**@}*/
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/**
|
|
|
|
* @defgroup cm3_scb_scr_values SCB_SCR Values
|
|
|
|
* @{
|
|
|
|
*/
|
2011-10-31 04:24:47 +00:00
|
|
|
/* Bits [31:5]: reserved - must be kept cleared */
|
2018-09-09 15:26:43 +00:00
|
|
|
/** SEVONPEND Send Event on Pending bit */
|
2017-04-03 16:42:49 +00:00
|
|
|
#define SCB_SCR_SEVONPEND (1 << 4)
|
2011-10-31 04:24:47 +00:00
|
|
|
/* Bit 3: reserved - must be kept cleared */
|
2018-09-09 15:26:43 +00:00
|
|
|
/** SLEEPDEEP implementation defined */
|
2011-10-31 04:24:47 +00:00
|
|
|
#define SCB_SCR_SLEEPDEEP (1 << 2)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** SLEEPONEXIT sleep when exiting ISR */
|
2011-10-31 04:24:47 +00:00
|
|
|
#define SCB_SCR_SLEEPONEXIT (1 << 1)
|
|
|
|
/* Bit 0: reserved - must be kept cleared */
|
2018-09-09 15:26:43 +00:00
|
|
|
/**@}*/
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/**
|
|
|
|
* @defgroup cm3_scb_ccr_values SCB_CCR Values
|
|
|
|
* @{
|
|
|
|
*/
|
2011-10-31 04:24:47 +00:00
|
|
|
/* Bits [31:10]: reserved - must be kept cleared */
|
2018-09-09 15:26:43 +00:00
|
|
|
/** STKALIGN set to zero to break things :) */
|
2011-10-31 04:24:47 +00:00
|
|
|
#define SCB_CCR_STKALIGN (1 << 9)
|
2013-07-22 16:43:16 +00:00
|
|
|
|
|
|
|
/* Those defined only on ARMv7 and above */
|
|
|
|
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** BFHFNMIGN set to attempt ignoring faults in handlers */
|
2011-10-31 04:24:47 +00:00
|
|
|
#define SCB_CCR_BFHFNMIGN (1 << 8)
|
|
|
|
/* Bits [7:5]: reserved - must be kept cleared */
|
2018-09-09 15:26:43 +00:00
|
|
|
/** DIV_0_TRP set to trap on divide by zero*/
|
2011-10-31 04:24:47 +00:00
|
|
|
#define SCB_CCR_DIV_0_TRP (1 << 4)
|
2013-07-22 16:43:16 +00:00
|
|
|
#endif
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/** UNALIGN_TRP set to trap on unaligned */
|
2011-10-31 04:24:47 +00:00
|
|
|
#define SCB_CCR_UNALIGN_TRP (1 << 3)
|
2013-07-22 16:43:16 +00:00
|
|
|
|
|
|
|
/* Those defined only on ARMv7 and above */
|
|
|
|
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
2011-10-31 04:24:47 +00:00
|
|
|
/* Bit 2: reserved - must be kept cleared */
|
2018-09-09 15:26:43 +00:00
|
|
|
/** USERSETMPEND set to allow unprivileged access to STIR */
|
2011-10-31 04:24:47 +00:00
|
|
|
#define SCB_CCR_USERSETMPEND (1 << 1)
|
2018-09-09 15:26:43 +00:00
|
|
|
/** NONBASETHRDENA set to allow non base priority threads */
|
2011-10-31 04:24:47 +00:00
|
|
|
#define SCB_CCR_NONBASETHRDENA (1 << 0)
|
2013-07-22 16:43:16 +00:00
|
|
|
#endif
|
2020-12-19 19:41:54 +00:00
|
|
|
|
|
|
|
/* Those defined only on ARMv7EM and above */
|
|
|
|
#if defined(__ARM_ARCH_7EM__)
|
|
|
|
/** BP set to enable branch predictor */
|
|
|
|
#define SCB_CCR_BP (1 << 18)
|
|
|
|
/** IC set to enable instruction cache */
|
|
|
|
#define SCB_CCR_IC (1 << 17)
|
|
|
|
/** DC set to enable data cache */
|
|
|
|
#define SCB_CCR_DC (1 << 16)
|
|
|
|
#endif
|
|
|
|
|
2018-09-09 15:26:43 +00:00
|
|
|
/**@}*/
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2013-07-17 21:25:47 +00:00
|
|
|
/* These numbers are designed to be used with the SCB_SHPR() macro */
|
|
|
|
/* SCB_SHPR1 */
|
|
|
|
#define SCB_SHPR_PRI_4_MEMMANAGE 0
|
|
|
|
#define SCB_SHPR_PRI_5_BUSFAULT 1
|
|
|
|
#define SCB_SHPR_PRI_6_USAGEFAULT 2
|
|
|
|
#define SCB_SHPR_PRI_7_RESERVED 3
|
|
|
|
/* SCB_SHPR2 */
|
|
|
|
#define SCB_SHPR_PRI_8_RESERVED 4
|
|
|
|
#define SCB_SHPR_PRI_9_RESERVED 5
|
|
|
|
#define SCB_SHPR_PRI_10_RESERVED 6
|
|
|
|
#define SCB_SHPR_PRI_11_SVCALL 7
|
|
|
|
/* SCB_SHPR3 */
|
|
|
|
#define SCB_SHPR_PRI_12_RESERVED 8
|
|
|
|
#define SCB_SHPR_PRI_13_RESERVED 9
|
|
|
|
#define SCB_SHPR_PRI_14_PENDSV 10
|
|
|
|
#define SCB_SHPR_PRI_15_SYSTICK 11
|
2011-10-31 04:24:47 +00:00
|
|
|
|
|
|
|
/* --- SCB_SHCSR values ---------------------------------------------------- */
|
|
|
|
|
|
|
|
/* Bits [31:19]: reserved - must be kept cleared */
|
2016-12-13 19:55:54 +00:00
|
|
|
|
|
|
|
/* Those defined only on ARMv7 and above */
|
|
|
|
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
2011-10-31 04:24:47 +00:00
|
|
|
/* USGFAULTENA: Usage fault enable */
|
|
|
|
#define SCB_SHCSR_USGFAULTENA (1 << 18)
|
|
|
|
/* BUSFAULTENA: Bus fault enable */
|
|
|
|
#define SCB_SHCSR_BUSFAULTENA (1 << 17)
|
|
|
|
/* MEMFAULTENA: Memory management fault enable */
|
|
|
|
#define SCB_SHCSR_MEMFAULTENA (1 << 16)
|
2016-12-13 19:55:54 +00:00
|
|
|
#endif
|
|
|
|
|
2011-10-31 04:24:47 +00:00
|
|
|
/* SVCALLPENDED: SVC call pending */
|
|
|
|
#define SCB_SHCSR_SVCALLPENDED (1 << 15)
|
2016-12-13 19:55:54 +00:00
|
|
|
|
|
|
|
/* Those defined only on ARMv7 and above */
|
|
|
|
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
2011-10-31 04:24:47 +00:00
|
|
|
/* BUSFAULTPENDED: Bus fault exception pending */
|
|
|
|
#define SCB_SHCSR_BUSFAULTPENDED (1 << 14)
|
|
|
|
/* MEMFAULTPENDED: Memory management fault exception pending */
|
|
|
|
#define SCB_SHCSR_MEMFAULTPENDED (1 << 13)
|
|
|
|
/* USGFAULTPENDED: Usage fault exception pending */
|
|
|
|
#define SCB_SHCSR_USGFAULTPENDED (1 << 12)
|
|
|
|
/* SYSTICKACT: SysTick exception active */
|
|
|
|
#define SCB_SHCSR_SYSTICKACT (1 << 11)
|
|
|
|
/* PENDSVACT: PendSV exception active */
|
|
|
|
#define SCB_SHCSR_PENDSVACT (1 << 10)
|
|
|
|
/* Bit 9: reserved - must be kept cleared */
|
|
|
|
/* MONITORACT: Debug monitor active */
|
|
|
|
#define SCB_SHCSR_MONITORACT (1 << 8)
|
|
|
|
/* SVCALLACT: SVC call active */
|
|
|
|
#define SCB_SHCSR_SVCALLACT (1 << 7)
|
|
|
|
/* Bits [6:4]: reserved - must be kept cleared */
|
|
|
|
/* USGFAULTACT: Usage fault exception active */
|
|
|
|
#define SCB_SHCSR_USGFAULTACT (1 << 3)
|
|
|
|
/* Bit 2: reserved - must be kept cleared */
|
|
|
|
/* BUSFAULTACT: Bus fault exception active */
|
|
|
|
#define SCB_SHCSR_BUSFAULTACT (1 << 1)
|
|
|
|
/* MEMFAULTACT: Memory management fault exception active */
|
|
|
|
#define SCB_SHCSR_MEMFAULTACT (1 << 0)
|
|
|
|
|
|
|
|
/* --- SCB_CFSR values ----------------------------------------------------- */
|
|
|
|
|
|
|
|
/* Bits [31:26]: reserved - must be kept cleared */
|
|
|
|
/* DIVBYZERO: Divide by zero usage fault */
|
|
|
|
#define SCB_CFSR_DIVBYZERO (1 << 25)
|
|
|
|
/* UNALIGNED: Unaligned access usage fault */
|
|
|
|
#define SCB_CFSR_UNALIGNED (1 << 24)
|
|
|
|
/* Bits [23:20]: reserved - must be kept cleared */
|
|
|
|
/* NOCP: No coprocessor usage fault */
|
|
|
|
#define SCB_CFSR_NOCP (1 << 19)
|
|
|
|
/* INVPC: Invalid PC load usage fault */
|
|
|
|
#define SCB_CFSR_INVPC (1 << 18)
|
|
|
|
/* INVSTATE: Invalid state usage fault */
|
|
|
|
#define SCB_CFSR_INVSTATE (1 << 17)
|
|
|
|
/* UNDEFINSTR: Undefined instruction usage fault */
|
|
|
|
#define SCB_CFSR_UNDEFINSTR (1 << 16)
|
|
|
|
/* BFARVALID: Bus Fault Address Register (BFAR) valid flag */
|
|
|
|
#define SCB_CFSR_BFARVALID (1 << 15)
|
|
|
|
/* Bits [14:13]: reserved - must be kept cleared */
|
|
|
|
/* STKERR: Bus fault on stacking for exception entry */
|
|
|
|
#define SCB_CFSR_STKERR (1 << 12)
|
|
|
|
/* UNSTKERR: Bus fault on unstacking for a return from exception */
|
|
|
|
#define SCB_CFSR_UNSTKERR (1 << 11)
|
|
|
|
/* IMPRECISERR: Imprecise data bus error */
|
|
|
|
#define SCB_CFSR_IMPRECISERR (1 << 10)
|
|
|
|
/* PRECISERR: Precise data bus error */
|
|
|
|
#define SCB_CFSR_PRECISERR (1 << 9)
|
|
|
|
/* IBUSERR: Instruction bus error */
|
|
|
|
#define SCB_CFSR_IBUSERR (1 << 8)
|
|
|
|
/* MMARVALID: Memory Management Fault Address Register (MMAR) valid flag */
|
|
|
|
#define SCB_CFSR_MMARVALID (1 << 7)
|
|
|
|
/* Bits [6:5]: reserved - must be kept cleared */
|
|
|
|
/* MSTKERR: Memory manager fault on stacking for exception entry */
|
|
|
|
#define SCB_CFSR_MSTKERR (1 << 4)
|
|
|
|
/* MUNSTKERR: Memory manager fault on unstacking for a return from exception */
|
|
|
|
#define SCB_CFSR_MUNSTKERR (1 << 3)
|
|
|
|
/* Bit 2: reserved - must be kept cleared */
|
|
|
|
/* DACCVIOL: Data access violation flag */
|
|
|
|
#define SCB_CFSR_DACCVIOL (1 << 1)
|
|
|
|
/* IACCVIOL: Instruction access violation flag */
|
|
|
|
#define SCB_CFSR_IACCVIOL (1 << 0)
|
|
|
|
|
|
|
|
/* --- SCB_HFSR values ----------------------------------------------------- */
|
|
|
|
|
|
|
|
/* DEBUG_VT: reserved for debug use */
|
|
|
|
#define SCB_HFSR_DEBUG_VT (1 << 31)
|
|
|
|
/* FORCED: Forced hard fault */
|
|
|
|
#define SCB_HFSR_FORCED (1 << 30)
|
|
|
|
/* Bits [29:2]: reserved - must be kept cleared */
|
|
|
|
/* VECTTBL: Vector table hard fault */
|
|
|
|
#define SCB_HFSR_VECTTBL (1 << 1)
|
|
|
|
/* Bit 0: reserved - must be kept cleared */
|
|
|
|
|
|
|
|
/* --- SCB_MMFAR values ---------------------------------------------------- */
|
|
|
|
|
|
|
|
/* MMFAR [31:0]: Memory management fault address */
|
|
|
|
|
|
|
|
/* --- SCB_BFAR values ----------------------------------------------------- */
|
|
|
|
|
|
|
|
/* BFAR [31:0]: Bus fault address */
|
|
|
|
|
2020-12-19 19:41:54 +00:00
|
|
|
#if defined(__ARM_ARCH_7EM__)
|
|
|
|
/* --- SCB_CTR values ------------------------------------------------------ */
|
|
|
|
/* FORMAT: implemented CTR format */
|
|
|
|
#define SCB_CTR_FORMAT_SHIFT 29
|
|
|
|
#define SCB_CTR_FORMAT_MASK 0x7
|
|
|
|
/* CWG: Cache Write-back Granule */
|
|
|
|
#define SCB_CTR_CWG_SHIFT 24
|
|
|
|
#define SCB_CTR_CWG_MASK 0xf
|
|
|
|
/* ERG: Exclusives Reservation Granule */
|
|
|
|
#define SCB_CTR_ERG_SHIFT 20
|
|
|
|
#define SCB_CTR_ERG_MASK 0xf
|
|
|
|
/* DMINLINE: log2 of number of words in smallest cache line of all data caches */
|
|
|
|
#define SCB_CTR_DMINLINE_SHIFT 16
|
|
|
|
#define SCB_CTR_DMINLINE_MASK 0x1f
|
|
|
|
/* IMINLINE: log2 of number of words in smallest cache line of all instruction caches */
|
|
|
|
#define SCB_CTR_IMINLINE_SHIFT 0
|
|
|
|
#define SCB_CTR_IMINLINE_MASK 0xf
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-08-22 04:05:07 +00:00
|
|
|
/* --- SCB_CPACR values ---------------------------------------------------- */
|
|
|
|
|
|
|
|
/* CPACR CPn: Access privileges values */
|
|
|
|
#define SCB_CPACR_NONE 0 /* Access denied */
|
|
|
|
#define SCB_CPACR_PRIV 1 /* Privileged access only */
|
|
|
|
#define SCB_CPACR_FULL 3 /* Full access */
|
|
|
|
|
|
|
|
/* CPACR [20:21]: Access privileges for coprocessor 10 */
|
|
|
|
#define SCB_CPACR_CP10 (1 << 20)
|
|
|
|
/* CPACR [22:23]: Access privileges for coprocessor 11 */
|
|
|
|
#define SCB_CPACR_CP11 (1 << 22)
|
2013-07-22 16:43:16 +00:00
|
|
|
#endif
|
2012-08-22 04:05:07 +00:00
|
|
|
|
2011-10-31 04:24:47 +00:00
|
|
|
/* --- SCB functions ------------------------------------------------------- */
|
2012-09-02 15:12:58 +00:00
|
|
|
|
|
|
|
BEGIN_DECLS
|
|
|
|
|
2012-11-22 00:38:17 +00:00
|
|
|
struct scb_exception_stack_frame {
|
2013-06-13 02:11:22 +00:00
|
|
|
uint32_t r0;
|
|
|
|
uint32_t r1;
|
|
|
|
uint32_t r2;
|
|
|
|
uint32_t r3;
|
|
|
|
uint32_t r12;
|
|
|
|
uint32_t lr;
|
|
|
|
uint32_t pc;
|
|
|
|
uint32_t xpsr;
|
2013-06-13 17:29:21 +00:00
|
|
|
} __attribute__((packed));
|
2012-11-22 00:38:17 +00:00
|
|
|
|
|
|
|
#define SCB_GET_EXCEPTION_STACK_FRAME(f) \
|
|
|
|
do { \
|
|
|
|
asm volatile ("mov %[frameptr], sp" \
|
|
|
|
: [frameptr]"=r" (f)); \
|
|
|
|
} while (0)
|
|
|
|
|
2018-03-07 14:53:11 +00:00
|
|
|
void scb_reset_system(void) __attribute__((noreturn));
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2013-07-22 16:43:16 +00:00
|
|
|
/* Those defined only on ARMv7 and above */
|
|
|
|
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
2018-03-07 14:53:11 +00:00
|
|
|
void scb_reset_core(void) __attribute__((noreturn));
|
2013-07-22 16:43:16 +00:00
|
|
|
void scb_set_priority_grouping(uint32_t prigroup);
|
|
|
|
#endif
|
2011-10-31 04:24:47 +00:00
|
|
|
|
2012-09-02 15:12:58 +00:00
|
|
|
END_DECLS
|
|
|
|
|
2018-09-09 15:21:02 +00:00
|
|
|
/**@}*/
|
|
|
|
|
2011-10-31 04:24:47 +00:00
|
|
|
#endif
|