Bladeren bron

Sauvgarde

remy 2 jaren geleden
bovenliggende
commit
d37cc9205b
10 gewijzigde bestanden met toevoegingen van 625 en 625 verwijderingen
  1. 90 90
      Source/Eeprom.c
  2. 52 52
      Source/Eeprom.h
  3. 43 43
      Source/FIFO_COM.c
  4. 40 40
      Source/FIFO_COM.h
  5. 50 50
      Source/Heure.c
  6. 42 42
      Source/Heure.h
  7. 72 72
      Source/PCF8574.c
  8. 40 40
      Source/PCF8574.h
  9. 109 109
      Source/RTC.c
  10. 87 87
      Source/RTC.h

+ 90 - 90
Source/Eeprom.c

@@ -1,90 +1,90 @@
-/*
- * V1.0
- */
-
-#include <Eeprom.h>
-
-/****Private fonction */
-
-void readEeprom(uint8_t *tab, int len){
-	//TODO (EEPROM IMPORTANT) On donne pas d'adresse a laqeuel on veux lire.
-	HAL_I2C_Master_Receive(&EEprom.I2C,EepromADD,tab,len,1000);
-}
-
-void writeEeprom(uint8_t *tab, int len){
-	//TODO (EEPROM IMPORTANT) On donne pas d'adresse a laqeuel on veux ecrire
-	HAL_GPIO_WritePin(&EEprom.WC_PORT,EEprom.WC_PIN,0);
-	HAL_I2C_Master_Transmit(&EEprom.I2C,EepromADD,tab,len,1000);
-	HAL_GPIO_WritePin(&EEprom.WC_PORT,EEprom.WC_PIN,1);
-}
-
-uint16_t readPointerEcriture(){
-	uint8_t t[2];
-	t[0]=0x00;
-	t[1]=0x00;
-	writeEeprom(t,2);
-	readEeprom(t,2);
-	uint16_t res = t[0]<<8 & t[1];
-	return res;
-}
-
-void writePointerEcriture(uint16_t p){
-	uint8_t t[4];
-	t[0]=0x00;
-	t[1]=0x00;
-	t[2]=(uint8_t)p>>8;
-	t[3]=(uint8_t)p>>8;
-	writeEeprom(t,4);
-}
-
-uint16_t readPointerLecture(){
-	uint8_t t[2];
-	t[0]=0x00;
-	t[1]=0x01;
-	writeEeprom(t,2);
-	readEeprom(t,2);
-	uint16_t res = t[0]<<8 & t[1];
-	return res;
-}
-
-void writePointerLecture(uint16_t p){
-	uint8_t t[4];
-	t[0]=0x00;
-	t[1]=0x01;
-	t[2]=(uint8_t)p>>8;
-	t[3]=(uint8_t)p>>8;
-	writeEeprom(t,4);
-}
-
-/** Public Fonction*/
-
-void initEprom(I2C_HandleTypeDef typ,GPIO_TypeDef port, uint16_t pin){
-	EEprom.I2C = typ;
-	EEprom.WC_PORT = port;
-	EEprom.WC_PIN = pin;
-}
-
-
-void writeData(uint16_t add, uint8_t *tab, uint8_t size){
-	uint8_t t[size+2];
-	t[0]=add>>8;
-	t[1]=add;
-	for(int i=0;i<size;i++)
-		t[i+2]=tab[i];
-	writeEeprom(t,size+2);
-}
-
-void readData(uint16_t add, uint8_t *tab, uint8_t size){
-	uint8_t t[size+2];
-	t[0]=add>>8;
-	t[1]=add;
-	writeEeprom(t,2);
-	readEeprom(tab,size);
-}
-
-//fonction pour tester le hard de l'Eeprom
-void testEeprom(){
-	uint16_t add = 0x04AA;
-	writePointerEcriture(add);
-	add = readPointerEcriture();
-}
+/*
+ * V1.0
+ */
+
+#include <Eeprom.h>
+
+/****Private fonction */
+
+void readEeprom(uint8_t *tab, int len){
+	//TODO (EEPROM IMPORTANT) On donne pas d'adresse a laqeuel on veux lire.
+	HAL_I2C_Master_Receive(&EEprom.I2C,EepromADD,tab,len,1000);
+}
+
+void writeEeprom(uint8_t *tab, int len){
+	//TODO (EEPROM IMPORTANT) On donne pas d'adresse a laqeuel on veux ecrire
+	HAL_GPIO_WritePin(&EEprom.WC_PORT,EEprom.WC_PIN,0);
+	HAL_I2C_Master_Transmit(&EEprom.I2C,EepromADD,tab,len,1000);
+	HAL_GPIO_WritePin(&EEprom.WC_PORT,EEprom.WC_PIN,1);
+}
+
+uint16_t readPointerEcriture(){
+	uint8_t t[2];
+	t[0]=0x00;
+	t[1]=0x00;
+	writeEeprom(t,2);
+	readEeprom(t,2);
+	uint16_t res = t[0]<<8 & t[1];
+	return res;
+}
+
+void writePointerEcriture(uint16_t p){
+	uint8_t t[4];
+	t[0]=0x00;
+	t[1]=0x00;
+	t[2]=(uint8_t)p>>8;
+	t[3]=(uint8_t)p>>8;
+	writeEeprom(t,4);
+}
+
+uint16_t readPointerLecture(){
+	uint8_t t[2];
+	t[0]=0x00;
+	t[1]=0x01;
+	writeEeprom(t,2);
+	readEeprom(t,2);
+	uint16_t res = t[0]<<8 & t[1];
+	return res;
+}
+
+void writePointerLecture(uint16_t p){
+	uint8_t t[4];
+	t[0]=0x00;
+	t[1]=0x01;
+	t[2]=(uint8_t)p>>8;
+	t[3]=(uint8_t)p>>8;
+	writeEeprom(t,4);
+}
+
+/** Public Fonction*/
+
+void initEprom(I2C_HandleTypeDef typ,GPIO_TypeDef port, uint16_t pin){
+	EEprom.I2C = typ;
+	EEprom.WC_PORT = port;
+	EEprom.WC_PIN = pin;
+}
+
+
+void writeData(uint16_t add, uint8_t *tab, uint8_t size){
+	uint8_t t[size+2];
+	t[0]=add>>8;
+	t[1]=add;
+	for(int i=0;i<size;i++)
+		t[i+2]=tab[i];
+	writeEeprom(t,size+2);
+}
+
+void readData(uint16_t add, uint8_t *tab, uint8_t size){
+	uint8_t t[size+2];
+	t[0]=add>>8;
+	t[1]=add;
+	writeEeprom(t,2);
+	readEeprom(tab,size);
+}
+
+//fonction pour tester le hard de l'Eeprom
+void testEeprom(){
+	uint16_t add = 0x04AA;
+	writePointerEcriture(add);
+	add = readPointerEcriture();
+}

