Skip to content

Commit b1ad68b

Browse files
committed
Initial import
1 parent aa82af4 commit b1ad68b

File tree

13 files changed

+1176
-0
lines changed

13 files changed

+1176
-0
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "nrfxlib"]
2+
path = nrfxlib
3+
url = https://github.com/NordicPlayground/nrfxlib
4+
[submodule "mdepx"]
5+
path = mdepx
6+
url = https://github.com/machdep/mdepx

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
APP = md009
2+
3+
OSDIR = mdepx
4+
5+
CMD = python3 -B ${OSDIR}/tools/emitter.py
6+
7+
all:
8+
@${CMD} mdepx.conf
9+
@${CROSS_COMPILE}objcopy -O ihex obj/${APP}.elf obj/${APP}.hex
10+
11+
debug:
12+
@${CMD} -d mdepx.conf
13+
@${CROSS_COMPILE}objcopy -O ihex obj/${APP}.elf obj/${APP}.hex
14+
15+
clean:
16+
@rm -rf obj/*
17+
18+
include ${OSDIR}/mk/user.mk

mdepx

Submodule mdepx added at cf17662

mdepx.conf

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
modules mdepx nrfxlib src;
2+
3+
link ./src/ldscript obj/md009.elf;
4+
5+
set-build-flags -mthumb
6+
-mcpu=cortex-m33
7+
-mfpu=fpv5-sp-d16
8+
-mfloat-abi=hard
9+
-g
10+
-nostdlib -nostdinc
11+
-fshort-enums
12+
-fno-builtin-printf
13+
-ffreestanding;
14+
15+
set-build-flags -Wredundant-decls
16+
-Wnested-externs
17+
-Wstrict-prototypes
18+
-Wmissing-prototypes
19+
-Wpointer-arith
20+
-Winline
21+
-Wcast-qual
22+
-Wundef
23+
-Wmissing-include-dirs
24+
-Wall
25+
-Werror;
26+
27+
nrfxlib {
28+
modules bsdlib crypto;
29+
30+
bsdlib {
31+
objects lib/cortex-m33/hard-float/libbsd_nrf9160_xxaa.a;
32+
};
33+
34+
crypto {
35+
modules nrf_oberon;
36+
37+
nrf_oberon {
38+
objects lib/cortex-m33/hard-float/liboberon_3.0.3.a;
39+
};
40+
};
41+
};
42+
43+
src {
44+
append-search-path ../mdepx/arch
45+
../mdepx/include
46+
../mdepx/kernel
47+
../mdepx/lib
48+
../mdepx/
49+
../;
50+
51+
objects bsd_os.o main.o gps.o board.o;
52+
};
53+
54+
mdepx {
55+
modules arch kernel lib;
56+
57+
arch {
58+
modules arm;
59+
60+
arm {
61+
options nrf9160 vfp;
62+
};
63+
};
64+
65+
kernel {
66+
modules callout
67+
cpu
68+
malloc
69+
sched
70+
systm
71+
thread;
72+
73+
callout {
74+
options usec_to_ticks_1mhz;
75+
};
76+
77+
malloc {
78+
options fl fl_wrapper;
79+
};
80+
81+
systm {
82+
options console;
83+
};
84+
85+
thread {
86+
options dynamic_alloc;
87+
};
88+
};
89+
90+
lib {
91+
modules aeabi_softfloat
92+
ftoa
93+
libaeabi
94+
libc
95+
softfloat;
96+
97+
softfloat {
98+
modules source;
99+
100+
source {
101+
modules ARM-VFPv2;
102+
};
103+
104+
options armvfpv2;
105+
};
106+
107+
libc {
108+
modules stdio string stdlib;
109+
};
110+
};
111+
};

nrfxlib

Submodule nrfxlib added at 037cb23

obj/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore

src/board.c

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*-
2+
* Copyright (c) 2018-2020 Ruslan Bukin <[email protected]>
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24+
* SUCH DAMAGE.
25+
*/
26+
27+
#include <sys/cdefs.h>
28+
#include <sys/console.h>
29+
#include <sys/callout.h>
30+
#include <sys/systm.h>
31+
#include <sys/malloc.h>
32+
#include <sys/thread.h>
33+
34+
#include <arm/arm/nvic.h>
35+
#include <arm/nordicsemi/nrf9160.h>
36+
37+
#include "board.h"
38+
39+
struct arm_nvic_softc nvic_sc;
40+
41+
struct nrf_spu_softc spu_sc;
42+
struct nrf_uarte_softc uarte_sc;
43+
struct nrf_power_softc power_sc;
44+
struct nrf_timer_softc timer0_sc;
45+
46+
static void
47+
uart_putchar(int c, void *arg)
48+
{
49+
struct nrf_uarte_softc *sc;
50+
51+
sc = arg;
52+
53+
if (c == '\n')
54+
nrf_uarte_putc(sc, '\r');
55+
56+
nrf_uarte_putc(sc, c);
57+
}
58+
59+
void
60+
board_init(void)
61+
{
62+
63+
nrf_uarte_init(&uarte_sc, BASE_UARTE0,
64+
UART_PIN_TX, UART_PIN_RX, UART_BAUDRATE);
65+
mdx_console_register(uart_putchar, (void *)&uarte_sc);
66+
67+
mdx_fl_init();
68+
mdx_fl_add_region(0x20030000, 0x10000);
69+
70+
nrf_power_init(&power_sc, BASE_POWER);
71+
nrf_timer_init(&timer0_sc, BASE_TIMER0, 1000000);
72+
73+
arm_nvic_init(&nvic_sc, BASE_SCS);
74+
75+
arm_nvic_setup_intr(&nvic_sc, ID_UARTE0, nrf_uarte_intr, &uarte_sc);
76+
arm_nvic_setup_intr(&nvic_sc, ID_TIMER0, nrf_timer_intr, &timer0_sc);
77+
78+
arm_nvic_enable_intr(&nvic_sc, ID_TIMER0);
79+
arm_nvic_enable_intr(&nvic_sc, ID_UARTE0);
80+
81+
printf("mdepx initialized\n");
82+
}

