| 
    MODBUS laajempi esimerkki
    
   | 
 

Go to the source code of this file.
Macros | |
| #define | MAX_RECEIVE_TIMEOUT 102000 /** @warning Find suitable value */ | 
| #define | RS_485 /* This indicates are we using RS485 or RS232. If RS485, Receive/Transmit enable needed */ | 
| #define | MAX_SIZE_TRANSMIT_BUFFER 1024 | 
| #define | RS_485_PORT PORTE | 
| #define | RS_485_DIR DDRE | 
| #define | RS_485_ENABLE_BIT 3 | 
| #define | ENABLE_RS485_TRANSMIT RS_485_PORT |= (1<<RS_485_ENABLE_BIT) /**!> MAX3535 component to 1 */ | 
| #define | ENABLE_RS485_RECEIVE RS_485_PORT &= ~(1<<RS_485_ENABLE_BIT) /**!> MAX3535 component to 0 */ | 
| #define | DISENABLE_COM0_ISR UCSR0B &= ~(1 << RXCIE0); | 
| #define | ENABLE_COM0_ISR UCSR0B |= (1 << RXCIE0); | 
| #define | USART0_STATUS UCSR0A | 
| #define | ENABLE_TRANSMIT_ISR UCSR1B |= (1 << TXCIE1); | 
| #define | DISENABLE_TRANSMIT_ISR UCSR1B &= ~(1 << TXCIE1); | 
| #define | ERROR_FLAGS (1<<FE0)|(1<<DOR0)|(1<<UPE0) | 
| #define | COM_ERR_OFF INDICATION_PORT |= (1<<COM_ERR_LED) | 
| #define | COM_ERR_ON INDICATION_PORT &= ~(1<<COM_ERR_LED) | 
| #define | SEND_DEBUG(s) | 
| #define | SEND_DEBUG_2(s) | 
| #define | SEND_DEBUG_CHAR(s) | 
Functions | |
| void | USART0_init (void) | 
| Initialization of USART0. USART0 settings 7 data, 1 stop bit, No parity. USART0 is used for ModBus communication.  More... | |
| void | USART1_init (void) | 
| Initialization of USART1.  More... | |
| void | USART0_Transmit (unsigned char character) | 
| Sends a character from USART0.  More... | |
| void | USART0_Transmit_string (unsigned char *string) | 
| Sends a string from USART0.  More... | |
| void | USART1_Transmit_string (unsigned char *string) | 
| Sends a string from USART0.  More... | |
| void | USART1_int_transmit_string (unsigned char *string) | 
| void | USART1_Transmit (unsigned char character) | 
| Send one character from USART1.  More... | |
Header file for rs.c.
Date
Versions:
Revision 1.3 2009/08/07 11:37:18 e0700008 Viestiin kesken kaiken tulevat CR ja LF virheet korjattu. Virhe hex_to_acii_hex funktiossa.
Revision 1.2 2009/08/07 08:50:01 juma Assertion testausta
Revision 1.1 2009/08/06 07:25:23 juma Ohjelma jaettu hallittavimpiin kokonaisuuksiin
| #define COM_ERR_OFF INDICATION_PORT |= (1<<COM_ERR_LED) | 
MACROS
| #define COM_ERR_ON INDICATION_PORT &= ~(1<<COM_ERR_LED) | 
| #define DISENABLE_COM0_ISR UCSR0B &= ~(1 << RXCIE0); | 
USART0 register settings
| #define DISENABLE_TRANSMIT_ISR UCSR1B &= ~(1 << TXCIE1); | 
| #define ENABLE_COM0_ISR UCSR0B |= (1 << RXCIE0); | 
| #define ENABLE_RS485_RECEIVE RS_485_PORT &= ~(1<<RS_485_ENABLE_BIT) /**!> MAX3535 component to 0 */ | 
| #define ENABLE_RS485_TRANSMIT RS_485_PORT |= (1<<RS_485_ENABLE_BIT) /**!> MAX3535 component to 1 */ | 
| #define ENABLE_TRANSMIT_ISR UCSR1B |= (1 << TXCIE1); | 
USART1 register settings
| #define ERROR_FLAGS (1<<FE0)|(1<<DOR0)|(1<<UPE0) | 
| #define MAX_RECEIVE_TIMEOUT 102000 /** @warning Find suitable value */ | 
| #define MAX_SIZE_TRANSMIT_BUFFER 1024 | 
| #define RS_485 /* This indicates are we using RS485 or RS232. If RS485, Receive/Transmit enable needed */ | 
| #define RS_485_DIR DDRE | 
| #define RS_485_ENABLE_BIT 3 | 
| #define RS_485_PORT PORTE | 
RS485 Port instructing read/write - mode
| #define SEND_DEBUG | ( | s | ) | 
| #define SEND_DEBUG_2 | ( | s | ) | 
| #define SEND_DEBUG_CHAR | ( | s | ) | 
| #define USART0_STATUS UCSR0A | 
| void USART0_init | ( | void | ) | 
Initialization of USART0. USART0 settings 7 data, 1 stop bit, No parity. USART0 is used for ModBus communication.
Prototypes
< write high register first
< ((XTAL/16)/BAUD)-1;

| void USART0_Transmit | ( | unsigned char | character | ) | 
Sends a character from USART0.
| character | Character to be sended from USART0. | 


| void USART0_Transmit_string | ( | unsigned char * | string | ) | 
Sends a string from USART0.
| string | Pointer to string to be sended from USART. | 

| void USART1_init | ( | void | ) | 
Initialization of USART1.

| void USART1_int_transmit_string | ( | unsigned char * | string | ) | 
| void USART1_Transmit | ( | unsigned char | character | ) | 
Send one character from USART1.
| character | Character to be sended from USART. | 


| void USART1_Transmit_string | ( | unsigned char * | string | ) | 
Sends a string from USART0.
| string | Pointer to string to be sended from USART. | 
