source: rtems/c/src/lib/libbsp/arm/lpc24xx/rtc/rtc-config.c @ 7ae2775

4.104.115
Last change on this file since 7ae2775 was 7ae2775, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on Jul 17, 2009 at 1:53:04 PM

ARM bsp maintenance

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup lpc24xx
5 *
6 * @brief RTC configuration.
7 */
8
9/*
10 * Copyright (c) 2008
11 * Embedded Brains GmbH
12 * Obere Lagerstr. 30
13 * D-82178 Puchheim
14 * Germany
15 * rtems@embedded-brains.de
16 *
17 * The license and distribution terms for this file may be found in the file
18 * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
19 */
20
21#include <libchip/rtc.h>
22
23#include <bsp/lpc24xx.h>
24#include <bsp/io.h>
25
26#define LPC24XX_RTC_NUMBER 1
27
28static void lpc24xx_rtc_initialize( int minor)
29{
30  rtems_interrupt_level level;
31
32  /* Enable module power */
33  lpc24xx_module_enable( LPC24XX_MODULE_RTC, 0, LPC24XX_MODULE_PCLK_DEFAULT);
34
35  /* Enable the RTC and use external clock */
36  RTC_CCR = RTC_CCR_CLKEN | RTC_CCR_CLKSRC;
37
38  /* Disable interrupts */
39  RTC_CIIR = 0;
40  RTC_CISS = 0;
41  RTC_AMR = 0xff;
42
43  /* Clear interrupts */
44  RTC_ILR = RTC_ILR_RTCCIF | RTC_ILR_RTCALF | RTC_ILR_RTSSF;
45}
46
47static int lpc24xx_rtc_get_time( int minor, rtems_time_of_day *tod)
48{
49  tod->ticks = 0;
50  tod->second = RTC_SEC;
51  tod->minute = RTC_MIN;
52  tod->hour = RTC_HOUR;
53  tod->day = RTC_DOM;
54  tod->month = RTC_MONTH;
55  tod->year = RTC_YEAR;
56
57  return 0;
58}
59
60static int lpc24xx_rtc_set_time( int minor, const rtems_time_of_day *tod)
61{
62  RTC_SEC = tod->second;
63  RTC_MIN = tod->minute;
64  RTC_HOUR = tod->hour;
65  RTC_DOM = tod->day;
66  RTC_MONTH = tod->month;
67  RTC_YEAR = tod->year;
68
69  return 0;
70}
71
72static bool lpc24xx_rtc_probe( int minor)
73{
74  return true;
75}
76
77const rtc_fns lpc24xx_rtc_ops = {
78  .deviceInitialize = lpc24xx_rtc_initialize,
79  .deviceGetTime = lpc24xx_rtc_get_time,
80  .deviceSetTime = lpc24xx_rtc_set_time
81};
82
83unsigned long RTC_Count = LPC24XX_RTC_NUMBER;
84
85rtems_device_minor_number RTC_Minor = 0;
86
87rtc_tbl RTC_Table [LPC24XX_RTC_NUMBER] = {
88  {
89    .sDeviceName = "/dev/rtc",
90    .deviceType = RTC_CUSTOM,
91    .pDeviceFns = &lpc24xx_rtc_ops,
92    .deviceProbe = lpc24xx_rtc_probe,
93    .pDeviceParams = NULL,
94    .ulCtrlPort1 = 0,
95    .ulDataPort = 0,
96    .getRegister = NULL,
97    .setRegister = NULL
98  }
99};
Note: See TracBrowser for help on using the repository browser.