+ 52 - 52
Source/Eeprom.h

@@ -1,52 +1,52 @@
-/*
- * Eeprom.h V1.0
- *
- *  Created on: 14 janv. 2019
- *      Author: e_rcluze
- *
- *Le fonctionement de l'Eeprom est en Fifo.
- *L'adrresse du pointeur de lecture est stocker dans les 16 premier byte de l'eeprom
- *L'adrresse du pointeur d'ecriture est stocker dans les 16 bit suivant
- *
- *
- *
- *
- */
-
-#ifndef EEPROM_H_
-#define EEPROM_H_
-
-#include <stdint.h>
-#include "i2c.h"
-
-#define EepromADD 0XA0
-
-typedef struct {
-	I2C_HandleTypeDef I2C;
-	GPIO_TypeDef WC_PORT;
-	uint16_t WC_PIN;
-} EEprom_HandleTypeDef;
-
-EEprom_HandleTypeDef EEprom;
-
-/****Private fonction */
-void readEeprom(uint8_t *tab, int len);
-void writeEeprom(uint8_t *tab, int len);
-
-uint16_t readPointerEcriture();
-void writePointerEcriture(uint16_t p);
-
-uint16_t readPointerLecture();
-void writePointerLecture(uint16_t p);
-
-/** Public Fonction*/
-
-void initEprom(I2C_HandleTypeDef typ, GPIO_TypeDef port, uint16_t pin);
-
-void writeData(uint16_t add, uint8_t *tab, uint8_t size);
-
-void readData(uint16_t add, uint8_t *tab, uint8_t size);
-
-void testEeprom(); //fonction pour tester le hard de l'Eeprom
-
-#endif /* EEPROM_H_ */
+/*
+ * Eeprom.h V1.0
+ *
+ *  Created on: 14 janv. 2019
+ *      Author: e_rcluze
+ *
+ *Le fonctionement de l'Eeprom est en Fifo.
+ *L'adrresse du pointeur de lecture est stocker dans les 16 premier byte de l'eeprom
+ *L'adrresse du pointeur d'ecriture est stocker dans les 16 bit suivant
+ *
+ *
+ *
+ *
+ */
+
+#ifndef EEPROM_H_
+#define EEPROM_H_
+
+#include <stdint.h>
+#include "i2c.h"
+
+#define EepromADD 0XA0
+
+typedef struct {
+	I2C_HandleTypeDef I2C;
+	GPIO_TypeDef WC_PORT;
+	uint16_t WC_PIN;
+} EEprom_HandleTypeDef;
+
+EEprom_HandleTypeDef EEprom;
+
+/****Private fonction */
+void readEeprom(uint8_t *tab, int len);
+void writeEeprom(uint8_t *tab, int len);
+
+uint16_t readPointerEcriture();
+void writePointerEcriture(uint16_t p);
+
+uint16_t readPointerLecture();
+void writePointerLecture(uint16_t p);
+
+/** Public Fonction*/
+
+void initEprom(I2C_HandleTypeDef typ, GPIO_TypeDef port, uint16_t pin);
+
+void writeData(uint16_t add, uint8_t *tab, uint8_t size);
+
+void readData(uint16_t add, uint8_t *tab, uint8_t size);
+
+void testEeprom(); //fonction pour tester le hard de l'Eeprom
+
+#endif /* EEPROM_H_ */

