1
0
mirror of https://github.com/elua/elua.git synced 2025-01-25 01:02:54 +08:00

Merge branch 'master' into newsite

This commit is contained in:
James Snyder 2011-12-02 16:35:49 -06:00
commit e51f4b9a33
3 changed files with 8 additions and 8 deletions

View File

@ -587,21 +587,21 @@ timer_data_type platform_s_timer_op( unsigned id, int op, timer_data_type data )
int platform_s_timer_set_match_int( unsigned id, timer_data_type period_us, int type )
{
volatile avr32_tc_t *tc = &AVR32_TC;
u32 final;
u64 final;
if( period_us == 0 )
{
tc->channel[ id ].CMR.waveform.wavsel = TC_WAVEFORM_SEL_UP_MODE;
return PLATFORM_TIMER_INT_OK;
}
final = ( u32 )( ( u64 )( platform_timer_get_clock( id ) * period_us ) / 1000000 );
final = ( u64 )platform_timer_get_clock( id ) * period_us / 1000000;
if( final == 0 )
return PLATFORM_TIMER_INT_TOO_SHORT;
if( final > 0xFFFF )
return PLATFORM_TIMER_INT_TOO_LONG;
tc_stop( tc, id );
tc->channel[ id ].CMR.waveform.wavsel = TC_WAVEFORM_SEL_UP_MODE_RC_TRIGGER;
tc->channel[ id ].rc = final;
tc->channel[ id ].rc = ( u32 )final;
avr32_timer_int_periodic_flag[ id ] = type;
tc_start( tc, id );
return PLATFORM_TIMER_INT_OK;

View File

@ -804,7 +804,7 @@ int platform_s_timer_set_match_int( unsigned id, timer_data_type period_us, int
{
TIM_TypeDef* base = ( TIM_TypeDef* )timer[ id ];
u32 period, prescaler, freq;
timer_data_type final;
u64 final;
TIM_OCInitTypeDef TIM_OCInitStructure;
if( period_us == 0 )
@ -834,12 +834,12 @@ int platform_s_timer_set_match_int( unsigned id, timer_data_type period_us, int
TIM_OCStructInit( &TIM_OCInitStructure );
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Timing;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = final;
TIM_OCInitStructure.TIM_Pulse = ( u16 )final;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init( base, &TIM_OCInitStructure );
// Patch timer configuration to reload when period is reached
TIM_SetAutoreload( base, final );
TIM_SetAutoreload( base, ( u16 )final );
TIM_OC1PreloadConfig( base, TIM_OCPreload_Enable );

View File

@ -396,7 +396,7 @@ int platform_s_timer_set_match_int( unsigned id, timer_data_type period_us, int
{
TIM_TypeDef* base = ( TIM_TypeDef* )str9_timer_data[ id ];
u32 freq;
timer_data_type final;
u64 final;
TIM_InitTypeDef TIM_InitStructure;
if( period_us == 0 )
@ -421,7 +421,7 @@ int platform_s_timer_set_match_int( unsigned id, timer_data_type period_us, int
TIM_InitStructure.TIM_Clock_Source = TIM_CLK_APB;
TIM_InitStructure.TIM_Clock_Edge = TIM_CLK_EDGE_FALLING;
TIM_InitStructure.TIM_Prescaler = TIM_GetPrescalerValue( base );
TIM_InitStructure.TIM_Pulse_Length_1 = final;
TIM_InitStructure.TIM_Pulse_Length_1 = ( u16 )final;
TIM_Init( base, &TIM_InitStructure );
str9_timer_int_periodic_flag[ id ] = type;