mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-23 13:33:49 +01:00
drivers/atwinc15x0: add timeout to init
This enables a timeout on init to not hang there forever if init fails but instead return an error.
This commit is contained in:
parent
9827e573c0
commit
9c8fa57f4d
@ -0,0 +1,29 @@
|
||||
From 9664046ab3fb2355fc3058bef90cc8727a67730b Mon Sep 17 00:00:00 2001
|
||||
From: Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
Date: Wed, 15 Jun 2022 18:06:09 +0200
|
||||
Subject: [PATCH 1/3] nmasic: always use 2000 retries
|
||||
|
||||
---
|
||||
src/driver/source/nmasic.c | 6 +-----
|
||||
1 file changed, 1 insertion(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/driver/source/nmasic.c b/src/driver/source/nmasic.c
|
||||
index 91c0e5a..9f46398 100644
|
||||
--- a/src/driver/source/nmasic.c
|
||||
+++ b/src/driver/source/nmasic.c
|
||||
@@ -59,11 +59,7 @@
|
||||
|
||||
|
||||
|
||||
-#ifdef ARDUINO
|
||||
-#define TIMEOUT (2000)
|
||||
-#else
|
||||
-#define TIMEOUT (0xfffffffful)
|
||||
-#endif
|
||||
+#define TIMEOUT (2000)
|
||||
#define WAKUP_TRAILS_TIMEOUT (4)
|
||||
|
||||
sint8 chip_apply_conf(uint32 u32Conf)
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
From 142506c9ed4e2d3a1c59cf39cd86473074981c6a Mon Sep 17 00:00:00 2001
|
||||
From: Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
Date: Wed, 15 Jun 2022 14:01:42 +0200
|
||||
Subject: [PATCH 2/3] nmasic: limit retries in wait_for_bootrom()
|
||||
|
||||
If no device is connected or init failed, wait_for_bootrom() will
|
||||
be stuck in an infinite loop trying to get a result from nm_read_reg().
|
||||
|
||||
Place an upper limit on the number of retries so we can recover from
|
||||
this instead of being stuck here.
|
||||
---
|
||||
src/driver/source/nmasic.c | 9 ++++++++-
|
||||
1 file changed, 8 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/driver/source/nmasic.c b/src/driver/source/nmasic.c
|
||||
index 9f46398..b77dc5a 100644
|
||||
--- a/src/driver/source/nmasic.c
|
||||
+++ b/src/driver/source/nmasic.c
|
||||
@@ -400,6 +400,7 @@ sint8 chip_reset(void)
|
||||
sint8 wait_for_bootrom(uint8 arg)
|
||||
{
|
||||
sint8 ret = M2M_SUCCESS;
|
||||
+ uint16 retries = TIMEOUT;
|
||||
uint32 reg = 0, cnt = 0;
|
||||
uint32 u32GpReg1 = 0;
|
||||
uint32 u32DriverVerInfo = M2M_MAKE_VERSION_INFO(M2M_RELEASE_VERSION_MAJOR_NO,\
|
||||
@@ -409,13 +410,19 @@ sint8 wait_for_bootrom(uint8 arg)
|
||||
|
||||
|
||||
reg = 0;
|
||||
- while(1) {
|
||||
+ while(--retries) {
|
||||
reg = nm_read_reg(0x1014); /* wait for efuse loading done */
|
||||
if (reg & 0x80000000) {
|
||||
break;
|
||||
}
|
||||
nm_bsp_sleep(1); /* TODO: Why bus error if this delay is not here. */
|
||||
}
|
||||
+
|
||||
+ /* communication with device failed */
|
||||
+ if(retries == 0) {
|
||||
+ return M2M_ERR_INIT;
|
||||
+ }
|
||||
+
|
||||
reg = nm_read_reg(M2M_WAIT_FOR_HOST_REG);
|
||||
reg &= 0x1;
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
From c1efd943abeb7ddf643bdb0849d1d70ae748ac5d Mon Sep 17 00:00:00 2001
|
||||
From: Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
Date: Wed, 15 Jun 2022 18:05:45 +0200
|
||||
Subject: [PATCH 3/3] nmasic: limit retries in chip_apply_conf()
|
||||
|
||||
---
|
||||
src/driver/source/nmasic.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/driver/source/nmasic.c b/src/driver/source/nmasic.c
|
||||
index b77dc5a..bcc766d 100644
|
||||
--- a/src/driver/source/nmasic.c
|
||||
+++ b/src/driver/source/nmasic.c
|
||||
@@ -65,6 +65,7 @@
|
||||
sint8 chip_apply_conf(uint32 u32Conf)
|
||||
{
|
||||
sint8 ret = M2M_SUCCESS;
|
||||
+ uint16 retries = TIMEOUT;
|
||||
uint32 val32 = u32Conf;
|
||||
|
||||
#if (defined __ENABLE_PMU__) || (defined CONF_WINC_INT_PMU)
|
||||
@@ -98,9 +99,9 @@ sint8 chip_apply_conf(uint32 u32Conf)
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
- } while(1);
|
||||
+ } while(--retries);
|
||||
|
||||
- return M2M_SUCCESS;
|
||||
+ return retries ? M2M_SUCCESS : M2M_ERR_TIME_OUT;
|
||||
}
|
||||
void chip_idle(void)
|
||||
{
|
||||
--
|
||||
2.34.1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user