mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-28 17:11:23 +02:00
Use mutex/semaphores for emulation, like in Pico and ESP.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -63,6 +63,7 @@ extern bool tud_hid_n_report(uint8_t itf, uint8_t report_id, const uint8_t *buff
|
||||
#endif
|
||||
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
typedef struct {
|
||||
pthread_mutex_t mtx;
|
||||
pthread_cond_t cnd;
|
||||
@@ -156,4 +157,14 @@ extern pthread_t hcore0, hcore1;
|
||||
#define multicore_launch_core1(a) pthread_create(&hcore1, NULL, (void *(*) (void *))a, NULL)
|
||||
#define multicore_reset_core1()
|
||||
|
||||
typedef pthread_mutex_t mutex_t;
|
||||
typedef sem_t semaphore_t;
|
||||
#define mutex_init(a) pthread_mutex_init(a, NULL)
|
||||
#define mutex_try_enter(a,b) (pthread_mutex_trylock(a) == 0)
|
||||
#define mutex_enter_blocking(a) pthread_mutex_lock(a)
|
||||
#define mutex_exit(a) pthread_mutex_unlock(a)
|
||||
#define sem_release(a) sem_post(a)
|
||||
#define sem_acquire_blocking(a) sem_wait(a)
|
||||
#define multicore_lockout_victim_init() (void)0
|
||||
|
||||
#endif // _EMULATION_H_
|
||||
|
||||
Reference in New Issue
Block a user