NXP’s Hardware Abstraction Layer (HAL) is based on the MCUXpresso SDK drivers. To learn more, see the blog Zephyr Software Code Reuse with NXP MCUXpresso SDK. Most Zephyr users want to use the Zephyr driver APIs in their application for portability. But if a Zephyr driver is not supported on a platform, or if there is no Zephyr driver for a hardware peripheral, another option is to use the MCUXpresso SDK driver directly in the application. This article provides details, using the PUF driver as an example on the LPC55S69.
NXP had a major update to the MCUXpresso SDK in v24.12 that restructured the SDK. This new HAL was added in Zephyr after the Zephyr v4.1 release, in this Pull Request. This article focuses on using drivers in this latest HAL. For older versions of Zephyr, or if using an older SOC that is not supported in this latest HAL, see this older post.
HAL drivers with Zephyr support are included in an app using devicetree and Kconfig. To include other drivers not managed by Zephyr, simply add a line in the application's CMakeLists.txt file enabling that driver. The first line shown below instructs Cmake to include the PUF driver by setting the variable CONFIG_MCUX_COMPONENT_driver.puf
. Note: be sure to set these variables before the find_package(Zephyr ...)
line.
set(CONFIG_MCUX_COMPONENT_driver.puf ON)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
With the driver included in the build, the driver APIs can be used in the application. This is a simple app using a PUF driver API:
#include <fsl_puf.h>
int main(void)
{
puf_config_t conf;
PUF_GetDefaultConfig(&conf);
return 0;
}
To find the name of the Cmake variable to use for a driver, look in the mcuxsdk-core repo. This is the Kconfig file for the PUF driver, and it defines the Kconfig symbol named MCUX_HAS_COMPONENT_driver.puf. Add the CONFIG_ prefix to get the final symbol name CONFIG_MCUX_HAS_COMPONENT_driver.puf
.