Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
nz_serDataPorts.h File Reference

Functions for "Serial Data Ports"(SDP) More...

#include "nz_circularBuffer.h"
#include "nz_serI2C.h"

Go to the source code of this file.

Data Structures

struct  _SERPORT
 
struct  SERPORTS_
 
union  SER_AVAIL_0TO7
 
union  SER_AVAIL_8TO15
 
union  SER_AVAIL_16TO23
 
union  SER_AVAIL_24TO31
 
struct  _SER_INFO
 
struct  SER_CONFIG
 
struct  SER_CONFIG_UART
 
struct  SER_CONFIG_SPI
 
struct  SER_CONFIG_I2C
 
struct  SER_CONFIG_USB
 
struct  SER_CONFIG_UDP
 
struct  SER_CONFIG_TCP
 
struct  CFG_BLOCK_SER_0TO7
 
struct  CFG_BLOCK_SER_8TO15
 
struct  CFG_BLOCK_SER_16TO23
 
struct  CFG_BLOCK_SER_24TO31
 

Macros

#define SERPORT_ID_DEBUG   0
 Default debug "Serial Data Port".
 
#define SERPORT_ID_UART1   1
 
#define SERPORT_ID_UART2   2
 
#define SERPORT_ID_UART3   3
 
#define SERPORT_ID_UART4   4
 
#define SERPORT_ID_SPI1   5
 
#define SERPORT_ID_SPI3   6
 
#define SERPORT_ID_I2C1   7
 
#define SERPORT_ID_I2C2   8
 
#define SERPORT_ID_I2C3   9
 
#define SERPORT_ID_UDP1   10
 
#define SERPORT_ID_UDP2   11
 
#define SERPORT_ID_UDP3   12
 
#define SERPORT_ID_TCP1   13
 
#define SERPORT_ID_TCP2   14
 
#define SERPORT_ID_TCP3   15
 
#define SERPORT_ID_USB1   16
 
#define SERPORT_ID_USER1   17
 
#define SERPORT_ID_USER2   18
 
#define SERPORT_ID_USER3   19
 
#define SERPORT_ID_USER4   20
 
#define SERPORT_ID_USER5   21
 
#define SERPORT_ID_USER6   22
 
#define SERPORT_ID_USER7   23
 
#define SERPORT_ID_USER8   24
 
#define SERPORT_ID_MAX   SERPORT_ID_USER8
 
#define SERPORT_TXBUFID_UART1   (SERPORT_ID_UART1*2)
 
#define SERPORT_RXBUFID_UART1   ((SERPORT_ID_UART1*2)+1)
 
#define SERPORT_TXBUFID_UART2   (SERPORT_ID_UART2*2)
 
#define SERPORT_RXBUFID_UART2   ((SERPORT_ID_UART2*2)+1)
 
#define SERPORT_TXBUFID_UART3   (SERPORT_ID_UART3*2)
 
#define SERPORT_RXBUFID_UART3   ((SERPORT_ID_UART3*2)+1)
 
#define SERPORT_TXBUFID_UART4   (SERPORT_ID_UART4*2)
 
#define SERPORT_RXBUFID_UART4   ((SERPORT_ID_UART4*2)+1)
 
#define SERPORT_TXBUFID_SPI1   (SERPORT_ID_SPI1*2)
 
#define SERPORT_RXBUFID_SPI1   ((SERPORT_ID_SPI1*2)+1)
 
#define SERPORT_TXBUFID_SPI3   (SERPORT_ID_SPI3*2)
 
#define SERPORT_RXBUFID_SPI3   ((SERPORT_ID_SPI3*2)+1)
 
#define SERPORT_TXBUFID_I2C1   (SERPORT_ID_I2C1*2)
 
#define SERPORT_RXBUFID_I2C1   ((SERPORT_ID_I2C1*2)+1)
 
#define SERPORT_TXBUFID_I2C2   (SERPORT_ID_I2C2*2)
 
#define SERPORT_RXBUFID_I2C2   ((SERPORT_ID_I2C2*2)+1)
 
#define SERPORT_TXBUFID_I2C3   (SERPORT_ID_I2C3*2)
 
#define SERPORT_RXBUFID_I2C3   ((SERPORT_ID_I2C3*2)+1)
 
#define SERPORT_TXBUFID_UDP1   (SERPORT_ID_UDP1*2)
 
#define SERPORT_RXBUFID_UDP1   ((SERPORT_ID_UDP1*2)+1)
 
#define SERPORT_TXBUFID_UDP2   (SERPORT_ID_UDP2*2)
 
