/*-----------------------------------------------------------------------------------
!
!                              COPYRIGHT 2015 BY
!                            MegaChips Corporation
!
!------------------------------------------------------------------------------------
! These coded instructions, statements, and computer programs include
! intellectual property and know-how belonging to MegaChips
! Corporaiton ("MCC") and its partner companies.
! Therefore, do not use these specifications for any purpose other than
! the purpose
! expressly agreed to by MCCs customer and MCC.  Also, do not duplicate,
! copy,
! or reproduce these specifications, nor reveal these specifications to
! any third party
! without MCCs prior written consent.
!
*/
/*-----------------------------------------------------------------------------------
  FILE        : lts3.h
  DESCRIPTION : Lotus3 header
  Revision    : $Rev: 4 $
  Author      : $Author: shirait $
  Date        : $Date: 2015-09-09 15:19:58 +0900 (水, 09 9 2015) $
-----------------------------------------------------------------------------------*/


#ifndef __LTS3_H__
#define __LTS3_H__

/*
 * ==========================================================================
 * ---------- Interrupt Number Definition -----------------------------------
 * ==========================================================================
 */

typedef enum IRQn
{
/******  Cortex-M3 Processor Exceptions Numbers ***************************************************/
  NonMaskableInt_IRQn           = -14,      /*!< 2 Non Maskable Interrupt                         */
  HardFault_IRQn                = -13,      /*!< 3 Cortex-M3 HardFault Interrupt                  */
  MemoryManagement_IRQn         = -12,      /*!< 4 Cortex-M3 Memory Management Interrupt          */
  BusFault_IRQn                 = -11,      /*!< 5 Cortex-M3 Bus Fault Interrupt                  */
  UsageFault_IRQn               = -10,      /*!< 6 Cortex-M3 Usage Fault Interrupt                */
  SVCall_IRQn                   = -5,       /*!< 11 Cortex-M3 SV Call Interrupt                   */
  DebugMonitor_IRQn             = -4,       /*!< 12 Cortex-M3 Debug Monitor Interrupt             */
  PendSV_IRQn                   = -2,       /*!< 14 Cortex-M3 Pend SV Interrupt                   */
  SysTick_IRQn                  = -1,       /*!< 15 Cortex-M3 System Tick Interrupt               */

/******  ARM MPS Specific Interrupt Numbers *******************************************************/
  CMD60_IRQn                    = 0,
  CMD63_IRQn                    = 1,
  Set_SecuritySet_IRQn          = 2,
  TransmissionFinish_IRQn       = 3,
  TimerStart_IRQn               = 4,
  TimerEnd_IRQn                 = 5,
  T1KeyUpdateFinish_IRQn        = 6,
} IRQn_Type;


/*
 * ==========================================================================
 * ----------- Processor and Core Peripheral Section ------------------------
 * ==========================================================================
 */

/* Configuration of the Cortex-M3 Processor and Core Peripherals */
#define __MPU_PRESENT             1         /*!< MPU present or not                               */
#define __NVIC_PRIO_BITS          3         /*!< Number of Bits used for Priority Levels          */
#define __Vendor_SysTickConfig    0         /*!< Set to 1 if different SysTick Config is used     */


#include <core_cm3.h>                       /* Cortex-M3 processor and core peripherals           */

/*---------------------------------------------------------------------------
  function  : Lotus3
  arguments : none
  return    : void
  detail    : NMI
--------------------------------------------------------------------------*/
#include "ctl.h"

#define LAZY_FLAG_ON            (0x00000001u)
#define LAZY_NMI_MODE           (0x04000000u | LAZY_FLAG_ON)
#define LAZY_HF_MODE            (0x02000000u | LAZY_FLAG_ON)
#define LAZY_BOOT_CMD63ERROR    (0x01000000u | LAZY_FLAG_ON)
#define LAZY_BOOT_CMD60ERROR    (0x01100000u | LAZY_FLAG_ON)
#define LAZY_BOOT_OPEERROR      (0x01200000u | LAZY_FLAG_ON)
#define LAZY_BOOT_CMD25ERROR    (0x01300000u | LAZY_FLAG_ON)
#define LAZY_BOOT_SIGNERROR     (0x01400000u | LAZY_FLAG_ON)
#define LAZY_BOOT_SIZEERROR     (0x01500000u | LAZY_FLAG_ON)
#define LAZY_BOOT_TYPEERROR     (0x01600000u | LAZY_FLAG_ON)
#define LAZY_BOOT_VERSIONERROR  (0x01700000u | LAZY_FLAG_ON)
#define LAZY_BOOT_IDERROR       (0x01800000u | LAZY_FLAG_ON)
#define BOOT_FINISH             (0x00000000u)

#define LTS3_Abort(tag) \
	CTL_SetLazyFlag((tag)); \
	SCB->ICSR = 0x80000000u



#endif  // __LTS3_H__
