MODBUS laajempi esimerkki
rs.h
Go to the documentation of this file.
1 
22 #define MAX_RECEIVE_TIMEOUT 102000
23 #define RS_485 /* This indicates are we using RS485 or RS232. If RS485, Receive/Transmit enable needed */
24 
25 #define MAX_SIZE_TRANSMIT_BUFFER 1024
26 
28 #define RS_485_PORT PORTE
29 #define RS_485_DIR DDRE
30 #define RS_485_ENABLE_BIT 3
31 
32 #ifdef RS_485
33 #define ENABLE_RS485_TRANSMIT RS_485_PORT |= (1<<RS_485_ENABLE_BIT)
34 #define ENABLE_RS485_RECEIVE RS_485_PORT &= ~(1<<RS_485_ENABLE_BIT)
35 #else
36 #define ENABLE_RS485_TRANSMIT
37 #define ENABLE_RS485_RECEIVE
38 #endif
39 
41 #define DISENABLE_COM0_ISR UCSR0B &= ~(1 << RXCIE0);
42 #define ENABLE_COM0_ISR UCSR0B |= (1 << RXCIE0);
43 #define USART0_STATUS UCSR0A
44 
46 #define ENABLE_TRANSMIT_ISR UCSR1B |= (1 << TXCIE1);
47 #define DISENABLE_TRANSMIT_ISR UCSR1B &= ~(1 << TXCIE1);
48 
49 #define ERROR_FLAGS (1<<FE0)|(1<<DOR0)|(1<<UPE0)
50 
52 #define COM_ERR_OFF INDICATION_PORT |= (1<<COM_ERR_LED)
53 #define COM_ERR_ON INDICATION_PORT &= ~(1<<COM_ERR_LED)
54 
55 #ifdef DEBUG
56 #define SEND_DEBUG( s ) USART1_Transmit_string ( s )
57 #else
58 #define SEND_DEBUG( s )
59 #endif
60 
61 #ifdef DEBUG2
62 #define SEND_DEBUG_2( s ) USART1_Transmit_string ( s )
63 #else
64 #define SEND_DEBUG_2( s )
65 #endif
66 
67 #ifdef DEBUG
68 #define SEND_DEBUG_CHAR( c ) USART1_Transmit ( c )
69 #else
70 #define SEND_DEBUG_CHAR( s )
71 #endif
72 
73 
75 void USART0_init ( void );
76 void USART1_init ( void );
77 
78 void USART0_Transmit ( unsigned char character );
79 void USART0_Transmit_string ( unsigned char *string );
80 
81 void USART1_Transmit_string ( unsigned char *string );
82 void USART1_int_transmit_string ( unsigned char *string );
83 void USART1_Transmit ( unsigned char character );
void USART1_int_transmit_string(unsigned char *string)
void USART1_init(void)
Initialization of USART1.
Definition: rs.c:159
void USART1_Transmit_string(unsigned char *string)
Sends a string from USART0.
Definition: rs.c:237
void USART0_init(void)
Initialization of USART0. USART0 settings 7 data, 1 stop bit, No parity. USART0 is used for ModBus co...
Definition: rs.c:75
void USART0_Transmit_string(unsigned char *string)
Sends a string from USART0.
Definition: rs.c:115
void USART1_Transmit(unsigned char character)
Send one character from USART1.
Definition: rs.c:208
void USART0_Transmit(unsigned char character)
Sends a character from USART0.
Definition: rs.c:97