//#############################################################################
//
// FILE:   cla_ex4_debug_variable_cla.cla
//
// TITLE:  CLA Task1 nesting in a Background Task
//
// Task 1 turns on and turns off D1 every 0.5 seconds
// Background task turns on and turns off D2 every 2 seconds
// due to the nesting time of task 1, maybe longer for real period.

//#############################################################################
// $TI Release: F28004x Support Library v1.08.00.00 $
// $Release Date: Mon Dec 23 17:24:05 IST 2019 $
// $Copyright:
// Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without 
// modification, are permitted provided that the following conditions 
// are met:
// 
//   Redistributions of source code must retain the above copyright 
//   notice, this list of conditions and the following disclaimer.
// 
//   Redistributions in binary form must reproduce the above copyright
//   notice, this list of conditions and the following disclaimer in the 
//   documentation and/or other materials provided with the   
//   distribution.
// 
//   Neither the name of Texas Instruments Incorporated nor the names of
//   its contributors may be used to endorse or promote products derived
//   from this software without specific prior written permission.
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################

//
// Included Files
//
#include <cla_ex4_debug_variable_shared.h>
#include <stdint.h>
#include "device.h"
#include "driverlib.h"

extern uint16_t u16CmpClaLoop_Cla1ToCpuMsgRAM;
extern uint16_t u16CmpClaLoop_Cla1Data;
extern uint16_t u16CmpClaLoop_global;

//-----------------------------------------------------------------------------
//
// Task 1
//
//-----------------------------------------------------------------------------
__attribute__((interrupt)) void Cla1Task1 ( void )
{
    //
    // Turn on LED1
    //
    GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);

    __mdebugstop();
    int32_t i;

    u16CmpClaLoop_Cla1ToCpuMsgRAM++;
    u16CmpClaLoop_Cla1Data++;
    u16CmpClaLoop_global++;

    for(i = 250000; i>=0; i--)
    {
        __asm(" MNOP");
        __asm(" MNOP");
        __asm(" MNOP");
        __asm(" MNOP");
        __asm(" MNOP");
        __asm(" MNOP");
        __asm(" MNOP");
        __asm(" MNOP");
        __asm(" MNOP");
        __asm(" MNOP");
    }

    //
    // Turn off LED1
    //
    GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);

    //
    // Clear EPWM interrupt flag
    //
    EPWM_clearEventTriggerInterruptFlag(EPWM1_BASE);
}

//-----------------------------------------------------------------------------
//
// Task 2 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task2 ( void )
{

}

//-----------------------------------------------------------------------------
//
// Task 3 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task3 ( void )
{

}

//-----------------------------------------------------------------------------
//
// Task 4 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task4 ( void )
{

}

//-----------------------------------------------------------------------------
//
// Task 5 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task5 ( void )
{

}

//-----------------------------------------------------------------------------
//
// Task 6 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task6 ( void )
{

}

//-----------------------------------------------------------------------------
//
// Task 7 - One Time Initialization Task
//
// Description: This task will clear out the delay line and reset the index
// and any flags
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task7 ( void )
{

}

//-----------------------------------------------------------------------------
//
// Task 8 - One Time Initialization Task
//
// Description: This task will clear out the delay line and reset the index
// and any flags
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task8 ( void )
{

}

//
// End of File
//
