removed static allocated timers

This commit is contained in:
Olaf Rempel 2008-02-06 17:56:27 +01:00
parent bd2c9b8f68
commit 23be9b58b9
6 changed files with 17 additions and 28 deletions

View File

@ -17,7 +17,6 @@ struct pitc_timer {
}; };
void pitc_schedule_timer(struct pitc_timer *timer); void pitc_schedule_timer(struct pitc_timer *timer);
struct pitc_timer * alloc_pitc_timer(uint32_t interval, uint32_t (*func)(struct pitc_timer *), void *privdata);
uint32_t pitc_get_ticks(void); uint32_t pitc_get_ticks(void);
void at91_pitc_init(void); void at91_pitc_init(void);

12
main.c
View File

@ -51,6 +51,11 @@ static uint32_t pitc_test(struct pitc_timer *timer)
return PITC_RESTART_TIMER; return PITC_RESTART_TIMER;
} }
static struct pitc_timer pitc_test_timer = {
.interval = 1,
.func = &pitc_test,
};
int main(void) int main(void)
{ {
/* LED outputs */ /* LED outputs */
@ -78,14 +83,13 @@ int main(void)
at91_twi_init(); at91_twi_init();
/* usb */ /* usb */
at91_udp_init(); // at91_udp_init();
struct pitc_timer *pitc_test_timer = alloc_pitc_timer(1, &pitc_test, NULL);
pitc_schedule_timer(pitc_test_timer);
printf("static alloc: %5ld bytes\n\r", static_alloc_used()); printf("static alloc: %5ld bytes\n\r", static_alloc_used());
at91_twi_test(); at91_twi_test();
pitc_schedule_timer(&pitc_test_timer);
while (1); while (1);
} }

View File

@ -44,6 +44,11 @@ static uint32_t adc_trigger(struct pitc_timer *timer)
return PITC_RESTART_TIMER; return PITC_RESTART_TIMER;
} }
static struct pitc_timer adc_timer = {
.interval = 100,
.func = &adc_trigger,
};
void at91_adc_test_init(void) void at91_adc_test_init(void)
{ {
/* enable ADC clock */ /* enable ADC clock */
@ -83,16 +88,5 @@ void at91_adc_test_init(void)
aic->AIC_SVR[AT91C_ID_ADC] = (uint32_t)at91_adc_isr; aic->AIC_SVR[AT91C_ID_ADC] = (uint32_t)at91_adc_isr;
aic->AIC_IECR = (1<<AT91C_ID_ADC); aic->AIC_IECR = (1<<AT91C_ID_ADC);
/* schedule trigger */ pitc_schedule_timer(&adc_timer);
struct pitc_timer *adc_timer = alloc_pitc_timer(100, &adc_trigger, NULL);
pitc_schedule_timer(adc_timer);
}
void at91_adc_printresults(void)
{
uint8_t i;
for (i = 0; i < ARRAY_SIZE(adc_result); i++)
printf("%x:0x%03X ", i, adc_result[i]);
printf("\n");
} }

View File

@ -20,7 +20,6 @@
#include "at91_pitc.h" #include "at91_pitc.h"
#include "at91_sysc.h" #include "at91_sysc.h"
#include "board.h" #include "board.h"
#include "memalloc.h"
/* PIV is 20bit -> min. 3Hz @48MHz MCK */ /* PIV is 20bit -> min. 3Hz @48MHz MCK */
#define HZ_TO_PIV(HZ) (MCK / (16 * HZ)) #define HZ_TO_PIV(HZ) (MCK / (16 * HZ))
@ -28,16 +27,6 @@
static LIST_HEAD(timer_list); static LIST_HEAD(timer_list);
volatile static uint32_t pitc_ticks; volatile static uint32_t pitc_ticks;
struct pitc_timer * alloc_pitc_timer(uint32_t interval, uint32_t (*func)(struct pitc_timer *), void *privdata)
{
struct pitc_timer *timer = static_alloc(sizeof(struct pitc_timer));
timer->interval = interval;
timer->func = func;
timer->privdata = privdata;
return timer;
}
void pitc_schedule_timer(struct pitc_timer *timer) void pitc_schedule_timer(struct pitc_timer *timer)
{ {
timer->nextrun = timer->interval + pitc_ticks; timer->nextrun = timer->interval + pitc_ticks;

View File

@ -88,6 +88,8 @@ static struct memchunk * alloc_add(uint32_t size)
{ {
size = ALIGN(size); size = ALIGN(size);
printf("alloc_add(%ld)\n\r", size);
/* struct at begin of memory block */ /* struct at begin of memory block */
struct memchunk *newblock = static_alloc(size); struct memchunk *newblock = static_alloc(size);

View File

@ -32,6 +32,7 @@ extern struct tdc_value _tdc_value_table_end;
/* max. 8x 32 = 256 variables */ /* max. 8x 32 = 256 variables */
static uint32_t tdc_varmap[8]; static uint32_t tdc_varmap[8];
/* array of devices, that are used to reach address X */
static struct comm_device *routing_table[8]; static struct comm_device *routing_table[8];
/* /*