+ 43 - 43
Source/FIFO_COM.c

@@ -1,43 +1,43 @@
-/*
- * V1.0
- */
-
-
-// ne fonctionne pas a ne pas utiliser
-#include "FIFO_COM.h"
-/*
-void initFIFO(FIFO_COM *f){
-	f->pt_read = 0;
-	f->pt_write = 0;
-	f->nb_Element =0;
-}
-
-void readFifo(FIFO_COM *f, uint8_t *r) {
-	for (uint8_t i = 0; i < 8 ; i++) {
-		if (f->pt_read + i >= NBFIFO)
-			r[i] = f->Fifo[f->pt_read + i - NBFIFO];
-		else
-			r[i] = f->Fifo[f->pt_read + i];
-	}
-	if (f->pt_read + 8 >= NBFIFO)
-		f->pt_read = f->pt_read + 8 - NBFIFO;
-	else
-		f->pt_read = f->pt_read + 8;
-}
-
-void writeFifo(FIFO_COM *f, uint8_t *r) {
-	uint8_t i;
-	uint8_t nb = FIFO_nbRead(f);
-
-	for (i = 0; i < 8;i++) {
-
-	}
-	if (f->pt_write + 8 >= NBFIFO)
-		f->pt_write = f->pt_write + 8 - NBFIFO;
-	else
-		f->pt_write = f->pt_write + nb*8;
-}
-
-uint8_t FIFO_nbRead(FIFO_COM *f) {
-	return f->nb_Element;
-}*/
+/*
+ * V1.0
+ */
+
+
+// ne fonctionne pas a ne pas utiliser
+#include "FIFO_COM.h"
+/*
+void initFIFO(FIFO_COM *f){
+	f->pt_read = 0;
+	f->pt_write = 0;
+	f->nb_Element =0;
+}
+
+void readFifo(FIFO_COM *f, uint8_t *r) {
+	for (uint8_t i = 0; i < 8 ; i++) {
+		if (f->pt_read + i >= NBFIFO)
+			r[i] = f->Fifo[f->pt_read + i - NBFIFO];
+		else
+			r[i] = f->Fifo[f->pt_read + i];
+	}
+	if (f->pt_read + 8 >= NBFIFO)
+		f->pt_read = f->pt_read + 8 - NBFIFO;
+	else
+		f->pt_read = f->pt_read + 8;
+}
+
+void writeFifo(FIFO_COM *f, uint8_t *r) {
+	uint8_t i;
+	uint8_t nb = FIFO_nbRead(f);
+
+	for (i = 0; i < 8;i++) {
+
+	}
+	if (f->pt_write + 8 >= NBFIFO)
+		f->pt_write = f->pt_write + 8 - NBFIFO;
+	else
+		f->pt_write = f->pt_write + nb*8;
+}
+
+uint8_t FIFO_nbRead(FIFO_COM *f) {
+	return f->nb_Element;
+}*/

+ 40 - 40
Source/FIFO_COM.h

@@ -1,40 +1,40 @@
-/*
- * FIFO_COM.h V1.0
- *
- *  Created on: 14 janv. 2019
- *      Author: e_rcluze
- */
-
-#ifndef _FIFO_COM_H_
-#define _FIFO_COM_H_
-
-// ne fonctionne pas a ne pas utiliser
-
-#include <stdint.h>
-
-#define NBFIFO 16*8 //Toujours un multiple de 8
-
-typedef struct{
-	uint8_t Fifo[NBFIFO];
-	uint8_t pt_read;
-	uint8_t pt_write;
-	uint8_t nb_Element;
-}FIFO_COM;
-
-
-void initFIFO(FIFO_COM *f);
-
-/*
- * lit dans la fifo (toujours 8 caractere)
- */
-void readFifo(FIFO_COM *f, uint8_t *r);
-
-void writeFifo(FIFO_COM *f, uint8_t *r);
-
-/*
- * retourne le nombre d'element a lire dans la fifo
- */
-uint8_t FIFO_nbRead(FIFO_COM *f);
-
-
-#endif /* _FIFO_COM_H_ */
+/*
+ * FIFO_COM.h V1.0
+ *
+ *  Created on: 14 janv. 2019
+ *      Author: e_rcluze
+ */
+
+#ifndef _FIFO_COM_H_
+#define _FIFO_COM_H_
+
+// ne fonctionne pas a ne pas utiliser
+
+#include <stdint.h>
+
+#define NBFIFO 16*8 //Toujours un multiple de 8
+
+typedef struct{
+	uint8_t Fifo[NBFIFO];
+	uint8_t pt_read;
+	uint8_t pt_write;
+	uint8_t nb_Element;
+}FIFO_COM;
+
+
+void initFIFO(FIFO_COM *f);
+
+/*
+ * lit dans la fifo (toujours 8 caractere)
+ */
+void readFifo(FIFO_COM *f, uint8_t *r);
+
+void writeFifo(FIFO_COM *f, uint8_t *r);
+
+/*
+ * retourne le nombre d'element a lire dans la fifo
+ */
+uint8_t FIFO_nbRead(FIFO_COM *f);
+
+
+#endif /* _FIFO_COM_H_ */

