Initial commit of firmware

This commit is contained in:
2025-04-12 13:30:57 +01:00
commit 264a3462e0
374 changed files with 332649 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
/***************************************************************************//**
* @file
* @brief API "assert" implementation.
*******************************************************************************
* # License
* <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_ASSERT_H
#define SL_ASSERT_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(DOXY_DOC_ONLY)
/** Included for documentation purposes only. This define is not present by default.
* DEBUG_EFM should be defined from the compiler to enable the default internal
* assert handler. */
#define DEBUG_EFM
#endif
#if defined(DEBUG_EFM) || defined(DEBUG_EFM_USER)
/***************************************************************************//**
* @addtogroup assert ASSERT - Assert
* @brief Assert/error checking module
* @details
* By default, library assert usage is not included to reduce
* footprint and processing overhead. Further, assert usage is decoupled
* from ISO C assert handling (NDEBUG usage) to allow using ISO C
* assert without including assert statements.
*
* Below are available defines for controlling assert inclusion. The defines
* are typically for a project to be used by the preprocessor.
*
* @li If DEBUG_EFM is defined, the internal library assert handling will
* be used. This is implemented as a simple while(true) loop. DEBUG_EFM is not
* defined by default.
*
* @li If DEBUG_EFM_USER is defined, the user must provide custom
* implementation of the assertEFM() function.
*
* @li If both DEBUG_EFM and DEBUG_EFM_USER are undefined, all EFM_ASSERT()
* statements are not operational.
*
* @note
* The internal assert is documented because DEBUG_EFM is defined in
* the doxygen configuration.
* @{
******************************************************************************/
/* Due to footprint considerations, we only pass file name and line number, */
/* not the assert expression (nor function name (C99)) */
/***************************************************************************//**
* @brief
* Assert function for EFM.
* @param[in] file - path and file name of the assert.
*
* @param[in] line - line number, in the file.
******************************************************************************/
void assertEFM(const char *file, int line);
/** Default assertion is not operational */
#define EFM_ASSERT(expr) ((expr) ? ((void)0) : assertEFM(__FILE__, __LINE__))
#else
/** Default assertion is not operational */
#define EFM_ASSERT(expr) ((void)(expr))
#endif /* defined(DEBUG_EFM) || defined(DEBUG_EFM_USER) */
/** @} (end addtogroup assert) */
#ifdef __cplusplus
}
#endif
#endif /* SL_ASSERT_H */

View File

@@ -0,0 +1,80 @@
/*******************************************************************************
* @file
* @brief Implementation of atomic operations.
*******************************************************************************
* # License
* <b>Copyright 2019 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_ATOMIC_H
#define SL_ATOMIC_H
/*******************************************************************************
* @addtogroup atomic Atomic Operations
* @brief Atomic operations provide RAM store and read functionalities.
* @n @section atomic_usage Atomic Operations Usage
* @{
******************************************************************************/
/***************************************************************************//**
* @brief Perform an atomic load. Use when a variable must be read from
* RAM.
*
* @param dest Variable where to copy the loaded value.
*
* @param source Variable from where to load the value.
*
* @note Does only support native types <= 32 bits.
*
* @note Load operation on 32 bit value is atomic on ARM architecture.
*
* @note Only the load operation from 'source' is guaranteed to be
* performed atomically. If writing to 'dest' implies a store,
* the load and store operations are not guaranteed to be
* performed atomically.
******************************************************************************/
#define sl_atomic_load(dest, source) ((dest) = (source))
/*******************************************************************************
* @brief Perform an atomic store. Use when a value must be stored in
* RAM.
*
* @param dest Variable where to store the value.
*
* @param source Variable that contains the value to store in 'dest'.
*
* @note Does only support native types <= 32 bits.
*
* @note Store operation on 32 bit value is atomic on ARM architecture.
*
* @note Only the store operation to 'dest' is guaranteed to be
* performed atomically. If reading from 'source' implies a load,
* the store and load operations are not guaranteed to be
* performed atomically.
******************************************************************************/
#define sl_atomic_store(dest, source) ((dest) = (source))
/** @} (end addtogroup atomic) */
#endif /* SL_ATOMIC_H */

View File

@@ -0,0 +1,189 @@
/***************************************************************************//**
* @file
* @brief Implementation of bit operations.
*******************************************************************************
* # License
* <b>Copyright 2019 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_BIT_H
#define SL_BIT_H
/***************************************************************************//**
* @addtogroup bit Bit Manipulation
* @brief Bitwise operations
* @{
******************************************************************************/
/****************************************************************************************************//**
* SL_DEF_BIT()
*
* @brief Create bit mask with single, specified bit set.
*
* @param bit Bit number of bit to set.
*
* @return Bit mask with single, specified bit set.
*
* @note (1) 'bit' SHOULD be a non-negative integer.
*
* @note (2) 'bit' values that overflow the target CPU &/or compiler environment (e.g. negative
* or greater-than-CPU-data-size values) MAY generate compiler warnings &/or errors.
*******************************************************************************************************/
#define SL_DEF_BIT(bit) (1u << (bit))
/****************************************************************************************************//**
* SL_SET_BIT()
*
* @brief Set specified bit(s) in a value.
*
* @param val Value to modify by setting specified bit(s).
*
* @param mask Mask of bits to set.
*
* @return Modified value with specified bit(s) set.
*
* @note 'val' & 'mask' SHOULD be unsigned integers.
*******************************************************************************************************/
#define SL_SET_BIT(val, mask) ((val) = ((val) | (mask)))
/****************************************************************************************************//**
* SL_CLEAR_BIT()
*
* @brief Clear specified bit(s) in a value.
*
* @param val Value to modify by clearing specified bit(s).
*
* @param mask Mask of bits to clear.
*
* @return Modified value with specified bit(s) clear.
*
* @note 'val' & 'mask' SHOULD be unsigned integers.
*
* @note 'mask' SHOULD be cast with the same data type than 'val'.
*******************************************************************************************************/
#define SL_CLEAR_BIT(val, mask) ((val) = ((val) & (~(mask))))
/****************************************************************************************************//**
* SL_IS_BIT_SET()
*
* @brief Determine whether the specified bit(s) in a value are set.
*
* @param val Value to check for specified bit(s) set.
*
* @param mask Mask of bits to check if set.
*
* @return true, if ALL specified bit(s) are set in value.
*
* false, if ALL specified bit(s) are NOT set in value.
*
* @note 'val' & 'mask' SHOULD be unsigned integers.
*
* @note NULL 'mask' allowed; returns 'false' since NO mask bits specified.
*******************************************************************************************************/
#define SL_IS_BIT_SET(val, mask) (((((val) & (mask)) == (mask)) && ((mask) != 0u)) ? (true) : (false))
/****************************************************************************************************//**
* SL_IS_BIT_CLEAR()
*
* @brief Determine whether the specified bit(s) in a value are clear.
*
* @param val Value to check for specified bit(s) clear.
*
* @param mask Mask of bits to check if clear.
*
* @return true, if ALL specified bit(s) are clear in value.
*
* false, if ALL specified bit(s) are NOT clear in value.
*
* @note val' & 'mask' SHOULD be unsigned integers.
*
* @note NULL 'mask' allowed; returns 'false' since NO mask bits specified.
*******************************************************************************************************/
#define SL_IS_BIT_CLEAR(val, mask) (((((val) & (mask)) == 0u) && ((mask) != 0u)) ? (true) : (false))
/****************************************************************************************************//**
* SL_IS_ANY_BIT_SET()
*
* @brief Determine whether any specified bit(s) in a value are set.
*
* @param val Value to check for specified bit(s) set.
*
* @param mask Mask of bits to check if set (see Note #2).
*
* @return true, if ANY specified bit(s) are set in value.
*
* false, if ALL specified bit(s) are NOT set in value.
*
* @note 'val' & 'mask' SHOULD be unsigned integers.
*
* @note NULL 'mask' allowed; returns 'false' since NO mask bits specified.
*******************************************************************************************************/
#define SL_IS_ANY_BIT_SET(val, mask) ((((val) & (mask)) == 0u) ? (false) : (true))
/****************************************************************************************************//**
* SL_IS_ANY_BIT_CLEAR()
*
* @brief Determine whether any specified bit(s) in a value are clear.
*
* @param val Value to check for specified bit(s) clear.
*
* @param mask Mask of bits to check if clear (see Note #2).
*
* @return true, if ANY specified bit(s) are clear in value.
*
* false, if ALL specified bit(s) are NOT clear in value.
*
* @note 'val' & 'mask' SHOULD be unsigned integers.
*
* @note NULL 'mask' allowed; returns 'false' since NO mask bits specified.
*******************************************************************************************************/
#define SL_IS_ANY_BIT_CLEAR(val, mask) ((((val) & (mask)) == (mask)) ? (false) : (true))
/****************************************************************************************************//**
* SL_MATH_IS_PWR2()
*
* @brief Determine if a value is a power of 2.
*
* @param val Value.
*
* @return true, 'val' is a power of 2.
* false, 'val' is not a power of 2.
*******************************************************************************************************/
#define SL_MATH_IS_PWR2(val) ((((val) != 0u) && (((val) & ((val) - 1u)) == 0u)) ? true : false)
/*******************************************************************************
****************************** DEFINES ************************************
******************************************************************************/
/** @} (end addtogroup bit) */
#endif /* SL_BIT_H */

View File

@@ -0,0 +1,200 @@
/***************************************************************************//**
* @file sl_cmsis_os2_common.h
* @brief OS-agnostic header to provide CMSIS OS-Specific APIs like typedefs.
* @version x.y.z
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_CMSIS_OS2_COMMON_H
#define SL_CMSIS_OS2_COMMON_H
#include <stdint.h>
#include "cmsis_os2.h"
#include "sl_status.h"
#if defined(SL_COMPONENT_CATALOG_PRESENT)
#include "sl_component_catalog.h"
#endif
// Validate the chosen RTOS
#if !defined(SL_CATALOG_FREERTOS_KERNEL_PRESENT) && !defined(SL_CATALOG_MICRIUMOS_KERNEL_PRESENT)
#error "The extended CMSIS RTOS2 API currently only supports FreeRTOS or MicriumOS"
#endif
#if defined(SL_CATALOG_FREERTOS_KERNEL_PRESENT)
#include "FreeRTOS.h"
#elif defined(SL_CATALOG_MICRIUMOS_KERNEL_PRESENT)
#include "os.h"
#endif
#if defined(SL_CATALOG_FREERTOS_KERNEL_PRESENT)
#define osEventFlagsCbSize sizeof(StaticEventGroup_t)
#define osThreadCbSize sizeof(StaticTask_t)
#define osTimerCbSize sizeof(StaticTimer_t)
#define osMutexCbSize sizeof(StaticSemaphore_t)
#define osSemaphoreCbSize sizeof(StaticSemaphore_t)
#define osMessageQueueCbSize sizeof(StaticQueue_t)
#define osAlignment (portBYTE_ALIGNMENT)
typedef StaticEventGroup_t osEventFlags_t;
typedef StaticTask_t osThread_t;
typedef StaticTimer_t osTimer_t;
typedef StaticSemaphore_t osMutex_t;
typedef StaticSemaphore_t osSemaphore_t;
typedef StaticQueue_t osMessageQueue_t;
#elif defined(SL_CATALOG_MICRIUMOS_KERNEL_PRESENT)
typedef struct {
OS_TCB tcb; // This must be the first element, used by OSTCBCurPtr
#if (OS_CFG_FLAG_EN == DEF_ENABLED)
OS_FLAG_GRP flag_grp;
#endif
#if (OS_CFG_MUTEX_EN == DEF_ENABLED)
OS_MUTEX join_mutex;
#endif
uint8_t obj_dyn_alloc;
uint8_t stack_dyn_alloc;
uint32_t attr_bits;
} osThread_t;
#if (CMSIS_RTOS2_TIMER_TASK_EN == DEF_ENABLED)
typedef struct {
sl_sleeptimer_timer_handle_t handle;
osTimerFunc_t callback;
void *callback_data;
osTimerType_t type;
const char *name;
uint8_t dyn_alloc;
} osTimer_t;
#endif
#if (OS_CFG_FLAG_EN == DEF_ENABLED)
typedef struct {
OS_FLAG_GRP flag_grp;
uint8_t dyn_alloc;
uint32_t flags;
} osEventFlags_t;
#endif
#if (OS_CFG_MUTEX_EN == DEF_ENABLED)
typedef struct {
OS_MUTEX mutex;
uint8_t dyn_alloc;
uint8_t recursive;
} osMutex_t;
#endif
#if (OS_CFG_SEM_EN == DEF_ENABLED)
typedef struct {
OS_SEM sem;
uint8_t dyn_alloc;
uint32_t max_ctr;
} osSemaphore_t;
#endif
#if (OS_CFG_SEM_EN == DEF_ENABLED)
typedef struct {
OS_SEM sem_put;
OS_SEM sem_get;
uint8_t *buf;
uint8_t obj_dyn_alloc;
uint8_t buf_dyn_alloc;
uint32_t msg_count;
uint32_t msg_size;
uint32_t msg_queued;
uint32_t msg_head;
uint32_t msg_tail;
} osMessageQueue_t;
#endif
#if (OS_CFG_SEM_EN == DEF_ENABLED)
typedef struct {
OS_SEM sem;
uint8_t *buf;
uint8_t obj_dyn_alloc;
uint8_t buf_dyn_alloc;
uint32_t block_count;
uint32_t block_size;
uint32_t free_count;
uint32_t free_head;
} osMemoryPool_t;
#endif
#if (OS_CFG_FLAG_EN == DEF_ENABLED)
#define osEventFlagsCbSize sizeof(osEventFlags_t)
#endif
#define osThreadCbSize sizeof(osThread_t)
#if (OS_CFG_TMR_EN == DEF_ENABLED)
#define osTimerCbSize sizeof(osTimer_t)
#endif
#if (OS_CFG_MUTEX_EN == DEF_ENABLED)
#define osMutexCbSize sizeof(osMutex_t)
#endif
#if (OS_CFG_SEM_EN == DEF_ENABLED)
#define osSemaphoreCbSize sizeof(osSemaphore_t)
#endif
#if (OS_CFG_SEM_EN == DEF_ENABLED)
#define osMessageQueueCbSize sizeof(osMessageQueue_t)
#endif
#if (OS_CFG_SEM_EN == DEF_ENABLED)
#define osMemoryPoolCbSize sizeof(osMemoryPool_t)
#endif
#define osAlignment sizeof(CPU_ALIGN)
#endif // SL_CATALOG_MICRIUMOS_KERNEL_PRESENT
// -----------------------------------------------------------------------------
// Functions
#ifdef __cplusplus
extern "C" {
#endif
/********************************************************************************************************
* sl_cmsis_os_convert_status()
*
* @brief Convert OsStatus from CMSIS-RTOS2 to sl_status type.
*
* @param os_status The OS status code returned by CMSIS-RTOS2 API.
*
* @return Status code converted to sl_status.
*******************************************************************************************************/
sl_status_t sl_cmsis_os_convert_status(osStatus_t os_status);
#ifdef __cplusplus
}
#endif
#endif // SL_CMSIS_OS2_COMMON_H

View File

@@ -0,0 +1,75 @@
/***************************************************************************//**
* @file
* @brief Code Classification API
*******************************************************************************
* # License
* <b>Copyright 2023 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef _SL_CODE_CLASSIFICATION_H_
#define _SL_CODE_CLASSIFICATION_H_
#include "sli_code_classification.h"
// NOTE: This API is for use by applications only.
/**************************************************************************//**
* @addtogroup code_placement
* @brief Code Classification API
* @{
*****************************************************************************/
/******************************************************************************/
/* Macro API */
/******************************************************************************/
#if defined(__GNUC__) && !defined(__llvm__)
// With GCC, __attribute__ can be used to specify the input section of
// functions.
/// Prepend a function definition with this macro to place it in RAM.
#define SL_CODE_RAM \
__attribute__((section("text_application_ram")))
#elif defined(__ICCARM__)
// With IAR, _Pragma can be used to specify the input section of
// functions.
/// Prepend a function definition with this macro to place it in RAM.
#define SL_CODE_RAM \
_Pragma("location =\"text_application_ram\"")
#elif defined(__llvm__)
#define SL_CODE_RAM
#else
#error "(sl_code_classification.h): Code classification does not support \
the chosen compiler."
#endif // __GNUC__
/** @} (end addtogroup code_placement) */
#endif // _SL_CODE_CLASSIFICATION_H_

View File

