summaryrefslogtreecommitdiff
path: root/cesar/maximus/stationtest/src/threaddelay.c
blob: f03a12f7adaa01e5bf1d98a476d1da12f0b76779 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    threaddelay.c
 * \brief   test program for eCos compilation
 * \ingroup
 *
 * this is a test program to check eCos well work with the tick timer
 */

#include <cyg/kernel/kapi.h>
#include <cyg/infra/diag.h>

#define MY_THREAD_STACK_SIZE (2048 / sizeof(int))

int my_thread_stack[MY_THREAD_STACK_SIZE];
cyg_handle_t my_thread_handle;
cyg_thread my_thread_obj;

void my_thread(cyg_addrword_t index)
{
    unsigned long my_counter = 0;
    diag_write_string("my thread started\n");
    while(1)
    {
        diag_printf("count=%ld, time=%lld\n",my_counter, cyg_current_time());
        cyg_thread_delay(1000); //wait 10 seconds (1000 ecos ticks)
        my_counter++;
    }
}

void cyg_user_start(void)
{

  cyg_thread_create(12, my_thread, (cyg_addrword_t) 0,
		    "My Thread", &my_thread_stack, MY_THREAD_STACK_SIZE,
		    &my_thread_handle, &my_thread_obj);

  cyg_thread_resume(my_thread_handle);

  diag_write_string("Starting Scheduler... ");
  
  cyg_scheduler_start();
}