MODBUS laajempi esimerkki
rs.c File Reference

Functions for receiving and sending with USART. More...

#include "kosteus.h"
Include dependency graph for rs.c:

Functions

 ISR (USART0_RX_vect)
 USART0 Receive interrupt. Occurs every time a character is received in USART0. More...
 
void USART0_init (void)
 Initialization of USART0. USART0 settings 7 data, 1 stop bit, No parity. USART0 is used for ModBus communication. 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...
 
 ISR (USART1_RX_vect)
 USART1 Receive interrupt. Occurs every time a character is received in USART1. More...
 
void USART1_init (void)
 Initialization of USART1. More...
 
 ISR (USART1_TX_vect)
 USART1 transmit interrupt. More...
 
void USART1_Transmit (unsigned char character)
 Send one character from USART1. More...
 
void USART1_Transmit_string (unsigned char *string)
 Sends a string from USART0. More...
 
void USART1_int_Transmit_string (unsigned char *string_to_be_sent)
 Transmit one character with interrupt. More...
 

Variables

unsigned char receive_timeout
 
unsigned char received_character
 
unsigned char previouse_received_character
 
volatile unsigned char receive_buffer [MAX_LENGTH_OF_BUFFER]
 
volatile unsigned char transmit_buffer [MAX_LENGTH_OF_BUFFER]
 
volatile unsigned char nro_characters_received
 
volatile unsigned char nro_characters_to_be_sent
 
unsigned char delayed_state
 
unsigned char state
 
unsigned char new_state
 
unsigned char error_condition
 
unsigned char transmit_buffer_begin
 
unsigned char transmit_buffer_end
 
unsigned char debug_transmit_buffer [MAX_SIZE_TRANSMIT_BUFFER]
 
unsigned char transmit_buffer_current_pos
 
unsigned char pos_in_string_to_be_sent
 

Detailed Description

Functions for receiving and sending with USART.


Function Documentation

ISR ( USART0_RX_vect  )

USART0 Receive interrupt. Occurs every time a character is received in USART0.


Here is the call graph for this function:

ISR ( USART1_RX_vect  )

USART1 Receive interrupt. Occurs every time a character is received in USART1.


Warning
The USART1 receive interrupt is disabled.
Todo:
this counter doesn't work

warning USART1:stä ei voida ottaa merkkejä vastaan samaan puskuriin, muutettu receive buffer Debugbufferiksi

ISR ( USART1_TX_vect  )

USART1 transmit interrupt.


Warning
The USART1 transmit interrupt is disabled.
void USART0_init ( void  )

Initialization of USART0. USART0 settings 7 data, 1 stop bit, No parity. USART0 is used for ModBus communication.


< 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_to_be_sent)

Transmit one character with interrupt.


Parameters
string_to_be_sentPointer to the string to be sent.
Warning
The USART1 transmit interrupt is disabled.
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:

Variable Documentation

unsigned char debug_transmit_buffer[MAX_SIZE_TRANSMIT_BUFFER]
unsigned char delayed_state
unsigned char error_condition
unsigned char new_state
volatile unsigned char nro_characters_received
volatile unsigned char nro_characters_to_be_sent
unsigned char pos_in_string_to_be_sent
unsigned char previouse_received_character
volatile unsigned char receive_buffer[MAX_LENGTH_OF_BUFFER]
unsigned char receive_timeout
unsigned char received_character
unsigned char state

controlling main loop

volatile unsigned char transmit_buffer[MAX_LENGTH_OF_BUFFER]
unsigned char transmit_buffer_begin
unsigned char transmit_buffer_current_pos
unsigned char transmit_buffer_end