/********************************************************************/
/* f2402A.gel                                                       */
/* Version 3.10                                                     */
/*                                                                  */
/* This GEL file is to be used with the TMS320LF2402A DSP.          */
/* Changes may be required to support specific hardware designs.    */
/*                                                                  */
/* Code Composer Studio supports six reserved GEL functions that    */
/* automatically get executed if they are defined. They are:        */
/*                                                                  */
/* StartUp()              - Executed whenever CCS is invoked        */
/* OnReset()              - Executed after Debug->Reset CPU         */
/* OnRestart()            - Executed after Debug->Restart           */
/* OnPreFileLoaded()      - Executed before File->Load Program      */
/* OnFileLoaded()         - Executed after File->Load Program       */
/* OnTargetConnect()      - Executed after Debug->Connect           */
/*                                                                  */
/********************************************************************/

StartUp()
{
}

OnReset(int nErrorCode)
{
}

OnRestart(int nErrorCode)
{
}

OnPreFileLoaded()
{
}

OnFileLoaded(int nErrorCode, int bSymbolsOnly)
{
}

OnTargetConnect()
{
    F2402A_Memory_Map();           /* Initialize the CCS memory map */
    GEL_Reset();                   /* Reset DSP */
    Unlock_CSM();                  /* Unlock the CSM */
}


/********************************************************************/
/* These functions are useful to engage/dis-enagage the realtime    */
/* monitor during debug.  They save the user from having to         */
/* manually perform these steps in CCS.                             */
/*                                                                  */
/* The user must have included the realtime monitor software in     */
/* their application code.                                          */
/********************************************************************/
menuitem "Realtime Monitor Control";

hotmenu Run_Monitor_with_Reset()
{
    GEL_Reset();                  /* Reset the DSP */
    GEL_Go(MON_GO);               /* Run the RTM init function */
    GEL_EnableRealtime();         /* Enable Realtime mode */
    GEL_Run();                    /* Run the DSP */
}
hotmenu Run_Monitor_with_Restart()
{
    GEL_Restart();                /* Reset the DSP */
    GEL_Go(MON_GO);               /* Run the RTM init function */
    GEL_EnableRealtime();         /* Enable Realtime mode */
    GEL_Run();                    /* Run the DSP */
}
hotmenu Full_Halt()
{
    GEL_Halt();                   /* Halt the DSP */
    GEL_DisableRealtime();        /* Disable Realtime mode */
}
hotmenu Full_Halt_with_Reset()
{
    GEL_Halt();                   /* Halt the DSP */
    GEL_DisableRealtime();        /* Disable Realtime mode */
    GEL_Reset();                  /* Reset the DSP */
}


