8000 nrf5/hal: Adding hal_irq.h which defines a set of static inline funct… · boneskull/circuitpython@852aaba · GitHub
[go: up one dir, main page]

Skip to content

Commit 852aaba

Browse files
committed
nrf5/hal: Adding hal_irq.h which defines a set of static inline functions to do nvic irq operations.
1 parent 9ddd62e commit 852aaba

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

nrf5/hal/hal_irq.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* This file is part of the Micro Python project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2017 Glenn Ruben Bakke
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#ifndef HAL_IRQ_H__
28+
#define HAL_IRQ_H__
29+
30+
#include <stdint.h>
31+
32+
#include "nrf.h"
33+
34+
static inline void hal_irq_clear(uint32_t irq_num) {
35+
NVIC_ClearPendingIRQ(irq_num);
36+
}
37+
38+
static inline void hal_irq_enable(uint32_t irq_num) {
39+
hal_irq_clear(irq_num);
40+
NVIC_EnableIRQ(irq_num);
41+
}
42+
43+
static inline void hal_irq_disable(uint32_t irq_num) {
44+
NVIC_DisableIRQ(irq_num);
45+
}
46+
47+
static inline void hal_irq_priority(uint32_t irq_num, uint8_t priority) {
48+
NVIC_SetPriority(irq_num, priority);
49+
}
50+
51+
#endif // HAL_IRQ_H__

0 commit comments

Comments
 (0)
0