/**
|
* @file Ems_def.h
|
* @author your name (you@domain.com)
|
* @brief
|
* @version 0.1
|
* @date 2023-04-05
|
*
|
* @copyright Copyright (c) 2023
|
*
|
*/
|
|
#ifndef EMS_DEF_H
|
#define EMS_DEF_H
|
|
/* includes ----------------------------------------------------------------- */
|
#include <stdint.h>
|
#include "EMS_config.h"
|
|
#if (EMS_QPC_EN != 0)
|
#include "qpc.h"
|
#endif
|
|
#ifdef __cplusplus
|
extern "C" {
|
#endif
|
|
/* public typedef ----------------------------------------------------------- */
|
typedef enum EMS_err
|
{
|
EMS_OK = 0,
|
EMS_ERROR = -1,
|
EMS_ERR_EMPTY = -2,
|
EMS_ERR_FULL = -3,
|
EMS_ERR_TIMEOUT = -4,
|
EMS_ERR_BUSY = -5,
|
EMS_ERR_NO_MEMORY = -6,
|
EMS_ERR_IO = -7,
|
EMS_ERR_INVALID = -8,
|
EMS_ERR_MEM_OVERLAY = -9,
|
EMS_ERR_MALLOC = -10,
|
EMS_ERR_NOT_ENOUGH = -11,
|
} ems_err_t;
|
|
#if (EMS_QPC_EN != 0)
|
|
typedef struct EMS_event
|
{
|
QEvt super;
|
uint8_t data[EMS_EVENT_DATA_SIZE];
|
} EMS_event_t;
|
|
#endif
|
|
/**
|
* Cast a member of a structure out to the containing structure.
|
* @ptr: the pointer to the member.
|
* @type: the type of the container struct this is embedded in.
|
* @member: the name of the member within the struct.
|
*/
|
#ifndef container_of
|
#define container_of(pointer, type, member) \
|
({ \
|
void *__pointer = (void *)(pointer); \
|
((type *)(__pointer - offsetof(type, member))); \
|
})
|
#endif
|
|
#ifndef offsetof
|
#define offsetof(type, member) ((uint32_t)&((type *)0)->member)
|
#endif
|
|
/* Compiler Related Definitions */
|
#if defined(__CC_ARM) || defined(__CLANG_ARM) /* ARM Compiler */
|
#include <stdarg.h>
|
#define EMS_SECTION(x) __attribute__((section(x)))
|
#define EMS_USED __attribute__((used))
|
#define EMS_ALIGN(n) __attribute__((aligned(n)))
|
#define EMS_WEAK __attribute__((weak))
|
#define EMS_INLINE static __inline
|
|
#elif defined (__IAR_SYSTEMS_ICC__) /* for IAR Compiler */
|
#include <stdarg.h>
|
#define EMS_SECTION(x) @ x
|
#define EMS_USED __root
|
#define EMS_PRAGMA(x) _Pragma(#x)
|
#define EMS_ALIGN(n) EMS_PRAGMA(data_alignment=n)
|
#define EMS_WEAK __weak
|
#define EMS_INLINE static inline
|
|
#elif defined (__GNUC__) /* GNU GCC Compiler */
|
#include <stdarg.h>
|
#define EMS_SECTION(x) __attribute__((section(x)))
|
#define EMS_USED __attribute__((used))
|
#define EMS_ALIGN(n) __attribute__((aligned(n)))
|
#define EMS_WEAK __attribute__((weak))
|
#define EMS_INLINE static __inline
|
#else
|
#error The compiler is not supported!
|
#endif
|
|
#ifdef __cplusplus
|
}
|
#endif
|
|
#endif
|
|
/* ----------------------------- end of file -------------------------------- */
|