/********************************************************************/
/*                        F2402A Memory Map                         */
/*                                                                  */
/* Map all available program, data, and I/O space memory into CCS.  */
/* Illegal and reserved addresses are NOT mapped.                   */
/*                                                                  */
/********************************************************************/
menuitem "Initialize Memory Map";
hotmenu F2402A_Memory_Map()
{
    GEL_MapReset();                    /* Reset the CCS memory map */
    GEL_MapOn();                       /* Turn on memory mapping */

/* Program Space Memory */
    GEL_MapAdd(0x0000,0,0x2000,1,0);   /* Flash */
    GEL_MapAdd(0x8000,0,0x0200,1,1);   /* SARAM */
    GEL_MapAdd(0xFF00,0,0x0100,1,1);   /* DARAM B0 */

/* Data Space Memory */
    GEL_MapAdd(0x0004,1,0x0001,1,1);   /* IMR Reg */
    GEL_MapAdd(0x0006,1,0x0001,1,1);   /* IFR Reg */
    GEL_MapAdd(0x0060,1,0x0020,1,1);   /* DARAM B2 */
    GEL_MapAdd(0x0200,1,0x0100,1,1);   /* DARAM B0 */
    GEL_MapAdd(0x0300,1,0x0100,1,1);   /* DARAM B1 */
    GEL_MapAdd(0x0800,1,0x0200,1,1);   /* SARAM */

    GEL_MapAdd(0x7010,1,0x0003,1,1);   /* Sys Config and Ctrl Regs */
    GEL_MapAdd(0x7014,1,0x0003,1,1);   /* Sys Config and Ctrl Regs */
    GEL_MapAdd(0x7018,1,0x0002,1,1);   /* Sys Config and Ctrl Regs */
    GEL_MapAdd(0x701C,1,0x0001,1,1);   /* Sys Config and Ctrl Regs */
    GEL_MapAdd(0x701E,1,0x0001,1,1);   /* Sys Config and Ctrl Regs */

    GEL_MapAdd(0x7023,1,0x0001,1,1);   /* WD Timer Regs */
    GEL_MapAdd(0x7025,1,0x0001,1,1);   /* WD Timer Regs */
    GEL_MapAdd(0x7029,1,0x0001,1,1);   /* WD Timer Regs */

    GEL_MapAdd(0x7050,1,0x0008,1,1);   /* SCI Regs */
    GEL_MapAdd(0x7059,1,0x0001,1,1);   /* SCI Regs */
    GEL_MapAdd(0x705F,1,0x0001,1,1);   /* SCI Regs */

    GEL_MapAdd(0x7070,1,0x0002,1,1);   /* External-Interrupt Regs */

    GEL_MapAdd(0x7090,1,0x0001,1,1);   /* GPIO Regs */
    GEL_MapAdd(0x7092,1,0x0001,1,1);   /* GPIO Regs */
    GEL_MapAdd(0x7094,1,0x0003,1,1);   /* GPIO Regs */
    GEL_MapAdd(0x7094,1,0x0003,1,1);   /* GPIO Regs */
    GEL_MapAdd(0x7098,1,0x0001,1,1);   /* GPIO Regs */
    GEL_MapAdd(0x709A,1,0x0001,1,1);   /* GPIO Regs */
    GEL_MapAdd(0x709C,1,0x0001,1,1);   /* GPIO Regs */
    GEL_MapAdd(0x709E,1,0x0001,1,1);   /* GPIO Regs */

    GEL_MapAdd(0x70A0,1,0x0018,1,1);   /* ADC Regs */

    GEL_MapAdd(0x7400,1,0x0009,1,1);   /* EVA Regs */
    GEL_MapAdd(0x7411,1,0x0001,1,1);   /* EVA Regs */
    GEL_MapAdd(0x7413,1,0x0001,1,1);   /* EVA Regs */
    GEL_MapAdd(0x7415,1,0x0001,1,1);   /* EVA Regs */
    GEL_MapAdd(0x7417,1,0x0003,1,1);   /* EVA Regs */
    GEL_MapAdd(0x7420,1,0x0001,1,1);   /* EVA Regs */
    GEL_MapAdd(0x7422,1,0x0004,1,1);   /* EVA Regs */
    GEL_MapAdd(0x7427,1,0x0003,1,1);   /* EVA Regs */
    GEL_MapAdd(0x742C,1,0x0006,1,1);   /* EVA Regs */

    GEL_MapAdd(0x77F0,1,0x0004,1,1);   /* Code Security Passwords */
}


/********************************************************************/
menuitem "Watchdog";
hotmenu Disable_WD()
{
    *0x7029 = *0x7029 | 0x0068;                /* Set the WDDIS bit */
    *0x7025 = 0x0055;                          /* Service the WD    */
    *0x7025 = 0x00AA;                          /*  once to be safe. */
    GEL_TextOut("\nWatchdog Timer Disabled");
}

