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 /* 18 * Callback another peripheral or tests can register if it wants to be called when an 19 * input/output is toggled. 20 * 21 * The callback will get as inputs: 22 * * port: the GPIO port which toggled, 23 * * n: the pin in the port 24 * * value: the new value (true: high, false: low) 25 */ 26 typedef void (*nrf_gpio_input_callback_t)(unsigned int port, unsigned int n, bool value); 27 typedef void (*nrf_gpio_input_callback_hw_t)(unsigned int port, unsigned int n, bool value, void *f_data); 28 29 30 unsigned int nrf_gpio_get_number_pins_in_port(int port); 31 32 void nrf_gpio_test_register_in_callback(nrf_gpio_input_callback_t fptr); 33 void nrf_gpio_test_register_out_callback(nrf_gpio_input_callback_t fptr); 34 void nrf_gpio_test_change_pin_level(unsigned int port, unsigned int n, bool value); 35 bool nrf_gpio_get_pin_level(unsigned int port, unsigned int n); 36 37 void nrf_gpio_peri_pin_control(unsigned int port, unsigned int n, 38 int override_output, int override_input, int override_dir, 39 nrf_gpio_input_callback_hw_t fptr, void *fptr_data, int new_level); 40 void nrf_gpio_peri_change_output(unsigned int port, unsigned int n, bool value); 41 42 bool nrf_gpio_get_detect_level(unsigned int port); 43 44 void nrf_gpio_regw_sideeffects_OUT(unsigned int port); 45 void nrf_gpio_regw_sideeffects_OUTSET(unsigned int port); 46 void nrf_gpio_regw_sideeffects_OUTCLR(unsigned int port); 47 void nrf_gpio_regw_sideeffects_DIR(unsigned int port); 48 void nrf_gpio_regw_sideeffects_DIRSET(unsigned int port); 49 void nrf_gpio_regw_sideeffects_DIRCLR(unsigned int port); 50 void nrf_gpio_regw_sideeffects_LATCH(unsigned int port); 51 void nrf_gpio_regw_sideeffects_DETECTMODE(unsigned int port); 52 void nrf_gpio_regw_sideeffects_PIN_CNF(unsigned int port,unsigned int n); 53 54 void nrf_gpio_eval_input(unsigned int port, unsigned int n, bool value); 55 56 #ifdef __cplusplus 57 } 58 #endif 59 60 #endif /* _NRF_HW_MODEL_GPIO_H */ 61