#define SERPORT_RXBUFID_UDP2   ((SERPORT_ID_UDP2*2)+1)
 
#define SERPORT_TXBUFID_UDP3   (SERPORT_ID_UDP3*2)
 
#define SERPORT_RXBUFID_UDP3   ((SERPORT_ID_UDP3*2)+1)
 
#define SERPORT_TXBUFID_TCP1   (SERPORT_ID_TCP1*2)
 
#define SERPORT_RXBUFID_TCP1   ((SERPORT_ID_TCP1*2)+1)
 
#define SERPORT_TXBUFID_TCP2   (SERPORT_ID_TCP2*2)
 
#define SERPORT_RXBUFID_TCP2   ((SERPORT_ID_TCP2*2)+1)
 
#define SERPORT_TXBUFID_TCP3   (SERPORT_ID_TCP3*2)
 
#define SERPORT_RXBUFID_TCP3   ((SERPORT_ID_TCP3*2)+1)
 
#define SERPORT_TXBUFID_USB1   (SERPORT_ID_USB1*2)
 
#define SERPORT_RXBUFID_USB1   ((SERPORT_ID_USB1*2)+1)
 
#define SERPORT_TXBUFID_USER1   (SERPORT_ID_USER1*2)
 
#define SERPORT_RXBUFID_USER1   ((SERPORT_ID_USER1*2)+1)
 
#define SERPORT_TXBUFID_USER2   (SERPORT_ID_USER2*2)
 
#define SERPORT_RXBUFID_USER2   ((SERPORT_ID_USER2*2)+1)
 
#define SERPORT_TXBUFID_USER3   (SERPORT_ID_USER3*2)
 
#define SERPORT_RXBUFID_USER3   ((SERPORT_ID_USER3*2)+1)
 
#define SERPORT_TXBUFID_USER4   (SERPORT_ID_USER4*2)
 
#define SERPORT_RXBUFID_USER4   ((SERPORT_ID_USER4*2)+1)
 
#define SERPORT_TXBUFID_USER5   (SERPORT_ID_USER5*2)
 
#define SERPORT_RXBUFID_USER5   ((SERPORT_ID_USER5*2)+1)
 
#define SERPORT_TXBUFID_USER6   (SERPORT_ID_USER6*2)
 
#define SERPORT_RXBUFID_USER6   ((SERPORT_ID_USER6*2)+1)
 
#define SERPORT_TXBUFID_USER7   (SERPORT_ID_USER7*2)
 
#define SERPORT_RXBUFID_USER7   ((SERPORT_ID_USER7*2)+1)
 
#define SERPORT_TXBUFID_USER8   (SERPORT_ID_USER8*2)
 
#define SERPORT_RXBUFID_USER8   ((SERPORT_ID_USER8*2)+1)
 
#define SERPORT_STAT_ENABLED   0x8000
 
#define SERPORT_DEBUG_INIT()
 
#define SERPORT_DEBUG_TASK()
 
#define SERPORT_UART1_INIT()
 
#define SERPORT_UART1_TASK()
 
#define SERPORT_UART2_INIT()
 
#define SERPORT_UART2_TASK()
 
#define SERPORT_UART3_INIT()
 
#define SERPORT_UART3_TASK()
 
#define SERPORT_UART4_INIT()
 
#define SERPORT_UART4_TASK()
 
#define SERPORT_SPI1_INIT()
 
#define SERPORT_SPI1_TASK()
 
#define SERPORT_SPI3_INIT()
 
#define SERPORT_SPI3_TASK()
 
#define SERPORT_I2C1_INIT()   serI2C1Init()
 
#define SERPORT_I2C1_TASK()   serI2CTask(&i2c1Info)
 
#define SERPORT_I2C2_INIT()
 
#define SERPORT_I2C2_TASK()
 
#define SERPORT_I2C3_INIT()
 
#define SERPORT_I2C3_TASK()
 
#define SERPORT_UDP1_INIT()
 
#define SERPORT_UDP1_TASK()
 
#define SERPORT_UDP2_INIT()
 
#define SERPORT_UDP2_TASK()
 
#define SERPORT_UDP3_INIT()
 
#define SERPORT_UDP3_TASK()
 
#define SERPORT_TCP1_INIT()
 
#define SERPORT_TCP1_TASK()
 
#define SERPORT_TCP2_INIT()
 
#define SERPORT_TCP2_TASK()
 
#define SERPORT_TCP3_INIT()
 
