phillip_bourdon234

RTC_DS1307_Driver.h

Feb 28th, 2021
672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.51 KB | None | 0 0
  1. #ifndef RTC_Driver
  2. #define RTC_Driver
  3.  
  4. #include "stm32f10x.h"
  5. #include "system_stm32f10x.h"
  6.  
  7. //Macros to define the registers in the DS1307 module
  8. #define RTC_ADDRESS 0xD0   
  9. #define SECOND_REG  0x00
  10. #define MINUTE_REG  0x01
  11. #define HOUR_REG        0x02
  12. #define DAY_REG         0x03
  13. #define DATE_REG        0x04
  14. #define MONTH_REG       0x05
  15. #define YEAR_REG        0x06
  16.  
  17. //The rtc_init function simply calls the i2c_init function in the I2C_Driver
  18. void rtc_init(void);
  19.  
  20. //the rtc_set_time function takes in the hours, minutes, and seconds and
  21. //writes this data to the correct locations in the DS1307 in order to
  22. //modify the time of day
  23. void rtc_set_time(uint8_t hours, uint8_t minutes, uint8_t seconds);
  24.  
  25. //the rtc_set_date function takes in the month, date, and year and writes
  26. //this data to the correct locations in the DS1307 in order to modify the
  27. //month, date, and year
  28. void rtc_set_date(uint8_t month, uint8_t date, uint8_t year);
  29.  
  30. //the rtc_get_seconds function returns the value in the SECOND_REG
  31. uint8_t rtc_get_seconds(void);
  32.  
  33. //the rtc_get_minutes function returns the value in the MINUTE_REG
  34. uint8_t rtc_get_minutes(void);
  35.  
  36. //the rtc_get_hours function returns the value in the HOUR_REG
  37. uint8_t rtc_get_hours(void);
  38.  
  39. //the rtc_get_date function returns the value in the DATE_REG
  40. uint8_t rtc_get_date(void);
  41.  
  42. //the rtc_get_month function returns the value in the MONTH_REG
  43. uint8_t rtc_get_month(void);
  44.  
  45. //the rtc_get_year function returns the value in the YEAR_REG
  46. uint8_t rtc_get_year(void);
  47.  
  48.  
  49.  
  50.  
  51. #endif
  52.  
  53.  
Advertisement
Add Comment
Please, Sign In to add comment