/********************************************************************/
menuitem "Code Security Module"
hotmenu Unlock_CSM()
{
    /* Perform dummy reads of the password locations */
    AR0 = *0x0040@PROG;
    AR0 = *0x0041@PROG;
    AR0 = *0x0042@PROG;
    AR0 = *0x0043@PROG;

    /* Write passwords to the KEY registers.  0xFFFF's are dummy passwords.
       User should replace them with the correct password for their DSP */
    *0x77F0 = 0xFFFF;
    *0x77F1 = 0xFFFF;
    *0x77F2 = 0xFFFF;
    *0x77F3 = 0xFFFF;
}


/********************************************************************/
/* The below are used to display the symbolic names of the DSP      */
/* peripheral registers in the watch window. To view these          */
/* registers, click on the GEL menu button in Code Composer Studio, */
/* then select which registers or groups of registers you want to   */
/* view. They will appear in the watch window under the Watch1 tab. */
/********************************************************************/

/* Add a space line to the GEL menu */
menuitem "______________________________________";
hotmenu __() {}

/************************************************************/
/* A/D Converter Registers                                  */
/************************************************************/
menuitem "Watch ADC Control Registers";

hotmenu All_ADC_Regs()
{
    GEL_WatchAdd("*0x70A0,x","ADCTRL1");
    GEL_WatchAdd("*0x70A1,x","ADCTRL2");
    GEL_WatchAdd("*0x70A2,x","MAX_CONV");
    GEL_WatchAdd("*0x70A3,x","CHSELSEQ1");
    GEL_WatchAdd("*0x70A4,x","CHSELSEQ2");
    GEL_WatchAdd("*0x70A5,x","CHSELSEQ3");
    GEL_WatchAdd("*0x70A6,x","CHSELSEQ4");
    GEL_WatchAdd("*0x70A7,x","AUTO_SEQ_SR");
    GEL_WatchAdd("*0x70A8,x","RESULT0");
    GEL_WatchAdd("*0x70A9,x","RESULT1");
    GEL_WatchAdd("*0x70AA,x","RESULT2");
    GEL_WatchAdd("*0x70AB,x","RESULT3");
    GEL_WatchAdd("*0x70AC,x","RESULT4");
    GEL_WatchAdd("*0x70AD,x","RESULT5");
    GEL_WatchAdd("*0x70AE,x","RESULT6");
    GEL_WatchAdd("*0x70AF,x","RESULT7");
    GEL_WatchAdd("*0x70B0,x","RESULT8");
    GEL_WatchAdd("*0x70B1,x","RESULT9");
    GEL_WatchAdd("*0x70B2,x","RESULT10");
    GEL_WatchAdd("*0x70B3,x","RESULT11");
    GEL_WatchAdd("*0x70B4,x","RESULT12");
    GEL_WatchAdd("*0x70B5,x","RESULT13");
    GEL_WatchAdd("*0x70B6,x","RESULT14");
    GEL_WatchAdd("*0x70B7,x","RESULT15");
    GEL_WatchAdd("*0x70B8,x","CALIBRATION");
}
hotmenu ADCTRL1()
{
    GEL_WatchAdd("*0x70A0,x","ADCTRL1");
}
hotmenu ADCTRL2()
{
    GEL_WatchAdd("*0x70A1,x","ADCTRL2");
}
hotmenu MAX_CONV()
{
    GEL_WatchAdd("*0x70A2,x","MAX_CONV");
}
hotmenu All_CHSELSEQx_Regs()
{
    GEL_WatchAdd("*0x70A3,x","CHSELSEQ1");
    GEL_WatchAdd("*0x70A4,x","CHSELSEQ2");
    GEL_WatchAdd("*0x70A5,x","CHSELSEQ3");
    GEL_WatchAdd("*0x70A6,x","CHSELSEQ4");
}
hotmenu AUTO_SEQ_SR()
{
    GEL_WatchAdd("*0x70A7,x","AUTO_SEQ_SR");
}
hotmenu RESULT_0_to_3()
{
    GEL_WatchAdd("*0x70A8,x","RESULT0");
    GEL_WatchAdd("*0x70A9,x","RESULT1");
    GEL_WatchAdd("*0x70AA,x","RESULT2");
    GEL_WatchAdd("*0x70AB,x","RESULT3");
}
hotmenu RESULT_4_to_7()
{
    GEL_WatchAdd("*0x70AC,x","RESULT4");
    GEL_WatchAdd("*0x70AD,x","RESULT5");
    GEL_WatchAdd("*0x70AE,x","RESULT6");
    GEL_WatchAdd("*0x70AF,x","RESULT7");
}
hotmenu RESULT_8_to_11()
{
    GEL_WatchAdd("*0x70B0,x","RESULT8");
    GEL_WatchAdd("*0x70B1,x","RESULT9");
    GEL_WatchAdd("*0x70B2,x","RESULT10");
    GEL_WatchAdd("*0x70B3,x","RESULT11");
}
hotmenu RESULT_12_to_15()
{
    GEL_WatchAdd("*0x70B4,x","RESULT12");
    GEL_WatchAdd("*0x70B5,x","RESULT13");
    GEL_WatchAdd("*0x70B6,x","RESULT14");
    GEL_WatchAdd("*0x70B7,x","RESULT15");
}