@@ -0,0 +1,420 @@
/***************************************************************************//**
* @file
* @brief General purpose utilities.
*******************************************************************************
* # License
* <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_COMMON_H
#define SL_COMMON_H
#include <stdint.h>
#include <stdbool.h>
#include "sl_assert.h"
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(__STATIC_INLINE)
#if !defined(__unix__) && defined(__arm__)
/* Compiler agnostic definitions */
#include "cmsis_compiler.h"
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
#define __STATIC_INLINE static inline
#else
#warning Please provide a macro for your compiler and architecture
#define __STATIC_INLINE static
#endif
#endif
/***************************************************************************//**
* @addtogroup common COMMON - Common Utilities
* @brief General purpose utilities and cross-compiler support
* @details
* This SDK supports the following compilers/IDEs:
* @li Simplicity Studio
* @li IAR Embedded Workbench
* @li Keil uVision IDE
* @li Plain armgcc
*
* Certain compiler features such as alignment is implemented differently in the tools.
* Therefore, macros such as @ref SL_ALIGN are provided to enable compiler independent
* code.
*
* @note RAM code macros are implemented in [RAMFUNC](/gecko-platform/<docspace-docleaf-version>/emlib-efm32g/).
* Cross-compiler RAM code support needs extended documentation and it is therefore
* implemented as a separate module.
*
* @{
******************************************************************************/
/** @brief Macros to concatenate. */
#define _CONCAT_2(first, second) first ## second
#define SL_CONCAT_PASTER_2(first, second) _CONCAT_2(first, second) ///< sl concat paster 2.
#define _CONCAT_3(first, second, third) first ## second ## third
#define SL_CONCAT_PASTER_3(first, second, third) _CONCAT_3(first, second, third) ///< sl concat paster 3.
#define _CONCAT_4(first, second, third, fourth) first ## second ## third ## fourth
#define SL_CONCAT_PASTER_4(first, second, third, fourth) _CONCAT_4(first, second, third, fourth) ///< sl concat paster 4.
/** @brief Round n up to closest interval of i. */
#define SL_CEILING(n, i) ((((n) + (i) - 1U) / (i)) * (i))
/** @brief Round n down to closest interval of i. */
#define SL_FLOOR(n, i) ((n / i) * i)
/** @brief Stringify X */
#define STRINGIZE(X) #X
#if !defined(__GNUC__)
/* Not GCC compilers */
/** @brief Macros for giving the compiler hints about the likelihood of a branch. */
#define SL_BRANCH_LIKELY(x) (x)
#define SL_BRANCH_UNLIKELY(x) (x)
/** @brief Macro for getting minimum value. */
#define SL_MIN(a, b) ((a) < (b) ? (a) : (b))
/** @brief Macro for getting maximum value. */
#define SL_MAX(a, b) ((a) > (b) ? (a) : (b))
/** @brief Macros for handling packed structures. */
#define SL_PACK_START(X) _Pragma(STRINGIZE(pack(X)))
#define SL_PACK_END() _Pragma("pack()")
#define SL_ATTRIBUTE_PACKED
#if defined(__CC_ARM)
/** @brief MDK-ARM compiler: Macros for handling aligned structures. */
#define SL_ALIGN(X) __align(X)
/** MDK-ARM compiler: Macro for handling weak symbols. */
#define SL_WEAK __attribute__ ((weak))
/** MDK-ARM compiler: Macro for handling non-returning functions. */
#define SL_NORETURN __attribute__ ((noreturn))
/** MDK-ARM compiler: Macro for handling section placement */
#define SL_ATTRIBUTE_SECTION(X) __attribute__ ((section(X)))
#endif
#if defined(__ICCARM__)
#if (__VER__ >= 8000000)
/** @brief Obsoleted macro from version 8.00 and on . */
#define _STD_BEGIN
/** @brief Obsoleted macro from version 8.00 and on . */
#define _STD_END
#endif
/** @brief IAR Embedded Workbench: Macros for handling aligned structures. */
#define SL_ALIGN(X) _Pragma(STRINGIZE(data_alignment = X))
/** @brief IAR Embedded Workbench: Macros for handling weak symbols. */
#define SL_WEAK __weak
/** @brief IAR Embedded Workbench: Macro for handling non-returning functions. */
#define SL_NORETURN __noreturn
/* *INDENT-OFF* */
/** IAR Embedded Workbench: Macro for handling section placement */
#define SL_ATTRIBUTE_SECTION(X) @ X
#endif
/* *INDENT-ON* */
#define SL_ATTRIBUTE_ALIGN(X)
/** @brief Macro for notifying the compiler of an intended
* switch case fallthrough. */
#define SL_FALLTHROUGH
/** @brief A macro for notifying the compiler to ignore type limit check. */
#define SL_IGNORE_TYPE_LIMIT_BEGIN
#define SL_IGNORE_TYPE_LIMIT_END
#else // !defined(__GNUC__)
/* GCC compilers */
/** @brief Macros for giving the compiler hints about the likelihood of a branch. */
#define SL_BRANCH_LIKELY(x) __builtin_expect(!!(x), 1)
#define SL_BRANCH_UNLIKELY(x) __builtin_expect(!!(x), 0)
/** @brief A macro for getting the minimum value. No side-effects, a and b are evaluated one time only. */
#define SL_MIN(a, b) __extension__({ __typeof__(a)_a = (a); __typeof__(b)_b = (b); _a < _b ? _a : _b; })
/** @brief A macro for getting the maximum value. No side-effects, a and b are evaluated one time only. */
#define SL_MAX(a, b) __extension__({ __typeof__(a)_a = (a); __typeof__(b)_b = (b); _a > _b ? _a : _b; })
/** @brief A GCC style macro for handling packed structures. */
#define SL_ATTRIBUTE_PACKED __attribute__ ((packed))
/** @brief A macro for handling packed structures.
* @n Use this macro before the structure definition.
* @n X denotes the maximum alignment of structure members. X is not supported with
* GCC. GCC always uses 1 byte maximum alignment.
*/
#define SL_PACK_START(x)
/** @brief A macro for handling packed structures.
* @n Use this macro after the structure definition.
* @n With GCC, add SL_ATTRIBUTE_PACKED after the closing curly braces of the structure
* definition.
*/
#define SL_PACK_END()
/** @brief GCC style macro for aligning a variable. */
#define SL_ATTRIBUTE_ALIGN(X) __attribute__ ((aligned(X)))
/** @brief A macro for aligning a variable.
* @n Use this macro before the variable definition.
* @n X denotes the storage alignment value in bytes.
* @n To be GCC-compatible, use SL_ATTRIBUTE_ALIGN(X) before the semicolon on normal
* variables. Use SL_ATTRIBUTE_ALIGN(X) before the opening curly brace on structure variables.
*/
#define SL_ALIGN(X)
/** @brief A macro for defining a weak symbol. */
#define SL_WEAK __attribute__ ((weak))
/** @brief A macro for handling non-returning functions. */
#define SL_NORETURN __attribute__ ((noreturn))
/** A macro for placing a variable in a section.
* @n Use this macro after the variable definition, before the equal sign or a semicolon.
* @n X denotes the section to place the variable in.
*/
#define SL_ATTRIBUTE_SECTION(X) __attribute__ ((section(X)))
/** @brief A macro for notifying the compiler of an intended
* switch case fallthrough. */
#if __GNUC__ >= 7
#define SL_FALLTHROUGH __attribute__ ((fallthrough));
#else
#define SL_FALLTHROUGH
#endif
/** @brief A macro for notifying the compiler to ignore type limit check. */
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#define SL_IGNORE_TYPE_LIMIT_BEGIN \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wtype-limits\"")
#define SL_IGNORE_TYPE_LIMIT_END \
_Pragma("GCC diagnostic pop")
#else
#define SL_IGNORE_TYPE_LIMIT_BEGIN
#define SL_IGNORE_TYPE_LIMIT_END ///< A MACRO to notify the compiler, limit END.
#endif
#endif // !defined(__GNUC__)
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
/** @brief
* Macro for marking deprecated functions
*
* @details
* SL_DEPRECATED_API_SDK_<RELEASE> is used to mark functions that are
* deprecated and should not be used from a given version of the SDK.
* The accompanying SL_SUPPRESS_DEPRECATION_WARNINGS_SDK_<RELEASE>
* define can be set to suppress warnings generated when using
* deprecated APIs.
*/
#ifdef SL_SUPPRESS_DEPRECATION_WARNINGS_SDK_3_0
#define SL_DEPRECATED_API_SDK_3_0
#else
#define SL_DEPRECATED_API_SDK_3_0 __attribute__ ((deprecated))
#endif
#ifdef SL_SUPPRESS_DEPRECATION_WARNINGS_SDK_3_2
#define SL_DEPRECATED_API_SDK_3_2
#else
#define SL_DEPRECATED_API_SDK_3_2 __attribute__ ((deprecated))
#endif
#ifdef SL_SUPPRESS_DEPRECATION_WARNINGS_SDK_3_3
#define SL_DEPRECATED_API_SDK_3_3
#else
#define SL_DEPRECATED_API_SDK_3_3 __attribute__ ((deprecated))
#endif
#ifdef SL_SUPPRESS_DEPRECATION_WARNINGS_SDK_4_1
#define SL_DEPRECATED_API_SDK_4_1
#else
#define SL_DEPRECATED_API_SDK_4_1 __attribute__ ((deprecated))
#endif
#ifdef SL_SUPPRESS_DEPRECATION_WARNINGS_SDK_4_2
#define SL_DEPRECATED_API_SDK_4_2
#else
#define SL_DEPRECATED_API_SDK_4_2 __attribute__ ((deprecated))
#endif
#ifdef SL_SUPPRESS_DEPRECATION_WARNINGS_SDK_4_4
#define SL_DEPRECATED_API_SDK_4_4
#else
#define SL_DEPRECATED_API_SDK_4_4 __attribute__ ((deprecated))
#endif
#ifdef SL_SUPPRESS_DEPRECATION_WARNINGS_SDK_2024_6
#define SL_DEPRECATED_API_SDK_2024_6
#else
#define SL_DEPRECATED_API_SDK_2024_6 __attribute__ ((deprecated))
#endif
/** @endcond */
/***************************************************************************//**
* @brief
* Count trailing number of zeros. Use CLZ instruction if available.
*
* @param[in] value
* Data value to check for number of trailing zero bits.
*
* @return
* A number of trailing zeros in value.
******************************************************************************/
__STATIC_INLINE uint32_t SL_CTZ(uint32_t value)
{
#if defined(__CORTEX_M) && (__CORTEX_M >= 3U)
return __CLZ(__RBIT(value));
#else
uint32_t zeros;
for (zeros = 0; (zeros < 32) && ((value & 0x1) == 0); zeros++, value >>= 1) {
;
}
return zeros;
#endif
}
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
/* Deprecated function. New code should use @ref SL_CTZ. */
__STATIC_INLINE uint32_t EFM32_CTZ(uint32_t value)
{
return SL_CTZ(value);
}
/** @endcond */
/***************************************************************************//**
* @brief
* Reverse the bits. Use the RBIT instruction if available, else process.
*
* @param[in] value
* Data value to reverse.
*
* @return
* A reversed value.
******************************************************************************/
__STATIC_INLINE uint32_t SL_RBIT(uint32_t value)
{
uint32_t result;
#if defined(__CORTEX_M) && (__CORTEX_M >= 0x03U)
result = __RBIT(value);
#else
int32_t s = 4 * 8 - 1;
result = value;
for (value >>= 1U; value != 0U; value >>= 1U) {
result <<= 1U;
result |= value & 1U;
s--;
}
result <<= s;
#endif
return result;
}
/***************************************************************************//**
* @brief
* Reverse the bits. Use the RBIT instruction if available, else process.
*
* @param[in] value
* 16-bit data value to reverse.
*
* @return
* A 16-bit reversed value.
******************************************************************************/
__STATIC_INLINE uint16_t SL_RBIT16(uint16_t value)
{
return (uint16_t)(SL_RBIT(value) >> 16);
}
/***************************************************************************//**
* @brief
* Reverse the bits. Use the RBIT instruction if available, else process.
*
* @param[in] value
* 8-bit data value to reverse.
*
* @return
* A 8-bit reversed value.
******************************************************************************/
__STATIC_INLINE uint8_t SL_RBIT8(uint8_t value)
{
return (uint8_t)(SL_RBIT(value) >> 24);
}
/***************************************************************************//**
* @brief
* Convert logarithm of 2 to division factor.
*
* @param[in] log2
* Logarithm of 2.
*
* @return
* Dividend.
******************************************************************************/
__STATIC_INLINE uint32_t SL_Log2ToDiv(uint32_t log2)
{
EFM_ASSERT(log2 < 32U);
return 1UL << log2;
}
/***************************************************************************//**
* @brief
* Count the number of bits that are set to 1 in a 32-bit bitfield.
*
* @param[in] bitfield
* 32-bit bitfield.
*
* @return
* The number of bits that are set to 1 in the bitfield.
******************************************************************************/
__STATIC_INLINE uint32_t SL_POPCOUNT32(uint32_t bitfield)
{
bitfield = bitfield - ((bitfield >> 1) & 0x55555555);
bitfield = (bitfield & 0x33333333) + ((bitfield >> 2) & 0x33333333);
bitfield = (bitfield + (bitfield >> 4)) & 0x0F0F0F0F;
return (bitfield * 0x01010101) >> 24;
}
/** @} (end addtogroup common) */
#ifdef __cplusplus
}
#endif
#endif /* SL_COMMON_H */

View File

@@ -0,0 +1,210 @@
/***************************************************************************//**
* @file
* @brief Silabs Compiler definitions.
*******************************************************************************
* # License
* <b>Copyright 2022 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_COMPILER_H
#define SL_COMPILER_H
/***************************************************************************//**
* @addtogroup compiler Compiler definitions
* @brief Compiler definitions
* @{
******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#if defined (__GNUC__)
// Fallback for __has_builtin.
#ifndef __has_builtin
#define __has_builtin(x) (0)
#endif
// Compiler specific defines.
#ifndef __ASM
#define __ASM __asm
#endif
#ifndef __INLINE
#define __INLINE inline
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static inline
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline
#endif
#ifndef __NO_RETURN
#define __NO_RETURN __attribute__((__noreturn__))
#endif
#ifndef __USED
#define __USED __attribute__((used))
#endif
#ifndef __WEAK
#define __WEAK __attribute__((weak))
#endif
#ifndef __PACKED
#define __PACKED __attribute__((packed, aligned(1)))
#endif
#ifndef __PACKED_STRUCT
#define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
#endif
#ifndef __PACKED_UNION
#define __PACKED_UNION union __attribute__((packed, aligned(1)))
#endif
#ifndef __ALIGNED
#define __ALIGNED(x) __attribute__((aligned(x)))
#endif
#ifndef __RESTRICT
#define __RESTRICT __restrict
#endif
#elif defined(__IAR_SYSTEMS_ICC__)
#pragma system_include
#if (__VER__ >= 8000000)
#define __ICCARM_V8 1
#else
#define __ICCARM_V8 0
#endif
#ifndef __ALIGNED
#if __ICCARM_V8
#define __ALIGNED(x) __attribute__((aligned(x)))
#elif (__VER__ >= 7080000)
/* Needs IAR language extensions */
#define __ALIGNED(x) __attribute__((aligned(x)))
#else
#warning No compiler specific solution for __ALIGNED.__ALIGNED is ignored.
#define __ALIGNED(x)
#endif
#endif
#ifndef __ASM
#define __ASM __asm
#endif
#ifndef __INLINE
#define __INLINE inline
#endif
#ifndef __NO_RETURN
#if __ICCARM_V8
#define __NO_RETURN __attribute__((__noreturn__))
#else
#define __NO_RETURN _Pragma("object_attribute=__noreturn")
#endif
#endif
#ifndef __PACKED
#if __ICCARM_V8
#define __PACKED __attribute__((packed, aligned(1)))
#else
/* Needs IAR language extensions */
#define __PACKED __packed
#endif
#endif
#ifndef __PACKED_STRUCT
#if __ICCARM_V8
#define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
#else
/* Needs IAR language extensions */
#define __PACKED_STRUCT __packed struct
#endif
#endif
#ifndef __PACKED_UNION
#if __ICCARM_V8
#define __PACKED_UNION union __attribute__((packed, aligned(1)))
#else
/* Needs IAR language extensions */
#define __PACKED_UNION __packed union
#endif
#endif
#ifndef __RESTRICT
#define __RESTRICT restrict
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static inline
#endif
#ifndef __FORCEINLINE
#define __FORCEINLINE _Pragma("inline=forced")
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE __FORCEINLINE __STATIC_INLINE
#endif
#ifndef __USED
#if __ICCARM_V8
#define __USED __attribute__((used))
#else
#define __USED _Pragma("__root")
#endif
#endif
#ifndef __WEAK
#if __ICCARM_V8
#define __WEAK __attribute__((weak))
#else
#define __WEAK _Pragma("__weak")
#endif
#endif
#else
#error "Unknown compiler."
#endif
// IO definitions (access restrictions to peripheral registers).
#ifdef __cplusplus
#define __I volatile ///< Defines 'read only' permissions
#else
#define __I volatile const ///< Defines 'read only' permissions
#endif
#define __O volatile ///< Defines 'write only' permissions
#define __IO volatile ///< Defines 'read / write' permissions
// The following defines should be used for structure members.
#define __IM volatile const ///< Defines 'read only' structure member permissions
#define __OM volatile ///< Defines 'write only' structure member permissions
#define __IOM volatile ///< Defines 'read / write' structure member permissions
#ifdef __cplusplus
}
#endif
/** @} (end group compiler) */
#endif // SL_COMPILER_H

View File

