GPIO interrupt example project using S32K1xx RTD without AUTOSAR

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

GPIO interrupt example project using S32K1xx RTD without AUTOSAR

GPIO interrupt example project using S32K1xx RTD without AUTOSAR

The Port_Ci_Port_Ip_Example in S32K1 RTD 1.0.1 lacks GPIO interrupt function. Port_Ci is part of Icu(Input Capture Unit), the main function of the example should have been: use the Icu and Dio drivers to toggle a LED on a push button. But it doesn't. So this document will show the step-by-step process to add 'GPIO interrupt' function in Port_Ci_Port_Ip_Example using the S32K1xx RTD and the S32 Configuration Tools. This example is for the S32K144EVB-Q100 EVB, connected to a PC through USB (OpenSDA) connection.

Preparation

  1. Setup the software tools
    1. Install S32 Design Studio for S32 Platform
    2. Install the S32K1xx development package and the S32K1 RTD AUTOSAR 4.4. Both of these are required for the S32 Configuration Tools.
      S32DS Extensions and Updates S32K1 RTD 101.png

       

  2. Launch S32 Design Studio for S32 Platform

 

Procedure

1. Import Port_Ci_Port_Ip_Example_S32K144 example

File->New->S32DS Project from Example

import Port_Ci_Port_Ip_Example_S32K144.png

Although the main function mentions the example use the Icu and Dio drivers to toggle a LED on a push button, it actually just waits in a loop for a delay to blink the LED. Not sure why the implementation of GPIO interrupts(Port_Ci_Icu) is missing.

Port_Ci_Port_Ip_Example_S32K144.png

S32K1 real time driver COMPONENTS.png

 

2. Add push button and LED in Pins tool

Add the pins for user buttons (SW2 PTC12 and SW3 PTC13) and LEDRGB_RED (RGB_RED PTD15) according to the S32K144EVB schematic RB1.

pins tool.png

USER BUTTONS S32K144EVB.pngBTN0 PTC12 BTN1 PTC13.png

 

3. Add IntCtrl_Ip component

Go to Peripherals tool. Here we can see that the ‘Gpio_Dio’ and ‘Port’ components are already added.

Drivers default.png

From the Components view, click on ‘Add a new configuration component…’ button from the Drivers category. This will bring up a list of non-AUTOSAR components. Locate and then select the ‘IntCtrl_Ip’ component from the list and click OK.

IntCtrl_Ip step1.png

Keep the default setting after add ‘IntCtrl_Ip’ component, we will call IntCtrl_Ip_InstallHandler and IntCtrl_Ip_EnableIrq those two APIs to install and enable the PORTC IRQ separately. (Here we didn't change the settings of ‘IntCtrl_Ip’, nor use IntCtrl_Ip_Init and IntCtrl_Ip_ConfigIrqRouting API to enable interrupts and install handlers in IntCtrl_Ip.)

IntCtrl_Ip step3.png

 

4. Add Port_Ci_Icu component

Locate and then select the ‘Port_Ci_Icu’ component from the list and click OK. Follow the steps below to configure it.

Port_Ci_Icu step1.png

Selecting PORT_2 for ICU Peripheral ISR Name and select IcuIsrEnable at step 6 actually refers to PORT C used in this example. In order to use the GPIO interrupts of the onboard SW2 (PTC12) and SW3 (PTC13) buttons, you need to add one more channel in step 9, and select Port CI Hardware Module and Hardware channel in steps 8 and 10.

Port_Ci_Icu step3 - Copy.png

The button circuit has a pull-down resistor, and it will be pulled high after being pressed, so the rising edge trigger is selected. In step 14, add IcuSignalNotification for PTC12 and PTC13 respectively, that is, the notification after the corresponding GPIO pin input captures the rising edge (there is no need to clear the interrupt flag here, the RTD driver has already done it).

Port_Ci_Icu step5.png

Port_Ci_Icu step7.png

 

5. Include the headers for the drivers used in the application

include.png

 

6. Add Port_Ci_Icu drivers

Port_Ci_Icu_Ip_Init initialize the rising edge of PTC12 and PTC13 set by the S32 Configuration Tools. Port_Ci_Icu_Ip_EnableNotification enable the Callback of PTC12 and PTC13 respectively, and we toggle the blue and red LEDs in the corresponding Callback.

Port_Ci_Icu_Ip APIs.png

 

7. Add IntCtrl drivers

IntCtrl_Ip_InstallHandler installs the PORT_CI_ICU_IP_C_EXT_IRQ_ISR interrupt handler generated by the S32 Configuration Tools.

IntCtrl_Ip APIs.png

标签 (2)
附件
100% 有帮助 (1/1)
版本历史
最后更新:
‎10-20-2022 01:02 AM
更新人: