mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-18 13:43:58 +00:00
Implement locking using FreeRTOS compatibility layer from TinyGo
This commit is contained in:
@@ -17,6 +17,8 @@ package espnet
|
|||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
|
import _ "compat/freertos"
|
||||||
|
|
||||||
type ESPWiFi struct {
|
type ESPWiFi struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-14
@@ -2,6 +2,8 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "espnet.h"
|
#include "espnet.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/semphr.h"
|
||||||
|
|
||||||
// Stub functions, to know which functions need to be implemented for OS
|
// Stub functions, to know which functions need to be implemented for OS
|
||||||
// functionality.
|
// functionality.
|
||||||
@@ -70,27 +72,17 @@ static void *_mutex_create(void) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// simplified mutex to continue with call stack
|
|
||||||
unsigned int mutx = 0;
|
|
||||||
|
|
||||||
static void *_recursive_mutex_create(void) {
|
static void *_recursive_mutex_create(void) {
|
||||||
printf("called: _recursive_mutex_create. ret=%p\n", &mutx);
|
return xSemaphoreCreateRecursiveMutex();
|
||||||
return &mutx;
|
|
||||||
}
|
}
|
||||||
static void _mutex_delete(void *mutex) {
|
static void _mutex_delete(void *mutex) {
|
||||||
printf("called: _mutex_delete: %p\n", mutex);
|
return vSemaphoreDelete(mutex);
|
||||||
}
|
}
|
||||||
static int32_t _mutex_lock(void *mutex) {
|
static int32_t _mutex_lock(void *mutex) {
|
||||||
printf("called: _mutex_lock: %p (%d)\n", mutex, *(unsigned int*)mutex);
|
return (int32_t)xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
|
||||||
// simplified mutex to continue with call stack
|
|
||||||
*(unsigned int*)mutex = 1;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
static int32_t _mutex_unlock(void *mutex) {
|
static int32_t _mutex_unlock(void *mutex) {
|
||||||
printf("called: _mutex_unlock: %p (%d)\n", mutex, *(unsigned int*)mutex);
|
return (int32_t)xSemaphoreGiveRecursive(mutex);
|
||||||
// simplified mutex to continue with call stack
|
|
||||||
*(unsigned int*)mutex = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
static void * _queue_create(uint32_t queue_len, uint32_t item_size) {
|
static void * _queue_create(uint32_t queue_len, uint32_t item_size) {
|
||||||
printf("called: _queue_create\n");
|
printf("called: _queue_create\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user