Announcements

Curious on how you can apply PSoC™ 6 to Smart Home Appliances? Register for the ASEAN Smart Home Appliance Webinar here to find out how.

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

PSoC™ 6 Forum Discussions

YSJE_3566666
Level 4
50 questions asked 25 replies posted 100 sign-ins
Level 4

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
Moderator
Moderator 250 solutions authored 100 likes received 250 sign-ins
Moderator

Hi @YSJE_3566666 

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
1000 replies posted 750 replies posted 500 likes received
Level 9

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
Moderator
Moderator 250 solutions authored 100 likes received 250 sign-ins
Moderator

Hi @YSJE_3566666 

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