SlideServe
Menu
Préférences
© SlideServe · v2026

Wireless Networks Lab – Callback Function

aschreiner avatar
14 diapositives · 221 Views · Jan 05, 2020

Learn how to utilize callback functions and setup Interrupt Service Routines to efficiently handle interrupt events. Integrating peripherals API for controlling LEDs and buttons.

Wireless Networks  Lab – Callback Function - slide 1
01 / 14Wireless Networks Lab – Callback Function
1 / 17

Télécharger la présentation

Wireless Networks Lab – Callback Function
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Wireless Networks Lab – Callback Function 2020/1/5

  2. Callback v.s. Polling • Polling • Using a loop to continuously check object. • Callback • Setup an ISR (Interrupt Service Routine). When an interrupt raises, the ISR will be called automatically to handle follow-up actions.

  3. Callback v.s. Polling • Lab1 • Lab2 • vAHI_TickTimerInit(vTickTimerISR); while (TRUE) { …… if (bBlink_Flag) { led_on(LED0); led_off(LED1); bBlink_Flag = FALSE; } …… }

  4. Sample • Install and Test

  5. Overview • Through Integrated Peripherals API, we can initialize the Button and LED devices. • Through FontalBSP, we can control the LEDs and monitor the button status • Through callback mechanism provided by Integrated Peripherals API, we can catch the interrupt event.

  6. Integrated peripherals API • The functions are defined in AppHardwareApi.h • u32AHI_init(void); • This should be called after every reset or wake-up and before any other AHI calls are made. • We can see that in sample codes about Lab1 and Lab2.

  7. BoardAPI • Allow rapid software development by providing a function library for interfacing to the evaluation board components • LED control • Button control • Sensor control • The FT 6250 device provides the FontalBSP.

  8. Callback function • Interrupt Handling • Interrupts from peripheral devices are handled by a set of device-specific callbacks. • callback registration PRIVATE void vHwDeviceIntCallback(uint32 u32DeviceId, uint32 u32ItemBitmap) • u32DeviceID is an enumerated value indicating the peripheral that generated the interrupt. • u32ItemBitmap is set for each individual interrupt source within the peripheral.

  9. vTickTimerISR PUBLIC void AppColdStart(void) { vAHI_TickTimerInit(vTickTimerISR); } PRIVATE void vTickTimerISR(uint32 u32DeviceId, uint32 u32ItemBitmap) { if (bBlink_Flag) { led_on(LED0); led_off(LED1); bBlink_Flag = FALSE; } else { led_on(LED1); led_off(LED0); bBlink_Flag = TRUE; } }

  10. Callback function • callback registration

  11. Lab2 • What should you do in this lab • Using the Callback function to handle the buttons interrupt events and control LEDs. • Bonus • Battery limitation • Using another ticktimer to save energy. If no one press the buttons for a long time, automatically turn them off. • Once each of buttons are pressed, you are required to let LED return the last status.

  12. Lab2 Flowchart

  13. Lab2 pseudo code • u32AHI_Init(); • u32AppApiInit(NULL, NULL, NULL, NULL, NULL, NULL, NULL); • led_init(); • btn_init(); • vAHI_SysCtrlRegisterCallback(vSystemISR);

  14. Callback function PRIVATE void vSystemISR(uint32 u32DeviceId, uint32 u32ItemBitmap) { switch (u32DeviceId) { case E_AHI_DEVICE_SYSCTRL: if (btn_pressed(BUTTON0)) …… break; default: break; } }