YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
lock_base_rp2350.h
1// ---------------------------------------------
2// This file is part of
3// _ _ __ _ _ __ __
4// ( \/ ) /__\ ( )_( ) /__\ ( )
5// \ / /(__)\ ) _ ( /(__)\ )(__
6// (__)(__)(__)(_) (_)(__)(__)(____)
7//
8// Yet Another HW Abstraction Library
9// Copyright (C) Andreas Terstegge
10// BSD Licensed (see file LICENSE)
11//
12// ---------------------------------------------
13//
14// Implementation of lock base interface for RP2350.
15//
16#ifndef _LOCK_BASE_RP2350_H
17#define _LOCK_BASE_RP2350_H
18
19#include "lock_base_interface.h"
20#include "RP2350.h"
21#include <cstdint>
22using namespace _SIO_;
23
25{
26 public:
28 ~lock_base_rp2350() override;
29
30 // No copy, no assignment
31 lock_base_rp2350 (const lock_base_rp2350 &) = delete;
32 lock_base_rp2350 & operator= (const lock_base_rp2350 &) = delete;
33
34 inline bool try_lock() override {
35 return *_lock;
36 }
37
38 inline void unlock() override {
39 *_lock = 1;
40 }
41
42 inline bool is_locked() override {
43 return SIO.SPINLOCK_ST & _mask;
44 }
45
46 private:
47 static uint32_t _index;
48 uint32_t _mask;
49 SPINLOCK_t * _lock;
50};
51
52#endif // _LOCK_BASE_RP2350_H