소스 검색

Update Makefile for local cross-compilation tool and add new object file

- Changed the CC variable to use the local default cross-compilation tool instead of the full path.
- Added 'tmp/bsp_share/bsp_ustimer.o' to the list of object files to be compiled.
juni 4 달 전
부모
커밋
7da7a41598

+ 0 - 0
dtu/dtu_main_t536/.clangd → .clangd


+ 2 - 0
.gitignore

@@ -1,3 +1,5 @@
 dtu/dtu_main_t536/tmp
 dtu/dtu_main_t536/out
 dtu/dtu_main_t536/ko
+.cache
+compile_commands.json

+ 1 - 1
app_public/fuxi_public/bsp_share/bsp_ccu.h

@@ -10,7 +10,7 @@
 
  #define CCU_BASE             		(0x02002000UL)
 
- void *g_ccu_map_base, *g_ccu_virt_addr;
+ extern void *g_ccu_map_base, *g_ccu_virt_addr;
 
  int ccu_init(void);
  int ccu_exit(void);

+ 90 - 7
app_public/fuxi_public/bsp_share/ustimer.c → app_public/fuxi_public/bsp_share/bsp_ustimer.c

@@ -9,7 +9,7 @@
 其它说明:
 修改记录:
 */
-#include "ustimer.h"
+#include "bsp_ustimer.h"
 #include <stdlib.h>
 #include <fcntl.h>
 #include <sys/types.h>
@@ -17,16 +17,18 @@
 #include <stdio.h>
 #include <sys/mman.h>
 #include "bsp_ccu.h"
+#include "rt_types.h"
 
 #define MAP_SIZE 4096UL
 #define MAP_MASK (MAP_SIZE - 1)
+#define BSP_USTIMER_DELAY_MAX_US	(10UL*60*BSP_USTIMER_SEC) //10分钟
 
 int g_ustimer_fd = -1;
 unsigned g_ustimer_mapped_size;
 void *g_ustimer_map_base, *g_ustimer_virt_addr; 
 
 /******************************************************************************
-函数名称:    ustimer_init
+函数名称:    bsp_ustimer_init
 函数版本:    01.01
 创建作者:    zhaoyang
 创建日期:    2025-07-28
@@ -35,7 +37,7 @@ void *g_ustimer_map_base, *g_ustimer_virt_addr;
 返回值:      无
 修改记录:
 */
-int ustimer_init(void)
+int bsp_ustimer_init(void)
 {   
     void *temp_ccu_base, *temp_virt_l_base, *temp_virt_h_base, *temp_virt_ctl_base;
     unsigned long read_result;
@@ -102,7 +104,7 @@ int ustimer_init(void)
 }
 
 /******************************************************************************
-函数名称:    ustimer_exit
+函数名称:    bsp_ustimer_exit
 函数版本:    01.01
 创建作者:    zhaoyang
 创建日期:    2025-07-28
@@ -111,7 +113,7 @@ int ustimer_init(void)
 返回值:      无
 修改记录:
 */
