Desculpa a demora para responder tcpipchip...
Eu tinha dois problemas para usar esse driver disponibilizado pelo ccs, 1º não estava conseguindo compilar e 2º toda vez que eu chamava alguma função do driver, o código fica parado num loop dentro da clocl_t clock(void).
Como eu resolvi os problemas:
1º problema - dentro do driver rtcticks.c ele incluí o arquivo time.c, percebi que os defines, estruturas, etc que era usado por esses dois drivers não estavam sendo declarados e pq?!!! pq o arquivo time.c não tinha o include do arquivo time.h... inserido o time.h resolvido o primeiro problema.
2º problema - esse foi um pouco mais complicado, no arquivo rtcticks.c tem uma diretiva #use timer(options), que basicamente utiliza um timer como base de tempo para gerar os ticks, no help diz que essa diretiva cria automaticamente um define chamado TICKS_PER_SECOND, mas ao que tudo indica não é verdade ou eu interpretei errado o help, pq esse define não foi criado e era esse o motivo do código travar na função clocl_t clock(void). o que eu fiz foi calcular qtos ticks eu teria dentro de um segundo e criar manualmente um define TICKS_PER_SECOND...
segue código do driver rtcticks.c:
cpp code
#ifndef __RTCTICKS_C__
#define __RTCTICKS_C__
#include <time.c>
#ifndef GET_RTC_TICKS
#use timer(TICK=10ms, BITS=32, ISR)
//if you change the above #use timer() to use ISR, then you need
//to enable_interrupts(GLOBAL) in order for timer ISR to be triggered.
#define GET_RTC_TICKS() get_ticks()
#define CLOCKS_PER_SECOND TICKS_PER_SECOND
#if defined(__PCD__)
//PCD has global interrupts enabled by default
#define INIT_RTC_TICKS()
#else
//enable interrupts because our #use timer() above is using ISR option.
#define INIT_RTC_TICKS() enable_interrupts(GLOBAL)
#endif
#endif
#ifndef INIT_RTC_TICKS
#define INIT_RTC_TICKS()
#endif
/* Globals & Resources */
static clock_t clock_ticks;
static time_t calendar_time; //seconds since Jan 1, 1970 00:00:00
/* Returns processor time used by program (clock ticks)
* Ticks occur at a rate specified by CLOCKS_PER_SECOND
*/
clock_t clock(void)
{
while (((clock_t)GET_RTC_TICKS() - clock_ticks) >= (clock_t)CLOCKS_PER_SECOND)
{
calendar_time += 1;
clock_ticks += (clock_t)CLOCKS_PER_SECOND;
}
return((clock_t)GET_RTC_TICKS());
}
/* Returns the current calendar time.
*/
time_t time(time_t * timer)
{
clock();
if (!timer)
*timer = calendar_time;
return(calendar_time);
}
/* Sets the current calendar time (in seconds) from the given time
* and resets the timer ticks.
*/
void SetTime(struct_tm * nTime)
{
calendar_time = mktime(nTime);
}
/* Sets the current calendar time from the given seconds time
* and resets the timer ticks.
*/
void SetTimeSec(time_t sTime)
{
calendar_time = sTime;
}
/* Returns the current time as a struct_tm
*/
void GetTime(struct_tm *pRetTm)
{
struct_tm *p;
clock();
p = localtime(&calendar_time);
memcpy(pRetTm, p, sizeof(struct_tm));
}
/* Initializes the timer
* The work is done by #use timer(), so just reset the ticks.
*/
void TimeInit(void)
{
INIT_RTC_TICKS();
clock_ticks = GET_RTC_TICKS();
calendar_time = 0;
}
#endif