@@ -0,0 +1,499 @@
/***************************************************************************//**
* @file
* @brief Core API
*******************************************************************************
* # License
* <b>Copyright 2023 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_CORE_H
#define SL_CORE_H
#include <stdint.h>
#include <stdbool.h>
#include "sl_code_classification.h"
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************//**
* @addtogroup sl_core Core
*
* @section sl_core_intro Introduction
*
* The core abstraction API provides high-level, device agnostic, control of
* core peripherals, most notably the ability to execute code in sections with
* varying levels of interrupt masking.
*
* This module provides support for two types of critical sections, each
* with different interrupt masking capabilities.
*
* @li <b>CRITICAL section</b>: Inside a critical section, all interrupts are
* masked (except for core exception handlers).
* @li <b>ATOMIC section</b>: Inside an atomic section, interrupts with a
* priority less than the configurable @ref SL_CORE_BASE_PRIORITY_LEVEL
* value will be masked.
*
* @section sl_core_conf Compile-time Configuration
*
* The following #define is used to configure sl_core:
* @code{.c}
* // Enables debug methods to measure the time spent in critical sections.
* #define SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING 0
* @endcode
*
* @section sl_core_macro_api Macro API
*
* The core abstraction API has macros to facilitate executing code in
* ATOMIC and CRITICAL sections.
*
* @ref CORE_DECLARE_IRQ_STATE, @ref CORE_ENTER_ATOMIC() and
* @ref CORE_EXIT_ATOMIC() can be used together to implement an ATOMIC section.
* @code{.c}
* {
* CORE_DECLARE_IRQ_STATE; // Storage for saving IRQ state prior to
* // atomic section entry.
*
* CORE_ENTER_ATOMIC(); // Enter atomic section.
*
* ...
* ... your code goes here ...
* ...
*
* CORE_EXIT_ATOMIC(); // Exit atomic section, IRQ state is restored.
* }
* @endcode
*
* @ref CORE_ATOMIC_SECTION(yourcode) is aconcatenation of all three of the
* macros above.
* @code{.c}
* {
* CORE_ATOMIC_SECTION(
* ...
* ... your code goes here ...
* ...
* )
* }
* @endcode
*
* The following macros implement CRITICAL sections in a similar fashion as
* described above for ATOMIC sections:
* <li>@ref CORE_DECLARE_IRQ_STATE</li>
* <li>@ref CORE_ENTER_CRITICAL()</li>
* <li>@ref CORE_EXIT_CRITICAL()</li>
* <li>@ref CORE_CRITICAL_SECTION(yourcode)</li>
*
* @section sl_core_reimplementation API Reimplementation
*
* Most of the functions in the API are implemented as weak functions. This means
* that it is easy to reimplement when special needs arise. Shown below is a
* reimplementation of CRITICAL sections suitable if FreeRTOS OS is used:
* @code{.c}
* CORE_irqState_t CORE_EnterCritical(void)
* {
* vPortEnterCritical();
* return 0;
* }
*
* void CORE_ExitCritical(CORE_irqState_t irqState)
* {
* (void)irqState;
* vPortExitCritical();
* }
* @endcode
* Also note that CORE_Enter/ExitCritical() are not implemented as inline
* functions. As a result, reimplementations will be possible even when original
* implementations are inside a linked library.
*
* Some RTOSes must be notified on interrupt handler entry and exit. Macros
* @ref CORE_INTERRUPT_ENTRY() and @ref CORE_INTERRUPT_EXIT() are suitable
* placeholders for inserting such code. Insert these macros in all your
* interrupt handlers and then override the default macro implementations.
* This is an example if uC/OS is used:
* @code{.c}
* // In emlib_config.h:
*
* #define CORE_INTERRUPT_ENTRY() OSIntEnter()
* #define CORE_INTERRUPT_EXIT() OSIntExit()
* @endcode
*
* @section sl_core_max_timing Maximum Interrupt Disabled Time
*
* The maximum time spent (in cycles) in critical and atomic sections can be
* measured for performance and interrupt latency analysis.
* To enable the timings, use the SL_CORE_ENABLE_INTERRUPT_DISABLED_TIMING
* configuration option. When enabled, the functions
* @ref CORE_get_max_time_critical_section() and
* @ref CORE_get_max_time_atomic_section()
* can be used to get the max timings since startup.
*
* @section sl_core_porting Porting from em_int
*
* Existing code using INT_Enable() and INT_Disable() must be ported to the
* sl_core API. While em_int used, a global counter to store the interrupt state,
* sl_core uses a local variable. Any usage of INT_Disable(), therefore, needs to
* be replaced with a declaration of the interrupt state variable before entering
* the critical section.
*
* Since the state variable is in local scope, the critical section exit
* needs to occur within the scope of the variable. If multiple nested critical
* sections are used, each needs to have its own state variable in its own scope.
*
* In many cases, completely disabling all interrupts using CRITICAL sections
* might be more heavy-handed than needed. When porting, consider whether
* an ATOMIC section can be used to only disable a subset of the interrupts.
*
* Replacing em_int calls with sl_core function calls:
* @code{.c}
* void func(void)
* {
* // INT_Disable();
* CORE_DECLARE_IRQ_STATE;
* CORE_ENTER_ATOMIC();
* .
* .
* .
* // INT_Enable();
* CORE_EXIT_ATOMIC();
* }
* @endcode
* @{
******************************************************************************/
/*******************************************************************************
***************************** DEFINES *************************************
******************************************************************************/
#if !defined(CORE_ATOMIC_BASE_PRIORITY_LEVEL)
/** The interrupt priority level disabled within ATOMIC regions. Interrupts
* with priority level equal to or lower than this definition will be disabled
* within ATOMIC regions. */
#define CORE_ATOMIC_BASE_PRIORITY_LEVEL 3
#else
#ifndef SL_SUPPRESS_DEPRECATION_WARNINGS_SDK_2024_6
#warning "The CORE_ATOMIC_BASE_PRIORITY_LEVEL configuration is DEPRECATED. In \
later releases, the base priority of atomic sections will be hardcoded to 3 \
and will no longer be configurable. Please consider updating the priorities \
of interrupts in your application to account for this new hardcoded value."
#endif
#endif
/*******************************************************************************
************************ MACRO API ***************************************
******************************************************************************/
/// Allocate storage for PRIMASK or BASEPRI value for use by
/// CORE_ENTER/EXIT_ATOMIC() and CORE_ENTER/EXIT_CRITICAL() macros.
#define CORE_DECLARE_IRQ_STATE CORE_irqState_t irqState
/// CRITICAL style interrupt disable.
#define CORE_CRITICAL_IRQ_DISABLE() CORE_CriticalDisableIrq()
/// CRITICAL style interrupt enable.
#define CORE_CRITICAL_IRQ_ENABLE() CORE_CriticalEnableIrq()
/// Convenience macro for implementing a CRITICAL section.
#define CORE_CRITICAL_SECTION(yourcode) \
{ \
CORE_DECLARE_IRQ_STATE; \
CORE_ENTER_CRITICAL(); \
{ \
yourcode \
} \
CORE_EXIT_CRITICAL(); \
}
/// Enter CRITICAL section. Assumes that a @ref CORE_DECLARE_IRQ_STATE exist in
/// scope.
#define CORE_ENTER_CRITICAL() irqState = CORE_EnterCritical()
/// Exit CRITICAL section. Assumes that a @ref CORE_DECLARE_IRQ_STATE exist in
/// scope.
#define CORE_EXIT_CRITICAL() CORE_ExitCritical(irqState)
/// CRITICAL style yield.
#define CORE_YIELD_CRITICAL() CORE_YieldCritical()
/// ATOMIC style interrupt disable.
#define CORE_ATOMIC_IRQ_DISABLE() CORE_AtomicDisableIrq()
/// ATOMIC style interrupt enable.
#define CORE_ATOMIC_IRQ_ENABLE() CORE_AtomicEnableIrq()
/// Convenience macro for implementing an ATOMIC section.
#define CORE_ATOMIC_SECTION(yourcode) \
{ \
CORE_DECLARE_IRQ_STATE; \
CORE_ENTER_ATOMIC(); \
{ \
yourcode \
} \
CORE_EXIT_ATOMIC(); \
}
/// Enter ATOMIC section. Assumes that a @ref CORE_DECLARE_IRQ_STATE exist in
/// scope.
#define CORE_ENTER_ATOMIC() irqState = CORE_EnterAtomic()
/// Exit ATOMIC section. Assumes that a @ref CORE_DECLARE_IRQ_STATE exist in
/// scope.
#define CORE_EXIT_ATOMIC() CORE_ExitAtomic(irqState)
/// ATOMIC style yield.
#define CORE_YIELD_ATOMIC() CORE_YieldAtomic()
/// Check if IRQ is disabled.
#define CORE_IRQ_DISABLED() CORE_IrqIsDisabled()
/// Check if inside an IRQ handler.
#define CORE_IN_IRQ_CONTEXT() CORE_InIrqContext()
// Reset System.
#define CORE_RESET_SYSTEM() CORE_ResetSystem()
/*******************************************************************************
************************* TYPEDEFS ****************************************
******************************************************************************/
/// Storage for PRIMASK or BASEPRI value.
typedef uint32_t CORE_irqState_t;
/*******************************************************************************
***************************** PROTOTYPES **********************************
******************************************************************************/
/***************************************************************************//**
* @brief
* Disable interrupts.
*
* Disable all interrupts by setting PRIMASK.
* (Fault exception handlers will still be enabled).
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
void CORE_CriticalDisableIrq(void);
/***************************************************************************//**
* @brief
* Enable interrupts.
*
* Enable interrupts by clearing PRIMASK.
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
void CORE_CriticalEnableIrq(void);
/***************************************************************************//**
* @brief
* Exit a CRITICAL section.
*
* @param[in] irqState
* The interrupt priority blocking level to restore to PRIMASK when exiting
* the CRITICAL section. This value is usually the one returned by a prior
* call to @ref CORE_EnterCritical().
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
void CORE_ExitCritical(CORE_irqState_t irqState);
/***************************************************************************//**
* @brief
* Brief interrupt enable/disable sequence to allow handling of
* pending interrupts.
*
* @note
* Usually used within a CRITICAL section.
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
void CORE_YieldCritical(void);
/***************************************************************************//**
* @brief
* Enter a CRITICAL section.
*
* When a CRITICAL section is entered, all interrupts (except fault handlers)
* are disabled.
*
* @return
* The value of PRIMASK register prior to the CRITICAL section entry.
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
CORE_irqState_t CORE_EnterCritical(void);
/***************************************************************************//**
* @brief
* Disable interrupts.
*
* Disable interrupts with a priority lower or equal to
* @ref CORE_ATOMIC_BASE_PRIORITY_LEVEL. Sets core BASEPRI register
* to CORE_ATOMIC_BASE_PRIORITY_LEVEL.
*
* @note
* If @ref CORE_ATOMIC_METHOD is @ref CORE_ATOMIC_METHOD_PRIMASK, this
* function is identical to @ref CORE_CriticalDisableIrq().
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
void CORE_AtomicDisableIrq(void);
/***************************************************************************//**
* @brief
* Enable interrupts.
*
* Enable interrupts by setting core BASEPRI register to 0.
*
* @note
* If @ref CORE_ATOMIC_METHOD is @ref CORE_ATOMIC_METHOD_BASEPRI and PRIMASK
* is set (CPU is inside a CRITICAL section), interrupts will still be
* disabled after calling this function.
*
* @note
* If @ref CORE_ATOMIC_METHOD is @ref CORE_ATOMIC_METHOD_PRIMASK, this
* function is identical to @ref CORE_CriticalEnableIrq().
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
void CORE_AtomicEnableIrq(void);
/***************************************************************************//**
* @brief
* Exit an ATOMIC section.
*
* @param[in] irqState
* The interrupt priority blocking level to restore to BASEPRI when exiting
* the ATOMIC section. This value is usually the one returned by a prior
* call to @ref CORE_EnterAtomic().
*
* @note
* If @ref CORE_ATOMIC_METHOD is set to @ref CORE_ATOMIC_METHOD_PRIMASK, this
* function is identical to @ref CORE_ExitCritical().
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
void CORE_ExitAtomic(CORE_irqState_t irqState);
/***************************************************************************//**
* @brief
* Brief interrupt enable/disable sequence to allow handling of
* pending interrupts.
*
* @note
* Usually used within an ATOMIC section.
*
* @note
* If @ref CORE_ATOMIC_METHOD is @ref CORE_ATOMIC_METHOD_PRIMASK, this
* function is identical to @ref CORE_YieldCritical().
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
void CORE_YieldAtomic(void);
/***************************************************************************//**
* @brief
* Enter an ATOMIC section.
*
* When an ATOMIC section is entered, interrupts with priority lower or equal
* to @ref CORE_ATOMIC_BASE_PRIORITY_LEVEL are disabled.
*
* @note
* If @ref CORE_ATOMIC_METHOD is @ref CORE_ATOMIC_METHOD_PRIMASK, this
* function is identical to @ref CORE_EnterCritical().
*
* @return
* The value of BASEPRI register prior to ATOMIC section entry.
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
CORE_irqState_t CORE_EnterAtomic(void);
/***************************************************************************//**
* @brief
* Check whether the current CPU operation mode is handler mode.
*
* @return
* True if the CPU is in handler mode (currently executing an interrupt handler).
* @n False if the CPU is in thread mode.
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
bool CORE_InIrqContext(void);
/***************************************************************************//**
* @brief
* Check if interrupts are disabled.
*
* @return
* True if interrupts are disabled.
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
bool CORE_IrqIsDisabled(void);
/***************************************************************************//**
* @brief
* Returns the max time spent in critical section.
*
* @return
* The max time spent in critical section.
*
* @note SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING must be enabled.
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
uint32_t CORE_get_max_time_critical_section(void);
/***************************************************************************//**
* @brief
* Returns the max time spent in atomic section.
*
* @return
* The max time spent in atomic section.
*
* @note SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING must be enabled.
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
uint32_t CORE_get_max_time_atomic_section(void);
/***************************************************************************//**
* @brief
* Clears the max time spent in atomic section.
*
* @note SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING must be enabled.
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
void CORE_clear_max_time_critical_section(void);
/***************************************************************************//**
* @brief
* Clears the max time spent in atomic section.
*
* @note SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING must be enabled.
******************************************************************************/
SL_CODE_CLASSIFY(SL_CODE_COMPONENT_CORE, SL_CODE_CLASS_TIME_CRITICAL)
void CORE_clear_max_time_atomic_section(void);
/***************************************************************************//**
* @brief
* Reset chip routine.
******************************************************************************/
void CORE_ResetSystem(void);
/** @} (end addtogroup sl_core) */
#ifdef __cplusplus
}
#endif
#endif /* SL_CORE_H */

View File

@@ -0,0 +1,66 @@
/*******************************************************************************
* @file
* @brief SL_ENUM Implementation
*******************************************************************************
* # License
* <b>Copyright 2019 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_ENUM_H
#define SL_ENUM_H
/*******************************************************************************
* @addtogroup enum Enumerations
* @brief Enumerations with stable binary representation
* @details
* Silicon Labs libraries do not use enumerations because the ARM EABI leaves
* their size ambiguous, which causes problems if the application is built
* with different flags than the library. Instead, uint8_t typedefs
* are used in compiled code for all enumerations. For documentation purposes,
* this is converted to an actual enumeration in documentation.
* @{
******************************************************************************/
#ifdef DOXYGEN
/// Enumeration mapped to uint8_t
#define SL_ENUM(name) enum name
/// Enumeration mapped to arbitrary type
#define SL_ENUM_GENERIC(name, type) enum name
#else
// NOTE: The following macros might cause MISRA warnings because
// Macro parameters need to be enclosed in parentheses.
// However, it is not possible in C to enclose declaration
// identifiers in parentheses. For example:
// typedef uint8_t (some_identifier);
// is not syntactically correct in the C language (C99).
#define SL_ENUM(name) typedef uint8_t name; enum name##_enum
#define SL_ENUM_GENERIC(name, type) typedef type name; enum name##_enum
// For debugging, use the following define to turn this back into a proper enumeration
// #define SL_ENUM(name) typedef enum name##_enum name; enum name##_enum
#endif
/** @} end enum */
#endif // SL_ENUM_H

View File

@@ -0,0 +1,173 @@
/*******************************************************************************
* @file
* @brief Single Link List.
*******************************************************************************
* # License
* <b>Copyright 2019 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_SLIST_H
#define SL_SLIST_H
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************************************
* @addtogroup slist Singly-Linked List
* @brief Singly-linked List module provides APIs to handle singly-linked list
* operations such as insert, push, pop, push back, sort and remove.
*
* @note The pop operation follows FIFO method.
* @n @section slist_usage Singly-Linked List module Usage
* @{
******************************************************************************/
/// List node type
typedef struct sl_slist_node sl_slist_node_t;
/// List node
struct sl_slist_node {
sl_slist_node_t *node; ///< List node
};
#ifndef DOXYGEN
#define container_of(ptr, type, member) (type *)((uintptr_t)(ptr) - ((uintptr_t)(&((type *)0)->member)))
#define SL_SLIST_ENTRY container_of
#define SL_SLIST_FOR_EACH(list_head, iterator) for ((iterator) = (list_head); (iterator) != NULL; (iterator) = (iterator)->node)
#define SL_SLIST_FOR_EACH_ENTRY(list_head, entry, type, member) for ( (entry) = SL_SLIST_ENTRY(list_head, type, member); \
(type *)(entry) != SL_SLIST_ENTRY(NULL, type, member); \
(entry) = SL_SLIST_ENTRY((entry)->member.node, type, member))
#endif
// -----------------------------------------------------------------------------
// Prototypes
/*******************************************************************************
* Initialize a singly-linked list.
*
* @param head Pointer to pointer of head element of list.
******************************************************************************/
void sl_slist_init(sl_slist_node_t **head);
/*******************************************************************************
* Add given item at beginning of the list.
*
* @param head Pointer to pointer of head element of the list.
*
* @param item Pointer to an item to add.
******************************************************************************/
void sl_slist_push(sl_slist_node_t **head,
sl_slist_node_t *item);
/*******************************************************************************
* Add item at the end of the list.
*
* @param head Pointer to the pointer of a head element of the list.
*
* @param item Pointer to the item to add.
******************************************************************************/
void sl_slist_push_back(sl_slist_node_t **head,
sl_slist_node_t *item);
/*******************************************************************************
* Remove and return the first element of the list.
*
* @param head Pointer to he pointer of the head element of the list.
*
* @return Pointer to item that was at top of the list.
******************************************************************************/
sl_slist_node_t *sl_slist_pop(sl_slist_node_t **head);
/*******************************************************************************
* Insert an item after the given item.
*
* @param item Pointer to an item to add.
*
* @param pos Pointer to an item after which the item to add will be inserted.
******************************************************************************/
void sl_slist_insert(sl_slist_node_t *item,
sl_slist_node_t *pos);
/*******************************************************************************
* Join two lists together.
*
* @param head_list_1 Pointer to the pointer of a head element of the list.
*
* @param head_list_2 Pointer to the pointer of a head element of the list
* to be appended. After the call, this pointer will be
* invalidated (set to NULL).
******************************************************************************/
void sl_slist_join(sl_slist_node_t **head_list_1,
sl_slist_node_t **head_list_2);
/*******************************************************************************
* Remove an item from the list.
*
* @param head Pointer to pointer of the head element of list.
*
* @param item Pointer to the item to remove.
******************************************************************************/
void sl_slist_remove(sl_slist_node_t **head,
sl_slist_node_t *item);
/*******************************************************************************
* Sort list items.
*
* @param head Pointer to the pointer of the head element of the list.
*
* @param cmp_fnct Pointer to function to use for sorting the list.
* item_l Pointer to left item.
* item_r Pointer to right item.
* Returns whether the two items are ordered (true) or not (false).
******************************************************************************/
void sl_slist_sort(sl_slist_node_t **head,
bool (*cmp_fnct)(sl_slist_node_t *item_l,
sl_slist_node_t *item_r));
/*******************************************************************************
* Checks if the list is empty.
*
* @param head Pointer to the head element of the list.
******************************************************************************/
static inline bool sl_slist_is_empty(sl_slist_node_t *head)
{
return head == NULL;
}
/** @} (end addtogroup slist) */
#ifdef __cplusplus
}
#endif
#endif /* SL_SLIST_H */

View File

