blob: 563281fa2c5519adc1de72f7c60995e5e60f8c13 [file] [log] [blame]
Jamie McCrae433b8482023-08-16 07:33:24 +01001/*
2 * Copyright (c) 2012-2014 Wind River Systems, Inc.
3 * Copyright (c) 2020 Arm Limited
4 * Copyright (c) 2021-2023 Nordic Semiconductor ASA
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * 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, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#ifndef H_IO_
20#define H_IO_
21
22#include <stddef.h>
23
Jamie McCrae8b4c70a2024-03-07 07:51:55 +000024#ifdef CONFIG_SOC_FAMILY_NORDIC_NRF
Jamie McCrae433b8482023-08-16 07:33:24 +010025#include <helpers/nrfx_reset_reason.h>
26#endif
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/*
33 * Initialises the configured LED.
34 */
35void io_led_init(void);
36
37/*
Piotr Dymacz2a74a2b2023-12-05 14:26:22 +010038 * Sets value of the configured LED.
39 */
40void io_led_set(int value);
41
42/*
Jamie McCrae433b8482023-08-16 07:33:24 +010043 * Checks if GPIO is set in the required way to remain in serial recovery mode
44 *
45 * @retval false for normal boot, true for serial recovery boot
46 */
47bool io_detect_pin(void);
48
49/*
50 * Checks if board was reset using reset pin and if device should stay in
51 * serial recovery mode
52 *
53 * @retval false for normal boot, true for serial recovery boot
54 */
55bool io_detect_pin_reset(void);
56
57/*
58 * Checks board boot mode via retention subsystem and if device should stay in
59 * serial recovery mode
60 *
61 * @retval false for normal boot, true for serial recovery boot
62 */
63bool io_detect_boot_mode(void);
64
Jamie McCrae8b4c70a2024-03-07 07:51:55 +000065#ifdef CONFIG_SOC_FAMILY_NORDIC_NRF
Jamie McCrae433b8482023-08-16 07:33:24 +010066static inline bool io_boot_skip_serial_recovery()
67{
68 uint32_t rr = nrfx_reset_reason_get();
69
70 return !(rr == 0 || (rr & NRFX_RESET_REASON_RESETPIN_MASK));
71}
72#else
73static inline bool io_boot_skip_serial_recovery()
74{
75 return false;
76}
77#endif
78
79#ifdef __cplusplus
80}
81#endif
82
83#endif