portevent_m.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * FreeModbus Libary: STM32 Port
  3. * Copyright (C) 2013 Armink <armink.ztl@gmail.com>
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. *
  19. * File: $Id: portevent_m.c v 1.60 2013/08/13 15:07:05 Armink add Master Functions$
  20. */
  21. /* ----------------------- Modbus includes ----------------------------------*/
  22. #include "mb.h"
  23. #include "mbport.h"
  24. #if MB_MASTER_RTU_ENABLED > 0 || MB_MASTER_ASCII_ENABLED
  25. /* ----------------------- Variables ----------------------------------------*/
  26. static eMBMasterEventType eMasterQueuedEvent;
  27. static BOOL xMasterEventInQueue;
  28. /* ----------------------- Start implementation -----------------------------*/
  29. BOOL
  30. xMBMasterPortEventInit( void )
  31. {
  32. xMasterEventInQueue = FALSE;
  33. return TRUE;
  34. }
  35. BOOL
  36. xMBMasterPortEventPost( eMBMasterEventType eEvent )
  37. {
  38. xMasterEventInQueue = TRUE;
  39. eMasterQueuedEvent = eEvent;
  40. return TRUE;
  41. }
  42. BOOL
  43. xMBMasterPortEventGet( eMBMasterEventType * eEvent )
  44. {
  45. BOOL xEventHappened = FALSE;
  46. if( xMasterEventInQueue )
  47. {
  48. *eEvent = eMasterQueuedEvent;
  49. xMasterEventInQueue = FALSE;
  50. xEventHappened = TRUE;
  51. }
  52. return xEventHappened;
  53. }
  54. #endif