Ejemplo n.º 1
0
/***************************************************************************//**
 * WD_disable()
 * See "core_watchdog.h" for details of how to use this function.
 */
void
WD_disable
(
	wd_instance_t *instance
)
{
	HAL_ASSERT( instance != NULL_instance )
    
	HAL_set_32bit_reg_field( instance->base_address, WDOGCONTROL_WATCHDOG_ENABLE, 0 );
}
/***************************************************************************//**
 * TMR_stop()
 * See "core_timer.h" for details of how to use this function.
 */
void
TMR_stop
(
    timer_instance_t * this_timer
)
{
	HAL_ASSERT( this_timer != NULL_timer_instance )
    
    HAL_set_32bit_reg_field( this_timer->base_address, TimerEnable, 0 );
}
/***************************************************************************//**
 * TMR_enable_int()
 * See "core_timer.h" for details of how to use this function.
 */
void
TMR_enable_int
(
    timer_instance_t * this_timer
)
{
	HAL_ASSERT( this_timer != NULL_timer_instance )
    
    HAL_set_32bit_reg_field( this_timer->base_address, InterruptEnable, 1 );
}
Ejemplo n.º 4
0
/***************************************************************************//**
 * WD_init()
 * See "core_watchdog.h" for details of how to use this function.
 */
void
WD_init
(
	wd_instance_t *instance,
	addr_t base,
	uint32_t value,
	uint32_t scale
)
{
	HAL_ASSERT( instance != NULL_instance )
	HAL_ASSERT( scale <= WD_PRESCALER_DIV_1024 )

	instance->base_address = base;

    /* Make sure the watchdog timer is disabled. */
    HAL_set_32bit_reg_field( instance->base_address, WDOGCONTROL_WATCHDOG_ENABLE, 0 );
    
    /* Configure prescaler and load value. */
	HAL_set_32bit_reg_field( instance->base_address, WDOGCONTROL_PRESCALE, scale );
	HAL_set_32bit_reg( instance->base_address, WDOGLOAD, value );
}
/***************************************************************************//**
 * TMR_init()
 * See "core_timer.h" for details of how to use this function.
 */
void 
TMR_init
(
	timer_instance_t * this_timer,
	addr_t address,
	uint8_t mode,
	uint32_t prescale,
	uint32_t load_value
)
{
	HAL_ASSERT( this_timer != NULL_timer_instance )
	HAL_ASSERT( prescale <= PRESCALER_DIV_1024 )
	HAL_ASSERT( load_value != 0 )
    
    this_timer->base_address = address;

    /* Disable interrupts. */
    HAL_set_32bit_reg_field( address, InterruptEnable,0 );

    /* Disable timer. */
    HAL_set_32bit_reg_field( address, TimerEnable, 0 );

    /* Clear pending interrupt. */
    HAL_set_32bit_reg( address, TimerIntClr, 1 );

    /* Configure prescaler and load value. */	
    HAL_set_32bit_reg( address, TimerPrescale, prescale );
    HAL_set_32bit_reg( address, TimerLoad, load_value );

    /* Set the interrupt mode. */
    if ( mode == TMR_CONTINUOUS_MODE )
    {
        HAL_set_32bit_reg_field( address, TimerMode, 0 );
    }
    else
    {
        /* TMR_ONE_SHOT_MODE */
        HAL_set_32bit_reg_field( address, TimerMode, 1 );
    }
}