blob: 332eefbd83eb44daf8e10ccd30a159c50c48ad43 [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
24#ifdef CONFIG_SOC_FAMILY_NRF
25#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/*
38 * Checks if GPIO is set in the required way to remain in serial recovery mode
39 *
40 * @retval false for normal boot, true for serial recovery boot
41 */
42bool io_detect_pin(void);
43
44/*
45 * Checks if board was reset using reset pin and if device should stay in
46 * serial recovery mode
47 *
48 * @retval false for normal boot, true for serial recovery boot
49 */
50bool io_detect_pin_reset(void);
51
52/*
53 * Checks board boot mode via retention subsystem and if device should stay in
54 * serial recovery mode
55 *
56 * @retval false for normal boot, true for serial recovery boot
57 */
58bool io_detect_boot_mode(void);
59
60#ifdef CONFIG_SOC_FAMILY_NRF
61static inline bool io_boot_skip_serial_recovery()
62{
63 uint32_t rr = nrfx_reset_reason_get();
64
65 return !(rr == 0 || (rr & NRFX_RESET_REASON_RESETPIN_MASK));
66}
67#else
68static inline bool io_boot_skip_serial_recovery()
69{
70 return false;
71}
72#endif
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif