Can PDL and HAL be used together?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
YongseokJeon
Level 4
Level 4
Distributor
50 replies posted 50 questions asked 25 replies posted

Hello,
I'm using the CY8C6136 and I have a question about PDL and HAL.

Q1. Can PDL and HAL drivers be used together for one peripheral?
PDL is convenient to initially set up, but for some functions the HAL API is useful.

Q2. I want to use PDL and HAL together for RTC like below.
To use the HAL API, I first used cyhal_rtc_t rtc_obj;.
Is there any problem with using this way?


cyhal_rtc_t rtc_obj;

static int in_rtc_init(void)
{
cy_en_rtc_status_t status;
cy_rslt_t result;

// init
status = Cy_RTC_Init(&RTC_config);
if(status != CY_RTC_SUCCESS)
{
CY_ASSERT(0);
return -1;
}

// time set from flash
if(RTC_TimeStampConfig() == -1)
if(status != CY_RTC_SUCCESS)
{
CY_ASSERT(0);
return -1;
}

// callback function registration
cyhal_rtc_register_callback(&rtc_obj, rtc_event_callback, NULL); // void *callback_arg);

// wake-up every 1sec.
result = cyhal_rtc_set_alarm_by_seconds(&rtc_obj, 1);
rtcAlarmVal = 1; // per 1sec

if (CY_RSLT_SUCCESS != result)
{
CY_ASSERT(0);
return -1;
}

return 0;
}

Q3. Can other components (e.g. PWM, ADC, etc.) use PDL and HAL together in this way?

Best Regards,
YS

0 Likes
1 Solution
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hi @YongseokJeon 

Yes PDL and HAL can be used together. But in order to avoid inconsistency, I would recommend you to use either PDL or HAL for a particular driver or component.

As you can see in the image below:

Ekta_0-1662968107669.png

HAL (Hardware Abstraction Layer)  lies on top of PDL (Peripheral driver library). HAL APIs in turn call APIs from PDL. Application code uses the HAL, which interacts with the PDL through structures created by
the HAL.

Best Regards
Ekta

View solution in original post

0 Likes
2 Replies
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

YS,


Q1. Can PDL and HAL drivers be used together for one peripheral?
PDL is convenient to initially set up, but for some functions the HAL API is useful.


In theory: Yes.

The base SW for HW control of devices is at the HAL level.  The PDL level is one level higher.  With few exceptions, the PDL level makes lower level HAL calls.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hi @YongseokJeon 

Yes PDL and HAL can be used together. But in order to avoid inconsistency, I would recommend you to use either PDL or HAL for a particular driver or component.

As you can see in the image below:

Ekta_0-1662968107669.png

HAL (Hardware Abstraction Layer)  lies on top of PDL (Peripheral driver library). HAL APIs in turn call APIs from PDL. Application code uses the HAL, which interacts with the PDL through structures created by
the HAL.

Best Regards
Ekta

0 Likes