mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-10-31 15:11:40 +01:00 
			
		
		
		
	
		
			
	
	
		
			28 lines
		
	
	
		
			590 B
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			28 lines
		
	
	
		
			590 B
		
	
	
	
		
			C
		
	
	
	
	
	
|   | /*
 | ||
|  |  * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD | ||
|  |  * | ||
|  |  * SPDX-License-Identifier: Apache-2.0 | ||
|  |  */ | ||
|  | #include "ulp_riscv_lock.h"
 | ||
|  | #include "ulp_riscv_lock_shared.h"
 | ||
|  | 
 | ||
|  | #include <assert.h>
 | ||
|  | 
 | ||
|  | void ulp_riscv_lock_acquire(ulp_riscv_lock_t *lock) | ||
|  | { | ||
|  |     assert(lock); | ||
|  | 
 | ||
|  |     lock->critical_section_flag_main_cpu = true; | ||
|  |     lock->turn = ULP_RISCV_LOCK_TURN_ULP; | ||
|  | 
 | ||
|  |     while (lock->critical_section_flag_ulp && (lock->turn == ULP_RISCV_LOCK_TURN_ULP)) { | ||
|  |     } | ||
|  | } | ||
|  | 
 | ||
|  | void ulp_riscv_lock_release(ulp_riscv_lock_t *lock) | ||
|  | { | ||
|  |     assert(lock); | ||
|  | 
 | ||
|  |     lock->critical_section_flag_main_cpu = false; | ||
|  | } |