Skip to content
This repository was archived by the owner on Mar 17, 2020. It is now read-only.

Commit 1bb00bb

Browse files
committed
Initial Zephyr server
1 parent fee9875 commit 1bb00bb

File tree

6 files changed

+88
-0
lines changed

6 files changed

+88
-0
lines changed

zephyr/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
MDEF_FILE = prj.mdef
2+
KERNEL_TYPE = micro
3+
BOARD ?= qemu_x86
4+
CONF_FILE = prj.conf
5+
6+
include ${ZEPHYR_BASE}/Makefile.inc

zephyr/README.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Source the zephyr-project/zephyr-env.sh to get up the environment
2+
3+
--------------------------------------------------------------------------------
4+
5+
Building and Running Project:
6+
7+
This microkernel project outputs to the console. It can be built and executed
8+
on QEMU as follows:
9+
10+
make qemu
11+
12+
--------------------------------------------------------------------------------
13+
14+
Troubleshooting:
15+
16+
Problems caused by out-dated project information can be addressed by
17+
issuing one of the following commands then rebuilding the project:
18+
19+
make clean # discard results of previous builds
20+
# but keep existing configuration info
21+
or
22+
make pristine # discard results of previous builds
23+
# and restore pre-defined configuration info
24+
25+
--------------------------------------------------------------------------------

zephyr/prj.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CONFIG_STDOUT_CONSOLE=y
2+
CONFIG_PRINTK=y
3+
CONFIG_PWM=y
4+
CONFIG_NANO_TIMERS=y
5+
CONFIG_NANO_TIMEOUTS=y
6+

zephyr/prj.mdef

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
% Application : Hello demo
2+
3+
% TASK NAME PRIO ENTRY STACK GROUPS
4+
% ==================================
5+
TASK TASKA 7 main 2048 [EXE]

zephyr/src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
obj-y = main.o

zephyr/src/main.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <zephyr.h>
2+
#include <device.h>
3+
#include <pwm.h>
4+
#include <sys_clock.h>
5+
6+
#if defined(CONFIG_STDOUT_CONSOLE)
7+
#include <stdio.h>
8+
#define PRINT printf
9+
#else
10+
#include <misc/printk.h>
11+
#define PRINT printk
12+
#endif
13+
14+
#define IO3_RED "PWM_0"
15+
#define IO5_GREEN "PWM_1"
16+
#define IO6_BLUE "PWM_2"
17+
18+
#define SLEEPTICKS SECONDS(1)
19+
20+
void main(void)
21+
{
22+
struct nano_timer timer;
23+
void *timer_data[1];
24+
25+
struct device *red, *green, *blue;
26+
27+
nano_timer_init(&timer, timer_data);
28+
29+
PRINT("Zephyr WebBluetooth demo\n");
30+
31+
red = device_get_binding(IO3_RED);
32+
green = device_get_binding(IO5_GREEN);
33+
blue = device_get_binding(IO6_BLUE);
34+
35+
if (!red || !green || !blue) {
36+
PRINT("Cannot find LED connected to pin 3 (red), 5 (green) and 6 (blue)!\n");
37+
}
38+
39+
while (1) {
40+
pwm_pin_set_values(red, 1024, SLEEPTICKS, 0);
41+
42+
nano_timer_start(&timer, SLEEPTICKS);
43+
nano_timer_test(&timer, TICKS_UNLIMITED);
44+
}
45+
}

0 commit comments

Comments
 (0)