From 48df1fd78bcaf07809aebf5022a11376c4a6cd94 Mon Sep 17 00:00:00 2001 From: qshi <123456@qq.com> Date: Mon, 19 Nov 2018 14:39:02 +0800 Subject: [PATCH] hyplnk example little modify --- samples/srio/.cproject | 6 ++++++ samples/srio/src/hyplnk.c | 44 +++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/samples/srio/.cproject b/samples/srio/.cproject index 471e963..e996f25 100644 --- a/samples/srio/.cproject +++ b/samples/srio/.cproject @@ -98,6 +98,9 @@ + + + @@ -195,6 +198,9 @@ + + + diff --git a/samples/srio/src/hyplnk.c b/samples/srio/src/hyplnk.c index bbad92e..630f718 100644 --- a/samples/srio/src/hyplnk.c +++ b/samples/srio/src/hyplnk.c @@ -7,62 +7,60 @@ #include #include #include "hyplnk_func.h" -typedef struct hyplnk_test { - int sem; - hpk_addr_cfg_s map_table; -}hyplnk_test_s; extern int g_master; -static hyplnk_test_s _hpk_test; +static volatile int _sem = 0; + static void __hyplnk_intr(void *arg) { - hyplnk_test_s *ht = (hyplnk_test_s *)arg; - ht->sem += 1; + *(int*)arg = 1; } int hyplnk_task() { - _hpk_test.sem = 0; - hyplnk_init(&_hpk_test, __hyplnk_intr); + hpk_addr_cfg_s map_table; + hyplnk_init((void *)&_sem, __hyplnk_intr); /* local remote leng * 0x40000000 -> 0x0C3000000 4M * 0x40100000 -> 0xB00000000 252M * */ - _hpk_test.map_table.seg_info[0].local_addr = 0x40000000; - _hpk_test.map_table.seg_info[0].remote_addr = 0x0C300000; //msmc - _hpk_test.map_table.seg_info[0].map_leng = 0x400000; //4M + map_table.seg_info[0].local_addr = 0x40000000; + map_table.seg_info[0].remote_addr = 0x0C300000; //msmc + map_table.seg_info[0].map_leng = 0x400000; //4M - _hpk_test.map_table.seg_info[1].local_addr = 0x40400000; - _hpk_test.map_table.seg_info[1].remote_addr = 0xB0000000; //ddr - _hpk_test.map_table.seg_info[1].map_leng = 0x0FC00000; //252M + map_table.seg_info[1].local_addr = 0x40400000; + map_table.seg_info[1].remote_addr = 0xB0000000; //ddr + map_table.seg_info[1].map_leng = 0x0FC00000; //252M - _hpk_test.map_table.seg_num = 2; - hyplnk_addr_map(&_hpk_test.map_table); + map_table.seg_num = 2; + hyplnk_addr_map(&map_table); printf("hyplnk func init complete ... \n"); if (g_master) { printf("master: send data to remote... \n"); - memset((void *)0x40000000, 0xA1, _hpk_test.map_table.seg_info[0].map_leng); - memset((void *)0x40400000, 0xA2, _hpk_test.map_table.seg_info[1].map_leng); + memset((void *)0x40000000, 0xA1, map_table.seg_info[0].map_leng); + memset((void *)0x40400000, 0xA2, map_table.seg_info[1].map_leng); printf("master: send intr to remote... \n"); hyplnk_send_intr_remote(); printf("master: wait slave ack...\n"); - while(_hpk_test.sem == 0) + //while(_hpk_test.sem == 0) + while(_sem == 0) ; } else { //wait recv intr printf("slave wait recv intr\n"); - while(_hpk_test.sem == 0) + //while(_hpk_test.sem == 0) + while(_sem == 0) ; printf("slave: send data to remote... \n"); - memset((void *)0x40000000, 0xB1, _hpk_test.map_table.seg_info[0].map_leng); - memset((void *)0x40400000, 0xB2, _hpk_test.map_table.seg_info[1].map_leng); + memset((void *)0x40000000, 0xB1, map_table.seg_info[0].map_leng); + memset((void *)0x40400000, 0xB2, map_table.seg_info[1].map_leng); printf("slave: send intr to remote... \n"); hyplnk_send_intr_remote();