+ 50 - 50
Source/Heure.c

@@ -1,50 +1,50 @@
-/*
- * V1.0
- */
-
-#include "RTC.h"
-#include "Heure.h"
-
-int8_t CompareHeure(Heure h1, Heure h2) {
-
-	if (h1.heure == h2.heure) {
-		if (h1.minute == h2.minute)
-			return 0;
-		else if (h1.minute < h2.minute)
-			return -1;
-		else
-			return 1;
-	} else if (h1.heure < h2.heure)
-		return -1;
-	else
-		return 1;
-}
-
-void HeureAjout(Heure res, Heure h1, uint8_t Pente) {
-	uint8_t minute = h1.minute + Pente;
-	res.heure = h1.heure + minute / 60;
-	res.minute = minute % 60;
-}
-
-void HeureSuppr(Heure res, Heure h1, uint8_t Pente) {
-	int8_t minute = h1.minute - Pente;
-	if (minute < 0) {
-		res.heure = h1.heure - 1;
-		res.minute = minute + 60;
-	} else {
-		res.heure = h1.heure;
-		res.minute = minute;
-	}
-}
-
-int16_t DiffHeure(Heure h1, Heure h2) {
-	return ((h1.heure - h2.heure) * 60) + (h1.minute - h2.minute);
-}
-
-int32_t DiffDate(Date h1, Date h2) {
-	int32_t min = h1.minute - h2.minute;
-	int32_t heure = (h1.heure - h2.heure) * 60;
-	int32_t jour = (h1.jour - h2.jour) * 24 * 60;
-	int32_t annee = (h1.annee - h2.annee) * 24 * 60 * 365;
-	return min + heure + jour + annee;
-}
+/*
+ * V1.0
+ */
+
+#include "RTC.h"
+#include "Heure.h"
+
+int8_t CompareHeure(Heure h1, Heure h2) {
+
+	if (h1.heure == h2.heure) {
+		if (h1.minute == h2.minute)
+			return 0;
+		else if (h1.minute < h2.minute)
+			return -1;
+		else
+			return 1;
+	} else if (h1.heure < h2.heure)
+		return -1;
+	else
+		return 1;
+}
+
+void HeureAjout(Heure res, Heure h1, uint8_t Pente) {
+	uint8_t minute = h1.minute + Pente;
+	res.heure = h1.heure + minute / 60;
+	res.minute = minute % 60;
+}
+
+void HeureSuppr(Heure res, Heure h1, uint8_t Pente) {
+	int8_t minute = h1.minute - Pente;
+	if (minute < 0) {
+		res.heure = h1.heure - 1;
+		res.minute = minute + 60;
+	} else {
+		res.heure = h1.heure;
+		res.minute = minute;
+	}
+}
+
+int16_t DiffHeure(Heure h1, Heure h2) {
+	return ((h1.heure - h2.heure) * 60) + (h1.minute - h2.minute);
+}
+
+int32_t DiffDate(Date h1, Date h2) {
+	int32_t min = h1.minute - h2.minute;
+	int32_t heure = (h1.heure - h2.heure) * 60;
+	int32_t jour = (h1.jour - h2.jour) * 24 * 60;
+	int32_t annee = (h1.annee - h2.annee) * 24 * 60 * 365;
+	return min + heure + jour + annee;
+}

+ 42 - 42
Source/Heure.h

@@ -1,42 +1,42 @@
-/*
- * Heure.h V1.0
- *
- *  Created on: 14 mai 2019
- *      Author: e_rcluze
- */
-
-#ifndef HEURE_H_
-#define HEURE_H_
-
-#include <stdint.h>
-
-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;
-
-/**
- * fonction qui renvoie
- * 	-1 si h1 est inf�rieur que H2
- * 	0 si h1 et h2 egale
- * 	1 si h1 est sup�rieur a h2
- */
-int8_t CompareHeure(Heure h1, Heure h2);
-
-int16_t DiffHeure(Heure h1, Heure h2);
-
-int32_t DiffDate(Date h1, Date h2);
-
-#endif /* HEURE_H_ */
+/*
+ * Heure.h V1.0
+ *
+ *  Created on: 14 mai 2019
+ *      Author: e_rcluze
+ */
+
+#ifndef HEURE_H_
+#define HEURE_H_
+
+#include <stdint.h>
+
+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;
+
+/**
+ * fonction qui renvoie
+ * 	-1 si h1 est inf�rieur que H2
+ * 	0 si h1 et h2 egale
+ * 	1 si h1 est sup�rieur a h2
+ */
+int8_t CompareHeure(Heure h1, Heure h2);
+
+int16_t DiffHeure(Heure h1, Heure h2);
+
+int32_t DiffDate(Date h1, Date h2);
+
+#endif /* HEURE_H_ */