src/board.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*-
2+
* Copyright (c) 2020 Ruslan Bukin <[email protected]>
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24+
* SUCH DAMAGE.
25+
*/
26+
27+
#ifndef _SRC_BOARD_H_
28+
#define _SRC_BOARD_H_
29+
30+
#define UART_PIN_TX 16
31+
#define UART_PIN_RX 15
32+
#define UART_BAUDRATE 115200
33+
34+
#endif /* !_SRC_BOARD_H_ */

src/bsd_os.c

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*-
2+
* Copyright (c) 2019 Ruslan Bukin <[email protected]>
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24+
* SUCH DAMAGE.
25+
*/
26+
27+
#include <sys/cdefs.h>
28+
29+
#include <arm/arm/nvic.h>
30+
#include <arm/nordicsemi/nrf9160.h>
31+
32+
#include <nrfxlib/bsdlib/include/bsd_os.h>
33+
34+
#define BSD_OS_DEBUG
35+
#undef BSD_OS_DEBUG
36+
37+
#ifdef BSD_OS_DEBUG
38+
#define dprintf(fmt, ...) printf(fmt, ##__VA_ARGS__)
39+
#else
40+
#define dprintf(fmt, ...)
41+
#endif
42+
43+
extern struct arm_nvic_softc nvic_sc;
44+
45+
void
46+
bsd_os_init(void)
47+
{
48+
49+
dprintf("%s\n", __func__);
50+
51+
arm_nvic_set_prio(&nvic_sc, ID_EGU1, 6);
52+
arm_nvic_enable_intr(&nvic_sc, ID_EGU1);
53+
54+
arm_nvic_set_prio(&nvic_sc, ID_EGU2, 6);
55+
arm_nvic_enable_intr(&nvic_sc, ID_EGU2);
56+
}
57+
58+
int32_t
59+
bsd_os_timedwait(uint32_t context, int32_t * p_timeout)
60+
{
61+
62+
dprintf("%s: %p\n", __func__, p_timeout);
63+
64+
return (0);
65+
}
66+
67+
void
68+
bsd_os_errno_set(int errno_val)
69+
{
70+
71+
dprintf("%s\n", __func__);
72+
}
73+
74+
void
75+
bsd_os_application_irq_clear(void)
76+
{
77+
78+
dprintf("%s\n", __func__);
79+
arm_nvic_clear_pending(&nvic_sc, ID_EGU1);
80+
}
81+
82+
void
83+
bsd_os_application_irq_set(void)
84+
{
85+
86+
dprintf("%s\n", __func__);
87+
arm_nvic_set_pending(&nvic_sc, ID_EGU1);
88+
}
89+
90+
void
91+
bsd_os_trace_irq_set(void)
92+
{
93+
94+
dprintf("%s\n", __func__);
95+
arm_nvic_set_pending(&nvic_sc, ID_EGU2);
96+
}
97+
98+
void
99+
bsd_os_trace_irq_clear(void)
100+
{
101+
102+
dprintf("%s\n", __func__);
103+
arm_nvic_clear_pending(&nvic_sc, ID_EGU2);
104+
}
105+
106+
int32_t
107+
bsd_os_trace_put(const uint8_t * const p_buffer, uint32_t buf_len)
108+
{
109+
110+
dprintf("%s\n", __func__);
111+
112+
return (0);
113+
}

0 commit comments

Comments
 (0)