pando_command.c 1.3 KB

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