@@ -0,0 +1,526 @@
/*******************************************************************************
* @file
* @brief SL Status Codes.
*******************************************************************************
* # License
* <b>Copyright 2019 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_STATUS_H
#define SL_STATUS_H
#include <stdint.h>
/*******************************************************************************
* @addtogroup status Status Codes
* @details Status Codes contains error and status code definitions used by
* Simplicity SDK software components and stacks. This module also
* provides routines to read the string linked with the error and
* status codes.
* @{
******************************************************************************/
// -----------------------------------------------------------------------------
// Space Defines
#define SL_STATUS_SPACE_MASK ((sl_status_t)0xFF00) ///< sl status space mask.
#define SL_STATUS_GENERIC_SPACE ((sl_status_t)0x0000) ///< sl status generic space.
#define SL_STATUS_PLATFORM_1_SPACE ((sl_status_t)0x0100) ///< sl status platform 1 space.
#define SL_STATUS_PLATFORM_2_SPACE ((sl_status_t)0x0200) ///< sl status platform 2 space.
#define SL_STATUS_HARDWARE_SPACE ((sl_status_t)0x0300) ///< sl status hardware space.
#define SL_STATUS_BLUETOOTH_SPACE ((sl_status_t)0x0400) ///< sl status bluetooth space.
#define SL_STATUS_BLUETOOTH_MESH_SPACE ((sl_status_t)0x0500) ///< sl status bluetooth mesh space.
#define SL_STATUS_CAN_CANOPEN_SPACE ((sl_status_t)0x0600) ///< sl status can canopen space.
#define SL_STATUS_CONNECT_SPACE ((sl_status_t)0x0700) ///< sl status connect space.
#define SL_STATUS_NET_SUITE_SPACE ((sl_status_t)0x0800) ///< sl status net suite space.
#define SL_STATUS_THREAD_SPACE ((sl_status_t)0x0900) ///< sl status thread space.
#define SL_STATUS_USB_SPACE ((sl_status_t)0x0A00) ///< sl status usb space.
#define SL_STATUS_WIFI_SPACE ((sl_status_t)0x0B00) ///< sl status wifi space.
#define SL_STATUS_ZIGBEE_SPACE ((sl_status_t)0x0C00) ///< sl status zigbee space.
#define SL_STATUS_Z_WAVE_SPACE ((sl_status_t)0x0D00) ///< sl status z wave space.
#define SL_STATUS_GECKO_OS_1_SPACE ((sl_status_t)0x0E00) ///< sl status gecko os 1 space.
#define SL_STATUS_GECKO_OS_2_SPACE ((sl_status_t)0x0F00) ///< sl status gecko os 2 space.
#define SL_STATUS_BLUETOOTH_CTRL_SPACE ((sl_status_t)0x1000) ///< sl status bluetooth ctrl space.
#define SL_STATUS_BLUETOOTH_ATT_SPACE ((sl_status_t)0x1100) ///< sl status bluetooth att space.
#define SL_STATUS_BLUETOOTH_SMP_SPACE ((sl_status_t)0x1200) ///< sl status bluetooth mesh foundation space.
#define SL_STATUS_BLUETOOTH_MESH_FOUNDATION_SPACE ((sl_status_t)0x1300) ///< sl status bluetooth mesh foundation space.
#define SL_STATUS_WISUN_SPACE ((sl_status_t)0x1400) ///< sl status wisun space.
#define SL_STATUS_COMPUTE_SPACE ((sl_status_t)0x1500) ///< sl status compute space.
// -----------------------------------------------------------------------------
// Status Defines
// -----------------------------------------------------------------------------
// Generic Errors
#define SL_STATUS_OK ((sl_status_t)0x0000) ///< No error.
#define SL_STATUS_FAIL ((sl_status_t)0x0001) ///< Generic error.
// State Errors
#define SL_STATUS_INVALID_STATE ((sl_status_t)0x0002) ///< Generic invalid state error.
#define SL_STATUS_NOT_READY ((sl_status_t)0x0003) ///< Module is not ready for requested operation.
#define SL_STATUS_BUSY ((sl_status_t)0x0004) ///< Module is busy and cannot carry out requested operation.
#define SL_STATUS_IN_PROGRESS ((sl_status_t)0x0005) ///< Operation is in progress and not yet complete (pass or fail).
#define SL_STATUS_ABORT ((sl_status_t)0x0006) ///< Operation aborted.
#define SL_STATUS_TIMEOUT ((sl_status_t)0x0007) ///< Operation timed out.
#define SL_STATUS_PERMISSION ((sl_status_t)0x0008) ///< Operation not allowed per permissions.
#define SL_STATUS_WOULD_BLOCK ((sl_status_t)0x0009) ///< Non-blocking operation would block.
#define SL_STATUS_IDLE ((sl_status_t)0x000A) ///< Operation/module is Idle, cannot carry requested operation.
#define SL_STATUS_IS_WAITING ((sl_status_t)0x000B) ///< Operation cannot be done while construct is waiting.
#define SL_STATUS_NONE_WAITING ((sl_status_t)0x000C) ///< No task/construct waiting/pending for that action/event.
#define SL_STATUS_SUSPENDED ((sl_status_t)0x000D) ///< Operation cannot be done while construct is suspended.
#define SL_STATUS_NOT_AVAILABLE ((sl_status_t)0x000E) ///< Feature not available due to software configuration.
#define SL_STATUS_NOT_SUPPORTED ((sl_status_t)0x000F) ///< Feature not supported.
#define SL_STATUS_INITIALIZATION ((sl_status_t)0x0010) ///< Initialization failed.
#define SL_STATUS_NOT_INITIALIZED ((sl_status_t)0x0011) ///< Module has not been initialized.
#define SL_STATUS_ALREADY_INITIALIZED ((sl_status_t)0x0012) ///< Module has already been initialized.
#define SL_STATUS_DELETED ((sl_status_t)0x0013) ///< Object/construct has been deleted.
#define SL_STATUS_ISR ((sl_status_t)0x0014) ///< Illegal call from ISR.
#define SL_STATUS_NETWORK_UP ((sl_status_t)0x0015) ///< Illegal call because network is up.
#define SL_STATUS_NETWORK_DOWN ((sl_status_t)0x0016) ///< Illegal call because network is down.
#define SL_STATUS_NOT_JOINED ((sl_status_t)0x0017) ///< Failure due to not being joined in a network.
#define SL_STATUS_NO_BEACONS ((sl_status_t)0x0018) ///< Invalid operation as there are no beacons.
// Allocation/ownership Errors
#define SL_STATUS_ALLOCATION_FAILED ((sl_status_t)0x0019) ///< Generic allocation error.
#define SL_STATUS_NO_MORE_RESOURCE ((sl_status_t)0x001A) ///< No more resource available to perform the operation.
#define SL_STATUS_EMPTY ((sl_status_t)0x001B) ///< Item/list/queue is empty.
#define SL_STATUS_FULL ((sl_status_t)0x001C) ///< Item/list/queue is full.
#define SL_STATUS_WOULD_OVERFLOW ((sl_status_t)0x001D) ///< Item would overflow.
#define SL_STATUS_HAS_OVERFLOWED ((sl_status_t)0x001E) ///< Item/list/queue has been overflowed.
#define SL_STATUS_OWNERSHIP ((sl_status_t)0x001F) ///< Generic ownership error.
#define SL_STATUS_IS_OWNER ((sl_status_t)0x0020) ///< Already/still owning resource.
// Invalid Parameters Errors
#define SL_STATUS_INVALID_PARAMETER ((sl_status_t)0x0021) ///< Generic invalid argument or consequence of invalid argument.
#define SL_STATUS_NULL_POINTER ((sl_status_t)0x0022) ///< Invalid null pointer received as argument.
#define SL_STATUS_INVALID_CONFIGURATION ((sl_status_t)0x0023) ///< Invalid configuration provided.
#define SL_STATUS_INVALID_MODE ((sl_status_t)0x0024) ///< Invalid mode.
#define SL_STATUS_INVALID_HANDLE ((sl_status_t)0x0025) ///< Invalid handle.
#define SL_STATUS_INVALID_TYPE ((sl_status_t)0x0026) ///< Invalid type for operation.
#define SL_STATUS_INVALID_INDEX ((sl_status_t)0x0027) ///< Invalid index.
#define SL_STATUS_INVALID_RANGE ((sl_status_t)0x0028) ///< Invalid range.
#define SL_STATUS_INVALID_KEY ((sl_status_t)0x0029) ///< Invalid key.
#define SL_STATUS_INVALID_CREDENTIALS ((sl_status_t)0x002A) ///< Invalid credentials.
#define SL_STATUS_INVALID_COUNT ((sl_status_t)0x002B) ///< Invalid count.
#define SL_STATUS_INVALID_SIGNATURE ((sl_status_t)0x002C) ///< Invalid signature / verification failed.
#define SL_STATUS_NOT_FOUND ((sl_status_t)0x002D) ///< Item could not be found.
#define SL_STATUS_ALREADY_EXISTS ((sl_status_t)0x002E) ///< Item already exists.
// IO/Communication Errors
#define SL_STATUS_IO ((sl_status_t)0x002F) ///< Generic I/O failure.
#define SL_STATUS_IO_TIMEOUT ((sl_status_t)0x0030) ///< I/O failure due to timeout.
#define SL_STATUS_TRANSMIT ((sl_status_t)0x0031) ///< Generic transmission error.
#define SL_STATUS_TRANSMIT_UNDERFLOW ((sl_status_t)0x0032) ///< Transmit underflowed.
#define SL_STATUS_TRANSMIT_INCOMPLETE ((sl_status_t)0x0033) ///< Transmit is incomplete.
#define SL_STATUS_TRANSMIT_BUSY ((sl_status_t)0x0034) ///< Transmit is busy.
#define SL_STATUS_RECEIVE ((sl_status_t)0x0035) ///< Generic reception error.
#define SL_STATUS_OBJECT_READ ((sl_status_t)0x0036) ///< Failed to read on/via given object.
#define SL_STATUS_OBJECT_WRITE ((sl_status_t)0x0037) ///< Failed to write on/via given object.
#define SL_STATUS_MESSAGE_TOO_LONG ((sl_status_t)0x0038) ///< Message is too long.
// EEPROM/Flash Errors
#define SL_STATUS_EEPROM_MFG_VERSION_MISMATCH ((sl_status_t)0x0039) ///< EEPROM MFG version mismatch.
#define SL_STATUS_EEPROM_STACK_VERSION_MISMATCH ((sl_status_t)0x003A) ///< EEPROM Stack version mismatch.
#define SL_STATUS_FLASH_WRITE_INHIBITED ((sl_status_t)0x003B) ///< Flash write is inhibited.
#define SL_STATUS_FLASH_VERIFY_FAILED ((sl_status_t)0x003C) ///< Flash verification failed.
#define SL_STATUS_FLASH_PROGRAM_FAILED ((sl_status_t)0x003D) ///< Flash programming failed.
#define SL_STATUS_FLASH_ERASE_FAILED ((sl_status_t)0x003E) ///< Flash erase failed.
// MAC Errors
#define SL_STATUS_MAC_NO_DATA ((sl_status_t)0x003F) ///< MAC no data.
#define SL_STATUS_MAC_NO_ACK_RECEIVED ((sl_status_t)0x0040) ///< MAC no ACK received.
#define SL_STATUS_MAC_INDIRECT_TIMEOUT ((sl_status_t)0x0041) ///< MAC indirect timeout.
#define SL_STATUS_MAC_UNKNOWN_HEADER_TYPE ((sl_status_t)0x0042) ///< MAC unknown header type.
#define SL_STATUS_MAC_ACK_HEADER_TYPE ((sl_status_t)0x0043) ///< MAC ACK unknown header type.
#define SL_STATUS_MAC_COMMAND_TRANSMIT_FAILURE ((sl_status_t)0x0044) ///< MAC command transmit failure.
// CLI_STORAGE Errors
#define SL_STATUS_CLI_STORAGE_NVM_OPEN_ERROR ((sl_status_t)0x0045) ///< Error in open NVM
// Security status codes
#define SL_STATUS_SECURITY_IMAGE_CHECKSUM_ERROR ((sl_status_t)0x0046) ///< Image checksum is not valid.
#define SL_STATUS_SECURITY_DECRYPT_ERROR ((sl_status_t)0x0047) ///< Decryption failed
// Command status codes
#define SL_STATUS_COMMAND_IS_INVALID ((sl_status_t)0x0048) ///< Command was not recognized
#define SL_STATUS_COMMAND_TOO_LONG ((sl_status_t)0x0049) ///< Command or parameter maximum length exceeded
#define SL_STATUS_COMMAND_INCOMPLETE ((sl_status_t)0x004A) ///< Data received does not form a complete command
// Misc Errors
#define SL_STATUS_BUS_ERROR ((sl_status_t)0x004B) ///< Bus error, e.g. invalid DMA address
// Unified MAC Errors
#define SL_STATUS_CCA_FAILURE ((sl_status_t)0x004C) ///< CCA failure.
// Scan errors
#define SL_STATUS_MAC_SCANNING ((sl_status_t)0x004D) ///< MAC scanning.
#define SL_STATUS_MAC_INCORRECT_SCAN_TYPE ((sl_status_t)0x004E) ///< MAC incorrect scan type.
#define SL_STATUS_INVALID_CHANNEL_MASK ((sl_status_t)0x004F) ///< Invalid channel mask.
#define SL_STATUS_BAD_SCAN_DURATION ((sl_status_t)0x0050) ///< Bad scan duration.
// MAC transmit related status
#define SL_STATUS_MAC_TRANSMIT_QUEUE_FULL ((sl_status_t)0x0053) ///< The MAC transmit queue is full
#define SL_STATUS_TRANSMIT_SCHEDULER_FAIL ((sl_status_t)0x0054) ///< The transmit attempt failed because the radio scheduler could not find a slot to transmit this packet in or a higher priority event interrupted it
#define SL_STATUS_TRANSMIT_INVALID_CHANNEL ((sl_status_t)0x0055) ///< An unsupported channel setting was specified
#define SL_STATUS_TRANSMIT_INVALID_POWER ((sl_status_t)0x0056) ///< An unsupported power setting was specified
#define SL_STATUS_TRANSMIT_ACK_RECEIVED ((sl_status_t)0x0057) ///< The expected ACK was received after the last transmission
#define SL_STATUS_TRANSMIT_BLOCKED ((sl_status_t)0x0058) ///< The transmit attempt was blocked from going over the air. Typically this is due to the Radio Hold Off (RHO) or Coexistence plugins as they can prevent transmits based on external signals.
// NVM3 specific errors
#define SL_STATUS_NVM3_ALIGNMENT_INVALID ((sl_status_t)0x0059) ///< The initialization was aborted as the NVM3 instance is not aligned properly in memory
#define SL_STATUS_NVM3_SIZE_TOO_SMALL ((sl_status_t)0x005A) ///< The initialization was aborted as the size of the NVM3 instance is too small
#define SL_STATUS_NVM3_PAGE_SIZE_NOT_SUPPORTED ((sl_status_t)0x005B) ///< The initialization was aborted as the NVM3 page size is not supported
#define SL_STATUS_NVM3_TOKEN_INIT_FAILED ((sl_status_t)0x005C) ///< The application that there was an error initializing some of the tokens
#define SL_STATUS_NVM3_OPENED_WITH_OTHER_PARAMETERS ((sl_status_t)0x005D) ///< The initialization was aborted as the NVM3 instance was already opened with other parameters
#define SL_STATUS_NVM3_NO_VALID_PAGES ((sl_status_t)0x005E) ///< Initialization aborted, no valid page found
#define SL_STATUS_NVM3_OBJECT_SIZE_NOT_SUPPORTED ((sl_status_t)0x005F) ///< The object size is not supported
#define SL_STATUS_NVM3_OBJECT_IS_NOT_DATA ((sl_status_t)0x0060) ///< Trying to access a data object which is currently a counter object
#define SL_STATUS_NVM3_OBJECT_IS_NOT_A_COUNTER ((sl_status_t)0x0061) ///< Trying to access a counter object which is currently a data object
#define SL_STATUS_NVM3_WRITE_DATA_SIZE ((sl_status_t)0x0062) ///< The object is too large
#define SL_STATUS_NVM3_READ_DATA_SIZE ((sl_status_t)0x0063) ///< Trying to read with a length different from actual object size
#define SL_STATUS_NVM3_INIT_WITH_FULL_NVM ((sl_status_t)0x0064) ///< The module was opened with a full NVM
#define SL_STATUS_NVM3_RESIZE_PARAMETER ((sl_status_t)0x0065) ///< Illegal parameter
#define SL_STATUS_NVM3_RESIZE_NOT_ENOUGH_SPACE ((sl_status_t)0x0066) ///< Not enough NVM to complete resize
#define SL_STATUS_NVM3_ERASE_COUNT_ERROR ((sl_status_t)0x0067) ///< Erase counts are not valid
#define SL_STATUS_NVM3_NVM_ACCESS ((sl_status_t)0x0068) ///< A NVM function call was failing
#define SL_STATUS_NVM3_CRYPTO_INIT_FAILED ((sl_status_t)0x0069) ///< Crypto initialization failed
#define SL_STATUS_NVM3_ENCRYPTION_KEY_ERROR ((sl_status_t)0x006A) ///< Error in obtaining encryption key
#define SL_STATUS_NVM3_RANDOM_NUM_GENERATION_FAILED ((sl_status_t)0x006B) ///< Error in obtaining random number
#define SL_STATUS_NVM3_ENCRYPTION_FAILED ((sl_status_t)0x006C) ///< Encryption failed
#define SL_STATUS_NVM3_WRITE_TO_NOT_ERASED ((sl_status_t)0x006D) ///< Write to memory that is not erased
#define SL_STATUS_NVM3_INVALID_ADDR ((sl_status_t)0x006E) ///< Invalid NVM address
#define SL_STATUS_NVM3_KEY_MISMATCH ((sl_status_t)0x006F) ///< Key validation failure
#define SL_STATUS_NVM3_SIZE_ERROR ((sl_status_t)0x0070) ///< Size mismatch error
#define SL_STATUS_NVM3_EMULATOR ((sl_status_t)0x0071) ///< Emulator error
#define SL_STATUS_NVM3_SECURITY_INIT_FAILED ((sl_status_t)0x0072) ///< Security init failed
#define SL_STATUS_NVM3_GET_REGION_LOCATION_FAILED ((sl_status_t)0x0073) ///< Get data region location failed
// Bluetooth status codes
#define SL_STATUS_BT_OUT_OF_BONDS ((sl_status_t)0x0402) ///< Bonding procedure can't be started because device has no space left for bond.
#define SL_STATUS_BT_UNSPECIFIED ((sl_status_t)0x0403) ///< Unspecified error
#define SL_STATUS_BT_HARDWARE ((sl_status_t)0x0404) ///< Hardware failure
#define SL_STATUS_BT_NO_BONDING ((sl_status_t)0x0406) ///< The bonding does not exist.
#define SL_STATUS_BT_CRYPTO ((sl_status_t)0x0407) ///< Error using crypto functions
#define SL_STATUS_BT_DATA_CORRUPTED ((sl_status_t)0x0408) ///< Data was corrupted.
#define SL_STATUS_BT_INVALID_SYNC_HANDLE ((sl_status_t)0x040A) ///< Invalid periodic advertising sync handle
#define SL_STATUS_BT_INVALID_MODULE_ACTION ((sl_status_t)0x040B) ///< Bluetooth cannot be used on this hardware
#define SL_STATUS_BT_RADIO ((sl_status_t)0x040C) ///< Error received from radio
#define SL_STATUS_BT_L2CAP_REMOTE_DISCONNECTED ((sl_status_t)0x040D) ///< Returned when remote disconnects the connection-oriented channel by sending disconnection request.
#define SL_STATUS_BT_L2CAP_LOCAL_DISCONNECTED ((sl_status_t)0x040E) ///< Returned when local host disconnect the connection-oriented channel by sending disconnection request.
#define SL_STATUS_BT_L2CAP_CID_NOT_EXIST ((sl_status_t)0x040F) ///< Returned when local host did not find a connection-oriented channel with given destination CID.
#define SL_STATUS_BT_L2CAP_LE_DISCONNECTED ((sl_status_t)0x0410) ///< Returned when connection-oriented channel disconnected due to LE connection is dropped.
#define SL_STATUS_BT_L2CAP_FLOW_CONTROL_VIOLATED ((sl_status_t)0x0412) ///< Returned when connection-oriented channel disconnected due to remote end send data even without credit.
#define SL_STATUS_BT_L2CAP_FLOW_CONTROL_CREDIT_OVERFLOWED ((sl_status_t)0x0413) ///< Returned when connection-oriented channel disconnected due to remote end send flow control credits exceed 65535.
#define SL_STATUS_BT_L2CAP_NO_FLOW_CONTROL_CREDIT ((sl_status_t)0x0414) ///< Returned when connection-oriented channel has run out of flow control credit and local application still trying to send data.
#define SL_STATUS_BT_L2CAP_CONNECTION_REQUEST_TIMEOUT ((sl_status_t)0x0415) ///< Returned when connection-oriented channel has not received connection response message within maximum timeout.
#define SL_STATUS_BT_L2CAP_INVALID_CID ((sl_status_t)0x0416) ///< Returned when local host received a connection-oriented channel connection response with an invalid destination CID.
#define SL_STATUS_BT_L2CAP_WRONG_STATE ((sl_status_t)0x0417) ///< Returned when local host application tries to send a command which is not suitable for L2CAP channel's current state.
#define SL_STATUS_BT_PS_STORE_FULL ((sl_status_t)0x041B) ///< Flash reserved for PS store is full
#define SL_STATUS_BT_PS_KEY_NOT_FOUND ((sl_status_t)0x041C) ///< PS key not found
#define SL_STATUS_BT_APPLICATION_MISMATCHED_OR_INSUFFICIENT_SECURITY ((sl_status_t)0x041D) ///< Mismatched or insufficient security level
#define SL_STATUS_BT_APPLICATION_ENCRYPTION_DECRYPTION_ERROR ((sl_status_t)0x041E) ///< Encryption/decryption operation failed.
// Bluetooth controller status codes
#define SL_STATUS_BT_CTRL_UNKNOWN_CONNECTION_IDENTIFIER ((sl_status_t)0x1002) ///< Connection does not exist, or connection open request was cancelled.
#define SL_STATUS_BT_CTRL_AUTHENTICATION_FAILURE ((sl_status_t)0x1005) ///< Pairing or authentication failed due to incorrect results in the pairing or authentication procedure. This could be due to an incorrect PIN or Link Key
#define SL_STATUS_BT_CTRL_PIN_OR_KEY_MISSING ((sl_status_t)0x1006) ///< Pairing failed because of missing PIN, or authentication failed because of missing Key
#define SL_STATUS_BT_CTRL_MEMORY_CAPACITY_EXCEEDED ((sl_status_t)0x1007) ///< Controller is out of memory.
#define SL_STATUS_BT_CTRL_CONNECTION_TIMEOUT ((sl_status_t)0x1008) ///< Link supervision timeout has expired.
#define SL_STATUS_BT_CTRL_CONNECTION_LIMIT_EXCEEDED ((sl_status_t)0x1009) ///< Controller is at limit of connections it can support.
#define SL_STATUS_BT_CTRL_SYNCHRONOUS_CONNECTION_LIMIT_EXCEEDED ((sl_status_t)0x100A) ///< The Synchronous Connection Limit to a Device Exceeded error code indicates that the Controller has reached the limit to the number of synchronous connections that can be achieved to a device.
#define SL_STATUS_BT_CTRL_ACL_CONNECTION_ALREADY_EXISTS ((sl_status_t)0x100B) ///< The ACL Connection Already Exists error code indicates that an attempt to create a new ACL Connection to a device when there is already a connection to this device.
#define SL_STATUS_BT_CTRL_COMMAND_DISALLOWED ((sl_status_t)0x100C) ///< Command requested cannot be executed because the Controller is in a state where it cannot process this command at this time.
#define SL_STATUS_BT_CTRL_CONNECTION_REJECTED_DUE_TO_LIMITED_RESOURCES ((sl_status_t)0x100D) ///< The Connection Rejected Due To Limited Resources error code indicates that an incoming connection was rejected due to limited resources.
#define SL_STATUS_BT_CTRL_CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS ((sl_status_t)0x100E) ///< The Connection Rejected Due To Security Reasons error code indicates that a connection was rejected due to security requirements not being fulfilled, like authentication or pairing.
#define SL_STATUS_BT_CTRL_CONNECTION_REJECTED_DUE_TO_UNACCEPTABLE_BD_ADDR ((sl_status_t)0x100F) ///< The Connection was rejected because this device does not accept the BD_ADDR. This may be because the device will only accept connections from specific BD_ADDRs.
#define SL_STATUS_BT_CTRL_CONNECTION_ACCEPT_TIMEOUT_EXCEEDED ((sl_status_t)0x1010) ///< The Connection Accept Timeout has been exceeded for this connection attempt.
#define SL_STATUS_BT_CTRL_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE ((sl_status_t)0x1011) ///< A feature or parameter value in the HCI command is not supported.
#define SL_STATUS_BT_CTRL_INVALID_COMMAND_PARAMETERS ((sl_status_t)0x1012) ///< Command contained invalid parameters.
#define SL_STATUS_BT_CTRL_REMOTE_USER_TERMINATED ((sl_status_t)0x1013) ///< User on the remote device terminated the connection.
#define SL_STATUS_BT_CTRL_REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES ((sl_status_t)0x1014) ///< The remote device terminated the connection because of low resources
#define SL_STATUS_BT_CTRL_REMOTE_POWERING_OFF ((sl_status_t)0x1015) ///< Remote Device Terminated Connection due to Power Off
#define SL_STATUS_BT_CTRL_CONNECTION_TERMINATED_BY_LOCAL_HOST ((sl_status_t)0x1016) ///< Local device terminated the connection.
#define SL_STATUS_BT_CTRL_REPEATED_ATTEMPTS ((sl_status_t)0x1017) ///< The Controller is disallowing an authentication or pairing procedure because too little time has elapsed since the last authentication or pairing attempt failed.
#define SL_STATUS_BT_CTRL_PAIRING_NOT_ALLOWED ((sl_status_t)0x1018) ///< The device does not allow pairing. This can be for example, when a device only allows pairing during a certain time window after some user input allows pairing
#define SL_STATUS_BT_CTRL_UNSUPPORTED_REMOTE_FEATURE ((sl_status_t)0x101A) ///< The remote device does not support the feature associated with the issued command.
#define SL_STATUS_BT_CTRL_INVALID_LL_PARAMETERS ((sl_status_t)0x101E) ///< Indicates that some LMP PDU / LL Control PDU parameters were invalid
#define SL_STATUS_BT_CTRL_UNSPECIFIED_ERROR ((sl_status_t)0x101F) ///< No other error code specified is appropriate to use.
#define SL_STATUS_BT_CTRL_LL_RESPONSE_TIMEOUT ((sl_status_t)0x1022) ///< Connection terminated due to link-layer procedure timeout.
#define SL_STATUS_BT_CTRL_LL_PROCEDURE_COLLISION ((sl_status_t)0x1023) ///< LL procedure has collided with the same transaction or procedure that is already in progress.
#define SL_STATUS_BT_CTRL_ENCRYPTION_MODE_NOT_ACCEPTABLE ((sl_status_t)0x1025) ///< The requested encryption mode is not acceptable at this time.
#define SL_STATUS_BT_CTRL_LINK_KEY_CANNOT_BE_CHANGED ((sl_status_t)0x1026) ///< Link key cannot be changed because a fixed unit key is being used.
#define SL_STATUS_BT_CTRL_INSTANT_PASSED ((sl_status_t)0x1028) ///< LMP PDU or LL PDU that includes an instant cannot be performed because the instant when this would have occurred has passed.
#define SL_STATUS_BT_CTRL_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED ((sl_status_t)0x1029) ///< It was not possible to pair as a unit key was requested and it is not supported.
#define SL_STATUS_BT_CTRL_DIFFERENT_TRANSACTION_COLLISION ((sl_status_t)0x102A) ///< LMP transaction was started that collides with an ongoing transaction.
#define SL_STATUS_BT_CTRL_CHANNEL_ASSESSMENT_NOT_SUPPORTED ((sl_status_t)0x102E) ///< The Controller cannot perform channel assessment because it is not supported.
#define SL_STATUS_BT_CTRL_INSUFFICIENT_SECURITY ((sl_status_t)0x102F) ///< The HCI command or LMP PDU sent is only possible on an encrypted link.
#define SL_STATUS_BT_CTRL_PARAMETER_OUT_OF_MANDATORY_RANGE ((sl_status_t)0x1030) ///< A parameter value requested is outside the mandatory range of parameters for the given HCI command or LMP PDU.
#define SL_STATUS_BT_CTRL_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST ((sl_status_t)0x1037) ///< The IO capabilities request or response was rejected because the sending Host does not support Secure Simple Pairing even though the receiving Link Manager does.
#define SL_STATUS_BT_CTRL_HOST_BUSY_PAIRING ((sl_status_t)0x1038) ///< The Host is busy with another pairing operation and unable to support the requested pairing. The receiving device should retry pairing again later.
#define SL_STATUS_BT_CTRL_CONNECTION_REJECTED_DUE_TO_NO_SUITABLE_CHANNEL_FOUND ((sl_status_t)0x1039) ///< The Controller could not calculate an appropriate value for the Channel selection operation.
#define SL_STATUS_BT_CTRL_CONTROLLER_BUSY ((sl_status_t)0x103A) ///< Operation was rejected because the controller is busy and unable to process the request.
#define SL_STATUS_BT_CTRL_UNACCEPTABLE_CONNECTION_INTERVAL ((sl_status_t)0x103B) ///< Remote device terminated the connection because of an unacceptable connection interval.
#define SL_STATUS_BT_CTRL_ADVERTISING_TIMEOUT ((sl_status_t)0x103C) ///< Advertising for a fixed duration completed or, for directed advertising, that advertising completed without a connection being created.
#define SL_STATUS_BT_CTRL_CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE ((sl_status_t)0x103D) ///< Connection was terminated because the Message Integrity Check (MIC) failed on a received packet.
#define SL_STATUS_BT_CTRL_CONNECTION_FAILED_TO_BE_ESTABLISHED ((sl_status_t)0x103E) ///< LL initiated a connection but the connection has failed to be established. Controller did not receive any packets from remote end.
#define SL_STATUS_BT_CTRL_MAC_CONNECTION_FAILED ((sl_status_t)0x103F) ///< The MAC of the 802.11 AMP was requested to connect to a peer, but the connection failed.
#define SL_STATUS_BT_CTRL_COARSE_CLOCK_ADJUSTMENT_REJECTED_BUT_WILL_TRY_TO_ADJUST_USING_CLOCK_DRAGGING ((sl_status_t)0x1040) ///< The master, at this time, is unable to make a coarse adjustment to the piconet clock, using the supplied parameters. Instead the master will attempt to move the clock using clock dragging.
#define SL_STATUS_BT_CTRL_UNKNOWN_ADVERTISING_IDENTIFIER ((sl_status_t)0x1042) ///< A command was sent from the Host that should identify an Advertising or Sync handle, but the Advertising or Sync handle does not exist.
#define SL_STATUS_BT_CTRL_LIMIT_REACHED ((sl_status_t)0x1043) ///< Number of operations requested has been reached and has indicated the completion of the activity (e.g., advertising or scanning).
#define SL_STATUS_BT_CTRL_OPERATION_CANCELLED_BY_HOST ((sl_status_t)0x1044) ///< A request to the Controller issued by the Host and still pending was successfully canceled.
#define SL_STATUS_BT_CTRL_PACKET_TOO_LONG ((sl_status_t)0x1045) ///< An attempt was made to send or receive a packet that exceeds the maximum allowed packet length.
#define SL_STATUS_BT_CTRL_TOO_LATE ((sl_status_t)0x1046) ///< Information was provided too late to the controller.
#define SL_STATUS_BT_CTRL_TOO_EARLY ((sl_status_t)0x1047) ///< Information was provided too early to the controller.
#define SL_STATUS_BT_CTRL_INSUFFICIENT_CHANNELS ((sl_status_t)0x1048) ///< Indicates that the result of the requested operation would yield too few physical channels.
// Bluetooth attribute status codes
#define SL_STATUS_BT_ATT_INVALID_HANDLE ((sl_status_t)0x1101) ///< The attribute handle given was not valid on this server
#define SL_STATUS_BT_ATT_READ_NOT_PERMITTED ((sl_status_t)0x1102) ///< The attribute cannot be read
#define SL_STATUS_BT_ATT_WRITE_NOT_PERMITTED ((sl_status_t)0x1103) ///< The attribute cannot be written
#define SL_STATUS_BT_ATT_INVALID_PDU ((sl_status_t)0x1104) ///< The attribute PDU was invalid
#define SL_STATUS_BT_ATT_INSUFFICIENT_AUTHENTICATION ((sl_status_t)0x1105) ///< The attribute requires authentication before it can be read or written.
#define SL_STATUS_BT_ATT_REQUEST_NOT_SUPPORTED ((sl_status_t)0x1106) ///< Attribute Server does not support the request received from the client.
#define SL_STATUS_BT_ATT_INVALID_OFFSET ((sl_status_t)0x1107) ///< Offset specified was past the end of the attribute
#define SL_STATUS_BT_ATT_INSUFFICIENT_AUTHORIZATION ((sl_status_t)0x1108) ///< The attribute requires authorization before it can be read or written.
#define SL_STATUS_BT_ATT_PREPARE_QUEUE_FULL ((sl_status_t)0x1109) ///< Too many prepare writes have been queued
#define SL_STATUS_BT_ATT_ATT_NOT_FOUND ((sl_status_t)0x110A) ///< No attribute found within the given attribute handle range.
#define SL_STATUS_BT_ATT_ATT_NOT_LONG ((sl_status_t)0x110B) ///< The attribute cannot be read or written using the Read Blob Request
#define SL_STATUS_BT_ATT_INSUFFICIENT_ENC_KEY_SIZE ((sl_status_t)0x110C) ///< The Encryption Key Size used for encrypting this link is insufficient.
#define SL_STATUS_BT_ATT_INVALID_ATT_LENGTH ((sl_status_t)0x110D) ///< The attribute value length is invalid for the operation
#define SL_STATUS_BT_ATT_UNLIKELY_ERROR ((sl_status_t)0x110E) ///< The attribute request that was requested has encountered an error that was unlikely, and therefore could not be completed as requested.
#define SL_STATUS_BT_ATT_INSUFFICIENT_ENCRYPTION ((sl_status_t)0x110F) ///< The attribute requires encryption before it can be read or written.
#define SL_STATUS_BT_ATT_UNSUPPORTED_GROUP_TYPE ((sl_status_t)0x1110) ///< The attribute type is not a supported grouping attribute as defined by a higher layer specification.
#define SL_STATUS_BT_ATT_INSUFFICIENT_RESOURCES ((sl_status_t)0x1111) ///< Insufficient Resources to complete the request
#define SL_STATUS_BT_ATT_OUT_OF_SYNC ((sl_status_t)0x1112) ///< The server requests the client to rediscover the database.
#define SL_STATUS_BT_ATT_VALUE_NOT_ALLOWED ((sl_status_t)0x1113) ///< The attribute parameter value was not allowed.
#define SL_STATUS_BT_ATT_APPLICATION ((sl_status_t)0x1180) ///< When this is returned in a BGAPI response, the application tried to read or write the value of a user attribute from the GATT database.
#define SL_STATUS_BT_ATT_WRITE_REQUEST_REJECTED ((sl_status_t)0x11FC) ///< The requested write operation cannot be fulfilled for reasons other than permissions.
#define SL_STATUS_BT_ATT_CLIENT_CHARACTERISTIC_CONFIGURATION_DESCRIPTOR_IMPROPERLY_CONFIGURED ((sl_status_t)0x11FD) ///< The Client Characteristic Configuration descriptor is not configured according to the requirements of the profile or service.
#define SL_STATUS_BT_ATT_PROCEDURE_ALREADY_IN_PROGRESS ((sl_status_t)0x11FE) ///< The profile or service request cannot be serviced because an operation that has been previously triggered is still in progress.
#define SL_STATUS_BT_ATT_OUT_OF_RANGE ((sl_status_t)0x11FF) ///< The attribute value is out of range as defined by a profile or service specification.
// Bluetooth Security Manager Protocol status codes
#define SL_STATUS_BT_SMP_PASSKEY_ENTRY_FAILED ((sl_status_t)0x1201) ///< The user input of passkey failed, for example, the user cancelled the operation
#define SL_STATUS_BT_SMP_OOB_NOT_AVAILABLE ((sl_status_t)0x1202) ///< Out of Band data is not available for authentication
#define SL_STATUS_BT_SMP_AUTHENTICATION_REQUIREMENTS ((sl_status_t)0x1203) ///< The pairing procedure cannot be performed as authentication requirements cannot be met due to IO capabilities of one or both devices
#define SL_STATUS_BT_SMP_CONFIRM_VALUE_FAILED ((sl_status_t)0x1204) ///< The confirm value does not match the calculated compare value
#define SL_STATUS_BT_SMP_PAIRING_NOT_SUPPORTED ((sl_status_t)0x1205) ///< Pairing is not supported by the device
#define SL_STATUS_BT_SMP_ENCRYPTION_KEY_SIZE ((sl_status_t)0x1206) ///< The resultant encryption key size is insufficient for the security requirements of this device
#define SL_STATUS_BT_SMP_COMMAND_NOT_SUPPORTED ((sl_status_t)0x1207) ///< The SMP command received is not supported on this device
#define SL_STATUS_BT_SMP_UNSPECIFIED_REASON ((sl_status_t)0x1208) ///< Pairing failed due to an unspecified reason
#define SL_STATUS_BT_SMP_REPEATED_ATTEMPTS ((sl_status_t)0x1209) ///< Pairing or authentication procedure is disallowed because too little time has elapsed since last pairing request or security request
#define SL_STATUS_BT_SMP_INVALID_PARAMETERS ((sl_status_t)0x120A) ///< The Invalid Parameters error code indicates: the command length is invalid or a parameter is outside of the specified range.
#define SL_STATUS_BT_SMP_DHKEY_CHECK_FAILED ((sl_status_t)0x120B) ///< Indicates to the remote device that the DHKey Check value received doesn't match the one calculated by the local device.
#define SL_STATUS_BT_SMP_NUMERIC_COMPARISON_FAILED ((sl_status_t)0x120C) ///< Indicates that the confirm values in the numeric comparison protocol do not match.
#define SL_STATUS_BT_SMP_BREDR_PAIRING_IN_PROGRESS ((sl_status_t)0x120D) ///< Indicates that the pairing over the LE transport failed due to a Pairing Request sent over the BR/EDR transport in process.
#define SL_STATUS_BT_SMP_CROSS_TRANSPORT_KEY_DERIVATION_GENERATION_NOT_ALLOWED ((sl_status_t)0x120E) ///< Indicates that the BR/EDR Link Key generated on the BR/EDR transport cannot be used to derive and distribute keys for the LE transport.
#define SL_STATUS_BT_SMP_KEY_REJECTED ((sl_status_t)0x120F) ///< Indicates that the device chose not to accept a distributed key.
// Bluetooth Mesh status codes
#define SL_STATUS_BT_MESH_ALREADY_EXISTS ((sl_status_t)0x0501) ///< Returned when trying to add a key or some other unique resource with an ID which already exists
#define SL_STATUS_BT_MESH_DOES_NOT_EXIST ((sl_status_t)0x0502) ///< Returned when trying to manipulate a key or some other resource with an ID which does not exist
#define SL_STATUS_BT_MESH_LIMIT_REACHED ((sl_status_t)0x0503) ///< Returned when an operation cannot be executed because a pre-configured limit for keys, key bindings, elements, models, virtual addresses, provisioned devices, or provisioning sessions is reached
#define SL_STATUS_BT_MESH_INVALID_ADDRESS ((sl_status_t)0x0504) ///< Returned when trying to use a reserved address or add a "pre-provisioned" device using an address already used by some other device
#define SL_STATUS_BT_MESH_MALFORMED_DATA ((sl_status_t)0x0505) ///< In a BGAPI response, the user supplied malformed data; in a BGAPI event, the remote end responded with malformed or unrecognized data
#define SL_STATUS_BT_MESH_ALREADY_INITIALIZED ((sl_status_t)0x0506) ///< An attempt was made to initialize a subsystem that was already initialized.
#define SL_STATUS_BT_MESH_NOT_INITIALIZED ((sl_status_t)0x0507) ///< An attempt was made to use a subsystem that wasn't initialized yet. Call the subsystem's init function first.
#define SL_STATUS_BT_MESH_NO_FRIEND_OFFER ((sl_status_t)0x0508) ///< Returned when trying to establish a friendship as a Low Power Node, but no acceptable friend offer message was received.
#define SL_STATUS_BT_MESH_PROV_LINK_CLOSED ((sl_status_t)0x0509) ///< Provisioning link was unexpectedly closed before provisioning was complete.
#define SL_STATUS_BT_MESH_PROV_INVALID_PDU ((sl_status_t)0x050A) ///< An unrecognized provisioning PDU was received.
#define SL_STATUS_BT_MESH_PROV_INVALID_PDU_FORMAT ((sl_status_t)0x050B) ///< A provisioning PDU with wrong length or containing field values that are out of bounds was received.
#define SL_STATUS_BT_MESH_PROV_UNEXPECTED_PDU ((sl_status_t)0x050C) ///< An unexpected (out of sequence) provisioning PDU was received.
#define SL_STATUS_BT_MESH_PROV_CONFIRMATION_FAILED ((sl_status_t)0x050D) ///< The computed confirmation value did not match the expected value.
#define SL_STATUS_BT_MESH_PROV_OUT_OF_RESOURCES ((sl_status_t)0x050E) ///< Provisioning could not be continued due to insufficient resources.
#define SL_STATUS_BT_MESH_PROV_DECRYPTION_FAILED ((sl_status_t)0x050F) ///< The provisioning data block could not be decrypted.
#define SL_STATUS_BT_MESH_PROV_UNEXPECTED_ERROR ((sl_status_t)0x0510) ///< An unexpected error happened during provisioning.
#define SL_STATUS_BT_MESH_PROV_CANNOT_ASSIGN_ADDR ((sl_status_t)0x0511) ///< Device could not assign unicast addresses to all of its elements.
#define SL_STATUS_BT_MESH_ADDRESS_TEMPORARILY_UNAVAILABLE ((sl_status_t)0x0512) ///< Returned when trying to reuse an address of a previously deleted device before an IV Index Update has been executed.
#define SL_STATUS_BT_MESH_ADDRESS_ALREADY_USED ((sl_status_t)0x0513) ///< Returned when trying to assign an address that is used by one of the devices in the Device Database, or by the Provisioner itself.
#define SL_STATUS_BT_MESH_PUBLISH_NOT_CONFIGURED ((sl_status_t)0x0514) ///< Application key or publish address are not set
#define SL_STATUS_BT_MESH_APP_KEY_NOT_BOUND ((sl_status_t)0x0515) ///< Application key is not bound to a model
// Bluetooth Mesh foundation status codes
#define SL_STATUS_BT_MESH_FOUNDATION_INVALID_ADDRESS ((sl_status_t)0x1301) ///< Returned when address in request was not valid
#define SL_STATUS_BT_MESH_FOUNDATION_INVALID_MODEL ((sl_status_t)0x1302) ///< Returned when model identified is not found for a given element
#define SL_STATUS_BT_MESH_FOUNDATION_INVALID_APP_KEY ((sl_status_t)0x1303) ///< Returned when the key identified by AppKeyIndex is not stored in the node
#define SL_STATUS_BT_MESH_FOUNDATION_INVALID_NET_KEY ((sl_status_t)0x1304) ///< Returned when the key identified by NetKeyIndex is not stored in the node
#define SL_STATUS_BT_MESH_FOUNDATION_INSUFFICIENT_RESOURCES ((sl_status_t)0x1305) ///< Returned when The node cannot serve the request due to insufficient resources
#define SL_STATUS_BT_MESH_FOUNDATION_KEY_INDEX_EXISTS ((sl_status_t)0x1306) ///< Returned when the key identified is already stored in the node and the new NetKey value is different
#define SL_STATUS_BT_MESH_FOUNDATION_INVALID_PUBLISH_PARAMS ((sl_status_t)0x1307) ///< Returned when the model does not support the publish mechanism
#define SL_STATUS_BT_MESH_FOUNDATION_NOT_SUBSCRIBE_MODEL ((sl_status_t)0x1308) ///< Returned when the model does not support the subscribe mechanism
#define SL_STATUS_BT_MESH_FOUNDATION_STORAGE_FAILURE ((sl_status_t)0x1309) ///< Returned when storing of the requested parameters failed
#define SL_STATUS_BT_MESH_FOUNDATION_NOT_SUPPORTED ((sl_status_t)0x130A) ///< Returned when requested setting is not supported
#define SL_STATUS_BT_MESH_FOUNDATION_CANNOT_UPDATE ((sl_status_t)0x130B) ///< Returned when the requested update operation cannot be performed due to general constraints
#define SL_STATUS_BT_MESH_FOUNDATION_CANNOT_REMOVE ((sl_status_t)0x130C) ///< Returned when the requested delete operation cannot be performed due to general constraints
#define SL_STATUS_BT_MESH_FOUNDATION_CANNOT_BIND ((sl_status_t)0x130D) ///< Returned when the requested bind operation cannot be performed due to general constraints
#define SL_STATUS_BT_MESH_FOUNDATION_TEMPORARILY_UNABLE ((sl_status_t)0x130E) ///< Returned when The node cannot start advertising with Node Identity or Proxy since the maximum number of parallel advertising is reached
#define SL_STATUS_BT_MESH_FOUNDATION_CANNOT_SET ((sl_status_t)0x130F) ///< Returned when the requested state cannot be set
#define SL_STATUS_BT_MESH_FOUNDATION_UNSPECIFIED ((sl_status_t)0x1310) ///< Returned when an unspecified error took place
#define SL_STATUS_BT_MESH_FOUNDATION_INVALID_BINDING ((sl_status_t)0x1311) ///< Returned when the NetKeyIndex and AppKeyIndex combination is not valid for a Config AppKey Update
// -----------------------------------------------------------------------------
// Wi-Fi Errors
#define SL_STATUS_WIFI_INVALID_KEY ((sl_status_t)0x0B01) ///< Invalid firmware keyset
#define SL_STATUS_WIFI_FIRMWARE_DOWNLOAD_TIMEOUT ((sl_status_t)0x0B02) ///< The firmware download took too long
#define SL_STATUS_WIFI_UNSUPPORTED_MESSAGE_ID ((sl_status_t)0x0B03) ///< Unknown request ID or wrong interface ID used
#define SL_STATUS_WIFI_WARNING ((sl_status_t)0x0B04) ///< The request is successful but some parameters have been ignored
#define SL_STATUS_WIFI_NO_PACKET_TO_RECEIVE ((sl_status_t)0x0B05) ///< No Packets waiting to be received
#define SL_STATUS_WIFI_SLEEP_GRANTED ((sl_status_t)0x0B08) ///< The sleep mode is granted
#define SL_STATUS_WIFI_SLEEP_NOT_GRANTED ((sl_status_t)0x0B09) ///< The WFx does not go back to sleep
#define SL_STATUS_WIFI_SECURE_LINK_MAC_KEY_ERROR ((sl_status_t)0x0B10) ///< The SecureLink MAC key was not found
#define SL_STATUS_WIFI_SECURE_LINK_MAC_KEY_ALREADY_BURNED ((sl_status_t)0x0B11) ///< The SecureLink MAC key is already installed in OTP
#define SL_STATUS_WIFI_SECURE_LINK_RAM_MODE_NOT_ALLOWED ((sl_status_t)0x0B12) ///< The SecureLink MAC key cannot be installed in RAM
#define SL_STATUS_WIFI_SECURE_LINK_FAILED_UNKNOWN_MODE ((sl_status_t)0x0B13) ///< The SecureLink MAC key installation failed
#define SL_STATUS_WIFI_SECURE_LINK_EXCHANGE_FAILED ((sl_status_t)0x0B14) ///< SecureLink key (re)negotiation failed
#define SL_STATUS_WIFI_WRONG_STATE ((sl_status_t)0x0B18) ///< The device is in an inappropriate state to perform the request
#define SL_STATUS_WIFI_CHANNEL_NOT_ALLOWED ((sl_status_t)0x0B19) ///< The request failed due to regulatory limitations
#define SL_STATUS_WIFI_NO_MATCHING_AP ((sl_status_t)0x0B1A) ///< The connection request failed because no suitable AP was found
#define SL_STATUS_WIFI_CONNECTION_ABORTED ((sl_status_t)0x0B1B) ///< The connection request was aborted by host
#define SL_STATUS_WIFI_CONNECTION_TIMEOUT ((sl_status_t)0x0B1C) ///< The connection request failed because of a timeout
#define SL_STATUS_WIFI_CONNECTION_REJECTED_BY_AP ((sl_status_t)0x0B1D) ///< The connection request failed because the AP rejected the device
#define SL_STATUS_WIFI_CONNECTION_AUTH_FAILURE ((sl_status_t)0x0B1E) ///< The connection request failed because the WPA handshake did not complete successfully
#define SL_STATUS_WIFI_RETRY_EXCEEDED ((sl_status_t)0x0B1F) ///< The request failed because the retry limit was exceeded
#define SL_STATUS_WIFI_TX_LIFETIME_EXCEEDED ((sl_status_t)0x0B20) ///< The request failed because the MSDU life time was exceeded
// -----------------------------------------------------------------------------
// MVP Driver and MVP Math status codes
#define SL_STATUS_COMPUTE_DRIVER_FAULT ((sl_status_t)0x1501) ///< Critical fault
#define SL_STATUS_COMPUTE_DRIVER_ALU_NAN ((sl_status_t)0x1502) ///< ALU operation output NaN
#define SL_STATUS_COMPUTE_DRIVER_ALU_OVERFLOW ((sl_status_t)0x1503) ///< ALU numeric overflow
#define SL_STATUS_COMPUTE_DRIVER_ALU_UNDERFLOW ((sl_status_t)0x1504) ///< ALU numeric underflow
#define SL_STATUS_COMPUTE_DRIVER_STORE_CONVERSION_OVERFLOW ((sl_status_t)0x1505) ///< Overflow during array store
#define SL_STATUS_COMPUTE_DRIVER_STORE_CONVERSION_UNDERFLOW ((sl_status_t)0x1506) ///< Underflow during array store conversion
#define SL_STATUS_COMPUTE_DRIVER_STORE_CONVERSION_INFINITY ((sl_status_t)0x1507) ///< Infinity encountered during array store conversion
#define SL_STATUS_COMPUTE_DRIVER_STORE_CONVERSION_NAN ((sl_status_t)0x1508) ///< NaN encountered during array store conversion
#define SL_STATUS_COMPUTE_MATH_NAN ((sl_status_t)0x1512) ///< MATH NaN encountered
#define SL_STATUS_COMPUTE_MATH_INFINITY ((sl_status_t)0x1513) ///< MATH Infinity encountered
#define SL_STATUS_COMPUTE_MATH_OVERFLOW ((sl_status_t)0x1514) ///< MATH numeric overflow
#define SL_STATUS_COMPUTE_MATH_UNDERFLOW ((sl_status_t)0x1515) ///< MATH numeric underflow
// Zigbee status codes
#define SL_STATUS_ZIGBEE_PACKET_HANDOFF_DROPPED ((sl_status_t)0x0C01) ///< Packet is dropped by packet-handoff callbacks
#define SL_STATUS_ZIGBEE_DELIVERY_FAILED ((sl_status_t)0x0C02) ///< The APS layer attempted to send or deliver a message and failed
#define SL_STATUS_ZIGBEE_MAX_MESSAGE_LIMIT_REACHED ((sl_status_t)0x0C03) ///< The maximum number of in-flight messages ::EMBER_APS_UNICAST_MESSAGE_COUNT has been reached
#define SL_STATUS_ZIGBEE_BINDING_IS_ACTIVE ((sl_status_t)0x0C04) ///< The application is trying to delete or overwrite a binding that is in use
#define SL_STATUS_ZIGBEE_ADDRESS_TABLE_ENTRY_IS_ACTIVE ((sl_status_t)0x0C05) ///< The application is trying to overwrite an address table entry that is in use
#define SL_STATUS_ZIGBEE_MOVE_FAILED ((sl_status_t)0x0C06) ///< After moving, a mobile node's attempt to re-establish contact with the network failed
#define SL_STATUS_ZIGBEE_NODE_ID_CHANGED ((sl_status_t)0x0C07) ///< The local node ID has changed. The application can get the new node ID by calling ::sl_zigbee_get_node_id()
#define SL_STATUS_ZIGBEE_INVALID_SECURITY_LEVEL ((sl_status_t)0x0C08) ///< The chosen security level is not supported by the stack
#define SL_STATUS_ZIGBEE_IEEE_ADDRESS_DISCOVERY_IN_PROGRESS ((sl_status_t)0x0C09) ///< An error occurred when trying to encrypt at the APS Level
#define SL_STATUS_ZIGBEE_APS_ENCRYPTION_ERROR ((sl_status_t)0x0C0A) ///< An error occurred when trying to encrypt at the APS Level
#define SL_STATUS_ZIGBEE_SECURITY_STATE_NOT_SET ((sl_status_t)0x0C0B) ///< There was an attempt to form or join a network with security without calling ::sl_zigbee_set_initial_security_state() first
#define SL_STATUS_ZIGBEE_TOO_SOON_FOR_SWITCH_KEY ((sl_status_t)0x0C0C) ///< There was an attempt to broadcast a key switch too quickly after broadcasting the next network key. The Trust Center must wait at least a period equal to the broadcast timeout so that all routers have a chance to receive the broadcast of the new network key
#define SL_STATUS_ZIGBEE_SIGNATURE_VERIFY_FAILURE ((sl_status_t)0x0C0D) ///< The received signature corresponding to the message that was passed to the CBKE Library failed verification and is not valid
#define SL_STATUS_ZIGBEE_KEY_NOT_AUTHORIZED ((sl_status_t)0x0C0E) ///< The message could not be sent because the link key corresponding to the destination is not authorized for use in APS data messages
#define SL_STATUS_ZIGBEE_BINDING_HAS_CHANGED ((sl_status_t)0x0C0F) ///< The application tried to use a binding that has been remotely modified and the change has not yet been reported to the application
#define SL_STATUS_ZIGBEE_TRUST_CENTER_SWAP_EUI_HAS_CHANGED ((sl_status_t)0x0C10) ///< The EUI of the Trust center has changed due to a successful rejoin after TC Swapout
#define SL_STATUS_ZIGBEE_TRUST_CENTER_SWAP_EUI_HAS_NOT_CHANGED ((sl_status_t)0x0C11) ///< A Trust Center Swapout Rejoin has occurred without the EUI of the TC changing
#define SL_STATUS_ZIGBEE_INSUFFICIENT_RANDOM_DATA ((sl_status_t)0x0C12) ///< An attempt to generate random bytes failed because of insufficient random data from the radio
#define SL_STATUS_ZIGBEE_SOURCE_ROUTE_FAILURE ((sl_status_t)0x0C13) ///< A Zigbee route error command frame was received indicating that a source routed message from this node failed en route
#define SL_STATUS_ZIGBEE_MANY_TO_ONE_ROUTE_FAILURE ((sl_status_t)0x0C14) ///< A Zigbee route error command frame was received indicating that a message sent to this node along a many-to-one route failed en route
#define SL_STATUS_ZIGBEE_STACK_AND_HARDWARE_MISMATCH ((sl_status_t)0x0C15) ///< A critical and fatal error indicating that the version of the stack trying to run does not match with the chip it's running on
#define SL_STATUS_ZIGBEE_PAN_ID_CHANGED ((sl_status_t)0x0C16) ///< The local PAN ID has changed. The application can get the new PAN ID by calling ::emberGetPanId()
#define SL_STATUS_ZIGBEE_CHANNEL_CHANGED ((sl_status_t)0x0C17) ///< The channel has changed.
#define SL_STATUS_ZIGBEE_NETWORK_OPENED ((sl_status_t)0x0C18) ///< The network has been opened for joining.
#define SL_STATUS_ZIGBEE_NETWORK_CLOSED ((sl_status_t)0x0C19) ///< The network has been closed for joining.
#define SL_STATUS_ZIGBEE_RECEIVED_KEY_IN_THE_CLEAR ((sl_status_t)0x0C1A) ///< An attempt was made to join a Secured Network using a pre-configured key, but the Trust Center sent back a Network Key in-the-clear when an encrypted Network Key was required. (::EMBER_REQUIRE_ENCRYPTED_KEY)
#define SL_STATUS_ZIGBEE_NO_NETWORK_KEY_RECEIVED ((sl_status_t)0x0C1B) ///< An attempt was made to join a Secured Network, but the device did not receive a Network Key.
#define SL_STATUS_ZIGBEE_NO_LINK_KEY_RECEIVED ((sl_status_t)0x0C1C) ///< After a device joined a Secured Network, a Link Key was requested (::EMBER_GET_LINK_KEY_WHEN_JOINING) but no response was ever received.
#define SL_STATUS_ZIGBEE_PRECONFIGURED_KEY_REQUIRED ((sl_status_t)0x0C1D) ///< An attempt was made to join a Secured Network without a pre-configured key, but the Trust Center sent encrypted data using a pre-configured key.
#define SL_STATUS_ZIGBEE_EZSP_ERROR ((sl_status_t)0x0C1E) ///< A Zigbee EZSP error has occured. Track the origin and corresponding EzspStatus for more info.
// -----------------------------------------------------------------------------
// Data Types
/** @brief define global status variable. */
typedef uint32_t sl_status_t;
// -----------------------------------------------------------------------------
// Functions
#ifdef __cplusplus
extern "C" {
#endif
/********************************************************************************************************
* sl_status_get_string_n()
*
* @brief Get a copy of the status string associated to the status code passed, up to
* 'buffer_length' length, if the string associated to the status code is enabled. If not,
* the error code number, in hex, prefixed by "SL_STATUS_" will be copied in the buffer
* instead.
* For example, the buffer would either contain "SL_STATUS_FAIL" if that status string is
* enabled, or "SL_STATUS_0x0001" if the string is disabled, as SL_STATUS_FAIL's
* value is 0x0001.
*
* @param status The status code from which to obtain the status string.
*
* @param buffer Pointer to a buffer in which the status string will be copied. A terminating
* null-character will be appended after the copied status string.
*
* @param buffer_length Maximum number of characters that can be written in the buffer, including the
* terminating null-character. If the status string would be longer than the
* available length, it will be truncated and a null-terminating character will
* be the last character contained in the buffer.
*
* @return The number of characters that would have been written if the buffer_length had been
* sufficiently large, not counting the terminating null character.
* If the status code is invalid, 0 or a negative number is returned.
* Notice that only when this returned value is strictly positive and less than
* buffer_length, the status string has been completely written in the buffer.
*******************************************************************************************************/
int32_t sl_status_get_string_n(sl_status_t status, char *buffer, uint32_t buffer_length);
/********************************************************************************************************
* sl_status_print()
*
* @brief Print, through printf, the string associated to the passed status code. If the string
* associated to the status code is enabled, the status string will be printed, for example
* "SL_STATUS_OK". If the string associated to the status code is disabled, the status number,
* in hex, prefixed by "SL_STATUS_" will be printed instead, for example "SL_STATUS_0x0000",
* as SL_STATUS_OK's value is 0x0000.
*
* @param status The status code of which to print the status string.
*******************************************************************************************************/
void sl_status_print(sl_status_t status);
#ifdef __cplusplus
}
#endif
/** @} (end addtogroup status) */
#endif /* SL_STATUS_H */