+ 72 - 72
Source/PCF8574.c

@@ -1,72 +1,72 @@
-/*
- * V1.0
- */
- 
-#include "PCF8574.h"
-/*
- * Warning Warning
- *
- * Il existe 2 type de PCF8474 les  PCF8474A et les PCF8474.
- * les PCF8474A on des adresse en 0x4X, les PCF8474 ont des adresse en 0x7X.
- * La différence est faite dans partkeep dans ce projet j'ai utilisé des A
- *
- */
-
-uint8_t ADD_PCF8474[] = { 0x40, 0x42, 0x44, 0x46, 0x48, 0x4A, 0x4C, 0x4E };
-//uint8_t ADD_PCF8474[] = {0x70, 0x72, 0x74, 0x76, 0x78, 0x7A, 0x7C, 0x7E};
-
-/** Private Fonction*/
-HAL_StatusTypeDef read_I2C_PCF8574(uint8_t add, uint8_t *tab) {
-	HAL_StatusTypeDef res;
-	int nbTentative = 0;
-	while ((res = HAL_I2C_Master_Receive(I2C_PCF8574, add, tab, 1, 1000))!= HAL_OK) {
-		nbTentative++;
-		if (nbTentative > 3)
-			break;
-	}
-	return res;
-}
-
-HAL_StatusTypeDef write_I2C_PCF8574(uint8_t addresse, uint8_t *tab) {
-	HAL_StatusTypeDef res;
-	int nbTentative;
-	while ((res = HAL_I2C_Master_Transmit(I2C_PCF8574, addresse, tab, 1, 1000))!= HAL_OK) {
-		nbTentative++;
-		if (nbTentative > 3)
-			break;
-	}
-	return res;
-}
-
-/** Public Fonction*/
-
-void initPCF8574(I2C_HandleTypeDef *typ) {
-	I2C_PCF8574 = typ;
-	Write_PCF8574(0, 0);
-}
-
-HAL_StatusTypeDef Read_PCF8574(uint8_t addBit, uint8_t* val) {
-	return read_I2C_PCF8574(ADD_PCF8474[addBit], val);
-}
-
-HAL_StatusTypeDef Write_PCF8574(uint8_t addBit, uint8_t val) {
-	return write_I2C_PCF8574(ADD_PCF8474[addBit], &val);
-}
-
-HAL_StatusTypeDef Write_One_Bit_PCF8574(uint8_t addBit, uint8_t val, uint8_t Local) {
-	uint8_t valInt;
-	HAL_StatusTypeDef res;
-	res = read_I2C_PCF8574(ADD_PCF8474[addBit], &valInt);
-	if (res != HAL_OK)
-		return res;
-	if (val)
-		val = valInt | (val << Local);
-	else{
-		uint8_t inte=1<<Local;
-
-		inte = ~inte;
-		val = valInt & inte;
-	}
-	return write_I2C_PCF8574(ADD_PCF8474[addBit], &val);
-}
-
+/*
+ * V1.0
+ */
+ 
+#include "PCF8574.h"
+/*
+ * Warning Warning
+ *
+ * Il existe 2 type de PCF8474 les  PCF8474A et les PCF8474.
+ * les PCF8474A on des adresse en 0x4X, les PCF8474 ont des adresse en 0x7X.
+ * La différence est faite dans partkeep dans ce projet j'ai utilisé des A
+ *
+ */
+
+uint8_t ADD_PCF8474[] = { 0x40, 0x42, 0x44, 0x46, 0x48, 0x4A, 0x4C, 0x4E };
+//uint8_t ADD_PCF8474[] = {0x70, 0x72, 0x74, 0x76, 0x78, 0x7A, 0x7C, 0x7E};
+
+/** Private Fonction*/
+HAL_StatusTypeDef read_I2C_PCF8574(uint8_t add, uint8_t *tab) {
+	HAL_StatusTypeDef res;
+	int nbTentative = 0;
+	while ((res = HAL_I2C_Master_Receive(I2C_PCF8574, add, tab, 1, 1000))!= HAL_OK) {
+		nbTentative++;
+		if (nbTentative > 3)
+			break;
+	}
+	return res;
+}
+
+HAL_StatusTypeDef write_I2C_PCF8574(uint8_t addresse, uint8_t *tab) {
+	HAL_StatusTypeDef res;
+	int nbTentative;
+	while ((res = HAL_I2C_Master_Transmit(I2C_PCF8574, addresse, tab, 1, 1000))!= HAL_OK) {
+		nbTentative++;
+		if (nbTentative > 3)
+			break;
+	}
+	return res;
+}
+
+/** Public Fonction*/
+
+void initPCF8574(I2C_HandleTypeDef *typ) {
+	I2C_PCF8574 = typ;
+	Write_PCF8574(0, 0);
+}
+
+HAL_StatusTypeDef Read_PCF8574(uint8_t addBit, uint8_t* val) {
+	return read_I2C_PCF8574(ADD_PCF8474[addBit], val);
+}
+
+HAL_StatusTypeDef Write_PCF8574(uint8_t addBit, uint8_t val) {
+	return write_I2C_PCF8574(ADD_PCF8474[addBit], &val);
+}
+
+HAL_StatusTypeDef Write_One_Bit_PCF8574(uint8_t addBit, uint8_t val, uint8_t Local) {
+	uint8_t valInt;
+	HAL_StatusTypeDef res;
+	res = read_I2C_PCF8574(ADD_PCF8474[addBit], &valInt);
+	if (res != HAL_OK)
+		return res;
+	if (val)
+		val = valInt | (val << Local);
+	else{
+		uint8_t inte=1<<Local;
+
+		inte = ~inte;
+		val = valInt & inte;
+	}
+	return write_I2C_PCF8574(ADD_PCF8474[addBit], &val);
+}
+

