diff --git a/stmhal/modnetwork.c b/stmhal/modnetwork.c
index e4d0fcdf9eeac4a3c18485d9fdce660b4a3eea3d..21e279a99d013383ff70a7e9460f6dacbab53275 100644
--- a/stmhal/modnetwork.c
+++ b/stmhal/modnetwork.c
@@ -29,8 +29,6 @@
 #include <string.h>
 #include <errno.h>
 
-#include "stm32f4xx_hal.h"
-
 #include "mpconfig.h"
 #include "nlr.h"
 #include "misc.h"
diff --git a/stmhal/moduselect.c b/stmhal/moduselect.c
index 0d5d6dd4adc6be3059df0a301f45a91e23c7f8fa..b354e486e7f6a739b65c99f227ac01d2c9bed6bd 100644
--- a/stmhal/moduselect.c
+++ b/stmhal/moduselect.c
@@ -28,8 +28,6 @@
 #include <stdio.h>
 #include <errno.h>
 
-#include "stm32f4xx_hal.h"
-
 #include "mpconfig.h"
 #include "misc.h"
 #include "nlr.h"
@@ -37,6 +35,7 @@
 #include "obj.h"
 #include "objlist.h"
 #include "pybioctl.h"
+#include MICROPY_HAL_H
 
 /// \module select - Provides select function to wait for events on a stream
 ///
diff --git a/stmhal/modusocket.c b/stmhal/modusocket.c
index d705636c1a1193bf6f1fede60076bb7af164db12..c2246b3c4df205b2aa90ef77319bcee8a292181a 100644
--- a/stmhal/modusocket.c
+++ b/stmhal/modusocket.c
@@ -29,8 +29,6 @@
 #include <string.h>
 #include <errno.h>
 
-#include "stm32f4xx_hal.h"
-
 #include "mpconfig.h"
 #include "nlr.h"
 #include "misc.h"
@@ -321,7 +319,11 @@ STATIC mp_obj_t socket_settimeout(mp_obj_t self_in, mp_obj_t timeout_in) {
     if (timeout_in == mp_const_none) {
         timeout = -1;
     } else {
+        #if MICROPY_PY_BUILTIN_FLOAT
         timeout = 1000 * mp_obj_get_float(timeout_in);
+        #else
+        timeout = 1000 * mp_obj_get_int(timeout_in);
+        #endif
     }
     int _errno;
     if (self->nic_type->settimeout(self, timeout, &_errno) != 0) {