Hi!
I've checked your solution, and I think it's OK. Only to comment that in almost all other eCos HALs, the definition of the RTC Constants follow always the same rule: 1000000000 for CYGNUM_HAL_RTC_NUMERATOR, and the frequency of the timer (times per second) for CYGNUM_HAL_RTC_DENOMINATOR. This is helpful because this way you only have to define one constant, and it's pretty straight.
If we follow this rule, and extracting some of the code of the previous altera_avalon_timer.h and I got this:
"# define ALT_SYS_CLK_PERIOD_MULT ((ALT_SYS_CLK_PERIOD_UNITS !=
ALT_AVALON_TIMER_PERIOD_UNITS_S) ?
((ALT_SYS_CLK_PERIOD_UNITS != ALT_AVALON_TIMER_PERIOD_UNITS_MS) ?
((ALT_SYS_CLK_PERIOD_UNITS != ALT_AVALON_TIMER_PERIOD_UNITS_US ) ?
1000000000
: 1000000)
: 1000)
: 1)
# define ALT_SYS_CLK_PERIOD_DIV (ALT_SYS_CLK_PERIOD)
/*
* Having extracted the timer constants, use these to contruct the real time clock constants
* required for eCos.
*/
# define CYGNUM_HAL_RTC_CONSTANTS (1)# define CYGNUM_HAL_RTC_NUMERATOR (1000000000)# define CYGNUM_HAL_RTC_DENOMINATOR (ALT_SYS_CLK_PERIOD_MULT
/ ALT_SYS_CLK_PERIOD_DIV)
"
I think this is working, except for the ALT_AVALON_TIMER_PERIOD_UNITS_CLOCKS case, which I haven't considered.
Hope this will be in the next nios altera package.
Thanx
Alex