/*********************************************************************************************************                                               
*                                     MCU ACH118X driver library
*                             COPYRIGHT(c) 2019 Amped RF Technology (ART)
*                                        All Rights Reserved
*
* File    : ach118x_type.h
* Version : V1.0.0
* Brief   : type definitions.
**********************************************************************************************************/

#ifndef __ACH118X_TYPE_H
#define __ACH118X_TYPE_H

#define OS_NO_C_LIB_DEFINES

#include <stdint.h>

typedef volatile uint64_t vu64;
typedef volatile uint32_t vu32;
typedef uint32_t u32;
typedef uint32_t uint32;
typedef uint16_t u16;
typedef uint8_t u8;
typedef uint8_t uint8;
typedef uint32_t bool;

typedef enum
{
  RESET = 0U,
  SET = !RESET
} FlagStatus, ITStatus;

typedef enum
{
  DISABLE = 0U,
  ENABLE = !DISABLE
} FunctionalState;
#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))

typedef enum
{
  ERROR = 0U,
  SUCCESS = !ERROR
} ErrorStatus;

typedef enum
{
    LOW = 0U,
    HIGH
} LevelState;

#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif

#define TRUE  1
#define true  1
#define FALSE 0
#define false 0

#define SET_BIT(REG, BIT)       ((REG) |= (BIT))
#define CLEAR_BIT(REG, BIT)     ((REG) &= ~(BIT))
#define READ_BIT(REG, BIT)      ((REG) & (BIT))
#define CLEAR_REG(REG)          ((REG) = (0x0))
#define WRITE_REG(REG, VAL)     ((REG) = (VAL))
#define READ_REG(REG)           ((REG))
#define MODIFY_REG(REG, CLEARMASK, SETMASK)  WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
#define POSITION_VAL(VAL)       (__CLZ(__RBIT(VAL)))
#define REG32(baseaddr, offset) *(volatile uint32_t *)((uint8_t *)baseaddr + offset)
#define REG8(baseaddr, offset)  *(volatile uint8_t *)((uint8_t *)baseaddr + offset)
#define VAL8(x)                 *(uint8_t *)&x
#define VAL16(x)                *(uint16_t *)&x

#endif // __ACH118X_TYPE_H
/************************ (C) COPYRIGHT ART *****END OF FILE****/
