source: network-demos/ntp/init.c @ 81f6c2e

4.11network-demos-4-10-branch
Last change on this file since 81f6c2e was 0417fe3, checked in by Joel Sherrill <joel.sherrill@…>, on 05/12/09 at 19:59:54

2009-05-12 Joel Sherrill <joel.sherrill@…>

  • init.c: Now build with libbsdport.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 * RTEMS configuration/initialization
3 *
4 * This program may be distributed and used for any purpose.
5 * I ask only that you:
6 *      1. Leave this author information intact.
7 *      2. Document any changes you make.
8 *
9 * W. Eric Norum
10 * Saskatchewan Accelerator Laboratory
11 * University of Saskatchewan
12 * Saskatoon, Saskatchewan, CANADA
13 * eric@skatter.usask.ca
14 *
15 *  $Id$
16 */
17
18#include <bsp.h>
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <rtems/rtems_bsdnet.h>
23#include <rtems/error.h>
24#include "../networkconfig.h"
25
26/*
27 * RTEMS Startup Task
28 */
29rtems_task
30Init (rtems_task_argument ignored)
31{
32        rtems_status_code sc;
33        rtems_time_of_day now;
34        rtems_interval ticksPerSecond;
35        int rtems_bsdnet_synchronize_ntp (int interval, rtems_task_priority priority);
36
37        printf ("****************** NTP TEST ***************\n");
38        rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
39        sc = rtems_clock_get (RTEMS_CLOCK_GET_TOD, &now);
40        if (sc == RTEMS_SUCCESSFUL)
41                printf ("Got time of day -- should have failed!\n");
42        else if (sc != RTEMS_NOT_DEFINED)
43                printf ("Failed to get time of day: %s\n", rtems_status_text (sc));
44        rtems_bsdnet_initialize_network ();
45        rtems_bsdnet_synchronize_ntp (0, 0);
46        sc = rtems_clock_get (RTEMS_CLOCK_GET_TOD, &now);
47        if (sc != RTEMS_SUCCESSFUL)
48                printf ("Failed to get time of day: %s\n", rtems_status_text (sc));
49        printf (
50          "The time is **** %.4ld-%.2ld-%.2ld %.2ld:%.2ld:%.2ld.%.3ld (%ld) ****\n",
51          (long) now.year,
52          (long) now.month,
53          (long) now.day,
54          (long) now.hour,
55          (long) now.minute,
56          (long) now.second,
57          (long) ((now.ticks * 1000) / ticksPerSecond),
58          (long) now.ticks);
59        exit (0);
60}
61
62#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
63#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
64#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
65#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
66#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
67
68#define CONFIGURE_EXECUTIVE_RAM_SIZE    (512*1024)
69#define CONFIGURE_MAXIMUM_SEMAPHORES    20
70#define CONFIGURE_MAXIMUM_TASKS         20
71
72#define CONFIGURE_MICROSECONDS_PER_TICK 10000
73
74#define CONFIGURE_INIT_TASK_STACK_SIZE  (10*1024)
75#define CONFIGURE_INIT_TASK_PRIORITY    120
76#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
77                                           RTEMS_NO_TIMESLICE | \
78                                           RTEMS_NO_ASR | \
79                                           RTEMS_INTERRUPT_LEVEL(0))
80
81#define CONFIGURE_INIT
82rtems_task Init (rtems_task_argument argument);
83
84#include <rtems/confdefs.h>
85
Note: See TracBrowser for help on using the repository browser.