NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
os.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef _OS_H
21#define _OS_H
22
23#include <assert.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#if !defined __cplusplus
30#define static_assert _Static_assert
31#endif
32
33#include "../syscfg/syscfg.h"
34#include "nimble/nimble/include/nimble/nimble_npl.h"
35
36#define OS_ALIGN(__n, __a) ( \
37 (((__n) & ((__a) - 1)) == 0) ? \
38 (__n) : \
39 ((__n) + ((__a) - ((__n) & ((__a) - 1)))) \
40 )
41#define OS_ALIGNMENT (BLE_NPL_OS_ALIGNMENT)
42
43typedef uint32_t os_sr_t;
44#define OS_ENTER_CRITICAL(_sr) (_sr = ble_npl_hw_enter_critical())
45#define OS_EXIT_CRITICAL(_sr) (ble_npl_hw_exit_critical(_sr))
46#define OS_ASSERT_CRITICAL() assert(ble_npl_hw_is_in_critical())
47
48/* Mynewt components (not abstracted in NPL) */
49#include "endian.h"
50#include "queue.h"
51#include "os_error.h"
52#include "os_mbuf.h"
53#include "os_mempool.h"
54
55#ifdef __cplusplus
56}
57#endif
58
59#endif /* _OS_H */