Freescale Semiconductor Inc.
    Regional Technical Application Center

 

E:/PROJECTS/IOP/ADC Average/Src/ADC_Filter/ADC_Filter_Drv/src/Emios.h File Reference

This file contains all timebase definitions for Multi-Thread Scheduler. More...

#include "Derivative.h"
#include "Mcu.h"
#include "typedefs.h"
#include "Scheduler.h"
#include "Emsci_ReportError.h"

Include dependency graph for Emios.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define EMIOS_CH0   (uint8_t)0U
#define EMIOS_CH1   (uint8_t)1U
#define EMIOS_CH2   (uint8_t)2U
#define EMIOS_CH3   (uint8_t)3U
#define EMIOS_CH4   (uint8_t)4U
#define EMIOS_CH5   (uint8_t)5U
#define EMIOS_CH6   (uint8_t)6U
#define EMIOS_CH7   (uint8_t)7U
#define EMIOS_CH8   (uint8_t)8U
#define EMIOS_CH9   (uint8_t)9U
#define START_BIT_SENT   (uint8_t) 0x01
#define START_BIT_NOT_SENT   (uint8_t) 0x00
#define LOOP_TIME_100ms   (((float32_t)SYS_FREQ * (float32_t)0.100) / ((float32_t)eMIOS_GLOBAL_PRESCALER * (float32_t)eMIOS_TM_LOCAL_PRESCALER))
#define LOOP_TIME_50ms   (((float32_t)SYS_FREQ * (float32_t)0.05) / ((float32_t)eMIOS_GLOBAL_PRESCALER * (float32_t)eMIOS_TM_LOCAL_PRESCALER))
#define EMIOS_GPIO_MODE   ((uint8_t)0x00)
#define EMIOS_MCB_MODE   ((uint8_t)0x50)
#define EMIOS_SAIC_MODE   ((uint8_t)0x02)
#define EMIOS_SAOC_MODE   ((uint8_t)0x03)
#define CNTR_BUS_A   ((uint8_t)0)
#define CNTR_BUS_BCD   ((uint8_t)1)
#define CNTR_BUS_INTERNAL   ((uint8_t)3)
#define eMIOS_GLOBAL_PRESCALER   ((uint32_t)128)
#define eMIOS_ENABLE_GLOBAL_TIMEBASE   (EMIOS.MCR.B.GTBE = (uint32_t)(1))
#define eMIOS_ENABLE_GLOBAL_PRESCALER   (EMIOS.MCR.B.GPREN = (uint32_t)(1))
#define eMIOS_SET_GLOBAL_PRESCALER_VALUE(value)   (EMIOS.MCR.B.GPRE = (uint32_t)(value))
#define eMIOS_ENABLE_GLOBAL_FREEZE_IN_DEBUG   (EMIOS.MCR.B.FRZ = (uint32_t)1)
#define eMIOS_SET_COUNT_A(channel, count)   (EMIOS.CH[(uint8_t)channel].CADR.R = (uint16_t)(count))
#define eMIOS_SET_COUNT_B(channel, count)   (EMIOS.CH[channel].CBDR.R = (uint16_t)(count))
#define eMIOS_STATUS_FLAG(channel)   EMIOS.CH[channel].CSR.B.FLAG
#define eMIOS_TIMER_COUNT(channel)   EMIOS.CH[channel].CCNTR.R
#define eMIOS_ENABLE_LOCAL_PRESCALER(channel)   (EMIOS.CH[channel].CCR.B.UCPEN = (uint32_t)(1))
#define eMIOS_DISABLE_LOCAL_PRESCALER(channel)   (EMIOS.CH[channel].CCR.B.UCPEN = (uint32_t)(0))
#define eMIOS_SET_PRESCALER(channel, value)   (EMIOS.CH[channel].CCR.B.UCPRE = (uint32_t)(value))
#define eMIOS_ENABLE_CHANNEL_INTERRUPT(channel)   (EMIOS.CH[channel].CCR.B.FEN = (uint32_t)(1))
#define eMIOS_DISABLE_CHANNEL_INTERRUPT(channel)   (EMIOS.CH[channel].CCR.B.FEN = (uint32_t)(0))
#define eMIOS_CLEAR_COUNTER(channel)   (eMIOS_TIMER_COUNT(channel) = (uint16_t)(0))
#define eMIOS_CLEAR_STATUS_FLAG(channel)   (eMIOS_STATUS_FLAG(channel) = (uint32_t)(1))
#define eMIOS_FREEZE_IN_DEBUG(channel)   (EMIOS.CH[channel].CCR.B.FREN = (uint32_t)(1))
#define eMIOS_SET_INTERNAL_TIME_BASE(channel)   (EMIOS.CH[channel].CCR.B.BSL = (uint32_t)(3))
#define eMIOS_SET_EDGE_SELECT(channel, Mode)   (EMIOS.CH[channel].CCR.B.EDSEL = (uint32_t)(Mode))
#define eMIOS_SET_EDGE_POLARITY(channel, pol)   (EMIOS.CH[channel].CCR.B.EDPOL = (uint32_t)(pol))
#define eMIOS_MATCH_EVENT_FLAG(channel)   EMIOS.CH[channel].CSR.B.FLAG
#define eMIOS_CLEAR_OVERFLOW_FLAG(channel)   EMIOS.CH[channel].CSR.B.OVFL = (uint32_t)1
#define eMIOS_SET_MODE(channel, Mode)   EMIOS.CH[(uint32_t)channel].CCR.B.MODE = (uint32_t)Mode
#define eMIOS_SET_MODULUS_UP_COUNTER(channel)   EMIOS.CH[channel].CCR.B.MODE = EMIOS_MCB_MODE
#define EMIOS_CHANNEL_0   ((uint8_t)0)
#define INTERRUPT_EMIOS_0   ((uint8_t)58)
#define INTERRUPT_EMIOS_1   ((uint8_t)59)
#define INTERRUPT_EMIOS_9   ((uint8_t)67)
#define eMIOS_TM_LOCAL_PRESCALER   ((uint8_t)4)

