Skip to content

Commit 36e9029

Browse files
pabigotnvlsianpu
authored andcommitted
boot: zephyr: move to non-deprecated GPIO flags
GPIO_DIR_IN has been replaced by GPIO_INPUT, GPIO_PUD_PULL_UP by GPIO_PULL_UP, and gpio_pin_read() by gpio_pin_get_raw(). Update the code to use the preferred API if it available. This avoids deprecation warnings in the build. Signed-off-by: Peter Bigot <[email protected]>
1 parent 1b19d2a commit 36e9029

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

boot/zephyr/main.c

+17-3
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,32 @@ void main(void)
201201
#ifdef CONFIG_MCUBOOT_SERIAL
202202

203203
struct device *detect_port;
204-
u32_t detect_value;
204+
u32_t detect_value = !CONFIG_BOOT_SERIAL_DETECT_PIN_VAL;
205205

206206
detect_port = device_get_binding(CONFIG_BOOT_SERIAL_DETECT_PORT);
207207
__ASSERT(detect_port, "Error: Bad port for boot serial detection.\n");
208208

209+
/* The default presence value is 0 which would normally be
210+
* active-low, but historically the raw value was checked so we'll
211+
* use the raw interface.
212+
*/
209213
rc = gpio_pin_configure(detect_port, CONFIG_BOOT_SERIAL_DETECT_PIN,
210-
GPIO_DIR_IN | GPIO_PUD_PULL_UP);
214+
#ifdef GPIO_INPUT
215+
GPIO_INPUT | GPIO_PULL_UP
216+
#else
217+
GPIO_DIR_IN | GPIO_PUD_PULL_UP
218+
#endif
219+
);
211220
__ASSERT(rc == 0, "Error of boot detect pin initialization.\n");
212221

222+
#ifdef GPIO_INPUT
223+
rc = gpio_pin_get_raw(detect_port, CONFIG_BOOT_SERIAL_DETECT_PIN);
224+
detect_value = rc;
225+
#else
213226
rc = gpio_pin_read(detect_port, CONFIG_BOOT_SERIAL_DETECT_PIN,
214227
&detect_value);
215-
__ASSERT(rc == 0, "Error of the reading the detect pin.\n");
228+
#endif
229+
__ASSERT(rc >= 0, "Error of the reading the detect pin.\n");
216230
if (detect_value == CONFIG_BOOT_SERIAL_DETECT_PIN_VAL &&
217231
!boot_skip_serial_recovery()) {
218232
BOOT_LOG_INF("Enter the serial recovery mode");

0 commit comments

Comments
 (0)