#define SERPORT_TCP3_TASK()
 
#define SERPORT_USB_INIT()
 
#define SERPORT_USB_TASK()
 
#define SERPORT_USER1_INIT()
 
#define SERPORT_USER1_TASK()
 
#define SERPORT_USER2_INIT()
 
#define SERPORT_USER2_TASK()
 
#define SERPORT_USER3_INIT()
 
#define SERPORT_USER3_TASK()
 
#define SERPORT_USER4_INIT()
 
#define SERPORT_USER4_TASK()
 
#define SERPORT_USER5_INIT()
 
#define SERPORT_USER5_TASK()
 
#define SERPORT_USER6_INIT()
 
#define SERPORT_USER6_TASK()
 
#define SERPORT_USER7_INIT()
 
#define SERPORT_USER7_TASK()
 
#define SERPORT_USER8_INIT()
 
#define SERPORT_USER8_TASK()
 
#define CIRBUF_TX_DEBUG   (&serports.debug.cbufTx)
 
#define CIRBUF_RX_DEBUG   (&serports.debug.cbufRx)
 
#define CIRBUF_TX_UART1   (&serports.uart1.cbufTx)
 
#define CIRBUF_RX_UART1   (&serports.uart1.cbufRx)
 
#define CIRBUF_TX_UART2   (&serports.uart2.cbufTx)
 
#define CIRBUF_RX_UART2   (&serports.uart2.cbufRx)
 
#define CIRBUF_TX_UART3   (&serports.uart3.cbufTx)
 
#define CIRBUF_RX_UART3   (&serports.uart3.cbufRx)
 
#define CIRBUF_TX_UART4   (&serports.uart4.cbufTx)
 
#define CIRBUF_RX_UART4   (&serports.uart4.cbufRx)
 
#define CIRBUF_TX_SPI1   (&serports.spi1.cbufTx)
 
#define CIRBUF_RX_SPI1   (&serports.spi1.cbufRx)
 
#define CIRBUF_TX_SPI3   (&serports.spi3.cbufTx)
 
#define CIRBUF_RX_SPI3   (&serports.spi3.cbufRx)
 
#define CIRBUF_TX_I2C1   (&serports.i2c1.cbufTx)
 
#define CIRBUF_RX_I2C1   (&serports.i2c1.cbufRx)
 
#define CIRBUF_TX_I2C2   (&serports.i2c2.cbufTx)
 
#define CIRBUF_RX_I2C2   (&serports.i2c2.cbufRx)
 
#define CIRBUF_TX_I2C3   (&serports.i2c3.cbufTx)
 
#define CIRBUF_RX_I2C3   (&serports.i2c3.cbufRx)
 
#define CIRBUF_TX_UDP1   (&serports.udp1.cbufTx)
 
#define CIRBUF_RX_UDP1   (&serports.udp1.cbufRx)
 
#define CIRBUF_TX_UDP2   (&serports.udp2.cbufTx)
 
#define CIRBUF_RX_UDP2   (&serports.udp2.cbufRx)
 
#define CIRBUF_TX_UDP3   (&serports.udp3.cbufTx)
 
#define CIRBUF_RX_UDP3   (&serports.udp3.cbufRx)
 
#define CIRBUF_TX_TCP1   (&serports.tcp1.cbufTx)
 
#define CIRBUF_RX_TCP1   (&serports.tcp1.cbufRx)
 
#define CIRBUF_TX_TCP2   (&serports.tcp2.cbufTx)
 
#define CIRBUF_RX_TCP2   (&serports.tcp2.cbufRx)
 
#define CIRBUF_TX_TCP3   (&serports.tcp3.cbufTx)
 
#define CIRBUF_RX_TCP3   (&serports.tcp3.cbufRx)
 
#define CIRBUF_TX_USB   (&serports.usb.cbufTx)
 
#define CIRBUF_RX_USB   (&serports.usb.cbufRx)
 
#define CIRBUF_TX_USER1   (&serports.user1.cbufTx)
 
#define CIRBUF_RX_USER1   (&serports.user1.cbufRx)
 
#define CIRBUF_TX_USER2   (&serports.user2.cbufTx)
 
#define CIRBUF_RX_USER2   (&serports.user2.cbufRx)
 
#define CIRBUF_TX_USER3   (&serports.user3.cbufTx)
 
#define CIRBUF_RX_USER3   (&serports.user3.cbufRx)
 
#define CIRBUF_TX_USER4   (&serports.user4.cbufTx)
 
#define CIRBUF_RX_USER4   (&serports.user4.cbufRx)
 
