The hardware is HMI-43 screen (FT812 and FT900) with attached HMI-BB for access to a GPIO pin.
I've chosen a HMI-BB ethernet LED as the input which is FT900 GPIO pin 4.
Using a wire from GND with a current limiting resistor, I can touch the wire to the first pin on the connector.
When the pin goes low, the ethernet LED lights up, which is good visual feedback.
Taking incremental steps:
GPIOs connected
The code can set up GPIO as an input and read it, duplicating it on GPIO 5 in order to light the other ethernet LED on the HMI-BB
Configuring the two GPIOs as input and output is easy. Before the main loop:
Code: Select all
// Configure GPIO 4 as an input for a wake up interrupt
GPIO_Pin_Config(GPIO_PIN4, _GPIO_DIR_INPUT, _GPIO_CFG_PULL_NONE);
// Configure GPIO 5 as an output to control the LED on the RJ45
GPIO_Pin_Config(GPIO_PIN5, _GPIO_DIR_OUTPUT, _GPIO_CFG_PULL_NONE);
GPIO_Pin_Write(GPIO_PIN5, _GPIO_PIN_VALUE_1);
Code: Select all
{
char rd = GPIO_Pin_Read(GPIO_PIN4);
if (_GPIO_PIN_VALUE_1 == rd || _GPIO_PIN_VALUE_0 == rd)
{
GPIO_Pin_Write(GPIO_PIN5, rd);
}
}
GPIO interrupt
The code can set up the GPIO as an interrupt that turns on the LED.
This code replaces the pin read code shown above.
The interrupt handler:
Code: Select all
void interrupt() iv IVT_GPIO_IRQ
{
// Turn on LED to prove there was an interrupt
GPIO_Pin_Write(GPIO_PIN5, _GPIO_PIN_VALUE_0); // I wouldn't usually use a high level pin write like this in an ISR!
// Clear interrupt flag
GPIO_INT_PEND4_bit = 1;
}
The code enabling the interrupt, based on the external interrupt example code:
Code: Select all
// Enable all interrupts
IRQ_CTRL.B31 = 0;
// Set falling edge to detect interrupt
GPIO04_CFG0_bit = 0;
// Interrupt capable
GPIO04_CFG1_bit = 1;
// Enable interrupt
GPIO_INT_EN4_bit = 1;
Waking from sleep
Now to the real goal, waking the FT90x from sleep.
Just adding a call to PWR_PowerDownMCU with parameters selecting a GPIO wake based on a falling pin 4.
Code: Select all
// Enable all interrupts
IRQ_CTRL.B31 = 0;
// Set falling edge to detect interrupt
GPIO04_CFG0_bit = 0;
// Interrupt capable
GPIO04_CFG1_bit = 1;
// Enable interrupt
GPIO_INT_EN4_bit = 1;
PWR_PowerDownMCU(_PWR_WAKEUP_GPIO_YES|_PWR_WAKEUP_GPIO_ON_FALL, GPIO_PIN4);
Sadly, touching the resistor/wire to the pin does not trigger the interrupt routine to make the LED light up, nor make the screen respond again.
It takes a power cycle to get out of the sleep state.
I've searched for other uses of PWR_PowerDownMCU without success. Does anyone have an example that successfully awakens the FT90x?