1
0
mirror of https://github.com/elua/elua.git synced 2025-01-08 20:56:17 +08:00

Fixed timer counting direction on all platforms

On some platforms, the hardware timers were counting down instead
of up, which broke the assumptions of the new timer implementation.
Fixed by inverting the timer value (relative to its maximum value).
This commit is contained in:
Bogdan Marinescu 2012-05-26 00:45:18 +03:00
parent d54659b572
commit 2658f7cf77
3 changed files with 7 additions and 0 deletions

View File

@ -272,6 +272,10 @@ timer_data_type platform_timer_op( unsigned id, int op, timer_data_type data )
return platform_timer_get_diff_us( id, 0, platform_timer_get_max_cnt( id ) );
else if( op == PLATFORM_TIMER_OP_GET_MIN_DELAY )
return platform_timer_get_diff_us( id, 0, 1 );
#ifdef PLATFORM_TMR_COUNTS_DOWN
else if( op == PLATFORM_TIMER_OP_START || op == PLATFORM_TIMER_OP_READ )
return platform_s_timer_op( id, PLATFORM_TIMER_OP_GET_MAX_CNT, 0 ) - platform_s_timer_op( id, op, 0 );
#endif
else
return platform_s_timer_op( id, op, data );
}

View File

@ -41,6 +41,7 @@
#define BUILD_C_INT_HANDLERS
#define PLATFORM_HAS_SYSTIMER
#define PLATFORM_TMR_COUNTS_DOWN
// *****************************************************************************
// UART/Timer IDs configuration data (used in main.c)

View File

@ -26,6 +26,8 @@
#define TERM_LINES 25
#define TERM_COLS 80
#define PLATFORM_TMR_COUNTS_DOWN
// *****************************************************************************
// Configuration data