View File

@@ -0,0 +1,108 @@
/***************************************************************************//**
* @file sli_cmsis_os2_ext_task_register.h
* @brief Abstraction for Task Registers (Thread Local Variables)
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SLI_CMSIS_OS2_EXT_TASK_REGISTER_H
#define SLI_CMSIS_OS2_EXT_TASK_REGISTER_H
#if defined(SL_COMPONENT_CATALOG_PRESENT)
#include "sl_component_catalog.h"
#endif
// Validate the chosen RTOS
#if !defined(SL_CATALOG_FREERTOS_KERNEL_PRESENT) && !defined(SL_CATALOG_MICRIUMOS_KERNEL_PRESENT)
#error "The task register API currently only supports FreeRTOS or MicriumOS"
#endif
#if defined(SL_CATALOG_FREERTOS_KERNEL_PRESENT)
#include "FreeRTOS.h"
#include "task.h"
// Validate maximum of task registers
#if configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS > 255
#error "The task register API currently only supports a maximum of 255 registers"
#endif
// Check if the user has overwritten the configNUM_THREAD_LOCAL_STORAGE_POINTERS config
#if configNUM_THREAD_LOCAL_STORAGE_POINTERS < (configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS \
+ configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS)
#error "Please use the configUSER_NUM_THREAD_LOCAL_STORAGE_POINTERS to configure the local storage pointers"
#endif
#elif defined(SL_CATALOG_MICRIUMOS_KERNEL_PRESENT)
#include "os.h"
#endif
#include "sl_status.h"
#include "cmsis_os2.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(SL_CATALOG_FREERTOS_KERNEL_PRESENT)
typedef uint8_t sli_task_register_id_t;
#elif defined(SL_CATALOG_MICRIUMOS_KERNEL_PRESENT)
typedef OS_REG_ID sli_task_register_id_t;
#endif
/***************************************************************************//**
* Get the task register ID.
*
* @param[out] reg_id The task register id
* @return sl_status_t The status result
******************************************************************************/
sl_status_t sli_osTaskRegisterNew(sli_task_register_id_t *reg_id);
/***************************************************************************//**
* Get the task register value.
*
* @param thread_id CMSIS-RTOS2 thread identification
* @param reg_id Task register ID
* @param[out] value Value of the task register requested
* @return sl_status_t The status result
******************************************************************************/
sl_status_t sli_osTaskRegisterGetValue(const osThreadId_t thread_id,
const sli_task_register_id_t reg_id,
uint32_t *value);
/***************************************************************************//**
* Set the task register to the provided value.
*
* @param thread_id CMSIS-RTOS2 thread identification
* @param reg_id Task register ID
* @param[out] value Value of the task register to set
* @return sl_status_t The status result
******************************************************************************/
sl_status_t sli_osTaskRegisterSetValue(const osThreadId_t thread_id,
const sli_task_register_id_t reg_id,
const uint32_t value);
#ifdef __cplusplus
}
#endif
#endif // SLI_CMSIS_OS2_EXT_TASK_REGISTER_H