Typedefs

typedef void(* Emios_CallbackType )(void)

Functions

void vfnEmios_Set_Callback_Fnc (Emios_CallbackType Callback_Fnc, uint8_t u8FncCallback)
 Sets the function to which the emios interrupt shall
jump once interrupt occurs.
void vfnEmios_Init_Channel (uint8_t u8EmiosChannel, uint8_t u8Emios_Interrupt_Num)
 Initialize specific emios channel.
void vfnEmiosConfig_General_Clocks (void)
 Enable General Emios Clocks.
void vfnEmios_Modulous_Cntr_Mode (uint8_t u8EmiosChannel, uint32_t u32Timming)
 Configures the Emios Modulus Counter Mode and starts the Specific Emios channel.
void vfnEmios_Isr_0 (void)
 Service Interrupt routine from Emios channel 0.
void vfnEmios_Isr_1 (void)
 Service Interrupt routine from Emios channel 0.
void vfnEmios_Isr_2 (void)
 Service Interrupt routine from Emios channel 2.
void vfnEmios_Isr_3 (void)
 Service Interrupt routine from Emios channel 3.
void vfnEmios_Isr_4 (void)
 Service Interrupt routine from Emios channel 4.
void vfnEmios_Isr_5 (void)
 Service Interrupt routine from Emios channel 5.
void vfnEmios_Isr_6 (void)
 Service Interrupt routine from Emios channel 6.
void vfnEmios_Isr_7 (void)
 Service Interrupt routine from Emios channel 7.
void vfnEmios_Isr_9 (void)
 Service Interrupt routine from Emios channel 9
this interrupt calls Scheduler function.


Detailed Description

This file contains all timebase definitions for Multi-Thread Scheduler.

Copyright (c) 2008 Freescale Semiconductor Freescale Confidential Proprietary

Author:
Freescale Semiconductor

Guadalajara Applications Laboratory RTAC Americas

R01160

Version:
0.1
Date:
5/23/2008

Define Documentation

#define CNTR_BUS_A   ((uint8_t)0)

Modes used to select either one of the counter buses or the internal counter

#define CNTR_BUS_BCD   ((uint8_t)1)

#define CNTR_BUS_INTERNAL   ((uint8_t)3)

#define EMIOS_CH0   (uint8_t)0U

Emios channels definitions

#define EMIOS_CH1   (uint8_t)1U

#define EMIOS_CH2   (uint8_t)2U

#define EMIOS_CH3   (uint8_t)3U

#define EMIOS_CH4   (uint8_t)4U

#define EMIOS_CH5   (uint8_t)5U

#define EMIOS_CH6   (uint8_t)6U

#define EMIOS_CH7   (uint8_t)7U

#define EMIOS_CH8   (uint8_t)8U

#define EMIOS_CH9   (uint8_t)9U

#define EMIOS_CHANNEL_0   ((uint8_t)0)

