Skip to content
Snippets Groups Projects
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: default avatarRahix <rahix@rahix.de>
parent 610a3048
No related branches found
No related tags found
No related merge requests found
......@@ -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 ------------------------------------------------------ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment