summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-06-29 00:00:05 -0400
committerDan Halbert <halbert@halwitz.org>2018-06-29 00:00:05 -0400
commitb4fd77bb7c041d2855dba826f380ce66944c23d4 (patch)
tree5aa046d6343f47072fa425b93c13c8f0a15a2c3f
parent52a11547cbd3d8bf132bdfdd2fa3f804920665f3 (diff)
fix nrf and esp8266 builds for OneWire fix
-rw-r--r--ports/atmel-samd/mphalport.c26
-rw-r--r--ports/esp8266/Makefile1
-rw-r--r--ports/esp8266/mphalport.c33
-rw-r--r--ports/esp8266/mphalport.h34
-rw-r--r--ports/nrf/mphalport.c4
5 files changed, 97 insertions, 1 deletions
diff --git a/ports/atmel-samd/mphalport.c b/ports/atmel-samd/mphalport.c
index dd6a14713..7bb423a3e 100644
--- a/ports/atmel-samd/mphalport.c
+++ b/ports/atmel-samd/mphalport.c
@@ -1,3 +1,29 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Scott Shawcroft
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
#include <string.h>
#include "lib/mp-readline/readline.h"
diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile
index 8fabd3412..02b75eadd 100644
--- a/ports/esp8266/Makefile
+++ b/ports/esp8266/Makefile
@@ -92,6 +92,7 @@ SRC_C = \
machine_hspi.c \
modesp.c \
modnetwork.c \
+ mphalport.c \
ets_alt_task.c \
fatfs_port.c \
posix_helpers.c \
diff --git a/ports/esp8266/mphalport.c b/ports/esp8266/mphalport.c
new file mode 100644
index 000000000..e22facef0
--- /dev/null
+++ b/ports/esp8266/mphalport.c
@@ -0,0 +1,33 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "esp_mphal.h"
+
+#include <stdint.h>
+
+void mp_hal_delay_us_loop(uint32_t us) {
+ mp_hal_delay_us(us);
+}
diff --git a/ports/esp8266/mphalport.h b/ports/esp8266/mphalport.h
new file mode 100644
index 000000000..9cf2fcdd6
--- /dev/null
+++ b/ports/esp8266/mphalport.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_ESP8266_MPHALPORT_H
+#define MICROPY_INCLUDED_ESP8266_MPHALPORT_H
+
+#include <stdint.h>
+
+void mp_hal_delay_us_loop(uint32_t us);
+
+#endif // MICROPY_INCLUDED_ESP8266_MPHALPORT_H
diff --git a/ports/nrf/mphalport.c b/ports/nrf/mphalport.c
index 1f732e188..014d410ec 100644
--- a/ports/nrf/mphalport.c
+++ b/ports/nrf/mphalport.c
@@ -32,6 +32,8 @@
#include "py/mperrno.h"
#include "hal_uart.h"
+extern uint32_t common_hal_mcu_processor_get_frequency(void);
+
#define UART_INSTANCE UART_BASE(0)
FIL* boot_output_file;
@@ -90,7 +92,7 @@ void mp_hal_stdout_tx_str(const char *str) {
// Testing done at 48 MHz on SAMD21 and 120 MHz on SAMD51 (cache on).
// TODO: Test on NRF. For now, use SAMD51 calibration, even though nRF52 runs slower.
// Fraction should compensate.
-#define DELAY_LOOP_ITERATIONS_PER_US (30U*120000000U) / common_hal_mcu_processor_get_frequency())
+#define DELAY_LOOP_ITERATIONS_PER_US ( (30U*120000000U) / common_hal_mcu_processor_get_frequency())
void mp_hal_delay_us_loop(uint32_t us) {
for (uint32_t i = us*DELAY_LOOP_ITERATIONS_PER_US; i > 0; i--) {