-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathnrfx_glue.h
117 lines (85 loc) · 3.41 KB
/
nrfx_glue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
* This file is part of the MicroPython for Monocle project:
* https://github.com/brilliantlabsAR/monocle-micropython
*
* Authored by: Josuah Demangeon ([email protected])
* Raj Nakarja / Brilliant Labs Ltd. ([email protected])
*
* ISC Licence
*
* Copyright © 2023 Brilliant Labs Ltd.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#pragma once
#include "monocle.h"
#include "nrfx.h"
#include "nrf_nvic.h"
#include <soc/nrfx_coredep.h>
#include <soc/nrfx_atomic.h>
#define NRFX_ASSERT(expression) \
do \
{ \
if ((expression) == 0) \
{ \
app_err(0xDEAD0A55); \
} \
} while (0)
#define NRFX_STATIC_ASSERT(expression) \
_Static_assert(expression, "unspecified message")
#define NRFX_IRQ_PRIORITY_SET(irq_number, priority) \
sd_nvic_SetPriority(irq_number, priority)
#define NRFX_IRQ_ENABLE(irq_number) \
sd_nvic_EnableIRQ(irq_number)
#define NRFX_IRQ_IS_ENABLED(irq_number) \
(0 != (NVIC->ISER[irq_number / 32] & (1UL << (irq_number % 32))))
#define NRFX_IRQ_DISABLE(irq_number) \
sd_nvic_DisableIRQ(irq_number)
#define NRFX_IRQ_PENDING_SET(irq_number) \
sd_nvic_SetPendingIRQ(irq_number)
#define NRFX_IRQ_PENDING_CLEAR(irq_number) \
sd_nvic_ClearPendingIRQ(irq_number)
#define NRFX_IRQ_IS_PENDING(irq_number) \
NVIC_GetPendingIRQ(irq_number)
#define NRFX_CRITICAL_SECTION_ENTER() \
{ \
uint8_t _is_nested_critical_region; \
sd_nvic_critical_region_enter(&_is_nested_critical_region);
#define NRFX_CRITICAL_SECTION_EXIT() \
sd_nvic_critical_region_exit(_is_nested_critical_region); \
}
#define NRFX_DELAY_DWT_BASED 0
#define NRFX_DELAY_US(us_time) \
nrfx_coredep_delay_us(us_time)
#define nrfx_atomic_t nrfx_atomic_u32_t
#define NRFX_ATOMIC_FETCH_STORE(p_data, value) \
nrfx_atomic_u32_fetch_store(p_data, value)
#define NRFX_ATOMIC_FETCH_OR(p_data, value) \
nrfx_atomic_u32_fetch_or(p_data, value)
#define NRFX_ATOMIC_FETCH_AND(p_data, value) \
nrfx_atomic_u32_fetch_and(p_data, value)
#define NRFX_ATOMIC_FETCH_XOR(p_data, value) \
nrfx_atomic_u32_fetch_xor(p_data, value)
#define NRFX_ATOMIC_FETCH_ADD(p_data, value) \
nrfx_atomic_u32_fetch_add(p_data, value)
#define NRFX_ATOMIC_FETCH_SUB(p_data, value) \
nrfx_atomic_u32_fetch_sub(p_data, value)
#define NRFX_CUSTOM_ERROR_CODES 0
#define NRFX_EVENT_READBACK_ENABLED 1
#define NRFX_DPPI_CHANNELS_USED 0
#define NRFX_DPPI_GROUPS_USED 0
#define NRFX_PPI_CHANNELS_USED 0
#define NRFX_PPI_GROUPS_USED 0
#define NRFX_GPIOTE_CHANNELS_USED 0
#define NRFX_EGUS_USED 0
#define NRFX_TIMERS_USED 0