/************************************************************************
 *    This file was generated by eTPU Graphical Configuration Tool        
 *                                                                        
 *  DESCRIPTION:
 *  This file is generated together with the same name .c file.
 *  It contains function prototypes and useful defines.
 *
 *  Creation Date: 12.1.2012
 *
 **************************************************************************/

/**************************************************************************
 * general macros
 **************************************************************************/
#define FS_ETPU_TCR1_PRESCALER(x)    (((x)-1) & 0xFF)
#define FS_ETPU_TCR2_PRESCALER(x)    ((((x)-1) & 0x3F)<<16)
#define FS_ETPU_TCR1_STAC_SRVSLOT(x) (((x) & 0xF)<<16)
#define FS_ETPU_TCR2_STAC_SRVSLOT(x) ((x) & 0xF)

#define FS_ETPU_ENTRY_TABLE_ADDR     (((FS_ETPU_ENTRY_TABLE)>>11) & 0x1F)

#define ETPU_ENGINE_A_CHANNEL(x)  (x)
#define ETPU_ENGINE_B_CHANNEL(x)  ((x)+64)
#define ETPU_CHANNEL_BIT(x)       (1<<((x) % 64))

/**************************************************************************
 * define functions to channels
 **************************************************************************/
#define APP_PMSMRSVC0_RSLV	                   ETPU_ENGINE_A_CHANNEL(0)
#define APP_PMSMRSVC0_SC                       ETPU_ENGINE_B_CHANNEL(5)
#define APP_PMSMRSVC0_PMSMVC                   ETPU_ENGINE_B_CHANNEL(6)
#define APP_PMSMRSVC0_PWM_MASTER               ETPU_ENGINE_B_CHANNEL(7)
#define APP_PMSMRSVC0_PWM_PHASEA_BASE_CHANNEL  ETPU_ENGINE_B_CHANNEL(8)
#define APP_PMSMRSVC0_PWM_PHASEA_COMPL_CHANNEL ETPU_ENGINE_B_CHANNEL(9)
#define APP_PMSMRSVC0_PWM_PHASEB_BASE_CHANNEL  ETPU_ENGINE_B_CHANNEL(10)
#define APP_PMSMRSVC0_PWM_PHASEB_COMPL_CHANNEL ETPU_ENGINE_B_CHANNEL(11)
#define APP_PMSMRSVC0_PWM_PHASEC_BASE_CHANNEL  ETPU_ENGINE_B_CHANNEL(12)
#define APP_PMSMRSVC0_PWM_PHASEC_COMPL_CHANNEL ETPU_ENGINE_B_CHANNEL(13)
#define APP_PMSMRSVC0_BC                       ETPU_ENGINE_B_CHANNEL(14)
#define APP_PMSMRSVC0_ASAC                     ETPU_ENGINE_A_CHANNEL(29)

/**************************************************************************
 * Interrupt Enable, DMA Enable and Output Disable options
 * filled accodring to the user settings
 **************************************************************************/
#define ETPU_CIE_A    0x00000000
#define ETPU_DTRE_A   0x00000000
#define ETPU_ODIS_A   0x00000000
#define ETPU_OPOL_A   0x00000000
#define ETPU_CIE_B    ( ETPU_CHANNEL_BIT(APP_PMSMRSVC0_PWM_MASTER) \
                      | ETPU_CHANNEL_BIT(APP_PMSMRSVC0_SC)) //enable interrupts from PWMMAC and SC
#define ETPU_DTRE_B   0x00000000
#define ETPU_ODIS_B   0x00000000
#define ETPU_OPOL_B   0x00000000

/**************************************************************************
 * function prototypes
 **************************************************************************/
int32_t my_system_etpu_init ();
void    my_system_etpu_start();


