source: rtems/c/src/lib/libbsp/arm/lpc24xx/rtc/rtc-config.c @ 0e27119

4.11
Last change on this file since 0e27119 was 0e27119, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 11, 2012 at 8:52:18 PM

Use proper 3 line form of license text

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