Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5091

SDK • Interrupt return

$
0
0
I'm working on a project where I read data from a controller and write it to a console. To handle this, I'm using interrupts. In the main while loop, I continuously read data from the controller. When the console starts requesting data, an interrupt is triggered, and I write the data to the console.

The problem is that after returning from the interrupt, I get stuck in a get_blocking function. This happens because the controller continues sending data while the interrupt is being handled.

I want to use an interrupt so I don't have to worry about the timing of when the console polls for the controller data.

Is there a way to make sure that when I return from the interrupt, I always start at the beginning of the function that reads data from the controller? or a different approach I should take?

Code:

void callback(uint gpio, uint32_t events){//Interrupt callback function    uint64_t delay_us = gamecubeconsole.write_data(controller.origin, controller.report);    busy_wait_us(delay_us);}void GCcontroller::get_report(){//get controller report function    outmode();    pio_sm_put_blocking(pio, sm, 0b11111010101010101010101010101110);   //ask controller for report    pio_sm_put_blocking(pio, sm, 0b111010101010101010);        report.SYXBA = pio_sm_get_blocking(pio, sm);            //read the report from the controller    report.LRZD = pio_sm_get_blocking(pio, sm);    report.xStick = pio_sm_get_blocking(pio, sm);    report.yStick = pio_sm_get_blocking(pio, sm);    report.cxStick = pio_sm_get_blocking(pio, sm);    report.cyStick = pio_sm_get_blocking(pio, sm);    report.analogL = pio_sm_get_blocking(pio, sm);    report.analogL = pio_sm_get_blocking(pio, sm);}while(true){controller.get_report();}    

Statistics: Posted by AndyVotava — Wed Dec 04, 2024 4:00 pm



Viewing all articles
Browse latest Browse all 5091

Trending Articles