-int ustimer_exit(void)
+int bsp_ustimer_exit(void)
 {
     if (g_ustimer_fd >= 0)
     {
@@ -128,7 +130,7 @@ int ustimer_exit(void)
 }
 
 /******************************************************************************
-函数名称:    ustimer_get_origin
+函数名称:    bsp_ustimer_get_origin
 函数版本:    01.01
 创建作者:    zhaoyang
 创建日期:    2025-07-28
@@ -138,7 +140,7 @@ int ustimer_exit(void)
 返回值:      当前时刻定时器的值。
 修改记录:
 */
-unsigned long ustimer_get_origin(void)
+unsigned long bsp_ustimer_get_origin(void)
 {
     void *temp_virt_l_base, *temp_virt_h_base;
     u_int64_t val_low, val_high;
@@ -154,3 +156,84 @@ unsigned long ustimer_get_origin(void)
 
     return ((val_high << TIMER_VH_OFFSET) | val_low)/3;
 }
+
+/******************************************************************************
+函数名称:    bsp_ustimer_get_duration
+函数版本:    01.01
+创建作者:    zhaoyang
+创建日期:    2025-07-28
+函数说明:    得到当前时刻相对于指定时间原点的时间间隔,以us为单位。
+参数说明:    origin:    时间原点,以us为单位。
+返回值:      当前时刻相对于原点的的时间间隔。
+修改记录:
+*/
+unsigned long bsp_ustimer_get_duration(unsigned long origin)
+{
+    if(!g_ustimer_map_base)
+		return 0;
+    // 返回差值(根据C语言算法,会自动处理回绕问题)
+    return bsp_ustimer_get_origin() - origin;
+}
+
+/******************************************************************************
+函数名称:    bsp_ustimer_delay_origin
+函数版本:    01.01
+创建作者:    zhaoyang
+创建日期:    2025-07-28
+函数说明:    以us为单位的延时函数。最大延时值为1小时(3600000000us)和
+             ustimer_delay函数不同的是bsp_ustimer_delay_origin函数的延时计算的时间
+             原点为origin,而不是函数被调用的时刻。当这个函数退出时,会确保延时
+             大于等于设定值。如果需要高精度的延时,调用这个函数时应先屏蔽中断。
+参数说明:
+    origin:  延时计算的时间原点,以us为单位,通常通过ustimer_get_origin函数获得。
+    us:     延时us数。
+返回值:
+    0:        成功
+    其它:    失败
+修改记录:
+*/
+unsigned long bsp_ustimer_delay_origin(unsigned long origin,unsigned long us)
+{
+    if(!g_ustimer_map_base)
+		return 0;
+
+    //检查参数
+	if(us > BSP_USTIMER_DELAY_MAX_US)
+		return -1;
+
+    // 循环等待
+    while (us > (bsp_ustimer_get_origin() - origin))
+        ;
+    return 0;
+}
+
+/******************************************************************************
+函数名称:    ustimer_delay
+函数版本:    01.01
+创建作者:    zhaoyang
+创建日期:    2025-07-28
+函数说明:    以us为单位的延时函数。最大延时值为1小时(3600000000us)。
+            当这个函数退出时,会确保延时大于等于设定值。如果需要高精度的延时,
+            调用这个函数时应先屏蔽中断。
+参数说明:
+    us:    延时us数。
+返回值:
+    0:    成功
+    其它:    失败
+修改记录:
+*/
+unsigned long bsp_ustimer_delay(unsigned long us)
+{
+    u64 origin;
+
+    if(!g_ustimer_map_base)
+		return 0;
+
+    //检查参数
+	if(us > BSP_USTIMER_DELAY_MAX_US)
+		return -1;
+
+    origin = bsp_ustimer_get_origin();
+	bsp_ustimer_delay_origin(origin, us);
+    return 0;
+}

+ 13 - 6
app_public/fuxi_public/bsp_share/ustimer.h → app_public/fuxi_public/bsp_share/bsp_ustimer.h

@@ -1,12 +1,12 @@
 /**************************************************************************//**
- * @file     ustimer.h
+ * @file     bsp_ustimer.h
  * @brief    TIMER register definition header file
  *
  * SPDX-License-Identifier: Apache-2.0
  * @copyright (C) 2024-2034 HaiYang Technology Corp. All rights reserved.
  *****************************************************************************/
- #ifndef __US_TIMER_H__
- #define __US_TIMER_H__
+ #ifndef __BSP_US_TIMER_H__
+ #define __BSP_US_TIMER_H__
  
  #include <linux/types.h>
 
@@ -29,8 +29,15 @@
  #define TIMER_INTVAL_REG(val)	(0x10 * val + 0x14)
  #define TIMER_CNTVAL_REG(val)	(0x10 * val + 0x18)
 
- int ustimer_init(void);
- int ustimer_exit(void);
- unsigned long ustimer_get_origin(void);
+ #define BSP_USTIMER_US		1
+#define BSP_USTIMER_MS		(1000*BSP_USTIMER_US)
+#define BSP_USTIMER_SEC		(1000*BSP_USTIMER_US)
+
+ int bsp_ustimer_init(void);
+ int bsp_ustimer_exit(void);
+ unsigned long bsp_ustimer_get_origin(void);
+ unsigned long bsp_ustimer_delay(unsigned long us);
+ unsigned long bsp_ustimer_delay_origin(unsigned long origin,unsigned long us);
+ unsigned long bsp_ustimer_get_duration(unsigned long origin);
 
  #endif

+ 2 - 0
app_public/fuxi_public/fuxi_bsp/include/bsp.h

@@ -30,6 +30,8 @@
 #include "goose.h"
 #include "goose_drv.h"
 #include <sched.h>
+#include "bsp_ccu.h"
+#include "bsp_ustimer.h"
 
 extern const char * szTool;
 

+ 4 - 0
app_public/fuxi_public/fuxi_bsp/source/bsp.c

@@ -22,6 +22,8 @@ const char * szTool = "JHW GH-F308 1.00.01";
 
 struct init_t  g_bsp_init_func[]=
 {
+	{ccu_init,ERR_CODE_INIT_SOFTWARE},	//初始化系统时钟CCU
+	{bsp_ustimer_init,ERR_CODE_INIT_SOFTWARE},	//初始化内核USTIMER
 	{ustimer_init,ERR_CODE_INIT_SOFTWARE},	//初始化USTIMER
 	{shm_init,ERR_CODE_INIT_SOFTWARE},	//初始化shm
 	{mb_init,ERR_CODE_INIT_SOFTWARE},	//初始化mb
@@ -70,7 +72,9 @@ INIT_FUNC g_bsp_exit_func[]=
 	shm_exit,
 	mb_exit,
 	ustimer_exit,
+	bsp_ustimer_exit,
 	log_exit,
+	ccu_exit,
 };
 #define BSP_EXIT_NUM	(sizeof(g_bsp_exit_func)/sizeof(g_bsp_exit_func[0]))
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 303 - 397
dtu/dtu_main_t536/compile_commands.json


+ 3 - 1
dtu/dtu_main_t536/sh/t536/Makefile

@@ -4,7 +4,8 @@ else
 Q = @
 endif
 
-CC 	=	/opt/EmbedSky/TQT536/bin/aarch64-none-linux-gnu-gcc
+# we only use the local default cross-compilation tool
+CC 	=	aarch64-none-linux-gnu-gcc
 
 IFLAGS  = -idirafter dummyinc
 # CFLAGS	= -O0 -g -Wshadow -Wformat -Wall -W -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-pointer-sign 
@@ -73,6 +74,7 @@ OBJS =  main_mod.o \
 		tmp/bsp_share/bsp_share.o \
 		tmp/bsp_share/bsp_packet.o \
 		tmp/bsp_share/bsp_ccu.o \
+		tmp/bsp_share/bsp_ustimer.o \
 		\
 		tmp/app/history_db.o\
 		tmp/app/app.o\

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.