mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-26 16:15:11 +02:00
Attempting to add support to esp32s3.
Will it work? Who knows... Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
67
src/esp_compat.h
Normal file
67
src/esp_compat.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of the Pico Keys SDK distribution (https://github.com/polhenarejos/pico-keys-sdk).
|
||||
* Copyright (c) 2022 Pol Henarejos.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __ESP_COMPAT_H_
|
||||
#define __ESP_COMPAT_H_
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include "freertos/freertos.h"
|
||||
#include "freertos/queue.h"
|
||||
typedef QueueHandle_t queue_t;
|
||||
#define queue_init(a,b,c) do { *(a) = xQueueCreate(c, b); } while(0)
|
||||
#define queue_add_blocking(a,b) xQueueSend(*(a), b, portMAX_DELAY)
|
||||
#define queue_try_add(a,b) xQueueSend(*(a), b, 0)
|
||||
#define queue_is_empty(a) (uxQueueMessagesWaiting(*(a)) == 0)
|
||||
#define queue_try_remove(a,b) xQueueReceive(*(a), b, 0)
|
||||
extern TaskHandle_t hcore0, hcore1;
|
||||
#define multicore_launch_core1(a) xTaskCreate(a, "core1", 512, NULL, tskIDLE_PRIORITY, &hcore1)
|
||||
#define multicore_reset_core1 vTaskEndScheduler
|
||||
#define sleep_ms(a) vTaskDelay(a / portTICK_PERIOD_MS)
|
||||
#define board_millis xTaskGetTickCount
|
||||
#define PICO_UNIQUE_BOARD_ID_SIZE_BYTES 8
|
||||
typedef struct { uint8_t id[PICO_UNIQUE_BOARD_ID_SIZE_BYTES]; } pico_unique_board_id_t;
|
||||
#define pico_get_unique_board_id(a) memset(a, 0, sizeof(pico_unique_board_id_t))
|
||||
#define pico_get_unique_board_id_string(a, b) \
|
||||
do { \
|
||||
pico_unique_board_id_t t; \
|
||||
pico_get_unique_board_id(&t); \
|
||||
snprintf(a, b, "%02X%02X%02X%02X%02X%02X%02X%02X", t.id[0], t.id[1], t.id[2], t.id[3], t.id[4], t.id[5], t.id[6], t.id[7]); } while(0)
|
||||
typedef SemaphoreHandle_t mutex_t;
|
||||
typedef SemaphoreHandle_t semaphore_t;
|
||||
#define mutex_init(a) do { *(a) = xSemaphoreCreateMutex();} while(0)
|
||||
#define mutex_try_enter(a,b) xSemaphoreTake(*(a), 0)
|
||||
#define mutex_enter_blocking(a) xSemaphoreTake(*(a), portMAX_DELAY)
|
||||
#define mutex_exit(a) xSemaphoreGive(*(a))
|
||||
#define sem_init(a,b,c) do { *(a) = xSemaphoreCreateCounting(c, b); } while(0)
|
||||
#define sem_release(a) xSemaphoreGive(*(a))
|
||||
#define sem_acquire_blocking(a) xSemaphoreTake(*(a), portMAX_DELAY)
|
||||
#define multicore_lockout_victim_init() (void)0
|
||||
static inline bool multicore_lockout_start_timeout_us(int a) {
|
||||
vTaskSuspend(hcore1); return true; }
|
||||
static inline bool multicore_lockout_end_timeout_us(int a) {
|
||||
vTaskResume(hcore1); return true; }
|
||||
#define save_and_disable_interrupts() 1
|
||||
|
||||
#include "esp_partition.h"
|
||||
extern esp_partition_t part0;
|
||||
#define flash_range_erase(a,b) esp_partition_erase_range(&part0, a, b)
|
||||
#define flash_range_program(a,b,c) esp_partition_write(&part0, a, b, c)
|
||||
#define restore_interrupts(a) (void)a
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user