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

5
Last change on this file since e610785 was 6b597c39, checked in by Joel Sherrill <joel@…>, on 03/27/16 at 23:37:48

libcpu/bfin/clock/clock.c: Fix warning by including <rtems/clockdrv.h>

  • 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 <rtems/score/percpu.h>
18#include <bsp.h>
19#include <rtems/clockdrv.h>
20
21
22#include <libcpu/cecRegs.h>
23#include <libcpu/coreTimerRegs.h>
24
25#if (BFIN_ON_SKYEYE)
26#define CLOCK_DRIVER_USE_FAST_IDLE 1
27#endif
28
29volatile uint32_t Clock_driver_ticks;
30
31void Clock_exit(void);
32
33static rtems_isr clockISR(rtems_vector_number vector) {
34
35  Clock_driver_ticks += 1;
36
37#if CLOCK_DRIVER_USE_FAST_IDLE
38  do {
39    rtems_clock_tick();
40  } while (
41    _Thread_Heir == _Thread_Executing
42      && _Thread_Executing->Start.Entry.Kinds.Idle.entry
43        == rtems_configuration_get_idle_task()
44  );
45#else
46  rtems_clock_tick();
47#endif
48}
49
50/*
51 *  Clock_exit
52 *
53 *  This routine allows the clock driver to exit by masking the interrupt and
54 *  disabling the clock's counter.
55 */
56void Clock_exit(void)
57{
58  *(uint32_t volatile *) TCNTL = 0;
59}
60
61/*
62 *  Clock_initialize
63 *
64 *  This routine initializes the clock driver.
65 */
66rtems_device_driver Clock_initialize(
67  rtems_device_major_number major,
68  rtems_device_minor_number minor,
69  void *pargp
70)
71{
72  Clock_driver_ticks = 0;
73
74  set_vector(clockISR, CEC_CORE_TIMER_VECTOR, 1);
75
76  *(uint32_t volatile *) TCNTL = TCNTL_TMPWR | TCNTL_TAUTORLD;
77  *(uint32_t volatile *) TSCALE = 0;
78  *(uint32_t volatile *) TPERIOD = CCLK / 1000000 *
79      rtems_configuration_get_microseconds_per_tick();
80  *(uint32_t volatile *) TCNTL = TCNTL_TMPWR | TCNTL_TAUTORLD | TCNTL_TMREN;
81
82  atexit(Clock_exit);
83
84  return RTEMS_SUCCESSFUL;
85}
Note: See TracBrowser for help on using the repository browser.