Guest User

Untitled

a guest
Jul 16th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. enum TN_RCode _tn_timer_start(struct TN_Timer *timer, TN_Timeout timeout)
  2. {
  3. /* ... real job is done here ... */
  4. }
  5.  
  6. /*
  7. * Function to be called from task
  8. */
  9. enum TN_RCode tn_timer_start(struct TN_Timer *timer, TN_Timeout timeout)
  10. {
  11. TN_INTSAVE_DATA; //-- define the variable to store interrupt status,
  12. // it is used by TN_INT_DIS_SAVE()
  13. // and TN_INT_RESTORE()
  14. enum TN_RCode rc = TN_RC_OK;
  15.  
  16. //-- check that function is called from right context
  17. if (!tn_is_task_context()){
  18. rc = TN_RC_WCONTEXT;
  19. goto out;
  20. }
  21.  
  22. //-- disable interrupts
  23. TN_INT_DIS_SAVE();
  24.  
  25. //-- perform real job, after all
  26. rc = _tn_timer_start(timer, timeout);
  27.  
  28. //-- restore interrupts state
  29. TN_INT_RESTORE();
  30.  
  31. out:
  32. return rc;
  33. }
  34.  
  35. /*
  36. * Function to be called from ISR
  37. */
  38. enum TN_RCode tn_timer_istart(struct TN_Timer *timer, TN_Timeout timeout)
  39. {
  40. TN_INTSAVE_DATA_INT; //-- define the variable to store interrupt status,
  41. // it is used by TN_INT_DIS_SAVE()
  42. // and TN_INT_RESTORE()
  43. enum TN_RCode rc = TN_RC_OK;
  44.  
  45. //-- check that function is called from right context
  46. if (!tn_is_isr_context()){
  47. rc = TN_RC_WCONTEXT;
  48. goto out;
  49. }
  50.  
  51. //-- disable interrupts
  52. TN_INT_IDIS_SAVE();
  53.  
  54. //-- perform real job, after all
  55. rc = _tn_timer_start(timer, timeout);
  56.  
  57. //-- restore interrupts state
  58. TN_INT_IRESTORE();
  59.  
  60. out:
  61. return rc;
  62. }
Add Comment
Please, Sign In to add comment