#define CIRBUF_TX_USER5   (&serports.user5.cbufTx)
 
#define CIRBUF_RX_USER5   (&serports.user5.cbufRx)
 
#define CIRBUF_TX_USER6   (&serports.user6.cbufTx)
 
#define CIRBUF_RX_USER6   (&serports.user6.cbufRx)
 
#define CIRBUF_TX_USER7   (&serports.user7.cbufTx)
 
#define CIRBUF_RX_USER7   (&serports.user7.cbufRx)
 
#define CIRBUF_TX_USER8   (&serports.user8.cbufTx)
 
#define CIRBUF_RX_USER8   (&serports.user8.cbufRx)
 
#define getCirbufForSerportID(bufid)   ( (bufid&0x01) ? ( &((SERPORT*)(NZ_GLOBALS_SERPORT_FIRST + (bufid/2)))->cbufTx) : ( &((SERPORT*)(NZ_GLOBALS_SERPORT_FIRST + (bufid/2)))->cbufRx) )
 
#define serIsEnabled(pSerport)   ( ((pSerport->flags & SERPORT_STAT_ENABLED) != 0) && (pSerport!=NULL) )
 

Typedefs

typedef struct _SERPORT SERPORT
 
typedef struct SERPORTS_ SERPORTS
 
typedef struct _SER_INFO SER_INFO
 

Enumerations

enum  SERPORT_TYPE_UART {
  SERPORT_TYPE_UNDEFINED =0, SERPORT_TYPE_SOFTWARE, SERPORT_TYPE_UART, SERPORT_TYPE_USART,
  SERPORT_TYPE_SPI, SERPORT_TYPE_I2C, SERPORT_TYPE_USBHID, SERPORT_TYPE_UDP,
  SERPORT_TYPE_TCP, SERPORT_TYPE_CAN, SERPORT_TYPE_MIWI, SERPORT_TYPE_ZIGBEE,
  SERPORT_TYPE_BLUETOOTH, SERPORT_TYPE_MAX
}
 

Functions

void serInit (void)
 
void serDefaultInit (void)
 
void serTask (void)
 

Variables

SER_INFO serInfo
 
SERPORTS serports
 

Detailed Description

Functions for "Serial Data Ports"(SDP)

Author
Modtronix Engineering
Compiler:
MPLAB XC16

Description

Functions for "Serial Data Ports"(SDP)

Configuration

The following defines are used to configure this module, and should be placed in projdefs.h. Note that all items marked [-DEFAULT-] are defaults, and do not have to be placed in projdefs.h if they contain desired configuration! For details, see Project Configuration.

// *********************************************************************
// ------ Serial Data Port Configuration (from nz_serDataPorts.h) ------
// *********************************************************************
//Dont create TX and RX buffers for "Serial Data Ports"
#define SERPORT_DONT_CREATE_TXRX_BUFS
//Dont initialize the SER_INFO structure, we will provide the serDefaultInit() function!
#define SERPORT_DONT_MANAGE_SER_INFO_INIT

Software License Agreement

The software supplied herewith is owned by Modtronix Engineering, and is protected under applicable copyright laws. The software supplied herewith is intended and supplied to you, the Company customer, for use solely and exclusively on products manufactured by Modtronix Engineering. The code may be modified and can be used free of charge for commercial and non commercial applications. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license.

THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

File History

2014-01-17, David H. (DH):

  • Initial version

Macro Definition Documentation

#define getCirbufForSerportID (   bufid)    ( (bufid&0x01) ? ( &((SERPORT*)(NZ_GLOBALS_SERPORT_FIRST + (bufid/2)))->cbufTx) : ( &((SERPORT*)(NZ_GLOBALS_SERPORT_FIRST + (bufid/2)))->cbufRx) )

Gets the "Circular Buffer" for the given Serial Data Port Buffer ID.

Parameters
bufidA Serial Data Port Buffer ID.
#define SERPORT_STAT_ENABLED   0x8000

This SERPORT is enabled

Typedef Documentation

typedef struct _SER_INFO SER_INFO

Structure containing information for all "Serial Data Ports"

typedef struct _SERPORT SERPORT

"Serial Data Port" structure, TX and RX "Circular Buffers" (CIRBUF structures).

Enumeration Type Documentation

"Serial Data Port" Types

Function Documentation

void serDefaultInit ( void  )

Allocate required memory for "Serial Data Ports".

void serInit ( void  )

Initialization code.

void serTask ( void  )

Must be called every couple of ms