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

4.115
Last change on this file since fe5d5048 was c468f18b, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 12/15/09 at 15:20:47

add support for LPC32xx

  • 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 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  /* Enable module power */
31  lpc24xx_module_enable(LPC24XX_MODULE_RTC, LPC24XX_MODULE_PCLK_DEFAULT);
32
33  /* Enable the RTC and use external clock */
34  RTC_CCR = RTC_CCR_CLKEN | RTC_CCR_CLKSRC;
35
36  /* Disable interrupts */
37  RTC_CIIR = 0;
38  RTC_CISS = 0;
39  RTC_AMR = 0xff;
40
41  /* Clear interrupts */
42  RTC_ILR = RTC_ILR_RTCCIF | RTC_ILR_RTCALF | RTC_ILR_RTSSF;
43}
44
45static int lpc24xx_rtc_get_time(int minor, rtems_time_of_day *tod)
46{
47  tod->ticks = 0;
48  tod->second = RTC_SEC;
49  tod->minute = RTC_MIN;
50  tod->hour = RTC_HOUR;
51  tod->day = RTC_DOM;
52  tod->month = RTC_MONTH;
53  tod->year = RTC_YEAR;
54
55  return 0;
56}
57
58static int lpc24xx_rtc_set_time(int minor, const rtems_time_of_day *tod)
59{
60  RTC_SEC = tod->second;
61  RTC_MIN = tod->minute;
62  RTC_HOUR = tod->hour;
63  RTC_DOM = tod->day;
64  RTC_MONTH = tod->month;
65  RTC_YEAR = tod->year;
66
67  return 0;
68}
69
70static bool lpc24xx_rtc_probe(int minor)
71{
72  return true;
73}
74
75const rtc_fns lpc24xx_rtc_ops = {
76  .deviceInitialize = lpc24xx_rtc_initialize,
77  .deviceGetTime = lpc24xx_rtc_get_time,
78  .deviceSetTime = lpc24xx_rtc_set_time
79};
80
81unsigned long RTC_Count = LPC24XX_RTC_NUMBER;
82
83rtems_device_minor_number RTC_Minor = 0;
84
85rtc_tbl RTC_Table [LPC24XX_RTC_NUMBER] = {
86  {
87    .sDeviceName = "/dev/rtc",
88    .deviceType = RTC_CUSTOM,
89    .pDeviceFns = &lpc24xx_rtc_ops,
90    .deviceProbe = lpc24xx_rtc_probe,
91    .pDeviceParams = NULL,
92    .ulCtrlPort1 = 0,
93    .ulDataPort = 0,
94    .getRegister = NULL,
95    .setRegister = NULL
96  }
97};
Note: See TracBrowser for help on using the repository browser.