Hello,
Are there any reference or sample code to control GPIO at register level?
I would like to control GPIO by C language and minimize software overhead.
(Assembler language is little bit too difficult for me...)
Regards,
U-SK
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
Are there any reference or sample code to control GPIO at register level?
I would like to control GPIO by C language and minimize software overhead.
(Assembler language is little bit too difficult for me...)
Regards,
U-SK
U-SK,
The functional CSL layer provides users a way to set/clear or send dataout on the GPIO pins using register level write. The C callable functions for GPIO for AM437x are defined in file :pdk_am437x_1_0_10\packages\ti\csl\src\ip\gpio\V1\priv\gpio_v2.c
Use the API GPIOPinWrite to write a value to the pin. The function is defined as follows:
void GPIOPinWrite(uint32_t baseAdd, uint32_t pinNumber, uint32_t pinValue) { if (GPIO_PIN_HIGH == pinValue) { HW_WR_REG32(baseAdd + GPIO_SETDATAOUT, (uint32_t) 1 << pinNumber); } else { HW_WR_REG32(baseAdd + GPIO_CLEARDATAOUT, (uint32_t) 1 << pinNumber); } }
You can use these APIs from RTOS application or from bare-metal applications. If you are simply benchmarking, you can use the GPIO LLD example to do basic pinmux and GPIO initialization and then use this API instead of GPIO_write/GPIO_toggle to reduce driver latency.
Regards,
Rahul
To use CSL APIs in the source you need to include the header file csl_gpio.h from pdk_am437x_1_0_10\packages\ti\csl\ and have -D SOC_AM437x in the compiler settings as described here:
http://software-dl.ti.com/processor-sdk-rtos/esd/docs/latest/rtos/index_device_drv.html
Detail documentation for GPIO CSL APIs is int he document pdk_am437x_1_0_xx\packages\API_Documentation.html as shown below: