Microprocessor and peripheral 2 assignments for AUTH
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

64 lines
1.7 KiB

  1. /*!
  2. * \file
  3. * assign2_impl.h
  4. * \brief
  5. * Assignment 2 application header
  6. *
  7. * Created on: May 23, 2020
  8. * Author: Christos Choutouridis AEM: 8997
  9. * email : <cchoutou@ece.auth.gr>
  10. */
  11. #ifndef ASSIGN2_IMPL_H_
  12. #define ASSIGN2_IMPL_H_
  13. #include "NUCLEO_F401RE.h"
  14. #include <stdlib.h>
  15. #include <math.h>
  16. /*
  17. * ============= User defines ===============
  18. */
  19. #define SYSTICK_FREQ (1000) //!< 1000Hz => 1msec accuracy
  20. #define MODE_LEADING_EDGE (1) //!< Start counting as soon as the led is switched on
  21. #define MODE_TRAILING_EDGE (2) //!< Start counting as soon as the led is switched off (Motor sport style)
  22. //! If there is no Pre-define MODE, select one here
  23. #ifndef MODE
  24. #define MODE MODE_TRAILING_EDGE
  25. #endif
  26. #define MEASUREMENTS (5) //!< The number of measurements for each experiment
  27. //! elect the maximum waiting time before the visual trigger.
  28. #define MAX_WAIT_TIME sec2CPUtime(10)
  29. //! Select if we need cycle counting also.
  30. #define CYCLE_COUNTING (1)
  31. /*
  32. * ============= Data types ===============
  33. */
  34. //! Select the application wide accuracy of the floating point type.
  35. typedef float fp_data_t; //!< floating point data alias.
  36. /*!
  37. * Statistical data structure
  38. */
  39. typedef struct {
  40. fp_data_t average; //!< The average response time of the experiment
  41. fp_data_t median; //!< The median of the times
  42. fp_data_t std_dev; //!< Standard deviation
  43. } stats_t;
  44. fp_data_t average (const clock_t *t, size_t n);
  45. fp_data_t median (const clock_t *t, size_t n);
  46. fp_data_t std_deviation (const clock_t* t, size_t n);
  47. void leading (clock_t *out, size_t n);
  48. void trailing (clock_t *out, size_t n);
  49. #endif /* ASSIGN2_IMPL_H_ */