Skip to content

Commit b9dc5f1

Browse files
committed
rename module HW to HAL
1 parent 9c0ee40 commit b9dc5f1

25 files changed

+97
-341
lines changed

extras/TestMadflight/baro/baro.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void setup() {
1313
Serial.begin(115200);
1414
while(!Serial);
1515

16-
hw_setup(); //hardware specific setup for spi and Wire (see hw_xxx.h)
16+
hal_setup(); //hardware specific setup for spi and Wire (see hw_xxx.h)
1717

1818
int rv = baro.setup(100);
1919
if(rv) {

extras/TestMadflight/cfg.ino

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88
//----------------------------------------------------------------------------------------------------------
99
#include <EEPROM.h>
1010

11-
void hw_eeprom_begin() {
11+
void hal_eeprom_begin() {
1212
Serial.println("EEPROM: Unbuffered IO");
1313
//EEPROM.begin(); //STM does not use size in begin() call
1414
}
1515

16-
uint8_t hw_eeprom_read(uint32_t adr) {
16+
uint8_t hal_eeprom_read(uint32_t adr) {
1717
uint8_t val = EEPROM.read(adr);
1818
//Serial.printf("EEPROM.read(%d) = 0x%02X\n", adr, val);
1919
return val;
2020
}
2121

22-
void hw_eeprom_write(uint32_t adr, uint8_t val) {
22+
void hal_eeprom_write(uint32_t adr, uint8_t val) {
2323
EEPROM.update(adr, val); //update only writes when changed
2424
//Serial.printf("EEPROM.write(%d, 0x%02X)\n", adr, val);
2525
}
2626

27-
void hw_eeprom_commit() {
27+
void hal_eeprom_commit() {
2828
//EEPROM.commit(); //STM does not use commit(), write() also executes commit()
2929
}
3030
#else
@@ -33,26 +33,26 @@
3333
//----------------------------------------------------------------------------------------------------------
3434
#include <EEPROM.h>
3535

36-
void hw_eeprom_begin() {
36+
void hal_eeprom_begin() {
3737
(void)(EEPROM); //keep compiler happy
3838
Serial.println("EEPROM: Buffered IO");
3939
//Serial.println("START reading from flash");Serial.flush();
4040
eeprom_buffer_fill(); //Copy the data from the flash to the buffer
4141
//Serial.println("DONE reading");Serial.flush();
4242
}
4343

44-
uint8_t hw_eeprom_read(uint32_t adr) {
44+
uint8_t hal_eeprom_read(uint32_t adr) {
4545
uint8_t val = eeprom_buffered_read_byte(adr); //read from buffer
46-
//Serial.printf("hw_eeprom_read(%d) = 0x%02X\n", adr, val);Serial.flush();
46+
//Serial.printf("hal_eeprom_read(%d) = 0x%02X\n", adr, val);Serial.flush();
4747
return val;
4848
}
4949

50-
void hw_eeprom_write(uint32_t adr, uint8_t val) {
51-
//Serial.printf("hw_eeprom_write(%d, 0x%02X)\n", adr, val);Serial.flush();
50+
void hal_eeprom_write(uint32_t adr, uint8_t val) {
51+
//Serial.printf("hal_eeprom_write(%d, 0x%02X)\n", adr, val);Serial.flush();
5252
eeprom_buffered_write_byte(adr, val); //write to buffer
5353
}
5454

55-
void hw_eeprom_commit() {
55+
void hal_eeprom_commit() {
5656
//Serial.println("START writing to flash");Serial.flush();
5757
eeprom_buffer_flush(); //Copy the data from the buffer to the flash
5858
//Serial.println("DONE writing");Serial.flush();
@@ -64,19 +64,19 @@
6464
//NON STM32
6565
#include <EEPROM.h>
6666

67-
void hw_eeprom_begin() {
67+
void hal_eeprom_begin() {
6868
EEPROM.begin(2048);
6969
}
7070

71-
uint8_t hw_eeprom_read(uint32_t adr) {
71+
uint8_t hal_eeprom_read(uint32_t adr) {
7272
return EEPROM.read(adr);
7373
}
7474

75-
void hw_eeprom_write(uint32_t adr, uint8_t val) {
75+
void hal_eeprom_write(uint32_t adr, uint8_t val) {
7676
EEPROM.write(adr, val);
7777
}
7878

79-
void hw_eeprom_commit() {
79+
void hal_eeprom_commit() {
8080
EEPROM.commit();
8181
}
8282
#endif

extras/TestMadflight/crsf/crsf.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ CRSF crsf;
1818
const int HW_PIN_RCIN_RX = 35;
1919
const int HW_PIN_RCIN_TX = 32;
2020
HardwareSerial *rcin_Serial = &Serial1; //&Serial1 or &Serial2 (&Serial is used for debugging)
21-
void hw_setup()
21+
void hal_setup()
2222
{
2323
rcin_Serial->setPins(HW_PIN_RCIN_RX, HW_PIN_RCIN_TX);
2424
}
2525
#elif defined ARDUINO_ARCH_RP2040
2626
const int HW_PIN_RCIN_RX = 1; //uart0: 1(default), 5, 13, 17 uart1: 5, 9(default)
2727
const int HW_PIN_RCIN_TX = 0; //uart0: 0(default), 4, 12, 16 uart1: 4, 8(default)
2828
SerialUART *rcin_Serial = new SerialUART(uart0, HW_PIN_RCIN_TX, HW_PIN_RCIN_RX); //uart0 or uart1
29-
void hw_setup()
29+
void hal_setup()
3030
{
3131
}
3232
#else
@@ -156,7 +156,7 @@ void setup() {
156156
while(!Serial);
157157
Serial.println("CRSF DEMO");
158158
159-
hw_setup();
159+
hal_setup();
160160
rcin_Serial->setFIFOSize(256);
161161
rcin_Serial->begin(CRSF_BAUD);
162162

extras/TestMadflight/imu/imu.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void setup() {
2626
Serial.begin(115200);
2727
while(!Serial);
2828

29-
hw_setup(); //hardware specific setup for spi and Wire (see hw_xxx.h)
29+
hal_setup(); //hardware specific setup for spi and Wire (see hw_xxx.h)
3030

3131
//IMU: keep on trying until no error is returned (some sensors need a couple of tries...)
3232
while(true) {

extras/TestMadflight/pwm/pwm.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
void setup() {
5252
Serial.begin(115100);
5353

54-
hw_setup(); //hardware specific setup for spi and Wire (see hw_xxx.h)
54+
hal_setup(); //hardware specific setup for spi and Wire (see hw_xxx.h)
5555

5656
for(int i=0;i<HW_OUT_COUNT;i++) {
5757
//out[i].begin(HW_PIN_OUT[i], 50, 1000, 2000); //Standard servo at 50Hz

extras/TestMadflight/rcin/rcin.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void setup() {
2222
while(!Serial);
2323

2424
//cli.print_boardInfo(); //print board info and pinout
25-
hw_setup(); //hardware specific setup for spi and Wire (see hw_xxx.h)
25+
hal_setup(); //hardware specific setup for spi and Wire (see hw_xxx.h)
2626

2727
rcin.setup(); //Initialize radio communication. Set correct USE_RCIN_xxx user specified defines above. Note: rcin_Setup() function is defined in rcin.h, but normally no changes needed there.
2828

extras/TestMadflight/rp2040_crsf/rp2040_crsf.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void setup() {
5353
Serial.begin(115200);
5454
while(!Serial);
5555
Serial.println("CRSF DEMO");
56-
hw_setup();
56+
hal_setup();
5757
imu.setup(1000);
5858
imu.onUpdate = imu_loop;
5959
rcin.setup();

src/madflight.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,7 @@ MF_Serial *rcin_Serial = nullptr; //serial bus for RCIN
4141
MF_Serial *gps_Serial = nullptr; //serial bus for GPS
4242
MF_I2C *mf_i2c = nullptr; //I2C (Wire) bus for sensors
4343

44-
//include hardware specific code & default board pinout
45-
#if defined ARDUINO_ARCH_ESP32
46-
#include "madflight/hw_ESP32/hw_ESP32.h"
47-
#elif defined ARDUINO_ARCH_RP2040
48-
#include "madflight/hw_RP2040/hw_RP2040.h"
49-
#elif defined ARDUINO_ARCH_STM32
50-
#include "madflight/hw_STM32/hw_STM32.h"
51-
#else
52-
#error "Unknown hardware architecture, expected ESP32 / RP2040 / STM32"
53-
#endif
44+
#include "madflight/hal/hal.h"
5445

5546
//default for ALT (Altitude Estimation)
5647
#ifndef ALT_USE
@@ -146,8 +137,8 @@ void madflight_setup() {
146137
cli.cmd_execute_batch(madflight_init_commands);
147138
}
148139

149-
//hardware specific setup for busses: serial, spi and i2c (see hw_xxx.h)
150-
hw_setup();
140+
//hardware abstraction layer setup: serial, spi, i2c (see hal.h)
141+
hal_setup();
151142

152143
//prevent nullpointers
153144
if(!rcin_Serial) rcin_Serial = new MF_SerialNone();

src/madflight/cfg/cfg_interface.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class Config {
267267
}
268268

269269
void begin() {
270-
hw_eeprom_begin();
270+
hal_eeprom_begin();
271271
read();
272272
}
273273

@@ -327,7 +327,7 @@ class Config {
327327
fvalues[i] = val.toInt();
328328
break;
329329
case 'p': //pinnumber/pinname
330-
fvalues[i] = hw_get_pin_number(val);
330+
fvalues[i] = hal_get_pin_number(val);
331331
break;
332332
default:
333333
//assume 'f'
@@ -377,7 +377,7 @@ class Config {
377377
uint16_t n = sizeof(Config);
378378
//Serial.printf("eeprom_read[%d]:", n);
379379
for(uint16_t i=0; i<n; i++) {
380-
buf[i] = hw_eeprom_read(i);
380+
buf[i] = hal_eeprom_read(i);
381381
//Serial.printf("%02X ",buf[i]);
382382
}
383383
//Serial.println();
@@ -401,10 +401,10 @@ class Config {
401401
uint16_t n = sizeof(Config);
402402
Serial.printf("eeprom_write[%d]:", n);
403403
for(int i=0; i<n; i++) {
404-
hw_eeprom_write(i, buf[i]);
404+
hal_eeprom_write(i, buf[i]);
405405
Serial.printf("%02X ",buf[i]);
406406
}
407-
hw_eeprom_commit();
407+
hal_eeprom_commit();
408408
Serial.println();
409409
}
410410

src/madflight/cli/cli.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ class CLI {
367367
}else if (cmd == "i2c") {
368368
print_i2cScan();
369369
}else if (cmd == "reboot") {
370-
hw_reboot();
370+
hal_reboot();
371371
}else if (cmd == "poff") {
372372
cli_print_all(false);
373373
}else if (cmd == "pall") {

0 commit comments

Comments
 (0)