1 |
5 |
sonicwave |
/*****************************************************************************
|
2 |
|
|
* Filename: /drivers/tosnet_v1_00_a/src/tosnet.h
|
3 |
|
|
* Version: 3.20.a
|
4 |
|
|
* Description: tosnet Driver Header File
|
5 |
|
|
* Date: Mon Feb 15 11:56:16 2010 (by Create and Import Peripheral Wizard)
|
6 |
|
|
*****************************************************************************/
|
7 |
|
|
|
8 |
|
|
#ifndef TOSNET_H
|
9 |
|
|
#define TOSNET_H
|
10 |
|
|
|
11 |
|
|
/***************************** Include Files *******************************/
|
12 |
|
|
|
13 |
|
|
#include "xbasic_types.h"
|
14 |
|
|
#include "xstatus.h"
|
15 |
|
|
#include "xio.h"
|
16 |
|
|
|
17 |
|
|
/************************** Constant Definitions ***************************/
|
18 |
|
|
|
19 |
|
|
/**************************** Type Definitions *****************************/
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
typedef struct {
|
23 |
|
|
volatile unsigned int *MemBaseAddress; /* Base address of memory */
|
24 |
|
|
volatile unsigned int *RegBaseAddress; /* Base address of registers */
|
25 |
|
|
} TosNet;
|
26 |
|
|
|
27 |
|
|
/***************** Macros (Inline Functions) Definitions *******************/
|
28 |
|
|
|
29 |
|
|
/************************** Function Prototypes ****************************/
|
30 |
|
|
|
31 |
|
|
XStatus TosNet_Initialize(TosNet *instancePtr, unsigned int *MemBaseAddress, unsigned int *RegBaseAddress); //Initializes a TosNet structure with the addresses of the memory and registers
|
32 |
|
|
unsigned int TosNet_GetNodeID(TosNet *instancePtr); //Returns the id of the node
|
33 |
|
|
unsigned int TosNet_GetNodeAddress(TosNet *instancePtr); //Returns the current address (that is, its position in the ring, relative to the current master) of the node
|
34 |
|
|
unsigned int TosNet_GetRegEnable(TosNet *instancePtr); //Returns the reg enables (bit 0 is 1 if register 0 is enabled, bit 1 is 1 if register 1 is enabled, etc, up to bit 7)
|
35 |
|
|
int TosNet_IsOnline(TosNet *instancePtr); //Returns 1 if the network is online, 0 otherwise
|
36 |
|
|
int TosNet_IsMaster(TosNet *instancePtr); //Returns 1 if the node is master, 0 if slave
|
37 |
|
|
int TosNet_SystemHalted(TosNet *instancePtr); //Returns 1 if the system is halted, 0 otherwise
|
38 |
|
|
void TosNet_CommitIn(TosNet *instancePtr); //Commits the in registers
|
39 |
|
|
void TosNet_CommitOut(TosNet *instancePtr); //Commits the out registers
|
40 |
|
|
unsigned int TosNet_GetPacketCounter(TosNet *instancePtr); //Returns the value of the packet counter
|
41 |
|
|
unsigned int TosNet_GetErrorCounter(TosNet *instancePtr); //Returns the value of the error counter
|
42 |
|
|
unsigned int TosNet_GetResetCounter(TosNet *instancePtr); //Returns the value of the reset counter
|
43 |
|
|
inline volatile unsigned int *TosNet_CalcInAddress(TosNet *instancePtr, unsigned int nodeId, unsigned int regId, unsigned int index); //Returns a pointer to the shared memory block address of a specified in register at nodeId/regId/index
|
44 |
|
|
inline volatile unsigned int *TosNet_CalcOutAddress(TosNet *instancePtr, unsigned int nodeId, unsigned int regId, unsigned int index); //Returns a pointer to the shared memory block address of a specified out register at nodeId/regId/index
|
45 |
|
|
|
46 |
|
|
int TosNet_AsyncDataReady(TosNet *instancePtr); //Returns 1 if data is available from the asynchronous channel
|
47 |
|
|
int TosNet_ReadAsync(TosNet *instancePtr, unsigned char *readBuffer, unsigned int maxBytes, unsigned int *nodeId); //Reads up to maxBytes of data from the asynchronous channel, data is returned in readBuffer, nodeId holds the sender (if the current node is master), the id of the current node (if the current node is a slave), or 0 (if the data comes from a broadcast)
|
48 |
|
|
int TosNet_WriteAsync(TosNet *instancePtr, unsigned char *writeBuffer, unsigned int writeBytes, unsigned int nodeId); //Writes writeBytes of data from writeBuffer to the asynchronous channel, nodeId should be the id of the target node (if the current node is master), the id of the current node (if the current node is a slave), or 0 (if the current node is master and wants to do a broadcast)
|
49 |
|
|
|
50 |
|
|
#endif /** TOSNET_H */
|