elc.c 1.84 KB
Newer Older
时昊's avatar
时昊 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
/***********************************************************************************************************************
Includes
***********************************************************************************************************************/

#include "elc.h"
/* Start user code for include. Do not edit comment generated here */
/* End user code. Do not edit comment generated here */

/***********************************************************************************************************************
* Function Name: ELC_Start
* @brief  This function initializes the ELC module.
* @param  event_src - event resources number to be start (bit n for ELSELRn)
* @param  event_dst - event destination number to be start (value of ELSELRn)
* @return None
***********************************************************************************************************************/
void ELC_Start(uint32_t event_src, uint32_t event_dst)
{
    volatile uint8_t  * sfr_addr;
    
    sfr_addr = &ELC->ELSELR00;
    
    // ELSELRn(n=00~14) = Link Destination Number
    *(sfr_addr + event_src) = event_dst;
}

/***********************************************************************************************************************
* Function Name: ELC_Stop
* @brief  This function stops the ELC event resources.
* @param  event - event resources to be stoped (bit n for ELSELRn)
* @return None
***********************************************************************************************************************/
void ELC_Stop(uint32_t event)
{
    volatile uint32_t   w_count;
    volatile uint8_t  * sfr_addr;

    sfr_addr = &ELC->ELSELR00;
    
    for (w_count = 0U; w_count < ELC_DESTINATION_COUNT; w_count++) 
    {
        if (0x1U == ((event >> w_count) & 0x1U))
        {
            *sfr_addr = _00_ELC_EVENT_LINK_OFF;
        }
        
        sfr_addr++;
    }
}