Commit 605d5e56 authored by Rahix's avatar Rahix
Browse files

feat(hw-locks): Introduce new hw-lock API



Re-add a `hwlock_acquire()` method, but this time without a timeout
parameter.  From a functional point of view, this is just a wrapper
around `mutex_lock()`.

Additionally, add `hwlock_acquire_nonblock()` which behaves like
`mutex_trylock()`.

Signed-off-by: Rahix's avatarRahix <rahix@rahix.de>
parent 610a3048
......@@ -21,6 +21,22 @@ void hwlock_init(void)
}
}
void hwlock_acquire(enum hwlock_periph p)
{
assert(p < _HWLOCK_MAX);
mutex_lock(&hwlock_mutex[p]);
}
int hwlock_acquire_nonblock(enum hwlock_periph p)
{
assert(p < _HWLOCK_MAX);
if (mutex_trylock(&hwlock_mutex[p])) {
return 0;
} else {
return -EBUSY;
}
}
int hwlock_acquire_timeout(enum hwlock_periph p, TickType_t wait)
{
assert(p < _HWLOCK_MAX);
......
......@@ -98,6 +98,8 @@ enum hwlock_periph {
};
int hwlock_acquire_timeout(enum hwlock_periph p, TickType_t wait);
void hwlock_acquire(enum hwlock_periph p);
int hwlock_acquire_nonblock(enum hwlock_periph p);
void hwlock_release(enum hwlock_periph p);
/* ---------- Display ------------------------------------------------------ */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment