diff --git a/README.md b/README.md
index 54d3356..fd688d7 100644
--- a/README.md
+++ b/README.md
@@ -1117,17 +1117,17 @@ mechanism. We use newlib, so let's modify `_write()` syscall to print to the
UART3.
Before that, let's organise our source code in the following way:
-- move all API definitions to the file `mcu.h`
+- move all API definitions to the file `hal.h` (Harware Abstraction Layer)
- move startup code to `startup.c`
- create an empty file `syscalls.c` for newlib "syscalls"
- modify Makefile to add `syscalls.c` and `startup.c` to the build
-After moving all API definitions to the `mcu.h`, our `main.c` file becomes
+After moving all API definitions to the `hal.h`, our `main.c` file becomes
quite compact. Note that it does not have any mention of the low-level
registers, just a high level API functions that are easy to understand:
```c
-#include "mcu.h"
+#include "hal.h"
static volatile uint32_t s_ticks;
void SysTick_Handler(void) {
@@ -1157,7 +1157,7 @@ Great, now let's retarget printf to the UART3. In the empty syscalls.c,
copy/paste the following code:
```c
-#include "mcu.h"
+#include "hal.h"
int _write(int fd, char *ptr, int len) {
(void) fd, (void) ptr, (void) len;
@@ -1272,7 +1272,7 @@ Choose our firmware.elf file:
Leave the defaults on the next screen, click Finish, and we've got our
-debugger loaded (note the mcu.h source code is picked up):
+debugger loaded (note the hal.h source code is picked up):
![](images/ozone4.png)
@@ -1329,8 +1329,8 @@ The ST CMSIS package also provides startup files for all their MCUs. We
can use those instead of hand-writing the startup.c. The ST-provided startup
file calls `SystemInit()` function, so we define it in the `main.c`.
-Now, let's replace our API functions in the `mcu.h` using CMSIS definitions,
-and leave the rest of the firmware intact. From the `mcu.h`, remove all
+Now, let's replace our API functions in the `hal.h` using CMSIS definitions,
+and leave the rest of the firmware intact. From the `hal.h`, remove all
peripheral API and definitions, and leave only standard C inludes, vendor CMSIS
include, defines to PIN, BIT, FREQ, and `timer_expired()` helper function.
@@ -1343,7 +1343,7 @@ Let's start from `systick_init()`. ARM core CMSIS headers provide a
Next goes `gpio_set_mode()` function. The `stm32f429xx.h` header has
`GPIO_TypeDef` structure, identical to our `struct gpio`. Let's use it:
-https://github.com/cpq/bare-metal-programming-guide/blob/785aa2ead0432fc67327781c82b9c41149fba158/step-5-cmsis/mcu.h#L24-L33
+https://github.com/cpq/bare-metal-programming-guide/blob/785aa2ead0432fc67327781c82b9c41149fba158/step-5-cmsis/hal.h#L24-L33
The `gpio_set_af()` and `gpio_write()` functions is also trivial -
simply replace `struct gpio` with `GPIO_TypeDef`, and that's all.
diff --git a/README_zh-CN.md b/README_zh-CN.md
index cab47fd..b0bcd56 100644
--- a/README_zh-CN.md
+++ b/README_zh-CN.md
@@ -894,15 +894,15 @@ newlib实现了一些标准C函数,特别是文件输入输出操作,并且
在那之前,我们先重新组织下源码结构:
-- 把所有API定义放到 `mcu.h` 文件中
+- 把所有API定义放到 `hal.h` 文件中
- 把启动代码放到 `startup.c` 文件中
- 为newlib的系统调用创建一个空文件 `syscalls.c`
- 修改Makefile,把 `syscalls.c` 和 `startup.c` 加到build中
-将所有 API 定义移动到 `mcu.h` 后,`main.c` 文件变得相当紧凑。注意我们还没提到底层寄存器,高级API函数很容易理解:
+将所有 API 定义移动到 `hal.h` 后,`main.c` 文件变得相当紧凑。注意我们还没提到底层寄存器,高级API函数很容易理解:
```c
-#include "mcu.h"
+#include "hal.h"
static volatile uint32_t s_ticks;
void SysTick_Handler(void) {
@@ -931,7 +931,7 @@ int main(void) {
现在我们把 `printf()` 重定向到串口3,在空的 `syscalls.c` 文件中拷入一下内容:
```c
-#include "mcu.h"
+#include "hal.h"
int _write(int fd, char *ptr, int len) {
(void) fd, (void) ptr, (void) len;
@@ -1027,7 +1027,7 @@ LED: 0, tick: 1000
-接下来的步骤保持默认,点击“完成”,调试器已经载入(可以看到`mcu.h`源码被拾取):
+接下来的步骤保持默认,点击“完成”,调试器已经载入(可以看到`hal.h`源码被拾取):
@@ -1060,7 +1060,7 @@ LED: 0, tick: 1000
CMSIS代表通用微控制器软件接口标准(Common Microcontroller Software Interface Standard),因此它是MCU制造商指定外设API的共同基础。 因为CMSIS是一种ARM标准,并且CMSIS头文件由MCU厂商提供,所以是权威的来源。因此,使用供应商头文件是首选方法,而不是手动编写定义。
-在这一节,我们将使用供应商CMSIS头文件替换 `mcu.h` 中的API函数,并保持固件其它部分不变。
+在这一节,我们将使用供应商CMSIS头文件替换 `hal.h` 中的API函数,并保持固件其它部分不变。
STM32 F4系列的CMSIS头文件在这个[仓库](https://github.com/STMicroelectronics/cmsis_device_f4),从那里将以下文件拷到我们的固件文件夹[step-5-cmsis](step-5-cmsis):
@@ -1074,7 +1074,7 @@ Those two files depend on a standard ARM CMSIS includes, download them too:
- [cmsis_compiler.h](https://raw.githubusercontent.com/STMicroelectronics/STM32CubeF4/master/Drivers/CMSIS/Core/Include/cmsis_compiler.h)
- [mpu_armv7.h](https://raw.githubusercontent.com/STMicroelectronics/STM32CubeF4/master/Drivers/CMSIS/Core/Include/mpu_armv7.h)
-然后移除 `mcu.h` 中所有外设API和定义,只留下标准C包含、供应商CMSIS包含,引脚定义等:
+然后移除 `hal.h` 中所有外设API和定义,只留下标准C包含、供应商CMSIS包含,引脚定义等:
```c
#pragma once
diff --git a/step-4-printf/mcu.h b/step-4-printf/hal.h
similarity index 100%
rename from step-4-printf/mcu.h
rename to step-4-printf/hal.h
diff --git a/step-4-printf/main.c b/step-4-printf/main.c
index 8ebaa66..50fa5f2 100644
--- a/step-4-printf/main.c
+++ b/step-4-printf/main.c
@@ -1,7 +1,7 @@
// Copyright (c) 2022 Cesanta Software Limited
// All rights reserved
-#include "mcu.h"
+#include "hal.h"
static volatile uint32_t s_ticks;
void SysTick_Handler(void) {
diff --git a/step-4-printf/syscalls.c b/step-4-printf/syscalls.c
index 8214418..b0b85a2 100644
--- a/step-4-printf/syscalls.c
+++ b/step-4-printf/syscalls.c
@@ -3,7 +3,7 @@
#include
-#include "mcu.h"
+#include "hal.h"
int _fstat(int fd, struct stat *st) {
if (fd < 0) return -1;
diff --git a/step-5-cmsis/Makefile b/step-5-cmsis/Makefile
index b818ade..435cff7 100644
--- a/step-5-cmsis/Makefile
+++ b/step-5-cmsis/Makefile
@@ -15,7 +15,7 @@ endif
build: firmware.bin
-firmware.elf: cmsis_core cmsis_f4 mcu.h link.ld Makefile $(SOURCES)
+firmware.elf: cmsis_core cmsis_f4 hal.h link.ld Makefile $(SOURCES)
arm-none-eabi-gcc $(SOURCES) $(CFLAGS) $(CFLAGS_EXTRA) $(LDFLAGS) -o $@
firmware.bin: firmware.elf
diff --git a/step-5-cmsis/mcu.h b/step-5-cmsis/hal.h
similarity index 100%
rename from step-5-cmsis/mcu.h
rename to step-5-cmsis/hal.h
diff --git a/step-5-cmsis/main.c b/step-5-cmsis/main.c
index 9a70cd2..76f0d07 100644
--- a/step-5-cmsis/main.c
+++ b/step-5-cmsis/main.c
@@ -1,7 +1,7 @@
// Copyright (c) 2022 Cesanta Software Limited
// All rights reserved
-#include "mcu.h"
+#include "hal.h"
static volatile uint32_t s_ticks;
void SysTick_Handler(void) {
diff --git a/step-5-cmsis/syscalls.c b/step-5-cmsis/syscalls.c
index 96eac96..fbf0b74 100644
--- a/step-5-cmsis/syscalls.c
+++ b/step-5-cmsis/syscalls.c
@@ -3,7 +3,7 @@
#include
-#include "mcu.h"
+#include "hal.h"
int _fstat(int fd, struct stat *st) {
if (fd < 0) return -1;
diff --git a/step-6-clock/mcu.h b/step-6-clock/hal.h
similarity index 100%
rename from step-6-clock/mcu.h
rename to step-6-clock/hal.h
diff --git a/step-6-clock/main.c b/step-6-clock/main.c
index 439c4bc..0cbb702 100644
--- a/step-6-clock/main.c
+++ b/step-6-clock/main.c
@@ -1,7 +1,7 @@
// Copyright (c) 2022 Cesanta Software Limited
// All rights reserved
-#include "mcu.h"
+#include "hal.h"
static volatile uint32_t s_ticks;
void SysTick_Handler(void) { s_ticks++; }
diff --git a/step-6-clock/syscalls.c b/step-6-clock/syscalls.c
index 8214418..b0b85a2 100644
--- a/step-6-clock/syscalls.c
+++ b/step-6-clock/syscalls.c
@@ -3,7 +3,7 @@
#include
-#include "mcu.h"
+#include "hal.h"
int _fstat(int fd, struct stat *st) {
if (fd < 0) return -1;
diff --git a/step-7-webserver/ek-tm4c1294xl/mcu.h b/step-7-webserver/ek-tm4c1294xl/hal.h
similarity index 100%
rename from step-7-webserver/ek-tm4c1294xl/mcu.h
rename to step-7-webserver/ek-tm4c1294xl/hal.h
diff --git a/step-7-webserver/ek-tm4c1294xl/main.c b/step-7-webserver/ek-tm4c1294xl/main.c
index 2469633..1483dcb 100644
--- a/step-7-webserver/ek-tm4c1294xl/main.c
+++ b/step-7-webserver/ek-tm4c1294xl/main.c
@@ -1,7 +1,7 @@
// Copyright (c) 2022 Cesanta Software Limited
// All rights reserved
-#include "mcu.h"
+#include "hal.h"
#include "mongoose.h"
static volatile uint32_t s_ticks;
diff --git a/step-7-webserver/ek-tm4c1294xl/syscalls.c b/step-7-webserver/ek-tm4c1294xl/syscalls.c
index 9bdf778..f99c770 100644
--- a/step-7-webserver/ek-tm4c1294xl/syscalls.c
+++ b/step-7-webserver/ek-tm4c1294xl/syscalls.c
@@ -3,7 +3,7 @@
#include
-#include "mcu.h"
+#include "hal.h"
int _fstat(int fd, struct stat *st) {
if (fd < 0) return -1;
diff --git a/step-7-webserver/nucleo-f429zi/mcu.h b/step-7-webserver/nucleo-f429zi/hal.h
similarity index 100%
rename from step-7-webserver/nucleo-f429zi/mcu.h
rename to step-7-webserver/nucleo-f429zi/hal.h
diff --git a/step-7-webserver/nucleo-f429zi/main.c b/step-7-webserver/nucleo-f429zi/main.c
index e0b2c72..1d990cb 100644
--- a/step-7-webserver/nucleo-f429zi/main.c
+++ b/step-7-webserver/nucleo-f429zi/main.c
@@ -1,7 +1,7 @@
// Copyright (c) 2022 Cesanta Software Limited
// All rights reserved
-#include "mcu.h"
+#include "hal.h"
#include "mongoose.h"
static volatile uint32_t s_ticks;
diff --git a/step-7-webserver/nucleo-f429zi/syscalls.c b/step-7-webserver/nucleo-f429zi/syscalls.c
index 8214418..b0b85a2 100644
--- a/step-7-webserver/nucleo-f429zi/syscalls.c
+++ b/step-7-webserver/nucleo-f429zi/syscalls.c
@@ -3,7 +3,7 @@
#include
-#include "mcu.h"
+#include "hal.h"
int _fstat(int fd, struct stat *st) {
if (fd < 0) return -1;
diff --git a/step-7-webserver/pico-w5500/Makefile b/step-7-webserver/pico-w5500/Makefile
index aab75f4..d74ee15 100644
--- a/step-7-webserver/pico-w5500/Makefile
+++ b/step-7-webserver/pico-w5500/Makefile
@@ -20,7 +20,7 @@ $(BIN2UF2): tools/bin2uf2.c
$(CC) -W -Wall $< -o $@
endif
-firmware.elf: $(SOURCES) mcu.h
+firmware.elf: $(SOURCES) hal.h
arm-none-eabi-gcc $(SOURCES) $(CFLAGS) $(LDFLAGS) -o $@
firmware.bin: firmware.elf
diff --git a/step-7-webserver/pico-w5500/mcu.h b/step-7-webserver/pico-w5500/hal.h
similarity index 100%
rename from step-7-webserver/pico-w5500/mcu.h
rename to step-7-webserver/pico-w5500/hal.h
diff --git a/step-7-webserver/pico-w5500/main.c b/step-7-webserver/pico-w5500/main.c
index cd03739..c054883 100644
--- a/step-7-webserver/pico-w5500/main.c
+++ b/step-7-webserver/pico-w5500/main.c
@@ -1,7 +1,7 @@
// Copyright (c) 2023 Cesanta Software Limited
// All rights reserved
-#include "mcu.h"
+#include "hal.h"
#include "mongoose.h"
enum { LED = 25 }; // LED pins
diff --git a/step-7-webserver/pico-w5500/startup.c b/step-7-webserver/pico-w5500/startup.c
index 9734350..ef89c12 100644
--- a/step-7-webserver/pico-w5500/startup.c
+++ b/step-7-webserver/pico-w5500/startup.c
@@ -1,7 +1,7 @@
// Copyright (c) 2022 Cesanta Software Limited
// All rights reserved
-#include "mcu.h"
+#include "hal.h"
// Startup code
__attribute__((naked, section(".boot"))) void _reset(void) {
diff --git a/step-7-webserver/pico-w5500/syscalls.c b/step-7-webserver/pico-w5500/syscalls.c
index 9bdf778..f99c770 100644
--- a/step-7-webserver/pico-w5500/syscalls.c
+++ b/step-7-webserver/pico-w5500/syscalls.c
@@ -3,7 +3,7 @@
#include
-#include "mcu.h"
+#include "hal.h"
int _fstat(int fd, struct stat *st) {
if (fd < 0) return -1;