summaryrefslogtreecommitdiff
path: root/samples/ipm
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2016-11-12 09:08:52 -0500
committerAnas Nashif <nashif@linux.intel.com>2016-11-13 13:53:53 +0000
commitae09e0761b478d4d92481fc82ed19d7a0c5ac91f (patch)
tree8d6ee429da99f82b39ce5a2df6bafe22d14f3acc /samples/ipm
parent2367df8d5962cf64c108f70db2135e712263421a (diff)
samples: ipm: convert sample to use unified APIs
Change-Id: Ibeadd2e8d9efa2380f21a091ab5645c4b69a4841 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Diffstat (limited to 'samples/ipm')
-rw-r--r--samples/ipm/ipm_demo_arc/src/hello.c7
-rw-r--r--samples/ipm/ipm_demo_lmt/Makefile1
-rw-r--r--samples/ipm/ipm_demo_lmt/prj.conf1
-rw-r--r--samples/ipm/ipm_demo_lmt/prj.mdef13
-rw-r--r--samples/ipm/ipm_demo_lmt/src/hello.c62
5 files changed, 39 insertions, 45 deletions
diff --git a/samples/ipm/ipm_demo_arc/src/hello.c b/samples/ipm/ipm_demo_arc/src/hello.c
index b5dc4330e..2ca9e4a9d 100644
--- a/samples/ipm/ipm_demo_arc/src/hello.c
+++ b/samples/ipm/ipm_demo_arc/src/hello.c
@@ -31,16 +31,11 @@ QUARK_SE_IPM_DEFINE(message_ipm2, 3, QUARK_SE_IPM_INBOUND);
/* specify delay between greetings (in ms); compute equivalent in ticks */
#define SLEEPTIME 1100
-#define SLEEPTICKS (SLEEPTIME * sys_clock_ticks_per_sec / 800)
#define STACKSIZE 2000
-char fiberStack[STACKSIZE];
uint8_t counters[3];
-struct nano_sem nanoSemTask;
-struct nano_sem nanoSemFiber;
-
void ping_ipm_callback(void *context, uint32_t id, volatile void *data)
{
printk("counters: %d %d %d\n", counters[0], counters[1], counters[2]);
@@ -97,6 +92,6 @@ void main(void)
/* say "hello" */
printk("Hello from ARC!\n");
- task_sleep(SLEEPTICKS);
+ k_sleep(SLEEPTIME);
}
}
diff --git a/samples/ipm/ipm_demo_lmt/Makefile b/samples/ipm/ipm_demo_lmt/Makefile
index 105e9078a..aee0c93a6 100644
--- a/samples/ipm/ipm_demo_lmt/Makefile
+++ b/samples/ipm/ipm_demo_lmt/Makefile
@@ -1,5 +1,4 @@
BOARD ?= arduino_101
-MDEF_FILE = prj.mdef
CONF_FILE = prj.conf
include ${ZEPHYR_BASE}/Makefile.inc
diff --git a/samples/ipm/ipm_demo_lmt/prj.conf b/samples/ipm/ipm_demo_lmt/prj.conf
index 505c5489d..8b011ec4e 100644
--- a/samples/ipm/ipm_demo_lmt/prj.conf
+++ b/samples/ipm/ipm_demo_lmt/prj.conf
@@ -6,3 +6,4 @@ CONFIG_IPM_QUARK_SE_MASTER=y
CONFIG_IPM_CONSOLE_RECEIVER=y
CONFIG_NANO_TIMEOUTS=y
CONFIG_TIMESLICE_SIZE=1
+CONFIG_MAIN_STACK_SIZE=2048
diff --git a/samples/ipm/ipm_demo_lmt/prj.mdef b/samples/ipm/ipm_demo_lmt/prj.mdef
deleted file mode 100644
index 992656bb5..000000000
--- a/samples/ipm/ipm_demo_lmt/prj.mdef
+++ /dev/null
@@ -1,13 +0,0 @@
-% Application : Hello demo
-
-% TASK NAME PRIO ENTRY STACK GROUPS
-% ====================================================
- TASK TASKA 7 main_task 2048 [EXE]
- TASK MSG_TASK0 7 message_source_task_0 2048 [EXE]
- TASK MSG_TASK1 7 message_source_task_1 2048 [EXE]
- TASK MSG_TASK2 7 message_source_task_2 2048 [EXE]
-
-% SEMA NAME
-% =============
- SEMA TASKASEM
- SEMA TASKBSEM
diff --git a/samples/ipm/ipm_demo_lmt/src/hello.c b/samples/ipm/ipm_demo_lmt/src/hello.c
index 79e9308dd..e9348ef08 100644
--- a/samples/ipm/ipm_demo_lmt/src/hello.c
+++ b/samples/ipm/ipm_demo_lmt/src/hello.c
@@ -27,24 +27,25 @@ QUARK_SE_IPM_DEFINE(message_ipm2, 3, QUARK_SE_IPM_OUTBOUND);
/* specify delay between greetings (in ms); compute equivalent in ticks */
-#define SLEEPTIME 1000
-#define SLEEPTICKS (SLEEPTIME * sys_clock_ticks_per_sec / 1000)
-#define SCSS_REGISTER_BASE 0xB0800000
-#define SCSS_SS_STS 0x0604
+#define SLEEPTIME 1000
+#define SCSS_REGISTER_BASE 0xB0800000
+#define SCSS_SS_STS 0x0604
-#define PING_TICKS 100
-#define STACKSIZE 2000
+#define PING_TIME 1000
+#define STACKSIZE 2000
-#define MSG_FIBER_PRI 6
-#define MAIN_FIBER_PRI 2
-#define PING_FIBER_PRI 4
+#define MSG_FIBER_PRI 6
+#define MAIN_FIBER_PRI 2
+#define PING_FIBER_PRI 4
+#define TASK_PRIO 7
-char fiber_stacks[2][STACKSIZE];
+char thread_stacks[2][STACKSIZE];
uint32_t scss_reg(uint32_t offset)
{
volatile uint32_t *ret = (volatile uint32_t *)(SCSS_REGISTER_BASE +
offset);
+
return *ret;
}
@@ -80,44 +81,46 @@ void message_source_task_2(void)
message_source(device_get_binding("message_ipm2"));
}
-void ping_source_fiber(int arg1, int arg2)
+void ping_source_thread(void *arg1, void *arg2, void *arg3)
{
ARG_UNUSED(arg1);
ARG_UNUSED(arg2);
+ ARG_UNUSED(arg3);
struct device *ipm = device_get_binding("ping_ipm");
while (1) {
- fiber_sleep(PING_TICKS);
- printk("pinging arc for counter status\n");
+ k_sleep(PING_TIME);
+ printk("pinging sensor subsystem (ARC) for counter status\n");
ipm_send(ipm, 1, 0, NULL, 0);
}
}
-void main_fiber(int arg1, int arg2)
+void main_thread(void *arg1, void *arg2, void *arg3)
{
ARG_UNUSED(arg1);
ARG_UNUSED(arg2);
+ ARG_UNUSED(arg3);
int ctr = 0;
uint32_t ss_sts;
while (1) {
/* say "hello" */
- printk("Hello from lakemont! (%d) ", ctr++);
+ printk("Hello from application processor (x86)! (%d) ", ctr++);
ss_sts = scss_reg(SCSS_SS_STS);
switch (ss_sts) {
case 0x4000:
- printk("ARC is halted");
+ printk("Sensor Subsystem (ARC) is halted");
break;
case 0x0400:
- printk("ARC is sleeping");
+ printk("Sensor Subsystem (ARC) is sleeping");
break;
case 0:
- printk("ARC is running");
+ printk("Sensor Subsystem (ARC) is running");
break;
default:
- printk("ARC status: %x", ss_sts);
+ printk("Sensor Subsystem (ARC) status: %x", ss_sts);
break;
}
@@ -125,19 +128,28 @@ void main_fiber(int arg1, int arg2)
scss_reg(0x4a0));
/* wait a while, then let other task have a turn */
- fiber_sleep(SLEEPTICKS);
+ k_sleep(SLEEPTIME);
}
}
-void main_task(void)
+K_THREAD_DEFINE(MSG_TASK0, STACKSIZE, message_source_task_0, NULL, NULL, NULL,
+ TASK_PRIO, 0, K_NO_WAIT);
+
+K_THREAD_DEFINE(MSG_TASK1, STACKSIZE, message_source_task_1, NULL, NULL, NULL,
+ TASK_PRIO, 0, K_NO_WAIT);
+
+K_THREAD_DEFINE(MSG_TASK2, STACKSIZE, message_source_task_2, NULL, NULL, NULL,
+ TASK_PRIO, 0, K_NO_WAIT);
+
+void main(void)
{
printk("===== app started ========\n");
- task_fiber_start(&fiber_stacks[0][0], STACKSIZE, main_fiber,
- 0, 0, MAIN_FIBER_PRI, 0);
+ k_thread_spawn(&thread_stacks[0][0], STACKSIZE, main_thread,
+ 0, 0, 0, K_PRIO_COOP(MAIN_FIBER_PRI), 0, 0);
- task_fiber_start(&fiber_stacks[1][0], STACKSIZE, ping_source_fiber,
- 0, 0, PING_FIBER_PRI, 0);
+ k_thread_spawn(&thread_stacks[1][0], STACKSIZE, ping_source_thread,
+ 0, 0, 0, K_PRIO_COOP(PING_FIBER_PRI), 0, 0);
}