/***************************************************************************//** * WD_reload() * See "core_watchdog.h" for details of how to use this function. */ void WD_reload ( wd_instance_t *instance ) { HAL_ASSERT( instance != NULL_instance ) HAL_set_32bit_reg( instance->base_address, WDOGREFRESH, 1 ); }
/***************************************************************************//** * TMR_clear_int() * See "core_timer.h" for details of how to use this function. */ void TMR_clear_int ( timer_instance_t * this_timer ) { HAL_ASSERT( this_timer != NULL_timer_instance ) HAL_set_32bit_reg( this_timer->base_address, TimerIntClr, 0x01 ); }
/***************************************************************************//** * TMR_reload() * See "core_timer.h" for details of how to use this function. */ void TMR_reload ( timer_instance_t * this_timer, uint32_t load_value ) { HAL_ASSERT( this_timer != NULL_timer_instance ) HAL_ASSERT( load_value != 0 ) HAL_set_32bit_reg(this_timer->base_address, TimerLoad, load_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 ); } }
/***************************************************************************//** * 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 ); }
/*-------------------------------------------------------------------------*//** * PWM_init() * See "core_pwm.h" for details of how to use this function. */ void PWM_init ( pwm_instance_t * pwm_inst, addr_t base_addr, uint32_t prescale, uint32_t period ) { pwm_inst->address = base_addr; HAL_set_8bit_reg( pwm_inst->address, PWM_ENABLE_1, 0u ); HAL_set_8bit_reg( pwm_inst->address, PWM_ENABLE_2, 0u ); HAL_set_32bit_reg( pwm_inst->address, PRESCALE, (uint_fast32_t)prescale ); /* * The minimum allowed period parameter value is 1. * This simplifies the duty cycle and edge value calculations for the driver. */ HAL_ASSERT( period >= 1 ) HAL_set_32bit_reg( pwm_inst->address, PERIOD, (uint_fast32_t)period ); /* Set positive edge to 0 for all PWMs. */ HAL_set_32bit_reg( pwm_inst->address, PWM1_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM2_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM3_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM4_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM5_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM6_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM7_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM8_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM9_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM10_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM11_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM12_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM13_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM14_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM15_POSEDGE, 0u ); HAL_set_32bit_reg( pwm_inst->address, PWM16_POSEDGE, 0u ); }