diff --git a/tp3/TP3.componentinfo.xml b/tp3/TP3.componentinfo.xml new file mode 100755 index 0000000..4cc4dd7 --- /dev/null +++ b/tp3/TP3.componentinfo.xml @@ -0,0 +1,86 @@ + + + + + + + Device + Startup + + + Atmel + 1.2.0 + C:/Program Files (x86)\Atmel\Studio\7.0\Packs + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\include + + include + C + + + include + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\include\avr\iom16.h + + header + C + BDa+/Y5e630de26bwSjZpg== + + include/avr/iom16.h + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\templates\main.c + template + source + C Exe + g/uCyfFENHok599MgaxPdw== + + templates/main.c + Main file (.c) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\templates\main.cpp + template + source + C Exe + YXFphlh0CtZJU+ebktABgQ== + + templates/main.cpp + Main file (.cpp) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\gcc\dev\atmega16 + + libraryPrefix + GCC + + + gcc/dev/atmega16 + + + + + ATmega_DFP + C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.132/Atmel.ATmega_DFP.pdsc + 1.2.132 + true + ATmega16 + + + + Resolved + Fixed + true + + + \ No newline at end of file diff --git a/tp3/TP3.cproj b/tp3/TP3.cproj new file mode 100755 index 0000000..91f9c28 --- /dev/null +++ b/tp3/TP3.cproj @@ -0,0 +1,157 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATmega16 + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + TP3 + TP3 + TP3 + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 0 + + + + + + + + + + + + + com.atmel.avrdbg.tool.stk500 + + 0x1E9403 + + + + 460800 + + ISP + + com.atmel.avrdbg.tool.stk500 + + + STK500 + + ISP + 460800 + 0 + + + + + + -mmcu=atmega16 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\gcc\dev\atmega16" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + + + + + + + -mmcu=atmega16 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\gcc\dev\atmega16" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + Default (-Wa,-g) + + + + + + compile + + + compile + + + compile + + + compile + + + compile + + + + \ No newline at end of file diff --git a/tp3/affiche_temp.c b/tp3/affiche_temp.c new file mode 100644 index 0000000..54966a1 --- /dev/null +++ b/tp3/affiche_temp.c @@ -0,0 +1,24 @@ +/* + * TP3.c + * + * Created: 10/02/2021 09:09:54 + * Author : yboujon1 + */ + +#include "spi.h" +#include "ds1722.h" + +int main(void) +{ + DDRA = 0xFF; //sortie des LEDS + char temp; //température de type char (8bit) + SPI_init(); + DS1722_init(); + _delay_ms(5); //on attends 5 ms pour être sûr de l'initialisation + while (1) + { + temp=DS1722_read(); //on récupère la température grâce à la fonction + PORTA=~temp; //on affiche la température sur les leds (logique inverse) + _delay_ms(1000); //on attends 1 seconde + } +} \ No newline at end of file diff --git a/tp3/ds1722.c b/tp3/ds1722.c new file mode 100644 index 0000000..5d6bb2c --- /dev/null +++ b/tp3/ds1722.c @@ -0,0 +1,18 @@ +#include "spi.h" +#include "ds1722.h" + +void DS1722_init(void){ + PORTB |= 1< +#include + +#define REG_D51722_CONFIG_BIT 0x80 //on veut écrire à l'adresse 0x00, nous devons mettre 0x80 +#define REG_D51722_CONFIG_WRITE 0xE0 //on a 111 puis nous avons que des 0 car nous voulons + //une resolution basse (R), donne la dernière température (1SHOT) et allumé (SD) +#define REG_D51722_MSB 0x02 //on veut lire la température du capteur + +char DS1722_read(void); //on envoie 0x02 pour lire la température, on envoie 0 par la suite et cela remplace la valeur de temp +void DS1722_init(void); //on écrit 0x80 pour acceder au bit 0x00, ensuite on écrit la configuration, soit 0xE0 \ No newline at end of file diff --git a/tp3/main.h b/tp3/main.h new file mode 100644 index 0000000..c202737 --- /dev/null +++ b/tp3/main.h @@ -0,0 +1,2 @@ +#include "spi.h" +#include "ds1722.h" \ No newline at end of file diff --git a/tp3/spi.c b/tp3/spi.c new file mode 100644 index 0000000..bc985c3 --- /dev/null +++ b/tp3/spi.c @@ -0,0 +1,15 @@ +#include "spi.h" +#include "ds1722.h" + +void SPI_init(void){ + DDRB = (1< F_CPU/16, et CPHA à 1, donc lecture en front decendant +char SPI_transmit_receive(char c); //on écrit des données et on les reçois \ No newline at end of file