[core] Update Arduino compatibility
This commit is contained in:
@@ -1,6 +1,27 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-06-14. */
|
||||
/* Copyright (c) Kuba Szczodrzyński 2023-03-02. */
|
||||
|
||||
#pragma once
|
||||
|
||||
// Provide GPIO names to variant.cpp files
|
||||
#define LT_VARIANT_INCLUDE "gpio_pub.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
extern void vPortClearInterruptMask(uint32_t ulNewMaskValue);
|
||||
extern uint32_t ulPortSetInterruptMask(void);
|
||||
|
||||
// TODO
|
||||
// #define clockCyclesPerMicrosecond() (SystemCoreClock / 1000000L)
|
||||
// #define clockCyclesToMicroseconds(a) (a * 1000L / (SystemCoreClock / 1000L))
|
||||
// #define microsecondsToClockCycles(a) (a * (SystemCoreClock / 1000000L))
|
||||
|
||||
#define interrupts() vPortClearInterruptMask(0)
|
||||
#define noInterrupts() ulPortSetInterruptMask()
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
// LibreTuya C API (with C standard libraries)
|
||||
#include <libretuya.h>
|
||||
|
||||
// Additional C libraries
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
// C++ standard libraries
|
||||
#ifdef __cplusplus
|
||||
#include <algorithm>
|
||||
|
||||
@@ -29,6 +29,10 @@ extern "C" {
|
||||
#define attachInterruptArg attachInterruptParam
|
||||
#define voidFuncPtrArg voidFuncPtrParam
|
||||
|
||||
// Additional Arduino compatibility macros
|
||||
#define round(x) ((x) >= 0 ? (long)((x) + 0.5) : (long)((x)-0.5))
|
||||
#define digitalPinToInterrupt(pin) (pin)
|
||||
|
||||
// FreeRTOS utilities
|
||||
#if LT_HAS_FREERTOS
|
||||
// if xCoreID < 0 or CPU is unicore, it will use xTaskCreate, else xTaskCreatePinnedToCore
|
||||
|
||||
Reference in New Issue
Block a user