https://github.com/tomtzook/hal
An hardware abstraction layer for hardware IO
https://github.com/tomtzook/hal
c hal input-output
Last synced: 28 days ago
JSON representation
An hardware abstraction layer for hardware IO
- Host: GitHub
- URL: https://github.com/tomtzook/hal
- Owner: tomtzook
- Created: 2018-08-08T18:56:51.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-07-18T19:52:11.000Z (almost 2 years ago)
- Last Synced: 2025-01-13T06:41:56.638Z (over 1 year ago)
- Topics: c, hal, input-output
- Language: C
- Homepage:
- Size: 605 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HAL
A basic abstraction layer for Hardware IO, such as GPIO, PWM and more. The actual implementation is provided in the form of _BACKENDS_, each providing different functionalities and supporting different hardware platform (e.g. Raspberry PI, Beaglebone Black, etc.).
The following are the available backends:
- `bbb-usermode-sysfs`: a usermode implementation using sysfs for Beaglebone Black.
Available for use in native code or with Java via JNI bindings.
## Usage
#### Basic Example LED
```c
#include
int main() {
hal_env_t* env;
hal_error_t status;
status = hal_init(&env);
if (HAL_IS_ERROR(status)) {
return 1;
}
hal_handle_t handle;
status = hal_open(env, "P8_12", HAL_TYPE_DIGITAL_OUTPUT, &handle);
if (HAL_IS_ERROR(status)) {
goto end;
}
for (int i = 0; i < 5; i++) {
status = hal_dio_set(handle, HAL_DIO_HIGH);
if (HAL_IS_ERROR(status)) {
goto end;
}
usleep(10000);
status = hal_dio_set(handle, HAL_DIO_LOW);
if (HAL_IS_ERROR(status)) {
goto end;
}
usleep(10000);
}
end:
hal_shutdown(env);
return status;
}
```