+ 40 - 40
Source/PCF8574.h

@@ -1,40 +1,40 @@
-/*
- * PCF8574.h V1.0
- *
- *  Created on: 14 mai 2019
- *      Author: e_rcluze
- */
-
-
-#ifndef _PCF8474__H_
-#define _PCF8474__H_
-
-#include "i2c.h"
-#include <stdint.h>
-
-
-
-I2C_HandleTypeDef *I2C_PCF8574;
-
-/** Private Fonction*/
-HAL_StatusTypeDef read_I2C_PCF8574(uint8_t add, uint8_t *tab);
-
-HAL_StatusTypeDef write_I2C_PCF8574(uint8_t addresse, uint8_t *tab);
-/** Public Fonction*/
-
-void initPCF8574(I2C_HandleTypeDef *typ);
-
-/*
- * PAram addBit : la valeurs des bit A1 A2 A3:
- * 	0 0 0 = 0;
- * 	0 0 1 = 1;
- * 	0 1 0 = 2;
- * 	...
- */
-HAL_StatusTypeDef Read_PCF8574(uint8_t addBit, uint8_t* val);
-HAL_StatusTypeDef Write_PCF8574(uint8_t addBit,uint8_t val);
-HAL_StatusTypeDef Write_One_Bit_PCF8574(uint8_t addBit, uint8_t val, uint8_t Local);
-
-
-
-#endif
+/*
+ * PCF8574.h V1.0
+ *
+ *  Created on: 14 mai 2019
+ *      Author: e_rcluze
+ */
+
+
+#ifndef _PCF8474__H_
+#define _PCF8474__H_
+
+#include "i2c.h"
+#include <stdint.h>
+
+
+
+I2C_HandleTypeDef *I2C_PCF8574;
+
+/** Private Fonction*/
+HAL_StatusTypeDef read_I2C_PCF8574(uint8_t add, uint8_t *tab);
+
+HAL_StatusTypeDef write_I2C_PCF8574(uint8_t addresse, uint8_t *tab);
+/** Public Fonction*/
+
+void initPCF8574(I2C_HandleTypeDef *typ);
+
+/*
+ * PAram addBit : la valeurs des bit A1 A2 A3:
+ * 	0 0 0 = 0;
+ * 	0 0 1 = 1;
+ * 	0 1 0 = 2;
+ * 	...
+ */
+HAL_StatusTypeDef Read_PCF8574(uint8_t addBit, uint8_t* val);
+HAL_StatusTypeDef Write_PCF8574(uint8_t addBit,uint8_t val);
+HAL_StatusTypeDef Write_One_Bit_PCF8574(uint8_t addBit, uint8_t val, uint8_t Local);
+
+
+
+#endif

+ 109 - 109
Source/RTC.c

