summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanek <[email protected]>2018-03-16 18:04:13 +0800
committerGitHub <[email protected]>2018-03-16 18:04:13 +0800
commitc4c729f014ca0a34f81966d656f07f6d804c722c (patch)
treefa16af2240958aa5b744e8b276f8465df2430278
parentbce9bc47af60f340e41f5d4e978972322b0fde83 (diff)
parent0dd4854dc795faf020463f99f08524a099277fe0 (diff)
Merge pull request #1290 from liu2guang/master
[BSP] add rt1050 hp rtc driver.| 添加RT1050 高功耗RTC驱动.
-rw-r--r--bsp/imxrt1052-evk/.config6
-rw-r--r--bsp/imxrt1052-evk/Kconfig16
-rw-r--r--bsp/imxrt1052-evk/drivers/SConscript3
-rw-r--r--bsp/imxrt1052-evk/drivers/drv_hp_rtc.c150
-rw-r--r--bsp/imxrt1052-evk/drivers/drv_hp_rtc.h23
-rw-r--r--bsp/imxrt1052-evk/drivers/usart.c4
-rw-r--r--bsp/imxrt1052-evk/drivers/usart.h2
-rw-r--r--bsp/imxrt1052-evk/project.uvoptx19
-rw-r--r--bsp/imxrt1052-evk/project.uvprojx20
-rw-r--r--bsp/imxrt1052-evk/rtconfig.h6
10 files changed, 218 insertions, 31 deletions
diff --git a/bsp/imxrt1052-evk/.config b/bsp/imxrt1052-evk/.config
index 130d4835b5..badc996951 100644
--- a/bsp/imxrt1052-evk/.config
+++ b/bsp/imxrt1052-evk/.config
@@ -130,7 +130,9 @@ CONFIG_RT_USING_I2C_BITOPS=y
CONFIG_RT_USING_PIN=y
# CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NAND is not set
-# CONFIG_RT_USING_RTC is not set
+CONFIG_RT_USING_RTC=y
+# CONFIG_RT_USING_SOFT_RTC is not set
+# CONFIG_RTC_SYNC_USING_NTP is not set
CONFIG_RT_USING_SDIO=y
# CONFIG_RT_USING_SPI is not set
# CONFIG_RT_USING_WDT is not set
@@ -312,5 +314,5 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
# CONFIG_PKG_USING_HELLO is not set
# CONFIG_PKG_USING_MULTIBUTTON is not set
CONFIG_SOC_IMXRT1052=y
-CONFIG_RT_USING_UART=y
CONFIG_RT_USING_UART1=y
+CONFIG_RT_USING_HP_RTC=y
diff --git a/bsp/imxrt1052-evk/Kconfig b/bsp/imxrt1052-evk/Kconfig
index 0a15061526..8bfb1e2589 100644
--- a/bsp/imxrt1052-evk/Kconfig
+++ b/bsp/imxrt1052-evk/Kconfig
@@ -23,13 +23,15 @@ config SOC_IMXRT1052
select ARCH_ARM_CORTEX_M7
default y
-config RT_USING_UART
- bool "Using RT_USING_UART"
- default y
-
-if RT_USING_UART
+if RT_USING_SERIAL
config RT_USING_UART1
bool "Using RT_USING_UART1"
- default y
+ default y
endif
-
+
+if RT_USING_RTC
+config RT_USING_HP_RTC
+ bool "Using RT_USING_HP_RTC"
+ default n
+endif
+
diff --git a/bsp/imxrt1052-evk/drivers/SConscript b/bsp/imxrt1052-evk/drivers/SConscript
index 4025fb6fbc..6ab68c0ea4 100644
--- a/bsp/imxrt1052-evk/drivers/SConscript
+++ b/bsp/imxrt1052-evk/drivers/SConscript
@@ -18,6 +18,9 @@ CPPDEFINES = []
if GetDepend('RT_USING_PIN'):
src += ['drv_pin.c']
+if GetDepend('RT_USING_HP_RTC'):
+ src += ['drv_hp_rtc.c']
+
if GetDepend('RT_USING_LWIP'):
src += ['drv_eth.c', 'fsl_phy.c']
CPPDEFINES += ['FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE']
diff --git a/bsp/imxrt1052-evk/drivers/drv_hp_rtc.c b/bsp/imxrt1052-evk/drivers/drv_hp_rtc.c
new file mode 100644
index 0000000000..29093e0eb8
--- /dev/null
+++ b/bsp/imxrt1052-evk/drivers/drv_hp_rtc.c
@@ -0,0 +1,150 @@
+/*
+ * File : drv_hp_rtc.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006-2013, RT-Thread Development Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2018-03-15 Liuguang the first version.
+ */
+#include "drv_hp_rtc.h"
+#include <time.h>
+#include "fsl_common.h"
+#include "fsl_snvs_hp.h"
+#include "fsl_snvs_lp.h"
+
+#ifdef RT_USING_RTC
+
+#if defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL
+ #error "Please don't define 'FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL'!"
+#endif
+
+static time_t get_timestamp(void)
+{
+ struct tm tm_new = {0};
+ snvs_hp_rtc_datetime_t rtcDate;
+
+ SNVS_HP_RTC_GetDatetime(SNVS, &rtcDate);
+
+ tm_new.tm_sec = rtcDate.second;
+ tm_new.tm_min = rtcDate.minute;
+ tm_new.tm_hour = rtcDate.hour;
+
+ tm_new.tm_mday = rtcDate.day;
+ tm_new.tm_mon = rtcDate.month - 1;
+ tm_new.tm_year = rtcDate.year - 1900;
+
+ return mktime(&tm_new);
+}
+
+static int set_timestamp(time_t timestamp)
+{
+ struct tm *p_tm;
+ snvs_hp_rtc_datetime_t rtcDate;
+
+ p_tm = localtime(&timestamp);
+
+ rtcDate.second = p_tm->tm_sec ;
+ rtcDate.minute = p_tm->tm_min ;
+ rtcDate.hour = p_tm->tm_hour;
+
+ rtcDate.day = p_tm->tm_mday;
+ rtcDate.month = p_tm->tm_mon + 1;
+ rtcDate.year = p_tm->tm_year + 1900;
+
+ SNVS_HP_RTC_SetDatetime(SNVS, &rtcDate);
+
+ return RT_EOK;
+}
+
+/* �����ӿ� */
+static rt_err_t rt1052_hp_rtc_init(rt_device_t dev)
+{
+ snvs_hp_rtc_config_t snvsRtcConfig;
+
+ SNVS_HP_RTC_GetDefaultConfig(&snvsRtcConfig);
+ SNVS_HP_RTC_Init(SNVS, &snvsRtcConfig);
+
+ SNVS_HP_RTC_StartTimer(SNVS);
+
+ return RT_EOK;
+}
+
+static rt_err_t rt1052_hp_rtc_open(rt_device_t dev, rt_uint16_t oflag)
+{
+ return RT_EOK;
+}
+
+static rt_err_t rt1052_hp_rtc_close(rt_device_t dev)
+{
+ return RT_EOK;
+}
+
+static rt_size_t rt1052_hp_rtc_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size)
+{
+ return 0;
+}
+
+static rt_size_t rt1052_hp_rtc_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
+{
+ return 0;
+}
+
+static rt_err_t rt1052_hp_rtc_control(rt_device_t dev, int cmd, void *args)
+{
+ RT_ASSERT(dev != RT_NULL);
+
+ switch(cmd)
+ {
+ case RT_DEVICE_CTRL_RTC_GET_TIME:
+ {
+ *(uint32_t *)args = get_timestamp();
+ }
+ break;
+
+ case RT_DEVICE_CTRL_RTC_SET_TIME:
+ {
+ set_timestamp(*(time_t *)args);
+ }
+ break;
+
+ /* ������ */
+ default:
+ return RT_EINVAL;
+ }
+
+ return RT_EOK;
+}
+
+static struct rt_device device =
+{
+ .type = RT_Device_Class_RTC,
+ .init = rt1052_hp_rtc_init,
+ .open = rt1052_hp_rtc_open,
+ .close = rt1052_hp_rtc_close,
+ .read = rt1052_hp_rtc_read,
+ .write = rt1052_hp_rtc_write,
+ .control = rt1052_hp_rtc_control,
+};
+
+int rt_hw_hp_rtc_init(void)
+{
+ rt_err_t ret = RT_EOK;
+
+ ret = rt_device_register(&device, "rtc", RT_DEVICE_FLAG_RDWR);
+ if(ret != RT_EOK)
+ {
+ return ret;
+ }
+
+ rt_device_open(&device, RT_DEVICE_OFLAG_RDWR);
+
+ return RT_EOK;
+}
+INIT_DEVICE_EXPORT(rt_hw_hp_rtc_init);
+
+#endif /*RT_USING_RTC */
diff --git a/bsp/imxrt1052-evk/drivers/drv_hp_rtc.h b/bsp/imxrt1052-evk/drivers/drv_hp_rtc.h
new file mode 100644
index 0000000000..e191e4714c
--- /dev/null
+++ b/bsp/imxrt1052-evk/drivers/drv_hp_rtc.h
@@ -0,0 +1,23 @@
+/*
+ * File : drv_hp_rtc.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006-2013, RT-Thread Development Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2018-03-15 Liuguang the first version.
+ */
+
+#ifndef __DRV_RTC_H__
+#define __DRV_RTC_H__
+
+#include <rtthread.h>
+#include <rtdevice.h>
+
+int rt_hw_hp_rtc_init(void);
+
+#endif
diff --git a/bsp/imxrt1052-evk/drivers/usart.c b/bsp/imxrt1052-evk/drivers/usart.c
index 68c0f500ee..65a480a199 100644
--- a/bsp/imxrt1052-evk/drivers/usart.c
+++ b/bsp/imxrt1052-evk/drivers/usart.c
@@ -18,7 +18,7 @@
#include "fsl_lpuart.h"
#include "fsl_iomuxc.h"
-#ifdef RT_USING_UART
+#ifdef RT_USING_SERIAL
#if !defined(RT_USING_UART0) && !defined(RT_USING_UART1) && \
!defined(RT_USING_UART2) && !defined(RT_USING_UART3) && \
@@ -380,4 +380,4 @@ int imxrt_hw_usart_init(void)
}
INIT_BOARD_EXPORT(imxrt_hw_usart_init);
-#endif /*RT_USING_UART*/
+#endif /*RT_USING_SERIAL */
diff --git a/bsp/imxrt1052-evk/drivers/usart.h b/bsp/imxrt1052-evk/drivers/usart.h
index abd7631fee..5cc02fb430 100644
--- a/bsp/imxrt1052-evk/drivers/usart.h
+++ b/bsp/imxrt1052-evk/drivers/usart.h
@@ -9,7 +9,7 @@
*
* Change Logs:
* Date Author Notes
- * 2013-11-15 bright the first version
+ * 2017-10-10 Tanek the first version
*/
#ifndef __USART_H__
diff --git a/bsp/imxrt1052-evk/project.uvoptx b/bsp/imxrt1052-evk/project.uvoptx
index deca1cf444..f28e56931b 100644
--- a/bsp/imxrt1052-evk/project.uvoptx
+++ b/bsp/imxrt1052-evk/project.uvoptx
@@ -73,7 +73,7 @@
<LExpSel>0</LExpSel>
</OPTXL>
<OPTFL>
- <tvExp>0</tvExp>
+ <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
@@ -101,9 +101,7 @@
<sRunDeb>0</sRunDeb>
<sLrtime>0</sLrtime>
<bEvRecOn>1</bEvRecOn>
- <bSchkAxf>0</bSchkAxf>
- <bTchkAxf>0</bTchkAxf>
- <nTsel>3</nTsel>
+ <nTsel>2</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
@@ -166,16 +164,11 @@
<LintExecutable></LintExecutable>
<LintConfigFile></LintConfigFile>
<bLintAuto>0</bLintAuto>
+ <Lin2Executable></Lin2Executable>
+ <Lin2ConfigFile></Lin2ConfigFile>
+ <bLin2Auto>0</bLin2Auto>
<bAutoGenD>0</bAutoGenD>
- <LntExFlags>0</LntExFlags>
- <pMisraName></pMisraName>
- <pszMrule></pszMrule>
- <pSingCmds></pSingCmds>
- <pMultCmds></pMultCmds>
- <pMisraNamep></pMisraNamep>
- <pszMrulep></pszMrulep>
- <pSingCmdsp></pSingCmdsp>
- <pMultCmdsp></pMultCmdsp>
+ <bAuto2GenD>0</bAuto2GenD>
</TargetOption>
</Target>
diff --git a/bsp/imxrt1052-evk/project.uvprojx b/bsp/imxrt1052-evk/project.uvprojx
index 40d5d8b5d7..baf0a744f4 100644
--- a/bsp/imxrt1052-evk/project.uvprojx
+++ b/bsp/imxrt1052-evk/project.uvprojx
@@ -8,13 +8,11 @@
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060528::V5.06 update 5 (build 528)::ARMCC</pCCUsed>
- <uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>MIMXRT1052:M7</Device>
<Vendor>NXP</Vendor>
- <PackID>NXP.iMXRT_DFP.1.0.2</PackID>
- <PackURL>http://mcuxpresso.nxp.com/cmsis_pack/repo/</PackURL>
+ <PackID>NXP.iMXRT_DFP.1.0.1</PackID>
<Cpu>IRAM(0x20000000,0x00060000) IRAM2(0x00000000,0x00020000) CPUTYPE("Cortex-M7") FPU3(SFPU) CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec />
<StartupFile />
@@ -333,7 +331,7 @@
<MiscControls>--library_interface=armcc --library_type=standardlib --diag_suppress=66,1296,186</MiscControls>
<Define>SKIP_SYSCLK_INIT, CPU_MIMXRT1052DVL6A, FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL=1, EVK_MCIMXRM, FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE, RT_USING_ARM_LIBC</Define>
<Undefine />
- <IncludePath>applications;.;drivers;Libraries;Libraries\drivers;Libraries\utilities;Libraries\CMSIS\Include;..\..\include;..\..\libcpu\arm\cortex-m7;..\..\libcpu\arm\common;..\..\components\dfs\include;..\..\components\dfs\filesystems\devfs;..\..\components\dfs\filesystems\elmfat;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh;..\..\components\libc\compilers\armlibc;..\..\components\net\lwip-2.0.2\src;..\..\components\net\lwip-2.0.2\src\include;..\..\components\net\lwip-2.0.2\src\include\ipv4;..\..\components\net\lwip-2.0.2\src\arch\include;..\..\components\net\lwip-2.0.2\src\include\netif;..\..\components\net\lwip-2.0.2\src\include\posix</IncludePath>
+ <IncludePath>applications;.;drivers;Libraries;Libraries\drivers;Libraries\utilities;Libraries\CMSIS\Include;..\..\include;..\..\libcpu\arm\cortex-m7;..\..\libcpu\arm\common;..\..\components\dfs\include;..\..\components\dfs\filesystems\devfs;..\..\components\dfs\filesystems\elmfat;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh;..\..\components\libc\compilers\armlibc;..\..\components\net\lwip-2.0.2\src;..\..\components\net\lwip-2.0.2\src\include;..\..\components\net\lwip-2.0.2\src\include\ipv4;..\..\components\net\lwip-2.0.2\src\arch\include;..\..\components\net\lwip-2.0.2\src\include\netif;..\..\components\net\lwip-2.0.2\src\include\posix</IncludePath>
</VariousControls>
</Cads>
<Aads>
@@ -444,6 +442,13 @@
</Files>
<Files>
<File>
+ <FileName>drv_hp_rtc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>drivers\drv_hp_rtc.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
<FileName>drv_eth.c</FileName>
<FileType>1</FileType>
<FilePath>drivers\drv_eth.c</FilePath>
@@ -1117,6 +1122,13 @@
</Files>
<Files>
<File>
+ <FileName>rtc.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\..\components\drivers\rtc\rtc.c</FilePath>
+ </File>
+ </Files>
+ <Files>
+ <File>
<FileName>block_dev.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\components\drivers\sdio\block_dev.c</FilePath>
diff --git a/bsp/imxrt1052-evk/rtconfig.h b/bsp/imxrt1052-evk/rtconfig.h
index b04305f7b9..664aeb5458 100644
--- a/bsp/imxrt1052-evk/rtconfig.h
+++ b/bsp/imxrt1052-evk/rtconfig.h
@@ -121,7 +121,9 @@
#define RT_USING_PIN
/* RT_USING_MTD_NOR is not set */
/* RT_USING_MTD_NAND is not set */
-/* RT_USING_RTC is not set */
+#define RT_USING_RTC
+/* RT_USING_SOFT_RTC is not set */
+/* RTC_SYNC_USING_NTP is not set */
#define RT_USING_SDIO
/* RT_USING_SPI is not set */
/* RT_USING_WDT is not set */
@@ -277,7 +279,7 @@
/* PKG_USING_HELLO is not set */
/* PKG_USING_MULTIBUTTON is not set */
#define SOC_IMXRT1052
-#define RT_USING_UART
#define RT_USING_UART1
+#define RT_USING_HP_RTC
#endif