View File

@@ -0,0 +1,131 @@
/***************************************************************************//**
* @file
* @brief Code Classification API (Internal)
*******************************************************************************
* # License
* <b>Copyright 2023 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef _SLI_CODE_CLASSIFICATION_H_
#define _SLI_CODE_CLASSIFICATION_H_
// Standard Code Classes
#define SL_CODE_CLASS_TIME_CRITICAL timecritical
/******************************************************************************/
/* Helper Macros */
/******************************************************************************/
// Stringize tokens
#define _SL_CC_STRINGIZE(X) #X
#define _SL_CC_XSTRINGIZE(X) _SL_CC_STRINGIZE(X)
#define _SL_CC_CONCAT3(A, B, C) A B C
#define _SL_CC_CONCAT4(A, B, C, D) A B C D
/******************************************************************************/
/* Compiler Specific Macros */
/******************************************************************************/
// The directive that is built is dependent on the compiler. Section names are
// appended with an identifier generated from __COUNTER__ and __LINE__ so that
// functions are more likely to be separated into unique sections. Doing this
// allows the linker to discard unused functions with more granularity.
#if defined(__GNUC__) && !(defined(__llvm__) || defined(SLI_CODE_CLASSIFICATION_DISABLE))
// With GCC, __attribute__ can be used to specify the input section of
// functions.
#define _SL_CC_SECTION(section_name, count, line) \
__attribute__((section(_SL_CC_CONCAT3(_SL_CC_XSTRINGIZE(section_name), _SL_CC_XSTRINGIZE(count), _SL_CC_XSTRINGIZE(line)))))
#elif defined(__ICCARM__) && !defined(SLI_CODE_CLASSIFICATION_DISABLE)
// With IAR, _Pragma can be used to specify the input section of
// functions.
#define _SL_CC_SECTION(section_name, count, line) \
_Pragma(_SL_CC_XSTRINGIZE(_SL_CC_CONCAT4(location =, _SL_CC_XSTRINGIZE(section_name), _SL_CC_XSTRINGIZE(count), _SL_CC_XSTRINGIZE(line))))
#elif defined(__llvm__) && !defined(SLI_CODE_CLASSIFICATION_DISABLE)
// With llvm, __attribute__ can be used to specify the input section of
// functions.
// However the syntax of the string within the section directive is
// dependent on the specifics of the target backend (e.g. osx)
#if defined(__MACH__) && defined(SLI_CODE_CLASSIFICATION_OSX_ENABLE)
// code classifcation is not supported on OSX and can have weird
// interactions for executable code so it is disabled by default
// since it can be useful for code analysis allow it as an opt-in feature
#define _SL_CC_SECTION(section_name, count, line) \
__attribute__((section("sl_cc,code_class" _SL_CC_XSTRINGIZE(count) _SL_CC_XSTRINGIZE(line))))
#else
#define _SL_CC_SECTION(section_name, count, line)
#endif // defined(__MACH__)
#elif defined(SLI_CODE_CLASSIFICATION_DISABLE)
#define _SL_CC_SECTION(section_name, count, line)
#else
#error "(sli_code_classification.h): Code classification does not support \
the chosen compiler."
#endif // __GNUC__
/******************************************************************************/
/* Compiler Generic Macros */
/******************************************************************************/
// Build the linker section name based on the name of the component and the
// code classes.
#define _SL_CODE_CLASS_SECTION_CONCAT1(component, p1) \
text_ ## component ## _ ## p1
#define _SL_CODE_CLASS_SECTION_CONCAT2(component, p1, p2) \
text_ ## component ## _ ## p1 ## _ ## p2
// Build the compiler specific directives
#define _SL_CODE_CLASS1(component, c1) \
_SL_CC_SECTION(_SL_CODE_CLASS_SECTION_CONCAT1(component, c1), __COUNTER__, __LINE__)
#define _SL_CODE_CLASS2(component, c1, c2) \
_SL_CC_SECTION(_SL_CODE_CLASS_SECTION_CONCAT2(component, c1, c2), __COUNTER__, __LINE__)
// Utilities to dispatch a macro with the correct number of parameters.
// Update COUNT_N and COUNT macros if the upper limit of code class
// combinations increases.
#define _SL_CC_COUNT_N(_1, _2, N, ...) N
#define _SL_CC_COUNT(...) _SL_CC_COUNT_N(__VA_ARGS__, 2, 1)
#define _SL_CC_IDENTITY(N) N
#define _SL_CC_APPLY(macro, ...) _SL_CC_IDENTITY(macro(__VA_ARGS__))
// Dispatch _SL_CODE_CLASSX with the correct number of parameters.
#define _SL_CC_DISPATCH(N) _SL_CODE_CLASS ## N
/******************************************************************************/
/* Macro API (Internal) */
/******************************************************************************/
// Variadic macro to specify the code class membership of a function.
#define SL_CODE_CLASSIFY(component, ...) \
_SL_CC_IDENTITY(_SL_CC_APPLY(_SL_CC_DISPATCH, _SL_CC_COUNT(__VA_ARGS__)))(component, __VA_ARGS__)
#endif // _SLI_CODE_CLASSIFICATION_H_

