From e742bccc85fd659b0d596cd2a76444f7d4f7f5cc Mon Sep 17 00:00:00 2001 From: dmohamed Date: Sun, 2 Jul 2017 17:51:12 +0200 Subject: [PATCH] ADD - Séparation des fonctions de liaison série dans une librairie serial. --- Moteur/serial.c | 33 +++++++++++++++++++++++++++++++++ Moteur/serial.h | 13 +++++++++++++ 2 files changed, 46 insertions(+), 0 deletions(-) create mode 100644 Moteur/serial.c create mode 100644 Moteur/serial.h diff --git a/Moteur/serial.c b/Moteur/serial.c new file mode 100644 index 0000000..7636c6a --- /dev/null +++ b/Moteur/serial.c @@ -0,0 +1,33 @@ +#include "serial.h" + +void init_serial(unsigned long int speed) //initialisation de la liaison série +{ +/* Set baud rate */ +UBRR0 = CPU_FREQ/(((unsigned long int)speed)<<4)-1; + +/* Enable transmitter & receiver */ +UCSR0B = (1< // for the input/output register +#include + +#define CPU_FREQ 16000000L // Assume a CPU frequency of 16Mhz + +void init_serial(unsigned long int speed); +void send_serial(uint8_t c); +uint8_t get_serial(void); +void send_ack(void); +#endif -- libgit2 0.21.2