You are not logged in.
Hello,
I was wondering if there is a way to use the buttons PB1-3 in soft core (i.e., c code) in 802.11 reference design.
In other words, is it possible to detect button press in the soft core?
My goal is to launch a function (in c) when a button is pressed, ideally like a interrupt service routine.
Thank you in advance!
Last edited by ksong (2015-May-27 16:44:32)
Offline
You can use the macros in w3_userio.h to read the current status of the push buttons. However, the User IO pcore is not currently defined such that the push buttons can be used as interrupts. It would be possible to modify the definition of the User IO pcore MPD file to declare the push button outputs as interrupts and then connect them to the interrupt controller in XPS. Then you could set up ISRs in the software project for the new interrupts.
Another possible solution would be to use the existing UART infrastructure to allow you to interact with the node over putty to accomplish something similar. It would not be quite as convenient as using the pushbutton but easier from a implementation perspective.
Offline
The 802.11 ref design actually connects the push buttons to two cores- the w3_userio core, which only supports polling, and an axi_gpio core, which supports interrupts. The MAC framework handles the axi_gpio interrupt already. You can assign a callback for the up/middle/down push buttons via the functions below. The ISR will execute your callback when the corresponding button causes an axi_gpio interrupt. No FPGA design changes are required.
By default all 3 callbacks are null. Call the functions below in the top-level application after wlan_mac_high_init() to override the default.
wlan_mac_high_set_pb_u_callback(your_up_function_pointer); wlan_mac_high_set_pb_m_callback(your_middle_function_pointer); wlan_mac_high_set_pb_d_callback(your_down_function_pointer);
Offline
I apologize for the confusion. I was looking at the WARPLab reference design and had forgotten that we had set up the push buttons that way in the 802.11 reference design. Patrick is correct.
You should set up your callbacks in the main() function of either the AP, STA, or IBSS. For example, you can see the callback setup for the AP here. As you can see the UP button callback is populated with a dummy function. Just know that we have set up the callbacks for the push buttons such that no arguments are passed or returned so the function needs to be completely standalone (i.e. "void my_function(void)" ). If you need to pass arguments, then you will have to modify the callback setup in the GPIO interrupt handler.
Offline
Great, that is exactly what I need.
Thanks for the comments, Erik and Patrick :)
Offline