/*******************************************************************************
* Project:      Amped'RF Bluetooth
* File name:    SDK_it.h
* Description:
*
* Copyright (c) 2016 Amped'RF Technology Inc, All rights reserved.
*******************************************************************************/
#ifndef _SDK_IT_H_
#define _SDK_IT_H_

#define FM_APP_VECTORS          0x08002000                      // Starting address of application

#define eTM_USART1      0
#define eTM_USART2      1
#define eTM_UART_MAX    2

typedef u16 tTM_UartType;

//------------------------------------------------
//    Define UARTs
//------------------------------------------------
#define eTM_HciUart         eTM_USART2
#define eTM_MainUart	    eTM_USART1

typedef enum {
    TM_IntSrc_IDLE=0,
    TM_IntSrc_FULL,
    TM_IntSrc_HALF,
    TM_IntSrc_SWI,
    TM_IntSrc_RXNE,
    TM_IntSrc_ERR
} tTM_InterruptSource;

//------------------------------------------------------------------------------
// All Cortex priority settings go here from 1 (highest) to 15 (lowest)
//------------------------------------------------------------------------------
enum {
    TM_HighestPriority=2,
    TM_XtiPriority,
    TM_RtcPriority,
    TM_ExtPriority,
    TM_HciUartPriority,
    TM_MainUartPriority,
    TM_DebugUartPriority,
    TM_SpareUartPriority,
    TM_LowestPriority
};

#define AT_UART_DEFAULT_TIMEOUT         *(uint8 *)TM_GetFlashReadPtr(VAR_ID_UartTimeout)
#define AT_UART_DEFAULT_BAUDRATE        *(uint32 *)TM_GetFlashReadPtr(VAR_ID_UartBaudrate)


//------------------------------------------------------------------------------
// Prototypes
//------------------------------------------------------------------------------
void    TM_GPIO_ISR(uint32 ExtLineSource);
uint16  TM_DmaRxCount(tTM_UartType u);
void    TM_UartHciRxHandler(uint16 u, tTM_InterruptSource iSrc);
void    TM_UartMainRxHandler(uint16 u, tTM_InterruptSource iSrc);
void    TM_UartRxHandler(uint16 u, tTM_InterruptSource iSrc);
void    TM_UartHciRxHandler(uint16 u, tTM_InterruptSource iSrc);
void    TM_DmaSendComplete(uint16 u);
void    TM_UartTxHandler(uint16 u);
void    TM_TimeoutIsrRTS(void);
void    TM_SpiHandler(void);


#endif // _SDK_IT_H_
