| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- /*
- * 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>
- #include "i2c.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;
- uint16_t annee;
- }Date;
- typedef struct {
- uint8_t minute;
- uint8_t heure;
- }Heure;
- I2C_HandleTypeDef I2C_RTC;
- /****Private fonction */
- void readRTC(uint8_t reg, uint8_t *tab, int len);
- void writeRTC(uint8_t reg, uint8_t *tab, int len);
- /** Public Fonction*/
- void initRTC(I2C_HandleTypeDef typ);
- 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 */
|