1 /*
2  * Copyright (c) 2023 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef _NRF_HW_MODEL_GPIO_H
8 #define _NRF_HW_MODEL_GPIO_H
9 
10 #include "NRF_GPIO_backend.h"
11 #include <stdbool.h>
12 
13 #ifdef __cplusplus
14 extern "C"{
15 #endif
16 
17 #define NRF_GPIOS 2
18 #define NRF_GPIO_MAX_PINS_PER_PORT 32
19 #define NRF_GPIO_PORTS_PINS {32, 10} /* Number of IOs per port */
20 
21 /*
22  * Callback another peripheral or tests can register if it wants to be called when an
23  * input/output is toggled.
24  *
25  * The callback will get as inputs:
26  *  * port: the GPIO port which toggled,
27  *  * n: the pin in the port
28  *  * value: the new value (true: high, false: low)
29  */
30 typedef void (*nrf_gpio_input_callback_t)(unsigned int port, unsigned int n, bool value);
31 
32 
33 unsigned int nrf_gpio_get_number_pins_in_port(int port);
34 
35 void nrf_gpio_test_register_in_callback(nrf_gpio_input_callback_t fptr);
36 void nrf_gpio_test_register_out_callback(nrf_gpio_input_callback_t fptr);
37 void nrf_gpio_test_change_pin_level(unsigned int port, unsigned int n, bool value);
38 bool nrf_gpio_get_pin_level(unsigned int port, unsigned int n);
39 
40 void nrf_gpio_peri_pin_control(unsigned int port, unsigned int n,
41 			      int override_output, int override_input, int override_dir,
42 			      nrf_gpio_input_callback_t fptr, int new_level);
43 void nrf_gpio_peri_change_output(unsigned int port, unsigned int n, bool value);
44 
45 bool nrf_gpio_get_detect_level(unsigned int port);
46 
47 void nrf_gpio_regw_sideeffects_OUT(unsigned int port);
48 void nrf_gpio_regw_sideeffects_OUTSET(unsigned int port);
49 void nrf_gpio_regw_sideeffects_OUTCLR(unsigned int port);
50 void nrf_gpio_regw_sideeffects_DIR(unsigned int port);
51 void nrf_gpio_regw_sideeffects_DIRSET(unsigned int port);
52 void nrf_gpio_regw_sideeffects_DIRCLR(unsigned int port);
53 void nrf_gpio_regw_sideeffects_LATCH(unsigned int port);
54 void nrf_gpio_regw_sideeffects_DETECTMODE(unsigned int port);
55 void nrf_gpio_regw_sideeffects_PIN_CNF(unsigned int port,unsigned  int n);
56 
57 void nrf_gpio_eval_input(unsigned int port, unsigned int n, bool value);
58 
59 #ifdef __cplusplus
60 }
61 #endif
62 
63 #endif /* _NRF_HW_MODEL_GPIO_H */
64