net/tick.h File Reference


Detailed Description

Tick Manager for Modtronix TCP/IP Stack.

Author:
Modtronix Engineering
Dependencies:
none
Compiler:
MPLAB C18 v2.10 or higher
HITECH PICC-18 V8.35PL3 or higher

Description

This module contains the Tick code.


Defines

#define NEAR_TICK
#define TICK_COUNTER_HIGH   ((TICK_COUNTER_RELOAD >> 8) & 0xff)
#define TICK_COUNTER_LOW   (TICK_COUNTER_RELOAD & 0xff)
#define TICK_COUNTER_RELOAD   (65536 - (WORD)(((CLOCK_FREQ/4)/TICKS_PER_SECOND)/4) )
#define TICK_SECOND   ((TICK)TICKS_PER_SECOND)
#define TickGet()   tickCount
#define TickGet16bit()   ((WORD)tickCount)
#define TickGet8bit()   ((BYTE)tickCount)
#define TickGet8bitSec()   ((BYTE)tickSec)
#define TickGetDiff(t)   ((TICK)(tickCount - ((TICK)t) ))
#define TickGetDiff16bit(t)   ((TICK16)( ((TICK16)tickCount) - ((TICK16)t) ))
#define TickGetDiff8bit(t)   ((TICK8)( ((TICK8)tickCount) - ((TICK8)t) ))
#define TickGetDiff8bitSec(t)   ((TICK8)( ((TICK8)tickSec) - ((TICK8)t) ))
#define TickGetDiffSec(t)   ((TICK16)( ((TICK16)tickSec) - ((TICK16)t) ))
#define TickGetSec()   tickSec
#define TickGetSecDiff(t)   ((TICK16)( ((TICK16)tickSec) - ((TICK16)t) ))
#define TICKS_PER_SECOND   (100)
#define TickUpdate()

Typedefs

typedef unsigned long TICK
typedef unsigned short TICK16
typedef unsigned long TICK32
typedef unsigned char TICK8

Functions

void TickInit (void)

Variables

NEAR_TICK TICK tickCount
NEAR_TICK unsigned char tickHelper
NEAR_TICK TICK16 tickSec


Define Documentation

#define NEAR_TICK

Only Tick.c defines TICK_INCLUDE and thus defines Seconds and TickValue storage.

#define TICK_COUNTER_HIGH   ((TICK_COUNTER_RELOAD >> 8) & 0xff)

#define TICK_COUNTER_LOW   (TICK_COUNTER_RELOAD & 0xff)

#define TICK_COUNTER_RELOAD   (65536 - (WORD)(((CLOCK_FREQ/4)/TICKS_PER_SECOND)/4) )

#define TICK_SECOND   ((TICK)TICKS_PER_SECOND)

Defines the number of ticks per second

 
#define TickGet (  )     tickCount

Get the current 32 bit tick value. The given tick is incremented every 10ms Has 32 Bits, range of 0 - 2^32 = 11930 hours = 497 days

Returns:
The current 32 bit tick value.
Examples:
ex_tick.c.

 
#define TickGet16bit (  )     ((WORD)tickCount)

Get the current 16 bit tick value. The given tick is incremented every 100ms Has 16 Bits, range of 0 - 65535 = 65535 x 10ms = 655 seconds = 10.9 minutes

Returns:
The current 16 bit tick value.
Examples:
ex_tick16.c.

 
#define TickGet8bit (  )     ((BYTE)tickCount)

Get the current 8 bit tick value. The given tick is incremented every 100ms. Has 8 Bits, range of 0 - 255 = 255 x 10ms = 2.55 seconds

Returns:
The current 8 bit tick value.
Examples:
ex_tick8.c.

 
#define TickGet8bitSec (  )     ((BYTE)tickSec)

Get the current 8 bit second tick value. The given tick is incremented every 1 second Has 8 Bits, range of 0 - 255 seconds

Returns:
The current 8 bit second tick value.
Examples:
ex_tcp_client.c, ex_tick_sec8.c, ex_udp_client.c, and ex_udp_client2.c.

#define TickGetDiff (  )     ((TICK)(tickCount - ((TICK)t) ))

Returns the difference between the given value and the current 32 bit tick value Has 32 Bits, range of 0 - 2^32 = 11930 hours = 497 days

Examples:
ex_tick.c.

#define TickGetDiff16bit (  )     ((TICK16)( ((TICK16)tickCount) - ((TICK16)t) ))

Returns the difference between the given value and the current 16 bit tick value. Has 16 Bits, range of 0 - 65535 = 65535 x 10ms = 655 seconds = 10.9 minutes

Examples:
ex_tick16.c.

#define TickGetDiff8bit (  )     ((TICK8)( ((TICK8)tickCount) - ((TICK8)t) ))

Returns the difference between the given value and the current 8 bit tick value Has 8 Bits, range of 0 - 255 = 255 x 10ms = 2.55 seconds

Examples:
ex_tick8.c.

#define TickGetDiff8bitSec (  )     ((TICK8)( ((TICK8)tickSec) - ((TICK8)t) ))

Returns the difference between the given value and the current 8 bit second tick value. Has 8 Bits, range of 0 - 255 seconds

Examples:
ex_tcp_client.c, ex_tick_sec8.c, ex_udp_client.c, and ex_udp_client2.c.

#define TickGetDiffSec (  )     ((TICK16)( ((TICK16)tickSec) - ((TICK16)t) ))

Returns the difference between the given value and the current 16 bit second counter. Has 16 Bits, range of 0 - 65,536 seconds = 0 to 18.2 hours

Examples:
ex_tick_sec.c.

 
#define TickGetSec (  )     tickSec

Get the current 16 bit second tick value. The given tick is incremented every 1 second. Has 16 Bits, range of 0 - 65,536 seconds = 0 to 18.2 hours

Returns:
The current 16 bit second tick value.
Examples:
ex_tick_sec.c, and ex_udp_client2.c.

#define TickGetSecDiff (  )     ((TICK16)( ((TICK16)tickSec) - ((TICK16)t) ))

Returns the difference between the given value and the current 16 bit second counter. Has 16 Bits, range of 0 - 65,536 seconds = 0 to 18.2 hours

Examples:
ex_udp_client2.c.

#define TICKS_PER_SECOND   (100)

Examples:
ex_tick.c, ex_tick16.c, and ex_tick8.c.

 
#define TickUpdate (  ) 

Value:

{ \
        TMR0H = TICK_COUNTER_HIGH;              \
        TMR0L = TICK_COUNTER_LOW;               \
        tickCount++;                            \
        if (--tickHelper == 0) {                \
            tickHelper = TICKS_PER_SECOND;      \
            tickSec++;                          \
        }                                       \
    }
Internal Tick and Seconds count are updated.


Typedef Documentation

typedef unsigned long TICK

Examples:
ex_tick.c.

typedef unsigned short TICK16

Examples:
ex_tcp_client.c, ex_tick16.c, ex_tick_sec.c, and ex_udp_client2.c.

typedef unsigned long TICK32

typedef unsigned char TICK8

Examples:
ex_tcp_client.c, ex_tick8.c, ex_tick_sec8.c, ex_udp_client.c, and ex_udp_client2.c.


Function Documentation

void TickInit ( void   ) 

Tick manager is initialized. Initializes Timer0 as a tick counter.


Variable Documentation

NEAR_TICK TICK tickCount

NEAR_TICK unsigned char tickHelper

NEAR_TICK TICK16 tickSec


Generated on Mon Oct 9 13:22:07 2006 for SBC65EC Web Server by  doxygen 1.4.7