Browse Source

removed static allocated timers

rtos
Olaf Rempel 12 years ago
parent
commit
23be9b58b9
6 changed files with 17 additions and 28 deletions
  1. +0
    -1
      include/at91_pitc.h
  2. +8
    -4
      main.c
  3. +6
    -12
      src/at91_adc.c
  4. +0
    -11
      src/at91_pitc.c
  5. +2
    -0
      src/memalloc.c
  6. +1
    -0
      src/telemetrie.c

+ 0
- 1
include/at91_pitc.h View File

@@ -17,7 +17,6 @@ struct pitc_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);
void at91_pitc_init(void);


+ 8
- 4
main.c View File

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

+ 6
- 12
src/at91_adc.c View File

@@ -44,6 +44,11 @@ static uint32_t adc_trigger(struct pitc_timer *timer)
return PITC_RESTART_TIMER;
}

static struct pitc_timer adc_timer = {
.interval = 100,
.func = &adc_trigger,
};

void at91_adc_test_init(void)
{
/* 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_IECR = (1<<AT91C_ID_ADC);

/* schedule trigger */
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");
pitc_schedule_timer(&adc_timer);
}

+ 0
- 11
src/at91_pitc.c View File

@@ -20,7 +20,6 @@
#include "at91_pitc.h"
#include "at91_sysc.h"
#include "board.h"
#include "memalloc.h"

/* PIV is 20bit -> min. 3Hz @48MHz MCK */
#define HZ_TO_PIV(HZ) (MCK / (16 * HZ))
@@ -28,16 +27,6 @@
static LIST_HEAD(timer_list);
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)
{
timer->nextrun = timer->interval + pitc_ticks;


+ 2
- 0
src/memalloc.c View File

@@ -88,6 +88,8 @@ static struct memchunk * alloc_add(uint32_t size)
{
size = ALIGN(size);

printf("alloc_add(%ld)\n\r", size);

/* struct at begin of memory block */
struct memchunk *newblock = static_alloc(size);



+ 1
- 0
src/telemetrie.c View File

@@ -32,6 +32,7 @@ extern struct tdc_value _tdc_value_table_end;
/* max. 8x 32 = 256 variables */
static uint32_t tdc_varmap[8];

/* array of devices, that are used to reach address X */
static struct comm_device *routing_table[8];

/*


Loading…
Cancel
Save