emios channel assigned to generate Scheduler Timebase

#define eMIOS_CLEAR_COUNTER ( channel   )     (eMIOS_TIMER_COUNT(channel) = (uint16_t)(0))

Clear counter of specified channel

#define eMIOS_CLEAR_OVERFLOW_FLAG ( channel   )     EMIOS.CH[channel].CSR.B.OVFL = (uint32_t)1

Clears Overflow flag

#define eMIOS_CLEAR_STATUS_FLAG ( channel   )     (eMIOS_STATUS_FLAG(channel) = (uint32_t)(1))

Clear counter flag

#define eMIOS_DISABLE_CHANNEL_INTERRUPT ( channel   )     (EMIOS.CH[channel].CCR.B.FEN = (uint32_t)(0))

Allow unified channel to disable interrupt

#define eMIOS_DISABLE_LOCAL_PRESCALER ( channel   )     (EMIOS.CH[channel].CCR.B.UCPEN = (uint32_t)(0))

Local Prescaler disabled

#define eMIOS_ENABLE_CHANNEL_INTERRUPT ( channel   )     (EMIOS.CH[channel].CCR.B.FEN = (uint32_t)(1))

Allow unified channel to set interrupt

#define eMIOS_ENABLE_GLOBAL_FREEZE_IN_DEBUG   (EMIOS.MCR.B.FRZ = (uint32_t)1)

Globally enable freeze mode

#define eMIOS_ENABLE_GLOBAL_PRESCALER   (EMIOS.MCR.B.GPREN = (uint32_t)(1))

Global prescaler enabled

#define eMIOS_ENABLE_GLOBAL_TIMEBASE   (EMIOS.MCR.B.GTBE = (uint32_t)(1))

Global Timebase enabled

#define eMIOS_ENABLE_LOCAL_PRESCALER ( channel   )     (EMIOS.CH[channel].CCR.B.UCPEN = (uint32_t)(1))

Local Prescaler enabled

#define eMIOS_FREEZE_IN_DEBUG ( channel   )     (EMIOS.CH[channel].CCR.B.FREN = (uint32_t)(1))

Stop (freeze) channel registers when in debug mode

#define eMIOS_GLOBAL_PRESCALER   ((uint32_t)128)

Global eMIOS prescaler: SysClk -> Global Pres -> Local Prescaler

#define EMIOS_GPIO_MODE   ((uint8_t)0x00)

emios Operation Mode

#define eMIOS_MATCH_EVENT_FLAG ( channel   )     EMIOS.CH[channel].CSR.B.FLAG

Indicator of input capture or a match event in the comparators occurred

#define EMIOS_MCB_MODE   ((uint8_t)0x50)

#define EMIOS_SAIC_MODE   ((uint8_t)0x02)

#define EMIOS_SAOC_MODE   ((uint8_t)0x03)

#define eMIOS_SET_COUNT_A ( channel,
count   )     (EMIOS.CH[(uint8_t)channel].CADR.R = (uint16_t)(count))

Load eMIOS counter register A with a 24-bit value

#define eMIOS_SET_COUNT_B ( channel,
count   )     (EMIOS.CH[channel].CBDR.R = (uint16_t)(count))

Load eMIOS counter register B with a 24-bit value

#define eMIOS_SET_EDGE_POLARITY ( channel,
pol   )     (EMIOS.CH[channel].CCR.B.EDPOL = (uint32_t)(pol))

Set edge polarity accordingly

#define eMIOS_SET_EDGE_SELECT ( channel,
Mode   )     (EMIOS.CH[channel].CCR.B.EDSEL = (uint32_t)(Mode))

Set edge mode accordingly

#define eMIOS_SET_GLOBAL_PRESCALER_VALUE ( value   )     (EMIOS.MCR.B.GPRE = (uint32_t)(value))

Set global prescaler value accordingly

#define eMIOS_SET_INTERNAL_TIME_BASE ( channel   )     (EMIOS.CH[channel].CCR.B.BSL = (uint32_t)(3))

Choose internal time base for channel

#define eMIOS_SET_MODE ( channel,
Mode   )     EMIOS.CH[(uint32_t)channel].CCR.B.MODE = (uint32_t)Mode

#define eMIOS_SET_MODULUS_UP_COUNTER ( channel   )     EMIOS.CH[channel].CCR.B.MODE = EMIOS_MCB_MODE

#define eMIOS_SET_PRESCALER ( channel,
value   )     (EMIOS.CH[channel].CCR.B.UCPRE = (uint32_t)(value))