View File

@@ -0,0 +1,76 @@
/***************************************************************************//**
* @file
* @brief Assert API
*******************************************************************************
* # License
* <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_assert.h"
#include <stdbool.h>
/***************************************************************************//**
* @addtogroup assert
* @details
* This module contains functions to control the ASSERT peripheral of Silicon
* Labs 32-bit MCUs and SoCs.
* @{
******************************************************************************/
#if defined(DEBUG_EFM) && !defined(DEBUG_EFM_USER)
/***************************************************************************//**
* @brief
* EFM internal assert handling.
*
* This function is invoked through EFM_ASSERT() macro usage only and should
* not be used explicitly.
*
* This implementation enters an indefinite loop, allowing
* the use of a debugger to determine a cause of failure. By defining
* DEBUG_EFM_USER to the preprocessor for all files, a user-defined version
* of this function must be defined and will be invoked instead, possibly
* providing output of assertion location.
*
* @note
* This function is not used unless DEBUG_EFM is defined
* during preprocessing of EFM_ASSERT() usage.
*
* @param[in] file
* Name of the source file where assertion failed.
*
* @param[in] line
* A line number in the source file where assertion failed.
******************************************************************************/
void assertEFM(const char *file, int line)
{
(void)file; /* Unused parameter */
(void)line; /* Unused parameter */
while (true) {
}
}
#endif /* DEBUG_EFM && !DEBUG_EFM_USER */
/** @} (end addtogroup assert) */

View File

@@ -0,0 +1,61 @@
/***************************************************************************//**
* @file
* @brief CMSIS OS2 Common
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include <stddef.h>
#include "sl_assert.h"
#include "sl_status.h"
#include "cmsis_os2.h"
/***************************************************************************//**
* Convert OsStatus from CMSIS-RTOS2 to sl_status type.
******************************************************************************/
sl_status_t sl_cmsis_os_convert_status(osStatus_t os_status)
{
switch (os_status) {
case osOK:
return SL_STATUS_OK;
case osError:
return SL_STATUS_FAIL;
case osErrorTimeout:
return SL_STATUS_TIMEOUT;
case osErrorResource:
return SL_STATUS_NOT_AVAILABLE;
case osErrorParameter:
return SL_STATUS_INVALID_PARAMETER;
case osErrorNoMemory:
return SL_STATUS_NO_MORE_RESOURCE;
case osErrorISR:
return SL_STATUS_ISR;
case osStatusReserved:
default:
EFM_ASSERT(0);
return SL_STATUS_FAIL;
}
}

View File

