source: rtems/bsps/arm/lpc24xx/rtc/rtc-config.c @ ba619b7f

Last change on this file since ba619b7f was ba619b7f, checked in by Joel Sherrill <joel@…>, on 03/01/22 at 21:38:20

bsps/arm/: Scripted embedded brains header file clean up

Updates #4625.

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