MODBUS laajempi esimerkki
rs.h File Reference

Header file for rs.c. More...

This graph shows which files directly or indirectly include this file:

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...
 

Detailed Description

Header file for rs.c.


Source
/var/lib/cvs/embedded/project/kosteus/rs.h,v

Date

Date
2010-01-07 12:09:51 +0200 (to, 07 tammi 2010)

Versions:

Revision
165
Log
rs.h,v

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

Macro Definition Documentation

#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

Function Documentation

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;

Here is the caller graph for this function:

void USART0_Transmit ( unsigned char  character)

Sends a character from USART0.


Parameters
characterCharacter to be sended from USART0.
Todo:
No delay should be in this function.
Warning
If buffer is not ready, function will wait for its clearence, waists time.
Warning
Must get rid off delay
Todo:
Must get rid off delay

Here is the call graph for this function:

Here is the caller graph for this function:

void USART0_Transmit_string ( unsigned char *  string)

Sends a string from USART0.


Parameters
stringPointer to string to be sended from USART.
Warning
EOL '\0' character is expected to be at the end of string.
Should NOT be used for ModBus communication.

Here is the call graph for this function:

void USART1_init ( void  )

Initialization of USART1.


Warning
tällä ei mitään merkitystä, seuraavaksi kirjoitetaan sen yli

Here is the caller graph for this function:

void USART1_int_transmit_string ( unsigned char *  string)
void USART1_Transmit ( unsigned char  character)

Send one character from USART1.


Parameters
characterCharacter to be sended from USART.
Warning
If buffer is not ready, function will wait for its clearence, waists time.

Here is the call graph for this function:

Here is the caller graph for this function:

void USART1_Transmit_string ( unsigned char *  string)

Sends a string from USART0.


Parameters
stringPointer to string to be sended from USART.
Warning
EOL '\0' character is expected to be at the end of string.

Here is the call graph for this function: