Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / colonet / utilities / dragonfly_wireless_relay / serial.h @ 13

History | View | Annotate | Download (1.8 KB)

1
/*
2
        serial.h - Contains definitions and function prototypes for the RS232 serial port
3
  author(s): pkv
4
  
5
  Directions:
6
  Call the initialization function for the serial port you wish to use.  Then, use
7
  either the provided functions or the stdio functions (fprintf, etc) to read and
8
  write characters to the serial ports.
9
  
10
  UART Mapping:
11
    usb_*() -> UART0
12
    xbee_*() -> UART1
13
  
14
  Options: (Add the following defines to your code to configure this library)
15
    #define USB_BAUD { 115200 | 9600 } <= pick ONE value from in here
16
    #define XBEE_BAUD { 115200 | 9600 } <= pick ONE value from in here
17
    #define USE_STDIO
18
  
19
  Note: If you enable USE_STDIO, the first init function that is called will 
20
  automatically be linked to stdin, stdout, and stderr.  To use the baud rate 
21
  commands, add something like the following to your code:
22
  
23
  #define FOO_BAUD 9600
24
  
25
  **UNLESS YOU KNOW WHAT YOU ARE DOING, PLEASE DO NOT CHANGE THIS FILE**
26
  Many, many other people use this file in their code.  If you change it, you will
27
  probably break all of their nice code.  You should not need to change anything in
28
  here, except to accomodate new hardware.
29
*/
30

    
31
#ifndef _SERIAL_H
32
#define _SERIAL_H
33

    
34
// if no baud rate is defined for usb, default is set here
35
#ifndef USB_BAUD
36
#define USB_BAUD 115200
37
#endif
38

    
39
// if no baud rate is defined for xbee, default is set here
40
#ifndef XBEE_BAUD
41
#define XBEE_BAUD 115200
42
#endif
43

    
44
#include <stdio.h>
45
FILE *usb_fd;  //For use with fprintf() and related stdio functions
46
FILE *xbee_fd;  //For use with fprintf() and related stdio functions
47

    
48
void usb_init(void);
49
int usb_putc(char c);
50
int usb_getc(void);
51
int usb_getc_nb(char *c);
52
int usb_puts(char *s);
53
int usb_puti(int value);
54

    
55
void xbee_init(void);
56
int xbee_putc(char c);
57
int xbee_getc(void);
58
int xbee_getc_nb(char *c);
59
int xbee_puts(char *s);
60

    
61
#endif