pando_event.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "pando_event.h"
  2. #include "../platform/include/pando_sys.h"
  3. #include "../protocol/pando_machine.h"
  4. #define MAX_EVENTS 16
  5. static pd_event s_pando_event_list[MAX_EVENTS];
  6. static int s_pando_event_list_idx = 0;
  7. /******************************************************************************
  8. * FunctionName : register_pando_event.
  9. * Description : register a pando event to framework.
  10. * Parameters : a pando event.
  11. * Returns : none.
  12. *******************************************************************************/
  13. void FUNCTION_ATTRIBUTE
  14. register_pando_event(pd_event event)
  15. {
  16. if(s_pando_event_list_idx > MAX_EVENTS - 1)
  17. {
  18. return;
  19. }
  20. s_pando_event_list[s_pando_event_list_idx++] = event;
  21. }
  22. /******************************************************************************
  23. * FunctionName : find_pando_event.
  24. * Description : find a pando event by event no.
  25. * Parameters : the event no.
  26. * Returns : the pando event of specified no, NULL if not found.
  27. *******************************************************************************/
  28. pd_event* FUNCTION_ATTRIBUTE
  29. find_pando_event(uint8_t no)
  30. {
  31. int i;
  32. for(i = 0; i < s_pando_event_list_idx; i++)
  33. {
  34. if( s_pando_event_list[i].no == no)
  35. {
  36. return &s_pando_event_list[i];
  37. }
  38. }
  39. return NULL;
  40. }