serial.c File Reference


Detailed Description

Implementation of the serial communication stuff.

Software License
See the MBCSL for details.
Author:
Sven Schlender (kontakt at mobacon dot de)
Date:
2010-10-29


Functions

void SerialInit (SerialMode_t Mode)
 Initializes the serial module in the requested mode.
WORD SerialGetTCPPort (BOOL bPersistent)
 Delivers the current configured TCP port of the serial server.
void SerialSetTCPPort (WORD Port)
 Configures a new TCP port for the serial server.
BOOL bSerialGetSPIMasterSample (void)
 Delivers the sampling mode of the input signal in SPI master mode.
SPIClockFrequencies_t SerialGetSPIFrequency (void)
 Delivers the currently used frequency of SPI master mode.
SPIModes_t SerialGetSPIMode (void)
 Delivers the currently used clock mode in SPI master mode.
void SerialSetSPIFrequency (SPIClockFrequencies_t Frequency)
 Sets the clock frequency in SPI master mode.
void SerialSetSPIMasterSample (BOOL Sample)
 Sets the sampling mode of the input signal in SPI master mode.
void SerialSetSPIMode (SPIModes_t Mode)
 Sets the SPI clock mode in SPI master mode.
UARTBaudrates_t SerialGetUARTBaudrate (void)
 Delivers the currently used baudrate in the UART mode.
void SerialSetUARTBaudrate (UARTBaudrates_t Baudrate)
 Sets the UART baudrate in UART mode.
void SerialResetToFactory (void)
 Resets the serial module EEPROM section to well known start parameters.
BOOL SerialInitTask (void)
 After initializing network and application stuff the application should call this function to prepare task members needed for proper serial task operation.
void SerialStopTask (void)
 On network errors or shut down events these function should be called by the main application to proper stop the serial tasks (i.e disconnecting a connected client).
BOOL bSerialCheckForStoppedTask (void)
 Before shutting down the application should poll for valid serial task shutdown.
void SerialTask (void)
 Call this function periodically from main application to execute serial module tasks.
void SerialShutdown (void)
 Call this function to process shutdown actions for serial server and serial connections.
void SerialRegisterHandling (void)
 Call this function to serve the virtual register set accessed by the SPI master.
SerialServerConnection_t SerialGetServerState (void)
 This function delivers the current state of the serial server.
DWORD SerialGetConnectedIP (void)
 Delivers the IP of a client who is connected to serial server.
DWORD SerialGetRXCounter (void)
 Delivers the count of bytes the serial server has sent to a client.
DWORD SerialGetTXCounter (void)
 Delivers the count of bytes the serial server has received from a client.


Function Documentation

BOOL bSerialCheckForStoppedTask ( void   ) 

Before shutting down the application should poll for valid serial task shutdown.

Return values:
TRUE The task has successfully stopped.
FALSE Stopping the serial task is pending.

BOOL bSerialGetSPIMasterSample ( void   ) 

Delivers the sampling mode of the input signal in SPI master mode.

The mode can be read indepently from the current active NetzerIO mode.

Return values:
FALSE Input data sampled at middle of data output time.
TRUE Input data sampled at end of data output time.

DWORD SerialGetConnectedIP ( void   ) 

Delivers the IP of a client who is connected to serial server.

Returns:
The IP address as 32 bit value, 0 if no client is connected.

DWORD SerialGetRXCounter ( void   ) 

Delivers the count of bytes the serial server has sent to a client.

The counter is set to zero while a new session starts.

Returns:
The counter value.

SerialServerConnection_t SerialGetServerState ( void   ) 

This function delivers the current state of the serial server.

Returns:
The current state.

SPIClockFrequencies_t SerialGetSPIFrequency ( void   ) 

Delivers the currently used frequency of SPI master mode.

The frequency can be read indepently from the current active NetzerIO mode.

Returns:
The frequency as enumerated value.

SPIModes_t SerialGetSPIMode ( void   ) 

Delivers the currently used clock mode in SPI master mode.

The mode can be read indepently from the current active NetzerIO mode.

Returns:
The SPI clock mode as enumerated value.

WORD SerialGetTCPPort ( BOOL  bPersistent  ) 

Delivers the current configured TCP port of the serial server.

Parameters:
bPersistent If TRUE the return value is read from EEPROM. If FALSE the value is taken from the current state.
Returns:
The port of the listening serial server.

DWORD SerialGetTXCounter ( void   ) 

Delivers the count of bytes the serial server has received from a client.

The counter is set to zero while a new session starts.

Returns:
The counter value.

UARTBaudrates_t SerialGetUARTBaudrate ( void   ) 

Delivers the currently used baudrate in the UART mode.

The baudrate can be read indepently from the current active NetzerIO mode.

Returns:
The baudrate as enumerated value.

void SerialInit ( SerialMode_t  Mode  ) 

Initializes the serial module in the requested mode.

Should be called once at startup (very early).

Parameters:
Mode Specifies the mode for NetzerIO. GPIO module must know this because it configures some port pins also for the serial modes.

BOOL SerialInitTask ( void   ) 

After initializing network and application stuff the application should call this function to prepare task members needed for proper serial task operation.

Return values:
TRUE Initialization was successful.
FALSE Initialization failed, try again later.

void SerialSetSPIFrequency ( SPIClockFrequencies_t  Frequency  ) 

Sets the clock frequency in SPI master mode.

If in SPI master mode the change takes effect directly. The new mode is stored persistent in EEPROM.

Parameters:
Frequency The frequency as enumerated value.

void SerialSetSPIMasterSample ( BOOL  bSample  ) 

Sets the sampling mode of the input signal in SPI master mode.

If in SPI master mode the change takes effect directly. The new mode is stored persistent in EEPROM.

Parameters:
bSample If FALSE, the input data is sampled at middle of data output time. If TRUE, the input data is sampled at end of data output time.

void SerialSetSPIMode ( SPIModes_t  Mode  ) 

Sets the SPI clock mode in SPI master mode.

If in SPI master mode the change takes effect directly. The new mode is stored persistent in EEPROM.

Parameters:
Mode The SPI clock mode as enumerated value.

void SerialSetTCPPort ( WORD  Port  ) 

Configures a new TCP port for the serial server.

This value is stored persistent in EEPROM.

Parameters:
Port The new port value.

void SerialSetUARTBaudrate ( UARTBaudrates_t  eBaudrate  ) 

Sets the UART baudrate in UART mode.

If in UART mode the change takes effect directly. The new mode is stored persistent in EEPROM.

Parameters:
eBaudrate The baudrate as enumerated value.

void SerialStopTask ( void   ) 

On network errors or shut down events these function should be called by the main application to proper stop the serial tasks (i.e disconnecting a connected client).

void SerialTask ( void   ) 

Call this function periodically from main application to execute serial module tasks.


Generated on Fri Mar 29 10:34:28 2013 for Netzer by  doxygen 1.5.5