-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommunication.h
52 lines (44 loc) · 2.17 KB
/
communication.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Technische Richtlinie FA205
// Bibliothek: communication.h
// Controller: atmel ATMega8
// Version: 1.1
// erstellt am: 5.5.2015
// letzte Änderung: 9.4.2018
// Autor: Rahm
#ifndef _COMMUNICATION_H_
#define _COMMUNICATION_H_
#include "controller.h"
//*************************************************************
//Globale Definitionen
// ... für I2C-Funktionen
// SDA = PC.4
// SCL = PC.5
#define _I2C_FREQUENZ_ 40000 // 40kHz @16MHz: 40kHz...100kHz
// @3.16MHz: 8kHz ...100kHz
#define ACK 0
#define NACK 1
// ... für RS232-Funktionen
#define BAUD 9600 //9600 //19200 //115200
//*************************************************************
// Funktionsprototypen für I2C-Busschnittstelle (Master-Mode)
extern void i2c_init ( void );
extern void i2c_start ( void );
extern void i2c_stop ( void );
extern uint8_t i2c_write ( uint8_t value); // Rückgabewert ACK / NACK
extern uint8_t i2c_read ( uint8_t ack ); // Rückgabewert Value
// Funktionsprototypen für RS232-Schnittstelle
extern void rs232_init ( void );
extern uint8_t rs232_get ( void );
extern void rs232_put ( uint8_t value );
extern void rs232_print ( uint8_t text[] );
extern void rs232_baud ( uint32_t baud ); // Ändert die Baudrate
extern uint8_t rs232_inputdd ( void ); // Erzeugt ein Eingabeprompt für eine Zahl von 00 ... 99
extern void rs232_printdd ( uint8_t value ); // Ausgabe einer Dezimalzahl 00..99 auf RS232
extern void rs232_int ( uint16_t value ); // Ausgabe einer Dezimalzahl 0...65535 auf RS232
extern uint8_t rs232_binary_get ( void );
//extern uint8_t rs232_binary_get ( uint8_t *buf ); // Gibt ein empfangenes Byte im Binärmodus zurück.
// buf = empfangenes Zeichen
// Rückgabe: 1 = Byte empfangen, 0 = keine Byte empfangen
extern uint8_t rs232_readbytes(uint8_t * buffer, int8_t length);
extern uint8_t rs232_is_received( void ); // Ist ein Byte im Empfangspuffer? Ja = 1; Nein = 0
#endif