Set local prescaler value

#define eMIOS_STATUS_FLAG ( channel   )     EMIOS.CH[channel].CSR.B.FLAG

Definition of eMIOS status flag

#define eMIOS_TIMER_COUNT ( channel   )     EMIOS.CH[channel].CCNTR.R

Define timer count register

#define eMIOS_TM_LOCAL_PRESCALER   ((uint8_t)4)

Task Manager channel eMIOS prescaler

#define INTERRUPT_EMIOS_0   ((uint8_t)58)

Define interrupt assigned to Timer channel

#define INTERRUPT_EMIOS_1   ((uint8_t)59)

Define interrupt assigned to Timer channel

#define INTERRUPT_EMIOS_9   ((uint8_t)67)

Define interrupt assigned to Timer channel

#define LOOP_TIME_100ms   (((float32_t)SYS_FREQ * (float32_t)0.100) / ((float32_t)eMIOS_GLOBAL_PRESCALER * (float32_t)eMIOS_TM_LOCAL_PRESCALER))

Timing constants

#define LOOP_TIME_50ms   (((float32_t)SYS_FREQ * (float32_t)0.05) / ((float32_t)eMIOS_GLOBAL_PRESCALER * (float32_t)eMIOS_TM_LOCAL_PRESCALER))

#define START_BIT_NOT_SENT   (uint8_t) 0x00

#define START_BIT_SENT   (uint8_t) 0x01


Typedef Documentation

typedef void(* Emios_CallbackType)(void)

Function pointer callback definition


Function Documentation

void vfnEmios_Init_Channel ( uint8_t  u8EmiosChannel,
uint8_t  u8Emios_Interrupt_Num 
)

Initialize specific emios channel.

Author:
R01160
Parameters:
Emios Channel, Interrupt Vector Number.
Returns:
void
Warning:
This function does not intialize the emios pin functionality of the MCU
neither the operation mode of the Emios channel.

void vfnEmios_Isr_0 ( void   ) 

Service Interrupt routine from Emios channel 0.

Author:
R01160
Parameters:
none 
Returns:
none

void vfnEmios_Isr_1 ( void   ) 

Service Interrupt routine from Emios channel 0.

Author:
R01160
Parameters:
none 
Returns:
none

void vfnEmios_Isr_2 ( void   ) 

Service Interrupt routine from Emios channel 2.

Author:
R01160
Parameters:
none 
Returns:
none

void vfnEmios_Isr_3 ( void   ) 

Service Interrupt routine from Emios channel 3.

Author:
R01160
Parameters:
none 
Returns:
none

void vfnEmios_Isr_4 ( void   ) 

Service Interrupt routine from Emios channel 4.

Author:
R01160
Parameters:
none 
Returns:
none

void vfnEmios_Isr_5 ( void   ) 

Service Interrupt routine from Emios channel 5.

Author:
R01160
Parameters:
none 
Returns:
none

void vfnEmios_Isr_6 ( void   ) 

Service Interrupt routine from Emios channel 6.

Author:
R01160
Parameters:
none 
Returns:
none

void vfnEmios_Isr_7 ( void   ) 

Service Interrupt routine from Emios channel 7.

Author:
R01160
Parameters:
none 
Returns:
none

void vfnEmios_Isr_9 ( void   ) 

Service Interrupt routine from Emios channel 9
this interrupt calls Scheduler function.

Author:
R01160
Parameters:
none 
Returns:
none

void vfnEmios_Modulous_Cntr_Mode ( uint8_t  u8EmiosChannel,
uint32_t  u32Timming 
)

Configures the Emios Modulus Counter Mode and starts the Specific Emios channel.

Author:
R01160
Parameters:
Emios Channel, Timming Interrupt.
Returns:
void
Warning:
This functions works only to operate the Modulus Up counter of the
Emios module.

void vfnEmios_Set_Callback_Fnc ( const Emios_CallbackType  Callback_Fnc,
uint8_t  u8FncCallback 
)

Sets the function to which the emios interrupt shall
jump once interrupt occurs.

Set a function pointer to call after emios interrupt occurs

Author:
R01160
Parameters:
Emios_CallbackType - Callback type definition, Fnc Callback
to be used.
Returns:
none
Warning:
this function will skip any null pointer parameter passed
as a input parameter.

void vfnEmiosConfig_General_Clocks ( void   ) 

Enable General Emios Clocks.

Author:
R01160
Parameters:
void 
Returns:
void