@@ -0,0 +1,395 @@
/***************************************************************************//**
* @file
* @brief Core API implemented for CortexM
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_core.h"
#include "sl_core_config.h"
#include "sl_common.h"
#include "em_device.h"
/**************************************************************************//**
* @addtogroup sl_core
* @{
*****************************************************************************/
/*******************************************************************************
************************** STRUCTS ****************************************
******************************************************************************/
/// A Cycle Counter Instance.
typedef struct {
uint32_t start; /*!< Cycle counter at start of recording. */
uint32_t cycles; /*!< Cycles elapsed in last recording. */
uint32_t max; /*!< Max recorded cycles since last reset or init. */
} dwt_cycle_counter_handle_t;
/*******************************************************************************
*************************** LOCAL VARIABLES *******************************
******************************************************************************/
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
// cycle counter to record atomic sections
dwt_cycle_counter_handle_t atomic_cycle_counter = { 0 };
// cycle counter to record critical sections
dwt_cycle_counter_handle_t critical_cycle_counter = { 0 };
#endif
/** @endcond */
/*******************************************************************************
*************************** LOCAL FUNCTIONS *******************************
******************************************************************************/
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
static void cycle_counter_start(dwt_cycle_counter_handle_t *handle);
static void cycle_counter_stop(dwt_cycle_counter_handle_t *handle);
#endif
/*******************************************************************************
************************** GLOBAL FUNCTIONS *******************************
******************************************************************************/
/***************************************************************************//**
* @brief
* Disable interrupts.
******************************************************************************/
SL_WEAK void CORE_CriticalDisableIrq(void)
{
__disable_irq();
}
/***************************************************************************//**
* @brief
* Enable interrupts.
* @note
* __ISB() makes sure pending interrupts are executed before returning.
* This can be a problem if the first instruction after changing the BASEPRI
* or PRIMASK assumes that the pending interrupts have already been processed.
******************************************************************************/
SL_WEAK void CORE_CriticalEnableIrq(void)
{
__enable_irq();
__ISB();
}
/***************************************************************************//**
* @brief
* Enter a CRITICAL section.
******************************************************************************/
SL_WEAK CORE_irqState_t CORE_EnterCritical(void)
{
CORE_irqState_t irqState = __get_PRIMASK();
__disable_irq();
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
if (irqState == 0U) {
cycle_counter_start(&critical_cycle_counter);
}
#endif
return irqState;
}
/***************************************************************************//**
* @brief
* Exit a CRITICAL section.
* @note
* __ISB() makes sure pending interrupts are executed before returning.
* This can be a problem if the first instruction after changing the BASEPRI
* or PRIMASK assumes that the pending interrupts have already been processed.
******************************************************************************/
SL_WEAK void CORE_ExitCritical(CORE_irqState_t irqState)
{
if (irqState == 0U) {
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
cycle_counter_stop(&critical_cycle_counter);
#endif
__enable_irq();
__ISB();
}
}
/***************************************************************************//**
* @brief
* Brief interrupt enable/disable sequence to allow handling of
* pending interrupts.
******************************************************************************/
SL_WEAK void CORE_YieldCritical(void)
{
if ((__get_PRIMASK() & 1U) != 0U) {
__enable_irq();
__ISB();
__disable_irq();
}
}
/***************************************************************************//**
* @brief
* Disable interrupts.
******************************************************************************/
SL_WEAK void CORE_AtomicDisableIrq(void)
{
#ifndef __CM0PLUS_REV
__set_BASEPRI(CORE_ATOMIC_BASE_PRIORITY_LEVEL << (8UL - __NVIC_PRIO_BITS));
#else
__disable_irq();
#endif
}
/***************************************************************************//**
* @brief
* Enable interrupts.
* @note
* __ISB() makes sure pending interrupts are executed before returning.
* This can be a problem if the first instruction after changing the BASEPRI
* or PRIMASK assumes that the pending interrupts have already been processed.
******************************************************************************/
SL_WEAK void CORE_AtomicEnableIrq(void)
{
#ifndef __CM0PLUS_REV
__set_BASEPRI(0);
#else
__enable_irq();
#endif
__ISB();
}
/***************************************************************************//**
* @brief
* Enter an ATOMIC section.
******************************************************************************/
SL_WEAK CORE_irqState_t CORE_EnterAtomic(void)
{
#ifndef __CM0PLUS_REV
CORE_irqState_t irqState = __get_BASEPRI();
__set_BASEPRI(CORE_ATOMIC_BASE_PRIORITY_LEVEL << (8U - __NVIC_PRIO_BITS));
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
if ((irqState & (CORE_ATOMIC_BASE_PRIORITY_LEVEL << (8U - __NVIC_PRIO_BITS)))
!= (CORE_ATOMIC_BASE_PRIORITY_LEVEL << (8U - __NVIC_PRIO_BITS))) {
cycle_counter_start(&atomic_cycle_counter);
}
#endif
return irqState;
#else
CORE_irqState_t irqState = __get_PRIMASK();
__disable_irq();
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
if (irqState == 0U) {
cycle_counter_start(&critical_cycle_counter);
}
#endif
return irqState;
#endif
}
/***************************************************************************//**
* @brief
* Exit an ATOMIC section.
* @note
* __ISB() makes sure pending interrupts are executed before returning.
* This can be a problem if the first instruction after changing the BASEPRI
* or PRIMASK assumes that the pending interrupts have already been processed.
******************************************************************************/
SL_WEAK void CORE_ExitAtomic(CORE_irqState_t irqState)
{
#ifndef __CM0PLUS_REV
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
if ((irqState & (CORE_ATOMIC_BASE_PRIORITY_LEVEL << (8U - __NVIC_PRIO_BITS)))
!= (CORE_ATOMIC_BASE_PRIORITY_LEVEL << (8U - __NVIC_PRIO_BITS))) {
cycle_counter_stop(&atomic_cycle_counter);
}
#endif
__set_BASEPRI(irqState);
__ISB();
#else
if (irqState == 0U) {
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
cycle_counter_stop(&critical_cycle_counter);
#endif
__enable_irq();
__ISB();
}
#endif
}
/***************************************************************************//**
* @brief
* Brief interrupt enable/disable sequence to allow handling of
* pending interrupts.
******************************************************************************/
SL_WEAK void CORE_YieldAtomic(void)
{
#ifndef __CM0PLUS_REV
CORE_irqState_t basepri = __get_BASEPRI();
if (basepri >= (CORE_ATOMIC_BASE_PRIORITY_LEVEL << (8U - __NVIC_PRIO_BITS))) {
__set_BASEPRI(0);
__ISB();
__set_BASEPRI(basepri);
}
#else
if ((__get_PRIMASK() & 1U) != 0U) {
__enable_irq();
__ISB();
__disable_irq();
}
#endif
}
/***************************************************************************//**
* @brief
* Check whether the current CPU operation mode is handler mode.
******************************************************************************/
SL_WEAK bool CORE_InIrqContext(void)
{
return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0U;
}
/***************************************************************************//**
* @brief
* Check if interrupts are disabled.
******************************************************************************/
SL_WEAK bool CORE_IrqIsDisabled(void)
{
#ifndef __CM0PLUS_REV
return ((__get_PRIMASK() & 1U) == 1U)
|| (__get_BASEPRI() >= (CORE_ATOMIC_BASE_PRIORITY_LEVEL
<< (8U - __NVIC_PRIO_BITS)));
#else
return (__get_PRIMASK() & 1U == 1U);
#endif
}
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
/***************************************************************************//**
* @brief
* Start a recording.
*
* @param[in] handle
* Pointer to initialized counter handle.
*
* @note SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING must be enabled.
******************************************************************************/
static void cycle_counter_start(dwt_cycle_counter_handle_t *handle)
{
handle->start = DWT->CYCCNT;
}
#endif //(SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
/***************************************************************************//**
* @brief
* Stop a recording.
*
* @param[in] handle
* Pointer to initialized counter handle.
*
* @note SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING must be enabled.
******************************************************************************/
static void cycle_counter_stop(dwt_cycle_counter_handle_t *handle)
{
handle->cycles = DWT->CYCCNT - handle->start;
if (handle->cycles > handle->max) {
handle->max = handle->cycles;
}
}
#endif //(SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
/***************************************************************************//**
* @brief
* Returns the max time spent in critical section.
******************************************************************************/
uint32_t CORE_get_max_time_critical_section(void)
{
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
return critical_cycle_counter.max;
#else
return 0U;
#endif //(SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
}
/***************************************************************************//**
* @brief
* Returns the max time spent in atomic section.
******************************************************************************/
uint32_t CORE_get_max_time_atomic_section(void)
{
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
return atomic_cycle_counter.max;
#else
return 0U;
#endif //(SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
}
/***************************************************************************//**
* @brief
* Clears the max time spent in atomic section.
******************************************************************************/
void CORE_clear_max_time_critical_section(void)
{
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
critical_cycle_counter.max = 0;
#endif //(SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
}
/***************************************************************************//**
* @brief
* Clears the max time spent in atomic section.
******************************************************************************/
void CORE_clear_max_time_atomic_section(void)
{
#if (SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
atomic_cycle_counter.max = 0;
#endif //(SL_CORE_DEBUG_INTERRUPTS_MASKED_TIMING == 1)
}
/***************************************************************************//**
* @brief
* Reset chip routine.
******************************************************************************/
void CORE_ResetSystem(void)
{
// Ensure all outstanding memory accesses including buffered writes are
// completed before reset
__DSB();
// Keep priority group unchanged
SCB->AIRCR = (0x5FAUL << SCB_AIRCR_VECTKEY_Pos)
| (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk)
| SCB_AIRCR_SYSRESETREQ_Msk;
// Ensure completion of memory access
__DSB();
// Wait until reset
for (;; ) {
__NOP();
}
}
/** @} (end addtogroup sl_core) */

View File

@@ -0,0 +1,190 @@
/***************************************************************************//**
* @file
* @brief Single Link List
*******************************************************************************
* # License
* <b>Copyright 2019 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_assert.h"
#include "sl_slist.h"
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
/*******************************************************************************
************************** GLOBAL FUNCTIONS *******************************
******************************************************************************/
/***************************************************************************//**
* Initializes a singly-linked list.
******************************************************************************/
void sl_slist_init(sl_slist_node_t **head)
{
*head = 0;
}
/***************************************************************************//**
* Add given item at beginning of list.
******************************************************************************/
void sl_slist_push(sl_slist_node_t **head,
sl_slist_node_t *item)
{
EFM_ASSERT((item != NULL) && (head != NULL));
item->node = *head;
*head = item;
}
/***************************************************************************//**
* Add item at end of list.
******************************************************************************/
void sl_slist_push_back(sl_slist_node_t **head,
sl_slist_node_t *item)
{
sl_slist_node_t **node_ptr = head;
EFM_ASSERT((item != NULL) && (head != NULL));
while (*node_ptr != NULL) {
node_ptr = &((*node_ptr)->node);
}
item->node = NULL;
*node_ptr = item;
}
/***************************************************************************//**
* Removes and returns first element of list.
******************************************************************************/
sl_slist_node_t *sl_slist_pop(sl_slist_node_t **head)
{
sl_slist_node_t *item;
EFM_ASSERT(head != NULL);
item = *head;
if (item == NULL) {
return (NULL);
}
*head = item->node;
item->node = NULL;
return (item);
}
/***************************************************************************//**
* Insert item after given item.
******************************************************************************/
void sl_slist_insert(sl_slist_node_t *item,
sl_slist_node_t *pos)
{
EFM_ASSERT((item != NULL) && (pos != NULL));
item->node = pos->node;
pos->node = item;
}
/***************************************************************************//**
* Add item at end of list.
******************************************************************************/
void sl_slist_join(sl_slist_node_t **head_list_1,
sl_slist_node_t **head_list_2)
{
sl_slist_node_t **node_ptr = head_list_1;
EFM_ASSERT((head_list_2 != NULL)
&& (head_list_1 != NULL));
while (*node_ptr != NULL) {
node_ptr = &((*node_ptr)->node);
}
*node_ptr = *head_list_2;
*head_list_2 = NULL;
}
/***************************************************************************//**
* Remove item from list.
******************************************************************************/
void sl_slist_remove(sl_slist_node_t **head,
sl_slist_node_t *item)
{
sl_slist_node_t **node_ptr;
EFM_ASSERT((item != NULL) && (head != NULL));
for (node_ptr = head; *node_ptr != NULL; node_ptr = &((*node_ptr)->node)) {
if (*node_ptr == item) {
*node_ptr = item->node;
item->node = NULL;
return;
}
}
}
/***************************************************************************//**
* Sorts list items.
******************************************************************************/
void sl_slist_sort(sl_slist_node_t **head,
bool (*cmp_fnct)(sl_slist_node_t *item_l,
sl_slist_node_t *item_r))
{
bool swapped;
sl_slist_node_t **pp_item_l;
EFM_ASSERT((head != NULL) && (cmp_fnct != NULL));
do {
swapped = false;
pp_item_l = head;
// Loop until end of list is found.
while ((*pp_item_l != NULL) && ((*pp_item_l)->node != NULL)) {
sl_slist_node_t *p_item_r = (*pp_item_l)->node;
bool ordered;
// Call provided compare fnct.
ordered = cmp_fnct(*pp_item_l, p_item_r);
if (ordered == false) {
// If order is not correct, swap items.
sl_slist_node_t *p_tmp = p_item_r->node;
// Swap the two items.
p_item_r->node = *pp_item_l;
(*pp_item_l)->node = p_tmp;
*pp_item_l = p_item_r;
pp_item_l = &(p_item_r->node);
// Indicate a swap has been done.
swapped = true;
} else {
pp_item_l = &((*pp_item_l)->node);
}
}
// Re-loop until no items have been swapped.
} while (swapped == true);
}

View File

@@ -0,0 +1,115 @@
/***************************************************************************//**
* @file
* @brief SystemCall API
*******************************************************************************
* # License
* <b>Copyright 2023 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
/***************************************************************************//**
* @addtogroup systemcalls
* @details
* This module reimplements the syscalls that don't have the definition in the
* bare metal project.
* This prevents linker warnings.
* @{
******************************************************************************/
#include "sl_compiler.h"
struct stat;
struct timeval;
struct timezone;
__WEAK int _close(int file)
{
(void)file;
return -1;
}
__WEAK void _exit(int status)
{
(void)status;
/* Convince GCC that this function never returns. */
for (;; ) {
;
}
}
__WEAK int _fstat(int file, struct stat *st)
{
(void)file;
(void)(void *)st;
return 0;
}
__WEAK int _getpid(void)
{
return 1;
}
__WEAK int _isatty(int file)
{
(void)file;
return 1;
}
__WEAK int _kill(int pid, int sig)
{
(void)pid;
(void)sig;
return -1;
}
__WEAK int _lseek(int file, int ptr, int dir)
{
(void)file;
(void)ptr;
(void)dir;
return 0;
}
__WEAK int _read(int file, char *ptr, int len)
{
(void)file;
(void)(void *)ptr;
(void)len;
return 0;
}
__WEAK int _write(int file, const char *ptr, int len)
{
(void)file;
(void)(const void *)ptr;
(void)len;
return 0;
}
__WEAK int _gettimeofday(struct timeval *tv, struct timezone *tz)
{
(void)(void *)tv;
(void)(void *)tz;
return 0;
}

View File

@@ -0,0 +1,143 @@
/***************************************************************************//**
* @file sli_cmsis_os2_ext_task_register.c
* @brief Abstraction for Task Registers (Thread Local Variables)
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#include "sl_assert.h"
#include "sli_cmsis_os2_ext_task_register.h"
#include "sl_cmsis_os2_common.h"
/*******************************************************************************
*************************** LOCAL VARIABLES ********************************
******************************************************************************/
/*******************************************************************************
************************** GLOBAL FUNCTIONS *******************************
******************************************************************************/
/***************************************************************************//**
* Get a task register ID
******************************************************************************/
sl_status_t sli_osTaskRegisterNew(sli_task_register_id_t *reg_id)
{
sl_status_t status = SL_STATUS_FAIL;
if (reg_id == NULL) {
return SL_STATUS_FAIL;
}
#if defined(SL_CATALOG_MICRIUMOS_KERNEL_PRESENT)
RTOS_ERR err;
*reg_id = OSTaskRegGetID(&err);
if (RTOS_ERR_CODE_GET(err) == RTOS_ERR_NONE) {
status = SL_STATUS_OK;
}
#elif defined(SL_CATALOG_FREERTOS_KERNEL_PRESENT)
static uint8_t register_count = 0;
if (register_count > (configNUM_SDK_THREAD_LOCAL_STORAGE_POINTERS - 1)) {
return SL_STATUS_FAIL;
}
*reg_id = register_count + configNUM_USER_THREAD_LOCAL_STORAGE_POINTERS;
++register_count;
status = SL_STATUS_OK;
#else
#error "Task registers abstraction only supports MicriumOS or FreeRTOS"
#endif
return status;
}
/***************************************************************************//**
* Get the task register
******************************************************************************/
sl_status_t sli_osTaskRegisterGetValue(const osThreadId_t thread_id,
const sli_task_register_id_t reg_id,
uint32_t *value)
{
sl_status_t status = SL_STATUS_FAIL;
#if defined(SL_CATALOG_MICRIUMOS_KERNEL_PRESENT)
RTOS_ERR err;
osThread_t *thread;
if (value == NULL) {
return SL_STATUS_FAIL;
}
if (thread_id != NULL) {
thread = (osThread_t *)thread_id;
*value = OSTaskRegGet(&thread->tcb, reg_id, &err);
} else {
*value = OSTaskRegGet(NULL, reg_id, &err);
}
if (RTOS_ERR_CODE_GET(err) == RTOS_ERR_NONE) {
status = SL_STATUS_OK;
}
#elif defined(SL_CATALOG_FREERTOS_KERNEL_PRESENT)
*value = (uint32_t)pvTaskGetThreadLocalStoragePointer(thread_id, reg_id);
status = SL_STATUS_OK;
#else
#error "Task registers abstraction only supports MicriumOS or FreeRTOS"
#endif
return status;
}
/***************************************************************************//**
* Set the task register
******************************************************************************/
sl_status_t sli_osTaskRegisterSetValue(const osThreadId_t thread_id,
const sli_task_register_id_t reg_id,
const uint32_t value)
{
sl_status_t status = SL_STATUS_FAIL;
#if defined(SL_CATALOG_MICRIUMOS_KERNEL_PRESENT)
RTOS_ERR err;
osThread_t *thread;
if (thread_id != NULL) {
thread = (osThread_t *)thread_id;
OSTaskRegSet(&thread->tcb, reg_id, (OS_REG)value, &err);
} else {
OSTaskRegSet(NULL, reg_id, (OS_REG)value, &err);
}
if (RTOS_ERR_CODE_GET(err) == RTOS_ERR_NONE) {
status = SL_STATUS_OK;
}
#elif defined(SL_CATALOG_FREERTOS_KERNEL_PRESENT)
vTaskSetThreadLocalStoragePointer(thread_id, reg_id, (void *)value);
status = SL_STATUS_OK;
#else
#error "Task registers abstraction only supports MicriumOS or FreeRTOS"
#endif
return status;
}

View File

@@ -0,0 +1,40 @@
/***************************************************************************//**
* @file
* @brief GCC startup file
*******************************************************************************
* # License
* <b>Copyright 2023 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
/* The startup files contain a stack and heap symbol in addition
* to the vector table. The size of these internal stack and heap
* objects depend on the build system providing two macros on the
* commandline called __STACK_SIZE and __HEAP_SIZE.
*
* We provide alternative stack and heap symbols in the sl_memory_region.c
* file which can be configured in a separate config file. Go to
* sl_memory_manager_config.h to configure the stack and heap size. */
#define __STACK_SIZE 0x0
#define __HEAP_SIZE 0x0

View File

@@ -0,0 +1,39 @@
/***************************************************************************//**
* @file
* @brief Heap and stack memory
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_MEMORY_H
#define SL_MEMORY_H
#include "sl_memory_manager_region.h"
#ifndef SL_SUPPRESS_DEPRECATION_WARNINGS_SDK_2024_6
#warning "This file is deprecated as of Simplicity SDK 2024.6. Content was moved to sl_memory_manager.h."
#endif
#endif // SL_MEMORY_H

View File

@@ -0,0 +1,39 @@
/***************************************************************************//**
* @file
* @brief Memory region types
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef SL_REGION_H
#define SL_REGION_H
#include "sl_memory_manager_region.h"
#ifndef SL_SUPPRESS_DEPRECATION_WARNINGS_SDK_2024_6
#warning "This file is deprecated as of Simplicity SDK 2024.6. Content was moved to sl_memory_manager.h."
#endif
#endif