cd001725b7
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
78 lines
2.4 KiB
C
78 lines
2.4 KiB
C
/****************************************************************************
|
|
* boards/arm/kinetis/freedom-k66f/src/k66_rtc.c
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership. The
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance with the
|
|
* License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
* License for the specific language governing permissions and limitations
|
|
* under the License.
|
|
*
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Included Files
|
|
****************************************************************************/
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <syslog.h>
|
|
#include <errno.h>
|
|
#include <debug.h>
|
|
#include <nuttx/timers/rtc.h>
|
|
|
|
#include "freedom-k66f.h"
|
|
#include "kinetis_alarm.h"
|
|
|
|
/****************************************************************************
|
|
* Public Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Name: k66_rtc_initialize
|
|
*
|
|
* Description:
|
|
* Called to initialize the RTC FREEDOM-K66F board.
|
|
*
|
|
****************************************************************************/
|
|
|
|
int k66_rtc_initialize(void)
|
|
{
|
|
int ret = -EIO;
|
|
struct rtc_lowerhalf_s *lower;
|
|
|
|
/* Instantiate the KINETIS lower-half RTC driver */
|
|
|
|
lower = kinetis_rtc_lowerhalf();
|
|
if (!lower)
|
|
{
|
|
syslog(LOG_ERR,
|
|
"ERROR: Failed to instantiate the RTC lower-half driver\n");
|
|
}
|
|
else
|
|
{
|
|
/* Bind the lower half driver and register the combined RTC driver
|
|
* as /dev/rtc0
|
|
*/
|
|
|
|
ret = rtc_initialize(0, lower);
|
|
|
|
if (ret < 0)
|
|
{
|
|
syslog(LOG_ERR,
|
|
"ERROR: Failed to bind/register the RTC driver: %d\n",
|
|
ret);
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|