@@ -1,109 +1,109 @@
-/*
- * V1.0
- */
-
-/*
- * RTC.c
- *
- *  Created on: 15 janv. 2019
- *      Author: e_rcluze
- */
-
-#include "RTC.h"
-
-I2C_HandleTypeDef *I2C_RTC;
-
-/** Private Fonction*/
-HAL_StatusTypeDef readRTC(uint8_t reg, uint8_t *tab, int len) {
-	HAL_StatusTypeDef res = HAL_I2C_Master_Transmit(I2C_RTC, RTC_ADD, &reg, 1, 10000);
-	if(res != HAL_OK)
-		return res;
-	return HAL_I2C_Master_Receive(I2C_RTC, RTC_ADD, tab, len, 1000);
-}
-
-HAL_StatusTypeDef writeRTC(uint8_t reg, uint8_t *tab, int len) {
-	uint8_t t[len + 1];
-	t[0] = reg;
-	for (int i = 0; i < len; i++)
-		t[i + 1] = tab[i];
-	return HAL_I2C_Master_Transmit(I2C_RTC, RTC_ADD, t, len + 1, 1000);
-}
-
-/** Public Fonction*/
-
-void initRTC(I2C_HandleTypeDef *typ) {
-	I2C_RTC = typ;
-}
-
-HAL_StatusTypeDef readHeure(Heure *heure) {
-	uint8_t tab[2];
-	HAL_StatusTypeDef res = readRTC(MINUTES, tab, 2);
-	heure->minute = (((tab[0] & 0x70) >> 4) * 10) + (tab[0] & 0X0F);
-	heure->heure = (((tab[1] & 0X30) >> 4) * 10) + (tab[1] & 0X0F);
-	return res;
-}
-
-/** Public Fonction*/
-HAL_StatusTypeDef readDate(Date *date) {
-	uint8_t tab[7];
-	HAL_StatusTypeDef res = readRTC(SECOND, tab, 7);
-	date->second = (((tab[0] & 0X70) >> 4) * 10) + (tab[0] & 0X0F);
-	date->minute = (((tab[1] & 0x70) >> 4) * 10) + (tab[1] & 0X0F);
-	date->heure = (((tab[2] & 0X30) >> 4) * 10) + (tab[2] & 0X0F);
-	date->jour = (((tab[4] & 0X30) >> 4) * 10) + (tab[4] & 0X0F);
-	date->mois = (((tab[5] & 0X10) >> 4) * 10) + (tab[5] & 0X0F);
-	date->annee = ((tab[6] >> 4) * 10) + (tab[6] & 0X0F);
-	return res;
-}
-
-HAL_StatusTypeDef writeDate(Date *date) {
-	uint8_t tab[7];
-
-	tab[0] = ((date->second / 10) << 4) + (date->second % 10);
-	tab[1] = ((date->minute / 10) << 4) + (date->minute % 10);
-	tab[2] = ((date->heure / 10) << 4) + (date->heure % 10);
-	tab[3] = date->joursemaine;
-	tab[4] = ((date->jour / 10) << 4) + (date->jour % 10);
-	tab[5] = ((date->mois / 10) << 4) + (date->mois % 10);
-	tab[6] = ((date->annee / 10) << 4) + (date->annee % 10);
-
-	return writeRTC(SECOND, tab, 7);
-}
-
-HAL_StatusTypeDef redemareRTC() {
-	uint8_t pt[1];
-	HAL_StatusTypeDef res = readRTC(ALARM_HOURS, pt, 1);
-		if (res != HAL_OK)
-		return res;
-	pt[0] = pt[0] & !0x40;
-	return writeRTC(ALARM_HOURS, pt, 1);
-}
-
-void testRTC() {
-	Date d;
-	d.annee = 2020;
-	d.mois = 1;
-	d.jour = 20;
-	d.joursemaine = 1;
-	d.heure = 14;
-	d.minute = 0;
-	d.second = 0;
-	writeDate(&d);
-	redemareRTC();
-	HAL_Delay(2000);
-	readDate(&d);
-	HAL_Delay(1);
-}
-
-uint16_t HeureEnMinute() {
-	Heure h;
-	readHeure(&h);
-	return h.minute+h.heure*60;
-}
-
-void testBatteryRTC() {
-	redemareRTC();
-	Date d;
-	readDate(&d);
-	HAL_Delay(1);
-}
+/*
+ * V1.0
+ */
+
+/*
+ * RTC.c
+ *
+ *  Created on: 15 janv. 2019
+ *      Author: e_rcluze
+ */
+
+#include "RTC.h"
+
+I2C_HandleTypeDef *I2C_RTC;
+
+/** Private Fonction*/
+HAL_StatusTypeDef readRTC(uint8_t reg, uint8_t *tab, int len) {
+	HAL_StatusTypeDef res = HAL_I2C_Master_Transmit(I2C_RTC, RTC_ADD, &reg, 1, 10000);
+	if(res != HAL_OK)
+		return res;
+	return HAL_I2C_Master_Receive(I2C_RTC, RTC_ADD, tab, len, 1000);
+}
+
+HAL_StatusTypeDef writeRTC(uint8_t reg, uint8_t *tab, int len) {
+	uint8_t t[len + 1];
+	t[0] = reg;
+	for (int i = 0; i < len; i++)
+		t[i + 1] = tab[i];
+	return HAL_I2C_Master_Transmit(I2C_RTC, RTC_ADD, t, len + 1, 1000);
+}
+
+/** Public Fonction*/
+
+void initRTC(I2C_HandleTypeDef *typ) {
+	I2C_RTC = typ;
+}
+
+HAL_StatusTypeDef readHeure(Heure *heure) {
+	uint8_t tab[2];
+	HAL_StatusTypeDef res = readRTC(MINUTES, tab, 2);
+	heure->minute = (((tab[0] & 0x70) >> 4) * 10) + (tab[0] & 0X0F);
+	heure->heure = (((tab[1] & 0X30) >> 4) * 10) + (tab[1] & 0X0F);
+	return res;
+}
+
+/** Public Fonction*/
+HAL_StatusTypeDef readDate(Date *date) {
+	uint8_t tab[7];
+	HAL_StatusTypeDef res = readRTC(SECOND, tab, 7);
+	date->second = (((tab[0] & 0X70) >> 4) * 10) + (tab[0] & 0X0F);
+	date->minute = (((tab[1] & 0x70) >> 4) * 10) + (tab[1] & 0X0F);
+	date->heure = (((tab[2] & 0X30) >> 4) * 10) + (tab[2] & 0X0F);
+	date->jour = (((tab[4] & 0X30) >> 4) * 10) + (tab[4] & 0X0F);
+	date->mois = (((tab[5] & 0X10) >> 4) * 10) + (tab[5] & 0X0F);
+	date->annee = ((tab[6] >> 4) * 10) + (tab[6] & 0X0F);
+	return res;
+}
+
+HAL_StatusTypeDef writeDate(Date *date) {
+	uint8_t tab[7];
+
+	tab[0] = ((date->second / 10) << 4) + (date->second % 10);
+	tab[1] = ((date->minute / 10) << 4) + (date->minute % 10);
+	tab[2] = ((date->heure / 10) << 4) + (date->heure % 10);
+	tab[3] = date->joursemaine;
+	tab[4] = ((date->jour / 10) << 4) + (date->jour % 10);
+	tab[5] = ((date->mois / 10) << 4) + (date->mois % 10);
+	tab[6] = ((date->annee / 10) << 4) + (date->annee % 10);
+
+	return writeRTC(SECOND, tab, 7);
+}
+
+HAL_StatusTypeDef redemareRTC() {
+	uint8_t pt[1];
+	HAL_StatusTypeDef res = readRTC(ALARM_HOURS, pt, 1);
+		if (res != HAL_OK)
+		return res;
+	pt[0] = pt[0] & !0x40;
+	return writeRTC(ALARM_HOURS, pt, 1);
+}
+
+void testRTC() {
+	Date d;
+	d.annee = 2020;
+	d.mois = 1;
+	d.jour = 20;
+	d.joursemaine = 1;
+	d.heure = 14;
+	d.minute = 0;
+	d.second = 0;
+	writeDate(&d);
+	redemareRTC();
+	HAL_Delay(2000);
+	readDate(&d);
+	HAL_Delay(1);
+}
+
+uint16_t HeureEnMinute() {
+	Heure h;
+	readHeure(&h);
+	return h.minute+h.heure*60;
+}
+
+void testBatteryRTC() {
+	redemareRTC();
+	Date d;
+	readDate(&d);
+	HAL_Delay(1);
+}

