Microprocessor and peripheral 2 assignments for AUTH
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

jiffies.h 2.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*!
  2. * \file jiffies.h
  3. * \brief
  4. * A target independent jiffy functionality
  5. *
  6. * Author: Christos Choutouridis AEM: 8997
  7. * email : <cchoutou@ece.auth.gr>
  8. *
  9. */
  10. #ifndef __jiffies_h__
  11. #define __jiffies_h__
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #include <stdint.h>
  16. #include <string.h>
  17. #include "driver_types.h"
  18. typedef uint16_t jiffy_t; //!< Jiffy type 2 byte unsigned integer
  19. typedef int32_t jtime_t; //!< Jiffy time type for delay functionalities usec/msec
  20. typedef int (*jf_setfreq_pt) (uint32_t, uint32_t); //!< Pointer to setfreq function \sa setfreq
  21. /*!
  22. * Jiffy inner structure,
  23. * \info
  24. * We use jiffies to count small time intervals and usually this is
  25. * below SysTick Interrupt. So we use an indepentend counter for that.
  26. * Linux names jiffies the Tick per sec. This is toooo big for us.
  27. * We name jiffy each tick of the extra timer.
  28. * The equalivent of linux jiffies is the return value of clock ().
  29. */
  30. typedef volatile struct {
  31. jf_setfreq_pt setfreq; /*!< Pointer to driver's timer set freq function */
  32. /*
  33. * \note
  34. * This function must get an integer value for timer's desired
  35. * frequency and returns the maximum jiffy value. This usual
  36. * refers to timer's auto reload value.
  37. */
  38. jiffy_t *value; /*!< Pointer to timers current value */
  39. uint32_t freq; /*!< timer's frequency */
  40. jiffy_t jiffies; /*!< jiffies max value (timer's max value) */
  41. jiffy_t jp1ms; /*!< Jiffies per 1 msec to use in delay function */
  42. jiffy_t jp1us; /*!< Jiffies per 1 usec to use in delay function */
  43. jiffy_t jp100ns; /*!< Jiffies per 100 nsec to use in delay function */
  44. drv_status_en status;
  45. }jf_t;
  46. /*
  47. * ============= PUBLIC jiffy API =============
  48. */
  49. /*
  50. * Link and Glue functions
  51. */
  52. void jf_link_setfreq (jf_setfreq_pt pfun);
  53. void jf_link_value (jiffy_t* v);
  54. /*
  55. * Set functions
  56. */
  57. /*
  58. * User Functions
  59. */
  60. drv_status_en jf_probe (void);
  61. void jf_deinit (void);
  62. drv_status_en jf_init (uint32_t jf_freq, jiffy_t jiffies);
  63. jiffy_t jf_get_jiffies (void);
  64. jiffy_t jf_get_jiffy (void);
  65. jiffy_t jf_per_msec (void);
  66. jiffy_t jf_per_usec (void);
  67. jiffy_t jf_per_100nsec (void);
  68. void jf_delay_ms (jtime_t msec);
  69. void jf_delay_us (jtime_t usec);
  70. void jf_delay_100ns (jtime_t _100nsec);
  71. int jf_check_msec (jtime_t msec);
  72. int jf_check_usec (jtime_t usec);
  73. int jf_check_100nsec (jtime_t _100nsec);
  74. /*!
  75. * \note
  76. * The Jiffy lib has no jiffy_t target pointer in the API. This means
  77. * that IT CAN BE ONLY ONE jiffy timer per application.
  78. */
  79. #ifdef __cplusplus
  80. }
  81. #endif
  82. #endif //#ifndef __jiffies_h__