1/***************************************************************************//** 2* \file cy_syslib_ext.S 3* \version 2.70 4* 5* \brief Assembly routines for GNU GCC. 6* 7******************************************************************************** 8* \copyright 9* Copyright 2016-2020 Cypress Semiconductor Corporation 10* SPDX-License-Identifier: Apache-2.0 11* 12* Licensed under the Apache License, Version 2.0 (the "License"); 13* you may not use this file except in compliance with the License. 14* You may obtain a copy of the License at 15* 16* http://www.apache.org/licenses/LICENSE-2.0 17* 18* Unless required by applicable law or agreed to in writing, software 19* distributed under the License is distributed on an "AS IS" BASIS, 20* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21* See the License for the specific language governing permissions and 22* limitations under the License. 23*******************************************************************************/ 24 25.syntax unified 26.text 27.thumb 28 29 30/******************************************************************************* 31* Function Name: Cy_SysLib_DelayCycles 32****************************************************************************//** 33* 34* Delays for the specified number of cycles. 35* 36* \param uint32_t cycles: The number of cycles to delay. 37* 38*******************************************************************************/ 39/* void Cy_SysLib_DelayCycles(uint32_t cycles) */ 40.align 3 /* Align to 8 byte boundary (2^n) */ 41.global Cy_SysLib_DelayCycles 42.func Cy_SysLib_DelayCycles, Cy_SysLib_DelayCycles 43.type Cy_SysLib_DelayCycles, %function 44.thumb_func 45Cy_SysLib_DelayCycles: /* cycles bytes */ 46 47 ADDS r0, r0, #2 /* 1 2 Round to nearest multiple of 4 */ 48 LSRS r0, r0, #2 /* 1 2 Divide by 4 and set flags */ 49 BEQ Cy_DelayCycles_done /* 2 2 Skip if 0 */ 50 51Cy_DelayCycles_loop: 52 ADDS r0, r0, #1 /* 1 2 Increment counter */ 53 SUBS r0, r0, #2 /* 1 2 Decrement counter by 2 */ 54 BNE Cy_DelayCycles_loop /* (1)2 2 2 CPU cycles (if branch is taken) */ 55 NOP /* 1 2 Loop alignment padding */ 56 57Cy_DelayCycles_done: 58 NOP /* 1 2 Loop alignment padding */ 59 BX lr /* 3 2 */ 60 61.endfunc 62 63/******************************************************************************* 64* Function Name: Cy_SysLib_EnterCriticalSection 65****************************************************************************//** 66* 67* Cy_SysLib_EnterCriticalSection disables interrupts and returns a value 68* indicating whether interrupts were previously enabled. 69* 70* Note Implementation of Cy_SysLib_EnterCriticalSection manipulates the IRQ 71* enable bit with interrupts still enabled. 72* 73* \return Returns 0 if interrupts were previously enabled or 1 if interrupts 74* were previously disabled. 75* 76*******************************************************************************/ 77/* uint8_t Cy_SysLib_EnterCriticalSection(void) */ 78.global Cy_SysLib_EnterCriticalSection 79.func Cy_SysLib_EnterCriticalSection, Cy_SysLib_EnterCriticalSection 80.type Cy_SysLib_EnterCriticalSection, %function 81.thumb_func 82 83Cy_SysLib_EnterCriticalSection: 84 MRS r0, PRIMASK /* Save and return interrupt state */ 85 cpsid i /* Disable interrupts */ 86 BX lr 87 88.endfunc 89 90 91/******************************************************************************* 92* Function Name: Cy_SysLib_ExitCriticalSection 93****************************************************************************//** 94* 95* Re-enables interrupts if they were enabled before 96* Cy_SysLib_EnterCriticalSection() was called. The argument should be the value 97* returned from \ref Cy_SysLib_EnterCriticalSection(). 98* 99* \param uint8_t savedIntrStatus: 100* Saved interrupt status returned by the \ref Cy_SysLib_EnterCriticalSection(). 101* 102*******************************************************************************/ 103/* void Cy_SysLib_ExitCriticalSection(uint8_t savedIntrStatus) */ 104.global Cy_SysLib_ExitCriticalSection 105.func Cy_SysLib_ExitCriticalSection, Cy_SysLib_ExitCriticalSection 106.type Cy_SysLib_ExitCriticalSection, %function 107.thumb_func 108 109Cy_SysLib_ExitCriticalSection: 110 MSR PRIMASK, r0 /* Restore interrupt state */ 111 BX lr 112 113.endfunc 114 115.end 116 117/* [] END OF FILE */ 118