// ************************************************
//
// XLINK configuration file for MSP430i2041
//
// Copyright 1996-2017 IAR Systems AB.
//
// See the file 430/doc/licenses/IARSourceLicense.txt for detailed
// license information.
//
// $Revision: 14570 $
//
// ************************************************

// ---------------------------------------------------------
// Description
//

//
// Usage:
//
//   xlink [file file ...] -f lnk430i2041.xcl
//
// -----------------------------------------------
// Device summary
//

//
// Core:                           MSP430
//
// Interrupt vectors:              16
//
// Signature memory:               4 Bytes
//
// Peripheral units:                  0-01FF
//
// Information memory (FLASH):     1000-13FF
//
// Read/write memory (RAM):        0200-09FF
//
// Read-only memory (FLASH):       8000-FFFF
//


// -----------------------------------------------
// Segments
//

// -------------------------------------
// Data read/write segments (RAM)
//

//
// segment         Usage
// -------         --------------------------
// DATA16_Z        Data initialized to zero
// DATA16_I        Data initialized by copying from DATA16_ID
// DATA16_N        Data defined using __no_init
// DATA16_HEAP     The heap used by 'malloc' and 'free'
// CSTACK          Runtime stack
// TLS16_I         Thread-local storage for main thread
//


// -------------------------------------
// Program and data read-only segments (FLASH)
//

//
// segment         Usage
// -------         --------------------------
// DATA16_C        Constant data, including string literals
// DATA16_ID       Initializers for DATA<nn>_I
// INFO            Information memory
// INFOA           Information memory, bank A
// CSTART          Program startup code
// CODE            Program code
// ISR_CODE        Program code for interrupt service routines
// DIFUNCT         Dynamic initialization vector used by C++
// CHECKSUM        Checksum byte(s) generated by the -J option
// SIGNATURE       Signature memory
// INTVEC          Interrupt vectors
// RESET           The reset vector
// TLS16_ID        Thread-local initializers for main thread
//
// Notes:
//
// * The INFOx and INFO segments overlap, this allows data either to be
//   placed in a specific bank or anywhere in the info memory.
//
// * The INTVEC and RESET segments overlap. This allows an application to
//   either use the reset vector provided by the runtime library, or
//   provide a reset function by defining an interrupt function associated
//   with the reset vector.
//


// ---------------------------------------------------------
// Configuation
//


/* RAM Memory Addresses */
-D_RAM_Start=200                 /* RAM Start */
-D_RAM_End=3FF                     /* RAM End */
    /* RAM shared between App and Bootloader, must be reserved */
    -D_PassWd=200                 /* Password sent by App to force boot  mode */
    -D_StatCtrl=202             /* Status and Control  byte used by Comm */
//    CI_State_Machine=203         /*  State machine variable used by Comm */
//    CI_Callback_ptr=204   /* Pointer to Comm callback structure */
    /* Unreserved RAM used for Bootloader or App purposes */
//    _NonReserved_RAM_Start=208 /* Non-reserved RAM */

/* Flash memory addresses */
-D_Appl_Start=8000                              //C000             /* Start of Application area */


    /* Reserved Flash locations for Bootloader Area */
    -D_Boot_Start=FC00         /* Boot flash */
    -D_Boot_Reset=FFFE                          /* Boot reset vector */
    -D_Boot_VectorTable=FFE0      /* Boot vector table */
    -D_Boot_SharedCallbacks_Len=6 /* Length of shared callbacks (2 calls =4B(msp430) or 8B(msp430x) */
    -D_Boot_SharedCallbacks=FFDA /* Start of Shared callbacks */
//    _BOOT_APPVECTOR=-D_Boot_SharedCallbacks;       /* Definition for application table             */
    -D_Appl_Proxy_Vector_Start=FBC2//FBE0 /* Proxy interrupt table */
/* Reserved Flash locations for Application Area */


/////////////////////////// MCU FLASH ADDRESSES ////////////////////////////////
//
// Flash Start Address:
    -D_FLASH_START=8000                 //C000
// Flash End Address: always 0xFFFF
    -D_FLASH_END=FFFF
// Flash vector start address:
    -D_FLASH_VECTORS_START=FFE0
// Flash Reset vector address: always FFFE
    -D_FLASH_RESET_VECTOR=FFFE


///////////////////////////// APP AREA FLASH ADDRESSES /////////////////////////
//
// Application Checksum address
    -D_AppChecksum=_FLASH_START
//    -D_AppChecksum_8=(_FLASH_START+2)
// Application Start address (after checksum)
    -D_App_Start=(_FLASH_START+2)
// Application End Address
    -D_App_End=(FC00-1)
// Application reset vector
    -D_App_Reset_Vector=(_App_End-1)
// Start address of Proxy vector table
    -D_App_Proxy_Vector_Start=(FBC2)
// End address of Proxy vector table
    -D_App_Proxy_Vector_End=(FBFD)
// Size of area calculated by CRC (App+ProxyTable)
    -D_CRC_Size=(_App_End-_App_Start+1)
////////////////////////////////////////////////////////////////////////////////



// -----------------------------------------------
// Stack and heap sizes
//

// Uncomment for command line use
-D_STACK_SIZE=80
-D_DATA16_HEAP_SIZE=0


// -----------------------------------------------
// Define cpu
//

-cmsp430


// -----------------------------------------------
// Support for placing functions in read/write memory
//

-QCODE_I=CODE_ID


// -----------------------------------------------
// Support for thread local storage
//

-QTLS16_I=TLS16_ID


// -----------------------------------------------
// Hardware multiplier location
//

-D__iar_HWMUL=130


// ---------------------------------------------------------
// Placement directives
//

// -----------------------------------------------
// Information memory
//

-Z(CONST)INFO=1000-13FF
-Z(CONST)INFOA=1000-13FF


// -----------------------------------------------
// RAM memory
//

-Z(DATA)DATA16_I,DATA16_Z,DATA16_N,TLS16_I=0200-09FF
-Z(DATA)DATA16_HEAP+_DATA16_HEAP_SIZE
-Z(DATA)CODE_I
-Z(DATA)CSTACK+_STACK_SIZE#


// -----------------------------------------------
// Read-only memory
//

// -------------------------------------
// Constant data
//

//-Z(CONST)DATA16_C,DATA16_ID,TLS16_ID,DIFUNCT,CHECKSUM=8000-FFDB

-Z(CONST)DATA16_C,DATA16_ID,TLS16_ID,DIFUNCT,CHECKSUM=_App_Start-FFDB
// -------------------------------------
// Code
//

//-Z(CODE)CSTART,ISR_CODE,CODE_ID=8000-FFDB
//-P(CODE)CODE=8000-FFDB

// -------------------------------------
// Signature memory and interrupt vectors
//

//-Z(CONST)SIGNATURE=FFDC-FFDF
//-Z(CODE)INTVEC=FFE0-FFFF
//-Z(CODE)RESET=FFFE-FFFF


// -------------------------------------
// Code
//


-Z(CODE)CSTART,ISR_CODE,CODE_ID=_App_Start-_App_End
-P(CODE)CODE=_App_Start-_App_End

// -------------------------------------
// Signature memory and interrupt vectors
//
-Z(CONST)APP_PROXY_VECTORS=_App_Proxy_Vector_Start-_App_Proxy_Vector_End
-Z(CODE)INTVEC=_App_Proxy_Vector_Start-_App_Proxy_Vector_End

-Z(CODE)RESET=FBFE-FBFF