/************************************************************/
/* Event Manager A (EV-A) Registers                         */
/************************************************************/
menuitem "Watch Event Manager A Registers";

hotmenu All_EVA_GPTIMER_Regs()
{
    GEL_WatchAdd("*0x7400,x","GPTCONA");
    GEL_WatchAdd("*0x7401,x","T1CNT");
    GEL_WatchAdd("*0x7402,x","T1CMPR");
    GEL_WatchAdd("*0x7403,x","T1PR");
    GEL_WatchAdd("*0x7404,x","T1CON");
    GEL_WatchAdd("*0x7405,x","T2CNT");
    GEL_WatchAdd("*0x7406,x","T2CMPR");
    GEL_WatchAdd("*0x7407,x","T2PR");
    GEL_WatchAdd("*0x7408,x","T2CON");
}
hotmenu GPTCONA()
{
    GEL_WatchAdd("*0x7400,x","GPTCONA");
}
hotmenu All_GPTIMER1_Regs()
{
    GEL_WatchAdd("*0x7401,x","T1CNT");
    GEL_WatchAdd("*0x7402,x","T1CMPR");
    GEL_WatchAdd("*0x7403,x","T1PR");
    GEL_WatchAdd("*0x7404,x","T1CON");
}
hotmenu All_GPTIMER2_Regs()
{
    GEL_WatchAdd("*0x7405,x","T2CNT");
    GEL_WatchAdd("*0x7406,x","T2CMPR");
    GEL_WatchAdd("*0x7407,x","T2PR");
    GEL_WatchAdd("*0x7408,x","T2CON");
}
hotmenu All_EVA_COMPARE_Regs()
{
    GEL_WatchAdd("*0x7411,x","COMCONA");
    GEL_WatchAdd("*0x7413,x","ACTRA");
    GEL_WatchAdd("*0x7415,x","DBTCONA");
    GEL_WatchAdd("*0x7417,x","CMPR1");
    GEL_WatchAdd("*0x7418,x","CMPR2");
    GEL_WatchAdd("*0x7419,x","CMPR3");
}
hotmenu COMCONA()
{
    GEL_WatchAdd("*0x7411,x","COMCONA");
}
hotmenu ACTRA()
{
    GEL_WatchAdd("*0x7413,x","ACTRA");
}
hotmenu DBTCONA()
{
    GEL_WatchAdd("*0x7415,x","DBTCONA");
}
hotmenu All_EVA_CMPRx_Regs()
{
    GEL_WatchAdd("*0x7417,x","CMPR1");
    GEL_WatchAdd("*0x7418,x","CMPR2");
    GEL_WatchAdd("*0x7419,x","CMPR3");
}
hotmenu All_EVA_CAPTURE_Regs()
{
    GEL_WatchAdd("*0x7420,x","CAPCONA");
    GEL_WatchAdd("*0x7422,x","CAPFIFOA");
    GEL_WatchAdd("*0x7423,x","CAP1FIFO");
    GEL_WatchAdd("*0x7424,x","CAP2FIFO");
    GEL_WatchAdd("*0x7425,x","CAP3FIFO");
}
hotmenu CAPCONA()
{
    GEL_WatchAdd("*0x7420,x","CAPCONA");
}
hotmenu CAPFIFOA()
{
    GEL_WatchAdd("*0x7422,x","CAPFIFOA");
}
hotmenu CAP1FIFO()
{
    GEL_WatchAdd("*0x7423,x","CAP1FIFO");
}
hotmenu CAP2FIFO()
{
    GEL_WatchAdd("*0x7424,x","CAP2FIFO");
}
hotmenu CAP3FIFO()
{
    GEL_WatchAdd("*0x7425,x","CAP3FIFO");
}
hotmenu All_EVAIMRx_Regs()
{
    GEL_WatchAdd("*0x742c,x","EVAIMRA");
    GEL_WatchAdd("*0x742d,x","EVAIMRB");
    GEL_WatchAdd("*0x742e,x","EVAIMRC");
}
hotmenu All_EVAIFRx_Regs()
{
    GEL_WatchAdd("*0x742f,x","EVAIFRA");
    GEL_WatchAdd("*0x7430,x","EVAIFRB");
    GEL_WatchAdd("*0x7431,x","EVAIFRC");
}


/************************************************************/
/* General Purpose I/O (GPIO) Registers                     */
/************************************************************/
menuitem "Watch GPIO Registers";                    

hotmenu All_GPIO_Regs()
{
    GEL_WatchAdd("*0x7090,x","MCRA");
    GEL_WatchAdd("*0x7092,x","MCRB");
    GEL_WatchAdd("*0x7094,x","MCRC");
    GEL_WatchAdd("*0x7098,x","PADATDIR");
    GEL_WatchAdd("*0x709A,x","PBDATDIR");
    GEL_WatchAdd("*0x709C,x","PCDATDIR");
    GEL_WatchAdd("*0x709E,x","PDDATDIR");
    GEL_WatchAdd("*0x7095,x","PEDATDIR");
    GEL_WatchAdd("*0x7096,x","PFDATDIR");
}
hotmenu All_MCRx_Regs()
{
    GEL_WatchAdd("*0x7090,x","MCRA");
    GEL_WatchAdd("*0x7092,x","MCRB");
    GEL_WatchAdd("*0x7094,x","MCRC");
}
hotmenu All_PxDATDIR_Regs()
{
    GEL_WatchAdd("*0x7098,x","PADATDIR");
    GEL_WatchAdd("*0x709A,x","PBDATDIR");
    GEL_WatchAdd("*0x709C,x","PCDATDIR");
    GEL_WatchAdd("*0x709E,x","PDDATDIR");
    GEL_WatchAdd("*0x7095,x","PEDATDIR");
    GEL_WatchAdd("*0x7096,x","PFDATDIR");
}


/************************************************************/
/* Serial Communication Interface (SCI) Registers           */
/************************************************************/
menuitem "Watch SCI Registers";                    

