text
stringlengths
9
39.2M
dir
stringlengths
26
295
lang
stringclasses
185 values
created_date
timestamp[us]
updated_date
timestamp[us]
repo_name
stringlengths
1
97
repo_full_name
stringlengths
7
106
star
int64
1k
183k
len_tokens
int64
1
13.8M
```objective-c /**************************************************************************//** * @file ARMv8MML_DSP.h * @brief CMSIS Core Peripheral Access Layer Header File for * ARMv8MML Mainline Device (configured for ARMv8MML without FPU, with DSP extension, with TrustZone) * @version V5.4.0 * @date 03. March 2020 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef ARMv8MML_DSP_H #define ARMv8MML_DSP_H #ifdef __cplusplus extern "C" { #endif /* ------------------------- Interrupt Number Definition ------------------------ */ typedef enum IRQn { /* ------------------- Processor Exceptions Numbers ----------------------------- */ NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */ HardFault_IRQn = -13, /* 3 HardFault Interrupt */ MemoryManagement_IRQn = -12, /* 4 Memory Management Interrupt */ BusFault_IRQn = -11, /* 5 Bus Fault Interrupt */ UsageFault_IRQn = -10, /* 6 Usage Fault Interrupt */ SecureFault_IRQn = -9, /* 7 Secure Fault Interrupt */ SVCall_IRQn = -5, /* 11 SVC Interrupt */ DebugMonitor_IRQn = -4, /* 12 Debug Monitor Interrupt */ PendSV_IRQn = -2, /* 14 PendSV Interrupt */ SysTick_IRQn = -1, /* 15 System Tick Interrupt */ /* ------------------- Processor Interrupt Numbers ------------------------------ */ Interrupt0_IRQn = 0, Interrupt1_IRQn = 1, Interrupt2_IRQn = 2, Interrupt3_IRQn = 3, Interrupt4_IRQn = 4, Interrupt5_IRQn = 5, Interrupt6_IRQn = 6, Interrupt7_IRQn = 7, Interrupt8_IRQn = 8, Interrupt9_IRQn = 9 /* Interrupts 10 .. 480 are left out */ } IRQn_Type; /* ================================================================================ */ /* ================ Processor and Core Peripheral Section ================ */ /* ================================================================================ */ /* ------- Start of section using anonymous unions and disabling warnings ------- */ #if defined (__CC_ARM) #pragma push #pragma anon_unions #elif defined (__ICCARM__) #pragma language=extended #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc11-extensions" #pragma clang diagnostic ignored "-Wreserved-id-macro" #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning 586 #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif /* -------- Configuration of Core Peripherals ----------------------------------- */ #define __ARMv8MML_REV 0x0001U /* Core revision r0p1 */ #define __SAUREGION_PRESENT 1U /* SAU regions present */ #define __MPU_PRESENT 1U /* MPU present */ #define __VTOR_PRESENT 1U /* VTOR present */ #define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */ #define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 0U /* no FPU present */ #define __DSP_PRESENT 1U /* DSP extension present */ #define __ICACHE_PRESENT 1U #define __DCACHE_PRESENT 1U #include "core_armv8mml.h" /* Processor and core peripherals */ #include "system_ARMv8MML.h" /* System Header */ /* -------- End of section using anonymous unions and disabling warnings -------- */ #if defined (__CC_ARM) #pragma pop #elif defined (__ICCARM__) /* leave anonymous unions enabled */ #elif (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) #pragma clang diagnostic pop #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning restore #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif #ifdef __cplusplus } #endif #endif /* ARMv8MML_DSP_H */ ```
/content/code_sandbox/Device/ARM/ARMv8MML/Include/ARMv8MML_DSP.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,050
```c /****************************************************************************** * @file startup_ARMv8MML.c * @brief CMSIS-Core Device Startup File for ARMv8MML Device * @version V2.1.0 * @date 16. December 2020 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #if defined (ARMv8MML) #include "ARMv8MML.h" #elif defined (ARMv8MML_DSP) #include "ARMv8MML_DSP.h" #elif defined (ARMv8MML_SP) #include "ARMv8MML_SP.h" #elif defined (ARMv8MML_DSP_SP) #include "ARMv8MML_DSP_SP.h" #elif defined (ARMv8MML_DP) #include "ARMv8MML_DP.h" #elif defined (ARMv8MML_DSP_DP) #include "ARMv8MML_DSP_DP.h" #else #error device not specified! #endif /*your_sha256_hash------------ External References *your_sha256_hash------------*/ extern uint32_t __INITIAL_SP; extern uint32_t __STACK_LIMIT; #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) extern uint32_t __STACK_SEAL; #endif extern __NO_RETURN void __PROGRAM_START(void); /*your_sha256_hash------------ Internal References *your_sha256_hash------------*/ __NO_RETURN void Reset_Handler (void); void Default_Handler(void); /*your_sha256_hash------------ Exception / Interrupt Handler *your_sha256_hash------------*/ /* Exceptions */ void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void HardFault_Handler (void) __attribute__ ((weak)); void MemManage_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void BusFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void UsageFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void SecureFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void DebugMon_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void Interrupt0_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void Interrupt1_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void Interrupt2_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void Interrupt3_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void Interrupt4_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void Interrupt5_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void Interrupt6_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void Interrupt7_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void Interrupt8_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void Interrupt9_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); /*your_sha256_hash------------ Exception / Interrupt Vector table *your_sha256_hash------------*/ #if defined ( __GNUC__ ) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" #endif extern const VECTOR_TABLE_Type __VECTOR_TABLE[496]; const VECTOR_TABLE_Type __VECTOR_TABLE[496] __VECTOR_TABLE_ATTRIBUTE = { (VECTOR_TABLE_Type)(&__INITIAL_SP), /* Initial Stack Pointer */ Reset_Handler, /* Reset Handler */ NMI_Handler, /* -14 NMI Handler */ HardFault_Handler, /* -13 Hard Fault Handler */ MemManage_Handler, /* -12 MPU Fault Handler */ BusFault_Handler, /* -11 Bus Fault Handler */ UsageFault_Handler, /* -10 Usage Fault Handler */ SecureFault_Handler, /* -9 Secure Fault Handler */ 0, /* Reserved */ 0, /* Reserved */ 0, /* Reserved */ SVC_Handler, /* -5 SVC Handler */ DebugMon_Handler, /* -4 Debug Monitor Handler */ 0, /* Reserved */ PendSV_Handler, /* -2 PendSV Handler */ SysTick_Handler, /* -1 SysTick Handler */ /* Interrupts */ Interrupt0_Handler, /* 0 Interrupt 0 */ Interrupt1_Handler, /* 1 Interrupt 1 */ Interrupt2_Handler, /* 2 Interrupt 2 */ Interrupt3_Handler, /* 3 Interrupt 3 */ Interrupt4_Handler, /* 4 Interrupt 4 */ Interrupt5_Handler, /* 5 Interrupt 5 */ Interrupt6_Handler, /* 6 Interrupt 6 */ Interrupt7_Handler, /* 7 Interrupt 7 */ Interrupt8_Handler, /* 8 Interrupt 8 */ Interrupt9_Handler /* 9 Interrupt 9 */ /* Interrupts 10 .. 480 are left out */ }; #if defined ( __GNUC__ ) #pragma GCC diagnostic pop #endif /*your_sha256_hash------------ Reset Handler called on controller reset *your_sha256_hash------------*/ __NO_RETURN void Reset_Handler(void) { __set_PSP((uint32_t)(&__INITIAL_SP)); __set_MSPLIM((uint32_t)(&__STACK_LIMIT)); __set_PSPLIM((uint32_t)(&__STACK_LIMIT)); #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) __TZ_set_STACKSEAL_S((uint32_t *)(&__STACK_SEAL)); #endif SystemInit(); /* CMSIS System Initialization */ __PROGRAM_START(); /* Enter PreMain (C library entry point) */ } #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmissing-noreturn" #endif /*your_sha256_hash------------ Hard Fault Handler *your_sha256_hash------------*/ void HardFault_Handler(void) { while(1); } /*your_sha256_hash------------ Default Handler for Exceptions / Interrupts *your_sha256_hash------------*/ void Default_Handler(void) { while(1); } #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic pop #endif ```
/content/code_sandbox/Device/ARM/ARMv8MML/Source/startup_ARMv8MML.c
c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,469
```c /**************************************************************************//** * @file system_ARMv8MML.c * @brief CMSIS Device System Source File for * ARMv8MML Device * @version V1.0.1 * @date 15. November 2019 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #if defined (ARMv8MML) #include "ARMv8MML.h" #elif defined (ARMv8MML_DSP) #include "ARMv8MML_DSP.h" #elif defined (ARMv8MML_SP) #include "ARMv8MML_SP.h" #elif defined (ARMv8MML_DSP_SP) #include "ARMv8MML_DSP_SP.h" #elif defined (ARMv8MML_DP) #include "ARMv8MML_DP.h" #elif defined (ARMv8MML_DSP_DP) #include "ARMv8MML_DSP_DP.h" #else #error device not specified! #endif #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) #include "partition_ARMv8MML.h" #endif /*your_sha256_hash------------ Define clocks *your_sha256_hash------------*/ #define XTAL (50000000UL) /* Oscillator frequency */ #define SYSTEM_CLOCK (XTAL / 2U) /*your_sha256_hash------------ Exception / Interrupt Vector table *your_sha256_hash------------*/ extern const VECTOR_TABLE_Type __VECTOR_TABLE[496]; /*your_sha256_hash------------ System Core Clock Variable *your_sha256_hash------------*/ uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Core Clock Frequency */ /*your_sha256_hash------------ System Core Clock update function *your_sha256_hash------------*/ void SystemCoreClockUpdate (void) { SystemCoreClock = SYSTEM_CLOCK; } /*your_sha256_hash------------ System initialization function *your_sha256_hash------------*/ void SystemInit (void) { #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) SCB->VTOR = (uint32_t) &(__Vectors[0]); #endif #if defined (__FPU_USED) && (__FPU_USED == 1U) SCB->CPACR |= ((3U << 10U*2U) | /* enable CP10 Full Access */ (3U << 11U*2U) ); /* enable CP11 Full Access */ #endif #ifdef UNALIGNED_SUPPORT_DISABLE SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk; #endif #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) TZ_SAU_Setup(); #endif SystemCoreClock = SYSTEM_CLOCK; } ```
/content/code_sandbox/Device/ARM/ARMv8MML/Source/system_ARMv8MML.c
c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
629
```gas ;/**************************************************************************//** ; * @file startup_ARMv8MML.s ; * @brief CMSIS Core Device Startup File for ; * ARMv8MML Device ; * @version V1.0.0 ; * @date 09. July 2018 ; ******************************************************************************/ ;/* ; * ; * ; * ; * www.apache.org/licenses/LICENSE-2.0 ; * ; * Unless required by applicable law or agreed to in writing, software ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; */ ; ; The modules in this file are included in the libraries, and may be replaced ; by any user-defined modules that define the PUBLIC symbol _program_start or ; a user defined start symbol. ; To override the cstartup defined in the library, simply add your modified ; version to the workbench project. ; ; The vector table is normally located at address 0. ; When debugging in RAM, it can be located in RAM, aligned to at least 2^6. ; The name "__vector_table" has special meaning for C-SPY: ; it is where the SP start value is found, and the NVIC vector ; table register (VTOR) is initialized to this address if != 0. ; ; Cortex-M version ; MODULE ?cstartup ;; Forward declaration of sections. SECTION CSTACK:DATA:NOROOT(3) SECTION .intvec:CODE:NOROOT(2) EXTERN __iar_program_start EXTERN SystemInit PUBLIC __vector_table PUBLIC __vector_table_0x1c PUBLIC __Vectors PUBLIC __Vectors_End PUBLIC __Vectors_Size DATA __vector_table DCD sfe(CSTACK) ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; -14 NMI Handler DCD HardFault_Handler ; -13 Hard Fault Handler DCD MemManage_Handler ; -12 MPU Fault Handler DCD BusFault_Handler ; -11 Bus Fault Handler DCD UsageFault_Handler ; -10 Usage Fault Handler __vector_table_0x1c DCD SecureFault_Handler ; -9 Security Fault Handler DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD SVC_Handler ; -5 SVC Handler DCD DebugMon_Handler ; -4 Debug Monitor Handler DCD 0 ; Reserved DCD PendSV_Handler ; -2 PendSV Handler DCD SysTick_Handler ; -1 SysTick Handler ; Interrupts DCD Interrupt0_Handler ; 0 Interrupt 0 DCD Interrupt1_Handler ; 1 Interrupt 1 DCD Interrupt2_Handler ; 2 Interrupt 2 DCD Interrupt3_Handler ; 3 Interrupt 3 DCD Interrupt4_Handler ; 4 Interrupt 4 DCD Interrupt5_Handler ; 5 Interrupt 5 DCD Interrupt6_Handler ; 6 Interrupt 6 DCD Interrupt7_Handler ; 7 Interrupt 7 DCD Interrupt8_Handler ; 8 Interrupt 8 DCD Interrupt9_Handler ; 9 Interrupt 9 DS32 (470) ; Interrupts 10 .. 480 are left out __Vectors_End __Vectors EQU __vector_table __Vectors_Size EQU __Vectors_End - __Vectors THUMB ; Reset Handler PUBWEAK Reset_Handler SECTION .text:CODE:REORDER:NOROOT(2) Reset_Handler LDR R0, =SystemInit BLX R0 LDR R0, =__iar_program_start BX R0 PUBWEAK NMI_Handler PUBWEAK HardFault_Handler PUBWEAK MemManage_Handler PUBWEAK BusFault_Handler PUBWEAK UsageFault_Handler PUBWEAK SecureFault_Handler PUBWEAK SVC_Handler PUBWEAK DebugMon_Handler PUBWEAK PendSV_Handler PUBWEAK SysTick_Handler PUBWEAK Interrupt0_Handler PUBWEAK Interrupt1_Handler PUBWEAK Interrupt2_Handler PUBWEAK Interrupt3_Handler PUBWEAK Interrupt4_Handler PUBWEAK Interrupt5_Handler PUBWEAK Interrupt6_Handler PUBWEAK Interrupt7_Handler PUBWEAK Interrupt8_Handler PUBWEAK Interrupt9_Handler SECTION .text:CODE:REORDER:NOROOT(1) NMI_Handler HardFault_Handler MemManage_Handler BusFault_Handler UsageFault_Handler SecureFault_Handler SVC_Handler DebugMon_Handler PendSV_Handler SysTick_Handler Interrupt0_Handler Interrupt1_Handler Interrupt2_Handler Interrupt3_Handler Interrupt4_Handler Interrupt5_Handler Interrupt6_Handler Interrupt7_Handler Interrupt8_Handler Interrupt9_Handler Default_Handler B . END ```
/content/code_sandbox/Device/ARM/ARMv8MML/Source/IAR/startup_ARMv8MML.s
gas
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,165
```objective-c /**************************************************************************//** * @file ARMCM0.h * @brief CMSIS Core Peripheral Access Layer Header File for * ARMCM0 Device * @version V5.3.2 * @date 01. May 2023 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef ARMCM0_H #define ARMCM0_H #ifdef __cplusplus extern "C" { #endif /* ------------------------- Interrupt Number Definition ------------------------ */ typedef enum IRQn { /* ------------------- Processor Exceptions Numbers ----------------------------- */ NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */ HardFault_IRQn = -13, /* 3 HardFault Interrupt */ SVCall_IRQn = -5, /* 11 SV Call Interrupt */ PendSV_IRQn = -2, /* 14 Pend SV Interrupt */ SysTick_IRQn = -1, /* 15 System Tick Interrupt */ /* ------------------- Processor Interrupt Numbers ------------------------------ */ Interrupt0_IRQn = 0, Interrupt1_IRQn = 1, Interrupt2_IRQn = 2, Interrupt3_IRQn = 3, Interrupt4_IRQn = 4, Interrupt5_IRQn = 5, Interrupt6_IRQn = 6, Interrupt7_IRQn = 7, Interrupt8_IRQn = 8, Interrupt9_IRQn = 9, /* Interrupts 10 .. 30 are left out */ Interrupt31_IRQn = 31 } IRQn_Type; /* ================================================================================ */ /* ================ Processor and Core Peripheral Section ================ */ /* ================================================================================ */ /* ------- Start of section using anonymous unions and disabling warnings ------- */ #if defined (__CC_ARM) #pragma push #pragma anon_unions #elif defined (__ICCARM__) #pragma language=extended #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc11-extensions" #pragma clang diagnostic ignored "-Wreserved-id-macro" #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning 586 #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif /* -------- Configuration of Core Peripherals ----------------------------------- */ #define __CM0_REV 0x0000U /* Core revision r0p0 */ #define __MPU_PRESENT 0U /* no MPU present */ #define __VTOR_PRESENT 0U /* no VTOR present */ #define __NVIC_PRIO_BITS 2U /* Number of Bits used for Priority Levels */ #define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */ #include "core_cm0.h" /* Processor and core peripherals */ #include "system_ARMCM0.h" /* System Header */ /* -------- End of section using anonymous unions and disabling warnings -------- */ #if defined (__CC_ARM) #pragma pop #elif defined (__ICCARM__) /* leave anonymous unions enabled */ #elif (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) #pragma clang diagnostic pop #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning restore #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif #ifdef __cplusplus } #endif #endif /* ARMCM0_H */ ```
/content/code_sandbox/Device/ARM/ARMCM0/Include/ARMCM0.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
861
```objective-c /**************************************************************************//** * @file system_ARMCM0.h * @brief CMSIS Device System Header File for * ARMCM0 Device * @version V5.3.3 * @date 11. July 2022 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef SYSTEM_ARMCM0_H #define SYSTEM_ARMCM0_H #ifdef __cplusplus extern "C" { #endif #include <stdint.h> /** \brief Exception / Interrupt Handler Function Prototype */ typedef void(*VECTOR_TABLE_Type)(void); /** \brief System Clock Frequency (Core Clock) */ extern uint32_t SystemCoreClock; /** \brief Setup the microcontroller system. Initialize the System and update the SystemCoreClock variable. */ extern void SystemInit (void); /** \brief Update SystemCoreClock variable. Updates the SystemCoreClock with current core Clock retrieved from cpu registers. */ extern void SystemCoreClockUpdate (void); #ifdef __cplusplus } #endif #endif /* SYSTEM_ARMCM0_H */ ```
/content/code_sandbox/Device/ARM/ARMCM0/Include/system_ARMCM0.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
253
```objective-c /**************************************************************************//** * @file partition_ARMv8MML.h * @brief CMSIS-CORE Initial Setup for Secure / Non-Secure Zones for Armv8-M Mainline * @version V1.1.1 * @date 18. March 2019 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef PARTITION_ARMv8MML_H #define PARTITION_ARMv8MML_H /* //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- */ /* // <e>Initialize Security Attribution Unit (SAU) CTRL register */ #define SAU_INIT_CTRL 1 /* // <q> Enable SAU // <i> Value for SAU->CTRL register bit ENABLE */ #define SAU_INIT_CTRL_ENABLE 1 /* // <o> When SAU is disabled // <0=> All Memory is Secure // <1=> All Memory is Non-Secure // <i> Value for SAU->CTRL register bit ALLNS // <i> When all Memory is Non-Secure (ALLNS is 1), IDAU can override memory map configuration. */ #define SAU_INIT_CTRL_ALLNS 0 /* // </e> */ /* // <h>Initialize Security Attribution Unit (SAU) Address Regions // <i>SAU configuration specifies regions to be one of: // <i> - Secure and Non-Secure Callable // <i> - Non-Secure // <i>Note: All memory regions not configured by SAU are Secure */ #define SAU_REGIONS_MAX 8 /* Max. number of SAU regions */ /* // <e>Initialize SAU Region 0 // <i> Setup SAU Region 0 memory attributes */ #define SAU_INIT_REGION0 1 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START0 0x00000000 /* start address of SAU region 0 */ /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END0 0x001FFFFF /* end address of SAU region 0 */ /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC0 1 /* // </e> */ /* // <e>Initialize SAU Region 1 // <i> Setup SAU Region 1 memory attributes */ #define SAU_INIT_REGION1 1 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START1 0x00200000 /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END1 0x003FFFFF /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC1 0 /* // </e> */ /* // <e>Initialize SAU Region 2 // <i> Setup SAU Region 2 memory attributes */ #define SAU_INIT_REGION2 1 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START2 0x20200000 /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END2 0x203FFFFF /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC2 0 /* // </e> */ /* // <e>Initialize SAU Region 3 // <i> Setup SAU Region 3 memory attributes */ #define SAU_INIT_REGION3 1 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START3 0x40000000 /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END3 0x40040000 /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC3 0 /* // </e> */ /* // <e>Initialize SAU Region 4 // <i> Setup SAU Region 4 memory attributes */ #define SAU_INIT_REGION4 0 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START4 0x00000000 /* start address of SAU region 4 */ /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END4 0x00000000 /* end address of SAU region 4 */ /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC4 0 /* // </e> */ /* // <e>Initialize SAU Region 5 // <i> Setup SAU Region 5 memory attributes */ #define SAU_INIT_REGION5 0 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START5 0x00000000 /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END5 0x00000000 /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC5 0 /* // </e> */ /* // <e>Initialize SAU Region 6 // <i> Setup SAU Region 6 memory attributes */ #define SAU_INIT_REGION6 0 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START6 0x00000000 /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END6 0x00000000 /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC6 0 /* // </e> */ /* // <e>Initialize SAU Region 7 // <i> Setup SAU Region 7 memory attributes */ #define SAU_INIT_REGION7 0 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START7 0x00000000 /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END7 0x00000000 /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC7 0 /* // </e> */ /* // </h> */ /* // <e>Setup behaviour of Sleep and Exception Handling */ #define SCB_CSR_AIRCR_INIT 1 /* // <o> Deep Sleep can be enabled by // <0=>Secure and Non-Secure state // <1=>Secure state only // <i> Value for SCB->CSR register bit DEEPSLEEPS */ #define SCB_CSR_DEEPSLEEPS_VAL 1 /* // <o>System reset request accessible from // <0=> Secure and Non-Secure state // <1=> Secure state only // <i> Value for SCB->AIRCR register bit SYSRESETREQS */ #define SCB_AIRCR_SYSRESETREQS_VAL 1 /* // <o>Priority of Non-Secure exceptions is // <0=> Not altered // <1=> Lowered to 0x80-0xFF // <i> Value for SCB->AIRCR register bit PRIS */ #define SCB_AIRCR_PRIS_VAL 1 /* // <o>BusFault, HardFault, and NMI target // <0=> Secure state // <1=> Non-Secure state // <i> Value for SCB->AIRCR register bit BFHFNMINS */ #define SCB_AIRCR_BFHFNMINS_VAL 0 /* // </e> */ /* // <e>Setup behaviour of Floating Point Unit */ #define TZ_FPU_NS_USAGE 1 /* // <o>Floating Point Unit usage // <0=> Secure state only // <3=> Secure and Non-Secure state // <i> Value for SCB->NSACR register bits CP10, CP11 */ #define SCB_NSACR_CP10_11_VAL 3 /* // <o>Treat floating-point registers as Secure // <0=> Disabled // <1=> Enabled // <i> Value for FPU->FPCCR register bit TS */ #define FPU_FPCCR_TS_VAL 0 /* // <o>Clear on return (CLRONRET) accessibility // <0=> Secure and Non-Secure state // <1=> Secure state only // <i> Value for FPU->FPCCR register bit CLRONRETS */ #define FPU_FPCCR_CLRONRETS_VAL 0 /* // <o>Clear floating-point caller saved registers on exception return // <0=> Disabled // <1=> Enabled // <i> Value for FPU->FPCCR register bit CLRONRET */ #define FPU_FPCCR_CLRONRET_VAL 1 /* // </e> */ /* // <h>Setup Interrupt Target */ /* // <e>Initialize ITNS 0 (Interrupts 0..31) */ #define NVIC_INIT_ITNS0 1 /* // Interrupts 0..31 // <o.0> Interrupt 0 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 1 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 2 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 3 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 4 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 5 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 6 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 7 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 8 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 9 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 10 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 11 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 12 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 13 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 14 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 15 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 16 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 17 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 18 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 19 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 20 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 21 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 22 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 23 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 24 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 25 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 26 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 27 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 28 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 29 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 30 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 31 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS0_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 1 (Interrupts 32..63) */ #define NVIC_INIT_ITNS1 1 /* // Interrupts 32..63 // <o.0> Interrupt 32 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 33 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 34 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 35 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 36 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 37 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 38 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 39 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 40 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 41 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 42 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 43 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 44 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 45 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 46 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 47 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 48 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 49 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 50 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 51 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 52 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 53 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 54 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 55 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 56 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 57 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 58 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 59 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 60 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 61 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 62 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 63 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS1_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 2 (Interrupts 64..95) */ #define NVIC_INIT_ITNS2 0 /* // Interrupts 64..95 // <o.0> Interrupt 64 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 65 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 66 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 67 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 68 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 69 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 70 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 71 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 72 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 73 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 74 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 75 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 76 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 77 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 78 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 79 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 80 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 81 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 82 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 83 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 84 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 85 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 86 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 87 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 88 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 89 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 90 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 91 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 92 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 93 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 94 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 95 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS2_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 3 (Interrupts 96..127) */ #define NVIC_INIT_ITNS3 0 /* // Interrupts 96..127 // <o.0> Interrupt 96 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 97 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 98 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 99 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 100 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 101 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 102 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 103 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 104 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 105 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 106 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 107 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 108 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 109 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 110 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 111 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 112 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 113 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 114 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 115 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 116 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 117 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 118 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 119 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 120 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 121 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 122 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 123 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 124 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 125 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 126 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 127 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS3_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 4 (Interrupts 128..159) */ #define NVIC_INIT_ITNS4 0 /* // Interrupts 128..159 // <o.0> Interrupt 128 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 129 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 130 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 131 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 132 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 133 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 134 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 135 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 136 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 137 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 138 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 139 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 140 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 141 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 142 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 143 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 144 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 145 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 146 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 147 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 148 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 149 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 150 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 151 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 152 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 153 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 154 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 155 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 156 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 157 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 158 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 159 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS4_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 5 (Interrupts 160..191) */ #define NVIC_INIT_ITNS5 0 /* // Interrupts 160..191 // <o.0> Interrupt 160 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 161 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 162 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 163 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 164 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 165 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 166 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 167 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 168 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 169 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 170 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 171 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 172 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 173 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 174 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 175 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 176 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 177 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 178 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 179 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 180 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 181 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 182 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 183 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 184 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 185 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 186 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 187 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 188 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 189 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 190 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 191 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS5_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 6 (Interrupts 192..223) */ #define NVIC_INIT_ITNS6 0 /* // Interrupts 192..223 // <o.0> Interrupt 192 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 193 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 194 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 195 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 196 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 197 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 198 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 199 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 200 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 201 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 202 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 203 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 204 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 205 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 206 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 207 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 208 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 209 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 210 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 211 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 212 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 213 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 214 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 215 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 216 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 217 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 218 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 219 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 220 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 221 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 222 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 223 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS6_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 7 (Interrupts 224..255) */ #define NVIC_INIT_ITNS7 0 /* // Interrupts 224..255 // <o.0> Interrupt 224 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 225 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 226 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 227 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 228 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 229 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 230 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 231 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 232 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 233 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 234 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 235 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 236 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 237 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 238 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 239 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 240 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 241 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 242 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 243 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 244 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 245 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 246 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 247 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 248 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 249 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 250 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 251 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 252 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 253 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 254 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 255 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS7_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 8 (Interrupts 256..287) */ #define NVIC_INIT_ITNS8 0 /* // Interrupts 256..287 // <o.0> Interrupt 256 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 257 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 258 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 259 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 260 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 261 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 262 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 263 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 264 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 265 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 266 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 267 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 268 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 269 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 270 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 271 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 272 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 273 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 274 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 275 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 276 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 277 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 278 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 279 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 280 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 281 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 282 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 283 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 284 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 285 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 286 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 287 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS8_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 9 (Interrupts 288..319) */ #define NVIC_INIT_ITNS9 0 /* // Interrupts 288..319 // <o.0> Interrupt 288 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 289 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 290 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 291 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 292 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 293 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 294 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 295 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 296 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 297 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 298 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 299 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 300 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 301 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 302 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 303 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 304 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 305 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 306 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 307 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 308 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 309 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 310 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 311 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 312 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 313 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 314 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 315 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 316 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 317 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 318 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 319 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS9_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 10 (Interrupts 320..351) */ #define NVIC_INIT_ITNS10 0 /* // Interrupts 320..351 // <o.0> Interrupt 320 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 321 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 322 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 323 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 324 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 325 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 326 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 327 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 328 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 329 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 330 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 331 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 332 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 333 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 334 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 335 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 336 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 337 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 338 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 339 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 340 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 341 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 342 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 343 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 344 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 345 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 346 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 347 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 348 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 349 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 350 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 351 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS10_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 11 (Interrupts 352..383) */ #define NVIC_INIT_ITNS11 0 /* // Interrupts 352..383 // <o.0> Interrupt 352 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 353 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 354 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 355 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 356 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 357 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 358 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 359 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 360 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 361 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 362 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 363 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 364 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 365 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 366 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 367 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 368 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 369 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 370 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 371 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 372 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 373 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 374 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 375 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 376 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 377 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 378 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 379 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 380 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 381 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 382 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 383 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS11_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 12 (Interrupts 384..415) */ #define NVIC_INIT_ITNS12 0 /* // Interrupts 384..415 // <o.0> Interrupt 384 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 385 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 386 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 387 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 388 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 389 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 390 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 391 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 392 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 393 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 394 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 395 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 396 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 397 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 398 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 399 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 400 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 401 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 402 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 403 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 404 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 405 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 406 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 407 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 408 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 409 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 410 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 411 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 412 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 413 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 414 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 415 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS12_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 13 (Interrupts 416..447) */ #define NVIC_INIT_ITNS13 0 /* // Interrupts 416..447 // <o.0> Interrupt 416 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 417 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 418 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 419 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 420 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 421 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 422 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 423 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 424 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 425 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 426 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 427 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 428 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 429 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 430 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 431 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 432 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 433 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 434 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 435 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 436 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 437 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 438 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 439 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 440 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 441 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 442 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 443 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 444 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 445 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 446 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 447 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS13_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 14 (Interrupts 448..479) */ #define NVIC_INIT_ITNS14 0 /* // Interrupts 448..479 // <o.0> Interrupt 448 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 449 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 450 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 451 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 452 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 453 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 454 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 455 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 456 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 457 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 458 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 459 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 460 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 461 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 462 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 463 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 464 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 465 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 466 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 467 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 468 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 469 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 470 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 471 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 472 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 473 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 474 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 475 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 476 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 477 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 478 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 479 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS14_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 15 (Interrupts 480..511) */ #define NVIC_INIT_ITNS15 0 /* // Interrupts 480..511 // <o.0> Interrupt 480 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 481 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 482 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 483 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 484 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 485 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 486 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 487 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 488 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 489 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 490 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 491 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 492 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 493 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 494 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 495 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 496 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 497 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 498 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 499 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 500 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 501 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 502 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 503 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 504 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 505 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 506 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 507 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 508 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 509 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 510 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 511 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS15_VAL 0x00000000 /* // </e> */ /* // </h> */ /* max 128 SAU regions. SAU regions are defined in partition.h */ #define SAU_INIT_REGION(n) \ SAU->RNR = (n & SAU_RNR_REGION_Msk); \ SAU->RBAR = (SAU_INIT_START##n & SAU_RBAR_BADDR_Msk); \ SAU->RLAR = (SAU_INIT_END##n & SAU_RLAR_LADDR_Msk) | \ ((SAU_INIT_NSC##n << SAU_RLAR_NSC_Pos) & SAU_RLAR_NSC_Msk) | 1U /** \brief Setup a SAU Region \details Writes the region information contained in SAU_Region to the registers SAU_RNR, SAU_RBAR, and SAU_RLAR */ __STATIC_INLINE void TZ_SAU_Setup (void) { #if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) #if defined (SAU_INIT_REGION0) && (SAU_INIT_REGION0 == 1U) SAU_INIT_REGION(0); #endif #if defined (SAU_INIT_REGION1) && (SAU_INIT_REGION1 == 1U) SAU_INIT_REGION(1); #endif #if defined (SAU_INIT_REGION2) && (SAU_INIT_REGION2 == 1U) SAU_INIT_REGION(2); #endif #if defined (SAU_INIT_REGION3) && (SAU_INIT_REGION3 == 1U) SAU_INIT_REGION(3); #endif #if defined (SAU_INIT_REGION4) && (SAU_INIT_REGION4 == 1U) SAU_INIT_REGION(4); #endif #if defined (SAU_INIT_REGION5) && (SAU_INIT_REGION5 == 1U) SAU_INIT_REGION(5); #endif #if defined (SAU_INIT_REGION6) && (SAU_INIT_REGION6 == 1U) SAU_INIT_REGION(6); #endif #if defined (SAU_INIT_REGION7) && (SAU_INIT_REGION7 == 1U) SAU_INIT_REGION(7); #endif /* repeat this for all possible SAU regions */ #endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ #if defined (SAU_INIT_CTRL) && (SAU_INIT_CTRL == 1U) SAU->CTRL = ((SAU_INIT_CTRL_ENABLE << SAU_CTRL_ENABLE_Pos) & SAU_CTRL_ENABLE_Msk) | ((SAU_INIT_CTRL_ALLNS << SAU_CTRL_ALLNS_Pos) & SAU_CTRL_ALLNS_Msk) ; #endif #if defined (SCB_CSR_AIRCR_INIT) && (SCB_CSR_AIRCR_INIT == 1U) SCB->SCR = (SCB->SCR & ~(SCB_SCR_SLEEPDEEPS_Msk )) | ((SCB_CSR_DEEPSLEEPS_VAL << SCB_SCR_SLEEPDEEPS_Pos) & SCB_SCR_SLEEPDEEPS_Msk); SCB->AIRCR = (SCB->AIRCR & ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_SYSRESETREQS_Msk | SCB_AIRCR_BFHFNMINS_Msk | SCB_AIRCR_PRIS_Msk )) | ((0x05FAU << SCB_AIRCR_VECTKEY_Pos) & SCB_AIRCR_VECTKEY_Msk) | ((SCB_AIRCR_SYSRESETREQS_VAL << SCB_AIRCR_SYSRESETREQS_Pos) & SCB_AIRCR_SYSRESETREQS_Msk) | ((SCB_AIRCR_PRIS_VAL << SCB_AIRCR_PRIS_Pos) & SCB_AIRCR_PRIS_Msk) | ((SCB_AIRCR_BFHFNMINS_VAL << SCB_AIRCR_BFHFNMINS_Pos) & SCB_AIRCR_BFHFNMINS_Msk); #endif /* defined (SCB_CSR_AIRCR_INIT) && (SCB_CSR_AIRCR_INIT == 1U) */ #if defined (__FPU_USED) && (__FPU_USED == 1U) && \ defined (TZ_FPU_NS_USAGE) && (TZ_FPU_NS_USAGE == 1U) SCB->NSACR = (SCB->NSACR & ~(SCB_NSACR_CP10_Msk | SCB_NSACR_CP11_Msk)) | ((SCB_NSACR_CP10_11_VAL << SCB_NSACR_CP10_Pos) & (SCB_NSACR_CP10_Msk | SCB_NSACR_CP11_Msk)); FPU->FPCCR = (FPU->FPCCR & ~(FPU_FPCCR_TS_Msk | FPU_FPCCR_CLRONRETS_Msk | FPU_FPCCR_CLRONRET_Msk)) | ((FPU_FPCCR_TS_VAL << FPU_FPCCR_TS_Pos ) & FPU_FPCCR_TS_Msk ) | ((FPU_FPCCR_CLRONRETS_VAL << FPU_FPCCR_CLRONRETS_Pos) & FPU_FPCCR_CLRONRETS_Msk) | ((FPU_FPCCR_CLRONRET_VAL << FPU_FPCCR_CLRONRET_Pos ) & FPU_FPCCR_CLRONRET_Msk ); #endif #if defined (NVIC_INIT_ITNS0) && (NVIC_INIT_ITNS0 == 1U) NVIC->ITNS[0] = NVIC_INIT_ITNS0_VAL; #endif #if defined (NVIC_INIT_ITNS1) && (NVIC_INIT_ITNS1 == 1U) NVIC->ITNS[1] = NVIC_INIT_ITNS1_VAL; #endif #if defined (NVIC_INIT_ITNS2) && (NVIC_INIT_ITNS2 == 1U) NVIC->ITNS[2] = NVIC_INIT_ITNS2_VAL; #endif #if defined (NVIC_INIT_ITNS3) && (NVIC_INIT_ITNS3 == 1U) NVIC->ITNS[3] = NVIC_INIT_ITNS3_VAL; #endif #if defined (NVIC_INIT_ITNS4) && (NVIC_INIT_ITNS4 == 1U) NVIC->ITNS[4] = NVIC_INIT_ITNS4_VAL; #endif #if defined (NVIC_INIT_ITNS5) && (NVIC_INIT_ITNS5 == 1U) NVIC->ITNS[5] = NVIC_INIT_ITNS5_VAL; #endif #if defined (NVIC_INIT_ITNS6) && (NVIC_INIT_ITNS6 == 1U) NVIC->ITNS[6] = NVIC_INIT_ITNS6_VAL; #endif #if defined (NVIC_INIT_ITNS7) && (NVIC_INIT_ITNS7 == 1U) NVIC->ITNS[7] = NVIC_INIT_ITNS7_VAL; #endif #if defined (NVIC_INIT_ITNS8) && (NVIC_INIT_ITNS8 == 1U) NVIC->ITNS[8] = NVIC_INIT_ITNS8_VAL; #endif #if defined (NVIC_INIT_ITNS9) && (NVIC_INIT_ITNS9 == 1U) NVIC->ITNS[9] = NVIC_INIT_ITNS9_VAL; #endif #if defined (NVIC_INIT_ITNS10) && (NVIC_INIT_ITNS10 == 1U) NVIC->ITNS[10] = NVIC_INIT_ITNS10_VAL; #endif #if defined (NVIC_INIT_ITNS11) && (NVIC_INIT_ITNS11 == 1U) NVIC->ITNS[11] = NVIC_INIT_ITNS11_VAL; #endif #if defined (NVIC_INIT_ITNS12) && (NVIC_INIT_ITNS12 == 1U) NVIC->ITNS[12] = NVIC_INIT_ITNS12_VAL; #endif #if defined (NVIC_INIT_ITNS13) && (NVIC_INIT_ITNS13 == 1U) NVIC->ITNS[13] = NVIC_INIT_ITNS13_VAL; #endif #if defined (NVIC_INIT_ITNS14) && (NVIC_INIT_ITNS14 == 1U) NVIC->ITNS[14] = NVIC_INIT_ITNS14_VAL; #endif #if defined (NVIC_INIT_ITNS15) && (NVIC_INIT_ITNS15 == 1U) NVIC->ITNS[15] = NVIC_INIT_ITNS15_VAL; #endif /* repeat this for all possible ITNS elements */ } #endif /* PARTITION_ARMv8MML_H */ ```
/content/code_sandbox/Device/ARM/ARMv8MML/Include/Template/partition_ARMv8MML.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
17,195
```gas ;/**************************************************************************//** ; * @file startup_ARMCM0.s ; * @brief CMSIS Core Device Startup File for ; * ARMCM0 Device ; * @version V1.0.1 ; * @date 23. July 2019 ; ******************************************************************************/ ;/* ; * ; * ; * ; * www.apache.org/licenses/LICENSE-2.0 ; * ; * Unless required by applicable law or agreed to in writing, software ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; */ ;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ ;<h> Stack Configuration ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> ;</h> Stack_Size EQU 0x00000400 AREA STACK, NOINIT, READWRITE, ALIGN=3 __stack_limit Stack_Mem SPACE Stack_Size __initial_sp ;<h> Heap Configuration ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> ;</h> Heap_Size EQU 0x00000C00 IF Heap_Size != 0 ; Heap is provided AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit ENDIF PRESERVE8 THUMB ; Vector Table Mapped to Address 0 at Reset AREA RESET, DATA, READONLY EXPORT __Vectors EXPORT __Vectors_End EXPORT __Vectors_Size __Vectors DCD __initial_sp ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; -14 NMI Handler DCD HardFault_Handler ; -13 Hard Fault Handler DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD SVC_Handler ; -5 SVCall Handler DCD 0 ; Reserved DCD 0 ; Reserved DCD PendSV_Handler ; -2 PendSV Handler DCD SysTick_Handler ; -1 SysTick Handler ; Interrupts DCD Interrupt0_Handler ; 0 Interrupt 0 DCD Interrupt1_Handler ; 1 Interrupt 1 DCD Interrupt2_Handler ; 2 Interrupt 2 DCD Interrupt3_Handler ; 3 Interrupt 3 DCD Interrupt4_Handler ; 4 Interrupt 4 DCD Interrupt5_Handler ; 5 Interrupt 5 DCD Interrupt6_Handler ; 6 Interrupt 6 DCD Interrupt7_Handler ; 7 Interrupt 7 DCD Interrupt8_Handler ; 8 Interrupt 8 DCD Interrupt9_Handler ; 9 Interrupt 9 SPACE ( 22 * 4) ; Interrupts 10 .. 31 are left out __Vectors_End __Vectors_Size EQU __Vectors_End - __Vectors AREA |.text|, CODE, READONLY ; Reset Handler Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT __main LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP ; The default macro is not used for HardFault_Handler ; because this results in a poor debug illusion. HardFault_Handler PROC EXPORT HardFault_Handler [WEAK] B . ENDP ; Macro to define default exception/interrupt handlers. ; Default handler are weak symbols with an endless loop. ; They can be overwritten by real handlers. MACRO Set_Default_Handler $Handler_Name $Handler_Name PROC EXPORT $Handler_Name [WEAK] B . ENDP MEND ; Default exception/interrupt handler Set_Default_Handler NMI_Handler Set_Default_Handler SVC_Handler Set_Default_Handler PendSV_Handler Set_Default_Handler SysTick_Handler Set_Default_Handler Interrupt0_Handler Set_Default_Handler Interrupt1_Handler Set_Default_Handler Interrupt2_Handler Set_Default_Handler Interrupt3_Handler Set_Default_Handler Interrupt4_Handler Set_Default_Handler Interrupt5_Handler Set_Default_Handler Interrupt6_Handler Set_Default_Handler Interrupt7_Handler Set_Default_Handler Interrupt8_Handler Set_Default_Handler Interrupt9_Handler ALIGN ; User setup Stack & Heap IF :LNOT::DEF:__MICROLIB IMPORT __use_two_region_memory ENDIF EXPORT __stack_limit EXPORT __initial_sp IF Heap_Size != 0 ; Heap is provided EXPORT __heap_base EXPORT __heap_limit ENDIF END ```
/content/code_sandbox/Device/ARM/ARMCM0/Source/ARM/startup_ARMCM0.s
gas
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,179
```gas ;/**************************************************************************//** ; * @file startup_ARMCM0.s ; * @brief CMSIS Core Device Startup File for ; * ARMCM0 Device ; * @version V1.0.0 ; * @date 09. July 2018 ; ******************************************************************************/ ;/* ; * ; * ; * ; * www.apache.org/licenses/LICENSE-2.0 ; * ; * Unless required by applicable law or agreed to in writing, software ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; */ ; ; The modules in this file are included in the libraries, and may be replaced ; by any user-defined modules that define the PUBLIC symbol _program_start or ; a user defined start symbol. ; To override the cstartup defined in the library, simply add your modified ; version to the workbench project. ; ; The vector table is normally located at address 0. ; When debugging in RAM, it can be located in RAM, aligned to at least 2^6. ; The name "__vector_table" has special meaning for C-SPY: ; it is where the SP start value is found, and the NVIC vector ; table register (VTOR) is initialized to this address if != 0. ; ; Cortex-M version ; MODULE ?cstartup ;; Forward declaration of sections. SECTION CSTACK:DATA:NOROOT(3) SECTION .intvec:CODE:NOROOT(2) EXTERN __iar_program_start EXTERN SystemInit PUBLIC __vector_table PUBLIC __vector_table_0x1c PUBLIC __Vectors PUBLIC __Vectors_End PUBLIC __Vectors_Size DATA __vector_table DCD sfe(CSTACK) ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; -14 NMI Handler DCD HardFault_Handler ; -13 Hard Fault Handler DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved __vector_table_0x1c DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD SVC_Handler ; -5 SVCall Handler DCD 0 ; Reserved DCD 0 ; Reserved DCD PendSV_Handler ; -2 PendSV Handler DCD SysTick_Handler ; -1 SysTick Handler ; Interrupts DCD Interrupt0_Handler ; 0 Interrupt 0 DCD Interrupt1_Handler ; 1 Interrupt 1 DCD Interrupt2_Handler ; 2 Interrupt 2 DCD Interrupt3_Handler ; 3 Interrupt 3 DCD Interrupt4_Handler ; 4 Interrupt 4 DCD Interrupt5_Handler ; 5 Interrupt 5 DCD Interrupt6_Handler ; 6 Interrupt 6 DCD Interrupt7_Handler ; 7 Interrupt 7 DCD Interrupt8_Handler ; 8 Interrupt 8 DCD Interrupt9_Handler ; 9 Interrupt 9 DS32 ( 22) ; Interrupts 10 .. 31 are left out __Vectors_End __Vectors EQU __vector_table __Vectors_Size EQU __Vectors_End - __Vectors THUMB ; Reset Handler PUBWEAK Reset_Handler SECTION .text:CODE:REORDER:NOROOT(2) Reset_Handler LDR R0, =SystemInit BLX R0 LDR R0, =__iar_program_start BX R0 PUBWEAK NMI_Handler PUBWEAK HardFault_Handler PUBWEAK SVC_Handler PUBWEAK PendSV_Handler PUBWEAK SysTick_Handler PUBWEAK Interrupt0_Handler PUBWEAK Interrupt1_Handler PUBWEAK Interrupt2_Handler PUBWEAK Interrupt3_Handler PUBWEAK Interrupt4_Handler PUBWEAK Interrupt5_Handler PUBWEAK Interrupt6_Handler PUBWEAK Interrupt7_Handler PUBWEAK Interrupt8_Handler PUBWEAK Interrupt9_Handler SECTION .text:CODE:REORDER:NOROOT(1) NMI_Handler HardFault_Handler SVC_Handler PendSV_Handler SysTick_Handler Interrupt0_Handler Interrupt1_Handler Interrupt2_Handler Interrupt3_Handler Interrupt4_Handler Interrupt5_Handler Interrupt6_Handler Interrupt7_Handler Interrupt8_Handler Interrupt9_Handler Default_Handler B . END ```
/content/code_sandbox/Device/ARM/ARMCM0/Source/IAR/startup_ARMCM0.s
gas
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,081
```objective-c /****************************************************************************** * @file ARMCA9.h * @brief CMSIS Cortex-A9 Core Peripheral Access Layer Header File * @version V1.1.0 * @date 15. May 2019 * * @note * ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef __ARMCA9_H__ #define __ARMCA9_H__ #ifdef __cplusplus extern "C" { #endif /* ------------------------- Interrupt Number Definition ------------------------ */ /** Device specific Interrupt IDs */ typedef enum IRQn { /****** SGI Interrupts Numbers ****************************************/ SGI0_IRQn = 0, /*!< Software Generated Interrupt 0 */ SGI1_IRQn = 1, /*!< Software Generated Interrupt 1 */ SGI2_IRQn = 2, /*!< Software Generated Interrupt 2 */ SGI3_IRQn = 3, /*!< Software Generated Interrupt 3 */ SGI4_IRQn = 4, /*!< Software Generated Interrupt 4 */ SGI5_IRQn = 5, /*!< Software Generated Interrupt 5 */ SGI6_IRQn = 6, /*!< Software Generated Interrupt 6 */ SGI7_IRQn = 7, /*!< Software Generated Interrupt 7 */ SGI8_IRQn = 8, /*!< Software Generated Interrupt 8 */ SGI9_IRQn = 9, /*!< Software Generated Interrupt 9 */ SGI10_IRQn = 10, /*!< Software Generated Interrupt 10 */ SGI11_IRQn = 11, /*!< Software Generated Interrupt 11 */ SGI12_IRQn = 12, /*!< Software Generated Interrupt 12 */ SGI13_IRQn = 13, /*!< Software Generated Interrupt 13 */ SGI14_IRQn = 14, /*!< Software Generated Interrupt 14 */ SGI15_IRQn = 15, /*!< Software Generated Interrupt 15 */ /****** Cortex-A9 Processor Exceptions Numbers ****************************************/ GlobalTimer_IRQn = 27, /*!< Global Timer Interrupt */ PrivTimer_IRQn = 29, /*!< Private Timer Interrupt */ PrivWatchdog_IRQn = 30, /*!< Private Watchdog Interrupt */ /****** Platform Exceptions Numbers ***************************************************/ Watchdog_IRQn = 32, /*!< SP805 Interrupt */ Timer0_IRQn = 34, /*!< SP804 Interrupt */ Timer1_IRQn = 35, /*!< SP804 Interrupt */ RTClock_IRQn = 36, /*!< PL031 Interrupt */ UART0_IRQn = 37, /*!< PL011 Interrupt */ UART1_IRQn = 38, /*!< PL011 Interrupt */ UART2_IRQn = 39, /*!< PL011 Interrupt */ UART3_IRQn = 40, /*!< PL011 Interrupt */ MCI0_IRQn = 41, /*!< PL180 Interrupt (1st) */ MCI1_IRQn = 42, /*!< PL180 Interrupt (2nd) */ AACI_IRQn = 43, /*!< PL041 Interrupt */ Keyboard_IRQn = 44, /*!< PL050 Interrupt */ Mouse_IRQn = 45, /*!< PL050 Interrupt */ CLCD_IRQn = 46, /*!< PL111 Interrupt */ Ethernet_IRQn = 47, /*!< SMSC_91C111 Interrupt */ VFS2_IRQn = 73, /*!< VFS2 Interrupt */ } IRQn_Type; /******************************************************************************/ /* Peripheral memory map */ /******************************************************************************/ /* Peripheral and RAM base address */ #define VE_A9_MP_FLASH_BASE0 (0x00000000UL) /*!< (FLASH0 ) Base Address */ #define VE_A9_MP_FLASH_BASE1 (0x0C000000UL) /*!< (FLASH1 ) Base Address */ #define VE_A9_MP_SRAM_BASE (0x14000000UL) /*!< (SRAM ) Base Address */ #define VE_A9_MP_PERIPH_BASE_CS2 (0x18000000UL) /*!< (Peripheral ) Base Address */ #define VE_A9_MP_VRAM_BASE (0x00000000UL + VE_A9_MP_PERIPH_BASE_CS2) /*!< (VRAM ) Base Address */ #define VE_A9_MP_ETHERNET_BASE (0x02000000UL + VE_A9_MP_PERIPH_BASE_CS2) /*!< (ETHERNET ) Base Address */ #define VE_A9_MP_USB_BASE (0x03000000UL + VE_A9_MP_PERIPH_BASE_CS2) /*!< (USB ) Base Address */ #define VE_A9_MP_PERIPH_BASE_CS3 (0x1C000000UL) /*!< (Peripheral ) Base Address */ #define VE_A9_MP_DAP_BASE (0x00000000UL + VE_A9_MP_PERIPH_BASE_CS3) /*!< (LOCAL DAP ) Base Address */ #define VE_A9_MP_SYSTEM_REG_BASE (0x00010000UL + VE_A9_MP_PERIPH_BASE_CS3) /*!< (SYSTEM REG ) Base Address */ #define VE_A9_MP_SERIAL_BASE (0x00030000UL + VE_A9_MP_PERIPH_BASE_CS3) /*!< (SERIAL ) Base Address */ #define VE_A9_MP_AACI_BASE (0x00040000UL + VE_A9_MP_PERIPH_BASE_CS3) /*!< (AACI ) Base Address */ #define VE_A9_MP_MMCI_BASE (0x00050000UL + VE_A9_MP_PERIPH_BASE_CS3) /*!< (MMCI ) Base Address */ #define VE_A9_MP_KMI0_BASE (0x00060000UL + VE_A9_MP_PERIPH_BASE_CS3) /*!< (KMI0 ) Base Address */ #define VE_A9_MP_UART_BASE (0x00090000UL + VE_A9_MP_PERIPH_BASE_CS3) /*!< (UART ) Base Address */ #define VE_A9_MP_WDT_BASE (0x000F0000UL + VE_A9_MP_PERIPH_BASE_CS3) /*!< (WDT ) Base Address */ #define VE_A9_MP_TIMER_BASE (0x00110000UL + VE_A9_MP_PERIPH_BASE_CS3) /*!< (TIMER ) Base Address */ #define VE_A9_MP_DVI_BASE (0x00160000UL + VE_A9_MP_PERIPH_BASE_CS3) /*!< (DVI ) Base Address */ #define VE_A9_MP_RTC_BASE (0x00170000UL + VE_A9_MP_PERIPH_BASE_CS3) /*!< (RTC ) Base Address */ #define VE_A9_MP_UART4_BASE (0x001B0000UL + VE_A9_MP_PERIPH_BASE_CS3) /*!< (UART4 ) Base Address */ #define VE_A9_MP_CLCD_BASE (0x001F0000UL + VE_A9_MP_PERIPH_BASE_CS3) /*!< (CLCD ) Base Address */ #define VE_A9_MP_PL310_BASE (0x1E00A000UL) /*!< (L2C-310 ) Base Address */ #define VE_A9_MP_PRIVATE_PERIPH_BASE (0x2C000000UL) /*!< (Peripheral ) Base Address */ #define VE_A9_MP_GIC_DISTRIBUTOR_BASE (0x00001000UL + VE_A9_MP_PRIVATE_PERIPH_BASE) /*!< (GIC DIST ) Base Address */ #define VE_A9_MP_GIC_INTERFACE_BASE (0x00000100UL + VE_A9_MP_PRIVATE_PERIPH_BASE) /*!< (GIC CPU IF ) Base Address */ #define VE_A9_MP_PRIVATE_TIMER (0x00000600UL + VE_A9_MP_PRIVATE_PERIPH_BASE) /*!< (PTIM ) Base Address */ #define VE_A9_MP_SSRAM_BASE (0x2E000000UL) /*!< (System SRAM) Base Address */ #define VE_A9_MP_DRAM_BASE (0x80000000UL) /*!< (DRAM ) Base Address */ #define GIC_DISTRIBUTOR_BASE VE_A9_MP_GIC_DISTRIBUTOR_BASE #define GIC_INTERFACE_BASE VE_A9_MP_GIC_INTERFACE_BASE #define TIMER_BASE VE_A9_MP_PRIVATE_TIMER //The VE-A9 model implements L1 cache as architecturally defined, but does not implement L2 cache. //Do not enable the L2 cache if you are running RTX on a VE-A9 model as it may cause a data abort. #define L2C_310_BASE VE_A9_MP_PL310_BASE /* -------- Configuration of the Cortex-A9 Processor and Core Peripherals ------- */ #define __CA_REV 0x0000U /*!< Core revision r0p0 */ #define __CORTEX_A 9U /*!< Cortex-A9 Core */ #define __FPU_PRESENT 1U /* FPU present */ #define __GIC_PRESENT 1U /* GIC present */ #define __TIM_PRESENT 1U /* TIM present */ #define __L2C_PRESENT 0U /* L2C present */ #include "core_ca.h" #include <system_ARMCA9.h> #ifdef __cplusplus } #endif #endif // __ARMCA9_H__ ```
/content/code_sandbox/Device/ARM/ARMCA9/Include/ARMCA9.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
2,030
```c /****************************************************************************** * @file startup_ARMCA9.c * @brief CMSIS Device System Source File for Arm Cortex-A9 Device Series * @version V1.0.1 * @date 10. January 2021 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include <ARMCA9.h> /*your_sha256_hash------------ Definitions *your_sha256_hash------------*/ #define USR_MODE 0x10 // User mode #define FIQ_MODE 0x11 // Fast Interrupt Request mode #define IRQ_MODE 0x12 // Interrupt Request mode #define SVC_MODE 0x13 // Supervisor mode #define ABT_MODE 0x17 // Abort mode #define UND_MODE 0x1B // Undefined Instruction mode #define SYS_MODE 0x1F // System mode /*your_sha256_hash------------ Internal References *your_sha256_hash------------*/ void Vectors (void) __attribute__ ((naked, section("RESET"))); void Reset_Handler (void) __attribute__ ((naked)); void Default_Handler(void) __attribute__ ((noreturn)); /*your_sha256_hash------------ Exception / Interrupt Handler *your_sha256_hash------------*/ void Undef_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void PAbt_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void DAbt_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void IRQ_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void FIQ_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); /*your_sha256_hash------------ Exception / Interrupt Vector Table *your_sha256_hash------------*/ void Vectors(void) { __ASM volatile( "LDR PC, =Reset_Handler \n" "LDR PC, =Undef_Handler \n" "LDR PC, =SVC_Handler \n" "LDR PC, =PAbt_Handler \n" "LDR PC, =DAbt_Handler \n" "NOP \n" "LDR PC, =IRQ_Handler \n" "LDR PC, =FIQ_Handler \n" ); } /*your_sha256_hash------------ Reset Handler called on controller reset *your_sha256_hash------------*/ void Reset_Handler(void) { __ASM volatile( // Mask interrupts "CPSID if \n" // Put any cores other than 0 to sleep "MRC p15, 0, R0, c0, c0, 5 \n" // Read MPIDR "ANDS R0, R0, #3 \n" "goToSleep: \n" "WFINE \n" "BNE goToSleep \n" // Reset SCTLR Settings "MRC p15, 0, R0, c1, c0, 0 \n" // Read CP15 System Control register "BIC R0, R0, #(0x1 << 12) \n" // Clear I bit 12 to disable I Cache "BIC R0, R0, #(0x1 << 2) \n" // Clear C bit 2 to disable D Cache "BIC R0, R0, #0x1 \n" // Clear M bit 0 to disable MMU "BIC R0, R0, #(0x1 << 11) \n" // Clear Z bit 11 to disable branch prediction "BIC R0, R0, #(0x1 << 13) \n" // Clear V bit 13 to disable hivecs "MCR p15, 0, R0, c1, c0, 0 \n" // Write value back to CP15 System Control register "ISB \n" // Configure ACTLR "MRC p15, 0, r0, c1, c0, 1 \n" // Read CP15 Auxiliary Control Register "ORR r0, r0, #(1 << 1) \n" // Enable L2 prefetch hint (UNK/WI since r4p1) "MCR p15, 0, r0, c1, c0, 1 \n" // Write CP15 Auxiliary Control Register // Set Vector Base Address Register (VBAR) to point to this application's vector table "LDR R0, =Vectors \n" "MCR p15, 0, R0, c12, c0, 0 \n" // Setup Stack for each exceptional mode "CPS #0x11 \n" "LDR SP, =Image$$FIQ_STACK$$ZI$$Limit \n" "CPS #0x12 \n" "LDR SP, =Image$$IRQ_STACK$$ZI$$Limit \n" "CPS #0x13 \n" "LDR SP, =Image$$SVC_STACK$$ZI$$Limit \n" "CPS #0x17 \n" "LDR SP, =Image$$ABT_STACK$$ZI$$Limit \n" "CPS #0x1B \n" "LDR SP, =Image$$UND_STACK$$ZI$$Limit \n" "CPS #0x1F \n" "LDR SP, =Image$$ARM_LIB_STACK$$ZI$$Limit \n" // Call SystemInit "BL SystemInit \n" // Unmask interrupts "CPSIE if \n" // Call __main "BL __main \n" ); } /*your_sha256_hash------------ Default Handler for Exceptions / Interrupts *your_sha256_hash------------*/ void Default_Handler(void) { while(1); } ```
/content/code_sandbox/Device/ARM/ARMCA9/Source/AC6/startup_ARMCA9.c
c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,435
```linker script #include "mem_ARMCA9.h" MEMORY { ROM (rx) : ORIGIN = __ROM_BASE, LENGTH = __ROM_SIZE L_TTB (rw) : ORIGIN = __TTB_BASE, LENGTH = __TTB_SIZE RAM (rwx) : ORIGIN = __RAM_BASE, LENGTH = __RAM_SIZE } ENTRY(Reset_Handler) SECTIONS { .text : { Image$$VECTORS$$Base = .; * (RESET) KEEP(*(.isr_vector)) Image$$VECTORS$$Limit = .; *(SVC_TABLE) *(.text*) KEEP(*(.init)) KEEP(*(.fini)) /* .ctors */ *crtbegin.o(.ctors) *crtbegin?.o(.ctors) *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) *(SORT(.ctors.*)) *(.ctors) /* .dtors */ *crtbegin.o(.dtors) *crtbegin?.o(.dtors) *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) *(SORT(.dtors.*)) *(.dtors) Image$$RO_DATA$$Base = .; *(.rodata*) Image$$RO_DATA$$Limit = .; KEEP(*(.eh_frame*)) } > ROM .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } > ROM __exidx_start = .; .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } > ROM __exidx_end = .; .copy.table : { . = ALIGN(4); __copy_table_start__ = .; LONG (__etext) LONG (__data_start__) LONG (__data_end__ - __data_start__) __copy_table_end__ = .; } > ROM .zero.table : { . = ALIGN(4); __zero_table_start__ = .; LONG (__bss_start__) LONG (__bss_end__ - __bss_start__) __zero_table_end__ = .; } > ROM __etext = .; .ttb : { Image$$TTB$$ZI$$Base = .; . += __TTB_SIZE; Image$$TTB$$ZI$$Limit = .; } > L_TTB .data : AT (__etext) { Image$$RW_DATA$$Base = .; __data_start__ = .; *(vtable) *(.data*) Image$$RW_DATA$$Limit = .; . = ALIGN(4); /* preinit data */ PROVIDE (__preinit_array_start = .); KEEP(*(.preinit_array)) PROVIDE (__preinit_array_end = .); . = ALIGN(4); /* init data */ PROVIDE (__init_array_start = .); KEEP(*(SORT(.init_array.*))) KEEP(*(.init_array)) PROVIDE (__init_array_end = .); . = ALIGN(4); /* finit data */ PROVIDE (__fini_array_start = .); KEEP(*(SORT(.fini_array.*))) KEEP(*(.fini_array)) PROVIDE (__fini_array_end = .); . = ALIGN(4); /* All data end */ __data_end__ = .; } > RAM .bss ALIGN(0x400): { Image$$ZI_DATA$$Base = .; __bss_start__ = .; *(.bss*) *(COMMON) __bss_end__ = .; Image$$ZI_DATA$$Limit = .; __end__ = .; end = __end__; } > RAM #if defined(__HEAP_SIZE) && (__HEAP_SIZE > 0) .heap (NOLOAD): { . = ALIGN(8); Image$$HEAP$$ZI$$Base = .; . += __HEAP_SIZE; Image$$HEAP$$ZI$$Limit = .; __HeapLimit = .; } > RAM #endif .stack (NOLOAD): { . = ORIGIN(RAM) + LENGTH(RAM) - __STACK_SIZE - __FIQ_STACK_SIZE - __IRQ_STACK_SIZE - __SVC_STACK_SIZE - __ABT_STACK_SIZE - __UND_STACK_SIZE; . = ALIGN(8); __StackTop = .; Image$$SYS_STACK$$ZI$$Base = .; . += __STACK_SIZE; Image$$SYS_STACK$$ZI$$Limit = .; __stack = .; Image$$FIQ_STACK$$ZI$$Base = .; . += __FIQ_STACK_SIZE; Image$$FIQ_STACK$$ZI$$Limit = .; Image$$IRQ_STACK$$ZI$$Base = .; . += __IRQ_STACK_SIZE; Image$$IRQ_STACK$$ZI$$Limit = .; Image$$SVC_STACK$$ZI$$Base = .; . += __SVC_STACK_SIZE; Image$$SVC_STACK$$ZI$$Limit = .; Image$$ABT_STACK$$ZI$$Base = .; . += __ABT_STACK_SIZE; Image$$ABT_STACK$$ZI$$Limit = .; Image$$UND_STACK$$ZI$$Base = .; . += __UND_STACK_SIZE; Image$$UND_STACK$$ZI$$Limit = .; } > RAM } ```
/content/code_sandbox/Device/ARM/ARMCA9/Source/GCC/ARMCA9.ld
linker script
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,232
```c /****************************************************************************** * @file startup_ARMCA9.c * @brief CMSIS Device System Source File for Arm Cortex-A9 Device Series * @version V1.00 * @date 10. January 2018 * * @note * ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include <ARMCA9.h> /*your_sha256_hash------------ Definitions *your_sha256_hash------------*/ #define USR_MODE 0x10 // User mode #define FIQ_MODE 0x11 // Fast Interrupt Request mode #define IRQ_MODE 0x12 // Interrupt Request mode #define SVC_MODE 0x13 // Supervisor mode #define ABT_MODE 0x17 // Abort mode #define UND_MODE 0x1B // Undefined Instruction mode #define SYS_MODE 0x1F // System mode /*your_sha256_hash------------ Internal References *your_sha256_hash------------*/ void Vectors (void) __attribute__ ((section("RESET"))); void Reset_Handler (void); /*your_sha256_hash------------ Exception / Interrupt Handler *your_sha256_hash------------*/ void Undef_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void PAbt_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void DAbt_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void IRQ_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void FIQ_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); /*your_sha256_hash------------ Exception / Interrupt Vector Table *your_sha256_hash------------*/ __ASM void Vectors(void) { PRESERVE8 IMPORT Undef_Handler IMPORT SVC_Handler IMPORT PAbt_Handler IMPORT DAbt_Handler IMPORT IRQ_Handler IMPORT FIQ_Handler LDR PC, =Reset_Handler LDR PC, =Undef_Handler LDR PC, =SVC_Handler LDR PC, =PAbt_Handler LDR PC, =DAbt_Handler NOP LDR PC, =IRQ_Handler LDR PC, =FIQ_Handler } /*your_sha256_hash------------ Reset Handler called on controller reset *your_sha256_hash------------*/ __ASM void Reset_Handler(void) { PRESERVE8 // Mask interrupts CPSID if // Put any cores other than 0 to sleep MRC p15, 0, R0, c0, c0, 5 // Read MPIDR ANDS R0, R0, #3 goToSleep WFINE BNE goToSleep // Reset SCTLR Settings MRC p15, 0, R0, c1, c0, 0 // Read CP15 System Control register BIC R0, R0, #(0x1 << 12) // Clear I bit 12 to disable I Cache BIC R0, R0, #(0x1 << 2) // Clear C bit 2 to disable D Cache BIC R0, R0, #0x1 // Clear M bit 0 to disable MMU BIC R0, R0, #(0x1 << 11) // Clear Z bit 11 to disable branch prediction BIC R0, R0, #(0x1 << 13) // Clear V bit 13 to disable hivecs MCR p15, 0, R0, c1, c0, 0 // Write value back to CP15 System Control register ISB // Configure ACTLR MRC p15, 0, r0, c1, c0, 1 // Read CP15 Auxiliary Control Register ORR r0, r0, #(1 << 1) // Enable L2 prefetch hint (UNK/WI since r4p1) MCR p15, 0, r0, c1, c0, 1 // Write CP15 Auxiliary Control Register // Set Vector Base Address Register (VBAR) to point to this application's vector table LDR R0, =Vectors MCR p15, 0, R0, c12, c0, 0 // Setup Stack for each exceptional mode IMPORT |Image$$FIQ_STACK$$ZI$$Limit| IMPORT |Image$$IRQ_STACK$$ZI$$Limit| IMPORT |Image$$SVC_STACK$$ZI$$Limit| IMPORT |Image$$ABT_STACK$$ZI$$Limit| IMPORT |Image$$UND_STACK$$ZI$$Limit| IMPORT |Image$$ARM_LIB_STACK$$ZI$$Limit| CPS #0x11 LDR SP, =|Image$$FIQ_STACK$$ZI$$Limit| CPS #0x12 LDR SP, =|Image$$IRQ_STACK$$ZI$$Limit| CPS #0x13 LDR SP, =|Image$$SVC_STACK$$ZI$$Limit| CPS #0x17 LDR SP, =|Image$$ABT_STACK$$ZI$$Limit| CPS #0x1B LDR SP, =|Image$$UND_STACK$$ZI$$Limit| CPS #0x1F LDR SP, =|Image$$ARM_LIB_STACK$$ZI$$Limit| // Call SystemInit IMPORT SystemInit BL SystemInit // Unmask interrupts CPSIE if // Call __main IMPORT __main BL __main } /*your_sha256_hash------------ Default Handler for Exceptions / Interrupts *your_sha256_hash------------*/ void Default_Handler(void) { while(1); } ```
/content/code_sandbox/Device/ARM/ARMCA9/Source/AC5/startup_ARMCA9.c
c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,362
```c /****************************************************************************** * @file startup_ARMCA9.c * @brief CMSIS Device System Source File for Arm Cortex-A9 Device Series * @version V1.0.1 * @date 10. January 2021 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include <ARMCA9.h> /*your_sha256_hash------------ Definitions *your_sha256_hash------------*/ #define USR_MODE 0x10 // User mode #define FIQ_MODE 0x11 // Fast Interrupt Request mode #define IRQ_MODE 0x12 // Interrupt Request mode #define SVC_MODE 0x13 // Supervisor mode #define ABT_MODE 0x17 // Abort mode #define UND_MODE 0x1B // Undefined Instruction mode #define SYS_MODE 0x1F // System mode /*your_sha256_hash------------ Internal References *your_sha256_hash------------*/ void Vectors (void) __attribute__ ((naked, section("RESET"))); void Reset_Handler (void) __attribute__ ((naked)); void Default_Handler(void); /*your_sha256_hash------------ Exception / Interrupt Handler *your_sha256_hash------------*/ void Undef_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void PAbt_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void DAbt_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void IRQ_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void FIQ_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); /*your_sha256_hash------------ Exception / Interrupt Vector Table *your_sha256_hash------------*/ void Vectors(void) { __ASM volatile( "LDR PC, =Reset_Handler \n" "LDR PC, =Undef_Handler \n" "LDR PC, =SVC_Handler \n" "LDR PC, =PAbt_Handler \n" "LDR PC, =DAbt_Handler \n" "NOP \n" "LDR PC, =IRQ_Handler \n" "LDR PC, =FIQ_Handler \n" ); } /*your_sha256_hash------------ Reset Handler called on controller reset *your_sha256_hash------------*/ void Reset_Handler(void) { __ASM volatile( // Mask interrupts "CPSID if \n" // Put any cores other than 0 to sleep "MRC p15, 0, R0, c0, c0, 5 \n" // Read MPIDR "ANDS R0, R0, #3 \n" "goToSleep: \n" "WFINE \n" "BNE goToSleep \n" // Reset SCTLR Settings "MRC p15, 0, R0, c1, c0, 0 \n" // Read CP15 System Control register "BIC R0, R0, #(0x1 << 12) \n" // Clear I bit 12 to disable I Cache "BIC R0, R0, #(0x1 << 2) \n" // Clear C bit 2 to disable D Cache "BIC R0, R0, #0x1 \n" // Clear M bit 0 to disable MMU "BIC R0, R0, #(0x1 << 11) \n" // Clear Z bit 11 to disable branch prediction "BIC R0, R0, #(0x1 << 13) \n" // Clear V bit 13 to disable hivecs "MCR p15, 0, R0, c1, c0, 0 \n" // Write value back to CP15 System Control register "ISB \n" // Configure ACTLR "MRC p15, 0, r0, c1, c0, 1 \n" // Read CP15 Auxiliary Control Register "ORR r0, r0, #(1 << 1) \n" // Enable L2 prefetch hint (UNK/WI since r4p1) "MCR p15, 0, r0, c1, c0, 1 \n" // Write CP15 Auxiliary Control Register // Set Vector Base Address Register (VBAR) to point to this application's vector table "LDR R0, =Vectors \n" "MCR p15, 0, R0, c12, c0, 0 \n" // Setup Stack for each exceptional mode "CPS #0x11 \n" "LDR SP, =Image$$FIQ_STACK$$ZI$$Limit \n" "CPS #0x12 \n" "LDR SP, =Image$$IRQ_STACK$$ZI$$Limit \n" "CPS #0x13 \n" "LDR SP, =Image$$SVC_STACK$$ZI$$Limit \n" "CPS #0x17 \n" "LDR SP, =Image$$ABT_STACK$$ZI$$Limit \n" "CPS #0x1B \n" "LDR SP, =Image$$UND_STACK$$ZI$$Limit \n" "CPS #0x1F \n" "LDR SP, =Image$$SYS_STACK$$ZI$$Limit \n" // Call SystemInit "BL SystemInit \n" // Unmask interrupts "CPSIE if \n" // Call __main "BL _start \n" ); } /*your_sha256_hash------------ Default Handler for Exceptions / Interrupts *your_sha256_hash------------*/ void Default_Handler(void) { while(1); } ```
/content/code_sandbox/Device/ARM/ARMCA9/Source/GCC/startup_ARMCA9.c
c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,427
```objective-c /**************************************************************************//** * @file system_ARMCM33.h * @brief CMSIS Device System Header File for * ARMCM33 Device * @version V5.3.3 * @date 11. July 2022 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef SYSTEM_ARMCM33_H #define SYSTEM_ARMCM33_H #ifdef __cplusplus extern "C" { #endif #include <stdint.h> /** \brief Exception / Interrupt Handler Function Prototype */ typedef void(*VECTOR_TABLE_Type)(void); /** \brief System Clock Frequency (Core Clock) */ extern uint32_t SystemCoreClock; /** \brief Setup the microcontroller system. Initialize the System and update the SystemCoreClock variable. */ extern void SystemInit (void); /** \brief Update SystemCoreClock variable. Updates the SystemCoreClock with current core Clock retrieved from cpu registers. */ extern void SystemCoreClockUpdate (void); #ifdef __cplusplus } #endif #endif /* SYSTEM_ARMCM33_H */ ```
/content/code_sandbox/Device/ARM/ARMCM33/Include/system_ARMCM33.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
253
```objective-c /**************************************************************************//** * @file ARMCM33_DSP_FP_TZ.h * @brief CMSIS Core Peripheral Access Layer Header File for * ARMCM33 Device (configured for ARMCM33 with FPU, with DSP extension, with TrustZone) * @version V5.3.2 * @date 01. May 2023 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef ARMCM33_DSP_FP_TZ_H #define ARMCM33_DSP_FP_TZ_H #ifdef __cplusplus extern "C" { #endif /* ------------------------- Interrupt Number Definition ------------------------ */ typedef enum IRQn { /* ------------------- Processor Exceptions Numbers ----------------------------- */ NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */ HardFault_IRQn = -13, /* 3 HardFault Interrupt */ MemoryManagement_IRQn = -12, /* 4 Memory Management Interrupt */ BusFault_IRQn = -11, /* 5 Bus Fault Interrupt */ UsageFault_IRQn = -10, /* 6 Usage Fault Interrupt */ SecureFault_IRQn = -9, /* 7 Secure Fault Interrupt */ SVCall_IRQn = -5, /* 11 SV Call Interrupt */ DebugMonitor_IRQn = -4, /* 12 Debug Monitor Interrupt */ PendSV_IRQn = -2, /* 14 Pend SV Interrupt */ SysTick_IRQn = -1, /* 15 System Tick Interrupt */ /* ------------------- Processor Interrupt Numbers ------------------------------ */ Interrupt0_IRQn = 0, Interrupt1_IRQn = 1, Interrupt2_IRQn = 2, Interrupt3_IRQn = 3, Interrupt4_IRQn = 4, Interrupt5_IRQn = 5, Interrupt6_IRQn = 6, Interrupt7_IRQn = 7, Interrupt8_IRQn = 8, Interrupt9_IRQn = 9, /* Interrupts 10 .. 479 are left out */ Interrupt480_IRQn = 480 } IRQn_Type; /* ================================================================================ */ /* ================ Processor and Core Peripheral Section ================ */ /* ================================================================================ */ /* ------- Start of section using anonymous unions and disabling warnings ------- */ #if defined (__CC_ARM) #pragma push #pragma anon_unions #elif defined (__ICCARM__) #pragma language=extended #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc11-extensions" #pragma clang diagnostic ignored "-Wreserved-id-macro" #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning 586 #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif /* -------- Configuration of Core Peripherals ----------------------------------- */ #define __CM33_REV 0x0000U /* Core revision r0p1 */ #define __SAUREGION_PRESENT 1U /* SAU regions present */ #define __MPU_PRESENT 1U /* MPU present */ #define __VTOR_PRESENT 1U /* VTOR present */ #define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */ #define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 1U /* FPU present */ #define __DSP_PRESENT 1U /* DSP extension present */ #include "core_cm33.h" /* Processor and core peripherals */ #include "system_ARMCM33.h" /* System Header */ /* -------- End of section using anonymous unions and disabling warnings -------- */ #if defined (__CC_ARM) #pragma pop #elif defined (__ICCARM__) /* leave anonymous unions enabled */ #elif (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) #pragma clang diagnostic pop #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning restore #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif #ifdef __cplusplus } #endif #endif /* ARMCM33_DSP_FP_TZ_H */ ```
/content/code_sandbox/Device/ARM/ARMCM33/Include/ARMCM33_DSP_FP_TZ.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,030
```objective-c /**************************************************************************//** * @file ARMCM33_TZ.h * @brief CMSIS Core Peripheral Access Layer Header File for * ARMCM33 Device (configured for ARMCM33 without FPU, without DSP extension, with TrustZone) * @version V5.3.2 * @date 01. May 2023 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef ARMCM33_TZ_H #define ARMCM33_TZ_H #ifdef __cplusplus extern "C" { #endif /* ------------------------- Interrupt Number Definition ------------------------ */ typedef enum IRQn { /* ------------------- Processor Exceptions Numbers ----------------------------- */ NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */ HardFault_IRQn = -13, /* 3 HardFault Interrupt */ MemoryManagement_IRQn = -12, /* 4 Memory Management Interrupt */ BusFault_IRQn = -11, /* 5 Bus Fault Interrupt */ UsageFault_IRQn = -10, /* 6 Usage Fault Interrupt */ SecureFault_IRQn = -9, /* 7 Secure Fault Interrupt */ SVCall_IRQn = -5, /* 11 SV Call Interrupt */ DebugMonitor_IRQn = -4, /* 12 Debug Monitor Interrupt */ PendSV_IRQn = -2, /* 14 Pend SV Interrupt */ SysTick_IRQn = -1, /* 15 System Tick Interrupt */ /* ------------------- Processor Interrupt Numbers ------------------------------ */ Interrupt0_IRQn = 0, Interrupt1_IRQn = 1, Interrupt2_IRQn = 2, Interrupt3_IRQn = 3, Interrupt4_IRQn = 4, Interrupt5_IRQn = 5, Interrupt6_IRQn = 6, Interrupt7_IRQn = 7, Interrupt8_IRQn = 8, Interrupt9_IRQn = 9, /* Interrupts 10 .. 479 are left out */ Interrupt480_IRQn = 480 } IRQn_Type; /* ================================================================================ */ /* ================ Processor and Core Peripheral Section ================ */ /* ================================================================================ */ /* ------- Start of section using anonymous unions and disabling warnings ------- */ #if defined (__CC_ARM) #pragma push #pragma anon_unions #elif defined (__ICCARM__) #pragma language=extended #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc11-extensions" #pragma clang diagnostic ignored "-Wreserved-id-macro" #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning 586 #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif /* -------- Configuration of Core Peripherals ----------------------------------- */ #define __CM33_REV 0x0000U /* Core revision r0p1 */ #define __SAUREGION_PRESENT 1U /* SAU regions present */ #define __MPU_PRESENT 1U /* MPU present */ #define __VTOR_PRESENT 1U /* VTOR present */ #define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */ #define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 0U /* no FPU present */ #define __DSP_PRESENT 0U /* no DSP extension present */ #include "core_cm33.h" /* Processor and core peripherals */ #include "system_ARMCM33.h" /* System Header */ /* -------- End of section using anonymous unions and disabling warnings -------- */ #if defined (__CC_ARM) #pragma pop #elif defined (__ICCARM__) /* leave anonymous unions enabled */ #elif (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) #pragma clang diagnostic pop #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning restore #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif #ifdef __cplusplus } #endif #endif /* ARMCM33_TZ_H */ ```
/content/code_sandbox/Device/ARM/ARMCM33/Include/ARMCM33_TZ.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,024
```objective-c /**************************************************************************//** * @file ARMCM33_DSP_FP.h * @brief CMSIS Core Peripheral Access Layer Header File for * ARMCM33 Device (configured for ARMCM33 with FPU, with DSP extension) * @version V5.3.2 * @date 01. May 2023 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef ARMCM33_DSP_FP_H #define ARMCM33_DSP_FP_H #ifdef __cplusplus extern "C" { #endif /* ------------------------- Interrupt Number Definition ------------------------ */ typedef enum IRQn { /* ------------------- Processor Exceptions Numbers ----------------------------- */ NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */ HardFault_IRQn = -13, /* 3 HardFault Interrupt */ MemoryManagement_IRQn = -12, /* 4 Memory Management Interrupt */ BusFault_IRQn = -11, /* 5 Bus Fault Interrupt */ UsageFault_IRQn = -10, /* 6 Usage Fault Interrupt */ SecureFault_IRQn = -9, /* 7 Secure Fault Interrupt */ SVCall_IRQn = -5, /* 11 SV Call Interrupt */ DebugMonitor_IRQn = -4, /* 12 Debug Monitor Interrupt */ PendSV_IRQn = -2, /* 14 Pend SV Interrupt */ SysTick_IRQn = -1, /* 15 System Tick Interrupt */ /* ------------------- Processor Interrupt Numbers ------------------------------ */ Interrupt0_IRQn = 0, Interrupt1_IRQn = 1, Interrupt2_IRQn = 2, Interrupt3_IRQn = 3, Interrupt4_IRQn = 4, Interrupt5_IRQn = 5, Interrupt6_IRQn = 6, Interrupt7_IRQn = 7, Interrupt8_IRQn = 8, Interrupt9_IRQn = 9, /* Interrupts 10 .. 479 are left out */ Interrupt480_IRQn = 480 } IRQn_Type; /* ================================================================================ */ /* ================ Processor and Core Peripheral Section ================ */ /* ================================================================================ */ /* ------- Start of section using anonymous unions and disabling warnings ------- */ #if defined (__CC_ARM) #pragma push #pragma anon_unions #elif defined (__ICCARM__) #pragma language=extended #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc11-extensions" #pragma clang diagnostic ignored "-Wreserved-id-macro" #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning 586 #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif /* -------- Configuration of Core Peripherals ----------------------------------- */ #define __CM33_REV 0x0000U /* Core revision r0p1 */ #define __SAUREGION_PRESENT 0U /* SAU regions present */ #define __MPU_PRESENT 1U /* MPU present */ #define __VTOR_PRESENT 1U /* VTOR present */ #define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */ #define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 1U /* FPU present */ #define __DSP_PRESENT 1U /* DSP extension present */ #include "core_cm33.h" /* Processor and core peripherals */ #include "system_ARMCM33.h" /* System Header */ /* -------- End of section using anonymous unions and disabling warnings -------- */ #if defined (__CC_ARM) #pragma pop #elif defined (__ICCARM__) /* leave anonymous unions enabled */ #elif (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) #pragma clang diagnostic pop #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning restore #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif #ifdef __cplusplus } #endif #endif /* ARMCM33_DSP_FP_H */ ```
/content/code_sandbox/Device/ARM/ARMCM33/Include/ARMCM33_DSP_FP.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,018
```objective-c /**************************************************************************//** * @file ARMCM33.h * @brief CMSIS Core Peripheral Access Layer Header File for * ARMCM33 Device (configured for ARMCM33 without FPU, without DSP extension, without TrustZone) * @version V5.3.2 * @date 01. May 2023 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef ARMCM33_H #define ARMCM33_H #ifdef __cplusplus extern "C" { #endif /* ------------------------- Interrupt Number Definition ------------------------ */ typedef enum IRQn { /* ------------------- Processor Exceptions Numbers ----------------------------- */ NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */ HardFault_IRQn = -13, /* 3 HardFault Interrupt */ MemoryManagement_IRQn = -12, /* 4 Memory Management Interrupt */ BusFault_IRQn = -11, /* 5 Bus Fault Interrupt */ UsageFault_IRQn = -10, /* 6 Usage Fault Interrupt */ SecureFault_IRQn = -9, /* 7 Secure Fault Interrupt */ SVCall_IRQn = -5, /* 11 SV Call Interrupt */ DebugMonitor_IRQn = -4, /* 12 Debug Monitor Interrupt */ PendSV_IRQn = -2, /* 14 Pend SV Interrupt */ SysTick_IRQn = -1, /* 15 System Tick Interrupt */ /* ------------------- Processor Interrupt Numbers ------------------------------ */ Interrupt0_IRQn = 0, Interrupt1_IRQn = 1, Interrupt2_IRQn = 2, Interrupt3_IRQn = 3, Interrupt4_IRQn = 4, Interrupt5_IRQn = 5, Interrupt6_IRQn = 6, Interrupt7_IRQn = 7, Interrupt8_IRQn = 8, Interrupt9_IRQn = 9, /* Interrupts 10 .. 479 are left out */ Interrupt480_IRQn = 480 } IRQn_Type; /* ================================================================================ */ /* ================ Processor and Core Peripheral Section ================ */ /* ================================================================================ */ /* ------- Start of section using anonymous unions and disabling warnings ------- */ #if defined (__CC_ARM) #pragma push #pragma anon_unions #elif defined (__ICCARM__) #pragma language=extended #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc11-extensions" #pragma clang diagnostic ignored "-Wreserved-id-macro" #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning 586 #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif /* -------- Configuration of Core Peripherals ----------------------------------- */ #define __CM33_REV 0x0000U /* Core revision r0p1 */ #define __SAUREGION_PRESENT 0U /* SAU regions present */ #define __MPU_PRESENT 1U /* MPU present */ #define __VTOR_PRESENT 1U /* VTOR present */ #define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */ #define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 0U /* no FPU present */ #define __DSP_PRESENT 0U /* no DSP extension present */ #include "core_cm33.h" /* Processor and core peripherals */ #include "system_ARMCM33.h" /* System Header */ /* -------- End of section using anonymous unions and disabling warnings -------- */ #if defined (__CC_ARM) #pragma pop #elif defined (__ICCARM__) /* leave anonymous unions enabled */ #elif (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) #pragma clang diagnostic pop #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning restore #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif #ifdef __cplusplus } #endif #endif /* ARMCM33_H */ ```
/content/code_sandbox/Device/ARM/ARMCM33/Include/ARMCM33.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,016
```gas ;/**************************************************************************//** ; * @file startup_ARMCM33.s ; * @brief CMSIS Core Device Startup File for ; * ARMCM33 Device ; * @version V1.1.0 ; * @date 08. April 2021 ; ******************************************************************************/ ;/* ; * ; * ; * ; * www.apache.org/licenses/LICENSE-2.0 ; * ; * Unless required by applicable law or agreed to in writing, software ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; */ ; ; The modules in this file are included in the libraries, and may be replaced ; by any user-defined modules that define the PUBLIC symbol _program_start or ; a user defined start symbol. ; To override the cstartup defined in the library, simply add your modified ; version to the workbench project. ; ; The vector table is normally located at address 0. ; When debugging in RAM, it can be located in RAM, aligned to at least 2^6. ; The name "__vector_table" has special meaning for C-SPY: ; it is where the SP start value is found, and the NVIC vector ; table register (VTOR) is initialized to this address if != 0. ; ; Cortex-M version ; MODULE ?cstartup ;; Forward declaration of sections. SECTION CSTACK:DATA:NOROOT(3) SECTION .intvec:CODE:NOROOT(2) EXTERN __iar_program_start EXTERN SystemInit PUBLIC __vector_table PUBLIC __vector_table_0x1c PUBLIC __Vectors PUBLIC __Vectors_End PUBLIC __Vectors_Size #define __INITIAL_SP sfe(CSTACK) #define __STACK_LIMIT sfb(CSTACK) #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) SECTION STACKSEAL:DATA:NOROOT(3) #define __STACK_SEAL sfb(STACKSEAL) #endif DATA __vector_table DCD __INITIAL_SP ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; -14 NMI Handler DCD HardFault_Handler ; -13 Hard Fault Handler DCD MemManage_Handler ; -12 MPU Fault Handler DCD BusFault_Handler ; -11 Bus Fault Handler DCD UsageFault_Handler ; -10 Usage Fault Handler __vector_table_0x1c DCD SecureFault_Handler ; -9 Security Fault Handler DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD SVC_Handler ; -5 SVCall Handler DCD DebugMon_Handler ; -4 Debug Monitor Handler DCD 0 ; Reserved DCD PendSV_Handler ; -2 PendSV Handler DCD SysTick_Handler ; -1 SysTick Handler ; Interrupts DCD Interrupt0_Handler ; 0 Interrupt 0 DCD Interrupt1_Handler ; 1 Interrupt 1 DCD Interrupt2_Handler ; 2 Interrupt 2 DCD Interrupt3_Handler ; 3 Interrupt 3 DCD Interrupt4_Handler ; 4 Interrupt 4 DCD Interrupt5_Handler ; 5 Interrupt 5 DCD Interrupt6_Handler ; 6 Interrupt 6 DCD Interrupt7_Handler ; 7 Interrupt 7 DCD Interrupt8_Handler ; 8 Interrupt 8 DCD Interrupt9_Handler ; 9 Interrupt 9 DS32 (470) ; Interrupts 10 .. 480 are left out __Vectors_End __Vectors EQU __vector_table __Vectors_Size EQU __Vectors_End - __Vectors THUMB ; Reset Handler PUBWEAK Reset_Handler SECTION .text:CODE:REORDER:NOROOT(2) Reset_Handler ldr r0, =__INITIAL_SP msr psp, r0 ldr r0, =__STACK_LIMIT msr msplim, r0 msr psplim, r0 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) ldr r0, =__STACK_SEAL ldr r1, =0xFEF5EDA5U strd r1,r1,[r0,#0] #endif LDR R0, =SystemInit BLX R0 LDR R0, =__iar_program_start BX R0 PUBWEAK NMI_Handler PUBWEAK HardFault_Handler PUBWEAK MemManage_Handler PUBWEAK BusFault_Handler PUBWEAK UsageFault_Handler PUBWEAK SecureFault_Handler PUBWEAK SVC_Handler PUBWEAK DebugMon_Handler PUBWEAK PendSV_Handler PUBWEAK SysTick_Handler PUBWEAK Interrupt0_Handler PUBWEAK Interrupt1_Handler PUBWEAK Interrupt2_Handler PUBWEAK Interrupt3_Handler PUBWEAK Interrupt4_Handler PUBWEAK Interrupt5_Handler PUBWEAK Interrupt6_Handler PUBWEAK Interrupt7_Handler PUBWEAK Interrupt8_Handler PUBWEAK Interrupt9_Handler SECTION .text:CODE:REORDER:NOROOT(1) NMI_Handler HardFault_Handler MemManage_Handler BusFault_Handler UsageFault_Handler SecureFault_Handler SVC_Handler DebugMon_Handler PendSV_Handler SysTick_Handler Interrupt0_Handler Interrupt1_Handler Interrupt2_Handler Interrupt3_Handler Interrupt4_Handler Interrupt5_Handler Interrupt6_Handler Interrupt7_Handler Interrupt8_Handler Interrupt9_Handler Default_Handler B . END ```
/content/code_sandbox/Device/ARM/ARMCM33/Source/IAR/startup_ARMCM33.s
gas
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,364
```objective-c /**************************************************************************//** * @file system_ARMCM7.h * @brief CMSIS Device System Header File for * ARMCM7 Device * @version V5.3.3 * @date 11. July 2022 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef SYSTEM_ARMCM7_H #define SYSTEM_ARMCM7_H #ifdef __cplusplus extern "C" { #endif #include <stdint.h> /** \brief Exception / Interrupt Handler Function Prototype */ typedef void(*VECTOR_TABLE_Type)(void); /** \brief System Clock Frequency (Core Clock) */ extern uint32_t SystemCoreClock; /** \brief Setup the microcontroller system. Initialize the System and update the SystemCoreClock variable. */ extern void SystemInit (void); /** \brief Update SystemCoreClock variable. Updates the SystemCoreClock with current core Clock retrieved from cpu registers. */ extern void SystemCoreClockUpdate (void); #ifdef __cplusplus } #endif #endif /* SYSTEM_ARMCM7_H */ ```
/content/code_sandbox/Device/ARM/ARMCM7/Include/system_ARMCM7.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
253
```objective-c /**************************************************************************//** * @file ARMCM7.h * @brief CMSIS Core Peripheral Access Layer Header File for * ARMCM7 Device (configured for CM7 without FPU) * @version V5.3.3 * @date 01. May 2023 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef ARMCM7_H #define ARMCM7_H #ifdef __cplusplus extern "C" { #endif /* ------------------------- Interrupt Number Definition ------------------------ */ typedef enum IRQn { /* ------------------- Processor Exceptions Numbers ----------------------------- */ NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */ HardFault_IRQn = -13, /* 3 HardFault Interrupt */ MemoryManagement_IRQn = -12, /* 4 Memory Management Interrupt */ BusFault_IRQn = -11, /* 5 Bus Fault Interrupt */ UsageFault_IRQn = -10, /* 6 Usage Fault Interrupt */ SVCall_IRQn = -5, /* 11 SVC Interrupt */ DebugMonitor_IRQn = -4, /* 12 Debug Monitor Interrupt */ PendSV_IRQn = -2, /* 14 Pend SV Interrupt */ SysTick_IRQn = -1, /* 15 System Tick Interrupt */ /* ------------------- Processor Interrupt Numbers ------------------------------ */ Interrupt0_IRQn = 0, Interrupt1_IRQn = 1, Interrupt2_IRQn = 2, Interrupt3_IRQn = 3, Interrupt4_IRQn = 4, Interrupt5_IRQn = 5, Interrupt6_IRQn = 6, Interrupt7_IRQn = 7, Interrupt8_IRQn = 8, Interrupt9_IRQn = 9, /* Interrupts 10 .. 223 are left out */ Interrupt224_IRQn = 224 } IRQn_Type; /* ================================================================================ */ /* ================ Processor and Core Peripheral Section ================ */ /* ================================================================================ */ /* ------- Start of section using anonymous unions and disabling warnings ------- */ #if defined (__CC_ARM) #pragma push #pragma anon_unions #elif defined (__ICCARM__) #pragma language=extended #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc11-extensions" #pragma clang diagnostic ignored "-Wreserved-id-macro" #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning 586 #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif /* -------- Configuration of Core Peripherals ----------------------------------- */ #define __CM7_REV 0x0000U /* Core revision r0p0 */ #define __MPU_PRESENT 1U /* MPU present */ #define __VTOR_PRESENT 1U /* VTOR present */ #define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */ #define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 0U /* no FPU present */ #define __FPU_DP 0U /* unused */ #define __ICACHE_PRESENT 1U /* Instruction Cache present */ #define __DCACHE_PRESENT 1U /* Data Cache present */ #define __DTCM_PRESENT 1U /* Data Tightly Coupled Memory present */ #include "core_cm7.h" /* Processor and core peripherals */ #include "system_ARMCM7.h" /* System Header */ /* -------- End of section using anonymous unions and disabling warnings -------- */ #if defined (__CC_ARM) #pragma pop #elif defined (__ICCARM__) /* leave anonymous unions enabled */ #elif (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) #pragma clang diagnostic pop #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning restore #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif #ifdef __cplusplus } #endif #endif /* ARMCM7_H */ ```
/content/code_sandbox/Device/ARM/ARMCM7/Include/ARMCM7.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,017
```objective-c /**************************************************************************//** * @file ARMCM7_DP.h * @brief CMSIS Core Peripheral Access Layer Header File for * ARMCM7 Device (configured for CM7 with double precision FPU) * @version V5.3.3 * @date 01. May 2023 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef ARMCM7_DP_H #define ARMCM7_DP_H #ifdef __cplusplus extern "C" { #endif /* ------------------------- Interrupt Number Definition ------------------------ */ typedef enum IRQn { /* ------------------- Processor Exceptions Numbers ----------------------------- */ NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */ HardFault_IRQn = -13, /* 3 HardFault Interrupt */ MemoryManagement_IRQn = -12, /* 4 Memory Management Interrupt */ BusFault_IRQn = -11, /* 5 Bus Fault Interrupt */ UsageFault_IRQn = -10, /* 6 Usage Fault Interrupt */ SVCall_IRQn = -5, /* 11 SVC Interrupt */ DebugMonitor_IRQn = -4, /* 12 Debug Monitor Interrupt */ PendSV_IRQn = -2, /* 14 Pend SV Interrupt */ SysTick_IRQn = -1, /* 15 System Tick Interrupt */ /* ------------------- Processor Interrupt Numbers ------------------------------ */ Interrupt0_IRQn = 0, Interrupt1_IRQn = 1, Interrupt2_IRQn = 2, Interrupt3_IRQn = 3, Interrupt4_IRQn = 4, Interrupt5_IRQn = 5, Interrupt6_IRQn = 6, Interrupt7_IRQn = 7, Interrupt8_IRQn = 8, Interrupt9_IRQn = 9, /* Interrupts 10 .. 223 are left out */ Interrupt224_IRQn = 224 } IRQn_Type; /* ================================================================================ */ /* ================ Processor and Core Peripheral Section ================ */ /* ================================================================================ */ /* ------- Start of section using anonymous unions and disabling warnings ------- */ #if defined (__CC_ARM) #pragma push #pragma anon_unions #elif defined (__ICCARM__) #pragma language=extended #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc11-extensions" #pragma clang diagnostic ignored "-Wreserved-id-macro" #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning 586 #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif /* -------- Configuration of Core Peripherals ----------------------------------- */ #define __CM7_REV 0x0000U /* Core revision r0p0 */ #define __MPU_PRESENT 1U /* MPU present */ #define __VTOR_PRESENT 1U /* VTOR present */ #define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */ #define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 1U /* FPU present */ #define __FPU_DP 1U /* double precision FPU */ #define __ICACHE_PRESENT 1U /* Instruction Cache present */ #define __DCACHE_PRESENT 1U /* Data Cache present */ #define __DTCM_PRESENT 1U /* Data Tightly Coupled Memory present */ #include "core_cm7.h" /* Processor and core peripherals */ #include "system_ARMCM7.h" /* System Header */ /* -------- End of section using anonymous unions and disabling warnings -------- */ #if defined (__CC_ARM) #pragma pop #elif defined (__ICCARM__) /* leave anonymous unions enabled */ #elif (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) #pragma clang diagnostic pop #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning restore #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif #ifdef __cplusplus } #endif #endif /* ARMCM7_DP_H */ ```
/content/code_sandbox/Device/ARM/ARMCM7/Include/ARMCM7_DP.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,025
```objective-c /**************************************************************************//** * @file ARMCM7_SP.h * @brief CMSIS Core Peripheral Access Layer Header File for * ARMCM7 Device (configured for CM7 with single precision FPU) * @version V5.3.3 * @date 01. May 2023 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef ARMCM7_SP_H #define ARMCM7_SP_H #ifdef __cplusplus extern "C" { #endif /* ------------------------- Interrupt Number Definition ------------------------ */ typedef enum IRQn { /* ------------------- Processor Exceptions Numbers ----------------------------- */ NonMaskableInt_IRQn = -14, /* 2 Non Maskable Interrupt */ HardFault_IRQn = -13, /* 3 HardFault Interrupt */ MemoryManagement_IRQn = -12, /* 4 Memory Management Interrupt */ BusFault_IRQn = -11, /* 5 Bus Fault Interrupt */ UsageFault_IRQn = -10, /* 6 Usage Fault Interrupt */ SVCall_IRQn = -5, /* 11 SVC Interrupt */ DebugMonitor_IRQn = -4, /* 12 Debug Monitor Interrupt */ PendSV_IRQn = -2, /* 14 Pend SV Interrupt */ SysTick_IRQn = -1, /* 15 System Tick Interrupt */ /* ------------------- Processor Interrupt Numbers ------------------------------ */ Interrupt0_IRQn = 0, Interrupt1_IRQn = 1, Interrupt2_IRQn = 2, Interrupt3_IRQn = 3, Interrupt4_IRQn = 4, Interrupt5_IRQn = 5, Interrupt6_IRQn = 6, Interrupt7_IRQn = 7, Interrupt8_IRQn = 8, Interrupt9_IRQn = 9, /* Interrupts 10 .. 223 are left out */ Interrupt224_IRQn = 224 } IRQn_Type; /* ================================================================================ */ /* ================ Processor and Core Peripheral Section ================ */ /* ================================================================================ */ /* ------- Start of section using anonymous unions and disabling warnings ------- */ #if defined (__CC_ARM) #pragma push #pragma anon_unions #elif defined (__ICCARM__) #pragma language=extended #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc11-extensions" #pragma clang diagnostic ignored "-Wreserved-id-macro" #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning 586 #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif /* -------- Configuration of Core Peripherals ----------------------------------- */ #define __CM7_REV 0x0000U /* Core revision r0p0 */ #define __MPU_PRESENT 1U /* MPU present */ #define __VTOR_PRESENT 1U /* VTOR present */ #define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */ #define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 1U /* FPU present */ #define __FPU_DP 0U /* single precision FPU */ #define __ICACHE_PRESENT 1U /* Instruction Cache present */ #define __DCACHE_PRESENT 1U /* Data Cache present */ #define __DTCM_PRESENT 1U /* Data Tightly Coupled Memory present */ #include "core_cm7.h" /* Processor and core peripherals */ #include "system_ARMCM7.h" /* System Header */ /* -------- End of section using anonymous unions and disabling warnings -------- */ #if defined (__CC_ARM) #pragma pop #elif defined (__ICCARM__) /* leave anonymous unions enabled */ #elif (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) #pragma clang diagnostic pop #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning restore #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif #ifdef __cplusplus } #endif #endif /* ARMCM7_SP_H */ ```
/content/code_sandbox/Device/ARM/ARMCM7/Include/ARMCM7_SP.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,025
```gas ;/**************************************************************************//** ; * @file startup_ARMCM7.s ; * @brief CMSIS Core Device Startup File for ; * ARMCM7 Device ; * @version V1.0.0 ; * @date 09. July 2018 ; ******************************************************************************/ ;/* ; * ; * ; * ; * www.apache.org/licenses/LICENSE-2.0 ; * ; * Unless required by applicable law or agreed to in writing, software ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; */ ; ; The modules in this file are included in the libraries, and may be replaced ; by any user-defined modules that define the PUBLIC symbol _program_start or ; a user defined start symbol. ; To override the cstartup defined in the library, simply add your modified ; version to the workbench project. ; ; The vector table is normally located at address 0. ; When debugging in RAM, it can be located in RAM, aligned to at least 2^6. ; The name "__vector_table" has special meaning for C-SPY: ; it is where the SP start value is found, and the NVIC vector ; table register (VTOR) is initialized to this address if != 0. ; ; Cortex-M version ; MODULE ?cstartup ;; Forward declaration of sections. SECTION CSTACK:DATA:NOROOT(3) SECTION .intvec:CODE:NOROOT(2) EXTERN __iar_program_start EXTERN SystemInit PUBLIC __vector_table PUBLIC __vector_table_0x1c PUBLIC __Vectors PUBLIC __Vectors_End PUBLIC __Vectors_Size DATA __vector_table DCD sfe(CSTACK) ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; -14 NMI Handler DCD HardFault_Handler ; -13 Hard Fault Handler DCD MemManage_Handler ; -12 MPU Fault Handler DCD BusFault_Handler ; -11 Bus Fault Handler DCD UsageFault_Handler ; -10 Usage Fault Handler __vector_table_0x1c DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD SVC_Handler ; -5 SVC Handler DCD DebugMon_Handler ; -4 Debug Monitor Handler DCD 0 ; Reserved DCD PendSV_Handler ; -2 PendSV Handler DCD SysTick_Handler ; -1 SysTick Handler ; Interrupts DCD Interrupt0_Handler ; 0 Interrupt 0 DCD Interrupt1_Handler ; 1 Interrupt 1 DCD Interrupt2_Handler ; 2 Interrupt 2 DCD Interrupt3_Handler ; 3 Interrupt 3 DCD Interrupt4_Handler ; 4 Interrupt 4 DCD Interrupt5_Handler ; 5 Interrupt 5 DCD Interrupt6_Handler ; 6 Interrupt 6 DCD Interrupt7_Handler ; 7 Interrupt 7 DCD Interrupt8_Handler ; 8 Interrupt 8 DCD Interrupt9_Handler ; 9 Interrupt 9 DS32 (214) ; Interrupts 10 .. 224 are left out __Vectors_End __Vectors EQU __vector_table __Vectors_Size EQU __Vectors_End - __Vectors THUMB ; Reset Handler PUBWEAK Reset_Handler SECTION .text:CODE:REORDER:NOROOT(2) Reset_Handler LDR R0, =SystemInit BLX R0 LDR R0, =__iar_program_start BX R0 PUBWEAK NMI_Handler PUBWEAK HardFault_Handler PUBWEAK MemManage_Handler PUBWEAK BusFault_Handler PUBWEAK UsageFault_Handler PUBWEAK SVC_Handler PUBWEAK DebugMon_Handler PUBWEAK PendSV_Handler PUBWEAK SysTick_Handler PUBWEAK Interrupt0_Handler PUBWEAK Interrupt1_Handler PUBWEAK Interrupt2_Handler PUBWEAK Interrupt3_Handler PUBWEAK Interrupt4_Handler PUBWEAK Interrupt5_Handler PUBWEAK Interrupt6_Handler PUBWEAK Interrupt7_Handler PUBWEAK Interrupt8_Handler PUBWEAK Interrupt9_Handler SECTION .text:CODE:REORDER:NOROOT(1) NMI_Handler HardFault_Handler MemManage_Handler BusFault_Handler UsageFault_Handler SVC_Handler DebugMon_Handler PendSV_Handler SysTick_Handler Interrupt0_Handler Interrupt1_Handler Interrupt2_Handler Interrupt3_Handler Interrupt4_Handler Interrupt5_Handler Interrupt6_Handler Interrupt7_Handler Interrupt8_Handler Interrupt9_Handler Default_Handler B . END ```
/content/code_sandbox/Device/ARM/ARMCM7/Source/IAR/startup_ARMCM7.s
gas
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,144
```gas ;/**************************************************************************//** ; * @file startup_ARMCM7.s ; * @brief CMSIS Core Device Startup File for ; * ARMCM7 Device ; * @version V1.0.1 ; * @date 23. July 2019 ; ******************************************************************************/ ;/* ; * ; * ; * ; * www.apache.org/licenses/LICENSE-2.0 ; * ; * Unless required by applicable law or agreed to in writing, software ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; */ ;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ ;<h> Stack Configuration ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> ;</h> Stack_Size EQU 0x00000400 AREA STACK, NOINIT, READWRITE, ALIGN=3 __stack_limit Stack_Mem SPACE Stack_Size __initial_sp ;<h> Heap Configuration ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> ;</h> Heap_Size EQU 0x00000C00 IF Heap_Size != 0 ; Heap is provided AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit ENDIF PRESERVE8 THUMB ; Vector Table Mapped to Address 0 at Reset AREA RESET, DATA, READONLY EXPORT __Vectors EXPORT __Vectors_End EXPORT __Vectors_Size __Vectors DCD __initial_sp ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; -14 NMI Handler DCD HardFault_Handler ; -13 Hard Fault Handler DCD MemManage_Handler ; -12 MPU Fault Handler DCD BusFault_Handler ; -11 Bus Fault Handler DCD UsageFault_Handler ; -10 Usage Fault Handler DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD SVC_Handler ; -5 SVC Handler DCD DebugMon_Handler ; -4 Debug Monitor Handler DCD 0 ; Reserved DCD PendSV_Handler ; -2 PendSV Handler DCD SysTick_Handler ; -1 SysTick Handler ; Interrupts DCD Interrupt0_Handler ; 0 Interrupt 0 DCD Interrupt1_Handler ; 1 Interrupt 1 DCD Interrupt2_Handler ; 2 Interrupt 2 DCD Interrupt3_Handler ; 3 Interrupt 3 DCD Interrupt4_Handler ; 4 Interrupt 4 DCD Interrupt5_Handler ; 5 Interrupt 5 DCD Interrupt6_Handler ; 6 Interrupt 6 DCD Interrupt7_Handler ; 7 Interrupt 7 DCD Interrupt8_Handler ; 8 Interrupt 8 DCD Interrupt9_Handler ; 9 Interrupt 9 SPACE (214 * 4) ; Interrupts 10 .. 224 are left out __Vectors_End __Vectors_Size EQU __Vectors_End - __Vectors AREA |.text|, CODE, READONLY ; Reset Handler Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT __main LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP ; The default macro is not used for HardFault_Handler ; because this results in a poor debug illusion. HardFault_Handler PROC EXPORT HardFault_Handler [WEAK] B . ENDP ; Macro to define default exception/interrupt handlers. ; Default handler are weak symbols with an endless loop. ; They can be overwritten by real handlers. MACRO Set_Default_Handler $Handler_Name $Handler_Name PROC EXPORT $Handler_Name [WEAK] B . ENDP MEND ; Default exception/interrupt handler Set_Default_Handler NMI_Handler Set_Default_Handler MemManage_Handler Set_Default_Handler BusFault_Handler Set_Default_Handler UsageFault_Handler Set_Default_Handler SVC_Handler Set_Default_Handler DebugMon_Handler Set_Default_Handler PendSV_Handler Set_Default_Handler SysTick_Handler Set_Default_Handler Interrupt0_Handler Set_Default_Handler Interrupt1_Handler Set_Default_Handler Interrupt2_Handler Set_Default_Handler Interrupt3_Handler Set_Default_Handler Interrupt4_Handler Set_Default_Handler Interrupt5_Handler Set_Default_Handler Interrupt6_Handler Set_Default_Handler Interrupt7_Handler Set_Default_Handler Interrupt8_Handler Set_Default_Handler Interrupt9_Handler ALIGN ; User setup Stack & Heap IF :LNOT::DEF:__MICROLIB IMPORT __use_two_region_memory ENDIF EXPORT __stack_limit EXPORT __initial_sp IF Heap_Size != 0 ; Heap is provided EXPORT __heap_base EXPORT __heap_limit ENDIF END ```
/content/code_sandbox/Device/ARM/ARMCM7/Source/ARM/startup_ARMCM7.s
gas
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,230
```objective-c /**************************************************************************//** * @file mem_<Device>.h * @brief CMSIS Cortex-A Memory base and size definitions (used in scatter file) * @version V1.00 * @date 10. January 2018 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef MEM_<Device>_H /* ToDo: replace '<Device>' with your device name */ #define MEM_<Device>_H /*your_sha256_hash------------ User Stack & Heap size definition *your_sha256_hash------------*/ /* //-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ */ /*--------------------- ROM Configuration ------------------------------------ // // <h> ROM Configuration // <o0> ROM Base Address <0x0-0xFFFFFFFF:8> // <o1> ROM Size (in Bytes) <0x0-0xFFFFFFFF:8> // </h> *your_sha256_hash------------*/ #define __ROM_BASE 0x80000000 #define __ROM_SIZE 0x00200000 /*--------------------- RAM Configuration ----------------------------------- // <h> RAM Configuration // <o0> RAM Base Address <0x0-0xFFFFFFFF:8> // <o1> RAM Total Size (in Bytes) <0x0-0xFFFFFFFF:8> // <o2> RW_DATA Size (in Bytes) <0x0-0xFFFFFFFF:8> // <o3> ZI_DATA Size (in Bytes) <0x0-0xFFFFFFFF:8> // <h> Stack / Heap Configuration // <o4> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> // <o5> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> // <h> Exceptional Modes // <o6> UND Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> // <o7> ABT Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> // <o8> SVC Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> // <o9> IRQ Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> // <o10> FIQ Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> // </h> // </h> // </h> *your_sha256_hash------------*/ #define __RAM_BASE 0x80200000 #define __RAM_SIZE 0x00200000 #define __RW_DATA_SIZE 0x00100000 #define __ZI_DATA_SIZE 0x000F0000 #define __STACK_SIZE 0x00001000 #define __HEAP_SIZE 0x00008000 #define __UND_STACK_SIZE 0x00000100 #define __ABT_STACK_SIZE 0x00000100 #define __SVC_STACK_SIZE 0x00000100 #define __IRQ_STACK_SIZE 0x00000100 #define __FIQ_STACK_SIZE 0x00000100 /*your_sha256_hash------------*/ /*--------------------- TTB Configuration ------------------------------------ // // <h> TTB Configuration // <o0> TTB Base Address <0x0-0xFFFFFFFF:8> // <o1> TTB Size (in Bytes) <0x0-0xFFFFFFFF:8> // </h> *your_sha256_hash------------*/ #define __TTB_BASE 0x80500000 #define __TTB_SIZE 0x00004000 #endif /* MEM_<Device>_H */ ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device_A/Include/mem_Device.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
811
```objective-c /**************************************************************************//** * @file system_<Device>.h * @brief CMSIS Cortex-A Device Peripheral Access Layer * @version V5.00 * @date 10. January 2018 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef SYSTEM_<Device>_H /* ToDo: replace '<Device>' with your device name */ #define SYSTEM_<Device>_H #ifdef __cplusplus extern "C" { #endif #include <stdint.h> extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ /** \brief Setup the microcontroller system. Initialize the System and update the SystemCoreClock variable. */ extern void SystemInit (void); /** \brief Update SystemCoreClock variable. Updates the SystemCoreClock with current core Clock retrieved from cpu registers. */ extern void SystemCoreClockUpdate (void); /** \brief Create Translation Table. Creates Memory Management Unit Translation Table. */ extern void MMU_CreateTranslationTable(void); #ifdef __cplusplus } #endif #endif /* SYSTEM_<Device>_H */ ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device_A/Include/system_Device.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
262
```objective-c /**************************************************************************//** * @file <Device>.h * @brief CMSIS Cortex-A Core Peripheral Access Layer Header File * @version V1.01 * @date 23. June 2020 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef <Device>_H /* ToDo: replace '<Device>' with your device name */ #define <Device>_H #ifdef __cplusplus extern "C" { #endif /* ToDo: replace '<Vendor>' with vendor name; add your doxyGen comment */ /** @addtogroup <Vendor> * @{ */ /* ToDo: replace '<Device>' with device name; add your doxyGen comment */ /** @addtogroup <Device> * @{ */ /** @addtogroup Configuration_of_CMSIS * @{ */ /* =========================================================================================================================== */ /* ================ Interrupt Number Definition ================ */ /* =========================================================================================================================== */ typedef enum IRQn { /* ======================================= ARM Cortex-A Specific Interrupt Numbers ========================================= */ /* Software Generated Interrupts */ SGI0_IRQn = 0, /*!< Software Generated Interrupt 0 */ SGI1_IRQn = 1, /*!< Software Generated Interrupt 1 */ SGI2_IRQn = 2, /*!< Software Generated Interrupt 2 */ SGI3_IRQn = 3, /*!< Software Generated Interrupt 3 */ SGI4_IRQn = 4, /*!< Software Generated Interrupt 4 */ SGI5_IRQn = 5, /*!< Software Generated Interrupt 5 */ SGI6_IRQn = 6, /*!< Software Generated Interrupt 6 */ SGI7_IRQn = 7, /*!< Software Generated Interrupt 7 */ SGI8_IRQn = 8, /*!< Software Generated Interrupt 8 */ SGI9_IRQn = 9, /*!< Software Generated Interrupt 9 */ SGI10_IRQn = 10, /*!< Software Generated Interrupt 10 */ SGI11_IRQn = 11, /*!< Software Generated Interrupt 11 */ SGI12_IRQn = 12, /*!< Software Generated Interrupt 12 */ SGI13_IRQn = 13, /*!< Software Generated Interrupt 13 */ SGI14_IRQn = 14, /*!< Software Generated Interrupt 14 */ SGI15_IRQn = 15, /*!< Software Generated Interrupt 15 */ /* Private Peripheral Interrupts */ VirtualMaintenanceInterrupt_IRQn = 25, /*!< Virtual Maintenance Interrupt */ HypervisorTimer_IRQn = 26, /*!< Hypervisor Timer Interrupt */ VirtualTimer_IRQn = 27, /*!< Virtual Timer Interrupt */ Legacy_nFIQ_IRQn = 28, /*!< Legacy nFIQ Interrupt */ SecurePhyTimer_IRQn = 29, /*!< Secure Physical Timer Interrupt */ NonSecurePhyTimer_IRQn = 30, /*!< Non-Secure Physical Timer Interrupt */ Legacy_nIRQ_IRQn = 31, /*!< Legacy nIRQ Interrupt */ /* Shared Peripheral Interrupts */ /* ToDo: add here your device specific external interrupt numbers */ <DeviceInterrupt>_IRQn = 0, /*!< Device Interrupt */ } IRQn_Type; /* =========================================================================================================================== */ /* ================ Processor and Core Peripheral Section ================ */ /* =========================================================================================================================== */ /* =========================== Configuration of the Arm Cortex-A Processor and Core Peripherals ============================ */ /* ToDo: set the defines according your Device */ /* ToDo: define the correct core revision 5U if your device is a CORTEX-A5 device 7U if your device is a CORTEX-A7 device 9U if your device is a CORTEX-A9 device */ #define __CORTEX_A #U /*!< Cortex-A# Core */ #define __CA_REV 0x0000U /*!< Core revision r0p0 */ /* ToDo: define the correct core features for the <Device> */ #define __FPU_PRESENT 1U /*!< Set to 1 if FPU is present */ #define __GIC_PRESENT 1U /*!< Set to 1 if GIC is present */ #define __TIM_PRESENT 1U /*!< Set to 1 if TIM is present */ #define __L2C_PRESENT 1U /*!< Set to 1 if L2C is present */ /** @} */ /* End of group Configuration_of_CMSIS */ /* ToDo: include the correct core_ca#.h file core_ca5.h if your device is a CORTEX-A5 device core_ca7.h if your device is a CORTEX-A7 device core_ca9.h if your device is a CORTEX-A9 device */ #include <core_ca#.h> /*!< Arm Cortex-A# processor and core peripherals */ /* ToDo: include your system_<Device>.h file replace '<Device>' with your device name */ #include "system_<Device>.h" /*!< <Device> System */ /* ======================================== Start of section using anonymous unions ======================================== */ #if defined (__CC_ARM) #pragma push #pragma anon_unions #elif defined (__ICCARM__) #pragma language=extended #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc11-extensions" #pragma clang diagnostic ignored "-Wreserved-id-macro" #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning 586 #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif /* =========================================================================================================================== */ /* ================ Device Specific Peripheral Section ================ */ /* =========================================================================================================================== */ /** @addtogroup Device_Peripheral_peripherals * @{ */ /* ToDo: add here your device specific peripheral access structure typedefs following is an example for a timer */ /* =========================================================================================================================== */ /* ================ TMR ================ */ /* =========================================================================================================================== */ /** * @brief Timer (TMR) */ typedef struct { /*!< (@ 0x40000000) TIM Structure */ __IOM uint32_t TimerLoad; /*!< (@ 0x00000004) Timer Load */ __IM uint32_t TimerValue; /*!< (@ 0x00000008) Timer Counter Current Value */ __IOM uint32_t TimerControl; /*!< (@ 0x0000000C) Timer Control */ __OM uint32_t TimerIntClr; /*!< (@ 0x00000010) Timer Interrupt Clear */ __IM uint32_t TimerRIS; /*!< (@ 0x00000014) Timer Raw Interrupt Status */ __IM uint32_t TimerMIS; /*!< (@ 0x00000018) Timer Masked Interrupt Status */ __IM uint32_t RESERVED[1]; __IOM uint32_t TimerBGLoad; /*!< (@ 0x00000020) Background Load Register */ } <DeviceAbbreviation>_TMR_TypeDef; /*@}*/ /* end of group <Device>_Peripherals */ /* ========================================= End of section using anonymous unions ========================================= */ #if defined (__CC_ARM) #pragma pop #elif defined (__ICCARM__) /* leave anonymous unions enabled */ #elif (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic pop #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning restore #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif /* =========================================================================================================================== */ /* ================ Device Specific Peripheral Address Map ================ */ /* =========================================================================================================================== */ /* ToDo: add here your device peripherals base addresses following is an example for timer */ /** @addtogroup Device_Peripheral_peripheralAddr * @{ */ /* Peripheral and SRAM base address */ #define <DeviceAbbreviation>_FLASH_BASE (0x00000000UL) /*!< (FLASH ) Base Address */ #define <DeviceAbbreviation>_SRAM_BASE (0x20000000UL) /*!< (SRAM ) Base Address */ #define <DeviceAbbreviation>_PERIPH_BASE (0x40000000UL) /*!< (Peripheral) Base Address */ /* Peripheral memory map */ #define <DeviceAbbreviation>TIM0_BASE (<DeviceAbbreviation>_PERIPH_BASE) /*!< (Timer0 ) Base Address */ #define <DeviceAbbreviation>TIM1_BASE (<DeviceAbbreviation>_PERIPH_BASE + 0x0800) /*!< (Timer1 ) Base Address */ #define <DeviceAbbreviation>TIM2_BASE (<DeviceAbbreviation>_PERIPH_BASE + 0x1000) /*!< (Timer2 ) Base Address */ /** @} */ /* End of group Device_Peripheral_peripheralAddr */ /* =========================================================================================================================== */ /* ================ Peripheral declaration ================ */ /* =========================================================================================================================== */ /* ToDo: add here your device peripherals pointer definitions following is an example for timer */ /** @addtogroup Device_Peripheral_declaration * @{ */ #define <DeviceAbbreviation>_TIM0 ((<DeviceAbbreviation>_TMR_TypeDef *) <DeviceAbbreviation>TIM0_BASE) #define <DeviceAbbreviation>_TIM1 ((<DeviceAbbreviation>_TMR_TypeDef *) <DeviceAbbreviation>TIM0_BASE) #define <DeviceAbbreviation>_TIM2 ((<DeviceAbbreviation>_TMR_TypeDef *) <DeviceAbbreviation>TIM0_BASE) /** @} */ /* End of group <Device> */ /** @} */ /* End of group <Vendor> */ #ifdef __cplusplus } #endif #endif /* <Device>_H */ ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device_A/Include/Device.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
2,210
```c /****************************************************************************** * @file system_<Device>.c * @brief CMSIS Cortex-A Device Peripheral Access Layer * @version V1.00 * @date 10. January 2018 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include <stdint.h> #include "<Device>.h" /* ToDo: replace '<Device>' with your device name */ #include "irq_ctrl.h" /*your_sha256_hash------------ Define clocks *your_sha256_hash------------*/ /* ToDo: add here your necessary defines for device initialization following is an example for different system frequencies */ #define XTAL (12000000U) /* Oscillator frequency */ #define SYSTEM_CLOCK (5 * XTAL) /*your_sha256_hash------------ System Core Clock Variable *your_sha256_hash------------*/ /* ToDo: initialize SystemCoreClock with the system core clock frequency value achieved after system intitialization. This means system core clock frequency after call to SystemInit() */ uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Clock Frequency (Core Clock)*/ /*your_sha256_hash------------ Clock functions *your_sha256_hash------------*/ void SystemCoreClockUpdate (void) /* Get Core Clock Frequency */ { /* ToDo: add code to calculate the system frequency based upon the current register settings. This function can be used to retrieve the system core clock frequeny after user changed register sittings. */ SystemCoreClock = SYSTEM_CLOCK; } /*your_sha256_hash------------ System Initialization *your_sha256_hash------------*/ void SystemInit (void) { /* ToDo: add code to initialize the system Do not use global variables because this function is called before reaching pre-main. RW section may be overwritten afterwards. */ SystemCoreClock = SYSTEM_CLOCK; // Invalidate entire Unified TLB __set_TLBIALL(0); // Invalidate entire branch predictor array __set_BPIALL(0); __DSB(); __ISB(); // Invalidate instruction cache and flush branch target cache __set_ICIALLU(0); __DSB(); __ISB(); // Invalidate data cache L1C_InvalidateDCacheAll(); // Create Translation Table MMU_CreateTranslationTable(); // Enable MMU MMU_Enable(); // Enable Caches L1C_EnableCaches(); L1C_EnableBTAC(); #if (__L2C_PRESENT == 1) // Enable GIC L2C_Enable(); #endif #if ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) // Enable FPU __FPU_Enable(); #endif // IRQ Initialize IRQ_Initialize(); } ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device_A/Source/system_Device.c
c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
627
```c /**************************************************************************//** * @file system_Device.c * @brief MMU Configuration * Device <DeviceAbbreviation> * @version V1.1.0 * @date 23. November 2018 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ /* Memory map description ToDo: add in this file your device memory map description following is an example of a Cortex-A9 Arm FVP device Memory Type 0xFFFFFFFF |--------------------------| ------------ | FLAG SYNC | Device Memory 0xFFFFF000 |--------------------------| ------------ | Fault | Fault 0xFFF00000 |--------------------------| ------------ | | Normal | | | Daughterboard | | memory | | | 0x80505000 |--------------------------| ------------ |TTB (L2 Sync Flags ) 4k | Normal 0x80504C00 |--------------------------| ------------ |TTB (L2 Peripherals-B) 16k| Normal 0x80504800 |--------------------------| ------------ |TTB (L2 Peripherals-A) 16k| Normal 0x80504400 |--------------------------| ------------ |TTB (L2 Priv Periphs) 4k | Normal 0x80504000 |--------------------------| ------------ | TTB (L1 Descriptors) | Normal 0x80500000 |--------------------------| ------------ | Heap | Normal |--------------------------| ------------ | Stack | Normal 0x80400000 |--------------------------| ------------ | ZI Data | Normal 0x80300000 |--------------------------| ------------ | RW Data | Normal 0x80200000 |--------------------------| ------------ | RO Data | Normal |--------------------------| ------------ | RO Code | USH Normal 0x80000000 |--------------------------| ------------ | Daughterboard | Fault | HSB AXI buses | 0x40000000 |--------------------------| ------------ | Daughterboard | Fault | test chips peripherals | 0x2C002000 |--------------------------| ------------ | Private Address | Device Memory 0x2C000000 |--------------------------| ------------ | Daughterboard | Fault | test chips peripherals | 0x20000000 |--------------------------| ------------ | Peripherals | Device Memory RW/RO | | & Fault 0x00000000 |--------------------------| */ // L1 Cache info and restrictions about architecture of the caches (CCSIR register): // Write-Through support *not* available // Write-Back support available. // Read allocation support available. // Write allocation support available. // Note: You should use the Shareable attribute carefully. // For cores without coherency logic (such as SCU) marking a region as shareable forces the processor to not cache that region regardless of the inner cache settings. // Cortex-A versions of RTX use LDREX/STREX instructions relying on Local monitors. Local monitors will be used only when the region gets cached, regions that are not cached will use the Global Monitor. // Some Cortex-A implementations do not include Global Monitors, so wrongly setting the attribute Shareable may cause STREX to fail. // Recall: When the Shareable attribute is applied to a memory region that is not Write-Back, Normal memory, data held in this region is treated as Non-cacheable. // When SMP bit = 0, Inner WB/WA Cacheable Shareable attributes are treated as Non-cacheable. // When SMP bit = 1, Inner WB/WA Cacheable Shareable attributes are treated as Cacheable. // Following MMU configuration is expected // SCTLR.AFE == 1 (Simplified access permissions model - AP[2:1] define access permissions, AP[0] is an access flag) // SCTLR.TRE == 0 (TEX remap disabled, so memory type and attributes are described directly by bits in the descriptor) // Domain 0 is always the Client domain // Descriptors should place all memory in domain 0 #include "<Device>.h" /* ToDo: replace '<Device>' with your device name */ // L2 table pointers //----------------------------------------------------- #define PRIVATE_TABLE_L2_BASE_4k (0x80504000) //Map 4k Private Address space #define SYNC_FLAGS_TABLE_L2_BASE_4k (0x80504C00) //Map 4k Flag synchronization #define PERIPHERAL_A_TABLE_L2_BASE_64k (0x80504400) //Map 64k Peripheral #1 #define PERIPHERAL_B_TABLE_L2_BASE_64k (0x80504800) //Map 64k Peripheral #2 //--------------------- PERIPHERALS ------------------- #define PERIPHERAL_A_FAULT (0x00000000 + 0x1C000000) #define PERIPHERAL_B_FAULT (0x00100000 + 0x1C000000) //--------------------- SYNC FLAGS -------------------- #define FLAG_SYNC 0xFFFFF000 #define F_SYNC_BASE 0xFFF00000 //1M aligned //Import symbols from linker extern uint32_t Image$$VECTORS$$Base; extern uint32_t Image$$RW_DATA$$Base; extern uint32_t Image$$ZI_DATA$$Base; extern uint32_t Image$$TTB$$ZI$$Base; static uint32_t Sect_Normal; // outer & inner wb/wa, non-shareable, executable, rw, domain 0, base addr 0 static uint32_t Sect_Normal_Cod; // outer & inner wb/wa, non-shareable, executable, ro, domain 0, base addr 0 static uint32_t Sect_Normal_RO; // as Sect_Normal_Cod, but not executable static uint32_t Sect_Normal_RW; // as Sect_Normal_Cod, but writeable and not executable static uint32_t Sect_Device_RO; // device, non-shareable, non-executable, ro, domain 0, base addr 0 static uint32_t Sect_Device_RW; // as Sect_Device_RO, but writeable /* Define global descriptors */ static uint32_t Page_L1_4k = 0x0; // generic static uint32_t Page_L1_64k = 0x0; // generic static uint32_t Page_4k_Device_RW; // shared device, not executable, rw, domain 0 static uint32_t Page_64k_Device_RW; // shared device, not executable, rw, domain 0 void MMU_CreateTranslationTable(void) { mmu_region_attributes_Type region; // Create 4GB of faulting entries MMU_TTSection (&Image$$TTB$$ZI$$Base, 0, 4096, DESCRIPTOR_FAULT); /* * Generate descriptors. Refer to core_ca.h to get information about attributes * */ // Create descriptors for Vectors, RO, RW, ZI sections section_normal(Sect_Normal, region); section_normal_cod(Sect_Normal_Cod, region); section_normal_ro(Sect_Normal_RO, region); section_normal_rw(Sect_Normal_RW, region); // Create descriptors for peripherals section_Device_ro(Sect_Device_RO, region); section_Device_rw(Sect_Device_RW, region); // Create descriptors for 64k pages page64k_Device_rw(Page_L1_64k, Page_64k_Device_RW, region); // Create descriptors for 4k pages page4k_Device_rw(Page_L1_4k, Page_4k_Device_RW, region); /* * Define MMU flat-map regions and attributes * */ // Define Image MMU_TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$VECTORS$$Base , 1U, Sect_Normal_Cod); MMU_TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$RW_DATA$$Base , 1U, Sect_Normal_RW); MMU_TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$ZI_DATA$$Base , 1U, Sect_Normal_RW); // All DRAM executable, RW, cacheable - applications may choose to divide memory into RO executable MMU_TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$TTB$$ZI$$Base , 2043U, Sect_Normal); //--------------------- PERIPHERALS ------------------- MMU_TTSection (&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_FLASH_BASE0 , 64U, Sect_Device_RO); MMU_TTSection (&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_FLASH_BASE1 , 64U, Sect_Device_RO); MMU_TTSection (&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_SRAM_BASE , 64U, Sect_Device_RW); MMU_TTSection (&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_VRAM_BASE , 32U, Sect_Device_RW); MMU_TTSection (&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_ETHERNET_BASE , 16U, Sect_Device_RW); MMU_TTSection (&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_USB_BASE , 16U, Sect_Device_RW); // Create (16 * 64k)=1MB faulting entries to cover peripheral range MMU_TTPage64k(&Image$$TTB$$ZI$$Base, PERIPHERAL_A_FAULT , 16U, Page_L1_64k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_64k, DESCRIPTOR_FAULT); // Define peripheral range MMU_TTPage64k(&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_DAP_BASE , 1U, Page_L1_64k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_64k, Page_64k_Device_RW); MMU_TTPage64k(&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_SYSTEM_REG_BASE , 1U, Page_L1_64k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_64k, Page_64k_Device_RW); MMU_TTPage64k(&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_SERIAL_BASE , 1U, Page_L1_64k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_64k, Page_64k_Device_RW); MMU_TTPage64k(&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_AACI_BASE , 1U, Page_L1_64k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_64k, Page_64k_Device_RW); MMU_TTPage64k(&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_MMCI_BASE , 1U, Page_L1_64k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_64k, Page_64k_Device_RW); MMU_TTPage64k(&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_KMI0_BASE , 2U, Page_L1_64k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_64k, Page_64k_Device_RW); MMU_TTPage64k(&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_UART_BASE , 4U, Page_L1_64k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_64k, Page_64k_Device_RW); MMU_TTPage64k(&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_WDT_BASE , 1U, Page_L1_64k, (uint32_t *)PERIPHERAL_A_TABLE_L2_BASE_64k, Page_64k_Device_RW); // Create (16 * 64k)=1MB faulting entries to cover peripheral range MMU_TTPage64k(&Image$$TTB$$ZI$$Base, PERIPHERAL_B_FAULT , 16U, Page_L1_64k, (uint32_t *)PERIPHERAL_B_TABLE_L2_BASE_64k, DESCRIPTOR_FAULT); // Define peripheral range MMU_TTPage64k(&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_TIMER_BASE , 2U, Page_L1_64k, (uint32_t *)PERIPHERAL_B_TABLE_L2_BASE_64k, Page_64k_Device_RW); MMU_TTPage64k(&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_DVI_BASE , 1U, Page_L1_64k, (uint32_t *)PERIPHERAL_B_TABLE_L2_BASE_64k, Page_64k_Device_RW); MMU_TTPage64k(&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_RTC_BASE , 1U, Page_L1_64k, (uint32_t *)PERIPHERAL_B_TABLE_L2_BASE_64k, Page_64k_Device_RW); MMU_TTPage64k(&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_UART4_BASE , 1U, Page_L1_64k, (uint32_t *)PERIPHERAL_B_TABLE_L2_BASE_64k, Page_64k_Device_RW); MMU_TTPage64k(&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_CLCD_BASE , 1U, Page_L1_64k, (uint32_t *)PERIPHERAL_B_TABLE_L2_BASE_64k, Page_64k_Device_RW); // Create (256 * 4k)=1MB faulting entries to cover private address space. Needs to be marked as Device memory MMU_TTPage4k (&Image$$TTB$$ZI$$Base, __get_CBAR() , 256U, Page_L1_4k, (uint32_t *)PRIVATE_TABLE_L2_BASE_4k, DESCRIPTOR_FAULT); // Define private address space entry MMU_TTPage4k (&Image$$TTB$$ZI$$Base, __get_CBAR() , 2U, Page_L1_4k, (uint32_t *)PRIVATE_TABLE_L2_BASE_4k, Page_4k_Device_RW); // Define L2CC entry MMU_TTPage4k (&Image$$TTB$$ZI$$Base, <DeviceAbbreviation>_L2C_BASE , 1U, Page_L1_4k, (uint32_t *)PRIVATE_TABLE_L2_BASE_4k, Page_4k_Device_RW); // Create (256 * 4k)=1MB faulting entries to synchronization space (Useful if some non-cacheable DMA agent is present in the SoC) MMU_TTPage4k (&Image$$TTB$$ZI$$Base, F_SYNC_BASE , 256U, Page_L1_4k, (uint32_t *)SYNC_FLAGS_TABLE_L2_BASE_4k, DESCRIPTOR_FAULT); // Define synchronization space entry. MMU_TTPage4k (&Image$$TTB$$ZI$$Base, FLAG_SYNC , 1U, Page_L1_4k, (uint32_t *)SYNC_FLAGS_TABLE_L2_BASE_4k, Page_4k_Device_RW); /* Set location of level 1 page table ; 31:14 - Translation table base addr (31:14-TTBCR.N, TTBCR.N is 0 out of reset) ; 13:7 - 0x0 ; 6 - IRGN[0] 0x1 (Inner WB WA) ; 5 - NOS 0x0 (Non-shared) ; 4:3 - RGN 0x01 (Outer WB WA) ; 2 - IMP 0x0 (Implementation Defined) ; 1 - S 0x0 (Non-shared) ; 0 - IRGN[1] 0x0 (Inner WB WA) */ __set_TTBR0(((uint32_t)&Image$$TTB$$ZI$$Base) | 0x48); __ISB(); /* Set up domain access control register ; We set domain 0 to Client and all other domains to No Access. ; All translation table entries specify domain 0 */ __set_DACR(1); __ISB(); } ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device_A/Source/mmu_Device.c
c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
3,864
```c /****************************************************************************** * @file startup_<Device>.c * @brief CMSIS Cortex-A Device Startup * @version V1.00 * @date 10. January 2018 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include "<Device>.h" /* ToDo: replace '<Device>' with your device name */ /*your_sha256_hash------------ Definitions *your_sha256_hash------------*/ #define USR_MODE 0x10 // User mode #define FIQ_MODE 0x11 // Fast Interrupt Request mode #define IRQ_MODE 0x12 // Interrupt Request mode #define SVC_MODE 0x13 // Supervisor mode #define ABT_MODE 0x17 // Abort mode #define UND_MODE 0x1B // Undefined Instruction mode #define SYS_MODE 0x1F // System mode /*your_sha256_hash------------ Internal References *your_sha256_hash------------*/ void Vectors (void) __attribute__ ((section("RESET"))); void Reset_Handler (void); /*your_sha256_hash------------ Exception / Interrupt Handler *your_sha256_hash------------*/ void Undef_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void PAbt_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void DAbt_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void IRQ_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void FIQ_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); /*your_sha256_hash------------ Exception / Interrupt Vector Table *your_sha256_hash------------*/ __ASM void Vectors(void) { IMPORT Undef_Handler IMPORT SVC_Handler IMPORT PAbt_Handler IMPORT DAbt_Handler IMPORT IRQ_Handler IMPORT FIQ_Handler LDR PC, =Reset_Handler LDR PC, =Undef_Handler LDR PC, =SVC_Handler LDR PC, =PAbt_Handler LDR PC, =DAbt_Handler NOP LDR PC, =IRQ_Handler LDR PC, =FIQ_Handler } /*your_sha256_hash------------ Reset Handler called on controller reset *your_sha256_hash------------*/ __ASM void Reset_Handler(void) { // Mask interrupts CPSID if // Put any cores other than 0 to sleep MRC p15, 0, R0, c0, c0, 5 // Read MPIDR ANDS R0, R0, #3 goToSleep WFINE BNE goToSleep // Reset SCTLR Settings MRC p15, 0, R0, c1, c0, 0 // Read CP15 System Control register BIC R0, R0, #(0x1 << 12) // Clear I bit 12 to disable I Cache BIC R0, R0, #(0x1 << 2) // Clear C bit 2 to disable D Cache BIC R0, R0, #0x1 // Clear M bit 0 to disable MMU BIC R0, R0, #(0x1 << 11) // Clear Z bit 11 to disable branch prediction BIC R0, R0, #(0x1 << 13) // Clear V bit 13 to disable hivecs MCR p15, 0, R0, c1, c0, 0 // Write value back to CP15 System Control register ISB // Configure ACTLR MRC p15, 0, r0, c1, c0, 1 // Read CP15 Auxiliary Control Register ORR r0, r0, #(1 << 1) // Enable L2 prefetch hint (UNK/WI since r4p1) MCR p15, 0, r0, c1, c0, 1 // Write CP15 Auxiliary Control Register // Set Vector Base Address Register (VBAR) to point to this application's vector table LDR R0, =Vectors MCR p15, 0, R0, c12, c0, 0 // Setup Stack for each exceptional mode IMPORT |Image$$FIQ_STACK$$ZI$$Limit| IMPORT |Image$$IRQ_STACK$$ZI$$Limit| IMPORT |Image$$SVC_STACK$$ZI$$Limit| IMPORT |Image$$ABT_STACK$$ZI$$Limit| IMPORT |Image$$UND_STACK$$ZI$$Limit| IMPORT |Image$$ARM_LIB_STACK$$ZI$$Limit| CPS #0x11 LDR SP, =|Image$$FIQ_STACK$$ZI$$Limit| CPS #0x12 LDR SP, =|Image$$IRQ_STACK$$ZI$$Limit| CPS #0x13 LDR SP, =|Image$$SVC_STACK$$ZI$$Limit| CPS #0x17 LDR SP, =|Image$$ABT_STACK$$ZI$$Limit| CPS #0x1B LDR SP, =|Image$$UND_STACK$$ZI$$Limit| CPS #0x1F LDR SP, =|Image$$ARM_LIB_STACK$$ZI$$Limit| // Call SystemInit IMPORT SystemInit BL SystemInit // Unmask interrupts CPSIE if // Call __main IMPORT __main BL __main } /*your_sha256_hash------------ Default Handler for Exceptions / Interrupts *your_sha256_hash------------*/ void Default_Handler(void) { while(1); } ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device_A/Source/ARM/startup_Device.c
c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,350
```objective-c /*************************************************************************//** * @file system_<Device>.h * @brief CMSIS-Core(M) Device Peripheral Access Layer Header File for * Device <Device> * @version V1.0.1 * @date 11. July 2022 *****************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef SYSTEM_<Device>_H /* ToDo: replace '<Device>' with your device name */ #define SYSTEM_<Device>_H #ifdef __cplusplus extern "C" { #endif #include <stdint.h> /** \brief Exception / Interrupt Handler Function Prototype */ typedef void(*VECTOR_TABLE_Type)(void); /** \brief System Clock Frequency (Core Clock) */ extern uint32_t SystemCoreClock; /** \brief Setup the microcontroller system. Initialize the System and update the SystemCoreClock variable. */ extern void SystemInit (void); /** \brief Update SystemCoreClock variable. Updates the SystemCoreClock with current core Clock retrieved from cpu registers. */ extern void SystemCoreClockUpdate (void); #ifdef __cplusplus } #endif #endif /* SYSTEM_<Device>_H */ ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device/Include/system_Device.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
270
```objective-c /*************************************************************************//** * @file <Device>.h * @brief CMSIS-Core(M) Device Peripheral Access Layer Header File for * Device <Device> * @version V1.0.0 * @date 20. January 2021 *****************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef <Device>_H /* ToDo: Replace '<Device>' with your device name */ #define <Device>_H #ifdef __cplusplus extern "C" { #endif /* ========================================================================= */ /* ============ Interrupt Number Definition ============ */ /* ========================================================================= */ typedef enum IRQn { /* ================ Cortex-M Core Exception Numbers ================ */ /* ToDo: Add Cortex exception numbers according the used Cortex-Core */ Reset_IRQn = -15, /* 1 Reset Vector invoked on Power up and warm reset */ NonMaskableInt_IRQn = -14, /* 2 Non maskable Interrupt cannot be stopped or preempted */ HardFault_IRQn = -13, /* 3 Hard Fault all classes of Fault */ MemoryManagement_IRQn = -12, /* 4 Memory Management MPU mismatch, including Access Violation and No Match */ BusFault_IRQn = -11, /* 5 Bus Fault Pre-Fetch-, Memory Access, other address/memory Fault */ UsageFault_IRQn = -10, /* 6 Usage Fault i.e. Undef Instruction, Illegal State Transition */ SecureFault_IRQn = -9, /* 7 Secure Fault Interrupt */ SVCall_IRQn = -5, /* 11 System Service Call via SVC instruction */ DebugMonitor_IRQn = -4, /* 12 Debug Monitor */ PendSV_IRQn = -2, /* 14 Pendable request for system service */ SysTick_IRQn = -1, /* 15 System Tick Timer */ /* ================ <Device> Interrupt Numbers ================ */ /* ToDo: Add here your device specific interrupt numbers according the interrupt handlers defined in startup_Device.s eg.: Interrupt for Timer#1 TIM1_IRQHandler -> TIM1_IRQn */ <DeviceInterrupt first>_IRQn = 0, /* first Device Interrupt*/ ... <DeviceInterrupt last>_IRQn = n /* last Device Interrupt */ } IRQn_Type; /* ========================================================================= */ /* ============ Processor and Core Peripheral Section ============ */ /* ========================================================================= */ /* ================ Start of section using anonymous unions ================ */ #if defined (__CC_ARM) #pragma push #pragma anon_unions #elif defined (__ICCARM__) #pragma language=extended #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wc11-extensions" #pragma clang diagnostic ignored "-Wreserved-id-macro" #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning 586 #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif /* ================ Configuration of Core Peripherals ================ */ /* ToDo: Set the defines according your Device */ /* ToDo: Define the correct core revision valid CMSIS core revision macro names are: __CM0_REV, __CM0PLUS_REV, __CM1_REV, __CM3_REV, __CM4_REV, __CM7_REV __CM23_REV, __CM33_REV, __CM35P_REV, __CM55_REV __SC000_REV, __SC300_REV */ #define __CM#_REV 0x0201U /* Core Revision r2p1 */ /* ToDo: define the correct core features for the <Device> */ #define __Vendor_SysTickConfig 0U /* Set to 1 if different SysTick Config is used */ #define __NVIC_PRIO_BITS 3U /* Number of Bits used for Priority Levels */ #define __VTOR_PRESENT 1U /* Set to 1 if VTOR is present */ #define __MPU_PRESENT 1U /* Set to 1 if MPU is present */ #define __FPU_PRESENT 0U /* Set to 1 if FPU is present */ #define __FPU_DP 0U /* Set to 1 if FPU is double precision FPU (default is single precision FPU) */ #define __DSP_PRESENT 1U /* Set to 1 if DSP extension are present */ #define __SAUREGION_PRESENT 1U /* Set to 1 if SAU regions are present */ #define __PMU_PRESENT 1U /* Set to 1 if PMU is present */ #define __PMU_NUM_EVENTCNT 8U /* Set number of PMU Event Counters */ #define __ICACHE_PRESENT 0U /* Set to 1 if I-Cache is present */ #define __DCACHE_PRESENT 0U /* Set to 1 if D-Cache is present */ #define __DTCM_PRESENT 0U /* Set to 1 if DTCM is present */ /* ToDo: Include the CMSIS core header file according your device. valid CMSIS core header files are: core_cm0.h, core_cm0plus.h, core_cm1.h, core_cm3.h, core_cm4.h, core_cm7.h core_cm23.h, core_cm33.h, core_cm35p.h, core_cm55.h core_sc000.h, core_sc300.h */ #include <core_cm#.h> /* Processor and core peripherals */ /* ToDo: Include your system_<Device>.h file replace '<Device>' with your device name */ #include "system_<Device>.h" /* System Header */ /* ========================================================================= */ /* ============ Device Specific Peripheral Section ============ */ /* ========================================================================= */ /* ToDo: Add here your device specific peripheral access structure typedefs including bit definitions for Pos/Msk macros following is an example for a timer */ /* ========================================================================= */ /* ============ TMR ============ */ /* ========================================================================= */ typedef struct { __IOM uint32_t LOAD; /* Offset: 0x000 (R/W) Load Register */ __IM uint32_t VALUE; /* Offset: 0x004 (R/ ) Value Register */ __IOM uint32_t CONTROL; /* Offset: 0x008 (R/W) Control Register */ __OM uint32_t INTCLR; /* Offset: 0x00C ( /W) Clear Interrupt Register */ __IM uint32_t RIS; /* Offset: 0x010 (R/ ) Raw Interrupt Status Register */ __IM uint32_t MIS; /* Offset: 0x014 (R/ ) Interrupt Status Register */ __IOM uint32_t BGLOAD; /* Offset: 0x018 (R/W) Background Load Register */ } <DeviceAbbreviation>_TMR_TypeDef; /* <DeviceAbbreviation>_TMR LOAD Register Definitions */ #define <DeviceAbbreviation>_TMR_LOAD_Pos 0 #define <DeviceAbbreviation>_TMR_LOAD_Msk (0xFFFFFFFFUL /*<< <DeviceAbbreviation>_TMR_LOAD_Pos*/) /* <DeviceAbbreviation>_TMR VALUE Register Definitions */ #define <DeviceAbbreviation>_TMR_VALUE_Pos 0 #define <DeviceAbbreviation>_TMR_VALUE_Msk (0xFFFFFFFFUL /*<< <DeviceAbbreviation>_TMR_VALUE_Pos*/) /* <DeviceAbbreviation>_TMR CONTROL Register Definitions */ #define <DeviceAbbreviation>_TMR_CONTROL_SIZE_Pos 1 #define <DeviceAbbreviation>_TMR_CONTROL_SIZE_Msk (1UL << <DeviceAbbreviation>_TMR_CONTROL_SIZE_Pos) #define <DeviceAbbreviation>_TMR_CONTROL_ONESHOT_Pos 0 #define <DeviceAbbreviation>_TMR_CONTROL_ONESHOT_Msk (1UL /*<< <DeviceAbbreviation>_TMR_CONTROL_ONESHOT_Pos*/) /* ================ End of section using anonymous unions ================ */ #if defined (__CC_ARM) #pragma pop #elif defined (__ICCARM__) /* leave anonymous unions enabled */ #elif (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) #pragma clang diagnostic pop #elif defined (__GNUC__) /* anonymous unions are enabled by default */ #elif defined (__TMS470__) /* anonymous unions are enabled by default */ #elif defined (__TASKING__) #pragma warning restore #elif defined (__CSMC__) /* anonymous unions are enabled by default */ #else #warning Not supported compiler type #endif /* ========================================================================= */ /* ============ Device Specific Peripheral Address Map ============ */ /* ========================================================================= */ /* ToDo: Add here your device peripherals base addresses following is an example for timer */ /* Peripheral and SRAM base address */ #define <DeviceAbbreviation>_FLASH_BASE (0x00000000UL) /* (FLASH ) Base Address */ #define <DeviceAbbreviation>_SRAM_BASE (0x20000000UL) /* (SRAM ) Base Address */ #define <DeviceAbbreviation>_PERIPH_BASE (0x40000000UL) /* (Peripheral) Base Address */ /* Peripheral memory map */ #define <DeviceAbbreviation>TIM0_BASE (<DeviceAbbreviation>_PERIPH_BASE) /* (Timer0 ) Base Address */ #define <DeviceAbbreviation>TIM1_BASE (<DeviceAbbreviation>_PERIPH_BASE + 0x0800) /* (Timer1 ) Base Address */ #define <DeviceAbbreviation>TIM2_BASE (<DeviceAbbreviation>_PERIPH_BASE + 0x1000) /* (Timer2 ) Base Address */ /* ========================================================================= */ /* ============ Peripheral declaration ============ */ /* ========================================================================= */ /* ToDo: Add here your device peripherals pointer definitions following is an example for timer */ #define <DeviceAbbreviation>_TIM0 ((<DeviceAbbreviation>_TMR_TypeDef *) <DeviceAbbreviation>TIM0_BASE) #define <DeviceAbbreviation>_TIM1 ((<DeviceAbbreviation>_TMR_TypeDef *) <DeviceAbbreviation>TIM0_BASE) #define <DeviceAbbreviation>_TIM2 ((<DeviceAbbreviation>_TMR_TypeDef *) <DeviceAbbreviation>TIM0_BASE) #ifdef __cplusplus } #endif #endif /* <Device>_H */ ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device/Include/Device.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
2,314
```c /*************************************************************************//** * @file system_<Device>.c * @brief CMSIS-Core(M) Device Peripheral Access Layer Source File for * Device <Device> * @version V1.0.0 * @date 20. January 2021 *****************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include <stdint.h> #include "<Device>.h" /* ToDo: Include partition header file if TZ is used */ #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) #include "partition_<Device>.h" #endif /*your_sha256_hash----------- Define clocks *your_sha256_hash-----------*/ /* ToDo: Add here your necessary defines for device initialization following is an example for different system frequencies */ #define XTAL (12000000U) /* Oscillator frequency */ #define SYSTEM_CLOCK (5 * XTAL) /*your_sha256_hash----------- Exception / Interrupt Vector table *your_sha256_hash-----------*/ extern const VECTOR_TABLE_Type __VECTOR_TABLE[496]; /*your_sha256_hash----------- System Core Clock Variable *your_sha256_hash-----------*/ /* ToDo: Initialize SystemCoreClock with the system core clock frequency value achieved after system intitialization. This means system core clock frequency after call to SystemInit() */ uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Clock Frequency (Core Clock)*/ /*your_sha256_hash----------- System Core Clock function *your_sha256_hash-----------*/ void SystemCoreClockUpdate (void) { /* ToDo: Add code to calculate the system frequency based upon the current register settings. This function can be used to retrieve the system core clock frequeny after user changed register sittings. */ SystemCoreClock = SYSTEM_CLOCK; } /*your_sha256_hash----------- System initialization function *your_sha256_hash-----------*/ void SystemInit (void) { /* ToDo: Add code to initialize the system. Do not use global variables because this function is called before reaching pre-main. RW section maybe overwritten afterwards. */ /* ToDo: Initialize VTOR if available */ #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) SCB->VTOR = (uint32_t)(&__VECTOR_TABLE[0]); #endif /* ToDo: Enable co-processor if it is used */ #if (defined (__FPU_USED) && (__FPU_USED == 1U)) || \ (defined (__ARM_FEATURE_MVE) && (__ARM_FEATURE_MVE > 0U)) SCB->CPACR |= ((3U << 10U*2U) | /* enable CP10 Full Access */ (3U << 11U*2U) ); /* enable CP11 Full Access */ #endif /* ToDo: Initialize SAU if TZ is used */ #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) TZ_SAU_Setup(); #endif SystemCoreClock = SYSTEM_CLOCK; } ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device/Source/system_Device.c
c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
667
```c /****************************************************************************** * @file startup_<Device>.c * @brief CMSIS-Core(M) Device Startup File for * Device <Device> * @version V1.0.0 * @date 20. January 2021 ******************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include "<Device>.h" /*your_sha256_hash----------- External References *your_sha256_hash-----------*/ extern uint32_t __INITIAL_SP; extern uint32_t __STACK_LIMIT; #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) extern uint32_t __STACK_SEAL; #endif extern __NO_RETURN void __PROGRAM_START(void); /*your_sha256_hash----------- Internal References *your_sha256_hash-----------*/ __NO_RETURN void Reset_Handler (void); __NO_RETURN void Default_Handler(void); /* ToDo: Add Cortex exception handler according the used Cortex-Core */ /*your_sha256_hash----------- Exception / Interrupt Handler *your_sha256_hash-----------*/ /* Exceptions */ void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void HardFault_Handler (void) __attribute__ ((weak)); void MemManage_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void BusFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void UsageFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void SecureFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void DebugMon_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); /* ToDo: Add your device specific interrupt handler */ void <DeviceInterrupt first>_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); ... void <DeviceInterrupt last>_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); /*your_sha256_hash------------ Exception / Interrupt Vector table *your_sha256_hash------------*/ #if defined ( __GNUC__ ) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" #endif /* ToDo: Add Cortex exception vectors according the used Cortex-Core */ extern const VECTOR_TABLE_Type __VECTOR_TABLE[<Device vector table entries>]; const VECTOR_TABLE_Type __VECTOR_TABLE[<Device vector table entries>] __VECTOR_TABLE_ATTRIBUTE = { (VECTOR_TABLE_Type)(&__INITIAL_SP), /* Initial Stack Pointer */ Reset_Handler, /* Reset Handler */ NMI_Handler, /* -14 NMI Handler */ HardFault_Handler, /* -13 Hard Fault Handler */ MemManage_Handler, /* -12 MPU Fault Handler */ BusFault_Handler, /* -11 Bus Fault Handler */ UsageFault_Handler, /* -10 Usage Fault Handler */ SecureFault_Handler, /* -9 Secure Fault Handler */ 0, /* Reserved */ 0, /* Reserved */ 0, /* Reserved */ SVC_Handler, /* -5 SVCall Handler */ DebugMon_Handler, /* -4 Debug Monitor Handler */ 0, /* Reserved */ PendSV_Handler, /* -2 PendSV Handler */ SysTick_Handler, /* -1 SysTick Handler */ /* ToDo: Add your device specific interrupt vectors */ /* Interrupts */ <DeviceInterrupt first>_Handler, /* first Device Interrupt */ ... <DeviceInterrupt last>_Handler /* last Device Interrupt */ }; #if defined ( __GNUC__ ) #pragma GCC diagnostic pop #endif /*your_sha256_hash----------- Reset Handler called on controller reset *your_sha256_hash-----------*/ __NO_RETURN void Reset_Handler(void) { __set_PSP((uint32_t)(&__INITIAL_SP)); /* ToDo: Initialize stack limit register for Armv8-M Main Extension based processors*/ __set_MSPLIM((uint32_t)(&__STACK_LIMIT)); __set_PSPLIM((uint32_t)(&__STACK_LIMIT)); /* ToDo: Add stack sealing for Armv8-M based processors */ #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) __TZ_set_STACKSEAL_S((uint32_t *)(&__STACK_SEAL)); #endif SystemInit(); /* CMSIS System Initialization */ __PROGRAM_START(); /* Enter PreMain (C library entry point) */ } #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmissing-noreturn" #endif /*your_sha256_hash----------- Hard Fault Handler *your_sha256_hash-----------*/ void HardFault_Handler(void) { while(1); } /*your_sha256_hash----------- Default Handler for Exceptions / Interrupts *your_sha256_hash-----------*/ void Default_Handler(void) { while(1); } #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #pragma clang diagnostic pop #endif ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device/Source/startup_Device.c
c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,145
```gas ;/*************************************************************************//** ; * @file startup_<Device>.s ; * @brief CMSIS-Core(M) Device Startup File for ; * Device <Device> (using Arm Compiler 5 with scatter file) ; * @version V1.0.0 ; * @date 20. January 2021 ; ****************************************************************************/ ;/* ; * ; * ; * ; * www.apache.org/licenses/LICENSE-2.0 ; * ; * Unless required by applicable law or agreed to in writing, software ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; */ PRESERVE8 THUMB ; Vector Table Mapped to Address 0 at Reset AREA RESET, DATA, READONLY EXPORT __Vectors EXPORT __Vectors_End EXPORT __Vectors_Size IMPORT |Image$$ARM_LIB_STACK$$ZI$$Limit| ; ToDo: Add Cortex exception vectors according the used Cortex-Core __Vectors DCD |Image$$ARM_LIB_STACK$$ZI$$Limit| ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; -14 NMI Handler DCD HardFault_Handler ; -13 Hard Fault Handler DCD MemManage_Handler ; -12 MPU Fault Handler DCD BusFault_Handler ; -11 Bus Fault Handler DCD UsageFault_Handler ; -10 Usage Fault Handler DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD SVC_Handler ; -5 SVCall Handler DCD DebugMon_Handler ; -4 Debug Monitor Handler DCD 0 ; Reserved DCD PendSV_Handler ; -2 PendSV Handler DCD SysTick_Handler ; -1 SysTick Handler ; ToDo: Add your device specific interrupt vectors ; Interrupts DCD <DeviceInterrupt first>_Handler ; first Device Interrupt ... DCD <DeviceInterrupt last>_Handler ; last Device Interrupt ; ToDo: calculate the empty space according the used Cortex-Core SPACE (x * 4) ; Interrupts x .. 224 are left out __Vectors_End __Vectors_Size EQU __Vectors_End - __Vectors AREA |.text|, CODE, READONLY ; Reset Handler Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT __main LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP ; The default macro is not used for HardFault_Handler ; because this results in a poor debug illusion. HardFault_Handler PROC EXPORT HardFault_Handler [WEAK] B . ENDP ; Macro to define default exception/interrupt handlers. ; Default handler are weak symbols with an endless loop. ; They can be overwritten by real handlers. MACRO Set_Default_Handler $Handler_Name $Handler_Name PROC EXPORT $Handler_Name [WEAK] B . ENDP MEND ; ToDo: Add Cortex exception handler according the used Cortex-Core ; Default exception/interrupt handler Set_Default_Handler NMI_Handler ; Set_Default_Handler HardFault_Handler Set_Default_Handler MemManage_Handler Set_Default_Handler BusFault_Handler Set_Default_Handler UsageFault_Handler Set_Default_Handler SVC_Handler Set_Default_Handler DebugMon_Handler Set_Default_Handler PendSV_Handler Set_Default_Handler SysTick_Handler ; ToDo: Add your device specific interrupt handler Set_Default_Handler <DeviceInterrupt first>_Handler ... Set_Default_Handler <DeviceInterrupt last>_Handler ALIGN ; User setup Stack & Heap IF :LNOT::DEF:__MICROLIB IMPORT __use_two_region_memory ENDIF EXPORT __stack_limit EXPORT __initial_sp IF Heap_Size != 0 ; Heap is provided EXPORT __heap_base EXPORT __heap_limit ENDIF END ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device/Source/ARM/startup_Device_ac5.s
gas
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
964
```gas ;/*************************************************************************//** ; * @file startup_<Device>.s ; * @brief CMSIS-Core(M) Device Startup File for ; * Device <Device> (using Arm Compiler 5 without scatter file) ; * @version V1.0.0 ; * @date 20. January 2021 ; ****************************************************************************/ ;/* ; * ; * ; * ; * www.apache.org/licenses/LICENSE-2.0 ; * ; * Unless required by applicable law or agreed to in writing, software ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; */ ;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ ;<h> Stack Configuration ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> ;</h> Stack_Size EQU 0x00000400 AREA STACK, NOINIT, READWRITE, ALIGN=3 __stack_limit Stack_Mem SPACE Stack_Size __initial_sp ;<h> Heap Configuration ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> ;</h> Heap_Size EQU 0x00000C00 IF Heap_Size != 0 ; Heap is provided AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit ENDIF PRESERVE8 THUMB ; Vector Table Mapped to Address 0 at Reset AREA RESET, DATA, READONLY EXPORT __Vectors EXPORT __Vectors_End EXPORT __Vectors_Size ; ToDo: Add Cortex exception vectors according the used Cortex-Core __Vectors DCD __initial_sp ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; -14 NMI Handler DCD HardFault_Handler ; -13 Hard Fault Handler DCD MemManage_Handler ; -12 MPU Fault Handler DCD BusFault_Handler ; -11 Bus Fault Handler DCD UsageFault_Handler ; -10 Usage Fault Handler DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD SVC_Handler ; -5 SVCall Handler DCD DebugMon_Handler ; -4 Debug Monitor Handler DCD 0 ; Reserved DCD PendSV_Handler ; -2 PendSV Handler DCD SysTick_Handler ; -1 SysTick Handler ; ToDo: Add your device specific interrupt vectors ; Interrupts DCD <DeviceInterrupt first>_Handler ; first Device Interrupt ... DCD <DeviceInterrupt last>_Handler ; last Device Interrupt ; ToDo: calculate the empty space according the used Cortex-Core SPACE (x * 4) ; Interrupts x .. 224 are left out __Vectors_End __Vectors_Size EQU __Vectors_End - __Vectors AREA |.text|, CODE, READONLY ; Reset Handler Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT __main LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP ; The default macro is not used for HardFault_Handler ; because this results in a poor debug illusion. HardFault_Handler PROC EXPORT HardFault_Handler [WEAK] B . ENDP ; Macro to define default exception/interrupt handlers. ; Default handler are weak symbols with an endless loop. ; They can be overwritten by real handlers. MACRO Set_Default_Handler $Handler_Name $Handler_Name PROC EXPORT $Handler_Name [WEAK] B . ENDP MEND ; ToDo: Add Cortex exception handler according the used Cortex-Core ; Default exception/interrupt handler Set_Default_Handler NMI_Handler ; Set_Default_Handler HardFault_Handler Set_Default_Handler MemManage_Handler Set_Default_Handler BusFault_Handler Set_Default_Handler UsageFault_Handler Set_Default_Handler SVC_Handler Set_Default_Handler DebugMon_Handler Set_Default_Handler PendSV_Handler Set_Default_Handler SysTick_Handler ; ToDo: Add your device specific interrupt handler Set_Default_Handler <DeviceInterrupt first>_Handler ... Set_Default_Handler <DeviceInterrupt last>_Handler ALIGN ; User setup Stack & Heap IF :LNOT::DEF:__MICROLIB IMPORT __use_two_region_memory ENDIF EXPORT __stack_limit EXPORT __initial_sp IF Heap_Size != 0 ; Heap is provided EXPORT __heap_base EXPORT __heap_limit ENDIF END ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device/Source/ARM/startup_Device_ac5_noSct.s
gas
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,123
```gas ;/**************************************************************************//** ; * @file startup_<Device>.s ; * @brief CMSIS Cortex-M# Core Device Startup File for ; * Device <Device> ; * @version V1.0.0 ; * @date 09. July 2018 ; ******************************************************************************/ ;/* ; * ; * ; * ; * www.apache.org/licenses/LICENSE-2.0 ; * ; * Unless required by applicable law or agreed to in writing, software ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; */ ; ; The modules in this file are included in the libraries, and may be replaced ; by any user-defined modules that define the PUBLIC symbol _program_start or ; a user defined start symbol. ; To override the cstartup defined in the library, simply add your modified ; version to the workbench project. ; ; The vector table is normally located at address 0. ; When debugging in RAM, it can be located in RAM, aligned to at least 2^6. ; The name "__vector_table" has special meaning for C-SPY: ; it is where the SP start value is found, and the NVIC vector ; table register (VTOR) is initialized to this address if != 0. ; ; Cortex-M version ; MODULE ?cstartup ;; Forward declaration of sections. SECTION CSTACK:DATA:NOROOT(3) SECTION .intvec:CODE:NOROOT(2) EXTERN __iar_program_start EXTERN SystemInit PUBLIC __vector_table PUBLIC __vector_table_0x1c PUBLIC __Vectors PUBLIC __Vectors_End PUBLIC __Vectors_Size DATA __vector_table DCD sfe(CSTACK) ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; -14 NMI Handler DCD HardFault_Handler ; -13 Hard Fault Handler DCD MemManage_Handler ; -12 MPU Fault Handler DCD BusFault_Handler ; -11 Bus Fault Handler DCD UsageFault_Handler ; -10 Usage Fault Handler __vector_table_0x1c DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD 0 ; Reserved DCD SVC_Handler ; -5 SVCall Handler DCD DebugMon_Handler ; -4 Debug Monitor Handler DCD 0 ; Reserved DCD PendSV_Handler ; -2 PendSV Handler DCD SysTick_Handler ; -1 SysTick Handler ; External Interrupts ; ToDo: Add here the vectors for the device specific external interrupts handler DCD Interrupt0_Handler ; 0 Interrupt 0 DCD Interrupt1_Handler ; 1 Interrupt 1 DCD Interrupt2_Handler ; 2 Interrupt 2 DCD Interrupt3_Handler ; 3 Interrupt 3 DCD Interrupt4_Handler ; 4 Interrupt 4 DCD Interrupt5_Handler ; 5 Interrupt 5 DCD Interrupt6_Handler ; 6 Interrupt 6 DCD Interrupt7_Handler ; 7 Interrupt 7 DCD Interrupt8_Handler ; 8 Interrupt 8 DCD Interrupt9_Handler ; 9 Interrupt 9 DS32 (214) ; Interrupts 10 .. 224 are left out __Vectors_End __Vectors EQU __vector_table __Vectors_Size EQU __Vectors_End - __Vectors THUMB ; Reset Handler PUBWEAK Reset_Handler SECTION .text:CODE:REORDER:NOROOT(2) Reset_Handler LDR R0, =SystemInit BLX R0 LDR R0, =__iar_program_start BX R0 PUBWEAK NMI_Handler PUBWEAK HardFault_Handler PUBWEAK MemManage_Handler PUBWEAK BusFault_Handler PUBWEAK UsageFault_Handler PUBWEAK SVC_Handler PUBWEAK DebugMon_Handler PUBWEAK PendSV_Handler PUBWEAK SysTick_Handler PUBWEAK Interrupt0_Handler PUBWEAK Interrupt1_Handler PUBWEAK Interrupt2_Handler PUBWEAK Interrupt3_Handler PUBWEAK Interrupt4_Handler PUBWEAK Interrupt5_Handler PUBWEAK Interrupt6_Handler PUBWEAK Interrupt7_Handler PUBWEAK Interrupt8_Handler PUBWEAK Interrupt9_Handler SECTION .text:CODE:REORDER:NOROOT(1) NMI_Handler HardFault_Handler MemManage_Handler BusFault_Handler UsageFault_Handler SVC_Handler DebugMon_Handler PendSV_Handler SysTick_Handler Interrupt0_Handler Interrupt1_Handler Interrupt2_Handler Interrupt3_Handler Interrupt4_Handler Interrupt5_Handler Interrupt6_Handler Interrupt7_Handler Interrupt8_Handler Interrupt9_Handler Default_Handler B . END ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device/Source/IAR/startup_Device.s
gas
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
1,164
```shell #!/bin/bash # local variables DEPENDENCIES_FOLDER=dependenciesFiles ARTIFACTORY_URL=path_to_url ARTIFACTORY_DEPOT=mcu.depot/ci/depot PACKCHK_VERSION=1.3.93 if [ -z "$ARTIFACTORY_API_KEY" ]; then echo "Please set your Artifactory ARTIFACTORY_API_KEY" exit 1 fi if [ -z "$USER" ]; then echo "Please set your short ARM user e.g. sampel01" exit 1 fi function downloadFromArtifactory { filename=$(basename $1) echo "Fetching ${filename} ..." if [[ -f "${filename}" ]]; then sha256sum=$(curl -s -I -H "X-JFrog-Art-Api:$ARTIFACTORY_API_KEY" "${ARTIFACTORY_URL}/${1}" | grep "X-Checksum-Sha256" | cut -d" " -f2) if echo "${sha256sum} *${filename}" | sha256sum -c --status; then echo " ... already up to date" else rm ${filename} fi fi if [[ ! -f "${filename}" ]]; then curl -C - -H "X-JFrog-Art-Api:$ARTIFACTORY_API_KEY" -O "${ARTIFACTORY_URL}/${1}" chmod +x ${filename} fi } function downloadFromDepot { downloadFromArtifactory "${ARTIFACTORY_DEPOT}/${1}" } function gitClone { echo "Cloning/updating ${2} ..." if [[ ! -d "${2}" ]]; then git clone -b $3 $1 $2 else pushd $2 git clean -fdx git checkout -f $3 git pull origin $3 popd fi } mkdir -p $DEPENDENCIES_FOLDER pushd $DEPENDENCIES_FOLDER || exit downloadFromDepot "doxygen_1.8.6-2_amd64.deb" downloadFromDepot "ArmCompiler-5.06u7-linux.sh" downloadFromDepot "ArmCompiler-6.16-linux-x86_64.sh" downloadFromDepot "ArmCompiler-6.6.4-linux-x86_64.sh" downloadFromDepot "gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2" downloadFromDepot "fvp-11.12-linux-x86_64.tar.gz" downloadFromArtifactory "mcu.promoted/staging/devtools/tools/packchk/${PACKCHK_VERSION}/linux64/PackChk" gitClone "ssh://${USER}@eu-gerrit-1.euhpc.arm.com:29418/dsg/cmsis/buildtools" "buildtools" "master" popd || exit ```
/content/code_sandbox/docker/getDependencies.sh
shell
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
628
```gnuplot # Due to bandwidth limitation, we need to keep the base image into our # Artifactory Docker Registry. Because we have more than one registry, # we need to set during build time which Artifactory Docker Registry to use. ARG DOCKER_REGISTRY FROM ${DOCKER_REGISTRY}/ubuntu:focal # install packages from official Ubuntu repo ENV DEBIAN_FRONTEND=noninteractive # hadolint ignore=DL3008 RUN apt-get update && \ apt-get install --no-install-recommends -y \ bc \ build-essential \ curl \ dos2unix \ git \ lib32stdc++6 \ mscgen \ p7zip-full \ python3 \ python3-pip \ tar \ unzip \ wget \ libxml2-utils \ zip && \ apt-get autoremove -y && \ apt-get autoclean -y && \ rm -rf /var/lib/apt/lists/* # Create build ARGs for installer files & versions ARG GCC=gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 # Including dependency folder ARG DEPENDENCIESFOLDER=dependenciesFiles ARG TOOLS_PATH=/opt ARG INSTALLER_PATH=/tmp/dependenciesFiles RUN mkdir -p ${INSTALLER_PATH} COPY dependenciesFiles/${GCC} ${INSTALLER_PATH}/${GCC} COPY dependenciesFiles/buildtools ${TOOLS_PATH}/buildtools # install & setup gcc RUN mkdir -p ${TOOLS_PATH} WORKDIR ${TOOLS_PATH} RUN tar -xvf ${INSTALLER_PATH}/${GCC} ENV PATH=${PATH}:${TOOLS_PATH}/gcc-arm-none-eabi-10-2020-q4-major/bin ENV CI_GCC_TOOLCHAIN_ROOT=${TOOLS_PATH}/gcc-arm-none-eabi-10-2020-q4-major/bin WORKDIR / # install Python requirements COPY requirements.txt ${INSTALLER_PATH}/ # hadolint ignore=DL3013 RUN python3 -m pip install -U --no-cache-dir pip && \ python3 -m pip install -U --no-cache-dir -r ${INSTALLER_PATH}/requirements.txt # install buildtools RUN python3 -m pip install --no-cache-dir -r ${TOOLS_PATH}/buildtools/requirements.txt COPY rtebuild /root/.rtebuild ENV PATH=${PATH}:${TOOLS_PATH}/buildtools # remove dependency folder RUN rm -rf ${INSTALLER_PATH} CMD ["bash"] ```
/content/code_sandbox/docker/dockerfile.gnu
gnuplot
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
522
```objective-c /*************************************************************************//** * @file partition_<Device>.h * @brief CMSIS-Core(M) Device Initial Setup for Secure/Non-Secure Zones for * Device <Device> * @version V1.0.0 * @date 20. January 2021 *****************************************************************************/ /* * * * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #ifndef PARTITION_<Device>_H /* ToDo: Replace '<Device>' with your device name */ #define PARTITION_<Device>_H /* //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- */ /* // <e>Initialize Security Attribution Unit (SAU) CTRL register */ #define SAU_INIT_CTRL 1 /* // <q> Enable SAU // <i> Value for SAU->CTRL register bit ENABLE */ #define SAU_INIT_CTRL_ENABLE 1 /* // <o> When SAU is disabled // <0=> All Memory is Secure // <1=> All Memory is Non-Secure // <i> Value for SAU->CTRL register bit ALLNS // <i> When all Memory is Non-Secure (ALLNS is 1), IDAU can override memory map configuration. */ #define SAU_INIT_CTRL_ALLNS 0 /* // </e> */ /* // <h>Initialize Security Attribution Unit (SAU) Address Regions // <i>SAU configuration specifies regions to be one of: // <i> - Secure and Non-Secure Callable // <i> - Non-Secure // <i>Note: All memory regions not configured by SAU are Secure */ #define SAU_REGIONS_MAX 8 /* Max. number of SAU regions */ /* // <e>Initialize SAU Region 0 // <i> Setup SAU Region 0 memory attributes */ #define SAU_INIT_REGION0 1 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START0 0x00000000 /* start address of SAU region 0 */ /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END0 0x001FFFFF /* end address of SAU region 0 */ /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC0 1 /* // </e> */ /* // <e>Initialize SAU Region 1 // <i> Setup SAU Region 1 memory attributes */ #define SAU_INIT_REGION1 1 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START1 0x00200000 /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END1 0x003FFFFF /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC1 0 /* // </e> */ /* // <e>Initialize SAU Region 2 // <i> Setup SAU Region 2 memory attributes */ #define SAU_INIT_REGION2 1 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START2 0x20200000 /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END2 0x203FFFFF /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC2 0 /* // </e> */ /* // <e>Initialize SAU Region 3 // <i> Setup SAU Region 3 memory attributes */ #define SAU_INIT_REGION3 1 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START3 0x40000000 /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END3 0x40040000 /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC3 0 /* // </e> */ /* // <e>Initialize SAU Region 4 // <i> Setup SAU Region 4 memory attributes */ #define SAU_INIT_REGION4 0 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START4 0x00000000 /* start address of SAU region 4 */ /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END4 0x00000000 /* end address of SAU region 4 */ /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC4 0 /* // </e> */ /* // <e>Initialize SAU Region 5 // <i> Setup SAU Region 5 memory attributes */ #define SAU_INIT_REGION5 0 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START5 0x00000000 /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END5 0x00000000 /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC5 0 /* // </e> */ /* // <e>Initialize SAU Region 6 // <i> Setup SAU Region 6 memory attributes */ #define SAU_INIT_REGION6 0 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START6 0x00000000 /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END6 0x00000000 /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC6 0 /* // </e> */ /* // <e>Initialize SAU Region 7 // <i> Setup SAU Region 7 memory attributes */ #define SAU_INIT_REGION7 0 /* // <o>Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START7 0x00000000 /* // <o>End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END7 0x00000000 /* // <o>Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC7 0 /* // </e> */ /* // </h> */ /* // <e>Setup behaviour of Sleep and Exception Handling */ #define SCB_CSR_AIRCR_INIT 1 /* // <o> Deep Sleep can be enabled by // <0=>Secure and Non-Secure state // <1=>Secure state only // <i> Value for SCB->CSR register bit DEEPSLEEPS */ #define SCB_CSR_DEEPSLEEPS_VAL 1 /* // <o>System reset request accessible from // <0=> Secure and Non-Secure state // <1=> Secure state only // <i> Value for SCB->AIRCR register bit SYSRESETREQS */ #define SCB_AIRCR_SYSRESETREQS_VAL 1 /* // <o>Priority of Non-Secure exceptions is // <0=> Not altered // <1=> Lowered to 0x80-0xFF // <i> Value for SCB->AIRCR register bit PRIS */ #define SCB_AIRCR_PRIS_VAL 1 /* // <o>BusFault, HardFault, and NMI target // <0=> Secure state // <1=> Non-Secure state // <i> Value for SCB->AIRCR register bit BFHFNMINS */ #define SCB_AIRCR_BFHFNMINS_VAL 0 /* // </e> */ /* // <e>Setup behaviour of Floating Point and Vector Unit (FPU/MVE) */ #define TZ_FPU_NS_USAGE 1 /* // <o>Floating Point and Vector Unit usage // <0=> Secure state only // <3=> Secure and Non-Secure state // <i> Value for SCB->NSACR register bits CP10, CP11 */ #define SCB_NSACR_CP10_11_VAL 3 /* // <o>Treat floating-point registers as Secure // <0=> Disabled // <1=> Enabled // <i> Value for FPU->FPCCR register bit TS */ #define FPU_FPCCR_TS_VAL 0 /* // <o>Clear on return (CLRONRET) accessibility // <0=> Secure and Non-Secure state // <1=> Secure state only // <i> Value for FPU->FPCCR register bit CLRONRETS */ #define FPU_FPCCR_CLRONRETS_VAL 0 /* // <o>Clear floating-point caller saved registers on exception return // <0=> Disabled // <1=> Enabled // <i> Value for FPU->FPCCR register bit CLRONRET */ #define FPU_FPCCR_CLRONRET_VAL 1 /* // </e> */ /* // <h>Setup Interrupt Target */ /* // <e>Initialize ITNS 0 (Interrupts 0..31) */ #define NVIC_INIT_ITNS0 1 /* // Interrupts 0..31 // <o.0> Interrupt 0 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 1 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 2 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 3 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 4 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 5 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 6 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 7 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 8 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 9 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 10 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 11 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 12 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 13 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 14 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 15 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 16 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 17 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 18 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 19 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 20 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 21 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 22 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 23 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 24 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 25 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 26 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 27 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 28 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 29 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 30 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 31 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS0_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 1 (Interrupts 32..63) */ #define NVIC_INIT_ITNS1 1 /* // Interrupts 32..63 // <o.0> Interrupt 32 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 33 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 34 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 35 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 36 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 37 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 38 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 39 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 40 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 41 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 42 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 43 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 44 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 45 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 46 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 47 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 48 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 49 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 50 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 51 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 52 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 53 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 54 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 55 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 56 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 57 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 58 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 59 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 60 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 61 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 62 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 63 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS1_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 2 (Interrupts 64..95) */ #define NVIC_INIT_ITNS2 0 /* // Interrupts 64..95 // <o.0> Interrupt 64 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 65 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 66 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 67 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 68 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 69 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 70 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 71 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 72 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 73 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 74 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 75 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 76 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 77 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 78 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 79 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 80 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 81 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 82 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 83 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 84 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 85 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 86 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 87 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 88 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 89 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 90 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 91 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 92 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 93 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 94 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 95 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS2_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 3 (Interrupts 96..127) */ #define NVIC_INIT_ITNS3 0 /* // Interrupts 96..127 // <o.0> Interrupt 96 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 97 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 98 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 99 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 100 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 101 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 102 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 103 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 104 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 105 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 106 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 107 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 108 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 109 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 110 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 111 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 112 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 113 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 114 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 115 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 116 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 117 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 118 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 119 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 120 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 121 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 122 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 123 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 124 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 125 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 126 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 127 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS3_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 4 (Interrupts 128..159) */ #define NVIC_INIT_ITNS4 0 /* // Interrupts 128..159 // <o.0> Interrupt 128 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 129 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 130 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 131 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 132 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 133 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 134 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 135 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 136 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 137 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 138 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 139 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 140 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 141 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 142 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 143 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 144 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 145 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 146 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 147 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 148 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 149 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 150 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 151 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 152 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 153 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 154 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 155 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 156 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 157 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 158 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 159 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS4_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 5 (Interrupts 160..191) */ #define NVIC_INIT_ITNS5 0 /* // Interrupts 160..191 // <o.0> Interrupt 160 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 161 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 162 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 163 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 164 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 165 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 166 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 167 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 168 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 169 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 170 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 171 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 172 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 173 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 174 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 175 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 176 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 177 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 178 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 179 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 180 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 181 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 182 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 183 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 184 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 185 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 186 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 187 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 188 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 189 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 190 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 191 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS5_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 6 (Interrupts 192..223) */ #define NVIC_INIT_ITNS6 0 /* // Interrupts 192..223 // <o.0> Interrupt 192 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 193 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 194 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 195 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 196 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 197 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 198 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 199 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 200 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 201 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 202 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 203 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 204 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 205 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 206 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 207 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 208 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 209 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 210 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 211 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 212 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 213 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 214 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 215 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 216 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 217 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 218 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 219 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 220 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 221 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 222 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 223 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS6_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 7 (Interrupts 224..255) */ #define NVIC_INIT_ITNS7 0 /* // Interrupts 224..255 // <o.0> Interrupt 224 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 225 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 226 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 227 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 228 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 229 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 230 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 231 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 232 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 233 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 234 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 235 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 236 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 237 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 238 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 239 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 240 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 241 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 242 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 243 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 244 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 245 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 246 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 247 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 248 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 249 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 250 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 251 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 252 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 253 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 254 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 255 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS7_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 8 (Interrupts 256..287) */ #define NVIC_INIT_ITNS8 0 /* // Interrupts 256..287 // <o.0> Interrupt 256 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 257 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 258 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 259 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 260 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 261 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 262 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 263 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 264 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 265 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 266 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 267 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 268 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 269 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 270 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 271 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 272 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 273 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 274 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 275 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 276 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 277 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 278 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 279 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 280 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 281 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 282 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 283 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 284 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 285 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 286 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 287 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS8_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 9 (Interrupts 288..319) */ #define NVIC_INIT_ITNS9 0 /* // Interrupts 288..319 // <o.0> Interrupt 288 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 289 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 290 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 291 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 292 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 293 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 294 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 295 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 296 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 297 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 298 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 299 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 300 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 301 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 302 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 303 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 304 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 305 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 306 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 307 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 308 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 309 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 310 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 311 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 312 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 313 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 314 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 315 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 316 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 317 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 318 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 319 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS9_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 10 (Interrupts 320..351) */ #define NVIC_INIT_ITNS10 0 /* // Interrupts 320..351 // <o.0> Interrupt 320 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 321 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 322 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 323 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 324 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 325 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 326 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 327 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 328 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 329 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 330 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 331 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 332 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 333 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 334 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 335 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 336 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 337 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 338 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 339 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 340 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 341 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 342 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 343 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 344 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 345 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 346 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 347 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 348 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 349 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 350 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 351 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS10_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 11 (Interrupts 352..383) */ #define NVIC_INIT_ITNS11 0 /* // Interrupts 352..383 // <o.0> Interrupt 352 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 353 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 354 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 355 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 356 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 357 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 358 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 359 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 360 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 361 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 362 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 363 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 364 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 365 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 366 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 367 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 368 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 369 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 370 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 371 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 372 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 373 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 374 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 375 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 376 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 377 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 378 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 379 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 380 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 381 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 382 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 383 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS11_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 12 (Interrupts 384..415) */ #define NVIC_INIT_ITNS12 0 /* // Interrupts 384..415 // <o.0> Interrupt 384 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 385 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 386 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 387 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 388 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 389 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 390 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 391 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 392 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 393 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 394 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 395 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 396 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 397 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 398 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 399 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 400 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 401 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 402 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 403 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 404 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 405 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 406 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 407 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 408 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 409 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 410 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 411 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 412 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 413 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 414 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 415 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS12_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 13 (Interrupts 416..447) */ #define NVIC_INIT_ITNS13 0 /* // Interrupts 416..447 // <o.0> Interrupt 416 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 417 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 418 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 419 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 420 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 421 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 422 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 423 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 424 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 425 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 426 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 427 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 428 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 429 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 430 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 431 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 432 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 433 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 434 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 435 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 436 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 437 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 438 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 439 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 440 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 441 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 442 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 443 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 444 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 445 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 446 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 447 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS13_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 14 (Interrupts 448..479) */ #define NVIC_INIT_ITNS14 0 /* // Interrupts 448..479 // <o.0> Interrupt 448 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 449 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 450 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 451 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 452 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 453 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 454 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 455 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 456 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 457 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 458 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 459 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 460 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 461 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 462 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 463 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 464 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 465 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 466 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 467 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 468 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 469 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 470 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 471 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 472 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 473 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 474 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 475 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 476 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 477 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 478 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 479 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS14_VAL 0x00000000 /* // </e> */ /* // <e>Initialize ITNS 15 (Interrupts 480..511) */ #define NVIC_INIT_ITNS15 0 /* // Interrupts 480..511 // <o.0> Interrupt 480 <0=> Secure state <1=> Non-Secure state // <o.1> Interrupt 481 <0=> Secure state <1=> Non-Secure state // <o.2> Interrupt 482 <0=> Secure state <1=> Non-Secure state // <o.3> Interrupt 483 <0=> Secure state <1=> Non-Secure state // <o.4> Interrupt 484 <0=> Secure state <1=> Non-Secure state // <o.5> Interrupt 485 <0=> Secure state <1=> Non-Secure state // <o.6> Interrupt 486 <0=> Secure state <1=> Non-Secure state // <o.7> Interrupt 487 <0=> Secure state <1=> Non-Secure state // <o.8> Interrupt 488 <0=> Secure state <1=> Non-Secure state // <o.9> Interrupt 489 <0=> Secure state <1=> Non-Secure state // <o.10> Interrupt 490 <0=> Secure state <1=> Non-Secure state // <o.11> Interrupt 491 <0=> Secure state <1=> Non-Secure state // <o.12> Interrupt 492 <0=> Secure state <1=> Non-Secure state // <o.13> Interrupt 493 <0=> Secure state <1=> Non-Secure state // <o.14> Interrupt 494 <0=> Secure state <1=> Non-Secure state // <o.15> Interrupt 495 <0=> Secure state <1=> Non-Secure state // <o.16> Interrupt 496 <0=> Secure state <1=> Non-Secure state // <o.17> Interrupt 497 <0=> Secure state <1=> Non-Secure state // <o.18> Interrupt 498 <0=> Secure state <1=> Non-Secure state // <o.19> Interrupt 499 <0=> Secure state <1=> Non-Secure state // <o.20> Interrupt 500 <0=> Secure state <1=> Non-Secure state // <o.21> Interrupt 501 <0=> Secure state <1=> Non-Secure state // <o.22> Interrupt 502 <0=> Secure state <1=> Non-Secure state // <o.23> Interrupt 503 <0=> Secure state <1=> Non-Secure state // <o.24> Interrupt 504 <0=> Secure state <1=> Non-Secure state // <o.25> Interrupt 505 <0=> Secure state <1=> Non-Secure state // <o.26> Interrupt 506 <0=> Secure state <1=> Non-Secure state // <o.27> Interrupt 507 <0=> Secure state <1=> Non-Secure state // <o.28> Interrupt 508 <0=> Secure state <1=> Non-Secure state // <o.29> Interrupt 509 <0=> Secure state <1=> Non-Secure state // <o.30> Interrupt 510 <0=> Secure state <1=> Non-Secure state // <o.31> Interrupt 511 <0=> Secure state <1=> Non-Secure state */ #define NVIC_INIT_ITNS15_VAL 0x00000000 /* // </e> */ /* // </h> */ /* max 128 SAU regions. SAU regions are defined in partition.h */ #define SAU_INIT_REGION(n) \ SAU->RNR = (n & SAU_RNR_REGION_Msk); \ SAU->RBAR = (SAU_INIT_START##n & SAU_RBAR_BADDR_Msk); \ SAU->RLAR = (SAU_INIT_END##n & SAU_RLAR_LADDR_Msk) | \ ((SAU_INIT_NSC##n << SAU_RLAR_NSC_Pos) & SAU_RLAR_NSC_Msk) | 1U /** \brief Setup a SAU Region \details Writes the region information contained in SAU_Region to the registers SAU_RNR, SAU_RBAR, and SAU_RLAR */ __STATIC_INLINE void TZ_SAU_Setup (void) { #if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) #if defined (SAU_INIT_REGION0) && (SAU_INIT_REGION0 == 1U) SAU_INIT_REGION(0); #endif #if defined (SAU_INIT_REGION1) && (SAU_INIT_REGION1 == 1U) SAU_INIT_REGION(1); #endif #if defined (SAU_INIT_REGION2) && (SAU_INIT_REGION2 == 1U) SAU_INIT_REGION(2); #endif #if defined (SAU_INIT_REGION3) && (SAU_INIT_REGION3 == 1U) SAU_INIT_REGION(3); #endif #if defined (SAU_INIT_REGION4) && (SAU_INIT_REGION4 == 1U) SAU_INIT_REGION(4); #endif #if defined (SAU_INIT_REGION5) && (SAU_INIT_REGION5 == 1U) SAU_INIT_REGION(5); #endif #if defined (SAU_INIT_REGION6) && (SAU_INIT_REGION6 == 1U) SAU_INIT_REGION(6); #endif #if defined (SAU_INIT_REGION7) && (SAU_INIT_REGION7 == 1U) SAU_INIT_REGION(7); #endif /* repeat this for all possible SAU regions */ #endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ #if defined (SAU_INIT_CTRL) && (SAU_INIT_CTRL == 1U) SAU->CTRL = ((SAU_INIT_CTRL_ENABLE << SAU_CTRL_ENABLE_Pos) & SAU_CTRL_ENABLE_Msk) | ((SAU_INIT_CTRL_ALLNS << SAU_CTRL_ALLNS_Pos) & SAU_CTRL_ALLNS_Msk) ; #endif #if defined (SCB_CSR_AIRCR_INIT) && (SCB_CSR_AIRCR_INIT == 1U) SCB->SCR = (SCB->SCR & ~(SCB_SCR_SLEEPDEEPS_Msk )) | ((SCB_CSR_DEEPSLEEPS_VAL << SCB_SCR_SLEEPDEEPS_Pos) & SCB_SCR_SLEEPDEEPS_Msk); SCB->AIRCR = (SCB->AIRCR & ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_SYSRESETREQS_Msk | SCB_AIRCR_BFHFNMINS_Msk | SCB_AIRCR_PRIS_Msk )) | ((0x05FAU << SCB_AIRCR_VECTKEY_Pos) & SCB_AIRCR_VECTKEY_Msk) | ((SCB_AIRCR_SYSRESETREQS_VAL << SCB_AIRCR_SYSRESETREQS_Pos) & SCB_AIRCR_SYSRESETREQS_Msk) | ((SCB_AIRCR_PRIS_VAL << SCB_AIRCR_PRIS_Pos) & SCB_AIRCR_PRIS_Msk) | ((SCB_AIRCR_BFHFNMINS_VAL << SCB_AIRCR_BFHFNMINS_Pos) & SCB_AIRCR_BFHFNMINS_Msk); #endif /* defined (SCB_CSR_AIRCR_INIT) && (SCB_CSR_AIRCR_INIT == 1U) */ #if (((defined (__FPU_USED) && (__FPU_USED == 1U)) || \ (defined (__ARM_FEATURE_MVE) && (__ARM_FEATURE_MVE > 0))) && \ (defined (TZ_FPU_NS_USAGE) && (TZ_FPU_NS_USAGE == 1U))) SCB->NSACR = (SCB->NSACR & ~(SCB_NSACR_CP10_Msk | SCB_NSACR_CP11_Msk)) | ((SCB_NSACR_CP10_11_VAL << SCB_NSACR_CP10_Pos) & (SCB_NSACR_CP10_Msk | SCB_NSACR_CP11_Msk)); FPU->FPCCR = (FPU->FPCCR & ~(FPU_FPCCR_TS_Msk | FPU_FPCCR_CLRONRETS_Msk | FPU_FPCCR_CLRONRET_Msk)) | ((FPU_FPCCR_TS_VAL << FPU_FPCCR_TS_Pos ) & FPU_FPCCR_TS_Msk ) | ((FPU_FPCCR_CLRONRETS_VAL << FPU_FPCCR_CLRONRETS_Pos) & FPU_FPCCR_CLRONRETS_Msk) | ((FPU_FPCCR_CLRONRET_VAL << FPU_FPCCR_CLRONRET_Pos ) & FPU_FPCCR_CLRONRET_Msk ); #endif #if defined (NVIC_INIT_ITNS0) && (NVIC_INIT_ITNS0 == 1U) NVIC->ITNS[0] = NVIC_INIT_ITNS0_VAL; #endif #if defined (NVIC_INIT_ITNS1) && (NVIC_INIT_ITNS1 == 1U) NVIC->ITNS[1] = NVIC_INIT_ITNS1_VAL; #endif #if defined (NVIC_INIT_ITNS2) && (NVIC_INIT_ITNS2 == 1U) NVIC->ITNS[2] = NVIC_INIT_ITNS2_VAL; #endif #if defined (NVIC_INIT_ITNS3) && (NVIC_INIT_ITNS3 == 1U) NVIC->ITNS[3] = NVIC_INIT_ITNS3_VAL; #endif #if defined (NVIC_INIT_ITNS4) && (NVIC_INIT_ITNS4 == 1U) NVIC->ITNS[4] = NVIC_INIT_ITNS4_VAL; #endif #if defined (NVIC_INIT_ITNS5) && (NVIC_INIT_ITNS5 == 1U) NVIC->ITNS[5] = NVIC_INIT_ITNS5_VAL; #endif #if defined (NVIC_INIT_ITNS6) && (NVIC_INIT_ITNS6 == 1U) NVIC->ITNS[6] = NVIC_INIT_ITNS6_VAL; #endif #if defined (NVIC_INIT_ITNS7) && (NVIC_INIT_ITNS7 == 1U) NVIC->ITNS[7] = NVIC_INIT_ITNS7_VAL; #endif #if defined (NVIC_INIT_ITNS8) && (NVIC_INIT_ITNS8 == 1U) NVIC->ITNS[8] = NVIC_INIT_ITNS8_VAL; #endif #if defined (NVIC_INIT_ITNS9) && (NVIC_INIT_ITNS9 == 1U) NVIC->ITNS[9] = NVIC_INIT_ITNS9_VAL; #endif #if defined (NVIC_INIT_ITNS10) && (NVIC_INIT_ITNS10 == 1U) NVIC->ITNS[10] = NVIC_INIT_ITNS10_VAL; #endif #if defined (NVIC_INIT_ITNS11) && (NVIC_INIT_ITNS11 == 1U) NVIC->ITNS[11] = NVIC_INIT_ITNS11_VAL; #endif #if defined (NVIC_INIT_ITNS12) && (NVIC_INIT_ITNS12 == 1U) NVIC->ITNS[12] = NVIC_INIT_ITNS12_VAL; #endif #if defined (NVIC_INIT_ITNS13) && (NVIC_INIT_ITNS13 == 1U) NVIC->ITNS[13] = NVIC_INIT_ITNS13_VAL; #endif #if defined (NVIC_INIT_ITNS14) && (NVIC_INIT_ITNS14 == 1U) NVIC->ITNS[14] = NVIC_INIT_ITNS14_VAL; #endif #if defined (NVIC_INIT_ITNS15) && (NVIC_INIT_ITNS15 == 1U) NVIC->ITNS[15] = NVIC_INIT_ITNS15_VAL; #endif /* repeat this for all possible ITNS elements */ } #endif /* PARTITION_<Device>_H */ ```
/content/code_sandbox/Device/_Template_Vendor/Vendor/Device/Include/Template/partition_Device.h
objective-c
2016-02-18T08:04:18
2024-08-16T08:24:23
CMSIS_5
ARM-software/CMSIS_5
1,295
17,235
```shell #!/bin/bash python configure.py --generator Ninja python build.py python run-tests.py --target LinkCoreTest --valgrind python run-tests.py --target LinkDiscoveryTest --valgrind ```
/content/code_sandbox/ci/run_valgrind_tests.sh
shell
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
44
```yaml clone_depth: 50 branches: only: - master environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: macos-monterey CONFIGURATION: Release XCODE_VERSION: 13.4.1 - APPVEYOR_BUILD_WORKER_IMAGE: macos-monterey CONFIGURATION: Debug XCODE_VERSION: 14.2.0 - APPVEYOR_BUILD_WORKER_IMAGE: macos-ventura CONFIGURATION: Release XCODE_VERSION: 14.3.0 - APPVEYOR_BUILD_WORKER_IMAGE: macos-sonoma CONFIGURATION: Debug XCODE_VERSION: 15.2.0 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004 AUDIO_DRIVER: Alsa CONFIGURATION: Release GENERATOR: Ninja CXX: clang++-12 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004 AUDIO_DRIVER: Jack CONFIGURATION: Debug GENERATOR: Ninja CXX: clang++-11 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004 AUDIO_DRIVER: Alsa CONFIGURATION: Release GENERATOR: Ninja CXX: clang++-10 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004 AUDIO_DRIVER: Jack CONFIGURATION: Debug GENERATOR: Ninja CXX: clang++-9 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2204 AUDIO_DRIVER: Alsa CONFIGURATION: Release GENERATOR: Ninja CXX: g++-11 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2204 AUDIO_DRIVER: Jack CONFIGURATION: Debug GENERATOR: Ninja CXX: g++-10 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004 AUDIO_DRIVER: Alsa CONFIGURATION: Release GENERATOR: Ninja CXX: g++-9 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004 AUDIO_DRIVER: Jack CONFIGURATION: Debug GENERATOR: Ninja CXX: g++-8 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004 AUDIO_DRIVER: Alsa CONFIGURATION: Release GENERATOR: Ninja CXX: g++-7 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 AUDIO_DRIVER: Wasapi THREAD_DESCRIPTION: OFF CONFIGURATION: Debug GENERATOR: Visual Studio 14 2015 Win64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 AUDIO_DRIVER: Wasapi THREAD_DESCRIPTION: OFF CONFIGURATION: Release GENERATOR: Visual Studio 14 2015 Win64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 AUDIO_DRIVER: Asio THREAD_DESCRIPTION: OFF CONFIGURATION: Release GENERATOR: Visual Studio 15 2017 Win64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 AUDIO_DRIVER: Asio THREAD_DESCRIPTION: ON CONFIGURATION: Release GENERATOR: Visual Studio 16 2019 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 AUDIO_DRIVER: Wasapi THREAD_DESCRIPTION: ON CONFIGURATION: Debug GENERATOR: Visual Studio 17 2022 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004 ESP_IDF: true IDF_RELEASE: v5.1.1 - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu2004 FORMATTING: true install: - git submodule update --init --recursive for: - matrix: only: - APPVEYOR_BUILD_WORKER_IMAGE: macos-monterey - APPVEYOR_BUILD_WORKER_IMAGE: macos-ventura - APPVEYOR_BUILD_WORKER_IMAGE: macos-sonoma build_script: - sudo xcode-select -s /Applications/Xcode-$XCODE_VERSION.app - python3 ci/configure.py --generator Xcode - python3 ci/build.py --configuration $CONFIGURATION test_script: - python3 ci/run-tests.py --target LinkCoreTest - python3 ci/run-tests.py --target LinkDiscoveryTest - matrix: only: # Ubuntu2004 but not ESP_IDF or FORMATTING - GENERATOR: Ninja install: - git submodule update --init --recursive - sudo apt-get install -y libjack-dev portaudio19-dev valgrind build_script: - python3 ci/configure.py --audio-driver $AUDIO_DRIVER --generator "$GENERATOR" --configuration $CONFIGURATION - python3 ci/build.py test_script: - python3 ci/run-tests.py --target LinkCoreTest --valgrind - python3 ci/run-tests.py --target LinkDiscoveryTest --valgrind - matrix: only: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 build_script: - py -3 -m pip install setuptools - py -3 ci/configure.py --audio-driver %AUDIO_DRIVER% --thread-description %THREAD_DESCRIPTION% --generator "%GENERATOR%" --flags="-DCMAKE_SYSTEM_VERSION=10.0.18362.0" - py -3 ci/build.py --configuration %CONFIGURATION% test_script: - py -3 ci/run-tests.py --target LinkCoreTest - py -3 ci/run-tests.py --target LinkDiscoveryTest - matrix: only: - ESP_IDF: true build_script: - docker run --rm -v $APPVEYOR_BUILD_FOLDER:/link -w /link/examples/esp32 -e LC_ALL=C.UTF-8 espressif/idf:$IDF_RELEASE idf.py build - matrix: only: - FORMATTING: true build_script: - docker run -v $APPVEYOR_BUILD_FOLDER:/link dalg24/clang-format:18.04.0 python /link/ci/check-formatting.py -c /usr/bin/clang-format-6.0 ```
/content/code_sandbox/.appveyor.yml
yaml
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,454
```cmake if(CMAKE_VERSION VERSION_LESS 3.0) message(FATAL_ERROR "CMake 3.0 or greater is required") endif() add_library(Ableton::Link IMPORTED INTERFACE) set_property(TARGET Ableton::Link APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}/include ) # Force C++11 support for consuming targets set_property(TARGET Ableton::Link APPEND PROPERTY INTERFACE_COMPILE_FEATURES cxx_generalized_initializers ) if(UNIX) set_property(TARGET Ableton::Link APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS LINK_PLATFORM_UNIX=1 ) endif() if(APPLE) set_property(TARGET Ableton::Link APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS LINK_PLATFORM_MACOSX=1 ) elseif(WIN32) set_property(TARGET Ableton::Link APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS LINK_PLATFORM_WINDOWS=1 ) elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|kFreeBSD|GNU") set_property(TARGET Ableton::Link APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS LINK_PLATFORM_LINUX=1 ) set_property(TARGET Ableton::Link APPEND PROPERTY INTERFACE_LINK_LIBRARIES atomic pthread ) endif() include(${CMAKE_CURRENT_LIST_DIR}/cmake_include/AsioStandaloneConfig.cmake) set_property(TARGET Ableton::Link APPEND PROPERTY INTERFACE_LINK_LIBRARIES AsioStandalone::AsioStandalone ) set_property(TARGET Ableton::Link APPEND PROPERTY INTERFACE_SOURCES ${CMAKE_CURRENT_LIST_DIR}/include/ableton/Link.hpp ) ```
/content/code_sandbox/AbletonLinkConfig.cmake
cmake
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
367
```python #!/usr/bin/env python import argparse import logging import os import shutil import sys from distutils.spawn import find_executable from subprocess import call def parse_args(): arg_parser = argparse.ArgumentParser() arg_parser.add_argument( '-a', '--audio-driver', help='Audio driver to build (Windows only, default: %(default)s)') arg_parser.add_argument( '--cmake', default=find_executable("cmake"), help='Path to CMake executable (default: %(default)s)') arg_parser.add_argument( '-c', '--configuration', help='Build configuration to use (not supported by IDE generators)') arg_parser.add_argument( '-g', '--generator', help='CMake generator to use (default: Determined by CMake)') arg_parser.add_argument( '-f', '--flags', help='Additional CMake flags') arg_parser.add_argument( '--thread-description', help='Set thread description. (Windows only)') return arg_parser.parse_args(sys.argv[1:]) def build_cmake_args(args): if args.cmake is None: logging.error('CMake not found, please use the --cmake option') return None cmake_args = [] cmake_args.append(args.cmake) if args.generator is not None: cmake_args.append('-G') cmake_args.append(args.generator) if args.configuration is not None: cmake_args.append('-DCMAKE_BUILD_TYPE=' + args.configuration) if args.flags is not None: cmake_args.append(args.flags) if sys.platform == 'win32': if args.audio_driver is None or args.audio_driver == 'Asio': cmake_args.append('-DLINK_BUILD_ASIO=ON') else: cmake_args.append('-DLINK_BUILD_ASIO=OFF') if args.thread_description == 'ON': cmake_args.append('-DLINK_WINDOWS_SETTHREADDESCRIPTION=ON') elif 'linux' in sys.platform: if args.audio_driver == 'Jack': cmake_args.append('-DLINK_BUILD_JACK=ON') # This must always be last cmake_args.append('..') return cmake_args def configure(args): scripts_dir = os.path.dirname(os.path.realpath(__file__)) root_dir = os.path.join(scripts_dir, os.pardir) build_dir = os.path.join(root_dir, 'build') if os.path.exists(build_dir): logging.info('Removing existing build directory') shutil.rmtree(build_dir) logging.debug('Creating build directory') os.mkdir(build_dir) os.chdir(build_dir) cmake_args = build_cmake_args(args) if cmake_args is None: return 1 logging.info('Running CMake') return call(cmake_args) if __name__ == '__main__': logging.basicConfig(format='%(message)s', level=logging.INFO, stream=sys.stdout) sys.exit(configure(parse_args())) ```
/content/code_sandbox/ci/configure.py
python
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
625
```python #!/usr/bin/env python import argparse import logging import os import sys from distutils.spawn import find_executable from subprocess import call def parse_args(): arg_parser = argparse.ArgumentParser() arg_parser.add_argument( '--cmake', default=find_executable("cmake"), help='Path to CMake executable (default: %(default)s)') arg_parser.add_argument( '-c', '--configuration', help='Build configuration to use (not supported by IDE generators)') arg_parser.add_argument( '-a', '--arguments', help='Arguments to pass to builder') return arg_parser.parse_args(sys.argv[1:]) def build_cmake_args(args, build_dir): if args.cmake is None: logging.error('CMake not found, please use the --cmake option') return None cmake_args = [] cmake_args.append(args.cmake) cmake_args.append('--build') cmake_args.append(build_dir) if args.configuration is not None: cmake_args.append('--config') cmake_args.append(args.configuration) if args.arguments is not None: cmake_args.append('--') for arg in args.arguments.split(): cmake_args.append(arg) return cmake_args def build(args): scripts_dir = os.path.dirname(os.path.realpath(__file__)) root_dir = os.path.join(scripts_dir, os.pardir) build_dir = os.path.join(root_dir, 'build') if not os.path.exists(build_dir): logging.error( 'Build directory not found, did you forget to run the configure.py script?') return 2 cmake_args = build_cmake_args(args, build_dir) if cmake_args is None: return 1 logging.info('Running CMake') return call(cmake_args) if __name__ == '__main__': logging.basicConfig(format='%(message)s', level=logging.INFO, stream=sys.stdout) sys.exit(build(parse_args())) ```
/content/code_sandbox/ci/build.py
python
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
417
```python #!/usr/bin/env python import argparse import logging import os import sys from distutils.spawn import find_executable from subprocess import call def parse_args(): arg_parser = argparse.ArgumentParser() arg_parser.add_argument( '-t', '--target', help='Target to test') arg_parser.add_argument( '--valgrind', default=False, help='Run with Valgrind', action='store_true') return arg_parser.parse_args(sys.argv[1:]) def get_system_exe_extension(): # Should return 'win32' even on 64-bit Windows if sys.platform == 'win32': return '.exe' else: return '' def find_exe(name, path): for root, dirs, files in os.walk(path): if name in files: return os.path.join(root, name) def build_test_exe_args(args, build_dir): if args.target is None: logging.error('Target not specified, please use the --target option') return None test_exe = find_exe(args.target + get_system_exe_extension(), build_dir) if not os.path.exists(test_exe): logging.error('Could not find test executable for target {}, ' 'did you forget to build?'.format(args.target)) else: logging.debug('Test executable is: {}'.format(test_exe)) test_exe_args = [test_exe] if args.valgrind is not False: valgrind_exe = find_executable('valgrind') if valgrind_exe is None: logging.error('Valgrind not found, cannot continue') return None test_exe_args = [ valgrind_exe, '--leak-check=full', '--show-reachable=yes', '--gen-suppressions=all', '--error-exitcode=1', '--track-origins=yes', '--suppressions=../ci/memcheck.supp', test_exe] return test_exe_args def run_tests(args): scripts_dir = os.path.dirname(os.path.realpath(__file__)) root_dir = os.path.join(scripts_dir, os.pardir) build_dir = os.path.join(root_dir, 'build') if not os.path.exists(build_dir): logging.error( 'Build directory not found, did you forget to run the configure.py script?') return 2 os.chdir(build_dir) env = os.environ.copy() env['GLIBCXX_FORCE_NEW'] = '1' test_exe_args = build_test_exe_args(args, build_dir) if test_exe_args is None: return 1 logging.info(test_exe_args) logging.info('Running Tests for {}'.format(args.target)) return call(test_exe_args, env=env) if __name__ == '__main__': logging.basicConfig(format='%(message)s', level=logging.INFO, stream=sys.stdout) sys.exit(run_tests(parse_args())) ```
/content/code_sandbox/ci/run-tests.py
python
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
613
```python #!/usr/bin/env python import argparse import logging import os import subprocess import sys def parse_args(): arg_parser = argparse.ArgumentParser() arg_parser.add_argument( '-c', '--clang-format', default='clang-format-6.0', help='Path to clang-format executable') arg_parser.add_argument( '-f', '--fix', action='store_true', help='Automatically fix all files with formatting errors') return arg_parser.parse_args(sys.argv[1:]) def parse_clang_xml(xml): for line in xml.splitlines(): if line.startswith(b'<replacement '): return False return True def fix_file(args, file_absolute_path): logging.info('Fixing formatting errors in file: {}'.format(file_absolute_path)) clang_format_args = [args.clang_format, '-style=file', '-i', file_absolute_path] try: subprocess.check_call(clang_format_args) except subprocess.CalledProcessError: logging.error('Error running clang-format on {},' ' please run clang-format -i by hand'.format(file_absolute_path)) def check_files_in_path(args, path): logging.info('Checking files in {}'.format(path)) errors_found = False for (path, dirs, files) in os.walk(path): for file in files: if file.endswith(('.c', '.cpp', '.h', '.hpp', '.ipp')): file_absolute_path = path + os.path.sep + file clang_format_args = [ args.clang_format, '-style=file', '-output-replacements-xml', file_absolute_path] try: clang_format_output = subprocess.check_output(clang_format_args) except subprocess.CalledProcessError: logging.error( 'Could not execute {}, try running this script with the' '--clang-format option'.format(args.clang_format)) sys.exit(2) if not parse_clang_xml(clang_format_output): if args.fix: fix_file(args, file_absolute_path) else: logging.warning( '{} has formatting errors'.format(file_absolute_path)) errors_found = True return errors_found def check_formatting(args): errors_found = False script_dir = os.path.dirname(os.path.realpath(__file__)) for path in ['../examples', '../include', '../src', '../extensions/abl_link']: subdir_abs_path = os.path.abspath(os.path.join(script_dir, path)) if check_files_in_path(args, subdir_abs_path): errors_found = True if errors_found: logging.warning( 'Formatting errors found, please fix with clang-format -style=file -i') else: logging.debug('No formatting errors found!') return errors_found if __name__ == '__main__': logging.basicConfig(format='%(message)s', level=logging.INFO, stream=sys.stdout) sys.exit(check_formatting(parse_args())) ```
/content/code_sandbox/ci/check-formatting.py
python
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
612
```cmake if(CMAKE_VERSION VERSION_LESS 3.0) message(FATAL_ERROR "CMake 3.0 or greater is required") endif() add_library(abl_link STATIC ${CMAKE_CURRENT_LIST_DIR}/src/abl_link.cpp ) target_include_directories(abl_link PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include ) set_property(TARGET abl_link PROPERTY C_STANDARD 11) target_link_libraries(abl_link Ableton::Link) ```
/content/code_sandbox/extensions/abl_link/abl_link.cmake
cmake
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
97
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <abl_link.h> #include <ableton/Link.hpp> extern "C" { abl_link abl_link_create(double bpm) { return abl_link{reinterpret_cast<void *>(new ableton::Link(bpm))}; } void abl_link_destroy(abl_link link) { delete reinterpret_cast<ableton::Link *>(link.impl); } bool abl_link_is_enabled(abl_link link) { return reinterpret_cast<ableton::Link *>(link.impl)->isEnabled(); } void abl_link_enable(abl_link link, bool enabled) { reinterpret_cast<ableton::Link *>(link.impl)->enable(enabled); } bool abl_link_is_start_stop_sync_enabled(abl_link link) { return reinterpret_cast<ableton::Link *>(link.impl)->isStartStopSyncEnabled(); } void abl_link_enable_start_stop_sync(abl_link link, bool enabled) { reinterpret_cast<ableton::Link *>(link.impl)->enableStartStopSync(enabled); } uint64_t abl_link_num_peers(abl_link link) { return reinterpret_cast<ableton::Link *>(link.impl)->numPeers(); } void abl_link_set_num_peers_callback( abl_link link, abl_link_num_peers_callback callback, void *context) { reinterpret_cast<ableton::Link *>(link.impl)->setNumPeersCallback( [callback, context]( std::size_t numPeers) { (*callback)(static_cast<uint64_t>(numPeers), context); }); } void abl_link_set_tempo_callback( abl_link link, abl_link_tempo_callback callback, void *context) { reinterpret_cast<ableton::Link *>(link.impl)->setTempoCallback( [callback, context](double tempo) { (*callback)(tempo, context); }); } void abl_link_set_start_stop_callback( abl_link link, abl_link_start_stop_callback callback, void *context) { reinterpret_cast<ableton::Link *>(link.impl)->setStartStopCallback( [callback, context](bool isPlaying) { (*callback)(isPlaying, context); }); } int64_t abl_link_clock_micros(abl_link link) { return reinterpret_cast<ableton::Link *>(link.impl)->clock().micros().count(); } abl_link_session_state abl_link_create_session_state(void) { return abl_link_session_state{reinterpret_cast<void *>( new ableton::Link::SessionState{ableton::link::ApiState{}, {}})}; } void abl_link_destroy_session_state(abl_link_session_state session_state) { delete reinterpret_cast<ableton::Link::SessionState *>(session_state.impl); } void abl_link_capture_app_session_state( abl_link link, abl_link_session_state session_state) { *reinterpret_cast<ableton::Link::SessionState *>(session_state.impl) = reinterpret_cast<ableton::Link *>(link.impl)->captureAppSessionState(); } void abl_link_commit_app_session_state( abl_link link, abl_link_session_state session_state) { reinterpret_cast<ableton::Link *>(link.impl)->commitAppSessionState( *reinterpret_cast<ableton::Link::SessionState *>(session_state.impl)); } void abl_link_capture_audio_session_state( abl_link link, abl_link_session_state session_state) { *reinterpret_cast<ableton::Link::SessionState *>(session_state.impl) = reinterpret_cast<ableton::Link *>(link.impl)->captureAudioSessionState(); } void abl_link_commit_audio_session_state( abl_link link, abl_link_session_state session_state) { reinterpret_cast<ableton::Link *>(link.impl)->commitAudioSessionState( *reinterpret_cast<ableton::Link::SessionState *>(session_state.impl)); } double abl_link_tempo(abl_link_session_state session_state) { return reinterpret_cast<ableton::Link::SessionState *>(session_state.impl)->tempo(); } void abl_link_set_tempo( abl_link_session_state session_state, double bpm, int64_t at_time) { reinterpret_cast<ableton::Link::SessionState *>(session_state.impl) ->setTempo(bpm, std::chrono::microseconds{at_time}); } double abl_link_beat_at_time( abl_link_session_state session_state, int64_t time, double quantum) { auto micros = std::chrono::microseconds{time}; return reinterpret_cast<ableton::Link::SessionState *>(session_state.impl) ->beatAtTime(micros, quantum); } double abl_link_phase_at_time( abl_link_session_state session_state, int64_t time, double quantum) { return reinterpret_cast<ableton::Link::SessionState *>(session_state.impl) ->phaseAtTime(std::chrono::microseconds{time}, quantum); } int64_t abl_link_time_at_beat( abl_link_session_state session_state, double beat, double quantum) { return reinterpret_cast<ableton::Link::SessionState *>(session_state.impl) ->timeAtBeat(beat, quantum) .count(); } void abl_link_request_beat_at_time( abl_link_session_state session_state, double beat, int64_t time, double quantum) { reinterpret_cast<ableton::Link::SessionState *>(session_state.impl) ->requestBeatAtTime(beat, std::chrono::microseconds{time}, quantum); } void abl_link_force_beat_at_time( abl_link_session_state session_state, double beat, uint64_t time, double quantum) { reinterpret_cast<ableton::Link::SessionState *>(session_state.impl) ->forceBeatAtTime(beat, std::chrono::microseconds{time}, quantum); } void abl_link_set_is_playing( abl_link_session_state session_state, bool is_playing, uint64_t time) { reinterpret_cast<ableton::Link::SessionState *>(session_state.impl) ->setIsPlaying(is_playing, std::chrono::microseconds(time)); } bool abl_link_is_playing(abl_link_session_state session_state) { return reinterpret_cast<ableton::Link::SessionState *>(session_state.impl) ->isPlaying(); } uint64_t abl_link_time_for_is_playing(abl_link_session_state session_state) { return static_cast<uint64_t>( reinterpret_cast<ableton::Link::SessionState *>(session_state.impl) ->timeForIsPlaying() .count()); } void abl_link_request_beat_at_start_playing_time( abl_link_session_state session_state, double beat, double quantum) { reinterpret_cast<ableton::Link::SessionState *>(session_state.impl) ->requestBeatAtStartPlayingTime(beat, quantum); } void abl_link_set_is_playing_and_request_beat_at_time( abl_link_session_state session_state, bool is_playing, uint64_t time, double beat, double quantum) { reinterpret_cast<ableton::Link::SessionState *>(session_state.impl) ->setIsPlayingAndRequestBeatAtTime( is_playing, std::chrono::microseconds{time}, beat, quantum); } } ```
/content/code_sandbox/extensions/abl_link/src/abl_link.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,680
```c * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <inttypes.h> #include <math.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #if defined(LINK_PLATFORM_UNIX) #include <sys/select.h> #include <termios.h> #include <unistd.h> #elif defined(LINK_PLATFORM_WINDOWS) #pragma warning(push, 0) #pragma warning(disable : 4255) // 'no function prototype given' in winuser.h #pragma warning(disable : 4668) // undefined preprocessor macro in winioctl.h #pragma warning(disable : 5105) // "/wd5105" # "macro expansion producing 'defined' has // undefined behavior" in winbase.h #include <windows.h> #pragma warning(pop) #pragma warning(disable : 4100) // unreferenced formal parameter in main #endif #include <abl_link.h> typedef struct state { abl_link link; abl_link_session_state session_state; bool running; double quantum; } state; struct state *new_state(void) { struct state *s = malloc(sizeof(state)); s->link = abl_link_create(120); s->session_state = abl_link_create_session_state(); s->running = true; s->quantum = 4; return s; } void delete_state(state *state) { abl_link_destroy_session_state(state->session_state); abl_link_destroy(state->link); free(state); } void disable_buffered_input(void) { #if defined(LINK_PLATFORM_UNIX) struct termios t; tcgetattr(STDIN_FILENO, &t); t.c_lflag &= ~ICANON; tcsetattr(STDIN_FILENO, TCSANOW, &t); #endif } void enable_buffered_input(void) { #if defined(LINK_PLATFORM_UNIX) struct termios t; tcgetattr(STDIN_FILENO, &t); t.c_lflag |= ICANON; tcsetattr(STDIN_FILENO, TCSANOW, &t); #endif } bool wait_for_input(void) { #if defined(LINK_PLATFORM_UNIX) fd_set selectset; struct timeval timeout = {0, 50000}; int ret; FD_ZERO(&selectset); FD_SET(0, &selectset); ret = select(1, &selectset, NULL, NULL, &timeout); if (ret > 0) { return true; } #elif (LINK_PLATFORM_WINDOWS) HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); if (WaitForSingleObject(handle, 50) == WAIT_OBJECT_0) { return true; } #else #error "Missing implementation" #endif return false; } void clear_line(void) { printf(" \r"); fflush(stdout); } void clear_input(void) { #if defined(LINK_PLATFORM_WINDOWS) { HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); INPUT_RECORD r[512]; DWORD read; ReadConsoleInput(handle, r, 512, &read); } #endif } void print_help(void) { printf("\n\n < L I N K H U T >\n\n"); printf("usage:\n"); printf(" enable / disable Link: a\n"); printf(" start / stop: space\n"); printf(" decrease / increase tempo: w / e\n"); printf(" decrease / increase quantum: r / t\n"); printf(" enable / disable start stop sync: s\n"); printf(" quit: q\n"); } void print_state_header(void) { printf( "\nenabled | num peers | quantum | start stop sync | tempo | beats | metro\n"); } void print_state(state *state) { abl_link_capture_app_session_state(state->link, state->session_state); const uint64_t time = abl_link_clock_micros(state->link); const char *enabled = abl_link_is_enabled(state->link) ? "yes" : "no"; const uint64_t num_peers = abl_link_num_peers(state->link); const char *start_stop = abl_link_is_start_stop_sync_enabled(state->link) ? "yes" : " no"; const char *playing = abl_link_is_playing(state->session_state) ? "[playing]" : "[stopped]"; const double tempo = abl_link_tempo(state->session_state); const double beats = abl_link_beat_at_time(state->session_state, time, state->quantum); const double phase = abl_link_phase_at_time(state->session_state, time, state->quantum); printf("%7s | ", enabled); printf("%9" PRIu64 " | ", num_peers); printf("%7.f | ", state->quantum); printf("%3s %11s | ", start_stop, playing); printf("%7.2f | ", tempo); printf("%7.2f | ", beats); for (int i = 0; i < ceil(state->quantum); ++i) { if (i < phase) { printf("X"); } else { printf("O"); } } } void input(state *state) { char in; #if defined(LINK_PLATFORM_UNIX) in = (char)fgetc(stdin); #elif defined(LINK_PLATFORM_WINDOWS) HANDLE stdinHandle = GetStdHandle(STD_INPUT_HANDLE); DWORD numCharsRead; INPUT_RECORD inputRecord; do { ReadConsoleInput(stdinHandle, &inputRecord, 1, &numCharsRead); } while ((inputRecord.EventType != KEY_EVENT) || inputRecord.Event.KeyEvent.bKeyDown); in = inputRecord.Event.KeyEvent.uChar.AsciiChar; #else #error "Missing implementation" #endif abl_link_capture_app_session_state(state->link, state->session_state); const double tempo = abl_link_tempo(state->session_state); const uint64_t timestamp = abl_link_clock_micros(state->link); const bool enabled = abl_link_is_enabled(state->link); switch (in) { case 'q': state->running = false; clear_line(); return; case 'a': abl_link_enable(state->link, !enabled); break; case 'w': abl_link_set_tempo(state->session_state, tempo - 1, timestamp); break; case 'e': abl_link_set_tempo(state->session_state, tempo + 1, timestamp); break; case 'r': state->quantum -= 1; break; case 't': state->quantum += 1; break; case 's': abl_link_enable_start_stop_sync( state->link, !abl_link_is_start_stop_sync_enabled(state->link)); break; case ' ': if (abl_link_is_playing(state->session_state)) { abl_link_set_is_playing( state->session_state, false, abl_link_clock_micros(state->link)); } else { abl_link_set_is_playing_and_request_beat_at_time(state->session_state, true, abl_link_clock_micros(state->link), 0, state->quantum); } break; } abl_link_commit_app_session_state(state->link, state->session_state); } int main(int nargs, char **args) { state *state = new_state(); print_help(); print_state_header(); disable_buffered_input(); clear_input(); while (state->running) { clear_line(); if (wait_for_input()) { input(state); } else { print_state(state); } } enable_buffered_input(); delete_state(state); return 0; } ```
/content/code_sandbox/extensions/abl_link/examples/link_hut/main.c
c
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,766
```cmake add_library(Catch::Catch IMPORTED INTERFACE) set_property(TARGET Catch::Catch APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}/../third_party/catch ) ```
/content/code_sandbox/cmake_include/CatchConfig.cmake
cmake
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
43
```cmake cmake_minimum_required(VERSION 3.5) set(build_flags_COMMON_LIST) set(build_flags_DEBUG_LIST) set(build_flags_RELEASE_LIST) # _ _ _ # | | | |_ __ (_)_ __ # | | | | '_ \| \ \/ / # | |_| | | | | |> < # \___/|_| |_|_/_/\_\ # if(UNIX) # Common flags for all Unix compilers set(build_flags_DEBUG_LIST "-DDEBUG=1" ) set(build_flags_RELEASE_LIST "-DNDEBUG=1" ) # Clang-specific flags if(${CMAKE_CXX_COMPILER_ID} MATCHES Clang) set(build_flags_COMMON_LIST ${build_flags_COMMON_LIST} "-Weverything" "-Werror" "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-deprecated" "-Wno-disabled-macro-expansion" "-Wno-exit-time-destructors" "-Wno-padded" "-Wno-poison-system-directories" "-Wno-reserved-id-macro" "-Wno-unknown-warning-option" "-Wno-unused-member-function" ) # GCC-specific flags # Unfortunately, we can't use -Werror on GCC, since there is no way to suppress the # warnings generated by -fpermissive. elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) set(build_flags_COMMON_LIST ${build_flags_COMMON_LIST} "-Werror" "-Wno-multichar" ) endif() # ASan support if(LINK_ENABLE_ASAN) set(build_flags_COMMON_LIST ${build_flags_COMMON_LIST} "-fsanitize=address" "-fno-omit-frame-pointer" ) endif() # __ ___ _ # \ \ / (_)_ __ __| | _____ _____ # \ \ /\ / /| | '_ \ / _` |/ _ \ \ /\ / / __| # \ V V / | | | | | (_| | (_) \ V V /\__ \ # \_/\_/ |_|_| |_|\__,_|\___/ \_/\_/ |___/ # elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) add_definitions("/D_SCL_SECURE_NO_WARNINGS") if(LINK_BUILD_VLD) add_definitions("/DLINK_BUILD_VLD=1") else() add_definitions("/DLINK_BUILD_VLD=0") endif() if(LINK_WINDOWS_SETTHREADDESCRIPTION) add_definitions("/DLINK_WINDOWS_SETTHREADDESCRIPTION") endif() set(build_flags_DEBUG_LIST "/DDEBUG=1" ) set(build_flags_RELEASE_LIST "/DNDEBUG=1" ) set(build_flags_COMMON_LIST ${build_flags_COMMON_LIST} "/MP" "/Wall" "/WX" "/EHsc" ############################# # Ignored compiler warnings # ############################# "/wd4061" # Enumerator 'identifier' in switch of enum 'enumeration' is not explicitly handled by a case label "/wd4265" # 'Class' : class has virtual functions, but destructor is not virtual "/wd4350" # Behavior change: 'member1' called instead of 'member2' "/wd4355" # 'This' : used in base member initializer list "/wd4365" # 'Action': conversion from 'type_1' to 'type_2', signed/unsigned mismatch "/wd4371" # Layout of class may have changed from a previous version of the compiler due to better packing of member 'member' "/wd4503" # 'Identifier': decorated name length exceeded, name was truncated "/wd4510" # 'Class': default constructor could not be generated "/wd4512" # 'Class': assignment operator could not be generated "/wd4514" # 'Function' : unreferenced inline function has been removed "/wd4571" # Informational: catch(...) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught "/wd4610" # 'Class': can never be instantiated - user defined constructor required "/wd4625" # 'Derived class' : copy constructor was implicitly defined as deleted because a base class copy constructor is inaccessible or deleted "/wd4626" # 'Derived class' : assignment operator was implicitly defined as deleted because a base class assignment operator is inaccessible or deleted "/wd4628" # digraphs not supported with -Ze. Character sequence 'digraph' not interpreted as alternate token for 'char' "/wd4640" # 'Instance': construction of local static object is not thread-safe "/wd4710" # 'Function': function not inlined "/wd4711" # Function 'function' selected for inline expansion "/wd4723" # potential divide by 0 "/wd4738" # Storing 32-bit float result in memory, possible loss of performance "/wd4820" # 'Bytes': bytes padding added after construct 'member_name' "/wd4996" # Your code uses a function, class member, variable, or typedef that's marked deprecated "/wd5045" # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified "/wd5204" # 'class' : class has virtual functions, but destructor is not virtual ) if(MSVC_VERSION VERSION_GREATER 1800) set(build_flags_COMMON_LIST ${build_flags_COMMON_LIST} "/wd4464" # Relative include path contains '..' "/wd4548" # Expression before comma has no effect; expected expression with side-effect "/wd4623" # 'Derived class': default constructor could not be generated because a base class default constructor is inaccessible "/wd4868" # Compiler may not enforce left-to-right evaluation order in braced initializer list "/wd5026" # Move constructor was implicitly defined as deleted "/wd5027" # Move assignment operator was implicitly defined as deleted "/wd5262" # implicit fall-through "/wd5264" # 'variable-name': 'const' variable is not used ) endif() if(MSVC_VERSION VERSION_GREATER 1900) set(build_flags_COMMON_LIST ${build_flags_COMMON_LIST} "/wd4987" # nonstandard extension used: 'throw (...)' "/wd4774" # 'printf_s' : format string expected in argument 1 is not a string literal "/wd5039" # "pointer or reference to potentially throwing function passed to extern C function under -EHc. Undefined behavior may occur if this function throws an exception." ) endif() if(NOT LINK_BUILD_ASIO) set(build_flags_COMMON_LIST ${build_flags_COMMON_LIST} "/wd4917" # 'Symbol': a GUID can only be associated with a class, interface or namespace # This compiler warning is generated by Microsoft's own ocidl.h, which is # used when building the WASAPI driver. ) endif() endif() # ____ _ __ _ # / ___| ___| |_ / _| | __ _ __ _ ___ # \___ \ / _ \ __| | |_| |/ _` |/ _` / __| # ___) | __/ |_ | _| | (_| | (_| \__ \ # |____/ \___|\__| |_| |_|\__,_|\__, |___/ # |___/ # Translate lists to strings string(REPLACE ";" " " build_flags_COMMON "${build_flags_COMMON_LIST}") string(REPLACE ";" " " build_flags_DEBUG "${build_flags_DEBUG_LIST}") string(REPLACE ";" " " build_flags_RELEASE "${build_flags_RELEASE_LIST}") # Set flags for different build types set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${build_flags_COMMON}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${build_flags_DEBUG}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${build_flags_RELEASE}") ```
/content/code_sandbox/cmake_include/ConfigureCompileFlags.cmake
cmake
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,777
```cmake add_library(AsioStandalone::AsioStandalone IMPORTED INTERFACE) set_property(TARGET AsioStandalone::AsioStandalone APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}/../modules/asio-standalone/asio/include ) ```
/content/code_sandbox/cmake_include/AsioStandaloneConfig.cmake
cmake
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
60
```objective-c * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <stdbool.h> #include <stdint.h> #ifdef __cplusplus extern "C" { #endif // __cplusplus /*! * @discussion Each abl_link instance has its own session state which * represents a beat timeline and a transport start/stop state. The * timeline starts running from beat 0 at the initial tempo when * constructed. The timeline always advances at a speed defined by * its current tempo, even if transport is stopped. Synchronizing to the * transport start/stop state of Link is optional for every peer. * The transport start/stop state is only shared with other peers when * start/stop synchronization is enabled. * * An abl_link instance is initially disabled after construction, which * means that it will not communicate on the network. Once enabled, * an abl_link instance initiates network communication in an effort to * discover other peers. When peers are discovered, they immediately * become part of a shared Link session. * * Each function documents its thread-safety and * realtime-safety properties. When a function is marked thread-safe, * it means it is safe to call from multiple threads * concurrently. When a function is marked realtime-safe, it means that * it does not block and is appropriate for use in the thread that * performs audio IO. * * One session state capture/commit function pair for use * in the audio thread and one for all other application contexts is provided. * In general, modifying the session state should be done in the audio * thread for the most accurate timing results. The ability to modify * the session state from application threads should only be used in * cases where an application's audio thread is not actively running * or if it doesn't generate audio at all. Modifying the Link session * state from both the audio thread and an application thread * concurrently is not advised and will potentially lead to unexpected * behavior. */ /*! @brief The representation of an abl_link instance*/ typedef struct abl_link { void *impl; } abl_link; /*! @brief Construct a new abl_link instance with an initial tempo. * Thread-safe: yes * Realtime-safe: no */ abl_link abl_link_create(double bpm); /*! @brief Delete an abl_link instance. * Thread-safe: yes * Realtime-safe: no */ void abl_link_destroy(abl_link link); /*! @brief Is Link currently enabled? * Thread-safe: yes * Realtime-safe: yes */ bool abl_link_is_enabled(abl_link link); /*! @brief Enable/disable Link. * Thread-safe: yes * Realtime-safe: no */ void abl_link_enable(abl_link link, bool enable); /*! @brief: Is start/stop synchronization enabled? * Thread-safe: yes * Realtime-safe: no */ bool abl_link_is_start_stop_sync_enabled(abl_link link); /*! @brief: Enable start/stop synchronization. * Thread-safe: yes * Realtime-safe: no */ void abl_link_enable_start_stop_sync(abl_link link, bool enabled); /*! @brief How many peers are currently connected in a Link session? * Thread-safe: yes * Realtime-safe: yes */ uint64_t abl_link_num_peers(abl_link link); /*! @brief Register a callback to be notified when the number of * peers in the Link session changes. * Thread-safe: yes * Realtime-safe: no * * @discussion The callback is invoked on a Link-managed thread. */ typedef void (*abl_link_num_peers_callback)(uint64_t num_peers, void *context); void abl_link_set_num_peers_callback( abl_link link, abl_link_num_peers_callback callback, void *context); /*! @brief Register a callback to be notified when the session * tempo changes. * Thread-safe: yes * Realtime-safe: no * * @discussion The callback is invoked on a Link-managed thread. */ typedef void (*abl_link_tempo_callback)(double tempo, void *context); void abl_link_set_tempo_callback( abl_link link, abl_link_tempo_callback callback, void *context); /*! brief: Register a callback to be notified when the state of * start/stop isPlaying changes. * Thread-safe: yes * Realtime-safe: no * * @discussion The callback is invoked on a Link-managed thread. */ typedef void (*abl_link_start_stop_callback)(bool is_playing, void *context); void abl_link_set_start_stop_callback( abl_link link, abl_link_start_stop_callback callback, void *context); /*! brief: Get the current link clock time in microseconds. * Thread-safe: yes * Realtime-safe: yes */ int64_t abl_link_clock_micros(abl_link link); /*! @brief The representation of the current local state of a client in a Link Session * * @discussion A session state represents a timeline and the start/stop * state. The timeline is a representation of a mapping between time and * beats for varying quanta. The start/stop state represents the user * intention to start or stop transport at a specific time. Start stop * synchronization is an optional feature that allows to share the user * request to start or stop transport between a subgroup of peers in a * Link session. When observing a change of start/stop state, audio * playback of a peer should be started or stopped the same way it would * have happened if the user had requested that change at the according * time locally. The start/stop state can only be changed by the user. * This means that the current local start/stop state persists when * joining or leaving a Link session. After joining a Link session * start/stop change requests will be communicated to all connected peers. */ typedef struct abl_link_session_state { void *impl; } abl_link_session_state; /*! @brief Create a new session_state instance. * Thread-safe: yes * Realtime-safe: no * * @discussion The session_state is to be used with the abl_link_capture... and * abl_link_commit... functions to capture snapshots of the current link state and pass * changes to the link session. */ abl_link_session_state abl_link_create_session_state(void); /*! @brief Delete a session_state instance. * Thread-safe: yes * Realtime-safe: no */ void abl_link_destroy_session_state(abl_link_session_state abl_link_session_state); /*! @brief Capture the current Link Session State from the audio thread. * Thread-safe: no * Realtime-safe: yes * * @discussion This function should ONLY be called in the audio thread and must not be * accessed from any other threads. After capturing the session_state holds a snapshot * of the current Link Session State, so it should be used in a local scope. The * session_state should not be created on the audio thread. */ void abl_link_capture_audio_session_state( abl_link link, abl_link_session_state session_state); /*! @brief Commit the given Session State to the Link session from the * audio thread. * Thread-safe: no * Realtime-safe: yes * * @discussion This function should ONLY be called in the audio thread. The given * session_state will replace the current Link state. Modifications will be * communicated to other peers in the session. */ void abl_link_commit_audio_session_state( abl_link link, abl_link_session_state session_state); /*! @brief Capture the current Link Session State from an application thread. * Thread-safe: no * Realtime-safe: yes * * @discussion Provides a mechanism for capturing the Link Session State from an * application thread (other than the audio thread). After capturing the session_state * contains a snapshot of the current Link state, so it should be used in a local * scope. */ void abl_link_capture_app_session_state( abl_link link, abl_link_session_state session_state); /*! @brief Commit the given Session State to the Link session from an * application thread. * Thread-safe: yes * Realtime-safe: no * * @discussion The given session_state will replace the current Link Session State. * Modifications of the Session State will be communicated to other peers in the * session. */ void abl_link_commit_app_session_state( abl_link link, abl_link_session_state session_state); /*! @brief: The tempo of the timeline, in Beats Per Minute. * * @discussion This is a stable value that is appropriate for display to the user. Beat * time progress will not necessarily match this tempo exactly because of clock drift * compensation. */ double abl_link_tempo(abl_link_session_state session_state); /*! @brief: Set the timeline tempo to the given bpm value, taking effect at the given * time. */ void abl_link_set_tempo( abl_link_session_state session_state, double bpm, int64_t at_time); /*! @brief: Get the beat value corresponding to the given time for the given quantum. * * @discussion: The magnitude of the resulting beat value is unique to this Link * client, but its phase with respect to the provided quantum is shared among all * session peers. For non-negative beat values, the following property holds: * fmod(beatAtTime(t, q), q) == phaseAtTime(t, q) */ double abl_link_beat_at_time( abl_link_session_state session_state, int64_t time, double quantum); /*! @brief: Get the session phase at the given time for the given quantum. * * @discussion: The result is in the interval [0, quantum). The result is equivalent to * fmod(beatAtTime(t, q), q) for non-negative beat values. This function is convenient * if the client application is only interested in the phase and not the beat * magnitude. Also, unlike fmod, it handles negative beat values correctly. */ double abl_link_phase_at_time( abl_link_session_state session_state, int64_t time, double quantum); /*! @brief: Get the time at which the given beat occurs for the given quantum. * * @discussion: The inverse of beatAtTime, assuming a constant tempo. * beatAtTime(timeAtBeat(b, q), q) === b. */ int64_t abl_link_time_at_beat( abl_link_session_state session_state, double beat, double quantum); /*! @brief: Attempt to map the given beat to the given time in the context of the given * quantum. * * @discussion: This function behaves differently depending on the state of the * session. If no other peers are connected, then this abl_link instance is in a * session by itself and is free to re-map the beat/time relationship whenever it * pleases. In this case, beatAtTime(time, quantum) == beat after this funtion has been * called. * * If there are other peers in the session, this abl_link instance should not abruptly * re-map the beat/time relationship in the session because that would lead to beat * discontinuities among the other peers. In this case, the given beat will be mapped * to the next time value greater than the given time with the same phase as the given * beat. * * This function is specifically designed to enable the concept of "quantized launch" * in client applications. If there are no other peers in the session, then an event * (such as starting transport) happens immediately when it is requested. If there are * other peers, however, we wait until the next time at which the session phase matches * the phase of the event, thereby executing the event in-phase with the other peers in * the session. The client application only needs to invoke this function to achieve * this behavior and should not need to explicitly check the number of peers. */ void abl_link_request_beat_at_time( abl_link_session_state session_state, double beat, int64_t time, double quantum); /*! @brief: Rudely re-map the beat/time relationship for all peers in a session. * * @discussion: DANGER: This function should only be needed in certain special * circumstances. Most applications should not use it. It is very similar to * requestBeatAtTime except that it does not fall back to the quantizing behavior when * it is in a session with other peers. Calling this function will unconditionally map * the given beat to the given time and broadcast the result to the session. This is * very anti-social behavior and should be avoided. * * One of the few legitimate uses of this function is to synchronize a Link session * with an external clock source. By periodically forcing the beat/time mapping * according to an external clock source, a peer can effectively bridge that clock into * a Link session. Much care must be taken at the application layer when implementing * such a feature so that users do not accidentally disrupt Link sessions that they may * join. */ void abl_link_force_beat_at_time( abl_link_session_state session_state, double beat, uint64_t time, double quantum); /*! @brief: Set if transport should be playing or stopped, taking effect at the given * time. */ void abl_link_set_is_playing( abl_link_session_state session_state, bool is_playing, uint64_t time); /*! @brief: Is transport playing? */ bool abl_link_is_playing(abl_link_session_state session_state); /*! @brief: Get the time at which a transport start/stop occurs */ uint64_t abl_link_time_for_is_playing(abl_link_session_state session_state); /*! @brief: Convenience function to attempt to map the given beat to the time * when transport is starting to play in context of the given quantum. * This function evaluates to a no-op if abl_link_is_playing equals false. */ void abl_link_request_beat_at_start_playing_time( abl_link_session_state session_state, double beat, double quantum); /*! @brief: Convenience function to start or stop transport at a given time and attempt * to map the given beat to this time in context of the given quantum. */ void abl_link_set_is_playing_and_request_beat_at_time( abl_link_session_state session_state, bool is_playing, uint64_t time, double beat, double quantum); #ifdef __cplusplus } // extern "C" #endif // __cplusplus ```
/content/code_sandbox/extensions/abl_link/include/abl_link.h
objective-c
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
3,533
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/Link.hpp> #include <ableton/platforms/stl/Clock.hpp> #include <ableton/test/CatchWrapper.hpp> namespace ableton { TEST_CASE("SessionState") { SECTION("ForceBeatTime") { using namespace std::chrono; using namespace ableton::link; const auto beats = 0.; const auto time = microseconds{23456789}; const auto quantum = 4.; using SessionState = ableton::BasicLink<platforms::stl::Clock>::SessionState; for (auto tempo = 20.; tempo < 999.; tempo += 0.8) { const auto tl = Timeline{Tempo{tempo}, Beats{12345678.}, microseconds{1234567}}; auto sessionState = SessionState({{tl, {}}, false}); sessionState.forceBeatAtTime(beats, time, quantum); CHECK(beats >= sessionState.beatAtTime(time, quantum)); } } } } // namespace ableton ```
/content/code_sandbox/src/ableton/tst_Link.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
341
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/test/serial_io/SchedulerTree.hpp> #include <algorithm> namespace ableton { namespace test { namespace serial_io { void SchedulerTree::run() { while (handlePending()) { } } std::shared_ptr<SchedulerTree> SchedulerTree::makeChild() { auto newChild = std::make_shared<SchedulerTree>(); mChildren.push_back(newChild); return newChild; } void SchedulerTree::cancelTimer(const TimerId timerId) { const auto it = std::find_if( begin(mTimers), end(mTimers), [timerId](const TimerMap::value_type& timer) { return timer.first.second == timerId; }); if (it != end(mTimers)) { auto handler = std::move(it->second); mPendingHandlers.push_back([handler]() { handler(1); // truthy indicates error }); mTimers.erase(it); } } SchedulerTree::TimePoint SchedulerTree::nextTimerExpiration() { auto nextTimePoint = TimePoint::max(); withChildren([&nextTimePoint](SchedulerTree& child) { nextTimePoint = (std::min)(nextTimePoint, child.nextOwnTimerExpiration()); }); return (std::min)(nextTimePoint, nextOwnTimerExpiration()); } void SchedulerTree::triggerTimersUntil(const TimePoint t) { using namespace std; withChildren([t](SchedulerTree& child) { child.triggerTimersUntil(t); }); const auto it = mTimers.upper_bound(make_pair(t, numeric_limits<TimerId>::max())); for_each(begin(mTimers), it, [this](const TimerMap::value_type& timer) { mPendingHandlers.push_back([timer]() { timer.second(0); // 0 indicates no error }); }); mTimers.erase(begin(mTimers), it); } bool SchedulerTree::handlePending() { bool subtreeWorked = false; withChildren( [&subtreeWorked](SchedulerTree& child) { subtreeWorked |= child.handlePending(); }); if (mPendingHandlers.empty()) { return subtreeWorked; } else { mPendingHandlers.front()(); mPendingHandlers.pop_front(); return true; } } SchedulerTree::TimePoint SchedulerTree::nextOwnTimerExpiration() { return mTimers.empty() ? TimePoint::max() : begin(mTimers)->first.first; } } // namespace serial_io } // namespace test } // namespace ableton ```
/content/code_sandbox/src/ableton/test/serial_io/SchedulerTree.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
668
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #define CATCH_CONFIG_MAIN #include <ableton/test/CatchWrapper.hpp> ```
/content/code_sandbox/src/ableton/test/catch/CatchMain.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
137
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/link/StartStopState.hpp> #include <ableton/test/CatchWrapper.hpp> namespace ableton { namespace link { TEST_CASE("StartStopState | RoundtripByteStreamEncoding") { const auto originalState = StartStopState{true, Beats{1234.}, std::chrono::microseconds{5678}}; std::vector<std::uint8_t> bytes(sizeInByteStream(originalState)); const auto serializedEndIter = toNetworkByteStream(originalState, begin(bytes)); const auto deserialized = StartStopState::fromNetworkByteStream(begin(bytes), serializedEndIter); CHECK(originalState == deserialized.first); } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_StartStopState.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
272
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/discovery/Payload.hpp> #include <ableton/discovery/test/Socket.hpp> #include <ableton/link/Measurement.hpp> #include <ableton/link/SessionId.hpp> #include <ableton/link/v1/Messages.hpp> #include <ableton/platforms/stl/Random.hpp> #include <ableton/test/CatchWrapper.hpp> #include <ableton/util/test/IoService.hpp> #include <array> namespace ableton { namespace link { namespace { struct MockClock { std::chrono::microseconds micros() const { return std::chrono::microseconds{4}; } }; struct MockIoContext { template <std::size_t BufferSize> using Socket = discovery::test::Socket; template <std::size_t BufferSize> Socket<BufferSize> openUnicastSocket(const discovery::IpAddress&) { return Socket<BufferSize>(mIo); } using Timer = util::test::Timer; Timer makeTimer() { return {}; } using Log = util::NullLog; Log log() const { return {}; } ableton::util::test::IoService mIo; }; struct TFixture { TFixture() : mMeasurement(mStateQuery(), [](std::vector<double>) {}, {}, MockClock{}, util::Injected<MockIoContext>(MockIoContext{})) { } discovery::test::Socket socket() { return mMeasurement.mpImpl->mSocket; } struct StateQuery { StateQuery() { using Random = ableton::platforms::stl::Random; mState.nodeState.sessionId = NodeId::random<Random>(); mState.endpoint = discovery::UdpEndpoint(discovery::IpAddressV4::from_string("127.0.0.1"), 9999); } PeerState operator()() { return mState; } PeerState mState; }; StateQuery mStateQuery; Measurement<MockClock, MockIoContext> mMeasurement; }; } // anonymous namespace TEST_CASE("PeerMeasurement") { using Micros = std::chrono::microseconds; TFixture fixture; const auto endpoint = discovery::UdpEndpoint(discovery::IpAddressV4::from_string("127.0.0.1"), 8888); SECTION("SendPingsOnConstruction") { CHECK(1 == fixture.socket().sentMessages.size()); const auto messageBuffer = fixture.socket().sentMessages[0].first; const auto result = v1::parseMessageHeader(std::begin(messageBuffer), std::end(messageBuffer)); const auto& header = result.first; std::chrono::microseconds gt{0}; std::chrono::microseconds ht{0}; discovery::parsePayload<GHostTime, HostTime>(result.second, std::end(messageBuffer), [&gt](GHostTime ghostTime) { gt = std::move(ghostTime.time); }, [&ht](HostTime hostTime) { ht = std::move(hostTime.time); }); CHECK(v1::kPing == header.messageType); CHECK(std::chrono::microseconds{4} == ht); CHECK(std::chrono::microseconds{0} == gt); } SECTION("ReceiveInitPong") { const auto id = SessionMembership{fixture.mStateQuery.mState.nodeState.sessionId}; const auto ht = HostTime{Micros(0)}; const auto gt = GHostTime{Micros(0)}; const auto payload = discovery::makePayload(id, gt, ht); v1::MessageBuffer buffer; const auto msgBegin = std::begin(buffer); const auto msgEnd = v1::pongMessage(payload, msgBegin); fixture.socket().incomingMessage(endpoint, msgBegin, msgEnd); CHECK(2 == fixture.socket().sentMessages.size()); CHECK(0 == fixture.mMeasurement.mpImpl->mData.size()); } SECTION("ReceivePong") { const auto id = SessionMembership{fixture.mStateQuery.mState.nodeState.sessionId}; const auto ht = HostTime{Micros(2)}; const auto gt = GHostTime{Micros(3)}; const auto pgt = PrevGHostTime{Micros(1)}; const auto payload = discovery::makePayload(id, gt, ht, pgt); v1::MessageBuffer buffer; const auto msgBegin = std::begin(buffer); const auto msgEnd = v1::pongMessage(payload, msgBegin); fixture.socket().incomingMessage(endpoint, msgBegin, msgEnd); CHECK(2 == fixture.socket().sentMessages.size()); CHECK(2 == fixture.mMeasurement.mpImpl->mData.size()); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_Measurement.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,157
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/link/Phase.hpp> #include <ableton/test/CatchWrapper.hpp> namespace ableton { namespace link { namespace { std::chrono::microseconds phaseEncodingRoundtrip( const Timeline& tl, const std::chrono::microseconds t, const Beats quantum) { return fromPhaseEncodedBeats(tl, toPhaseEncodedBeats(tl, t, quantum), quantum); } } // namespace TEST_CASE("Phase") { const auto zero = Beats{0.}; const auto one = Beats{1.}; const auto two = Beats{2.}; const auto three = Beats{3.}; const auto four = Beats{4.}; using std::chrono::microseconds; const auto tl0 = Timeline{Tempo{120.}, one, microseconds{0}}; const auto tl1 = Timeline{Tempo{60.}, Beats{-9.5}, microseconds{2000000}}; SECTION("phase(x, 0) == 0") { CHECK(phase(zero, zero) == zero); CHECK(phase(Beats{0.1}, zero) == zero); CHECK(phase(one, zero) == zero); CHECK(phase(-one, zero) == zero); } SECTION("phase(x, y) == x % y when x and y >= 0") { CHECK(phase(zero, zero) == zero % zero); CHECK(phase(one, zero) == one % zero); CHECK(phase(zero, one) == zero % one); CHECK(phase(Beats{0.1}, one) == Beats{0.1} % one); CHECK(phase(Beats{2.3}, one) == Beats{2.3} % one); CHECK(phase(Beats{9.5}, Beats{2.3}) == Beats{9.5} % Beats{2.3}); } SECTION("phase of negatives is not mirrored around zero") { CHECK(phase(-one, one) == zero); CHECK(phase(Beats{-0.1}, one) == Beats{0.9}); CHECK(phase(Beats{-2.3}, one) == Beats{0.7}); CHECK(phase(Beats{-9.5}, Beats{2.3}) == Beats{2.}); } SECTION("nextPhaseMatch | result == x when quantum == 0") { CHECK(nextPhaseMatch(Beats{0.1}, one, zero) == Beats{0.1}); CHECK(nextPhaseMatch(Beats{2.3}, Beats{9.5}, zero) == Beats{2.3}); CHECK(nextPhaseMatch(Beats{-0.1}, Beats{-2.3}, zero) == Beats{-0.1}); } SECTION("nextPhaseMatch | result == target when 0 <= x < target < quantum") { CHECK(nextPhaseMatch(zero, Beats{0.1}, one) == Beats{0.1}); CHECK(nextPhaseMatch(Beats{0.1}, one, two) == one); CHECK(nextPhaseMatch(one, two, Beats{2.3}) == two); CHECK(nextPhaseMatch(two, Beats{2.3}, three) == Beats{2.3}); } SECTION("nextPhaseMatch | some example cases") { CHECK(nextPhaseMatch(one, Beats{2.3}, two) == Beats{2.3}); CHECK(nextPhaseMatch(Beats{2.3}, Beats{-0.1}, two) == Beats{3.9}); CHECK(nextPhaseMatch(Beats{-9.5}, Beats{0.1}, two) == Beats{-7.9}); CHECK(nextPhaseMatch(Beats{-2.3}, Beats{0.1}, Beats{9.5}) == Beats{0.1}); } SECTION("toPhaseEncodedBeats | result == tl.toBeats when quantum == 0") { const auto t0 = microseconds{0}; const auto t1 = microseconds{2000000}; const auto t2 = microseconds{-3200000}; CHECK(toPhaseEncodedBeats(tl1, t0, zero) == tl1.toBeats(t0)); CHECK(toPhaseEncodedBeats(tl0, t1, zero) == tl0.toBeats(t1)); CHECK(toPhaseEncodedBeats(tl0, t2, zero) == tl0.toBeats(t2)); } SECTION("toPhaseEncodedBeats | result is the nearest quantum boundary") { const auto sec = microseconds{1000000}; // Takes the previous boundary CHECK(toPhaseEncodedBeats(tl0, sec, Beats{2.2}) == two); // Takes the next boundary CHECK(toPhaseEncodedBeats(tl0, sec, Beats{1.8}) == Beats{3.8}); // Takes the previous boundary when exactly in the middle CHECK(toPhaseEncodedBeats(tl0, sec, two) == two); } SECTION("toPhaseEncodedBeats | some example cases") { CHECK(toPhaseEncodedBeats(tl0, microseconds{-2000000}, four) == -four); CHECK(toPhaseEncodedBeats(tl0, microseconds{-3000000}, four) == Beats{-6.}); CHECK(toPhaseEncodedBeats(tl0, microseconds{3200000}, three) == Beats{6.4}); CHECK(toPhaseEncodedBeats(tl1, microseconds{0}, three) == Beats{-11.}); CHECK(toPhaseEncodedBeats(tl1, microseconds{1500000}, Beats{2.4}) == Beats{-10.1}); } SECTION("fromPhaseEncodedBeats | inverse of toPhaseEncodedBeats") { using std::chrono::microseconds; const auto t0 = microseconds{0}; const auto t1 = microseconds{2000000}; const auto t2 = microseconds{-3200000}; const auto t3 = microseconds{87654321}; CHECK(phaseEncodingRoundtrip(tl0, t0, zero) == t0); CHECK(phaseEncodingRoundtrip(tl0, t1, zero) == t1); CHECK(phaseEncodingRoundtrip(tl0, t2, zero) == t2); CHECK(phaseEncodingRoundtrip(tl0, t3, zero) == t3); CHECK(phaseEncodingRoundtrip(tl0, t0, one) == t0); CHECK(phaseEncodingRoundtrip(tl0, t1, one) == t1); CHECK(phaseEncodingRoundtrip(tl0, t2, one) == t2); CHECK(phaseEncodingRoundtrip(tl0, t3, one) == t3); CHECK(phaseEncodingRoundtrip(tl0, t0, two) == t0); CHECK(phaseEncodingRoundtrip(tl0, t1, two) == t1); CHECK(phaseEncodingRoundtrip(tl0, t2, two) == t2); CHECK(phaseEncodingRoundtrip(tl0, t3, two) == t3); CHECK(phaseEncodingRoundtrip(tl0, t0, three) == t0); CHECK(phaseEncodingRoundtrip(tl0, t1, three) == t1); CHECK(phaseEncodingRoundtrip(tl0, t2, three) == t2); CHECK(phaseEncodingRoundtrip(tl0, t3, three) == t3); CHECK(phaseEncodingRoundtrip(tl1, t0, zero) == t0); CHECK(phaseEncodingRoundtrip(tl1, t1, zero) == t1); CHECK(phaseEncodingRoundtrip(tl1, t2, zero) == t2); CHECK(phaseEncodingRoundtrip(tl1, t3, zero) == t3); CHECK(phaseEncodingRoundtrip(tl1, t0, one) == t0); CHECK(phaseEncodingRoundtrip(tl1, t1, one) == t1); CHECK(phaseEncodingRoundtrip(tl1, t2, one) == t2); CHECK(phaseEncodingRoundtrip(tl1, t3, one) == t3); CHECK(phaseEncodingRoundtrip(tl1, t0, two) == t0); CHECK(phaseEncodingRoundtrip(tl1, t1, two) == t1); CHECK(phaseEncodingRoundtrip(tl1, t2, two) == t2); CHECK(phaseEncodingRoundtrip(tl1, t3, two) == t3); CHECK(phaseEncodingRoundtrip(tl1, t0, three) == t0); CHECK(phaseEncodingRoundtrip(tl1, t1, three) == t1); CHECK(phaseEncodingRoundtrip(tl1, t2, three) == t2); CHECK(phaseEncodingRoundtrip(tl1, t3, three) == t3); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_Phase.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
2,030
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/link/Controller.hpp> #include <ableton/link/Tempo.hpp> #include <ableton/platforms/stl/Random.hpp> #include <ableton/test/CatchWrapper.hpp> #include <ableton/util/Log.hpp> #include <ableton/util/test/Timer.hpp> namespace ableton { namespace link { using namespace std::chrono; static bool operator==(const IncomingClientState& lhs, const ClientState& rhs) { return static_cast<bool>(lhs.timeline) && static_cast<bool>(lhs.startStopState) && std::tie(*lhs.timeline, *lhs.startStopState) == std::tie(rhs.timeline, rhs.startStopState); } namespace { struct MockClock { template <typename T, typename Rep> void advance(std::chrono::duration<T, Rep> duration) { now() += duration; } microseconds micros() const { return now(); } private: static microseconds& now() { static microseconds now{1}; return now; } }; struct MockIoContext { MockIoContext() { } template <typename ExceptionHandler> MockIoContext(ExceptionHandler) { } template <std::size_t BufferSize> struct Socket { std::size_t send( const uint8_t* const, const size_t numBytes, const discovery::UdpEndpoint&) { return numBytes; } template <typename Handler> void receive(Handler) { } discovery::UdpEndpoint endpoint() const { return {}; } }; void stop() { } template <std::size_t BufferSize> Socket<BufferSize> openUnicastSocket(const discovery::IpAddress&) { return {}; } template <std::size_t BufferSize> Socket<BufferSize> openMulticastSocket(const discovery::IpAddress&) { return {}; } std::vector<discovery::IpAddress> scanNetworkInterfaces() { return {}; } using Timer = util::test::Timer; Timer makeTimer() { return {}; } template <typename Callback, typename Duration> struct LockFreeCallbackDispatcher { LockFreeCallbackDispatcher(Callback callback, Duration) : mCallback(std::move(callback)) { } void invoke() { mCallback(); } Callback mCallback; }; using Log = util::NullLog; Log log() const { return {}; } template <typename Handler> void async(Handler handler) const { handler(); } }; using MockController = Controller<PeerCountCallback, TempoCallback, StartStopStateCallback, MockClock, platforms::stl::Random, MockIoContext>; const auto kAnyTime = std::chrono::microseconds{6}; struct TempoClientCallback { void operator()(const Tempo bpm) { tempos.push_back(bpm); } std::vector<Tempo> tempos; }; struct StartStopStateClientCallback { void operator()(const bool isPlaying) { startStopStates.push_back(isPlaying); } std::vector<bool> startStopStates; }; template <typename SetClientStateFunctionT, typename GetClientStateFunctionT> void testSetAndGetClientState( SetClientStateFunctionT setClientState, GetClientStateFunctionT getClientState) { using namespace std::chrono; auto clock = MockClock{}; MockController controller( Tempo{100.0}, [](std::size_t) {}, [](Tempo) {}, [](bool) {}, clock); clock.advance(microseconds{1}); const auto initialTimeline = Optional<Timeline>{Timeline{Tempo{60.}, Beats{0.}, kAnyTime}}; const auto initialStartStopState = Optional<ClientStartStopState>{ClientStartStopState{false, kAnyTime, clock.micros()}}; const auto initialClientState = IncomingClientState{initialTimeline, initialStartStopState, clock.micros()}; setClientState(controller, initialClientState); SECTION("Client state is correct after initial set") { CHECK(initialClientState == getClientState(controller)); } SECTION("Set outdated start stop state (timestamp unchanged)") { // Set client state with a StartStopState having the same timestamp as the current // StartStopState - don't advance clock const auto outdatedStartStopState = Optional<ClientStartStopState>{ ClientStartStopState{false, kAnyTime, clock.micros()}}; setClientState(controller, IncomingClientState{Optional<Timeline>{}, outdatedStartStopState, clock.micros()}); CHECK(initialClientState == getClientState(controller)); } clock.advance(microseconds{1}); SECTION("Set outdated start stop state (timestamp in past)") { const auto outdatedStartStopState = Optional<ClientStartStopState>{ ClientStartStopState{false, kAnyTime, microseconds{0}}}; setClientState(controller, IncomingClientState{Optional<Timeline>{}, outdatedStartStopState, clock.micros()}); CHECK(initialClientState == getClientState(controller)); } SECTION("Set empty client state") { setClientState(controller, IncomingClientState{Optional<Timeline>{}, Optional<ClientStartStopState>{}, clock.micros()}); CHECK(initialClientState == getClientState(controller)); } SECTION("Set client state with new Timeline and StartStopState") { const auto expectedTimeline = Optional<Timeline>{Timeline{Tempo{80.}, Beats{1.}, kAnyTime}}; const auto expectedStartStopState = Optional<ClientStartStopState>{ ClientStartStopState{false, kAnyTime, clock.micros()}}; const auto expectedClientState = IncomingClientState{expectedTimeline, expectedStartStopState, clock.micros()}; setClientState(controller, expectedClientState); CHECK(expectedClientState == getClientState(controller)); } } template <typename SetClientStateFunctionT> void testCallbackInvocation(SetClientStateFunctionT setClientState) { using namespace std::chrono; auto clock = MockClock{}; auto tempoCallback = TempoClientCallback{}; auto startStopStateCallback = StartStopStateClientCallback{}; MockController controller(Tempo{100.0}, [](std::size_t) {}, std::ref(tempoCallback), std::ref(startStopStateCallback), clock); clock.advance(microseconds{1}); const auto initialTempo = Tempo{50.}; const auto initialIsPlaying = true; const auto initialTimeline = Optional<Timeline>{Timeline{initialTempo, Beats{0.}, kAnyTime}}; const auto initialStartStopState = Optional<ClientStartStopState>{ ClientStartStopState{initialIsPlaying, kAnyTime, clock.micros()}}; setClientState(controller, {initialTimeline, initialStartStopState, clock.micros()}); SECTION("Callbacks are called when setting new client state") { CHECK(std::vector<Tempo>{initialTempo} == tempoCallback.tempos); CHECK(std::vector<bool>{initialIsPlaying} == startStopStateCallback.startStopStates); clock.advance(microseconds{1}); tempoCallback.tempos = {}; startStopStateCallback.startStopStates = {}; SECTION("Callbacks mustn't be called if Tempo and isPlaying don't change") { const auto timeline = Optional<Timeline>{Timeline{initialTempo, Beats{1.}, kAnyTime}}; const auto startStopState = Optional<ClientStartStopState>{ ClientStartStopState{initialIsPlaying, kAnyTime, clock.micros()}}; setClientState(controller, {timeline, startStopState, clock.micros()}); CHECK(tempoCallback.tempos.empty()); CHECK(startStopStateCallback.startStopStates.empty()); } } } } // namespace TEST_CASE("Controller") { SECTION("ConstructOptimistically") { MockController controller( Tempo{100.0}, [](std::size_t) {}, [](Tempo) {}, [](bool) {}, MockClock{}); CHECK(!controller.isEnabled()); CHECK(!controller.isStartStopSyncEnabled()); CHECK(0 == controller.numPeers()); const auto tl = controller.clientState().timeline; CHECK(Tempo{100.0} == tl.tempo); } SECTION("ConstructWithInvalidTempo") { MockController controllerLowTempo( Tempo{1.0}, [](std::size_t) {}, [](Tempo) {}, [](bool) {}, MockClock{}); const auto tlLow = controllerLowTempo.clientState().timeline; CHECK(Tempo{20.0} == tlLow.tempo); MockController controllerHighTempo( Tempo{100000.0}, [](std::size_t) {}, [](Tempo) {}, [](bool) {}, MockClock{}); const auto tlHigh = controllerHighTempo.clientState().timeline; CHECK(Tempo{999.0} == tlHigh.tempo); } SECTION("EnableDisable") { MockController controller( Tempo{100.0}, [](std::size_t) {}, [](Tempo) {}, [](bool) {}, MockClock{}); controller.enable(true); CHECK(controller.isEnabled()); controller.enable(false); CHECK(!controller.isEnabled()); } SECTION("EnableDisableStartStopSync") { MockController controller( Tempo{100.0}, [](std::size_t) {}, [](Tempo) {}, [](bool) {}, MockClock{}); controller.enableStartStopSync(true); CHECK(controller.isStartStopSyncEnabled()); controller.enableStartStopSync(false); CHECK(!controller.isStartStopSyncEnabled()); } SECTION("SetAndGetClientStateThreadSafe") { testSetAndGetClientState( [](MockController& controller, IncomingClientState clientState) { controller.setClientState(clientState); }, [](MockController& controller) { return controller.clientState(); }); } SECTION("SetAndGetClientStateRealtimeSafe") { testSetAndGetClientState( [](MockController& controller, IncomingClientState clientState) { controller.setClientStateRtSafe(clientState); }, [](MockController& controller) { return controller.clientStateRtSafe(); }); } SECTION("SetClientStateRealtimeSafeAndGetItThreadSafe") { testSetAndGetClientState( [](MockController& controller, IncomingClientState clientState) { controller.setClientStateRtSafe(clientState); }, [](MockController& controller) { return controller.clientState(); }); } SECTION("SetClientStateThreadSafeAndGetItRealtimeSafe") { testSetAndGetClientState( [](MockController& controller, IncomingClientState clientState) { controller.setClientState(clientState); }, [](MockController& controller) { MockClock{}.advance(seconds{2}); return controller.clientStateRtSafe(); }); } SECTION("CallbacksCalledBySettingClientStateThreadSafe") { testCallbackInvocation( [](MockController& controller, IncomingClientState clientState) { controller.setClientState(clientState); }); } SECTION("CallbacksCalledBySettingClientStateRealtimeSafe") { testCallbackInvocation( [](MockController& controller, IncomingClientState clientState) { controller.setClientStateRtSafe(clientState); }); } SECTION("GetClientStateRtSafeGracePeriod") { using namespace std::chrono; auto clock = MockClock{}; auto tempoCallback = TempoClientCallback{}; auto startStopStateCallback = StartStopStateClientCallback{}; MockController controller(Tempo{100.0}, [](std::size_t) {}, std::ref(tempoCallback), std::ref(startStopStateCallback), clock); controller.enable(true); clock.advance(microseconds{1}); const auto initialTimeline = Optional<Timeline>{Timeline{Tempo{50.}, Beats{0.}, clock.micros()}}; const auto initialStartStopState = Optional<ClientStartStopState>{ ClientStartStopState{true, kAnyTime, clock.micros()}}; const auto initialState = IncomingClientState{initialTimeline, initialStartStopState, clock.micros()}; controller.setClientStateRtSafe( {initialTimeline, initialStartStopState, clock.micros()}); REQUIRE(initialState == controller.clientState()); REQUIRE(initialState == controller.clientStateRtSafe()); clock.advance(microseconds{1}); const auto newTimeline = Optional<Timeline>{Timeline{Tempo{70.}, Beats{1.}, clock.micros()}}; const auto newStartStopState = Optional<ClientStartStopState>{ ClientStartStopState{false, kAnyTime, clock.micros()}}; const auto newState = IncomingClientState{newTimeline, newStartStopState, clock.micros()}; controller.setClientState({newTimeline, newStartStopState, clock.micros()}); clock.advance(milliseconds{500}); CHECK(newState == controller.clientState()); CHECK(initialState == controller.clientStateRtSafe()); clock.advance(milliseconds{500}); CHECK(newState == controller.clientState()); CHECK(newState == controller.clientStateRtSafe()); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_Controller.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
2,959
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/link/HostTimeFilter.hpp> #include <ableton/test/CatchWrapper.hpp> #include <chrono> namespace ableton { namespace link { struct MockClock { MockClock() : time(std::chrono::microseconds(0)) { } std::chrono::microseconds micros() { const auto current = time; time += std::chrono::microseconds(1); return current; } std::chrono::microseconds time; }; TEST_CASE("HostTimeFilter") { using Filter = ableton::link::HostTimeFilter<MockClock>; Filter filter; SECTION("OneValue") { const auto ht = filter.sampleTimeToHostTime(5); CHECK(0 == ht.count()); } SECTION("MultipleValues") { const auto numValues = 600; auto ht = std::chrono::microseconds(0); for (int i = 0; i <= numValues; ++i) { ht = filter.sampleTimeToHostTime(i); } CHECK(numValues == ht.count()); } SECTION("Reset") { auto ht = filter.sampleTimeToHostTime(0); ht = filter.sampleTimeToHostTime(-230); ht = filter.sampleTimeToHostTime(40); REQUIRE(2 != ht.count()); filter.reset(); ht = filter.sampleTimeToHostTime(0); CHECK(3 == ht.count()); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_HostTimeFilter.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
449
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/discovery/AsioTypes.hpp> #include <ableton/link/NodeId.hpp> #include <ableton/link/PeerState.hpp> #include <ableton/link/StartStopState.hpp> #include <ableton/link/Timeline.hpp> #include <ableton/platforms/stl/Random.hpp> #include <ableton/test/CatchWrapper.hpp> namespace ableton { namespace link { TEST_CASE("PeerState") { auto nodeId = NodeId::random<platforms::stl::Random>(); const auto timeline = Timeline{Tempo{60.}, Beats{1.}, std::chrono::microseconds{100}}; const auto startStop = StartStopState{true, Beats{1234.}, std::chrono::microseconds{5678}}; const auto nodeState = NodeState{nodeId, nodeId, timeline, startStop}; SECTION("V4RoundtripByteStreamEncoding") { PeerState state{nodeState, discovery::UdpEndpoint( {discovery::makeAddress<discovery::IpAddressV4>("123.123.1.2"), 6780})}; const auto payload = toPayload(state); std::vector<std::uint8_t> bytes(sizeInByteStream(payload)); const auto end = toNetworkByteStream(payload, begin(bytes)); const auto result = PeerState::fromPayload(nodeId, bytes.begin(), end); CHECK(state == result); } SECTION("V6RoundtripByteStreamEncoding") { PeerState state{ nodeState, discovery::UdpEndpoint( {::LINK_ASIO_NAMESPACE::ip::make_address("fe80::8080"), 6780})}; const auto payload = toPayload(state); std::vector<std::uint8_t> bytes(sizeInByteStream(payload)); const auto end = toNetworkByteStream(payload, begin(bytes)); const auto result = PeerState::fromPayload(nodeId, bytes.begin(), end); CHECK(state == result); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_PeerState.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
554
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/link/Median.hpp> #include <ableton/test/CatchWrapper.hpp> #include <array> #include <vector> namespace ableton { namespace link { TEST_CASE("Median") { using Vector = std::vector<double>; SECTION("ArrayWithThreePoints") { auto data = std::array<double, 3>{{5., 0., 6.}}; CHECK_THAT(5, Catch::Matchers::WithinAbs(median(data.begin(), data.end()), 1e-10)); } SECTION("VectorWithFourPoints") { auto data = Vector{{0., 2., 1., 3., 2.}}; CHECK_THAT(2.0, Catch::Matchers::WithinAbs(median(data.begin(), data.end()), 1e-10)); } SECTION("VectorWithFivePoints") { auto data = Vector{{0., 1., 3., 2.}}; CHECK_THAT(1.5, Catch::Matchers::WithinAbs(median(data.begin(), data.end()), 1e-10)); } SECTION("VectorWith9999Points") { Vector data; const double slope = -0.2; const double intercept = -357.53456; for (int i = 1; i < 10000; ++i) { data.emplace_back(i * slope + intercept); } CHECK_THAT(slope * 5000 + intercept, Catch::Matchers::WithinAbs(median(data.begin(), data.end()), 1e-10)); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_Median.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
465
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/link/LinearRegression.hpp> #include <ableton/test/CatchWrapper.hpp> #include <array> #include <vector> namespace ableton { namespace link { TEST_CASE("LinearRegression") { using Array = std::array<std::pair<double, double>, 1>; using Vector = std::vector<std::pair<double, double>>; using FloatVector = std::vector<std::pair<float, float>>; SECTION("OnePoint") { Array data; data[0] = {0., 0.}; const auto result = linearRegression(data.begin(), data.end()); CHECK_THAT(result.first, Catch::Matchers::WithinAbs(0, 0.00001)); CHECK_THAT(result.second, Catch::Matchers::WithinAbs(0, 0.00001)); } SECTION("TwoPoints") { Vector data; data.emplace_back(0.0, 0.0); data.emplace_back(666666.6, 66666.6); const auto result = linearRegression(data.begin(), data.end()); CHECK_THAT(result.first, Catch::Matchers::WithinAbs(0.1, 0.00001)); CHECK_THAT(result.second, Catch::Matchers::WithinAbs(0.0, 0.00001)); } SECTION("10000Points") { Vector data; const double slope = -0.2; const double intercept = -357.53456; for (int i = 1; i < 10000; ++i) { data.emplace_back(i, i * slope + intercept); } const auto result = linearRegression(data.begin(), data.end()); CHECK_THAT(slope, Catch::Matchers::WithinAbs(result.first, 1e-7)); CHECK_THAT(intercept, Catch::Matchers::WithinAbs(result.second, 1e-7)); } SECTION("TwoPoints Float") { FloatVector data; data.emplace_back(0.f, 0.f); data.emplace_back(666666.6f, 66666.6f); const auto result = linearRegression(data.begin(), data.end()); CHECK_THAT(static_cast<double>(result.first), Catch::Matchers::WithinAbs(0.1, 0.002)); CHECK_THAT(static_cast<double>(result.second), Catch::Matchers::WithinAbs(0., 0.002)); } SECTION("10000Points Float") { FloatVector data; const float slope = -0.2f; const float intercept = -357.53456f; for (int i = 1; i < 500; ++i) { data.emplace_back(static_cast<float>(i), static_cast<float>(i) * slope + intercept); } const auto result = linearRegression(data.begin(), data.end()); CHECK_THAT( slope, Catch::Matchers::WithinAbs(static_cast<double>(result.first), 1e-3)); CHECK_THAT( intercept, Catch::Matchers::WithinAbs(static_cast<double>(result.second), 1e-3)); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_LinearRegression.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
790
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/link/ClientSessionTimelines.hpp> #include <ableton/test/CatchWrapper.hpp> namespace ableton { namespace link { TEST_CASE("ClientSessionTimelines") { using std::chrono::microseconds; // Make the constants non-zero to make sure we're not hiding bugs const auto b0 = Beats{-1.}; const auto t0 = microseconds{-1}; const auto xform = GhostXForm{1., microseconds{-1000000}}; SECTION("Session->Client | UpdatesTempo") { const auto curClient = Timeline{Tempo{60.}, b0, t0}; const auto session = Timeline{Tempo{90.}, b0, xform.hostToGhost(t0)}; const auto newClient = updateClientTimelineFromSession(curClient, session, t0, xform); CHECK(newClient.tempo == Tempo{90.}); } SECTION("Session->Client | PreservesClientBeatMagnitude") { const auto curClient = Timeline{Tempo{60.}, b0, t0}; const auto session = Timeline{Tempo{120.}, Beats{12.32}, microseconds{-123456789}}; // Transition to the session timeline at t1 const auto t1 = t0 + microseconds{5000000}; const auto b1 = curClient.toBeats(t1); const auto newClient = updateClientTimelineFromSession(curClient, session, t1, xform); // The new client timeline should have the same magnitude as the old // one at the transition point CHECK(newClient.toBeats(t1) == b1); // At t1 + dt, the new tempo should be in effect CHECK(newClient.toBeats(t1 + microseconds{1000000}) == b1 + Beats{2.}); } SECTION("Session->Client | AtDifferentTimesGivesSameResult") { const auto curClient = Timeline{Tempo{60.}, b0, t0}; const auto session = Timeline{Tempo{120.}, Beats{-11.}, microseconds{-12356789}}; const auto t1 = t0 + microseconds{5000000}; const auto t2 = t1 + microseconds{6849353}; // Once a given session timeline has been converted to a client // timeline, converting again from the same session at different // times should not change the result because the result is colinear // and the origin should always be anchored at the session's beat 0. const auto updated1 = updateClientTimelineFromSession(curClient, session, t1, xform); const auto updated2 = updateClientTimelineFromSession(updated1, session, t2, xform); CHECK(updated1 == updated2); } SECTION("Session->Client | EncodesSessionOrigin") { const auto curClient = Timeline{Tempo{60.}, b0, t0}; const auto session = Timeline{Tempo{21.3}, Beats{-421.3}, microseconds{15003240}}; const auto newClient = updateClientTimelineFromSession(curClient, session, microseconds{-1345298}, xform); // The new client timeline's origin should be at beat 0 on the // session timeline. This is how we encode the session origin in the // client timeline. CHECK(xform.hostToGhost(newClient.timeOrigin) == session.fromBeats(Beats{0.})); } SECTION("Client->Session | ShiftedForward") { const auto session = Timeline{Tempo{60.}, b0, t0}; auto client = Timeline{Tempo{60.}, Beats{111.}, xform.ghostToHost(t0)}; client = updateClientTimelineFromSession(client, session, t0, xform); // Shift the phase one beat forward client = shiftClientTimeline(client, Beats{1.}); const auto newSession = updateSessionTimelineFromClient(session, client, xform.ghostToHost(t0), xform); CHECK(newSession.toBeats(t0) == b0 + Beats{1.}); } SECTION("Client->Session | ShiftedBackward") { const auto session = Timeline{Tempo{60.}, b0, t0}; auto client = Timeline{Tempo{60.}, Beats{983.}, xform.ghostToHost(t0)}; client = updateClientTimelineFromSession(client, session, t0, xform); // Shift the phase one beat backward client = shiftClientTimeline(client, Beats{-1.}); const auto newSession = updateSessionTimelineFromClient(session, client, xform.ghostToHost(t0), xform); CHECK(newSession.toBeats(t0) == b0 - Beats{1.}); } SECTION("Session->Client->Session | Roundtrip") { const auto session = Timeline{Tempo{60.}, b0, t0}; // Initial client timeline values shouldn't matter auto client = Timeline{Tempo{213.5}, Beats{432.}, microseconds{5143503}}; client = updateClientTimelineFromSession(client, session, t0, xform); auto newSession = updateSessionTimelineFromClient(session, client, microseconds{42905944}, xform); CHECK(session == newSession); // Now verify that modifying the client timeline and then routing it // through a session update results in the same client timeline. const auto updateTime = microseconds{-35023900}; newSession = updateSessionTimelineFromClient(newSession, client, updateTime, xform); const auto newClient = updateClientTimelineFromSession(client, newSession, updateTime, xform); CHECK(client == newClient); } SECTION("ShiftClientTimelineOrigin") { const auto shift = Beats{1.1}; const auto timeline = Timeline{Tempo{60.}, b0, t0}; CHECK( shiftClientTimeline(timeline, shift).toBeats(t0) == timeline.toBeats(t0) + shift); CHECK( shiftClientTimeline(timeline, -shift).toBeats(t0) == timeline.toBeats(t0) - shift); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_ClientSessionTimelines.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,479
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/discovery/Payload.hpp> #include <ableton/discovery/test/Socket.hpp> #include <ableton/link/GhostXForm.hpp> #include <ableton/link/NodeState.hpp> #include <ableton/link/PayloadEntries.hpp> #include <ableton/link/PingResponder.hpp> #include <ableton/link/v1/Messages.hpp> #include <ableton/platforms/stl/Random.hpp> #include <ableton/test/CatchWrapper.hpp> #include <ableton/util/test/IoService.hpp> #include <array> namespace ableton { namespace link { namespace { using Random = ableton::platforms::stl::Random; struct MockClock { std::chrono::microseconds micros() const { return std::chrono::microseconds{4}; } }; struct MockIoContext { template <std::size_t BufferSize> using Socket = discovery::test::Socket; template <std::size_t BufferSize> Socket<BufferSize> openUnicastSocket(const discovery::IpAddress&) { return Socket<BufferSize>(mIo); } using Log = util::NullLog; Log log() const { return {}; } ableton::util::test::IoService mIo; }; struct RpFixture { RpFixture() : mAddress(discovery::IpAddressV4::from_string("127.0.0.1")) , mResponder(mAddress, NodeId::random<Random>(), GhostXForm{1.0, std::chrono::microseconds{0}}, MockClock{}, util::injectRef(*mIo)) { } discovery::test::Socket responderSocket() { return mResponder.socket(); } std::size_t numSentMessages() { return responderSocket().sentMessages.size(); } discovery::IpAddressV4 mAddress = discovery::IpAddressV4::from_string("127.0.0.1"); util::Injected<MockIoContext> mIo; PingResponder<MockClock, MockIoContext> mResponder; }; } // anonymous namespace TEST_CASE("PingResponder") { using std::chrono::microseconds; RpFixture fixture; SECTION("ReplyToPing") { // Construct and send Ping Message. Check if Responder sent back a Message const auto payload = discovery::makePayload(HostTime{microseconds(2)}, PrevGHostTime{microseconds(1)}); v1::MessageBuffer buffer; const auto msgBegin = std::begin(buffer); const auto msgEnd = v1::pingMessage(payload, msgBegin); const auto endpoint = discovery::UdpEndpoint(fixture.mAddress, 8888); fixture.responderSocket().incomingMessage(endpoint, msgBegin, msgEnd); CHECK(1 == fixture.numSentMessages()); // Check Responder's message const auto messageBuffer = fixture.responderSocket().sentMessages[0].first; const auto result = v1::parseMessageHeader(begin(messageBuffer), end(messageBuffer)); const auto& hdr = result.first; std::chrono::microseconds ghostTime{0}; std::chrono::microseconds prevGHostTime{0}; std::chrono::microseconds hostTime{0}; discovery::parsePayload<GHostTime, PrevGHostTime, HostTime>(result.second, std::end(messageBuffer), [&ghostTime](GHostTime gt) { ghostTime = std::move(gt.time); }, [&prevGHostTime](PrevGHostTime gt) { prevGHostTime = std::move(gt.time); }, [&hostTime](HostTime ht) { hostTime = std::move(ht.time); }); CHECK(v1::kPong == hdr.messageType); CHECK(std::chrono::microseconds{2} == hostTime); CHECK(std::chrono::microseconds{1} == prevGHostTime); CHECK(std::chrono::microseconds{4} == ghostTime); } SECTION("PingSizeExceeding") { const auto ht = HostTime{microseconds(2)}; const auto payload = discovery::makePayload(ht, ht, ht); v1::MessageBuffer buffer; const auto msgBegin = std::begin(buffer); const auto msgEnd = v1::pingMessage(payload, msgBegin); const auto endpoint = discovery::UdpEndpoint(fixture.mAddress, 8888); fixture.responderSocket().incomingMessage(endpoint, msgBegin, msgEnd); CHECK(0 == fixture.numSentMessages()); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_PingResponder.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,105
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/link/Peers.hpp> #include <ableton/platforms/stl/Random.hpp> #include <ableton/test/CatchWrapper.hpp> #include <ableton/test/serial_io/Fixture.hpp> namespace ableton { namespace link { namespace { using Random = ableton::platforms::stl::Random; struct SessionMembershipCallback { void operator()() { ++calls; } std::size_t calls = 0; }; struct SessionTimelineCallback { void operator()(const SessionId& sessionId, const Timeline& timeline) { sessionTimelines.push_back(std::make_pair(sessionId, timeline)); } std::vector<std::pair<SessionId, Timeline>> sessionTimelines; }; struct SessionStartStopStateCallback { void operator()(const SessionId& sessionId, const StartStopState& startStopState) { sessionStartStopStates.push_back(std::make_pair(sessionId, startStopState)); } std::vector<std::pair<SessionId, StartStopState>> sessionStartStopStates; }; using PeerVector = std::vector<typename Peers<test::serial_io::Context, SessionMembershipCallback, SessionTimelineCallback, SessionStartStopStateCallback>::Peer>; void expectPeers(const PeerVector& expected, const PeerVector& actual) { CHECK(expected == actual); } void expectSessionTimelines(const std::vector<std::pair<SessionId, Timeline>>& expected, const SessionTimelineCallback& callback) { CHECK(expected == callback.sessionTimelines); } void expectStartStopStates( const std::vector<std::pair<SessionId, StartStopState>>& expected, const SessionStartStopStateCallback& callback) { CHECK(expected == callback.sessionStartStopStates); } } // anonymous namespace TEST_CASE("Peers") { const auto fooPeer = PeerState{{NodeId::random<Random>(), NodeId::random<Random>(), Timeline{Tempo{60.}, Beats{1.}, std::chrono::microseconds{1234}}, StartStopState{false, Beats{0.}, std::chrono::microseconds{2345}}}, {}}; const auto barPeer = PeerState{{NodeId::random<Random>(), NodeId::random<Random>(), Timeline{Tempo{120.}, Beats{10.}, std::chrono::microseconds{500}}, {}}, {}}; const auto bazPeer = PeerState{{NodeId::random<Random>(), NodeId::random<Random>(), Timeline{Tempo{100.}, Beats{4.}, std::chrono::microseconds{100}}, {}}, {}}; const auto gateway1 = discovery::IpAddress::from_string("123.123.123.123"); const auto gateway2 = discovery::IpAddress::from_string("210.210.210.210"); auto membership = SessionMembershipCallback{}; auto sessions = SessionTimelineCallback{}; auto startStops = SessionStartStopStateCallback{}; test::serial_io::Fixture io; auto peers = makePeers(util::injectVal(io.makeIoContext()), std::ref(membership), std::ref(sessions), std::ref(startStops)); SECTION("EmptySessionPeersAfterInit") { io.flush(); expectPeers({}, peers.sessionPeers(fooPeer.sessionId())); } SECTION("AddAndFindPeer") { auto observer = makeGatewayObserver(peers, gateway1); sawPeer(observer, fooPeer); io.flush(); expectPeers({{fooPeer, gateway1}}, peers.sessionPeers(fooPeer.sessionId())); CHECK(1u == membership.calls); expectSessionTimelines( {make_pair(fooPeer.sessionId(), fooPeer.timeline())}, sessions); expectStartStopStates( {make_pair(fooPeer.sessionId(), fooPeer.startStopState())}, startStops); } SECTION("AddAndRemovePeer") { auto observer = makeGatewayObserver(peers, gateway1); sawPeer(observer, fooPeer); peerLeft(observer, fooPeer.ident()); io.flush(); expectPeers({}, peers.sessionPeers(fooPeer.sessionId())); CHECK(2u == membership.calls); } SECTION("AddTwoPeersRemoveOne") { auto observer = makeGatewayObserver(peers, gateway1); sawPeer(observer, fooPeer); sawPeer(observer, barPeer); peerLeft(observer, fooPeer.ident()); io.flush(); expectPeers({}, peers.sessionPeers(fooPeer.sessionId())); expectPeers({{barPeer, gateway1}}, peers.sessionPeers(barPeer.sessionId())); CHECK(3u == membership.calls); } SECTION("AddThreePeersTwoOnSameGateway") { auto observer1 = makeGatewayObserver(peers, gateway1); auto observer2 = makeGatewayObserver(peers, gateway2); sawPeer(observer1, fooPeer); sawPeer(observer2, fooPeer); sawPeer(observer1, barPeer); sawPeer(observer1, bazPeer); io.flush(); expectPeers({{fooPeer, gateway1}, {fooPeer, gateway2}}, peers.sessionPeers(fooPeer.sessionId())); CHECK(3 == membership.calls); } SECTION("CloseGateway") { auto observer1 = makeGatewayObserver(peers, gateway1); { // The observer will close the gateway when it goes out of scope auto observer2 = makeGatewayObserver(peers, gateway2); sawPeer(observer2, fooPeer); sawPeer(observer2, barPeer); sawPeer(observer1, fooPeer); sawPeer(observer2, bazPeer); io.flush(); } expectPeers({{fooPeer, gateway1}}, peers.sessionPeers(fooPeer.sessionId())); CHECK(4 == membership.calls); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_Peers.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,373
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/link/Beats.hpp> #include <ableton/test/CatchWrapper.hpp> namespace ableton { namespace link { TEST_CASE("Beats") { SECTION("ConstructFromFloating") { const auto beats = Beats{0.5}; CHECK(500000 == beats.microBeats()); CHECK_THAT(0.5, Catch::Matchers::WithinAbs(beats.floating(), 1e-10)); } SECTION("ConstructFromMicros") { const auto beats = Beats{INT64_C(100000)}; CHECK(100000 == beats.microBeats()); CHECK_THAT(0.1, Catch::Matchers::WithinAbs(beats.floating(), 1e-10)); } SECTION("Negation") { const auto beat = Beats{1.}; CHECK(beat > -beat); CHECK(beat == -(-beat)); CHECK(-beat < Beats{0.}); } SECTION("Addition") { const auto beat1 = Beats{0.5}; const auto beat2 = Beats{INT64_C(200000)}; const auto beat3 = Beats{0.1}; CHECK(beat1 == beat2 + beat2 + beat3); } SECTION("Subtraction") { const auto beat1 = Beats{0.5}; const auto beat2 = Beats{INT64_C(200000)}; const auto beat3 = Beats{0.1}; CHECK(beat3 == beat1 - beat2 - beat2); } SECTION("Modulo") { const auto beat1 = Beats{0.1}; const auto beat2 = Beats{0.5}; const auto beat3 = Beats{0.6}; const auto beat4 = Beats{0.}; CHECK(beat1 == beat3 % beat2); CHECK(beat4 == beat3 % beat4); } SECTION("SizeInByteStream") { Beats beats{0.5}; CHECK(8 == sizeInByteStream(beats)); } SECTION("RoundtripByteStreamEncoding") { Beats beats{0.5}; std::vector<std::uint8_t> bytes(sizeInByteStream(beats)); const auto end = toNetworkByteStream(beats, begin(bytes)); const auto result = Beats::fromNetworkByteStream(begin(bytes), end); CHECK(beats == result.first); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_Beats.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
655
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/link/TripleBuffer.hpp> #include <ableton/test/CatchWrapper.hpp> #include <array> #include <cstdint> #include <functional> #include <random> #include <thread> namespace ableton { namespace link { namespace { constexpr auto kNumTestOps = 1u << 18u; struct BigValue { BigValue(const uint32_t s) : seed{s} { // Generate random values to take some time and test read/write consistency. std::minstd_rand generator{s}; std::generate(values.begin(), values.end(), generator); } uint32_t seed; // Seed that identifies this value std::array<uint32_t, 40> values; // Seed-derived data larger than a cache line }; void writeValues(TripleBuffer<BigValue>& buffer, const uint32_t numOps) { for (uint32_t i = 0; i < numOps; ++i) { buffer.write(i); } } void readValues(TripleBuffer<BigValue>& buffer, const uint32_t numOps) { auto prevValueSeed = 0u; for (uint32_t i = 0; i < numOps; ++i) { const auto thisValue = buffer.read(); CHECK(thisValue.seed >= prevValueSeed); CHECK(thisValue.values == BigValue{thisValue.seed}.values); prevValueSeed = thisValue.seed; } } } // namespace TEST_CASE("TripleBuffer") { SECTION("Construction") { TripleBuffer<int> buffer; } SECTION("Reads default value before any writes") { TripleBuffer<int> buffer; CHECK(buffer.read() == int{}); CHECK(buffer.read() == int{}); CHECK(buffer.read() == int{}); } SECTION("Reads initial value before any writes") { TripleBuffer<int> buffer{42}; CHECK(buffer.read() == 42); CHECK(buffer.read() == 42); CHECK(buffer.read() == 42); } SECTION("Reads last written value") { TripleBuffer<int> buffer; buffer.write(42); CHECK(buffer.read() == 42); CHECK(buffer.read() == 42); CHECK(buffer.read() == 42); buffer.write(43); CHECK(buffer.read() == 43); CHECK(buffer.read() == 43); CHECK(buffer.read() == 43); buffer.write(44); CHECK(buffer.read() == 44); CHECK(buffer.read() == 44); CHECK(buffer.read() == 44); buffer.write(45); CHECK(buffer.read() == 45); CHECK(buffer.read() == 45); CHECK(buffer.read() == 45); } SECTION("Reads new last written value") { TripleBuffer<int> buffer; buffer.write(42); CHECK(*buffer.readNew() == 42); CHECK(!buffer.readNew()); CHECK(buffer.read() == 42); buffer.write(43); CHECK(buffer.read() == 43); CHECK(!buffer.readNew()); CHECK(buffer.read() == 43); buffer.write(44); CHECK(*buffer.readNew() == 44); CHECK(!buffer.readNew()); CHECK(buffer.read() == 44); buffer.write(45); CHECK(buffer.read() == 45); CHECK(!buffer.readNew()); CHECK(buffer.read() == 45); } SECTION("Threaded read and write") { TripleBuffer<BigValue> buffer{0u}; std::thread writer{writeValues, std::ref(buffer), kNumTestOps}; std::thread reader{readValues, std::ref(buffer), kNumTestOps}; writer.join(); reader.join(); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_TripleBuffer.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
945
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/link/Timeline.hpp> #include <ableton/test/CatchWrapper.hpp> namespace ableton { namespace link { TEST_CASE("Timeline") { const auto tl60 = Timeline{Tempo{60.}, Beats{-1.}, std::chrono::microseconds{1000000}}; const auto tl120 = Timeline{Tempo{120.}, Beats{5.5}, std::chrono::microseconds{12558940}}; SECTION("TimeToBeats") { CHECK(Beats{2.5} == tl60.toBeats(std::chrono::microseconds{4500000})); } SECTION("BeatsToTime") { CHECK(std::chrono::microseconds{5200000} == tl60.fromBeats(Beats{3.2})); } SECTION("RoundtripByteStreamEncoding") { std::vector<std::uint8_t> bytes(sizeInByteStream(tl120)); const auto end = toNetworkByteStream(tl120, begin(bytes)); const auto result = Timeline::fromNetworkByteStream(begin(bytes), end); CHECK(tl120 == result.first); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_Timeline.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
378
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/link/Tempo.hpp> #include <ableton/test/CatchWrapper.hpp> namespace ableton { namespace link { TEST_CASE("Tempo") { SECTION("ConstructFromBpm") { const auto tempo = Tempo{120.}; CHECK_THAT(120., Catch::Matchers::WithinAbs(tempo.bpm(), 1e-10)); CHECK(std::chrono::microseconds{500000} == tempo.microsPerBeat()); } SECTION("ConstructFromMicros") { const auto tempo = Tempo{std::chrono::microseconds{500000}}; CHECK_THAT(120., Catch::Matchers::WithinAbs(tempo.bpm(), 1e-10)); CHECK(std::chrono::microseconds{500000} == tempo.microsPerBeat()); } SECTION("MicrosToBeats") { const auto tempo = Tempo{120.}; CHECK(Beats{2.} == tempo.microsToBeats(std::chrono::microseconds{1000000})); } SECTION("BeatsToMicros") { const auto tempo = Tempo{120.}; CHECK(std::chrono::microseconds{1000000} == tempo.beatsToMicros(Beats{2.})); } SECTION("Comparison") { const auto tempo1 = Tempo{100.}; const auto tempo2 = Tempo{200.}; CHECK(tempo1 < tempo2); CHECK(tempo2 > tempo1); CHECK(tempo1 <= tempo2); CHECK(tempo2 <= tempo2); CHECK(tempo2 >= tempo1); CHECK(tempo2 >= tempo2); CHECK(Tempo{100.} == tempo1); CHECK(tempo1 != tempo2); } SECTION("RoundtripByteStreamEncoding") { const auto tempo = Tempo{120.}; std::vector<std::uint8_t> bytes(sizeInByteStream(tempo)); const auto end = toNetworkByteStream(tempo, begin(bytes)); const auto result = Tempo::fromNetworkByteStream(begin(bytes), end); CHECK(tempo == result.first); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/link/tst_Tempo.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
586
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/discovery/UdpMessenger.hpp> #include <ableton/discovery/test/Interface.hpp> #include <ableton/discovery/test/PayloadEntries.hpp> #include <ableton/test/CatchWrapper.hpp> #include <ableton/test/serial_io/Fixture.hpp> #include <array> namespace ableton { namespace discovery { namespace { struct TestNodeState { using IdType = uint8_t; IdType ident() const { return nodeId; } friend auto toPayload(const TestNodeState& state) -> decltype(makePayload(test::Foo{})) { return makePayload(test::Foo{state.fooVal}); } template <typename It> static TestNodeState fromPayload(const uint8_t id, It begin, It end) { TestNodeState state = {id, 0}; parsePayload<test::Foo>( begin, end, [&state](const test::Foo& foo) { state.fooVal = foo.fooVal; }); return state; } IdType nodeId; int32_t fooVal; }; struct TestHandler { void operator()(PeerState<TestNodeState> state) { peerStates.push_back(std::move(state)); } void operator()(ByeBye<TestNodeState::IdType> byeBye) { byeByes.push_back(std::move(byeBye)); } std::vector<PeerState<TestNodeState>> peerStates; std::vector<ByeBye<TestNodeState::IdType>> byeByes; }; template <typename Messenger> struct MessengerWrapper { MessengerWrapper(Messenger messenger) : mMessenger(std::move(messenger)) { } Messenger mMessenger; }; template <typename Messenger> MessengerWrapper<Messenger> wrapMessenger(Messenger messenger) { return {std::move(messenger)}; } } // anonymous namespace TEST_CASE("UdpMessenger") { const TestNodeState state1 = {5, 15}; const auto state2 = TestNodeState{3, 10}; const auto peerEndpoint = UdpEndpoint{IpAddress::from_string("123.123.234.234"), 1900}; ::ableton::test::serial_io::Fixture io; auto iface = test::Interface(UdpEndpoint{IpAddress::from_string("123.123.234.42"), 1234}); SECTION("BroadcastsStateOnConstruction") { auto messenger = makeUdpMessenger( util::injectRef(iface), state2, util::injectVal(io.makeIoContext()), 1, 1); REQUIRE(1 == iface.sentMessages.size()); const auto messageBuffer = iface.sentMessages[0].first; const auto sentTo = iface.sentMessages[0].second; const auto result = v1::parseMessageHeader<TestNodeState::IdType>( begin(messageBuffer), end(messageBuffer)); // Expect an Alive header CHECK(v1::kAlive == result.first.messageType); CHECK(state2.nodeId == result.first.ident); CHECK(1 == result.first.ttl); // Sent to the multicast endpoint CHECK(multicastEndpointV4() == sentTo); // And the payload should parse to equal to the original state const auto actualState = TestNodeState::fromPayload(state2.nodeId, result.second, end(messageBuffer)); CHECK(state2.fooVal == actualState.fooVal); } SECTION("Heartbeat") { auto messenger = makeUdpMessenger( util::injectRef(iface), state2, util::injectVal(io.makeIoContext()), 4, 2); REQUIRE(1 == iface.sentMessages.size()); // At two seconds the messenger should have broadcasted its state again io.advanceTime(std::chrono::seconds(3)); CHECK(2 == iface.sentMessages.size()); } SECTION("Response") { auto messenger = makeUdpMessenger( util::injectRef(iface), state2, util::injectVal(io.makeIoContext()), 1, 1); // Simulate state broadcast from peer, leaving out details like payload v1::MessageBuffer buffer; const auto messageEnd = v1::aliveMessage(state1.ident(), 0, makePayload(), begin(buffer)); iface.incomingMessage(peerEndpoint, begin(buffer), messageEnd); // The messenger should have responded to the alive message with its // current state REQUIRE(2 == iface.sentMessages.size()); const auto messageBuffer = iface.sentMessages[1].first; const auto sentTo = iface.sentMessages[1].second; const auto result = v1::parseMessageHeader<TestNodeState::IdType>( begin(messageBuffer), end(messageBuffer)); CHECK(v1::kResponse == result.first.messageType); CHECK(state2.nodeId == result.first.ident); CHECK(1 == result.first.ttl); CHECK(peerEndpoint == sentTo); } SECTION("Receive") { auto tmpMessenger = makeUdpMessenger( util::injectRef(iface), TestNodeState{}, util::injectVal(io.makeIoContext()), 1, 1); auto messenger = std::move(tmpMessenger); auto handler = TestHandler{}; messenger.receive(std::ref(handler)); v1::MessageBuffer buffer; // Receive an alive message auto end = v1::aliveMessage(state1.nodeId, 3, toPayload(state1), begin(buffer)); iface.incomingMessage(peerEndpoint, begin(buffer), end); // And a bye bye message end = v1::byeByeMessage(state1.nodeId, begin(buffer)); messenger.receive(std::ref(handler)); iface.incomingMessage(peerEndpoint, begin(buffer), end); REQUIRE(1 == handler.peerStates.size()); CHECK(3 == handler.peerStates[0].ttl); CHECK(state1.nodeId == handler.peerStates[0].peerState.nodeId); CHECK(state1.fooVal == handler.peerStates[0].peerState.fooVal); REQUIRE(1 == handler.byeByes.size()); CHECK(state1.nodeId == handler.byeByes[0].peerId); } SECTION("SendByeByeOnDestruction") { { auto messenger = makeUdpMessenger(util::injectRef(iface), TestNodeState{5, 10}, util::injectVal(io.makeIoContext()), 1, 1); } REQUIRE(2 == iface.sentMessages.size()); const auto messageBuffer = iface.sentMessages[1].first; const auto sentTo = iface.sentMessages[1].second; const auto result = v1::parseMessageHeader<TestNodeState::IdType>( begin(messageBuffer), end(messageBuffer)); CHECK(v1::kByeBye == result.first.messageType); CHECK(multicastEndpointV4() == sentTo); } SECTION("MovingMessengerDoesntSendByeBye") { // The destructor for the messenger is written so that if an // instance is moved from, it won't send the bye bye message. { auto messenger = makeUdpMessenger(util::injectRef(iface), TestNodeState{5, 10}, util::injectVal(io.makeIoContext()), 1, 1); auto wrapper = wrapMessenger(std::move(messenger)); } // We should have an initial Alive and then a single ByeBye CHECK(2 == iface.sentMessages.size()); } SECTION("DropMessageFromUnreachableNetwork") { auto tmpMessenger = makeUdpMessenger( util::injectRef(iface), TestNodeState{}, util::injectVal(io.makeIoContext()), 1, 1); auto messenger = std::move(tmpMessenger); auto handler = TestHandler{}; messenger.receive(std::ref(handler)); // Simulate state broadcast from peer, leaving out details like payload v1::MessageBuffer buffer; const auto messageEnd = v1::aliveMessage(state1.ident(), 0, makePayload(), begin(buffer)); iface.incomingMessage( UdpEndpoint{IpAddress::from_string("1.2.3.4"), 5678}, begin(buffer), messageEnd); // Received message should not be handled CHECK(0 == handler.peerStates.size()); } } } // namespace discovery } // namespace ableton ```
/content/code_sandbox/src/ableton/discovery/tst_UdpMessenger.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,911
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/discovery/InterfaceScanner.hpp> #include <ableton/test/CatchWrapper.hpp> #include <ableton/test/serial_io/Fixture.hpp> namespace ableton { namespace link { namespace { struct TestCallback { template <typename AddrRange> void operator()(AddrRange addrs) { addrRanges.emplace_back(begin(addrs), end(addrs)); } std::vector<std::vector<discovery::IpAddress>> addrRanges; }; } // anonymous namespace TEST_CASE("InterfaceScanner") { const auto addr1 = discovery::IpAddress::from_string("123.123.123.1"); const auto addr2 = discovery::IpAddress::from_string("123.123.123.2"); test::serial_io::Fixture io; auto callback = TestCallback{}; SECTION("NoInterfacesThenOneThenTwo") { { auto scanner = discovery::makeInterfaceScanner(std::chrono::seconds(2), util::injectRef(callback), util::injectVal(io.makeIoContext())); scanner.enable(true); CHECK(1 == callback.addrRanges.size()); io.setNetworkInterfaces({addr1}); io.advanceTime(std::chrono::seconds(3)); io.setNetworkInterfaces({addr1, addr2}); io.advanceTime(std::chrono::seconds(2)); } REQUIRE(3 == callback.addrRanges.size()); CHECK(0 == callback.addrRanges[0].size()); REQUIRE(1 == callback.addrRanges[1].size()); CHECK(addr1 == callback.addrRanges[1].front()); REQUIRE(2 == callback.addrRanges[2].size()); CHECK(addr1 == callback.addrRanges[2].front()); CHECK(addr2 == callback.addrRanges[2].back()); } SECTION("InterfaceGoesAway", "[InterfaceScanner]") { io.setNetworkInterfaces({addr1}); { auto scanner = discovery::makeInterfaceScanner(std::chrono::seconds(2), util::injectRef(callback), util::injectVal(io.makeIoContext())); scanner.enable(true); io.setNetworkInterfaces({}); io.advanceTime(std::chrono::seconds(3)); } REQUIRE(2 == callback.addrRanges.size()); REQUIRE(1 == callback.addrRanges[0].size()); CHECK(addr1 == callback.addrRanges[0].front()); CHECK(0 == callback.addrRanges[1].size()); } } } // namespace link } // namespace ableton ```
/content/code_sandbox/src/ableton/discovery/tst_InterfaceScanner.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
637
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/discovery/Payload.hpp> #include <ableton/discovery/test/PayloadEntries.hpp> #include <ableton/test/CatchWrapper.hpp> #include <ableton/util/Log.hpp> #include <array> namespace ableton { namespace discovery { TEST_CASE("Payload") { SECTION("EmptyPayload") { CHECK(0 == sizeInByteStream(makePayload())); CHECK(nullptr == toNetworkByteStream(makePayload(), nullptr)); } SECTION("FixedSizeEntryPayloadSize") { CHECK(12 == sizeInByteStream(makePayload(test::Foo{}))); } SECTION("SingleEntryPayloadEncoding") { const auto payload = makePayload(test::Foo{-1}); std::vector<char> bytes(sizeInByteStream(payload)); const auto end = toNetworkByteStream(payload, begin(bytes)); // Should have filled the buffer with the payload CHECK(bytes.size() == static_cast<size_t>(end - begin(bytes))); // Should have encoded the value 1 after the payload entry header // as an unsigned in network byte order const auto uresult = ntohl(reinterpret_cast<const std::uint32_t&>(*(begin(bytes) + 8))); CHECK(-1 == reinterpret_cast<const std::int32_t&>(uresult)); } SECTION("DoubleEntryPayloadSize") { CHECK(48 == sizeInByteStream(makePayload(test::Foo{}, test::Bar{{0, 1, 2}}))); } SECTION("DoubleEntryPayloadEncoding") { const auto payload = makePayload(test::Foo{1}, test::Bar{{0, 1, 2}}); std::vector<char> bytes(sizeInByteStream(payload)); const auto end = toNetworkByteStream(payload, begin(bytes)); // Should have filled the buffer with the payload CHECK(bytes.size() == static_cast<size_t>(end - begin(bytes))); // Should have encoded the value 1 after the first payload entry header // and the number of elements of the vector as well as 0,1,2 after the // second payload entry header in network byte order CHECK(1 == ntohl(reinterpret_cast<const std::uint32_t&>(*(begin(bytes) + 8)))); CHECK(3 == ntohl(reinterpret_cast<const std::uint32_t&>(*(begin(bytes) + 20)))); CHECK(0 == ntohll(reinterpret_cast<const std::uint64_t&>(*(begin(bytes) + 24)))); CHECK(1 == ntohll(reinterpret_cast<const std::uint64_t&>(*(begin(bytes) + 32)))); CHECK(2 == ntohll(reinterpret_cast<const std::uint64_t&>(*(begin(bytes) + 40)))); } SECTION("RoundtripSingleEntry") { const auto expected = test::Foo{1}; const auto payload = makePayload(expected); std::vector<char> bytes(sizeInByteStream(payload)); const auto end = toNetworkByteStream(payload, begin(bytes)); test::Foo actual{}; parsePayload<test::Foo>( begin(bytes), end, [&actual](const test::Foo& foo) { actual = foo; }); CHECK(expected.fooVal == actual.fooVal); } SECTION("RoundtripDoubleEntry") { const auto expectedFoo = test::Foo{1}; const auto expectedBar = test::Bar{{0, 1, 2}}; const auto payload = makePayload(expectedBar, expectedFoo); std::vector<char> bytes(sizeInByteStream(payload)); const auto end = toNetworkByteStream(payload, begin(bytes)); test::Foo actualFoo{}; test::Bar actualBar{}; parsePayload<test::Foo, test::Bar>(begin(bytes), end, [&actualFoo](const test::Foo& foo) { actualFoo = foo; }, [&actualBar](const test::Bar& bar) { actualBar = bar; }); CHECK(expectedFoo.fooVal == actualFoo.fooVal); CHECK(expectedBar.barVals == actualBar.barVals); } SECTION("RoundtripSingleEntryWithMultipleVectors") { const auto expectedFoobar = test::Foobar{{0, 1, 2}, {3, 4, 5}}; const auto payload = makePayload(expectedFoobar); std::vector<char> bytes(sizeInByteStream(payload)); const auto end = toNetworkByteStream(payload, begin(bytes)); test::Foobar actualFoobar{}; parsePayload<test::Foobar>(begin(bytes), end, [&actualFoobar](const test::Foobar& foobar) { actualFoobar = foobar; }); CHECK(expectedFoobar.asTuple() == actualFoobar.asTuple()); } SECTION("ParseSubset") { // Encode two payload entries const auto expectedFoo = test::Foo{1}; const auto expectedBar = test::Bar{{0, 1, 2}}; const auto payload = makePayload(expectedFoo, expectedBar); std::vector<char> bytes(sizeInByteStream(payload)); const auto end = toNetworkByteStream(payload, begin(bytes)); // Only decode one of them test::Bar actualBar{}; parsePayload<test::Bar>( begin(bytes), end, [&actualBar](const test::Bar& bar) { actualBar = bar; }); CHECK(expectedBar.barVals == actualBar.barVals); } SECTION("ParseTruncatedEntry") { const auto expectedFoo = test::Foo{1}; const auto expectedBar = test::Bar{{0, 1, 2}}; const auto payload = makePayload(expectedBar, expectedFoo); std::vector<char> bytes(sizeInByteStream(payload)); const auto end = toNetworkByteStream(payload, begin(bytes)); test::Foo actualFoo{}; test::Bar actualBar{}; REQUIRE_THROWS_AS(( // We truncate the buffer by one byte parsePayload<test::Foo, test::Bar>(begin(bytes), end - 1, [&actualFoo](const test::Foo& foo) { actualFoo = foo; }, [&actualBar](const test::Bar& bar) { actualBar = bar; })), std::runtime_error); // We expect that bar should be properly parsed but foo not CHECK(0 == actualFoo.fooVal); CHECK(expectedBar.barVals == actualBar.barVals); } SECTION("AddPayloads") { // The sum of a foo payload and a bar payload should be equal in // every way to a foobar payload const auto foo = test::Foo{1}; const auto bar = test::Bar{{0, 1, 2}}; const auto fooBarPayload = makePayload(foo, bar); const auto sumPayload = makePayload(foo) + makePayload(bar); REQUIRE(sizeInByteStream(fooBarPayload) == sizeInByteStream(sumPayload)); std::vector<char> fooBarBytes(sizeInByteStream(fooBarPayload)); std::vector<char> sumBytes(sizeInByteStream(sumPayload)); const auto fooBarEnd = toNetworkByteStream(fooBarPayload, begin(fooBarBytes)); toNetworkByteStream(sumPayload, begin(sumBytes)); CHECK(std::equal(begin(fooBarBytes), fooBarEnd, begin(sumBytes))); } } } // namespace discovery } // namespace ableton ```
/content/code_sandbox/src/ableton/discovery/tst_Payload.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,689
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/discovery/PeerGateway.hpp> #include <ableton/test/CatchWrapper.hpp> #include <ableton/test/serial_io/Fixture.hpp> #include <ableton/util/Log.hpp> namespace ableton { namespace discovery { namespace { struct TestNodeState : std::tuple<std::string, double> { TestNodeState(std::string ident, double tempo) : std::tuple<std::string, double>(std::move(ident), std::move(tempo)) { } std::string ident() const { return std::get<0>(*this); } }; struct TestMessenger { template <typename Handler> void receive(Handler handler) { receivePeerState = [handler](const PeerState<TestNodeState>& msg) { handler(msg); }; receiveByeBye = [handler](const ByeBye<std::string>& msg) { handler(msg); }; } std::function<void(const PeerState<TestNodeState>&)> receivePeerState; std::function<void(const ByeBye<std::string>&)> receiveByeBye; }; struct TestObserver { using GatewayObserverNodeState = TestNodeState; using GatewayObserverNodeId = std::string; friend void sawPeer(TestObserver& observer, const GatewayObserverNodeState& peer) { observer.mPeersSeen.push_back(peer); } friend void peerLeft(TestObserver& observer, const GatewayObserverNodeId& id) { observer.mPeersLeft.push_back(id); } friend void peerTimedOut(TestObserver& observer, const GatewayObserverNodeId& id) { observer.mPeersTimedOut.push_back(id); } std::vector<GatewayObserverNodeState> mPeersSeen; std::vector<GatewayObserverNodeId> mPeersLeft; std::vector<GatewayObserverNodeId> mPeersTimedOut; }; void expectPeersSeen(std::vector<TestNodeState> expected, const TestObserver& observer) { CHECK(expected == observer.mPeersSeen); } void expectPeersLeft(std::vector<std::string> expected, const TestObserver& observer) { CHECK(expected == observer.mPeersLeft); } void expectPeersTimedOut(std::vector<std::string> expected, const TestObserver& observer) { CHECK(expected == observer.mPeersTimedOut); } } // anonymous namespace TEST_CASE("PeerGateway") { const auto peerA = TestNodeState{"peerA", 120}; const auto peerB = TestNodeState{"peerB", 150}; test::serial_io::Fixture io; TestObserver observer; SECTION("NoActivity") { auto listener = makePeerGateway(util::injectVal(TestMessenger{}), util::injectRef(observer), util::injectVal(io.makeIoContext())); io.advanceTime(std::chrono::seconds(10)); // Without any outside interaction but the passage of time, our // listener should not have seen any peers. CHECK(observer.mPeersSeen.empty()); CHECK(observer.mPeersLeft.empty()); CHECK(observer.mPeersTimedOut.empty()); } TestMessenger messenger; auto listener = makePeerGateway(util::injectRef(messenger), util::injectRef(observer), util::injectVal(io.makeIoContext())); SECTION("ReceivedPeerState") { messenger.receivePeerState({peerA, 5}); io.flush(); expectPeersSeen({peerA}, observer); } SECTION("TwoPeersOneLeaves") { messenger.receivePeerState({peerA, 5}); messenger.receivePeerState({peerB, 5}); messenger.receiveByeBye({peerA.ident()}); io.flush(); expectPeersSeen({peerA, peerB}, observer); expectPeersLeft({peerA.ident()}, observer); } SECTION("TwoPeersOneTimesOut") { messenger.receivePeerState({peerA, 5}); messenger.receivePeerState({peerB, 10}); io.advanceTime(std::chrono::seconds(3)); expectPeersTimedOut({}, observer); io.advanceTime(std::chrono::seconds(4)); expectPeersTimedOut({peerA.ident()}, observer); } SECTION("PeerTimesOutAndIsSeenAgain") { messenger.receivePeerState({peerA, 5}); io.advanceTime(std::chrono::seconds(7)); expectPeersTimedOut({peerA.ident()}, observer); messenger.receivePeerState({peerA, 5}); io.advanceTime(std::chrono::seconds(3)); expectPeersSeen({peerA, peerA}, observer); expectPeersTimedOut({peerA.ident()}, observer); } } } // namespace discovery } // namespace ableton ```
/content/code_sandbox/src/ableton/discovery/tst_PeerGateway.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,148
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/discovery/PeerGateways.hpp> #include <ableton/test/CatchWrapper.hpp> #include <ableton/test/serial_io/Fixture.hpp> namespace ableton { namespace discovery { namespace { struct Gateway { IpAddress addr; }; struct NodeState { }; struct Factory { template <typename IoContext> Gateway operator()(NodeState, util::Injected<IoContext>, const IpAddress& addr) { return {addr}; } }; template <typename Gateways> void expectGateways( Gateways& gateways, test::serial_io::Fixture& io, std::vector<IpAddress> addrs) { using namespace std; using GatewayIt = typename Gateways::GatewayMap::iterator; bool bTested = false; gateways.withGateways([addrs, &bTested](GatewayIt begin, const GatewayIt end) { bTested = true; REQUIRE(static_cast<size_t>(distance(begin, end)) == addrs.size()); std::size_t i = 0; for (; begin != end; ++begin) { CHECK(begin->first == addrs[i++]); } }); io.flush(); CHECK(bTested); } } // anonymous namespace TEST_CASE("PeerGateways") { const IpAddress addr1 = IpAddress::from_string("192.192.192.1"); const IpAddress addr2 = IpAddress::from_string("192.192.192.2"); test::serial_io::Fixture io; auto pGateways = makePeerGateways( std::chrono::seconds(2), NodeState{}, Factory{}, util::injectVal(io.makeIoContext())); SECTION("EmptyIfNoInterfaces") { pGateways->enable(true); expectGateways(*pGateways, io, {}); } SECTION("MatchesAfterInitialScan") { io.setNetworkInterfaces({addr1, addr2}); pGateways->enable(true); expectGateways(*pGateways, io, {addr1, addr2}); } SECTION("GatewayAppears") { io.setNetworkInterfaces({addr1}); pGateways->enable(true); expectGateways(*pGateways, io, {addr1}); io.setNetworkInterfaces({addr1, addr2}); io.advanceTime(std::chrono::seconds(3)); expectGateways(*pGateways, io, {addr1, addr2}); } SECTION("GatewayDisappears") { io.setNetworkInterfaces({addr1, addr2}); pGateways->enable(true); expectGateways(*pGateways, io, {addr1, addr2}); io.setNetworkInterfaces({addr1}); io.advanceTime(std::chrono::seconds(3)); expectGateways(*pGateways, io, {addr1}); } SECTION("GatewayChangesAddress") { io.setNetworkInterfaces({addr1}); pGateways->enable(true); expectGateways(*pGateways, io, {addr1}); io.setNetworkInterfaces({addr2}); io.advanceTime(std::chrono::seconds(3)); expectGateways(*pGateways, io, {addr2}); } } } // namespace discovery } // namespace ableton ```
/content/code_sandbox/src/ableton/discovery/tst_PeerGateways.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
828
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include <ableton/discovery/v1/Messages.hpp> #include <ableton/test/CatchWrapper.hpp> #include <array> namespace ableton { namespace discovery { namespace v1 { namespace { // For testing just use a single byte identifier using NodeId = uint8_t; } // anonymous namespace TEST_CASE("ParseEmptyBuffer", "[Messages]") { const std::array<char, 0> buffer{}; auto result = parseMessageHeader<NodeId>(begin(buffer), end(buffer)); CHECK(kInvalid == result.first.messageType); CHECK(begin(buffer) == result.second); } TEST_CASE("ParseTruncatedMessageHeader", "[Messages]") { const std::array<char, 10> truncated = { {'_', 'a', 's', 'd', 'p', '_', 'v', 1, 'x', 'y'}}; const auto result = parseMessageHeader<NodeId>(begin(truncated), end(truncated)); CHECK(kInvalid == result.first.messageType); const auto consumedBytes = (begin(truncated) != result.second); CHECK_FALSE(consumedBytes); } TEST_CASE("MissingProtocolHeader", "[Messages]") { // Buffer should be large enough to proceed but shouldn't match the protocol header const std::array<char, 32> zeros{}; auto result = parseMessageHeader<NodeId>(begin(zeros), end(zeros)); CHECK(kInvalid == result.first.messageType); CHECK(begin(zeros) == result.second); } TEST_CASE("RoundtripAliveNoPayload", "[Messages]") { std::array<char, 32> buffer{}; const uint8_t ident = 1; const auto endAlive = aliveMessage(ident, 5, makePayload(), begin(buffer)); const auto result = parseMessageHeader<NodeId>(begin(buffer), endAlive); CHECK(endAlive == result.second); CHECK(kAlive == result.first.messageType); CHECK(5 == result.first.ttl); CHECK(ident == result.first.ident); } } // namespace v1 } // namespace discovery } // namespace ableton ```
/content/code_sandbox/src/ableton/discovery/v1/tst_Messages.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
557
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include "AudioPlatform.hpp" #include <algorithm> #include <atomic> #include <chrono> #include <iomanip> #include <iostream> #include <thread> #if defined(LINK_PLATFORM_UNIX) #include <termios.h> #endif namespace { struct State { std::atomic<bool> running; ableton::Link link; ableton::linkaudio::AudioPlatform audioPlatform; State() : running(true) , link(120.) , audioPlatform(link) { } }; void disableBufferedInput() { #if defined(LINK_PLATFORM_UNIX) termios t; tcgetattr(STDIN_FILENO, &t); t.c_lflag &= static_cast<unsigned long>(~ICANON); tcsetattr(STDIN_FILENO, TCSANOW, &t); #endif } void enableBufferedInput() { #if defined(LINK_PLATFORM_UNIX) termios t; tcgetattr(STDIN_FILENO, &t); t.c_lflag |= ICANON; tcsetattr(STDIN_FILENO, TCSANOW, &t); #endif } void clearLine() { std::cout << " \r" << std::flush; std::cout.fill(' '); } void printHelp() { std::cout << std::endl << " < L I N K H U T >" << std::endl << std::endl; std::cout << "usage:" << std::endl; std::cout << " enable / disable Link: a" << std::endl; std::cout << " start / stop: space" << std::endl; std::cout << " decrease / increase tempo: w / e" << std::endl; std::cout << " decrease / increase quantum: r / t" << std::endl; std::cout << " enable / disable start stop sync: s" << std::endl; std::cout << " quit: q" << std::endl << std::endl; } void printStateHeader() { std::cout << "enabled | num peers | quantum | start stop sync | tempo | beats | metro" << std::endl; } void printState(const std::chrono::microseconds time, const ableton::Link::SessionState sessionState, const bool linkEnabled, const std::size_t numPeers, const double quantum, const bool startStopSyncOn) { using namespace std; const auto enabled = linkEnabled ? "yes" : "no"; const auto beats = sessionState.beatAtTime(time, quantum); const auto phase = sessionState.phaseAtTime(time, quantum); const auto startStop = startStopSyncOn ? "yes" : "no"; const auto isPlaying = sessionState.isPlaying() ? "[playing]" : "[stopped]"; cout << defaultfloat << left << setw(7) << enabled << " | " << setw(9) << numPeers << " | " << setw(7) << quantum << " | " << setw(3) << startStop << " " << setw(11) << isPlaying << " | " << fixed << setw(7) << sessionState.tempo() << " | " << fixed << setprecision(2) << setw(7) << beats << " | "; for (int i = 0; i < ceil(quantum); ++i) { if (i < phase) { std::cout << 'X'; } else { std::cout << 'O'; } } clearLine(); } void input(State& state) { char in; for (;;) { #if defined(LINK_PLATFORM_WINDOWS) HANDLE stdinHandle = GetStdHandle(STD_INPUT_HANDLE); DWORD numCharsRead; INPUT_RECORD inputRecord; do { ReadConsoleInput(stdinHandle, &inputRecord, 1, &numCharsRead); } while ((inputRecord.EventType != KEY_EVENT) || inputRecord.Event.KeyEvent.bKeyDown); in = inputRecord.Event.KeyEvent.uChar.AsciiChar; #elif defined(LINK_PLATFORM_UNIX) in = static_cast<char>(std::cin.get()); #endif const auto tempo = state.link.captureAppSessionState().tempo(); auto& engine = state.audioPlatform.mEngine; switch (in) { case 'q': state.running = false; clearLine(); return; case 'a': state.link.enable(!state.link.isEnabled()); break; case 'w': engine.setTempo(tempo - 1); break; case 'e': engine.setTempo(tempo + 1); break; case 'r': engine.setQuantum(engine.quantum() - 1); break; case 't': engine.setQuantum(std::max(1., engine.quantum() + 1)); break; case 's': engine.setStartStopSyncEnabled(!engine.isStartStopSyncEnabled()); break; case ' ': if (engine.isPlaying()) { engine.stopPlaying(); } else { engine.startPlaying(); } break; } } } } // namespace int main(int, char**) { State state; printHelp(); printStateHeader(); std::thread thread(input, std::ref(state)); disableBufferedInput(); while (state.running) { const auto time = state.link.clock().micros(); auto sessionState = state.link.captureAppSessionState(); printState(time, sessionState, state.link.isEnabled(), state.link.numPeers(), state.audioPlatform.mEngine.quantum(), state.audioPlatform.mEngine.isStartStopSyncEnabled()); std::this_thread::sleep_for(std::chrono::milliseconds(10)); } enableBufferedInput(); thread.join(); return 0; } ```
/content/code_sandbox/examples/linkhut/main.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,380
```json dependencies: espressif/asio: component_hash: your_sha256_hash source: service_url: path_to_url type: service version: 1.14.1~3 idf: component_hash: null source: type: idf version: 5.1.1 manifest_hash: your_sha256_hash target: esp32 version: 1.0.0 ```
/content/code_sandbox/examples/esp32/dependencies.lock
json
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
98
```c++ #include <ableton/Link.hpp> #include <driver/gpio.h> #include <driver/gptimer.h> #include <esp_event.h> #include <freertos/FreeRTOS.h> #include <freertos/semphr.h> #include <freertos/task.h> #include <nvs_flash.h> #include <protocol_examples_common.h> #define LED GPIO_NUM_2 #define PRINT_LINK_STATE false unsigned int if_nametoindex(const char* ifName) { return 0; } char* if_indextoname(unsigned int ifIndex, char* ifName) { return nullptr; } void printTask(void* userParam) { auto link = static_cast<ableton::Link*>(userParam); const auto quantum = 4.0; while (true) { const auto sessionState = link->captureAppSessionState(); const auto numPeers = link->numPeers(); const auto time = link->clock().micros(); const auto beats = sessionState.beatAtTime(time, quantum); std::cout << std::defaultfloat << "| peers: " << numPeers << " | " << "tempo: " << sessionState.tempo() << " | " << std::fixed << "beats: " << beats << " |" << std::endl; vTaskDelay(800 / portTICK_PERIOD_MS); } } void tickTask(void* userParam) { ableton::Link link(120.0f); link.enable(true); if (PRINT_LINK_STATE) { xTaskCreate(printTask, "print", 8192, &link, 1, nullptr); } gpio_set_direction(LED, GPIO_MODE_OUTPUT); while (true) { const auto state = link.captureAudioSessionState(); const auto phase = state.phaseAtTime(link.clock().micros(), 1.); gpio_set_level(LED, fmodf(phase, 1.) < 0.1); vTaskDelay(1); } } extern "C" void app_main() { ESP_ERROR_CHECK(nvs_flash_init()); esp_netif_init(); ESP_ERROR_CHECK(esp_event_loop_create_default()); ESP_ERROR_CHECK(example_connect()); xTaskCreate(tickTask, "tick", 8192, nullptr, configMAX_PRIORITIES - 1, nullptr); } ```
/content/code_sandbox/examples/esp32/main/main.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
503
```yaml ## IDF Component Manager Manifest File dependencies: espressif/asio: "*" ## Required IDF version idf: version: ">=4.1.0" # # Put list of dependencies here # # For components maintained by Espressif: # component: "~1.0.0" # # For 3rd party components: # username/component: ">=1.0.0,<2.0.0" # username2/component2: # version: "~1.0.0" # # For transient dependencies `public` flag can be set. # # `public` flag doesn't have an effect dependencies of the `main` component. # # All dependencies of `main` are public by default. # public: true ```
/content/code_sandbox/examples/esp32/main/idf_component.yml
yaml
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
177
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #pragma once #include "AudioEngine.hpp" #include <ableton/link/HostTimeFilter.hpp> #include <ableton/platforms/Config.hpp> #include <jack/jack.h> namespace ableton { namespace linkaudio { class AudioPlatform { public: AudioPlatform(Link& link); ~AudioPlatform(); AudioEngine mEngine; private: static int audioCallback(jack_nframes_t nframes, void* pvUserData); int audioCallback(jack_nframes_t nframes); static void latencyCallback(jack_latency_callback_mode_t mode, void* pvUserData); void updateLatency(); void initialize(); void uninitialize(); void start(); void stop(); link::HostTimeFilter<link::platform::Clock> mHostTimeFilter; double mSampleTime; jack_client_t* mpJackClient; jack_port_t** mpJackPorts; }; } // namespace linkaudio } // namespace ableton ```
/content/code_sandbox/examples/linkaudio/AudioPlatform_Jack.hpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
320
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #pragma once #include "AudioEngine.hpp" #include <ableton/link/HostTimeFilter.hpp> #include <ableton/platforms/Config.hpp> #include <portaudio.h> namespace ableton { namespace linkaudio { class AudioPlatform { public: AudioPlatform(Link& link); ~AudioPlatform(); AudioEngine mEngine; private: static int audioCallback(const void* inputBuffer, void* outputBuffer, unsigned long inNumFrames, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void* userData); void initialize(); void uninitialize(); void start(); void stop(); link::HostTimeFilter<link::platform::Clock> mHostTimeFilter; double mSampleTime; PaStream* pStream; }; } // namespace linkaudio } // namespace ableton ```
/content/code_sandbox/examples/linkaudio/AudioPlatform_Portaudio.hpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
302
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include "AudioPlatform_CoreAudio.hpp" #include <chrono> #include <iostream> #include <mach/mach_time.h> namespace ableton { namespace linkaudio { AudioPlatform::AudioPlatform(Link& link) : mEngine(link) { initialize(); start(); } AudioPlatform::~AudioPlatform() { stop(); uninitialize(); } OSStatus AudioPlatform::audioCallback(void* inRefCon, AudioUnitRenderActionFlags*, const AudioTimeStamp* inTimeStamp, UInt32, UInt32 inNumberFrames, AudioBufferList* ioData) { AudioEngine* engine = static_cast<AudioEngine*>(inRefCon); const auto bufferBeginAtOutput = engine->mLink.clock().ticksToMicros(inTimeStamp->mHostTime) + engine->mOutputLatency.load(); engine->audioCallback(bufferBeginAtOutput, inNumberFrames); for (std::size_t i = 0; i < inNumberFrames; ++i) { for (UInt32 j = 0; j < ioData->mNumberBuffers; ++j) { SInt16* bufData = static_cast<SInt16*>(ioData->mBuffers[j].mData); bufData[i] = static_cast<SInt16>(32761. * engine->mBuffer[i]); } } return noErr; } void AudioPlatform::initialize() { AudioComponentDescription cd = {}; cd.componentManufacturer = kAudioUnitManufacturer_Apple; cd.componentFlags = 0; cd.componentFlagsMask = 0; cd.componentType = kAudioUnitType_Output; cd.componentSubType = kAudioUnitSubType_DefaultOutput; AudioComponent component = AudioComponentFindNext(nullptr, &cd); OSStatus result = AudioComponentInstanceNew(component, &mIoUnit); if (result) { std::cerr << "Could not get Audio Unit. " << result << std::endl; std::terminate(); } UInt32 size = sizeof(mEngine.mSampleRate); result = AudioUnitGetProperty(mIoUnit, kAudioUnitProperty_SampleRate, kAudioUnitScope_Output, 0, &mEngine.mSampleRate, &size); if (result) { std::cerr << "Could not get sample rate. " << result << std::endl; std::terminate(); } std::clog << "SAMPLE RATE: " << mEngine.mSampleRate << std::endl; AudioStreamBasicDescription asbd = {}; asbd.mFormatID = kAudioFormatLinearPCM; asbd.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsNonInterleaved; asbd.mChannelsPerFrame = 2; asbd.mBytesPerPacket = sizeof(SInt16); asbd.mFramesPerPacket = 1; asbd.mBytesPerFrame = sizeof(SInt16); asbd.mBitsPerChannel = 8 * sizeof(SInt16); asbd.mSampleRate = mEngine.mSampleRate; result = AudioUnitSetProperty(mIoUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &asbd, sizeof(asbd)); if (result) { std::cerr << "Could not set stream format. " << result << std::endl; } char deviceName[512]; size = sizeof(deviceName); result = AudioUnitGetProperty(mIoUnit, kAudioDevicePropertyDeviceName, kAudioUnitScope_Global, 0, &deviceName, &size); if (result) { std::cerr << "Could not get device name. " << result << std::endl; std::terminate(); } std::clog << "DEVICE NAME: " << deviceName << std::endl; UInt32 bufferSize = 512; size = sizeof(bufferSize); result = AudioUnitSetProperty(mIoUnit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0, &bufferSize, size); if (result) { std::cerr << "Could not set buffer size. " << result << std::endl; std::terminate(); } mEngine.setBufferSize(bufferSize); UInt32 propertyResult = 0; size = sizeof(propertyResult); result = AudioUnitGetProperty(mIoUnit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0, &propertyResult, &size); if (result) { std::cerr << "Could not get buffer size. " << result << std::endl; std::terminate(); } std::clog << "BUFFER SIZE: " << propertyResult << " samples, " << propertyResult / mEngine.mSampleRate * 1e3 << " ms." << std::endl; // the buffer, stream and safety-offset latencies are part of inTimeStamp->mHostTime // within the audio callback. UInt32 deviceLatency = 0; size = sizeof(deviceLatency); result = AudioUnitGetProperty(mIoUnit, kAudioDevicePropertyLatency, kAudioUnitScope_Output, 0, &deviceLatency, &size); if (result) { std::cerr << "Could not get output device latency. " << result << std::endl; std::terminate(); } std::clog << "OUTPUT DEVICE LATENCY: " << deviceLatency << " samples, " << deviceLatency / mEngine.mSampleRate * 1e3 << " ms." << std::endl; using namespace std::chrono; const double latency = static_cast<double>(deviceLatency) / mEngine.mSampleRate; mEngine.mOutputLatency.store(duration_cast<microseconds>(duration<double>{latency})); AURenderCallbackStruct ioRemoteInput; ioRemoteInput.inputProc = audioCallback; ioRemoteInput.inputProcRefCon = &mEngine; result = AudioUnitSetProperty(mIoUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &ioRemoteInput, sizeof(ioRemoteInput)); if (result) { std::cerr << "Could not set render callback. " << result << std::endl; } result = AudioUnitInitialize(mIoUnit); if (result) { std::cerr << "Could not initialize audio unit. " << result << std::endl; } } void AudioPlatform::uninitialize() { OSStatus result = AudioUnitUninitialize(mIoUnit); if (result) { std::cerr << "Could not uninitialize Audio Unit. " << result << std::endl; } } void AudioPlatform::start() { OSStatus result = AudioOutputUnitStart(mIoUnit); if (result) { std::cerr << "Could not start Audio Unit. " << result << std::endl; std::terminate(); } } void AudioPlatform::stop() { OSStatus result = AudioOutputUnitStop(mIoUnit); if (result) { std::cerr << "Could not stop Audio Unit. " << result << std::endl; } } } // namespace linkaudio } // namespace ableton ```
/content/code_sandbox/examples/linkaudio/AudioPlatform_CoreAudio.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,695
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include "AudioPlatform_Wasapi.hpp" #include <Comdef.h> #include <chrono> // WARNING: This file provides an audio driver for Windows using WASAPI. This driver is // considered experimental and has problems with low-latency playback. Please consider // using the ASIO driver instead. namespace ableton { namespace linkaudio { // GUID identifiers used to when looking up COM enumerators and devices static const IID kMMDeviceEnumeratorId = __uuidof(MMDeviceEnumerator); static const IID kIMMDeviceEnumeratorId = __uuidof(IMMDeviceEnumerator); static const IID kAudioClientId = __uuidof(IAudioClient); static const IID kAudioRenderClientId = __uuidof(IAudioRenderClient); // Controls how large the driver's ring buffer will be, expressed in terms of // 100-nanosecond units. This value also influences the overall driver latency. static const REFERENCE_TIME kBufferDuration = 1000000; // How long to block the runloop while waiting for an event callback. static const DWORD kWaitTimeoutInMs = 2000; void fatalError(HRESULT result, LPCTSTR context) { if (result > 0) { _com_error error(result); LPCTSTR errorMessage = error.ErrorMessage(); std::cerr << context << ": " << errorMessage << std::endl; } else { std::cerr << context << std::endl; } std::terminate(); } DWORD renderAudioRunloop(LPVOID lpParam) { AudioPlatform* platform = static_cast<AudioPlatform*>(lpParam); return platform->audioRunloop(); } AudioPlatform::AudioPlatform(Link& link) : mEngine(link) , mSampleTime(0) , mDevice(nullptr) , mAudioClient(nullptr) , mRenderClient(nullptr) , mStreamFormat(nullptr) , mEventHandle(nullptr) , mAudioThreadHandle(nullptr) , mIsRunning(false) { initialize(); mEngine.setBufferSize(bufferSize()); mEngine.setSampleRate(mStreamFormat->nSamplesPerSec); start(); } AudioPlatform::~AudioPlatform() { // WARNING: Here be dragons! // The WASAPI driver is not thread-safe, and crashes may occur when shutting down due // to these fields being concurrently accessed in the audio thread. Introducing a mutex // in the audio thread is not an appropriate solution to fix this race condition; a more // robust solution needs to be considered instead. if (mDevice != nullptr) { mDevice->Release(); } if (mAudioClient != nullptr) { mAudioClient->Release(); } if (mRenderClient != nullptr) { mRenderClient->Release(); } CoTaskMemFree(mStreamFormat); } UINT32 AudioPlatform::bufferSize() { UINT32 bufferSize; HRESULT result = mAudioClient->GetBufferSize(&bufferSize); if (FAILED(result)) { fatalError(result, "Could not get buffer size"); return 0; // not reached } return bufferSize; } void AudioPlatform::initialize() { HRESULT result = CoInitialize(nullptr); if (FAILED(result)) { fatalError(result, "Could not initialize COM library"); } IMMDeviceEnumerator* enumerator = nullptr; result = CoCreateInstance(kMMDeviceEnumeratorId, nullptr, CLSCTX_ALL, kIMMDeviceEnumeratorId, (void**)&enumerator); if (FAILED(result)) { fatalError(result, "Could not create device instance"); } result = enumerator->GetDefaultAudioEndpoint(eRender, eConsole, &(mDevice)); if (FAILED(result)) { fatalError(result, "Could not get default audio endpoint"); } else { enumerator->Release(); enumerator = nullptr; } result = mDevice->Activate(kAudioClientId, CLSCTX_ALL, nullptr, (void**)&(mAudioClient)); if (FAILED(result)) { fatalError(result, "Could not activate audio device"); } result = mAudioClient->GetMixFormat(&(mStreamFormat)); if (FAILED(result)) { fatalError(result, "Could not get mix format"); } if (mStreamFormat->wFormatTag == WAVE_FORMAT_EXTENSIBLE) { WAVEFORMATEXTENSIBLE* streamFormatEx = reinterpret_cast<WAVEFORMATEXTENSIBLE*>(mStreamFormat); if (streamFormatEx->SubFormat != KSDATAFORMAT_SUBTYPE_IEEE_FLOAT) { fatalError(0, "Sorry, only IEEE floating point streams are supported"); } } else { fatalError(0, "Sorry, only extensible wave streams are supported"); } result = mAudioClient->Initialize(AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, kBufferDuration, 0, mStreamFormat, nullptr); if (FAILED(result)) { fatalError(result, "Could not initialize audio device"); } mEventHandle = CreateEvent(nullptr, false, false, nullptr); if (mEventHandle == nullptr) { fatalError(result, "Could not create event handle"); } result = mAudioClient->GetService(kAudioRenderClientId, (void**)&(mRenderClient)); if (FAILED(result)) { fatalError(result, "Could not get audio render service"); } mIsRunning = true; LPTHREAD_START_ROUTINE threadEntryPoint = reinterpret_cast<LPTHREAD_START_ROUTINE>(renderAudioRunloop); mAudioThreadHandle = CreateThread(nullptr, 0, threadEntryPoint, this, 0, nullptr); if (mAudioThreadHandle == nullptr) { fatalError(GetLastError(), "Could not create audio thread"); } } void AudioPlatform::start() { UINT32 bufSize = bufferSize(); BYTE* buffer; HRESULT result = mRenderClient->GetBuffer(bufSize, &buffer); if (FAILED(result)) { fatalError(result, "Could not get render client buffer (in start audio engine)"); } result = mRenderClient->ReleaseBuffer(bufSize, 0); if (FAILED(result)) { fatalError(result, "Could not release buffer"); } result = mAudioClient->SetEventHandle(mEventHandle); if (FAILED(result)) { fatalError(result, "Could not set event handle to audio client"); } REFERENCE_TIME latency; result = mAudioClient->GetStreamLatency(&latency); if (FAILED(result)) { fatalError(result, "Could not get stream latency"); } result = mAudioClient->Start(); if (FAILED(result)) { fatalError(result, "Could not start audio client"); } } DWORD AudioPlatform::audioRunloop() { while (mIsRunning) { DWORD wait = WaitForSingleObject(mEventHandle, kWaitTimeoutInMs); if (wait != WAIT_OBJECT_0) { mIsRunning = false; mAudioClient->Stop(); return wait; } // Get the amount of padding, which basically is the amount of data in the driver's // ring buffer that is filled with unread data. Thus, subtracting this amount from // the buffer size gives the effective buffer size, which is the amount of frames // that can be safely written to the driver. UINT32 paddingFrames; HRESULT result = mAudioClient->GetCurrentPadding(&paddingFrames); if (FAILED(result)) { fatalError(result, "Could not get number of padding frames"); } const UINT32 numSamples = bufferSize() - paddingFrames; BYTE* buffer; result = mRenderClient->GetBuffer(numSamples, &buffer); if (FAILED(result)) { fatalError(result, "Could not get render client buffer (in callback)"); } const double sampleRate = static_cast<double>(mStreamFormat->nSamplesPerSec); using namespace std::chrono; const auto bufferDuration = duration_cast<microseconds>(duration<double>{numSamples / sampleRate}); const auto hostTime = mHostTimeFilter.sampleTimeToHostTime(mSampleTime); mSampleTime += numSamples; const auto bufferBeginAtOutput = hostTime + mEngine.mOutputLatency.load(); mEngine.audioCallback(bufferBeginAtOutput, numSamples); float* floatBuffer = reinterpret_cast<float*>(buffer); for (WORD i = 0; i < numSamples; ++i) { if (i >= mEngine.mBuffer.size()) { break; } for (WORD j = 0; j < mStreamFormat->nChannels; ++j) { floatBuffer[j + (i * mStreamFormat->nChannels)] = static_cast<float>(mEngine.mBuffer[i]); } } // Write the buffer to the audio driver and subsequently free the buffer memory result = mRenderClient->ReleaseBuffer(numSamples, 0); if (FAILED(result)) { fatalError(result, "Error rendering data"); } } // end of runloop mIsRunning = false; return 0; } // void fillBuffer(MetronomeSynth& metronome, // const UINT32 startFrame, // const UINT32 numSamples, // const UINT32 numChannels, // BYTE* buffer) //{ // float* floatBuffer = reinterpret_cast<float*>(buffer); // UINT32 frame = startFrame; // while (frame < numSamples * numChannels) // { // const float sample = static_cast<float>(metronome.getSample()); // for (UINT32 channel = 0; channel < numChannels; ++channel) // { // floatBuffer[frame++] = sample; // } // } //} } // namespace linkaudio } // namespace ableton ```
/content/code_sandbox/examples/linkaudio/AudioPlatform_Wasapi.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
2,232
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #pragma once #include "AudioEngine.hpp" #include <AudioToolbox/AudioToolbox.h> namespace ableton { namespace linkaudio { class AudioPlatform { public: AudioPlatform(Link& link); ~AudioPlatform(); AudioEngine mEngine; private: static OSStatus audioCallback(void* inRefCon, AudioUnitRenderActionFlags*, const AudioTimeStamp* inTimeStamp, UInt32, UInt32 inNumberFrames, AudioBufferList* ioData); void initialize(); void uninitialize(); void start(); void stop(); AudioUnit mIoUnit; }; } // namespace linkaudio } // namespace ableton ```
/content/code_sandbox/examples/linkaudio/AudioPlatform_CoreAudio.hpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
262
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #pragma once #include <ableton/Link.hpp> namespace ableton { namespace linkaudio { class AudioPlatform { class AudioEngine { public: AudioEngine(Link& link) : mLink(link) , mQuantum(4.) { } void startPlaying() { auto sessionState = mLink.captureAppSessionState(); sessionState.setIsPlayingAndRequestBeatAtTime(true, now(), 0., mQuantum); mLink.commitAppSessionState(sessionState); } void stopPlaying() { auto sessionState = mLink.captureAppSessionState(); sessionState.setIsPlaying(false, now()); mLink.commitAppSessionState(sessionState); } bool isPlaying() const { return mLink.captureAppSessionState().isPlaying(); } double beatTime() const { auto sessionState = mLink.captureAppSessionState(); return sessionState.beatAtTime(now(), mQuantum); } void setTempo(double tempo) { auto sessionState = mLink.captureAppSessionState(); sessionState.setTempo(tempo, now()); mLink.commitAppSessionState(sessionState); } double quantum() const { return mQuantum; } void setQuantum(double quantum) { mQuantum = quantum; } bool isStartStopSyncEnabled() const { return mLink.isStartStopSyncEnabled(); } void setStartStopSyncEnabled(bool enabled) { mLink.enableStartStopSync(enabled); } private: std::chrono::microseconds now() const { return mLink.clock().micros(); } Link& mLink; double mQuantum; }; public: AudioPlatform(Link& link) : mEngine(link) { } AudioEngine mEngine; }; } // namespace linkaudio } // namespace ableton ```
/content/code_sandbox/examples/linkaudio/AudioPlatform_Dummy.hpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
542
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #pragma once #include "AudioEngine.hpp" #include <Audioclient.h> #include <Mmdeviceapi.h> #include <ableton/link/HostTimeFilter.hpp> #include <atomic> // WARNING: This file provides an audio driver for Windows using WASAPI. This driver is // considered experimental and has problems with low-latency playback. Please consider // using the ASIO driver instead. namespace ableton { namespace linkaudio { // Convenience function to look up the human-readable WinAPI error code, print it out, // and then terminate the application. void fatalError(HRESULT result, LPCTSTR context); DWORD renderAudioRunloop(LPVOID); class AudioPlatform { public: AudioPlatform(Link& link); ~AudioPlatform(); DWORD audioRunloop(); AudioEngine mEngine; private: UINT32 bufferSize(); void initialize(); void start(); link::HostTimeFilter<platforms::windows::Clock> mHostTimeFilter; double mSampleTime; IMMDevice* mDevice; IAudioClient* mAudioClient; IAudioRenderClient* mRenderClient; WAVEFORMATEX* mStreamFormat; HANDLE mEventHandle; HANDLE mAudioThreadHandle; std::atomic<bool> mIsRunning; }; } // namespace linkaudio } // namespace ableton ```
/content/code_sandbox/examples/linkaudio/AudioPlatform_Wasapi.hpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
400
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #pragma once #if defined(LINKHUT_AUDIO_PLATFORM_ASIO) #include "AudioPlatform_Asio.hpp" #endif #if defined(LINKHUT_AUDIO_PLATFORM_COREAUDIO) #include "AudioPlatform_CoreAudio.hpp" #endif #if defined(LINKHUT_AUDIO_PLATFORM_DUMMY) #include "AudioPlatform_Dummy.hpp" #endif #if defined(LINKHUT_AUDIO_PLATFORM_JACK) #include "AudioPlatform_Jack.hpp" #endif #if defined(LINKHUT_AUDIO_PLATFORM_PORTAUDIO) #include "AudioPlatform_Portaudio.hpp" #endif #if defined(LINKHUT_AUDIO_PLATFORM_WASAPI) #include "AudioPlatform_Wasapi.hpp" #endif ```
/content/code_sandbox/examples/linkaudio/AudioPlatform.hpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
252
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #pragma once // Make sure to define this before <cmath> is included for Windows #define _USE_MATH_DEFINES #include <ableton/Link.hpp> #include <atomic> #include <mutex> namespace ableton { namespace linkaudio { class AudioEngine { public: AudioEngine(Link& link); void startPlaying(); void stopPlaying(); bool isPlaying() const; double beatTime() const; void setTempo(double tempo); double quantum() const; void setQuantum(double quantum); bool isStartStopSyncEnabled() const; void setStartStopSyncEnabled(bool enabled); private: struct EngineData { double requestedTempo; bool requestStart; bool requestStop; double quantum; bool startStopSyncOn; }; void setBufferSize(std::size_t size); void setSampleRate(double sampleRate); EngineData pullEngineData(); void renderMetronomeIntoBuffer(Link::SessionState sessionState, double quantum, std::chrono::microseconds beginHostTime, std::size_t numSamples); void audioCallback(const std::chrono::microseconds hostTime, std::size_t numSamples); Link& mLink; double mSampleRate; std::atomic<std::chrono::microseconds> mOutputLatency; std::vector<double> mBuffer; EngineData mSharedEngineData; EngineData mLockfreeEngineData; std::chrono::microseconds mTimeAtLastClick; bool mIsPlaying; std::mutex mEngineDataGuard; friend class AudioPlatform; }; } // namespace linkaudio } // namespace ableton ```
/content/code_sandbox/examples/linkaudio/AudioEngine.hpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
476
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include "AudioPlatform_Jack.hpp" #include <chrono> #include <iostream> #include <string> namespace ableton { namespace linkaudio { AudioPlatform::AudioPlatform(Link& link) : mEngine(link) , mSampleTime(0.) , mpJackClient(nullptr) , mpJackPorts(nullptr) { initialize(); start(); } AudioPlatform::~AudioPlatform() { stop(); uninitialize(); } int AudioPlatform::audioCallback(jack_nframes_t nframes, void* pvUserData) { AudioPlatform* pAudioPlatform = static_cast<AudioPlatform*>(pvUserData); return pAudioPlatform->audioCallback(nframes); } void AudioPlatform::latencyCallback(jack_latency_callback_mode_t, void* pvUserData) { AudioPlatform* pAudioPlatform = static_cast<AudioPlatform*>(pvUserData); pAudioPlatform->updateLatency(); } void AudioPlatform::updateLatency() { jack_latency_range_t latencyRange; jack_port_get_latency_range(mpJackPorts[0], JackPlaybackLatency, &latencyRange); mEngine.mOutputLatency.store( std::chrono::microseconds(llround(1.0e6 * latencyRange.max / mEngine.mSampleRate))); } int AudioPlatform::audioCallback(jack_nframes_t nframes) { using namespace std::chrono; AudioEngine& engine = mEngine; const auto hostTime = mHostTimeFilter.sampleTimeToHostTime(mSampleTime); mSampleTime += nframes; const auto bufferBeginAtOutput = hostTime + engine.mOutputLatency.load(); engine.audioCallback(bufferBeginAtOutput, nframes); for (int k = 0; k < 2; ++k) { float* buffer = static_cast<float*>(jack_port_get_buffer(mpJackPorts[k], nframes)); for (unsigned long i = 0; i < nframes; ++i) buffer[i] = static_cast<float>(engine.mBuffer[i]); } return 0; } void AudioPlatform::initialize() { jack_status_t status = JackFailure; mpJackClient = jack_client_open("LinkHut", JackNullOption, &status); if (mpJackClient == nullptr) { std::cerr << "Could not initialize Audio Engine. "; std::cerr << "JACK: " << std::endl; if (status & JackFailure) std::cerr << "Overall operation failed." << std::endl; if (status & JackInvalidOption) std::cerr << "Invalid or unsupported option." << std::endl; if (status & JackNameNotUnique) std::cerr << "Client name not unique." << std::endl; if (status & JackServerStarted) std::cerr << "Server is started." << std::endl; if (status & JackServerFailed) std::cerr << "Unable to connect to server." << std::endl; if (status & JackServerError) std::cerr << "Server communication error." << std::endl; if (status & JackNoSuchClient) std::cerr << "Client does not exist." << std::endl; if (status & JackLoadFailure) std::cerr << "Unable to load internal client." << std::endl; if (status & JackInitFailure) std::cerr << "Unable to initialize client." << std::endl; if (status & JackShmFailure) std::cerr << "Unable to access shared memory." << std::endl; if (status & JackVersionError) std::cerr << "Client protocol version mismatch." << std::endl; std::cerr << std::endl; std::terminate(); } const double bufferSize = jack_get_buffer_size(mpJackClient); const double sampleRate = jack_get_sample_rate(mpJackClient); mEngine.setBufferSize(static_cast<std::size_t>(bufferSize)); mEngine.setSampleRate(sampleRate); jack_set_latency_callback(mpJackClient, AudioPlatform::latencyCallback, this); mpJackPorts = new jack_port_t*[2]; for (int k = 0; k < 2; ++k) { const std::string port_name = "out_" + std::to_string(k + 1); mpJackPorts[k] = jack_port_register( mpJackClient, port_name.c_str(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); if (mpJackPorts[k] == nullptr) { std::cerr << "Could not get Audio Device. " << std::endl; jack_client_close(mpJackClient); std::terminate(); } } jack_set_process_callback(mpJackClient, AudioPlatform::audioCallback, this); } void AudioPlatform::uninitialize() { for (int k = 0; k < 2; ++k) { jack_port_unregister(mpJackClient, mpJackPorts[k]); mpJackPorts[k] = nullptr; } delete[] mpJackPorts; mpJackPorts = nullptr; jack_client_close(mpJackClient); mpJackClient = nullptr; } void AudioPlatform::start() { jack_activate(mpJackClient); const char** playback_ports = jack_get_ports( mpJackClient, nullptr, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput | JackPortIsPhysical); if (playback_ports) { const std::string client_name = jack_get_client_name(mpJackClient); for (int k = 0; k < 2; ++k) { const std::string port_name = "out_" + std::to_string(k + 1); const std::string client_port = client_name + ':' + port_name; jack_connect(mpJackClient, client_port.c_str(), playback_ports[k]); } jack_free(playback_ports); } } void AudioPlatform::stop() { jack_deactivate(mpJackClient); } } // namespace linkaudio } // namespace ableton ```
/content/code_sandbox/examples/linkaudio/AudioPlatform_Jack.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,400
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include "AudioEngine.hpp" // Make sure to define this before <cmath> is included for Windows #ifdef LINK_PLATFORM_WINDOWS #define _USE_MATH_DEFINES #endif #include <cmath> #include <iostream> namespace ableton { namespace linkaudio { AudioEngine::AudioEngine(Link& link) : mLink(link) , mSampleRate(44100.) , mOutputLatency(std::chrono::microseconds{0}) , mSharedEngineData({0., false, false, 4., false}) , mLockfreeEngineData(mSharedEngineData) , mTimeAtLastClick{} , mIsPlaying(false) { if (!mOutputLatency.is_lock_free()) { std::cout << "WARNING: AudioEngine::mOutputLatency is not lock free!" << std::endl; } } void AudioEngine::startPlaying() { std::lock_guard<std::mutex> lock(mEngineDataGuard); mSharedEngineData.requestStart = true; } void AudioEngine::stopPlaying() { std::lock_guard<std::mutex> lock(mEngineDataGuard); mSharedEngineData.requestStop = true; } bool AudioEngine::isPlaying() const { return mLink.captureAppSessionState().isPlaying(); } double AudioEngine::beatTime() const { const auto sessionState = mLink.captureAppSessionState(); return sessionState.beatAtTime(mLink.clock().micros(), mSharedEngineData.quantum); } void AudioEngine::setTempo(double tempo) { std::lock_guard<std::mutex> lock(mEngineDataGuard); mSharedEngineData.requestedTempo = tempo; } double AudioEngine::quantum() const { return mSharedEngineData.quantum; } void AudioEngine::setQuantum(double quantum) { std::lock_guard<std::mutex> lock(mEngineDataGuard); mSharedEngineData.quantum = quantum; } bool AudioEngine::isStartStopSyncEnabled() const { return mLink.isStartStopSyncEnabled(); } void AudioEngine::setStartStopSyncEnabled(const bool enabled) { mLink.enableStartStopSync(enabled); } void AudioEngine::setBufferSize(std::size_t size) { mBuffer = std::vector<double>(size, 0.); } void AudioEngine::setSampleRate(double sampleRate) { mSampleRate = sampleRate; } AudioEngine::EngineData AudioEngine::pullEngineData() { auto engineData = EngineData{}; if (mEngineDataGuard.try_lock()) { engineData.requestedTempo = mSharedEngineData.requestedTempo; mSharedEngineData.requestedTempo = 0; engineData.requestStart = mSharedEngineData.requestStart; mSharedEngineData.requestStart = false; engineData.requestStop = mSharedEngineData.requestStop; mSharedEngineData.requestStop = false; mLockfreeEngineData.quantum = mSharedEngineData.quantum; mLockfreeEngineData.startStopSyncOn = mSharedEngineData.startStopSyncOn; mEngineDataGuard.unlock(); } engineData.quantum = mLockfreeEngineData.quantum; return engineData; } void AudioEngine::renderMetronomeIntoBuffer(const Link::SessionState sessionState, const double quantum, const std::chrono::microseconds beginHostTime, const std::size_t numSamples) { using namespace std::chrono; // Metronome frequencies static const double highTone = 1567.98; static const double lowTone = 1108.73; // 100ms click duration static const auto clickDuration = duration<double>{0.1}; // The number of microseconds that elapse between samples const auto microsPerSample = 1e6 / mSampleRate; for (std::size_t i = 0; i < numSamples; ++i) { double amplitude = 0.; // Compute the host time for this sample and the last. const auto hostTime = beginHostTime + microseconds(llround(static_cast<double>(i) * microsPerSample)); const auto lastSampleHostTime = hostTime - microseconds(llround(microsPerSample)); // Only make sound for positive beat magnitudes. Negative beat // magnitudes are count-in beats. if (sessionState.beatAtTime(hostTime, quantum) >= 0.) { // If the phase wraps around between the last sample and the // current one with respect to a 1 beat quantum, then a click // should occur. if (sessionState.phaseAtTime(hostTime, 1) < sessionState.phaseAtTime(lastSampleHostTime, 1)) { mTimeAtLastClick = hostTime; } const auto secondsAfterClick = duration_cast<duration<double>>(hostTime - mTimeAtLastClick); // If we're within the click duration of the last beat, render // the click tone into this sample if (secondsAfterClick < clickDuration) { // If the phase of the last beat with respect to the current // quantum was zero, then it was at a quantum boundary and we // want to use the high tone. For other beats within the // quantum, use the low tone. const auto freq = floor(sessionState.phaseAtTime(hostTime, quantum)) == 0 ? highTone : lowTone; // Simple cosine synth amplitude = cos(2 * M_PI * secondsAfterClick.count() * freq) * (1 - sin(5 * M_PI * secondsAfterClick.count())); } } mBuffer[i] = amplitude; } } void AudioEngine::audioCallback( const std::chrono::microseconds hostTime, const std::size_t numSamples) { const auto engineData = pullEngineData(); auto sessionState = mLink.captureAudioSessionState(); // Clear the buffer std::fill(mBuffer.begin(), mBuffer.end(), 0); if (engineData.requestStart) { sessionState.setIsPlaying(true, hostTime); } if (engineData.requestStop) { sessionState.setIsPlaying(false, hostTime); } if (!mIsPlaying && sessionState.isPlaying()) { // Reset the timeline so that beat 0 corresponds to the time when transport starts sessionState.requestBeatAtStartPlayingTime(0, engineData.quantum); mIsPlaying = true; } else if (mIsPlaying && !sessionState.isPlaying()) { mIsPlaying = false; } if (engineData.requestedTempo > 0) { // Set the newly requested tempo from the beginning of this buffer sessionState.setTempo(engineData.requestedTempo, hostTime); } // Timeline modifications are complete, commit the results mLink.commitAudioSessionState(sessionState); if (mIsPlaying) { // As long as the engine is playing, generate metronome clicks in // the buffer at the appropriate beats. renderMetronomeIntoBuffer(sessionState, engineData.quantum, hostTime, numSamples); } } } // namespace linkaudio } // namespace ableton ```
/content/code_sandbox/examples/linkaudio/AudioEngine.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
1,687
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #pragma once #include "AudioEngine.hpp" #include <ableton/Link.hpp> #include <ableton/link/HostTimeFilter.hpp> #include "asiosys.h" // Should be included before asio.h #include "asio.h" #include "asiodrivers.h" // External functions in the ASIO SDK which aren't declared in the SDK headers extern AsioDrivers* asioDrivers; bool loadAsioDriver(char* name); namespace ableton { namespace linkaudio { #ifndef LINK_ASIO_DRIVER_NAME #define LINK_ASIO_DRIVER_NAME "ASIO4ALL v2" #endif #ifndef LINK_ASIO_INPUT_CHANNELS #define LINK_ASIO_INPUT_CHANNELS 0 #endif #ifndef LINK_ASIO_OUTPUT_CHANNELS #define LINK_ASIO_OUTPUT_CHANNELS 2 #endif struct DriverInfo { ASIODriverInfo driverInfo; long inputChannels; long outputChannels; long preferredSize; ASIOSampleRate sampleRate; bool outputReady; long numBuffers; ASIOBufferInfo bufferInfos[LINK_ASIO_INPUT_CHANNELS + LINK_ASIO_OUTPUT_CHANNELS]; ASIOChannelInfo channelInfos[LINK_ASIO_INPUT_CHANNELS + LINK_ASIO_OUTPUT_CHANNELS]; }; // Helper functions // Convenience function to print out an ASIO error code along with the function called void fatalError(const ASIOError result, const std::string& function); double asioSamplesToDouble(const ASIOSamples& samples); ASIOTime* bufferSwitchTimeInfo(ASIOTime* timeInfo, long index, ASIOBool); void bufferSwitch(long index, ASIOBool processNow); class AudioPlatform { public: AudioPlatform(Link& link); ~AudioPlatform(); void audioCallback(ASIOTime* timeInfo, long index); AudioEngine mEngine; // Unfortunately, the ASIO SDK does not allow passing void* user data to callback // functions, so we need to keep a singleton instance of the audio engine static AudioPlatform* singleton(); static void setSingleton(AudioPlatform* platform); private: void createAsioBuffers(); void initializeDriverInfo(); void initialize(); void start(); void stop(); DriverInfo mDriverInfo; ASIOCallbacks mAsioCallbacks; link::HostTimeFilter<platforms::windows::Clock> mHostTimeFilter; static AudioPlatform* _singleton; }; } // namespace linkaudio } // namespace ableton ```
/content/code_sandbox/examples/linkaudio/AudioPlatform_Asio.hpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
629
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include "AudioPlatform_Asio.hpp" namespace ableton { namespace linkaudio { void fatalError(const ASIOError result, const std::string& function) { std::cerr << "Call to ASIO function " << function << " failed"; if (result != ASE_OK) { std::cerr << " (ASIO error code " << result << ")"; } std::cerr << std::endl; std::terminate(); } double asioSamplesToDouble(const ASIOSamples& samples) { return samples.lo + samples.hi * std::pow(2, 32); } // ASIO processing callbacks ASIOTime* bufferSwitchTimeInfo(ASIOTime* timeInfo, long index, ASIOBool) { AudioPlatform* platform = AudioPlatform::singleton(); if (platform) { platform->audioCallback(timeInfo, index); } return nullptr; } void bufferSwitch(long index, ASIOBool processNow) { ASIOTime timeInfo{}; ASIOError result = ASIOGetSamplePosition( &timeInfo.timeInfo.samplePosition, &timeInfo.timeInfo.systemTime); if (result != ASE_OK) { std::cerr << "ASIOGetSamplePosition failed with ASIO error: " << result << std::endl; } else { timeInfo.timeInfo.flags = kSystemTimeValid | kSamplePositionValid; } bufferSwitchTimeInfo(&timeInfo, index, processNow); } AudioPlatform* AudioPlatform::_singleton = nullptr; AudioPlatform* AudioPlatform::singleton() { return _singleton; } void AudioPlatform::setSingleton(AudioPlatform* platform) { _singleton = platform; } AudioPlatform::AudioPlatform(Link& link) : mEngine(link) { initialize(); mEngine.setBufferSize(mDriverInfo.preferredSize); mEngine.setSampleRate(mDriverInfo.sampleRate); setSingleton(this); start(); } AudioPlatform::~AudioPlatform() { stop(); ASIODisposeBuffers(); ASIOExit(); if (asioDrivers != nullptr) { asioDrivers->removeCurrentDriver(); } setSingleton(nullptr); } void AudioPlatform::audioCallback(ASIOTime* timeInfo, long index) { auto hostTime = std::chrono::microseconds(0); if (timeInfo->timeInfo.flags & kSystemTimeValid) { hostTime = mHostTimeFilter.sampleTimeToHostTime( asioSamplesToDouble(timeInfo->timeInfo.samplePosition)); } const auto bufferBeginAtOutput = hostTime + mEngine.mOutputLatency.load(); ASIOBufferInfo* bufferInfos = mDriverInfo.bufferInfos; const long numSamples = mDriverInfo.preferredSize; const long numChannels = mDriverInfo.numBuffers; const double maxAmp = std::numeric_limits<int>::max(); mEngine.audioCallback(bufferBeginAtOutput, numSamples); for (long i = 0; i < numSamples; ++i) { for (long j = 0; j < numChannels; ++j) { int* buffer = static_cast<int*>(bufferInfos[j].buffers[index]); buffer[i] = static_cast<int>(mEngine.mBuffer[i] * maxAmp); } } if (mDriverInfo.outputReady) { ASIOOutputReady(); } } void AudioPlatform::createAsioBuffers() { DriverInfo& driverInfo = mDriverInfo; ASIOBufferInfo* bufferInfo = driverInfo.bufferInfos; driverInfo.numBuffers = 0; // Prepare input channels. Though this is not necessarily required, the opened input // channels will not work. int numInputBuffers; if (driverInfo.inputChannels > LINK_ASIO_INPUT_CHANNELS) { numInputBuffers = LINK_ASIO_INPUT_CHANNELS; } else { numInputBuffers = driverInfo.inputChannels; } for (long i = 0; i < numInputBuffers; ++i, ++bufferInfo) { bufferInfo->isInput = ASIOTrue; bufferInfo->channelNum = i; bufferInfo->buffers[0] = bufferInfo->buffers[1] = nullptr; } // Prepare output channels int numOutputBuffers; if (driverInfo.outputChannels > LINK_ASIO_OUTPUT_CHANNELS) { numOutputBuffers = LINK_ASIO_OUTPUT_CHANNELS; } else { numOutputBuffers = driverInfo.outputChannels; } for (long i = 0; i < numOutputBuffers; i++, bufferInfo++) { bufferInfo->isInput = ASIOFalse; bufferInfo->channelNum = i; bufferInfo->buffers[0] = bufferInfo->buffers[1] = nullptr; } driverInfo.numBuffers = numInputBuffers + numOutputBuffers; ASIOError result = ASIOCreateBuffers(driverInfo.bufferInfos, driverInfo.numBuffers, driverInfo.preferredSize, &(mAsioCallbacks)); if (result != ASE_OK) { fatalError(result, "ASIOCreateBuffers"); } // Now get all buffer details, sample word length, name, word clock group and latency for (long i = 0; i < driverInfo.numBuffers; ++i) { driverInfo.channelInfos[i].channel = driverInfo.bufferInfos[i].channelNum; driverInfo.channelInfos[i].isInput = driverInfo.bufferInfos[i].isInput; result = ASIOGetChannelInfo(&driverInfo.channelInfos[i]); if (result != ASE_OK) { fatalError(result, "ASIOGetChannelInfo"); } std::clog << "ASIOGetChannelInfo successful, type: " << (driverInfo.bufferInfos[i].isInput ? "input" : "output") << ", channel: " << i << ", sample type: " << driverInfo.channelInfos[i].type << std::endl; if (driverInfo.channelInfos[i].type != ASIOSTInt32LSB) { fatalError(ASE_OK, "Unsupported sample type!"); } } long inputLatency, outputLatency; result = ASIOGetLatencies(&inputLatency, &outputLatency); if (result != ASE_OK) { fatalError(result, "ASIOGetLatencies"); } std::clog << "Driver input latency: " << inputLatency << "usec" << ", output latency: " << outputLatency << "usec" << std::endl; const double bufferSize = driverInfo.preferredSize / driverInfo.sampleRate; auto outputLatencyMicros = std::chrono::microseconds(llround(outputLatency / driverInfo.sampleRate)); outputLatencyMicros += std::chrono::microseconds(llround(1.0e6 * bufferSize)); mEngine.mOutputLatency.store(outputLatencyMicros); std::clog << "Total latency: " << outputLatencyMicros.count() << "usec" << std::endl; } void AudioPlatform::initializeDriverInfo() { ASIOError result = ASIOGetChannels(&mDriverInfo.inputChannels, &mDriverInfo.outputChannels); if (result != ASE_OK) { fatalError(result, "ASIOGetChannels"); } std::clog << "ASIOGetChannels succeeded, inputs:" << mDriverInfo.inputChannels << ", outputs: " << mDriverInfo.outputChannels << std::endl; long minSize, maxSize, granularity; result = ASIOGetBufferSize(&minSize, &maxSize, &mDriverInfo.preferredSize, &granularity); if (result != ASE_OK) { fatalError(result, "ASIOGetBufferSize"); } std::clog << "ASIOGetBufferSize succeeded, min: " << minSize << ", max: " << maxSize << ", preferred: " << mDriverInfo.preferredSize << ", granularity: " << granularity << std::endl; result = ASIOGetSampleRate(&mDriverInfo.sampleRate); if (result != ASE_OK) { fatalError(result, "ASIOGetSampleRate"); } std::clog << "ASIOGetSampleRate succeeded, sampleRate: " << mDriverInfo.sampleRate << "Hz" << std::endl; // Check wether the driver requires the ASIOOutputReady() optimization, which can be // used by the driver to reduce output latency by one block mDriverInfo.outputReady = (ASIOOutputReady() == ASE_OK); std::clog << "ASIOOutputReady optimization is " << (mDriverInfo.outputReady ? "enabled" : "disabled") << std::endl; } void AudioPlatform::initialize() { if (!loadAsioDriver(LINK_ASIO_DRIVER_NAME)) { std::cerr << "Failed opening ASIO driver for device named '" << LINK_ASIO_DRIVER_NAME << "', is the driver installed?" << std::endl; std::terminate(); } ASIOError result = ASIOInit(&mDriverInfo.driverInfo); if (result != ASE_OK) { fatalError(result, "ASIOInit"); } std::clog << "ASIOInit succeeded, asioVersion: " << mDriverInfo.driverInfo.asioVersion << ", driverVersion: " << mDriverInfo.driverInfo.driverVersion << ", name: " << mDriverInfo.driverInfo.name << std::endl; initializeDriverInfo(); ASIOCallbacks* callbacks = &(mAsioCallbacks); callbacks->bufferSwitch = &bufferSwitch; callbacks->bufferSwitchTimeInfo = &bufferSwitchTimeInfo; createAsioBuffers(); } void AudioPlatform::start() { ASIOError result = ASIOStart(); if (result != ASE_OK) { fatalError(result, "ASIOStart"); } } void AudioPlatform::stop() { ASIOError result = ASIOStop(); if (result != ASE_OK) { fatalError(result, "ASIOStop"); } } } // namespace linkaudio } // namespace ableton ```
/content/code_sandbox/examples/linkaudio/AudioPlatform_Asio.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
2,313
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #include "AudioPlatform_Portaudio.hpp" #include <chrono> #include <iostream> namespace ableton { namespace linkaudio { AudioPlatform::AudioPlatform(Link& link) : mEngine(link) , mSampleTime(0.) { mEngine.setSampleRate(44100.); mEngine.setBufferSize(512); initialize(); start(); } AudioPlatform::~AudioPlatform() { stop(); uninitialize(); } int AudioPlatform::audioCallback(const void* /*inputBuffer*/, void* outputBuffer, unsigned long inNumFrames, const PaStreamCallbackTimeInfo* /*timeInfo*/, PaStreamCallbackFlags /*statusFlags*/, void* userData) { using namespace std::chrono; float* buffer = static_cast<float*>(outputBuffer); AudioPlatform& platform = *static_cast<AudioPlatform*>(userData); AudioEngine& engine = platform.mEngine; const auto hostTime = platform.mHostTimeFilter.sampleTimeToHostTime(platform.mSampleTime); platform.mSampleTime += static_cast<double>(inNumFrames); const auto bufferBeginAtOutput = hostTime + engine.mOutputLatency.load(); engine.audioCallback(bufferBeginAtOutput, inNumFrames); for (unsigned long i = 0; i < inNumFrames; ++i) { buffer[i * 2] = static_cast<float>(engine.mBuffer[i]); buffer[i * 2 + 1] = static_cast<float>(engine.mBuffer[i]); } return paContinue; } void AudioPlatform::initialize() { PaError result = Pa_Initialize(); if (result) { std::cerr << "Could not initialize Audio Engine. " << result << std::endl; std::terminate(); } PaStreamParameters outputParameters; outputParameters.device = Pa_GetDefaultOutputDevice(); if (outputParameters.device == paNoDevice) { std::cerr << "Could not get Audio Device. " << std::endl; std::terminate(); } outputParameters.channelCount = 2; outputParameters.sampleFormat = paFloat32; outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency; outputParameters.hostApiSpecificStreamInfo = nullptr; mEngine.mOutputLatency.store( std::chrono::microseconds(llround(outputParameters.suggestedLatency * 1.0e6))); result = Pa_OpenStream(&pStream, nullptr, &outputParameters, mEngine.mSampleRate, mEngine.mBuffer.size(), paClipOff, &audioCallback, this); if (result) { std::cerr << "Could not open stream. " << result << std::endl; std::terminate(); } if (!pStream) { std::cerr << "No valid audio stream." << std::endl; std::terminate(); } } void AudioPlatform::uninitialize() { PaError result = Pa_CloseStream(pStream); if (result) { std::cerr << "Could not close Audio Stream. " << result << std::endl; } Pa_Terminate(); if (!pStream) { std::cerr << "No valid audio stream." << std::endl; std::terminate(); } } void AudioPlatform::start() { PaError result = Pa_StartStream(pStream); if (result) { std::cerr << "Could not start Audio Stream. " << result << std::endl; } } void AudioPlatform::stop() { if (pStream == nullptr) { return; } PaError result = Pa_StopStream(pStream); if (result) { std::cerr << "Could not stop Audio Stream. " << result << std::endl; std::terminate(); } } } // namespace linkaudio } // namespace ableton ```
/content/code_sandbox/examples/linkaudio/AudioPlatform_Portaudio.cpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
948
```c++ * * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #pragma once #include <ableton/link/Phase.hpp> namespace ableton { namespace detail { template <typename Clock> inline typename BasicLink<Clock>::SessionState toSessionState( const link::ClientState& state, const bool isConnected) { return {{state.timeline, {state.startStopState.isPlaying, state.startStopState.time}}, isConnected}; } inline link::IncomingClientState toIncomingClientState(const link::ApiState& state, const link::ApiState& originalState, const std::chrono::microseconds timestamp) { const auto timeline = originalState.timeline != state.timeline ? link::OptionalTimeline{state.timeline} : link::OptionalTimeline{}; const auto startStopState = originalState.startStopState != state.startStopState ? link::OptionalClientStartStopState{{state.startStopState.isPlaying, state.startStopState.time, timestamp}} : link::OptionalClientStartStopState{}; return {timeline, startStopState, timestamp}; } } // namespace detail template <typename Clock> inline BasicLink<Clock>::BasicLink(const double bpm) : mController(link::Tempo(bpm), [this](const std::size_t peers) { std::lock_guard<std::mutex> lock(mCallbackMutex); mPeerCountCallback(peers); }, [this](const link::Tempo tempo) { std::lock_guard<std::mutex> lock(mCallbackMutex); mTempoCallback(tempo); }, [this](const bool isPlaying) { std::lock_guard<std::mutex> lock(mCallbackMutex); mStartStopCallback(isPlaying); }, mClock) { } template <typename Clock> inline bool BasicLink<Clock>::isEnabled() const { return mController.isEnabled(); } template <typename Clock> inline void BasicLink<Clock>::enable(const bool bEnable) { mController.enable(bEnable); } template <typename Clock> inline bool BasicLink<Clock>::isStartStopSyncEnabled() const { return mController.isStartStopSyncEnabled(); } template <typename Clock> inline void BasicLink<Clock>::enableStartStopSync(bool bEnable) { mController.enableStartStopSync(bEnable); } template <typename Clock> inline std::size_t BasicLink<Clock>::numPeers() const { return mController.numPeers(); } template <typename Clock> template <typename Callback> void BasicLink<Clock>::setNumPeersCallback(Callback callback) { std::lock_guard<std::mutex> lock(mCallbackMutex); mPeerCountCallback = [callback](const std::size_t numPeers) { callback(numPeers); }; } template <typename Clock> template <typename Callback> void BasicLink<Clock>::setTempoCallback(Callback callback) { std::lock_guard<std::mutex> lock(mCallbackMutex); mTempoCallback = [callback](const link::Tempo tempo) { callback(tempo.bpm()); }; } template <typename Clock> template <typename Callback> void BasicLink<Clock>::setStartStopCallback(Callback callback) { std::lock_guard<std::mutex> lock(mCallbackMutex); mStartStopCallback = callback; } template <typename Clock> inline Clock BasicLink<Clock>::clock() const { return mClock; } template <typename Clock> inline typename BasicLink<Clock>::SessionState BasicLink< Clock>::captureAudioSessionState() const { return detail::toSessionState<Clock>(mController.clientStateRtSafe(), numPeers() > 0); } template <typename Clock> inline void BasicLink<Clock>::commitAudioSessionState( const typename BasicLink<Clock>::SessionState state) { mController.setClientStateRtSafe( detail::toIncomingClientState(state.mState, state.mOriginalState, mClock.micros())); } template <typename Clock> inline typename BasicLink<Clock>::SessionState BasicLink<Clock>::captureAppSessionState() const { return detail::toSessionState<Clock>(mController.clientState(), numPeers() > 0); } template <typename Clock> inline void BasicLink<Clock>::commitAppSessionState( const typename BasicLink<Clock>::SessionState state) { mController.setClientState( detail::toIncomingClientState(state.mState, state.mOriginalState, mClock.micros())); } // Link::SessionState template <typename Clock> inline BasicLink<Clock>::SessionState::SessionState( const link::ApiState state, const bool bRespectQuantum) : mOriginalState(state) , mState(state) , mbRespectQuantum(bRespectQuantum) { } template <typename Clock> inline double BasicLink<Clock>::SessionState::tempo() const { return mState.timeline.tempo.bpm(); } template <typename Clock> inline void BasicLink<Clock>::SessionState::setTempo( const double bpm, const std::chrono::microseconds atTime) { const auto desiredTl = link::clampTempo( link::Timeline{link::Tempo(bpm), mState.timeline.toBeats(atTime), atTime}); mState.timeline.tempo = desiredTl.tempo; mState.timeline.timeOrigin = desiredTl.fromBeats(mState.timeline.beatOrigin); } template <typename Clock> inline double BasicLink<Clock>::SessionState::beatAtTime( const std::chrono::microseconds time, const double quantum) const { return link::toPhaseEncodedBeats(mState.timeline, time, link::Beats{quantum}) .floating(); } template <typename Clock> inline double BasicLink<Clock>::SessionState::phaseAtTime( const std::chrono::microseconds time, const double quantum) const { return link::phase(link::Beats{beatAtTime(time, quantum)}, link::Beats{quantum}) .floating(); } template <typename Clock> inline std::chrono::microseconds BasicLink<Clock>::SessionState::timeAtBeat( const double beat, const double quantum) const { return link::fromPhaseEncodedBeats( mState.timeline, link::Beats{beat}, link::Beats{quantum}); } template <typename Clock> inline void BasicLink<Clock>::SessionState::requestBeatAtTime( const double beat, std::chrono::microseconds time, const double quantum) { if (mbRespectQuantum) { time = timeAtBeat(link::nextPhaseMatch(link::Beats{beatAtTime(time, quantum)}, link::Beats{beat}, link::Beats{quantum}) .floating(), quantum); } forceBeatAtTime(beat, time, quantum); } inline void forceBeatAtTimeImpl(link::Timeline& timeline, const link::Beats beat, const std::chrono::microseconds time, const link::Beats quantum) { // There are two components to the beat adjustment: a phase shift // and a beat magnitude adjustment. const auto curBeatAtTime = link::toPhaseEncodedBeats(timeline, time, quantum); const auto closestInPhase = link::closestPhaseMatch(curBeatAtTime, beat, quantum); timeline = shiftClientTimeline(timeline, closestInPhase - curBeatAtTime); // Now adjust the magnitude timeline.beatOrigin = timeline.beatOrigin + beat - closestInPhase; } template <typename Clock> inline void BasicLink<Clock>::SessionState::forceBeatAtTime( const double beat, std::chrono::microseconds time, const double quantum) { forceBeatAtTimeImpl(mState.timeline, link::Beats{beat}, time, link::Beats{quantum}); // Due to quantization errors the resulting BeatTime at 'time' after forcing can be // bigger than 'beat' which then violates intended behavior of the API and can lead // i.e. to missing a downbeat. Thus we have to shift the timeline forwards. if (beatAtTime(time, quantum) > beat) { forceBeatAtTimeImpl(mState.timeline, link::Beats{beat}, ++time, link::Beats{quantum}); } } template <typename Clock> inline void BasicLink<Clock>::SessionState::setIsPlaying( const bool isPlaying, const std::chrono::microseconds time) { mState.startStopState = {isPlaying, time}; } template <typename Clock> inline bool BasicLink<Clock>::SessionState::isPlaying() const { return mState.startStopState.isPlaying; } template <typename Clock> inline std::chrono::microseconds BasicLink<Clock>::SessionState::timeForIsPlaying() const { return mState.startStopState.time; } template <typename Clock> inline void BasicLink<Clock>::SessionState::requestBeatAtStartPlayingTime( const double beat, const double quantum) { if (isPlaying()) { requestBeatAtTime(beat, mState.startStopState.time, quantum); } } template <typename Clock> inline void BasicLink<Clock>::SessionState::setIsPlayingAndRequestBeatAtTime( bool isPlaying, std::chrono::microseconds time, double beat, double quantum) { mState.startStopState = {isPlaying, time}; requestBeatAtStartPlayingTime(beat, quantum); } } // namespace ableton ```
/content/code_sandbox/include/ableton/Link.ipp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
2,133
```c++ /*! @file Link.hpp * @copyright 2016, Ableton AG, Berlin. All rights reserved. * @brief Library for cross-device shared tempo and quantized beat grid * * @license: * This program is free software: you can redistribute it and/or modify * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * along with this program. If not, see <path_to_url * * If you would like to incorporate Link into a proprietary software application, * please contact <link-devs@ableton.com>. */ #pragma once #include <ableton/platforms/Config.hpp> #include <chrono> #include <mutex> namespace ableton { /*! @class Link and BasicLink * @brief Classes representing a participant in a Link session. * The BasicLink type allows to customize the clock. The Link type * uses the recommended platform-dependent representation of the * system clock as defined in platforms/Config.hpp. * It's preferred to use Link instead of BasicLink. * * @discussion Each Link instance has its own session state which * represents a beat timeline and a transport start/stop state. The * timeline starts running from beat 0 at the initial tempo when * constructed. The timeline always advances at a speed defined by * its current tempo, even if transport is stopped. Synchronizing to the * transport start/stop state of Link is optional for every peer. * The transport start/stop state is only shared with other peers when * start/stop synchronization is enabled. * * A Link instance is initially disabled after construction, which * means that it will not communicate on the network. Once enabled, * a Link instance initiates network communication in an effort to * discover other peers. When peers are discovered, they immediately * become part of a shared Link session. * * Each method of the Link type documents its thread-safety and * realtime-safety properties. When a method is marked thread-safe, * it means it is safe to call from multiple threads * concurrently. When a method is marked realtime-safe, it means that * it does not block and is appropriate for use in the thread that * performs audio IO. * * Link provides one session state capture/commit method pair for use * in the audio thread and one for all other application contexts. In * general, modifying the session state should be done in the audio * thread for the most accurate timing results. The ability to modify * the session state from application threads should only be used in * cases where an application's audio thread is not actively running * or if it doesn't generate audio at all. Modifying the Link session * state from both the audio thread and an application thread * concurrently is not advised and will potentially lead to unexpected * behavior. * * Only use the BasicLink class if the default platform clock does not * fulfill other requirements of the client application. Please note this * will require providing a custom Clock implementation. See the clock() * documentation for details. */ template <typename Clock> class BasicLink { public: class SessionState; /*! @brief Construct with an initial tempo. */ BasicLink(double bpm); /*! @brief Link instances cannot be copied or moved */ BasicLink(const BasicLink<Clock>&) = delete; BasicLink& operator=(const BasicLink<Clock>&) = delete; BasicLink(BasicLink<Clock>&&) = delete; BasicLink& operator=(BasicLink<Clock>&&) = delete; /*! @brief Is Link currently enabled? * Thread-safe: yes * Realtime-safe: yes */ bool isEnabled() const; /*! @brief Enable/disable Link. * Thread-safe: yes * Realtime-safe: no */ void enable(bool bEnable); /*! @brief: Is start/stop synchronization enabled? * Thread-safe: yes * Realtime-safe: no */ bool isStartStopSyncEnabled() const; /*! @brief: Enable start/stop synchronization. * Thread-safe: yes * Realtime-safe: no */ void enableStartStopSync(bool bEnable); /*! @brief How many peers are currently connected in a Link session? * Thread-safe: yes * Realtime-safe: yes */ std::size_t numPeers() const; /*! @brief Register a callback to be notified when the number of * peers in the Link session changes. * Thread-safe: yes * Realtime-safe: no * * @discussion The callback is invoked on a Link-managed thread. * * @param callback The callback signature is: * void (std::size_t numPeers) */ template <typename Callback> void setNumPeersCallback(Callback callback); /*! @brief Register a callback to be notified when the session * tempo changes. * Thread-safe: yes * Realtime-safe: no * * @discussion The callback is invoked on a Link-managed thread. * * @param callback The callback signature is: void (double bpm) */ template <typename Callback> void setTempoCallback(Callback callback); /*! brief: Register a callback to be notified when the state of * start/stop isPlaying changes. * Thread-safe: yes * Realtime-safe: no * * @discussion The callback is invoked on a Link-managed thread. * * @param callback The callback signature is: * void (bool isPlaying) */ template <typename Callback> void setStartStopCallback(Callback callback); /*! @brief The clock used by Link. * Thread-safe: yes * Realtime-safe: yes * * @discussion The Clock type is a platform-dependent representation * of the system clock. It exposes a micros() method, which is a * normalized representation of the current system time in * std::chrono::microseconds. */ Clock clock() const; /*! @brief Capture the current Link Session State from the audio thread. * Thread-safe: no * Realtime-safe: yes * * @discussion This method should ONLY be called in the audio thread * and must not be accessed from any other threads. The returned * object stores a snapshot of the current Link Session State, so it * should be captured and used in a local scope. Storing the * Session State for later use in a different context is not advised * because it will provide an outdated view. */ SessionState captureAudioSessionState() const; /*! @brief Commit the given Session State to the Link session from the * audio thread. * Thread-safe: no * Realtime-safe: yes * * @discussion This method should ONLY be called in the audio * thread. The given Session State will replace the current Link * state. Modifications will be communicated to other peers in the * session. */ void commitAudioSessionState(SessionState state); /*! @brief Capture the current Link Session State from an application * thread. * Thread-safe: yes * Realtime-safe: no * * @discussion Provides a mechanism for capturing the Link Session * State from an application thread (other than the audio thread). * The returned Session State stores a snapshot of the current Link * state, so it should be captured and used in a local scope. * Storing the it for later use in a different context is not * advised because it will provide an outdated view. */ SessionState captureAppSessionState() const; /*! @brief Commit the given Session State to the Link session from an * application thread. * Thread-safe: yes * Realtime-safe: no * * @discussion The given Session State will replace the current Link * Session State. Modifications of the Session State will be * communicated to other peers in the session. */ void commitAppSessionState(SessionState state); /*! @class SessionState * @brief Representation of a timeline and the start/stop state * * @discussion A SessionState object is intended for use in a local scope within * a single thread - none of its methods are thread-safe. All of its methods are * non-blocking, so it is safe to use from a realtime thread. * It provides functions to observe and manipulate the timeline and start/stop * state. * * The timeline is a representation of a mapping between time and beats for varying * quanta. * The start/stop state represents the user intention to start or stop transport at * a specific time. Start stop synchronization is an optional feature that allows to * share the user request to start or stop transport between a subgroup of peers in * a Link session. When observing a change of start/stop state, audio playback of a * peer should be started or stopped the same way it would have happened if the user * had requested that change at the according time locally. The start/stop state can * only be changed by the user. This means that the current local start/stop state * persists when joining or leaving a Link session. After joining a Link session * start/stop change requests will be communicated to all connected peers. */ class SessionState { public: SessionState(const link::ApiState state, const bool bRespectQuantum); /*! @brief: The tempo of the timeline, in Beats Per Minute. * * @discussion This is a stable value that is appropriate for display * to the user. Beat time progress will not necessarily match this tempo * exactly because of clock drift compensation. */ double tempo() const; /*! @brief: Set the timeline tempo to the given bpm value, taking * effect at the given time. */ void setTempo(double bpm, std::chrono::microseconds atTime); /*! @brief: Get the beat value corresponding to the given time * for the given quantum. * * @discussion: The magnitude of the resulting beat value is * unique to this Link instance, but its phase with respect to * the provided quantum is shared among all session * peers. For non-negative beat values, the following * property holds: fmod(beatAtTime(t, q), q) == phaseAtTime(t, q) */ double beatAtTime(std::chrono::microseconds time, double quantum) const; /*! @brief: Get the session phase at the given time for the given * quantum. * * @discussion: The result is in the interval [0, quantum). The * result is equivalent to fmod(beatAtTime(t, q), q) for * non-negative beat values. This method is convenient if the * client is only interested in the phase and not the beat * magnitude. Also, unlike fmod, it handles negative beat values * correctly. */ double phaseAtTime(std::chrono::microseconds time, double quantum) const; /*! @brief: Get the time at which the given beat occurs for the * given quantum. * * @discussion: The inverse of beatAtTime, assuming a constant * tempo. beatAtTime(timeAtBeat(b, q), q) === b. */ std::chrono::microseconds timeAtBeat(double beat, double quantum) const; /*! @brief: Attempt to map the given beat to the given time in the * context of the given quantum. * * @discussion: This method behaves differently depending on the * state of the session. If no other peers are connected, * then this instance is in a session by itself and is free to * re-map the beat/time relationship whenever it pleases. In this * case, beatAtTime(time, quantum) == beat after this method has * been called. * * If there are other peers in the session, this instance * should not abruptly re-map the beat/time relationship in the * session because that would lead to beat discontinuities among * the other peers. In this case, the given beat will be mapped * to the next time value greater than the given time with the * same phase as the given beat. * * This method is specifically designed to enable the concept of * "quantized launch" in client applications. If there are no other * peers in the session, then an event (such as starting * transport) happens immediately when it is requested. If there * are other peers, however, we wait until the next time at which * the session phase matches the phase of the event, thereby * executing the event in-phase with the other peers in the * session. The client only needs to invoke this method to * achieve this behavior and should not need to explicitly check * the number of peers. */ void requestBeatAtTime(double beat, std::chrono::microseconds time, double quantum); /*! @brief: Rudely re-map the beat/time relationship for all peers * in a session. * * @discussion: DANGER: This method should only be needed in * certain special circumstances. Most applications should not * use it. It is very similar to requestBeatAtTime except that it * does not fall back to the quantizing behavior when it is in a * session with other peers. Calling this method will * unconditionally map the given beat to the given time and * broadcast the result to the session. This is very anti-social * behavior and should be avoided. * * One of the few legitimate uses of this method is to * synchronize a Link session with an external clock source. By * periodically forcing the beat/time mapping according to an * external clock source, a peer can effectively bridge that * clock into a Link session. Much care must be taken at the * application layer when implementing such a feature so that * users do not accidentally disrupt Link sessions that they may * join. */ void forceBeatAtTime(double beat, std::chrono::microseconds time, double quantum); /*! @brief: Set if transport should be playing or stopped, taking effect * at the given time. */ void setIsPlaying(bool isPlaying, std::chrono::microseconds time); /*! @brief: Is transport playing? */ bool isPlaying() const; /*! @brief: Get the time at which a transport start/stop occurs */ std::chrono::microseconds timeForIsPlaying() const; /*! @brief: Convenience function to attempt to map the given beat to the time * when transport is starting to play in context of the given quantum. * This function evaluates to a no-op if isPlaying() equals false. */ void requestBeatAtStartPlayingTime(double beat, double quantum); /*! @brief: Convenience function to start or stop transport at a given time and * attempt to map the given beat to this time in context of the given quantum. */ void setIsPlayingAndRequestBeatAtTime( bool isPlaying, std::chrono::microseconds time, double beat, double quantum); private: friend BasicLink<Clock>; link::ApiState mOriginalState; link::ApiState mState; bool mbRespectQuantum; }; private: using Controller = ableton::link::Controller<link::PeerCountCallback, link::TempoCallback, link::StartStopStateCallback, Clock, link::platform::Random, link::platform::IoContext>; std::mutex mCallbackMutex; link::PeerCountCallback mPeerCountCallback = [](std::size_t) {}; link::TempoCallback mTempoCallback = [](link::Tempo) {}; link::StartStopStateCallback mStartStopCallback = [](bool) {}; Clock mClock; Controller mController; }; class Link : public BasicLink<link::platform::Clock> { public: using Clock = link::platform::Clock; Link(double bpm) : BasicLink(bpm) { } }; } // namespace ableton #include <ableton/Link.ipp> ```
/content/code_sandbox/include/ableton/Link.hpp
c++
2016-02-03T16:19:24
2024-08-10T07:40:39
link
Ableton/link
1,073
3,773