Select one of the symbols to view example projects that use it.
 
Outline
#include "hardware/sync/spin_lock.h"
spin_locks_reset()
spin_lock_init(uint)
_sw_spin_locks
#include "pico/runtime_init.h"
#include "hardware/structs/m33.h"
spinlock_set_extexclall()
__pre_init_spinlock_set_extexclall
Files
loading...
SourceVuRaspberry Pi Pico SDK and ExamplesPicoSDKsrc/rp2_common/hardware_sync_spin_lock/sync_spin_lock.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * Copyright (c) 2024 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause *//* ... */ #include "hardware/sync/spin_lock.h" void spin_locks_reset(void) { for (uint i = 0; i < NUM_SPIN_LOCKS; i++) { spin_unlock_unsafe(spin_lock_instance(i)); }for (uint i = 0; i < NUM_SPIN_LOCKS; i++) { ... } }{ ... } spin_lock_t *spin_lock_init(uint lock_num) { assert(lock_num < NUM_SPIN_LOCKS); spin_lock_t *lock = spin_lock_instance(lock_num); spin_unlock_unsafe(lock); return lock; }{ ... } #if PICO_USE_SW_SPIN_LOCKS spin_lock_t _sw_spin_locks[NUM_SPIN_LOCKS]; #if __ARM_ARCH_8M_MAIN__ && !PICO_SW_SPIN_LOCKS_NO_EXTEXCLALL #include "pico/runtime_init.h" #include "hardware/structs/m33.h" static void spinlock_set_extexclall(void) { // Force use of global exclusive monitor for all exclusive load/stores: // makes multicore exclusives work without adding MPU regions. For // something more exotic, like having multicore exclusives in internal // SRAM and also single-core exclusives in external PSRAM (not covered by // the global monitor on RP2350) you must clear this and add your own // Shareable regions. // // Setting PICO_SW_SPIN_LOCKS_NO_EXTEXCLALL == 1 will disable this code m33_hw->actlr |= M33_ACTLR_EXTEXCLALL_BITS; }{ ... } // PICO_RUNTIME_INIT_SPIN_LOCKS_RESET is fine as resetting them does not require EXTEXCLALL PICO_RUNTIME_INIT_FUNC_PER_CORE(spinlock_set_extexclall, PICO_RUNTIME_INIT_SPIN_LOCKS_RESET);/* ... */ #endif/* ... */ #endif
Details