Installation
This guide covers how to obtain and integrate the AS5047U driver library into your project.
Prerequisites
Before installing the driver, ensure you have:
- C++20 Compiler: GCC 10+, Clang 12+, or MSVC 2019+
- Build System: Make, CMake, or ESP-IDF (depending on your platform)
- Platform SDK: ESP-IDF, STM32 HAL, Arduino, or your platformβs SPI driver
Obtaining the Source
Option 1: Git Clone
1
2
git clone https://github.com/n3b3x/hf-as5047u-driver.git
cd hf-as5047u-driver
Option 2: Copy Files
Copy the following files into your project:
1
2
3
4
5
6
7
8
inc/
βββ as5047u.hpp
βββ as5047u_spi_interface.hpp
βββ as5047u_registers.hpp
βββ as5047u_types.hpp
βββ as5047u_config.hpp
src/
βββ as5047u.cpp
Integration Methods
Using CMake
Add the driver as a subdirectory in your CMakeLists.txt:
1
2
3
4
5
add_subdirectory(external/hf-as5047u-driver)
target_link_libraries(your_target PRIVATE hf_as5047u)
target_include_directories(your_target PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/external/hf-as5047u-driver/inc
)
Using ESP-IDF Component
The driver can be used as an ESP-IDF component. Add it to your components directory:
1
2
3
4
5
6
# In your main CMakeLists.txt
idf_component_register(
SRCS "your_code.cpp"
INCLUDE_DIRS "."
REQUIRES hf_as5047u
)
Manual Integration
- Copy the driver files to your project
- Add the
inc/directory to your include path - Include the header:
1
#include "as5047u.hpp"
- Compile with C++20 support:
1
g++ -std=c++20 -I inc/ your_code.cpp src/as5047u.cpp
Running Unit Tests
The library includes unit tests. To run them:
1
2
3
cd tests
g++ -std=c++20 -I ../inc ../src/as5047u.cpp test_as5047u.cpp -o test
./test
Expected output:
1
All tests passed.
Verification
To verify the installation:
- Include the header in a test file:
1
#include "as5047u.hpp"
- Compile a simple test:
1
g++ -std=c++20 -I inc/ -c src/as5047u.cpp -o test.o
- If compilation succeeds, the library is properly installed.
Next Steps
- Follow the Quick Start guide to create your first application
- Review Hardware Setup for wiring instructions
- Check Platform Integration to implement the SPI interface
Navigation β¬ οΈ Back to Index | Next: Quick Start β‘οΈ