+ 87 - 87
Source/RTC.h

@@ -1,87 +1,87 @@
-/*
- * RTC.h V1.0
- *
- *  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 "Heure.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
-
-
-
-/****Private fonction */
-HAL_StatusTypeDef readRTC(uint8_t reg, uint8_t *tab, int len);
-
-HAL_StatusTypeDef writeRTC(uint8_t reg, uint8_t *tab, int len);
-
-/** Public Fonction*/
-void initRTC(I2C_HandleTypeDef *typ);
-
-HAL_StatusTypeDef readHeure(Heure *heure);
-
-uint16_t HeureEnMinute();
-
-HAL_StatusTypeDef readDate(Date *date);
-
-HAL_StatusTypeDef redemareRTC();
-
-HAL_StatusTypeDef writeDate(Date *date);
-
-/**
- * Fonction qui permet de tester le mat�riel
- */
-void testRTC();
-
-void testBatteryRTC();
-
-#endif /* RTC_H */
+/*
+ * RTC.h V1.0
+ *
+ *  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 "Heure.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
+
+
+
+/****Private fonction */
+HAL_StatusTypeDef readRTC(uint8_t reg, uint8_t *tab, int len);
+
+HAL_StatusTypeDef writeRTC(uint8_t reg, uint8_t *tab, int len);
+
+/** Public Fonction*/
+void initRTC(I2C_HandleTypeDef *typ);
+
+HAL_StatusTypeDef readHeure(Heure *heure);
+
+uint16_t HeureEnMinute();
+
+HAL_StatusTypeDef readDate(Date *date);
+
+HAL_StatusTypeDef redemareRTC();
+
+HAL_StatusTypeDef writeDate(Date *date);
+
+/**
+ * Fonction qui permet de tester le mat�riel
+ */
+void testRTC();
+
+void testBatteryRTC();
+
+#endif /* RTC_H */