mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 07:12:54 +08:00
Add support for RTC driver to the STM32F4-Discovery board
This commit is contained in:
@@ -180,8 +180,8 @@ int stm32_rtc_cancelalarm(void);
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_RTC_DRIVER
|
||||
struct rtc_lower_half_s;
|
||||
FAR struct rtc_lower_half_s *stm32_rtc_lowerhalf(void);
|
||||
struct rtc_lowerhalf_s;
|
||||
FAR struct rtc_lowerhalf_s *stm32_rtc_lowerhalf(void);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
|
||||
@@ -273,9 +273,9 @@ static int stm32_settime(FAR struct rtc_lowerhalf_s *lower,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct rtc_lower_half_s *stm32_rtc_lowerhalf(void)
|
||||
FAR struct rtc_lowerhalf_s *stm32_rtc_lowerhalf(void)
|
||||
{
|
||||
return (FAR struct rtc_lower_half_s *)&g_rtc_lowerhalf;
|
||||
return (FAR struct rtc_lowerhalf_s *)&g_rtc_lowerhalf;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_RTC_DRIVER */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* config/stm32f4discovery/src/stm32_bringup.c
|
||||
*
|
||||
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012, 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -48,13 +48,24 @@
|
||||
# include <apps/usbmonitor.h>
|
||||
#endif
|
||||
|
||||
#include "stm32.h"
|
||||
|
||||
#ifdef CONFIG_STM32_OTGFS
|
||||
# include "stm32_usbhost.h"
|
||||
#endif
|
||||
|
||||
#include "stm32.h"
|
||||
#include "stm32f4discovery.h"
|
||||
|
||||
/* Conditional logic in stm32f4discover.h will determine if certain features
|
||||
* are supported. Tests for these features need to be made after including
|
||||
* stm32f4discovery.h.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_RTC_DRIVER
|
||||
# include <nuttx/rtc.h>
|
||||
# include "stm32_rtc.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
@@ -79,6 +90,9 @@
|
||||
|
||||
int stm32_bringup(void)
|
||||
{
|
||||
#ifdef HAVE_RTC_DRIVER
|
||||
FAR struct rtc_lowerhalf_s *lower;
|
||||
#endif
|
||||
int ret = OK;
|
||||
|
||||
#ifdef HAVE_SDIO
|
||||
@@ -87,7 +101,7 @@ int stm32_bringup(void)
|
||||
ret = stm32_sdio_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
fdbg("Failed to initialize MMC/SD driver: %d\n", ret);
|
||||
fdbg("ERROR: Failed to initialize MMC/SD driver: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
@@ -100,7 +114,7 @@ int stm32_bringup(void)
|
||||
ret = stm32_usbhost_initialize();
|
||||
if (ret != OK)
|
||||
{
|
||||
udbg("Failed to initialize USB host: %d\n", ret);
|
||||
udbg("ERROR: Failed to initialize USB host: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
@@ -111,7 +125,32 @@ int stm32_bringup(void)
|
||||
ret = usbmonitor_start(0, NULL);
|
||||
if (ret != OK)
|
||||
{
|
||||
udbg("Start USB monitor: %d\n", ret);
|
||||
udbg("ERROR: Failed to start USB monitor: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RTC_DRIVER
|
||||
/* Instantiate the STM32 lower-half RTC driver */
|
||||
|
||||
lower = stm32_rtc_lowerhalf();
|
||||
if (!lower)
|
||||
{
|
||||
sdbg("ERROR: Failed to instantiate the RTC lower-half driver\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Bind the lower half driver and register the combined RTC driver
|
||||
* as /dev/rtc0
|
||||
*/
|
||||
|
||||
ret = rtc_initialize(0, lower);
|
||||
if (ret < 0)
|
||||
{
|
||||
sdbg("ERROR: Failed to bind/register the RTC driver: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
#define HAVE_USBHOST 1
|
||||
#define HAVE_USBMONITOR 1
|
||||
#define HAVE_SDIO 1
|
||||
#define HAVE_RTC_DRIVER 1
|
||||
|
||||
/* Can't support USB host or device features if USB OTG FS is not enabled */
|
||||
|
||||
@@ -133,6 +134,12 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Check if we can support the RTC driver */
|
||||
|
||||
#if !defined(CONFIG_RTC) || !defined(CONFIG_RTC_DRIVER)
|
||||
# undef HAVE_RTC_DRIVER
|
||||
#endif
|
||||
|
||||
/* STM32F4 Discovery GPIOs **************************************************/
|
||||
/* LEDs */
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* With extensions, modifications by:
|
||||
*
|
||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011-2012, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregroy Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
Reference in New Issue
Block a user