arch/arm/src/max326xx: Work-in-progress RTC driver for the MAX32660

This commit is contained in:
Gregory Nutt
2018-11-21 12:27:23 -06:00
parent 357deb41f4
commit 49ed9cac86
7 changed files with 1579 additions and 7 deletions
-5
View File
@@ -126,10 +126,6 @@ config MAX326XX_HAVE_WAKEUP
bool
default n
config MAX326XX_HAVE_RTC
bool
default n
config MAX326XX_HAVE_CRC
bool
default n
@@ -248,7 +244,6 @@ config MAX326XX_WAKEUP
config MAX326XX_RTC
bool "RTC"
default n
depends on MAX326XX_HAVE_RTC
config MAX326XX_CRC
bool "CRC 16/32"
+10
View File
@@ -86,6 +86,10 @@ ifeq ($(CONFIG_MAX326XX_ICC),y)
CHIP_CSRCS += max326_icc.c
endif
ifeq ($(CONFIG_RTC_DRIVER),y)
CHIP_CSRCS += max326_rtc_lowerhalf.c
endif
# Source Files for the MAX32620 and MAX32630
# Source Files for the MAX32660
@@ -122,6 +126,12 @@ CHIP_CSRCS += max32660_gpioirq.c
endif
endif
ifeq ($(CONFIG_MAX326XX_RTC),y)
ifeq ($(CONFIG_ARCH_FAMILY_MAX32660),y)
CHIP_CSRCS += max32660_rtc.c
endif
endif
ifeq ($(CONFIG_MAX32XX_WDT),y)
ifeq ($(CONFIG_ARCH_FAMILY_MAX32660),y)
CHIP_CSRCS += max32660_rtc.c
File diff suppressed because it is too large Load Diff
@@ -69,7 +69,7 @@
/* Register Bit-field Definitions ***************************************************/
/* Seconds Counter Register (32-bit seconds count) */
/* Seconds Counter Register (32-bit seconds counter) */
/* Sub-Seconds Counter Register */
#define RTC_SSEC_MASK (0xff) /* Bits 0-7: Sub-second counter */
@@ -221,7 +221,7 @@ static int max326_dmach_interrupt(int irq, FAR void *context, FAR void *arg)
****************************************************************************/
/****************************************************************************
* Name: stm32_dmainitialize
* Name: up_dma_initialize
*
* Description:
* Initialize the DMA subsystem
File diff suppressed because it is too large Load Diff
+168
View File
@@ -0,0 +1,168 @@
/****************************************************************************
* arch/arm/src/max326xx/max326_rtc.h
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> (On-going support and development)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __ARCH_ARM_SRC_MAX326XX_MAX326_RTC_H
#define __ARCH_ARM_SRC_MAX326XX_MAX326_RTC_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/* Type of callback invoked when an ALARM interrupt occurs */
typedef CODE void (*alm_callback_t)(FAR void *arg, unsigned int alarmid);
/* Structure used to pass parameters to query an alarm */
struct alm_rdalarm_s
{
FAR struct rtc_time *ar_time; /* Argument for storing ALARM RTC time */
};
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: max326_rtc_setalarm
*
* Description:
* Set an alarm to an absolute time using associated hardware.
*
* Input Parameters:
* ts - Alarm time
* cb - Callback invoked when alarm expires
* arg - Argument passed with the alarm
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
****************************************************************************/
#ifdef CONFIG_RTC_ALARM
int max326_rtc_setalarm(FAR struct timespec *ts, alm_callback_t cb,
FAR void *arg);
#endif
/****************************************************************************
* Name: max326_rtc_rdalarm
*
* Description:
* Query an alarm configured in hardware.
*
* Input Parameters:
* alminfo - Information about the alarm configuration.
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
****************************************************************************/
#ifdef CONFIG_RTC_ALARM
int max326_rtc_rdalarm(FAR struct alm_rdalarm_s *alminfo);
#endif
/****************************************************************************
* Name: max326_rtc_cancelalarm
*
* Description:
* Cancel a pending alarm alarm
*
* Input Parameters:
* none
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
****************************************************************************/
#ifdef CONFIG_RTC_ALARM
int max326_rtc_cancelalarm(void);
#endif
/****************************************************************************
* Name: max326_rtc_lowerhalf
*
* Description:
* Instantiate the RTC lower half driver for the MAX326XX. General usage:
*
* #include <nuttx/timers/rtc.h>
* #include "max326_rtc.h"
*
* struct rtc_lowerhalf_s *lower;
* lower = max326_rtc_lowerhalf();
* rtc_initialize(0, lower);
*
* Input Parameters:
* None
*
* Returned Value:
* On success, a non-NULL RTC lower interface is returned. NULL is
* returned on any failure.
*
****************************************************************************/
#ifdef CONFIG_RTC_DRIVER
struct rtc_lowerhalf_s;
FAR struct rtc_lowerhalf_s *max326_rtc_lowerhalf(void);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_MAX326XX_MAX326_RTC_H */