| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- /*
- * RTC.h
- *
- * Created on: 14 janv. 2019
- * Author: e_rcluze
- *
- * Penser a ajouter les fonction de lecture ecriture dans le fichier i2c.c "générer"
- *
- *
- *
- void readRTC(uint8_t add, uint8_t *tab, int len){
- uint8_t ad[1];
- ad[0]=add;
- HAL_StatusTypeDef res;
- res = HAL_I2C_Master_Transmit(&hi2c?,RTC_ADD,ad,1,1000);
- res = HAL_I2C_Master_Receive(&hi2c?,RTC_ADD,tab,len,1000);
- }
- void writeRTC(uint8_t add, uint8_t *tab, int len){
- uint8_t ad[len+1];
- ad[0]=add;
- for (int i = 0; i< len;i++){
- ad[i+1]=tab[i];
- }
- HAL_StatusTypeDef res;
- res = HAL_I2C_Master_Transmit(&hi2c3,RTC_ADD,ad,len+1,1000);
- }
- *
- */
- #ifndef RTC_H
- #define RTC_H
- #include <stdint.h>
- #define RTC_ADD 0XD0
- #define CENTIEM 0X00
- #define SECOND 0X01
- #define MINUTES 0X02
- #define HOURS 0X03
- #define DAYWEEK 0X04
- #define DAY 0X05
- #define MONTHS 0X06
- #define YEAR 0X07
- #define CALIBRATION 0X08
- #define WATCHDOG 0X09
- #define ALARM_MONTH 0X0A
- #define ALARM_DAY 0X0B
- #define ALARM_HOURS 0X0C
- #define ALARM_MINUTES 0X0D
- #define ALARM_SECOND 0X0E
- #define FLAGS 0X0F
- #define TIMER_VALUE 0X10
- #define TIMER_CONTROL 0X11
- #define ANALOG_CALIBRATION 0X12
- #define SQW 0X13
- typedef struct {
- uint8_t second;
- uint8_t minute;
- uint8_t heure;
- uint8_t jour;
- uint8_t joursemaine;
- uint8_t mois;
- uint8_t annee;
- }Date;
- typedef struct {
- uint8_t minute;
- uint8_t heure;
- }Heure;
- void readHeure(Heure *heure);
- void readDate(Date *date);
- void redemareRTC();
- void writeDate(Date *date);
- /**
- * Fonction qui permet de tester le matériel
- */
- void testRTC();
- void testBatteryRTC();
- #endif /* RTC_H */
|