RTC.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * RTC.h V1.0
  3. *
  4. * Created on: 14 janv. 2019
  5. * Author: e_rcluze
  6. *
  7. * Penser a ajouter les fonction de lecture ecriture dans le fichier i2c.c "g�n�rer"
  8. *
  9. *
  10. *
  11. void readRTC(uint8_t add, uint8_t *tab, int len){
  12. uint8_t ad[1];
  13. ad[0]=add;
  14. HAL_StatusTypeDef res;
  15. res = HAL_I2C_Master_Transmit(&hi2c?,RTC_ADD,ad,1,1000);
  16. res = HAL_I2C_Master_Receive(&hi2c?,RTC_ADD,tab,len,1000);
  17. }
  18. void writeRTC(uint8_t add, uint8_t *tab, int len){
  19. uint8_t ad[len+1];
  20. ad[0]=add;
  21. for (int i = 0; i< len;i++){
  22. ad[i+1]=tab[i];
  23. }
  24. HAL_StatusTypeDef res;
  25. res = HAL_I2C_Master_Transmit(&hi2c3,RTC_ADD,ad,len+1,1000);
  26. }
  27. *
  28. */
  29. #ifndef RTC_H
  30. #define RTC_H
  31. #include "Heure.h"
  32. #include "i2c.h"
  33. #define RTC_ADD 0XD0
  34. #define CENTIEM 0X00
  35. #define SECOND 0X01
  36. #define MINUTES 0X02
  37. #define HOURS 0X03
  38. #define DAYWEEK 0X04
  39. #define DAY 0X05
  40. #define MONTHS 0X06
  41. #define YEAR 0X07
  42. #define CALIBRATION 0X08
  43. #define WATCHDOG 0X09
  44. #define ALARM_MONTH 0X0A
  45. #define ALARM_DAY 0X0B
  46. #define ALARM_HOURS 0X0C
  47. #define ALARM_MINUTES 0X0D
  48. #define ALARM_SECOND 0X0E
  49. #define FLAGS 0X0F
  50. #define TIMER_VALUE 0X10
  51. #define TIMER_CONTROL 0X11
  52. #define ANALOG_CALIBRATION 0X12
  53. #define SQW 0X13
  54. /****Private fonction */
  55. HAL_StatusTypeDef readRTC(uint8_t reg, uint8_t *tab, int len);
  56. HAL_StatusTypeDef writeRTC(uint8_t reg, uint8_t *tab, int len);
  57. /** Public Fonction*/
  58. void initRTC(I2C_HandleTypeDef *typ);
  59. HAL_StatusTypeDef readHeure(Heure *heure);
  60. uint16_t HeureEnMinute();
  61. HAL_StatusTypeDef readDate(Date *date);
  62. HAL_StatusTypeDef redemareRTC();
  63. HAL_StatusTypeDef writeDate(Date *date);
  64. /**
  65. * Fonction qui permet de tester le mat�riel
  66. */
  67. void testRTC();
  68. void testBatteryRTC();
  69. #endif /* RTC_H */