Blame view

arduinoToRpi.c 821 Bytes
770e8ca9   lahouass   envoi de donnĂ©es ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  #include <avr/io.h>			// for the input/output register
  #include <avr/interrupt.h> 	
  #include <util/delay.h>  
  #include <unistd.h>
  #include <string.h>
  #include <stdlib.h>
  #include <stdio.h>
  
  #define PRESCALER 1024
  #define TIME_SLOT 20
  #define NB_TICK 113
  #define BAUDRATE	103
  
  void send_serial(unsigned char c)
  {
  	loop_until_bit_is_set(UCSR0A, UDRE0);
  	UDR0 = c;
  }
  
770e8ca9   lahouass   envoi de donnĂ©es ...
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  void init_serial(void)
  {
  	/* ACHTUNG : we suppose UBRR value < 0xff */
  	/* Not true in all case */
  	uint8_t baudrate = BAUDRATE;
  	/* Set baud rate */
  	UBRR0H = 0;
  	UBRR0L = baudrate;
  
  	/* Enable transmitter *///task_led_red();
        //task_send_serial('A');
  	UCSR0B = (1<<TXEN0);
  
  	/* Set frame format */
  	UCSR0C = 0x06;
      
  }
  
  
  int main(void)
  {
     init_serial();
907e2ddf   grouille   MAJ Fichier
42
43
44
45
46
47
48
     while(1)
      {
          send_serial('A');
          _delay_ms(3000);
      }
      return 0;
  }