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

UART Port 1 functions. More...

Go to the source code of this file.

Detailed Description

UART Port 1 functions.

Author
Modtronix Engineering
Compiler:
MPLAB XC16

Description

Functions for communicating with UART Ports. It is interrupt based, and all processing is handled in the background by interrupt service routines. Internally Circular Buffers are used, allowing multiple messages to be written to the queue.

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.

// *********************************************************************
// --------------- UART Configuration (from nz_serUart.h) ----------------
// *********************************************************************
//To save space, this will remove all code to do with Listeners
//#define UART_DONT_SUPPORT_LISTENERS
//Number of listeners that can be registered for all UART ports, a value from 1 to 7.
#define UART_LISTENERS (4) //[-DEFAULT-]
//---- Enable UART1 as a "Serial Data Port" ----
#define NZ_UART1_ENABLE
#define USER_CONFIGURES_UART1 (0) //[-DEFAULT-]
//UART1 Interrupt priority, a value from 0 to 7. 0 will disable interrupt, 7 is highest priority.
#define nzINT_PRIORITY_UART1 (4) //[-DEFAULT-]
//Transmit and Receive buffer sizes, for compatibility, ensure it is a power of 2 value! This can be bypassed
//by using a "non power of 2" CircularBuffer implementation for this project. See nz_CircularBuffer.h for details.
#define UART1_RXBUF_SIZE (64) //[-DEFAULT-]
#define UART1_TXBUF_SIZE (256) //[-DEFAULT-]
//UART1 speed, can be 1K2, 2K4, 4K8, 9K6, 19K2, 38K4, 56K, 115K, 250K. Can also use value, for example 12 will give 300kbps.
#define UART1_BAUD (UART_BAUD_9K6) //[-DEFAULT-]
//Uncomment this to define your own UART 1 TX and RX "Circular Buffers"
//#define UART1_DONT_CREATE_CIRBUF
//UART1 ISR timeout, default is 200ms. This is maximum time allowed from START till STOP
#define UART1_TIMEOUT (200) //[-DEFAULT-]
//---- Enable UART2 as a "Serial Data Port" ----
#define NZ_UART2_ENABLE
#define USER_CONFIGURES_UART1 (0) //[-DEFAULT-]
//UART2 Interrupt priority, a value from 0 to 7. 0 will disable interrupt, 7 is highest priority.
#define nzINT_PRIORITY_UART2 (4) //[-DEFAULT-]
//Transmit and Receive buffer sizes, for compatibility, ensure it is a power of 2 value! This can be bypassed
//by using a "non power of 2" CircularBuffer implementation for this project. See nz_CircularBuffer.h for details.
#define UART2_RXBUF_SIZE (64) //[-DEFAULT-]
#define UART2_TXBUF_SIZE (256) //[-DEFAULT-]

Usage

To use this module, the following must be done:

  • Ensure a "Circular Buffer" has been added to the project, for details see Circular Buffer Usage.
  • Copy the Configuration section above (from nz_serUart.h) to the projdefs.h file.
  • In this "Configuration" section, enable required UART ports. For example to enable UART 1, ensure following is uncommented:
    #define NZ_UART1_ENABLE
  • In this "Configuration" section, change any default values if required (if default values should be used, define is not required in projdefs.h).
  • Add nz_serUart.c and nz_serDataPorts.c to the MPLAB project.
  • Include nz_serUart.h in the c file it is used in.
  • All DONE! The functions defined in this file can now be used in the project.

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

2011-06-03, David H. (DH):

  • Initial version