Light hardware abstraction layer for peripherals.
More...
#include <Arduino.h>
#include <SPI.h>
#include <Wire.h>
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
|
| #define | hV_HAL_PERIPHERALS_RELEASE 922 |
| | Release. More...
|
| |
| #define | hV_HAL_Serial Serial |
| | SDK library. More...
|
| |
|
#define | mySerial hV_HAL_Serial |
| | Serial port, synonym.
|
| |
|
|
|
#define | hV_HAL_delayMilliseconds(X) (delay(X)) |
| |
|
#define | hV_HAL_delayMicroseconds(X) (delayMicroseconds(X)) |
| |
|
#define | hV_HAL_getMilliseconds() (millis()) |
| |
|
| #define | LEVEL_CRITICAL 0x0001 |
| | Log level messages. More...
|
| |
|
#define | LEVEL_INFO 0x0008 |
| | . Information
|
| |
|
#define | LEVEL_DEBUG 0x0010 |
| | - Debug
|
| |
|
#define | LEVEL_SYSTEM 0x0020 |
| | = System
|
| |
|
- Warning
- Arduino: GPIO requires pin number, example 4
- Mbed: GPIO requires pin name, example D4 or PB_5
- Mbed: GPIO is created at call
- Mbed: GPIO not suitable for interrupts
- Viewer: For compatibility only, GPIO not implemented in Linux
|
| #define | hV_HAL_GPIO_define(X, Y) (pinMode(X, Y)) |
| | Undefine GPIO. More...
|
| |
| #define | hV_HAL_GPIO_set(X) (digitalWrite(X, HIGH)) |
| | Undefine GPIO. More...
|
| |
| #define | hV_HAL_GPIO_clear(X) (digitalWrite(X, LOW)) |
| | Undefine GPIO. More...
|
| |
| #define | hV_HAL_GPIO_get(X) (digitalRead(X)) |
| | Undefine GPIO. More...
|
| |
| #define | hV_HAL_GPIO_write(X, Y) (digitalWrite(X, Y)) |
| | Undefine GPIO. More...
|
| |
| #define | hV_HAL_GPIO_read(X) (digitalRead(X)) |
| | Undefine GPIO. More...
|
| |
| void | hV_HAL_GPIO_begin (void) |
| | Undefine GPIO. More...
|
| |
| void | hV_HAL_GPIO_undefine (uint8_t pin) |
| | Undefine GPIO. More...
|
| |
| void | hV_HAL_GPIO_waitFor (uint8_t pin, uint8_t state) |
| | Wait for GPIO. More...
|
| |
|
| #define | hV_HAL_min(a, b) ((a) < (b) ? (a) : (b)) |
| | Minimum of two numbers. More...
|
| |
| #define | hV_HAL_max(a, b) ((a) > (b) ? (a) : (b)) |
| | Maximum of two numbers. More...
|
| |
| #define | hV_HAL_swap(x, y) do { __typeof__(x) WORK = x; x = y; y = WORK; } while (0) |
| | Swap numbers. More...
|
| |
| long | hV_HAL_map (long x, long in_min, long in_max, long out_min, long out_max) |
| | Rescale a value. More...
|
| |
Light hardware abstraction layer for peripherals.
Based on highView technology
- Date
- 21 Oct 2025
- Version
- 922
- Copyright
- (c) Etigues, 2010-2025
-
All rights reserved
-
For exclusive use with Pervasive Displays screens
- Basic edition: for hobbyists and for basic usage
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) - See also
- https://creativecommons.org/licenses/by-sa/4.0/
Consider the Evaluation or Commercial editions for professionals or organisations and for commercial usage
- Evaluation edition: for professionals or organisations, evaluation only, no commercial usage
All rights reserved
- Commercial edition: for professionals or organisations, commercial usage
All rights reserved
- Viewer edition: for professionals or organisations
All rights reserved
- Documentation
All rights reserved
◆ hV_HAL_GPIO_clear
| #define hV_HAL_GPIO_clear |
( |
|
X | ) |
(digitalWrite(X, LOW)) |
Undefine GPIO.
- Parameters
-
| pin | pin number or pin name according to SDK |
◆ hV_HAL_GPIO_define
| #define hV_HAL_GPIO_define |
( |
|
X, |
|
|
|
Y |
|
) |
| (pinMode(X, Y)) |
Undefine GPIO.
- Parameters
-
| pin | pin number or pin name according to SDK |
◆ hV_HAL_GPIO_get
| #define hV_HAL_GPIO_get |
( |
|
X | ) |
(digitalRead(X)) |
Undefine GPIO.
- Parameters
-
| pin | pin number or pin name according to SDK |
◆ hV_HAL_GPIO_read
| #define hV_HAL_GPIO_read |
( |
|
X | ) |
(digitalRead(X)) |
Undefine GPIO.
- Parameters
-
| pin | pin number or pin name according to SDK |
◆ hV_HAL_GPIO_set
| #define hV_HAL_GPIO_set |
( |
|
X | ) |
(digitalWrite(X, HIGH)) |
Undefine GPIO.
- Parameters
-
| pin | pin number or pin name according to SDK |
◆ hV_HAL_GPIO_write
| #define hV_HAL_GPIO_write |
( |
|
X, |
|
|
|
Y |
|
) |
| (digitalWrite(X, Y)) |
Undefine GPIO.
- Parameters
-
| pin | pin number or pin name according to SDK |
◆ hV_HAL_max
| #define hV_HAL_max |
( |
|
a, |
|
|
|
b |
|
) |
| ((a) > (b) ? (a) : (b)) |
Maximum of two numbers.
- Parameters
-
| a | first number |
| b | second number |
- Returns
- maximum of a and b
- Note
- Macro more robust than bugged implementation on some platforms
◆ hV_HAL_min
| #define hV_HAL_min |
( |
|
a, |
|
|
|
b |
|
) |
| ((a) < (b) ? (a) : (b)) |
Minimum of two numbers.
- Parameters
-
| a | first number |
| b | second number |
- Returns
- minimum of a and b
- Note
- Macro more robust than bugged implementation on some platforms
◆ hV_HAL_PERIPHERALS_RELEASE
| #define hV_HAL_PERIPHERALS_RELEASE 922 |
Release.
- Deprecated:
- Removed synonyms for GPIO (7.0.0)
- Deprecated:
- Removed synonyms for Time (7.0.0)
- hV_HAL_delay() is removed. Use hV_HAL_delayMilliseconds() instead (7.0.0)
- Deprecated:
- Removed synonyms for Serial (7.0.0)
- hV_HAL_printf() is removed. Use hV_HAL_Serial_printf() instead (7.0.0)
- hV_HAL_crlf() is removed. Use hV_HAL_Serial_crlf() instead (7.0.0)
- hV_HAL_Serial_print() and hV_HAL_Serial_println() are not recommended. Use hV_HAL_Serial_printf() and hV_HAL_Serial_crlf() instead (7.0.0)
- Deprecated:
- Removed synonyms for SPI (7.0.0)
- Deprecated:
- Removed synonyms for Wire (7.0.0)
◆ hV_HAL_Serial
| #define hV_HAL_Serial Serial |
SDK library.
- See also
- References
SDK other libraries
Other libraries
Serial port
Serial or Serial1
◆ hV_HAL_swap
| #define hV_HAL_swap |
( |
|
x, |
|
|
|
y |
|
) |
| do { __typeof__(x) WORK = x; x = y; y = WORK; } while (0) |
Swap numbers.
- Parameters
-
| [out] | x | first number |
| [out] | y | second number |
- Note
- Macro more robust than template for some platforms
template <typename T> T
{
T w = x;
x = y;
y = w;
}
#define hV_HAL_swap(x, y)
Swap numbers.
Definition: hV_HAL_Peripherals.h:389
- Note
__typeof__ recommended over typeof
◆ LEVEL_CRITICAL
| #define LEVEL_CRITICAL 0x0001 |
Log level messages.
* Non-handled error, stop or exit
◆ hV_HAL_begin()
General initialisation.
hV_HAL_Serial initialised at hV_HAL_Serial_Speed
◆ hV_HAL_exit()
| void hV_HAL_exit |
( |
uint8_t |
code = 0 | ) |
|
General exit.
- Parameters
-
| code | default = 0 = success, otherwise error |
- Note
- Only used on Linux
◆ hV_HAL_GPIO_begin()
| void hV_HAL_GPIO_begin |
( |
void |
| ) |
|
Undefine GPIO.
- Parameters
-
| pin | pin number or pin name according to SDK |
◆ hV_HAL_GPIO_undefine()
| void hV_HAL_GPIO_undefine |
( |
uint8_t |
pin | ) |
|
Undefine GPIO.
- Parameters
-
| pin | pin number or pin name according to SDK |
◆ hV_HAL_GPIO_waitFor()
| void hV_HAL_GPIO_waitFor |
( |
uint8_t |
pin, |
|
|
uint8_t |
state |
|
) |
| |
Wait for GPIO.
- Parameters
-
| pin | pin number or pin name according to SDK |
| state | HIGH or LOW |
◆ hV_HAL_log()
| void hV_HAL_log |
( |
uint16_t |
level, |
|
|
const char * |
format, |
|
|
|
... |
|
) |
| |
Send debug message to console.
- Parameters
-
- Note
- With final CR-LF
◆ hV_HAL_map()
| long hV_HAL_map |
( |
long |
x, |
|
|
long |
in_min, |
|
|
long |
in_max, |
|
|
long |
out_min, |
|
|
long |
out_max |
|
) |
| |
Rescale a value.
- Parameters
-
| x | input value |
| in_min | minimal input value |
| in_max | maximum input value |
| out_min | minimum output value |
| out_max | maximum output value |
- Returns
- long output value
- Note
- Formula is
(x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
◆ hV_HAL_SPI3_begin()
| void hV_HAL_SPI3_begin |
( |
| ) |
|
Configure 3-wire SPI.
- Note
- Select default SCK as clock and MOSI as data (SDIO)
◆ hV_HAL_SPI3_define()
| void hV_HAL_SPI3_define |
( |
uint8_t |
pinClock = SCK, |
|
|
uint8_t |
pinData = MOSI |
|
) |
| |
Set the 3-wire SPI pins.
- Parameters
-
| pinClock | clock, default = SCK |
| pinData | combined data, default = MOSI |
- Note
- For manual configuration only
- Warning
- SCK and MOSI provided by Arduino SDK
- Some boards require manual configuration
◆ hV_HAL_SPI3_end()
End 3-wire SPI.
- Warning
- Some platforms require freeing the GPIOs used by 3-wire SPI before starting SPI.
◆ hV_HAL_SPI3_read()
| uint8_t hV_HAL_SPI3_read |
( |
| ) |
|
Read a single byte.
- Returns
- read byte
- Note
- Configure the clock pin as output and data pin as input.
- Warning
- /CS to be managed externally.
◆ hV_HAL_SPI3_write()
| void hV_HAL_SPI3_write |
( |
uint8_t |
value | ) |
|
Write a single byte.
- Parameters
-
- Note
- Configure the clock and data pins as output.
- Warning
- /CS to be managed externally.
◆ hV_HAL_SPI_begin()
| void hV_HAL_SPI_begin |
( |
uint32_t |
speed = 8000000 | ) |
|
Configure and start SPI.
- Parameters
-
| speed | SPI speed in Hz, 8000000 = default |
- Note
- Other parameters are
- Bit order: MSBFIRST
- Data mode: SPI_MODE0
-
With check for unique initialisation
◆ hV_HAL_SPI_end()
End SPI.
- Note
- With check for unique deinitialisation
◆ hV_HAL_SPI_transfer()
| uint8_t hV_HAL_SPI_transfer |
( |
uint8_t |
data | ) |
|
Combined write and read of a single byte.
- Parameters
-
- Returns
- read byte
- Warning
- No check for previous initialisation
◆ hV_HAL_Wire_begin()
| void hV_HAL_Wire_begin |
( |
| ) |
|
Configure and start Wire bus.
- Note
- Master mode only
-
With check for unique initialisation
◆ hV_HAL_Wire_end()
End Wire bus.
- Note
- With check for unique deinitialisation
◆ hV_HAL_Wire_transfer()
| uint8_t hV_HAL_Wire_transfer |
( |
uint8_t |
address, |
|
|
uint8_t * |
dataWrite, |
|
|
size_t |
sizeWrite, |
|
|
uint8_t * |
dataRead = 0, |
|
|
size_t |
sizeRead = 0, |
|
|
uint32_t |
us = 0 |
|
) |
| |
Combined write and read with optional delay.
- Parameters
-
| [in] | address | I2C device address |
| [in] | dataWrite | buffer to write |
| [in] | sizeWrite | number of bytes |
| [out] | dataRead | buffer to read |
| [in] | sizeRead | number of bytes |
| [in] | us | delay in microseconds, default = 0 = no delay |
- Returns
- uint8_t transmission status, RESULT_SUCCESS = 0 or RESULT_ERROR = 1
- Note
- If sizeRead = 0, no read performed
- Warning
- No check for previous initialisation