/** 
 * @file 
 * @copyright  Nehemis SARL reserves all rights even in the event of industrial     
 *             property rights. We reserve all rights of disposal such as           
 *             copying and passing on to third parties.
 *
 * @brief      Defines helper typedef on the standard types, that are shorter 
 *             to write because programmers are lazy. This file should be always 
 *             included (don't include stdbool or stdint separately in other files,
 *             it would break the benefit for portability!)
 *
 */

#ifndef NMS_TYPES_H_INCLUDED
#define NMS_TYPES_H_INCLUDED

/******************************************************************************
 * Include-Files
 ******************************************************************************/
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

/******************************************************************************
 * Constants and Macros
 ******************************************************************************/
/* Maximum size of integer variables */
#define NMS_INT8_MAX        INT8_MAX
#define NMS_UINT8_MAX       UINT8_MAX
#define NMS_INT16_MAX       INT16_MAX
#define NMS_UINT16_MAX      UINT16_MAX
#define NMS_INT32_MAX       INT32_MAX
#define NMS_UINT32_MAX      UINT32_MAX
#define NMS_INT64_MAX       INT64_MAX
#define NMS_UINT64_MAX      UINT64_MAX

/******************************************************************************
 * Types definitions
 ******************************************************************************/
/* Standard types redefinition */
typedef int8_t   sint8;
typedef uint8_t  uint8;
typedef int16_t  sint16;
typedef uint16_t uint16;
typedef int32_t  sint32;
typedef uint32_t uint32;
typedef int64_t  sint64;
typedef uint64_t uint64;
typedef float    float32;   /* Check the doc of the compiler for size of floats, 32 bits on CubeIDE */
typedef double   float64;   /* Check the doc of the compiler for size of doubles, 64 bits on CubeIDE */

/* Typedef for the errors
*/
typedef enum
{
    NMS_ERR_NONE = 0u,
    NMS_ERR_DEFAULT,
    NMS_ERR_UNKNOWN,                /* Error detected but unknown source */
    NMS_ERR_UNEXPECTED,             /* Unexpected behaviour happened */
    NMS_ERR_INVALID_ARGUMENT,       /* Invalid argument transmitted to a function (e.g. try to configured a GPIO port not present on the target) */
    NMS_ERR_INVALID_ADDRESS,        /* Invalid address (e.g. address out of valid range) */
    NMS_ERR_INVALID_CONFIG,         /* Module is trying to set an invalid configuration. */
    NMS_ERR_INVALID_SIZE,           /* Invalid size */
    NMS_ERR_INVALID_INDEX,          /* Invalid index (e.g. module index out of range) */
    NMS_ERR_NULL_FUNCTION,          /* Invalid function pointer (NULL) */
    NMS_ERR_INVALID_CRC,            /* Invalid CRC has been detected (e.g. after a flash read operation) */
    NMS_ERR_TIMEOUT,                /* Timeout detected (e.g. waited too long for a response from a SPI device) */
    NMS_ERR_INTERNAL,               /* Internal error detected by a low level driver */
    NMS_ERR_OVERRUN,                /* Overrun error detected by a low level driver (e.g. UART overrun) */
    NMS_ERR_DMA,                    /* DMA error detected by a low level driver (e.g. issue with ADC) */
    NMS_ERR_BUSY,                   /* Module is already busy / configured (e.g. trying to configure something when the HAL is already running) */
    NMS_ERR_NOISE,                  /* Noise detected on a received frame */
    NMS_ERR_FRAME,                  /* De-synchronization detected on a received frame */
    NMS_ERR_PARITY,                 /* Parity error detected on a received frame */
    NMS_ERR_NOT_SUPPORTED,          /* Request not yet supported */
    NMS_ERR_NOT_INITIALIZED,        /* The initialization was unsuccessful */
    NMS_ERR_NOT_RUNNING,            /* Module has not been started */
    NMS_ERR_BUS_ERROR,              /* Memory cannot be physically addressed (e.g. invalid bus address) */
    NMS_ERR_NULL_POINTER,
	NMS_ERR_INVALID_MODULE,
	NMS_ERR_INVALID_POINTER,
	NMS_LSS_NODE_CONFIG_ERROR,
} NMSErrorEn;

#endif /* NMS_TYPES_H_INCLUDED */
