STM32 F4 RTC driver is fully coded (but not tested)

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4176 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2011-12-14 19:12:00 +00:00
parent 8bf1779001
commit 9922992d84
11 changed files with 639 additions and 51 deletions
+32 -1
View File
@@ -1689,7 +1689,7 @@
<p>
<b>STATUS:</b>
This is really a vapor ware, pre-announcement.
I have the hardware and the motivation and I expect to announce the availability of support the STM32F4-Discovery with the NuttX 6.13 release.
I have the hardware and the motivation and I expect to announce the availability of support the STM32F4-Discovery in a later NuttX release.
</p>
</td>
</tr>
@@ -2728,8 +2728,39 @@ buildroot-1.10 2011-05-06 &lt;gnutt@nuttx.org&gt;
<ul><pre>
nuttx-6.13 2012-xx-xx Gregory Nutt &lt;gnutt@nuttx.org&gt;
* arch/arm/src/stm32/stm32f40xxx_dma.c: Add DMA support for the STM32 F4
family (untested on initial check-in)
* arch/arm/src/armv7-m/up_fpu.c: Add logic for saving an restoring VFP
floating point registers on context switches (but also disable the FPU
because CodeSourcery doesn't support hard flowing point!)
* arch/arm/src/stm32/chip/stm32_eth.h: Add Ethernet register definitions
for the STM32 F4.
* arch/arm/srcm/stm32/stm32_eth.c: Adds an Ethernet driver for the STM32 F4.
* arch/arm/srcm/stm32/stm32_dac.c and stm32_adc.c: &quot;Skeleton&quot; files for STM32
DAC and ADC drivers. The actual logic will come later.
* arch/arm/srcm/stm32/stm32_eth.c: There may be a few more lurking bugs, but
the STM32 Ethernet driver appears to be fully functional on the STM3240G-EVAL.
* arch/arm/srcm/stm32/stm32_eth.c: Fix an error in clearing abnormal interrupt
events.
* configs/stm3240g-eval/dhcpd: Add a DCHP daemon configuration for the
STM3240G-EVAL board.
* configs/stm3240g-eval/nettest: Add a network test configuration for the
STM3240G-EVAL board.
* arch/arm/srcm/stm32/stm32_rtc.c, stm32f10xxx_rtc.c, and stm32f40xxx_rtc:
Broke out separate drivers to handle the very different RTC implementations
in the STM32 F1 and F4 family.
apps-6.13 2012-xx-xx Gregory Nutt &lt;gnutt@nuttx.org&gt;
* apps/examples/dhcpd: May now be built as an NSH built-in application
by setting CONFIG_NSH_BUILTIN_APPS.
* apps/netutils/dhcpd/dhcpd.c: Fix several problems using host order address
where network addresses expected (and vice versa).
* apps/examples/nettest: May now be built as an NSH built-in application
by setting CONFIG_NSH_BUILTIN_APPS.
* apps/examples/nettest: Correct some build issues with the nettest is
built for performance evaluation.
pascal-3.1 2012-xx-xx Gregory Nutt &lt;gnutt@nuttx.org&gt;
buildroot-1.11 2012-xx-xx &lt;gnutt@nuttx.org&gt;
+20
View File
@@ -82,6 +82,26 @@
/* Register Bitfield Definitions ****************************************************/
/* EXTI lines > 15 are associated with internal devices: */
#if defined(CONFIG_STM32_STM32F10XX)
# 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_USB_WAKEUP (1 << 18) /* EXTI line 18 is connected to the USB Wakeup event */
# ifdef CONFIG_STM32_CONNECTIVITYLINE
# define EXTI_ETH_WAKEUP (1 << 19) /* EXTI line 19 is connected to the Ethernet Wakeup event */
# endif
#elif defined(CONFIG_STM32_STM32F40XX)
# 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_OTGFS_WAKEUP (1 << 18) /* EXTI line 18 is connected to the USB OTG FS Wakeup event */
# define EXTI_ETH_WAKEUP (1 << 19) /* EXTI line 19 is connected to the Ethernet Wakeup event */
# define EXTI_OTGHS_WAKEUP (1 << 20) /* EXTI line 20 is connected to the USB OTG HS Wakeup event */
# define EXTI_RTC_TAMPER (1 << 21) /* EXTI line 21 is connected to the RTC Tamper and TimeStamp events */
# define EXTI_RTC_TIMESTAMP (1 << 22) /* EXTI line 21 is connected to the RTC Tamper and TimeStamp events */
# define EXTI_RTC_WAKEUP (1 << 23) /* EXTI line 22 is connected to the RTC Wakeup event
#endif
/* Interrupt mask register */
#define EXTI_IMR_BIT(n) STM32_EXTI_BIT(n) /* 1=Interrupt request from line x is not masked */
+7 -4
View File
@@ -133,7 +133,7 @@
#define RTC_TR_SU_SHIFT (0) /* Bits 0-3: Second units in BCD format */
#define RTC_TR_SU_MASK (15 << RTC_TR_SU_SHIFT)
#define RTC_TR_ST_SHIFT (4) /* Bits 4-6: Second tens in BCD format */
#define RTC_TR_ST_MASK (7 << RTC_TR_ST_SHIFT)*
#define RTC_TR_ST_MASK (7 << RTC_TR_ST_SHIFT)
#define RTC_TR_MNU_SHIFT (8) /* Bit 8-11: Minute units in BCD format */
#define RTC_TR_MNU_MASK (15 << RTC_TR_MNU_SHIFT)
#define RTC_TR_MNT_SHIFT (12) /* Bits 12-14: Minute tens in BCD format */
@@ -143,10 +143,11 @@
#define RTC_TR_HT_SHIFT (20) /* Bits 20-21: Hour tens in BCD format */
#define RTC_TR_HT_MASK (3 << RTC_TR_HT_SHIFT)
#define RTC_TR_PM (1 << 22) /* Bit 22: AM/PM notation */
#define RTC_TR_RESERVED_BITS (0xff808080)
/* RTC date register */
#define RTC_DR_DU_SHIFT (0) /* Bits 0-3]: Date units in BCD format */
#define RTC_DR_DU_SHIFT (0) /* Bits 0-3: Date units in BCD format */
#define RTC_DR_DU_MASK (15 << RTC_DR_DU_SHIFT)
#define RTC_DR_DT_SHIFT (4) /* Bits 4-5: Date tens in BCD format */
#define RTC_DR_DT_MASK (3 << RTC_DR_DT_SHIFT)
@@ -166,6 +167,7 @@
#define RTC_DR_YU_MASK (15 << RTC_DR_YU_SHIFT)
#define RTC_DR_YT_SHIFT (20) /* Bits 20-23: Year tens in BCD format */
#define RTC_DR_YT_MASK (15 << RTC_DR_YT_SHIFT)
#define RTC_DR_RESERVED_BITS (0xff0000c0)
/* RTC control register */
@@ -220,13 +222,14 @@
#define RTC_ISR_TSOVF (1 << 12) /* Bit 12: Timestamp overflow 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_RECALPF (1 << 15) /* Bit 16: Recalibration pending Flag */
#define RTC_ISR_RECALPF (1 << 16) /* Bit 16: Recalibration pending Flag */
#define RTC_ISR_ALLFLAGS (0x00017fff)
/* RTC prescaler register */
#define RTC_PRER_PREDIV_S_SHIFT (0) /* Bits 0-14: Synchronous prescaler factor */
#define RTC_PRER_PREDIV_S_MASK (0x7fff << RTC_PRER_PREDIV_S_SHIFT)
#define RTC_PRER_PREDIV_A_SHIFT (22) /* Bits 16-22: Asynchronous prescaler factor */
#define RTC_PRER_PREDIV_A_SHIFT (16) /* Bits 16-22: Asynchronous prescaler factor */
#define RTC_PRER_PREDIV_A_MASK (0x7f << RTC_PRER_PREDIV_A_SHIFT)
/* RTC wakeup timer register */
+20 -8
View File
@@ -2,7 +2,7 @@
* arch/arm/src/stm32/stm32_lse.c
*
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Author: Gregory Nutt <gnutt@nuttx.orgr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -63,31 +63,43 @@
/****************************************************************************
* Name: stm32_rcc_enablelse
*
* Description:
* Enable the External Low-Speed (LSE) Oscillator and, if the RTC is
* configured, setup the LSE as the RTC clock source, and enable the RTC.
*
* Todo:
* Check for LSE good timeout and return with -1,
* possible ISR optimization? or at least ISR should be cough in case of\
* failure
*
****************************************************************************/
void stm32_rcc_enablelse(void)
{
/* Enable LSE */
/* Enable the External Low-Speed (LSE) Oscillator by setting the LSEON bit
* the RCC BDCR register.
*/
modifyreg16(STM32_RCC_BDCR, 0, RCC_BDCR_LSEON);
/* We could wait for ISR here ... */
/* Wait for the LSE clock to be ready */
while ((getreg16(STM32_RCC_BDCR) & RCC_BDCR_LSERDY) == 0)
{
up_waste();
}
/* Select LSE as RTC Clock Source */
/* The primariy purpose of the LSE clock is to drive the RTC. The RTC could
* also be driven by the LSI (but that would be very inaccurate) or by the
* HSE (but that would prohibit low-power operation)
*
* Select LSE as RTC Clock Source by setting the RTCSEL field of the RCC BDCR
* register.
*/
#ifdef CONFIG_RTC
modifyreg16(STM32_RCC_BDCR, RCC_BDCR_RTCSEL_MASK, RCC_BDCR_RTCSEL_LSE);
/* Enable Clock */
/* Enable the RTC Clock by setting the RTCEN bit in the RCC BDCR register */
modifyreg16(STM32_RCC_BDCR, 0, RCC_BDCR_RTCEN);
#endif
}
+22 -18
View File
@@ -33,13 +33,9 @@
*
************************************************************************************/
/** \file
* \author Uros Platise
* \brief STM32 Power
*
* \addtogroup STM32_PWR
* \{
*/
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <nuttx/arch.h>
@@ -50,7 +46,6 @@
#include "up_arch.h"
#include "stm32_pwr.h"
#if defined(CONFIG_STM32_PWR)
/************************************************************************************
@@ -59,32 +54,41 @@
static inline uint16_t stm32_pwr_getreg(uint8_t offset)
{
return getreg32(STM32_PWR_BASE + offset);
return getreg32(STM32_PWR_BASE + offset);
}
static inline void stm32_pwr_putreg(uint8_t offset, uint16_t value)
{
putreg32(value, STM32_PWR_BASE + offset);
putreg32(value, STM32_PWR_BASE + offset);
}
static inline void stm32_pwr_modifyreg(uint8_t offset, uint16_t clearbits, uint16_t setbits)
{
modifyreg32(STM32_PWR_BASE + offset, clearbits, setbits);
modifyreg32(STM32_PWR_BASE + offset, clearbits, setbits);
}
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Public Function - Initialization
* Name: stm32_pwr_enablebkp
*
* Description:
* Enables access to the backup domain (RTC registers, RTC backup data registers
* and backup SRAM).
*
* Input Parameters:
* None
*
* Returned Values:
* None
*
************************************************************************************/
void stm32_pwr_enablebkp(void)
{
stm32_pwr_modifyreg(STM32_PWR_CR_OFFSET, 0, PWR_CR_DBP);
stm32_pwr_modifyreg(STM32_PWR_CR_OFFSET, 0, PWR_CR_DBP);
}
#endif // defined(CONFIG_STM32_PWR)
/** \} */
+16 -4
View File
@@ -63,15 +63,27 @@ extern "C" {
* Public Functions
************************************************************************************/
/** Disables Write Protection to the Backup Area
**/
/************************************************************************************
* Name: stm32_pwr_enablebkp
*
* Description:
* Enables access to the backup domain (RTC registers, RTC backup data registers
* and backup SRAM).
*
* Input Parameters:
* None
*
* Returned Values:
* None
*
************************************************************************************/
EXTERN void stm32_pwr_enablebkp(void);
/** \} */
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_STM32_STM32_PWR_H */
+3 -2
View File
@@ -2,7 +2,7 @@
* arch/arm/src/stm32/stm32_rcc.h
*
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Author: Gregory Nutt <gnutt@nuttx.orgr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -170,7 +170,8 @@ EXTERN void stm32_clockconfig(void);
* Name: stm32_rcc_enablelse
*
* Description:
* Enable LSE Clock
* Enable the External Low-Speed (LSE) Oscillator and, if the RTC is
* configured, setup the LSE as the RTC clock source, and enable the RTC.
*
* Input Parameters:
* None
+2 -1
View File
@@ -354,7 +354,8 @@ static int stm32_rtc_interrupt(int irq, void *context)
int up_rtcinitialize(void)
{
/* Set access to the peripheral, enable the backup domain (BKP) and the lower power
* extern 32,768Hz (Low-Speed External, LSE) oscillator.
* extern 32,768Hz (Low-Speed External, LSE) oscillator. Configure the LSE to
* drive the RTC.
*/
stm32_pwr_enablebkp();
+1 -1
View File
@@ -426,7 +426,7 @@ static inline void rcc_enableapb1(void)
#endif
/* Power interface clock enable. The PWR block is always enabled so that
* we can set the internal voltage regulator for maximum performanc.
* we can set the internal voltage regulator for maximum performance.
*/
regval |= RCC_APB1ENR_PWREN;
File diff suppressed because it is too large Load Diff
+24
View File
@@ -236,6 +236,18 @@
# define illvdbg(x...)
#endif
#ifdef CONFIG_DEBUG_ANALOG
# define adbg(format, arg...) dbg(format, ##arg)
# define alldbg(format, arg...) lldbg(format, ##arg)
# define avdbg(format, arg...) vdbg(format, ##arg)
# define allvdbg(format, arg...) llvdbg(format, ##arg)
#else
# define adbg(x...)
# define alldbg(x...)
# define avdbg(x...)
# define allvdbg(x...)
#endif
#ifdef CONFIG_DEBUG_GRAPHICS
# define gdbg(format, arg...) dbg(format, ##arg)
# define glldbg(format, arg...) lldbg(format, ##arg)
@@ -393,6 +405,18 @@
# define illvdbg (void)
#endif
#ifdef CONFIG_DEBUG_ANALOG
# define adbg dbg
# define alldbg lldbg
# define avdbg vdbg
# define allvdbg llvdbg
#else
# define adbg (void)
# define alldbg (void)
# define avdbg (void)
# define allvdbg (void)
#endif
#ifdef CONFIG_DEBUG_GRAPHICS
# define gdbg dbg
# define glldbg lldbg