Merged in juniskane/nuttx_stm32l4/stm32_rtc_small_patches_pr (pull request #511)
Stm32 rtc small patches * RTC: canceling an alarm marks it as inactive * STM32L4, STM32F4, STM32F7 RTC: fix reading alarm value that is more than 24h in future * STM32F0 RTC: fix backup register count in stm32_rtcc.h All other STM32: SHIFTR_SUBFS_MASK was correct in STM32F0 only * STM32L1: use correct EXTI line definitions Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
parent
3750da237c
commit
d101fad026
@ -153,4 +153,4 @@ UNUSED(KINETIS_IRQ_RESVD92) /* Vector 108: Reserved */
|
|||||||
UNUSED(KINETIS_IRQ_RESVD93) /* Vector 109: Reserved */
|
UNUSED(KINETIS_IRQ_RESVD93) /* Vector 109: Reserved */
|
||||||
VECTOR(kinetis_swi, KINETIS_IRQ_SWI) /* Vector 110: Software interrupt */
|
VECTOR(kinetis_swi, KINETIS_IRQ_SWI) /* Vector 110: Software interrupt */
|
||||||
# endif /* CONFIG_ARMV7M_CMNVECTOR */
|
# endif /* CONFIG_ARMV7M_CMNVECTOR */
|
||||||
#endif /* CONFIG_STM32_CONNECTIVITYLINE */
|
#endif /* CONFIG_ARCH_FAMILY_K20 */
|
||||||
|
@ -55,6 +55,14 @@
|
|||||||
# define STM32_NEXTI 19
|
# define STM32_NEXTI 19
|
||||||
# define STM32_EXTI_MASK 0x0007ffff
|
# define STM32_EXTI_MASK 0x0007ffff
|
||||||
# endif
|
# endif
|
||||||
|
#elif defined(CONFIG_STM32_STM32L15XX)
|
||||||
|
# if defined(CONFIG_STM32_LOWDENSITY) || defined(CONFIG_STM32_MEDIUMDENSITY)
|
||||||
|
# define STM32_NEXTI 23
|
||||||
|
# define STM32_EXTI_MASK 0x007fffff
|
||||||
|
# else
|
||||||
|
# define STM32_NEXTI 24
|
||||||
|
# define STM32_EXTI_MASK 0x00ffffff
|
||||||
|
# endif
|
||||||
#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
|
#elif defined(CONFIG_STM32_STM32F30XX) || defined(CONFIG_STM32_STM32F33XX)
|
||||||
# define STM32_NEXTI1 31
|
# define STM32_NEXTI1 31
|
||||||
# define STM32_EXTI1_MASK 0xffffffff
|
# define STM32_EXTI1_MASK 0xffffffff
|
||||||
@ -121,7 +129,7 @@
|
|||||||
|
|
||||||
/* EXTI lines > 15 are associated with internal devices: */
|
/* EXTI lines > 15 are associated with internal devices: */
|
||||||
|
|
||||||
#if defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32L15XX)
|
#if defined(CONFIG_STM32_STM32F10XX)
|
||||||
# define EXTI_PVD_LINE (1 << 16) /* EXTI line 16 is connected to the PVD output */
|
# define EXTI_PVD_LINE (1 << 16) /* EXTI line 16 is connected to the PVD output */
|
||||||
# define EXTI_RTC_ALARM (1 << 17) /* EXTI line 17 is connected to the RTC Alarm event */
|
# define EXTI_RTC_ALARM (1 << 17) /* EXTI line 17 is connected to the RTC Alarm event */
|
||||||
# define EXTI_USB_WAKEUP (1 << 18) /* EXTI line 18 is connected to the USB Wakeup event */
|
# define EXTI_USB_WAKEUP (1 << 18) /* EXTI line 18 is connected to the USB Wakeup event */
|
||||||
@ -134,8 +142,8 @@
|
|||||||
# define EXTI_USB_WAKEUP (1 << 18) /* EXTI line 18 is connected to the USB Device FS Wakeup event */
|
# define EXTI_USB_WAKEUP (1 << 18) /* EXTI line 18 is connected to the USB Device FS Wakeup event */
|
||||||
# define EXTI_RTC_TAMPER (1 << 19) /* EXTI line 19 is connected to the RTC Tamper and TimeStamp events */
|
# define EXTI_RTC_TAMPER (1 << 19) /* EXTI line 19 is connected to the RTC Tamper and TimeStamp events */
|
||||||
# define EXTI_RTC_WAKEUP (1 << 20) /* EXTI line 20 is connected to the RTC Wakeup event */
|
# define EXTI_RTC_WAKEUP (1 << 20) /* EXTI line 20 is connected to the RTC Wakeup event */
|
||||||
# define EXTI_RTC_CMP1 (1 << 21) /* EXTI line 21 is connected to the Comparator 1 wakeup event */
|
# define EXTI_COMP1 (1 << 21) /* EXTI line 21 is connected to the Comparator 1 wakeup event */
|
||||||
# define EXTI_RTC_CMP2 (1 << 22) /* EXTI line 22 is connected to the Comparator 2 wakeup event */
|
# define EXTI_COMP2 (1 << 22) /* EXTI line 22 is connected to the Comparator 2 wakeup event */
|
||||||
# define EXTI_RTC_ACQUIRE (1 << 23) /* EXTI line 23 is connected to the channel acquisition interrupt */
|
# define EXTI_RTC_ACQUIRE (1 << 23) /* EXTI line 23 is connected to the channel acquisition interrupt */
|
||||||
#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX)
|
#elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX)
|
||||||
# define EXTI_PVD_LINE (1 << 16) /* EXTI line 16 is connected to the PVD output */
|
# define EXTI_PVD_LINE (1 << 16) /* EXTI line 16 is connected to the PVD output */
|
||||||
|
@ -330,7 +330,7 @@
|
|||||||
/* RTC shift control register */
|
/* RTC shift control register */
|
||||||
|
|
||||||
#define RTC_SHIFTR_SUBFS_SHIFT (0) /* Bits 0-14: Subtract a fraction of a second */
|
#define RTC_SHIFTR_SUBFS_SHIFT (0) /* Bits 0-14: Subtract a fraction of a second */
|
||||||
#define RTC_SHIFTR_SUBFS_MASK (0x7ffff << RTC_SHIFTR_SUBFS_SHIFT)
|
#define RTC_SHIFTR_SUBFS_MASK (0x7fff << RTC_SHIFTR_SUBFS_SHIFT)
|
||||||
#define RTC_SHIFTR_ADD1S (1 << 31) /* Bit 31: Add one second */
|
#define RTC_SHIFTR_ADD1S (1 << 31) /* Bit 31: Add one second */
|
||||||
|
|
||||||
/* RTC time stamp time register */
|
/* RTC time stamp time register */
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* arch/arm/src/stm32/chip/stm32f30xx_rcc.h
|
* arch/arm/src/stm32/chip/stm32f30xx_rcc.h
|
||||||
* For STM32L100xx, STM32L151xx, STM32L152xx and STM32L162xx advanced ARM-based
|
|
||||||
* 32-bit MCUs
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
@ -63,7 +63,7 @@ enum alm_id_e
|
|||||||
RTC_ALARM_LAST
|
RTC_ALARM_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Structure used to pass parmaters to set an alarm */
|
/* Structure used to pass parameters to set an alarm */
|
||||||
|
|
||||||
struct alm_setalarm_s
|
struct alm_setalarm_s
|
||||||
{
|
{
|
||||||
@ -89,7 +89,7 @@ struct alm_rdalarm_s
|
|||||||
* Name: stm32_rtc_setalarm
|
* Name: stm32_rtc_setalarm
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Set an alarm to an asbolute time using associated hardware.
|
* Set an alarm to an absolute time using associated hardware.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* alminfo - Information about the alarm configuration.
|
* alminfo - Information about the alarm configuration.
|
||||||
@ -121,7 +121,7 @@ int stm32_rtc_rdalarm(FAR struct alm_rdalarm_s *alminfo);
|
|||||||
* Name: stm32_rtc_cancelalarm
|
* Name: stm32_rtc_cancelalarm
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Cancel an alaram.
|
* Cancel an alarm.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* alarmid - Identifies the alarm to be cancelled
|
* alarmid - Identifies the alarm to be cancelled
|
||||||
|
@ -712,7 +712,7 @@ static int rtchw_check_alrbwf(void)
|
|||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
int ret = -ETIMEDOUT;
|
int ret = -ETIMEDOUT;
|
||||||
|
|
||||||
/* Check RTC_ISR ALRAWF for access to alarm register,
|
/* Check RTC_ISR ALRBWF for access to alarm register,
|
||||||
* can take 2 RTCCLK cycles or timeout
|
* can take 2 RTCCLK cycles or timeout
|
||||||
* CubeMX use GetTick.
|
* CubeMX use GetTick.
|
||||||
*/
|
*/
|
||||||
@ -885,8 +885,7 @@ static int stm32_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp)
|
|||||||
data = getreg32(reg);
|
data = getreg32(reg);
|
||||||
|
|
||||||
/* Convert the RTC time to fields in struct tm format. All of the STM32
|
/* Convert the RTC time to fields in struct tm format. All of the STM32
|
||||||
* All of the ranges of values correspond between struct tm and the time
|
* ranges of values correspond between struct tm and the time register.
|
||||||
* register.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tmp = (data & (RTC_ALRMR_SU_MASK | RTC_ALRMR_ST_MASK)) >> RTC_ALRMR_SU_SHIFT;
|
tmp = (data & (RTC_ALRMR_SU_MASK | RTC_ALRMR_ST_MASK)) >> RTC_ALRMR_SU_SHIFT;
|
||||||
@ -898,6 +897,9 @@ static int stm32_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp)
|
|||||||
tmp = (data & (RTC_ALRMR_HU_MASK | RTC_ALRMR_HT_MASK)) >> RTC_ALRMR_HU_SHIFT;
|
tmp = (data & (RTC_ALRMR_HU_MASK | RTC_ALRMR_HT_MASK)) >> RTC_ALRMR_HU_SHIFT;
|
||||||
tp->tm_hour = rtc_bcd2bin(tmp);
|
tp->tm_hour = rtc_bcd2bin(tmp);
|
||||||
|
|
||||||
|
tmp = (data & (RTC_ALRMR_DU_MASK | RTC_ALRMR_DT_MASK)) >> RTC_ALRMR_DU_SHIFT;
|
||||||
|
tp->tm_mday = rtc_bcd2bin(tmp);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1416,7 +1418,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
|
|||||||
* Name: stm32_rtc_setalarm
|
* Name: stm32_rtc_setalarm
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Set an alarm to an asbolute time using associated hardware.
|
* Set an alarm to an absolute time using associated hardware.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* alminfo - Information about the alarm configuration.
|
* alminfo - Information about the alarm configuration.
|
||||||
@ -1507,7 +1509,7 @@ int stm32_rtc_setalarm(FAR struct alm_setalarm_s *alminfo)
|
|||||||
* Name: stm32_rtc_cancelalarm
|
* Name: stm32_rtc_cancelalarm
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Cancel an alaram.
|
* Cancel an alarm.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* alarmid - Identifies the alarm to be cancelled
|
* alarmid - Identifies the alarm to be cancelled
|
||||||
|
@ -93,13 +93,7 @@
|
|||||||
#define STM32F0_RTC_BK3R (STM32F0_RTC_BASE+STM32F0_RTC_BK3R_OFFSET)
|
#define STM32F0_RTC_BK3R (STM32F0_RTC_BASE+STM32F0_RTC_BK3R_OFFSET)
|
||||||
#define STM32F0_RTC_BK4R (STM32F0_RTC_BASE+STM32F0_RTC_BK4R_OFFSET)
|
#define STM32F0_RTC_BK4R (STM32F0_RTC_BASE+STM32F0_RTC_BK4R_OFFSET)
|
||||||
|
|
||||||
#ifdef CONFIG_STM32F0_STM32F30XX
|
#define STM32F0_RTC_BKCOUNT 5
|
||||||
# define STM32F0_RTC_BKCOUNT 16
|
|
||||||
#elif defined(CONFIG_STM32F0_STM32L15XX)
|
|
||||||
# define STM32F0_RTC_BKCOUNT 32
|
|
||||||
#else
|
|
||||||
# define STM32F0_RTC_BKCOUNT 20
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Register Bitfield Definitions ****************************************************/
|
/* Register Bitfield Definitions ****************************************************/
|
||||||
|
|
||||||
@ -167,7 +161,7 @@
|
|||||||
#define RTC_CR_ADD1H (1 << 16) /* Bit 16: Add 1 hour (summer time change) */
|
#define RTC_CR_ADD1H (1 << 16) /* Bit 16: Add 1 hour (summer time change) */
|
||||||
#define RTC_CR_SUB1H (1 << 17) /* Bit 17: Subtract 1 hour (winter time change) */
|
#define RTC_CR_SUB1H (1 << 17) /* Bit 17: Subtract 1 hour (winter time change) */
|
||||||
#define RTC_CR_BKP (1 << 18) /* Bit 18: Backup */
|
#define RTC_CR_BKP (1 << 18) /* Bit 18: Backup */
|
||||||
#define RTC_CR_COSEL (1 << 19) /* Bit 19 : Calibration output selection */
|
#define RTC_CR_COSEL (1 << 19) /* Bit 19: Calibration output selection */
|
||||||
#define RTC_CR_POL (1 << 20) /* Bit 20: Output polarity */
|
#define RTC_CR_POL (1 << 20) /* Bit 20: Output polarity */
|
||||||
#define RTC_CR_OSEL_SHIFT (21) /* Bits 21-22: Output selection */
|
#define RTC_CR_OSEL_SHIFT (21) /* Bits 21-22: Output selection */
|
||||||
#define RTC_CR_OSEL_MASK (3 << RTC_CR_OSEL_SHIFT)
|
#define RTC_CR_OSEL_MASK (3 << RTC_CR_OSEL_SHIFT)
|
||||||
@ -193,7 +187,7 @@
|
|||||||
#define RTC_ISR_TAMP1F (1 << 13) /* Bit 13: Tamper detection flag */
|
#define RTC_ISR_TAMP1F (1 << 13) /* Bit 13: Tamper detection flag */
|
||||||
#define RTC_ISR_TAMP2F (1 << 14) /* Bit 14: TAMPER2 detection flag */
|
#define RTC_ISR_TAMP2F (1 << 14) /* Bit 14: TAMPER2 detection flag */
|
||||||
#define RTC_ISR_TAMP3F (1 << 15) /* Bit 15: TAMPER3 detection flag */
|
#define RTC_ISR_TAMP3F (1 << 15) /* Bit 15: TAMPER3 detection flag */
|
||||||
#define RTC_ISR_RECALPF (1 << 16) /* Bit 16: Recalibration pending Flag */
|
#define RTC_ISR_RECALPF (1 << 16) /* Bit 16: Recalibration pending flag */
|
||||||
#define RTC_ISR_ALLFLAGS (0x00017fff)
|
#define RTC_ISR_ALLFLAGS (0x00017fff)
|
||||||
|
|
||||||
/* RTC prescaler register */
|
/* RTC prescaler register */
|
||||||
@ -265,11 +259,11 @@
|
|||||||
/* RTC time stamp date register */
|
/* RTC time stamp date register */
|
||||||
|
|
||||||
#define RTC_TSDR_DU_SHIFT (0) /* Bit 0-3: Date units in BCD format */
|
#define RTC_TSDR_DU_SHIFT (0) /* Bit 0-3: Date units in BCD format */
|
||||||
#define RTC_TSDR_DU_MASK (15 << RTC_TSDR_DU_SHIFT) /* */
|
#define RTC_TSDR_DU_MASK (15 << RTC_TSDR_DU_SHIFT)
|
||||||
#define RTC_TSDR_DT_SHIFT (4) /* Bits 4-5: Date tens in BCD format */
|
#define RTC_TSDR_DT_SHIFT (4) /* Bits 4-5: Date tens in BCD format */
|
||||||
#define RTC_TSDR_DT_MASK (3 << RTC_TSDR_DT_SHIFT)
|
#define RTC_TSDR_DT_MASK (3 << RTC_TSDR_DT_SHIFT)
|
||||||
#define RTC_TSDR_MU_SHIFT (8) /* Bits 8-11: Month units in BCD format */
|
#define RTC_TSDR_MU_SHIFT (8) /* Bits 8-11: Month units in BCD format */
|
||||||
#define RTC_TSDR_MU_MASK (xx << RTC_TSDR_MU_SHIFT)
|
#define RTC_TSDR_MU_MASK (15 << RTC_TSDR_MU_SHIFT)
|
||||||
#define RTC_TSDR_MT (1 << 12) /* Bit 12: Month tens in BCD format */
|
#define RTC_TSDR_MT (1 << 12) /* Bit 12: Month tens in BCD format */
|
||||||
#define RTC_TSDR_WDU_SHIFT (13) /* Bits 13-15: Week day units */
|
#define RTC_TSDR_WDU_SHIFT (13) /* Bits 13-15: Week day units */
|
||||||
#define RTC_TSDR_WDU_MASK (7 << RTC_TSDR_WDU_SHIFT)
|
#define RTC_TSDR_WDU_MASK (7 << RTC_TSDR_WDU_SHIFT)
|
||||||
|
@ -302,7 +302,7 @@
|
|||||||
/* RTC shift control register */
|
/* RTC shift control register */
|
||||||
|
|
||||||
#define RTC_SHIFTR_SUBFS_SHIFT (0) /* Bits 0-14: Subtract a fraction of a second */
|
#define RTC_SHIFTR_SUBFS_SHIFT (0) /* Bits 0-14: Subtract a fraction of a second */
|
||||||
#define RTC_SHIFTR_SUBFS_MASK (0x7ffff << RTC_SHIFTR_SUBFS_SHIFT)
|
#define RTC_SHIFTR_SUBFS_MASK (0x7fff << RTC_SHIFTR_SUBFS_SHIFT)
|
||||||
#define RTC_SHIFTR_ADD1S (1 << 31) /* Bit 31: Add one second */
|
#define RTC_SHIFTR_ADD1S (1 << 31) /* Bit 31: Add one second */
|
||||||
|
|
||||||
/* RTC time stamp time register */
|
/* RTC time stamp time register */
|
||||||
|
@ -709,7 +709,7 @@ static int rtchw_check_alrbwf(void)
|
|||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
int ret = -ETIMEDOUT;
|
int ret = -ETIMEDOUT;
|
||||||
|
|
||||||
/* Check RTC_ISR ALRAWF for access to alarm register,
|
/* Check RTC_ISR ALRBWF for access to alarm register,
|
||||||
* can take 2 RTCCLK cycles or timeout
|
* can take 2 RTCCLK cycles or timeout
|
||||||
* CubeMX use GetTick.
|
* CubeMX use GetTick.
|
||||||
*/
|
*/
|
||||||
@ -844,8 +844,7 @@ static int stm32_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp)
|
|||||||
data = getreg32(reg);
|
data = getreg32(reg);
|
||||||
|
|
||||||
/* Convert the RTC time to fields in struct tm format. All of the STM32
|
/* Convert the RTC time to fields in struct tm format. All of the STM32
|
||||||
* All of the ranges of values correspond between struct tm and the time
|
* ranges of values correspond between struct tm and the time register.
|
||||||
* register.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tmp = (data & (RTC_ALRMR_SU_MASK | RTC_ALRMR_ST_MASK)) >> RTC_ALRMR_SU_SHIFT;
|
tmp = (data & (RTC_ALRMR_SU_MASK | RTC_ALRMR_ST_MASK)) >> RTC_ALRMR_SU_SHIFT;
|
||||||
@ -857,6 +856,9 @@ static int stm32_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp)
|
|||||||
tmp = (data & (RTC_ALRMR_HU_MASK | RTC_ALRMR_HT_MASK)) >> RTC_ALRMR_HU_SHIFT;
|
tmp = (data & (RTC_ALRMR_HU_MASK | RTC_ALRMR_HT_MASK)) >> RTC_ALRMR_HU_SHIFT;
|
||||||
tp->tm_hour = rtc_bcd2bin(tmp);
|
tp->tm_hour = rtc_bcd2bin(tmp);
|
||||||
|
|
||||||
|
tmp = (data & (RTC_ALRMR_DU_MASK | RTC_ALRMR_DT_MASK)) >> RTC_ALRMR_DU_SHIFT;
|
||||||
|
tp->tm_mday = rtc_bcd2bin(tmp);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -303,7 +303,7 @@
|
|||||||
/* RTC shift control register */
|
/* RTC shift control register */
|
||||||
|
|
||||||
#define RTC_SHIFTR_SUBFS_SHIFT (0) /* Bits 0-14: Subtract a fraction of a second */
|
#define RTC_SHIFTR_SUBFS_SHIFT (0) /* Bits 0-14: Subtract a fraction of a second */
|
||||||
#define RTC_SHIFTR_SUBFS_MASK (0x7ffff << RTC_SHIFTR_SUBFS_SHIFT)
|
#define RTC_SHIFTR_SUBFS_MASK (0x7fff << RTC_SHIFTR_SUBFS_SHIFT)
|
||||||
#define RTC_SHIFTR_ADD1S (1 << 31) /* Bit 31: Add one second */
|
#define RTC_SHIFTR_ADD1S (1 << 31) /* Bit 31: Add one second */
|
||||||
|
|
||||||
/* RTC time stamp time register */
|
/* RTC time stamp time register */
|
||||||
|
@ -634,7 +634,7 @@ static int rtchw_check_alrbwf(void)
|
|||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
int ret = -ETIMEDOUT;
|
int ret = -ETIMEDOUT;
|
||||||
|
|
||||||
/* Check RTC_ISR ALRAWF for access to alarm register,
|
/* Check RTC_ISR ALRBWF for access to alarm register,
|
||||||
* can take 2 RTCCLK cycles or timeout
|
* can take 2 RTCCLK cycles or timeout
|
||||||
* CubeMX use GetTick.
|
* CubeMX use GetTick.
|
||||||
*/
|
*/
|
||||||
@ -824,8 +824,7 @@ static int stm32l4_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp)
|
|||||||
data = getreg32(reg);
|
data = getreg32(reg);
|
||||||
|
|
||||||
/* Convert the RTC time to fields in struct tm format. All of the STM32
|
/* Convert the RTC time to fields in struct tm format. All of the STM32
|
||||||
* All of the ranges of values correspond between struct tm and the time
|
* ranges of values correspond between struct tm and the time register.
|
||||||
* register.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tmp = (data & (RTC_ALRMR_SU_MASK | RTC_ALRMR_ST_MASK)) >> RTC_ALRMR_SU_SHIFT;
|
tmp = (data & (RTC_ALRMR_SU_MASK | RTC_ALRMR_ST_MASK)) >> RTC_ALRMR_SU_SHIFT;
|
||||||
@ -837,6 +836,9 @@ static int stm32l4_rtc_getalarmdatetime(rtc_alarmreg_t reg, FAR struct tm *tp)
|
|||||||
tmp = (data & (RTC_ALRMR_HU_MASK | RTC_ALRMR_HT_MASK)) >> RTC_ALRMR_HU_SHIFT;
|
tmp = (data & (RTC_ALRMR_HU_MASK | RTC_ALRMR_HT_MASK)) >> RTC_ALRMR_HU_SHIFT;
|
||||||
tp->tm_hour = rtc_bcd2bin(tmp);
|
tp->tm_hour = rtc_bcd2bin(tmp);
|
||||||
|
|
||||||
|
tmp = (data & (RTC_ALRMR_DU_MASK | RTC_ALRMR_DT_MASK)) >> RTC_ALRMR_DU_SHIFT;
|
||||||
|
tp->tm_mday = rtc_bcd2bin(tmp);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -179,14 +179,14 @@ static void rtc_alarm_callback(FAR void *priv, int alarmid)
|
|||||||
DEBUGASSERT(upper != NULL && alarmid >= 0 && alarmid < CONFIG_RTC_NALARMS);
|
DEBUGASSERT(upper != NULL && alarmid >= 0 && alarmid < CONFIG_RTC_NALARMS);
|
||||||
alarminfo = &upper->alarminfo[alarmid];
|
alarminfo = &upper->alarminfo[alarmid];
|
||||||
|
|
||||||
/* Do we think that the alaram is active? It might be due to some
|
/* Do we think that the alarm is active? It might be due to some
|
||||||
* race condition between a cancellation event and the alarm
|
* race condition between a cancellation event and the alarm
|
||||||
* expiration.
|
* expiration.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (alarminfo->active)
|
if (alarminfo->active)
|
||||||
{
|
{
|
||||||
/* Yes.. signal the alarm expriration */
|
/* Yes.. signal the alarm expiration */
|
||||||
|
|
||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
(void)nxsig_queue(alarminfo->pid, alarminfo->signo,
|
(void)nxsig_queue(alarminfo->pid, alarminfo->signo,
|
||||||
@ -446,7 +446,6 @@ static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
* new relative alarm time to be set.
|
* new relative alarm time to be set.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
case RTC_SET_RELATIVE:
|
case RTC_SET_RELATIVE:
|
||||||
{
|
{
|
||||||
FAR const struct rtc_setrelative_s *alarminfo =
|
FAR const struct rtc_setrelative_s *alarminfo =
|
||||||
@ -513,7 +512,7 @@ static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* RTC_WKALRM_CANCEL cancel the alarm.
|
/* RTC_CANCEL_ALARM cancel the alarm.
|
||||||
*
|
*
|
||||||
* Argument: An ALARM ID value that indicates which alarm should be
|
* Argument: An ALARM ID value that indicates which alarm should be
|
||||||
* canceled.
|
* canceled.
|
||||||
@ -521,12 +520,20 @@ static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
case RTC_CANCEL_ALARM:
|
case RTC_CANCEL_ALARM:
|
||||||
{
|
{
|
||||||
|
FAR struct rtc_alarminfo_s *upperinfo;
|
||||||
int alarmid = (int)arg;
|
int alarmid = (int)arg;
|
||||||
|
|
||||||
DEBUGASSERT(alarmid >= 0 && alarmid < CONFIG_RTC_NALARMS);
|
DEBUGASSERT(alarmid >= 0 && alarmid < CONFIG_RTC_NALARMS);
|
||||||
|
|
||||||
|
upperinfo = &upper->alarminfo[alarmid];
|
||||||
|
|
||||||
if (ops->cancelalarm)
|
if (ops->cancelalarm)
|
||||||
{
|
{
|
||||||
ret = ops->cancelalarm(upper->lower, alarmid);
|
ret = ops->cancelalarm(upper->lower, alarmid);
|
||||||
|
if (ret == OK)
|
||||||
|
{
|
||||||
|
upperinfo->active = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user