Please provide detailed feedback on the module model and firmware version you are using.
There is an example of GPIO used in the SDK on the official website for your reference.
// Specify a GPIO pin
Enum_PinName gpioPin = PINNAME_NETLIGHT;
// Define the initial level for GPIO pin
Enum_PinLevel gpioLvl = PINLEVEL_HIGH;
// Initialize the GPIO pin (output high level, pull up)
Ql_GPIO_Init(gpioPin, PINDIRECTION_OUT, gpioLvl, PINPULLSEL_PULLUP);
APP_DEBUG("<-- Initialize GPIO pin (PINNAME_STATUS): output, high level, pull up -->\r\n");
// Get the direction of GPIO
APP_DEBUG("<-- Get the GPIO direction: %d -->\r\n", Ql_GPIO_GetDirection(gpioPin));
// Get the level value of GPIO
APP_DEBUG("<-- Get the GPIO level value: %d -->\r\n\r\n", Ql_GPIO_GetLevel(gpioPin));
// Set the GPIO level to low after 500ms.
APP_DEBUG("<-- Set the GPIO level to low after 500ms -->\r\n");
Ql_Sleep(500);
Ql_GPIO_SetLevel(gpioPin, PINLEVEL_LOW);
APP_DEBUG("<-- Get the GPIO level value: %d -->\r\n\r\n", Ql_GPIO_GetLevel(gpioPin));
// Set the GPIO level to high after 500ms.
APP_DEBUG("<-- Set the GPIO level to high after 500ms -->\r\n");
Ql_Sleep(500);
Ql_GPIO_SetLevel(gpioPin, PINLEVEL_HIGH);
APP_DEBUG("<-- Get the GPIO level value: %d -->\r\n", Ql_GPIO_GetLevel(gpioPin));
Hi Grey,
The documentation on the MC60 says that I can do GPIO initialization using the “custom_gpio_cfg.h” file or use the API.
In OpenCPU, there are two ways to initialize GPIOs. One is to configure initial GPIO list in custom_gpio_cfg.h, please refer to Chapter 4.3; the other way is to call GPIO related APIs to initialize after App starts.
So, I’m interested in how to do GPIO initialization using the “custom_gpio_cfg.h” file?
It’s not quite clear to me how this needs to be done correctly.
You changed the “custom_gpio_cfg. H” file by calling "GPIO_ITEM(PINNAME_CTS, PINDIRECTION_OUT, PINLEVEL_HIGH, PINPULLSEL_PULLUP)
GPIO_ITEM(PINNAME_RTS, PINDIRECTION_OUT, PINLEVEL_HIGH, PINPULLSEL_PULLUP)" but no GPIO is initialized.These two statements modify the GPIO default state so that the level is reversed when used for power control, but to actually use the GPIO reversal, use the “Ql_GPIO_Init” function.