hotmenu All_SCI_Regs()
{
    GEL_WatchAdd("*0x7050,x","SCICCR");
    GEL_WatchAdd("*0x7051,x","SCICTL1");
    GEL_WatchAdd("*0x7052,x","SCIHBAUD");
    GEL_WatchAdd("*0x7053,x","SCILBAUD");
    GEL_WatchAdd("*0x7054,x","SCICTL2");
    GEL_WatchAdd("*0x7055,x","SCIRXST");
    GEL_WatchAdd("*0x7056,x","SCIRXEMU");
    GEL_WatchAdd("*0x7057,x","SCIRXBUF");
    GEL_WatchAdd("*0x7059,x","SCITXBUF");
    GEL_WatchAdd("*0x705F,x","SCIPRI");
}
hotmenu SCICCR()
{
    GEL_WatchAdd("*0x7050,x","SCICCR");
}
hotmenu SCICTL1()
{
    GEL_WatchAdd("*0x7051,x","SCICTL1");
}
hotmenu SCIHBAUD()
{
    GEL_WatchAdd("*0x7052,x","SCIHBAUD");
}
hotmenu SCILBAUD()
{
    GEL_WatchAdd("*0x7053,x","SCILBAUD");
}
hotmenu SCICTL2()
{
    GEL_WatchAdd("*0x7054,x","SCICTL2");
}
hotmenu SCIRXST()
{
    GEL_WatchAdd("*0x7055,x","SCIRXST");
}
hotmenu SCIRXEMU()
{
    GEL_WatchAdd("*0x7056,x","SCIRXEMU");
}
hotmenu SCIRXBUF()
{
    GEL_WatchAdd("*0x7057,x","SCIRXBUF");
}
hotmenu SCITXBUF()
{
    GEL_WatchAdd("*0x7059,x","SCITXBUF");
}
hotmenu SCIPRI()
{
    GEL_WatchAdd("*0x705F,x","SCIPRI");
}


/************************************************************/
/* System Registers                                         */
/************************************************************/
menuitem "Watch System Registers";                    

hotmenu All_System_Regs()
{
    GEL_WatchAdd("*0x7018,x","SCSR1");
    GEL_WatchAdd("*0x7019,x","SCSR2");
    GEL_WatchAdd("*0x701C,x","DINR");
    GEL_WatchAdd("*0x7010,x","PIRQR0");
    GEL_WatchAdd("*0x7011,x","PIRQR1");
    GEL_WatchAdd("*0x7012,x","PIRQR2");
    GEL_WatchAdd("*0x7014,x","PIACKR0");
    GEL_WatchAdd("*0x7015,x","PIACKR1");
    GEL_WatchAdd("*0x7016,x","PIACKR2");
    GEL_WatchAdd("*0x7070,x","XINT1CR");
    GEL_WatchAdd("*0x7071,x","XINT2CR");
    GEL_WatchAdd("*0x7023,x","WDCNTR");
    GEL_WatchAdd("*0x7025,x","WDKEY");
    GEL_WatchAdd("*0x7029,x","WDCR");
}
hotmenu All_PIRQ_and_PIACK_Regs()
{
    GEL_WatchAdd("*0x7010,x","PIRQR0");
    GEL_WatchAdd("*0x7011,x","PIRQR1");
    GEL_WatchAdd("*0x7012,x","PIRQR2");
    GEL_WatchAdd("*0x7014,x","PIACKR0");
    GEL_WatchAdd("*0x7015,x","PIACKR1");
    GEL_WatchAdd("*0x7016,x","PIACKR2");
}
hotmenu SCSR1()
{
    GEL_WatchAdd("*0x7018,x","SCSR1");
}
hotmenu SCSR2()
{
    GEL_WatchAdd("*0x7019,x","SCSR2");
}
hotmenu DINR()
{
    GEL_WatchAdd("*0x701C,x","DINR");
}
hotmenu XINT1CR()
{
    GEL_WatchAdd("*0x7070,x","XINT1CR");
}
hotmenu XINT2CR()
{
    GEL_WatchAdd("*0x7071,x","XINT2CR");
}
hotmenu WDCNTR()
{
    GEL_WatchAdd("*0x7023,x","WDCNTR");
}
hotmenu WDKEY()
{
    GEL_WatchAdd("*0x7025,x","WDKEY");
}
hotmenu WDCR()
{
    GEL_WatchAdd("*0x7029,x","WDCR");
}


/********************************************************************/
/*** End of file ***/
