porttimer.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * FreeModbus Libary: BARE Port
  3. * Copyright (C) 2006 Christian Walter <wolti@sil.at>
  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$
  20. */
  21. /* ----------------------- Platform includes --------------------------------*/
  22. #include "port.h"
  23. #include "stm32f10x.h"
  24. /* ----------------------- Modbus includes ----------------------------------*/
  25. #include "mb.h"
  26. #include "mbport.h"
  27. /* ----------------------- static functions ---------------------------------*/
  28. void prvvTIMERExpiredISR( void );
  29. /* ----------------------- Start implementation -----------------------------*/
  30. BOOL
  31. xMBPortTimersInit( USHORT usTim1Timerout50us )
  32. {
  33. return TRUE;
  34. }
  35. inline void
  36. vMBPortTimersEnable( )
  37. {
  38. /* Enable the timer with the timeout passed to xMBPortTimersInit( ) */
  39. TIM_SetCounter(TIM2, 0);
  40. TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
  41. TIM_Cmd(TIM2, ENABLE);
  42. }
  43. inline void
  44. vMBPortTimersDisable( )
  45. {
  46. /* Disable any pending timers. */
  47. TIM_SetCounter(TIM2, 0);
  48. TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
  49. TIM_Cmd(TIM2, DISABLE);
  50. }
  51. /* Create an ISR which is called whenever the timer has expired. This function
  52. * must then call pxMBPortCBTimerExpired( ) to notify the protocol stack that
  53. * the timer has expired.
  54. */
  55. void prvvTIMERExpiredISR( void )
  56. {
  57. ( void )pxMBPortCBTimerExpired( );
  58. }