source: rtems/c/src/lib/libcpu/bfin/clock/clock.c @ e827199

4.115
Last change on this file since e827199 was e827199, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/14 at 20:38:01

libcpu/bfin/clock: Fix warnings

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*  RTEMS Clock Tick Driver for Blackfin.  Uses Blackfin Core Timer.
2 */
3
4/*
5 *  Copyright (c) 2008 Kallisti Labs, Los Gatos, CA, USA
6 *             written by Allan Hessenflow <allanh@kallisti.com>
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.org/license/LICENSE.
11 */
12
13
14#include <rtems.h>
15#include <stdlib.h>
16#include <rtems/libio.h>
17#include <bsp.h>
18
19#include <libcpu/cecRegs.h>
20#include <libcpu/coreTimerRegs.h>
21
22#if (BFIN_ON_SKYEYE)
23#define CLOCK_DRIVER_USE_FAST_IDLE 1
24#endif
25
26volatile uint32_t Clock_driver_ticks;
27
28void Clock_exit(void);
29
30static rtems_isr clockISR(rtems_vector_number vector) {
31
32  Clock_driver_ticks += 1;
33
34#if CLOCK_DRIVER_USE_FAST_IDLE
35  do {
36    rtems_clock_tick();
37  } while (
38    _Thread_Heir == _Thread_Executing
39      && _Thread_Executing->Start.entry_point
40        == rtems_configuration_get_idle_task()
41  );
42#else
43  rtems_clock_tick();
44#endif
45}
46
47/*
48 *  Clock_exit
49 *
50 *  This routine allows the clock driver to exit by masking the interrupt and
51 *  disabling the clock's counter.
52 */
53void Clock_exit(void)
54{
55  *(uint32_t volatile *) TCNTL = 0;
56}
57
58/*
59 *  Clock_initialize
60 *
61 *  This routine initializes the clock driver.
62 */
63rtems_device_driver Clock_initialize(
64  rtems_device_major_number major,
65  rtems_device_minor_number minor,
66  void *pargp
67)
68{
69  Clock_driver_ticks = 0;
70
71  set_vector(clockISR, CEC_CORE_TIMER_VECTOR, 1);
72
73  *(uint32_t volatile *) TCNTL = TCNTL_TMPWR | TCNTL_TAUTORLD;
74  *(uint32_t volatile *) TSCALE = 0;
75  *(uint32_t volatile *) TPERIOD = CCLK / 1000000 *
76      rtems_configuration_get_microseconds_per_tick();
77  *(uint32_t volatile *) TCNTL = TCNTL_TMPWR | TCNTL_TAUTORLD | TCNTL_TMREN;
78
79  atexit(Clock_exit);
80
81  return RTEMS_SUCCESSFUL;
82}
Note: See TracBrowser for help on using the repository browser.