MAX3100, an external serial device to add additional serial ports via SPI

Dependents:   FLIGHT_CONTROL_AND_COMMUNICATIONS_SYSTEM

Embed: (wiki syntax)

« Back to documentation index

MAX3100 Class Reference

MAX3100 An external serial IO device. More...

#include <MAX3100.h>

Public Member Functions

 MAX3100 ()
 Constructor.
 MAX3100 (PinName mosi, PinName miso, PinName sclk, PinName cs, PinName irq, int device=0)
 Constructor.
 MAX3100 (SPI *spi, PinName cs, PinName irq, int device=0)
 Constructor.
virtual ~MAX3100 ()
 Destructor.
void setParity (int p)
 setParity
void setStopBits (int i)
 setStopBits
void isr (void)
 System interrupt service routine.
void baud (int baudrate)
 baud Set the system baud.
void enableRxIrq (void)
 enableRxIrq
void disableRxIrq (void)
 disableRxIrq
void enableTxIrq (void)
 enableTxIrq
void disableTxIrq (void)
 disableTxIrq
int putc (int c)
 putc
void puts (char *s)
 puts
int getc (void)
 getc
char * gets (char *s, int size)
 gets Get a string.
int peek (void)
 peek like getc() but does NOT remove the byte from the buffer.
int readable (void)
 readable Are any byte(s) available in the RX buffer?
int writable (void)
 writable Can we write a byte to teh serial stream?
void setDevice (int i)
 setDevice Give this device an "address".
void flushTxBuffer (void)
 flushTxBuffer
void flushRxBuffer (void)
 flushRxBuffer
void irqMask (PinName p)
 irqMask Setup the mask for enable/disable interrupts.
void attach_cs (void(*function)(int, int)=0)
 attach_cs Attach a C style callback function pointer.
template<class T >
void attach_cs (T *item, void(T::*method)(int, int))
 attach_cs Attach a C++ object/method pointer.
void attach_isr_user (void(*function)(int)=0)
 attach_isr_user is controlling the chip CS line.
template<class T >
void attach_isr_user (T *item, void(T::*method)(int))
 attach_isr_user

Protected Member Functions

void init (PinName mosi, PinName miso, PinName sclk, PinName cs, PinName irq, SPI *spi=(SPI *) NULL)
 init

Detailed Description

MAX3100 An external serial IO device.

The MAX3100 librray is designed to allow the easy attachment of additional serial ports to the Mbed. We all know that the Mbed already has 3 potential serial ports. But maybe you need more ports or maybe you need to use the Mbed pins for an alternative function. The MAX3100 may well be able to help in situations like these.

Each MAX3100 device you create in is TX/RX buffered with 32 characters in a circular buffer system.

The MAX3100 uses at least one Mbed SPI port and additional DigitalOut and InterruptIn pins to work. However, you can attach multiple MAX3100 devices to a single SPI "bus".

For more information on attaching multiple devices see all the examples listed below.

See also:
example1.h
example2.h
example3.h
http://pdfserv.maxim-ic.com/en/ds/MAX3100.pdf

Definition at line 93 of file MAX3100.h.


Constructor & Destructor Documentation

MAX3100 (  )

Constructor.

Definition at line 172 of file MAX3100.h.

MAX3100 ( PinName  mosi,
PinName  miso,
PinName  sclk,
PinName  cs,
PinName  irq,
int  device = 0 
)

Constructor.

Definition at line 176 of file MAX3100.h.

MAX3100 ( SPI *  spi,
PinName  cs,
PinName  irq,
int  device = 0 
)

Constructor.

Definition at line 183 of file MAX3100.h.

virtual ~MAX3100 (  ) [virtual]

Destructor.

Definition at line 190 of file MAX3100.h.


Member Function Documentation

void attach_cs ( T *  item,
void(T::*)(int, int)  method 
)

attach_cs Attach a C++ object/method pointer.

Used if an external function

Parameters:
objectAn object that conatins the callback method.
methodThe method within the object to call.

Definition at line 331 of file MAX3100.h.

void attach_cs ( void(*)(int, int)  function = 0 )

attach_cs Attach a C style callback function pointer.

Used if an external function is controlling the chip CS line.

Parameters:
functionA C function pointer

Definition at line 323 of file MAX3100.h.

void attach_isr_user ( void(*)(int)  function = 0 )

attach_isr_user is controlling the chip CS line.

Parameters:
functionA C function pointer

Definition at line 339 of file MAX3100.h.

void attach_isr_user ( T *  item,
void(T::*)(int)  method 
)

attach_isr_user

Parameters:
objectAn object that conatins the callback method.
methodThe method within the object to call.

Definition at line 346 of file MAX3100.h.

void baud ( int  baudrate )

baud Set the system baud.

Default is "10" (9600). Note, this is not like Mbed's Serial where you pass the baud rate you want. The MAX3100 has 16 possible preset prescalers you can choose from. See the datasheet for more info.

See also:
http://pdfserv.maxim-ic.com/en/ds/MAX3100.pdf
Parameters:
intA number from 0 to 15 indicating which prescaler to use.

Definition at line 106 of file MAX3100.cpp.

void disableRxIrq ( void   )

disableRxIrq

Definition at line 126 of file MAX3100.cpp.

void disableTxIrq ( void   )

disableTxIrq

Definition at line 145 of file MAX3100.cpp.

void enableRxIrq ( void   )

enableRxIrq

Definition at line 116 of file MAX3100.cpp.

void enableTxIrq ( void   )

enableTxIrq

Definition at line 135 of file MAX3100.cpp.

void flushRxBuffer ( void   )

flushRxBuffer

Flush the RX buffer.

Definition at line 309 of file MAX3100.h.

void flushTxBuffer ( void   )

flushTxBuffer

Flush the TX buffer.

Definition at line 303 of file MAX3100.h.

int getc ( void   )

getc

Returns:
int c The byte read or -1 if no bytes to read.

Definition at line 207 of file MAX3100.cpp.

char * gets ( char *  s,
int  size 
)

gets Get a string.

Note, this method blocks until size bytes are read.

Parameters:
char*s where to place the incoming bytes.
intsize How many bytes to read.
Returns:
char * The value of *s passed in.

Definition at line 216 of file MAX3100.cpp.

void init ( PinName  mosi,
PinName  miso,
PinName  sclk,
PinName  cs,
PinName  irq,
SPI *  spi = (SPI *)NULL 
) [protected]

init

Initialise the device.

Parameters:
PinNameSPI mosi
PinNameSPI miso
PinNameSPI sclk
PinNameDigitalOut cs
PinNameInterruptIn irq
SPI* A pointer to a shared SPI bus

Definition at line 28 of file MAX3100.cpp.

void irqMask ( PinName  p )

irqMask Setup the mask for enable/disable interrupts.

See also:
example3.h
Parameters:
PinNamep The InterruptIn pin.

Definition at line 324 of file MAX3100.cpp.

void isr ( void   )

System interrupt service routine.

Definition at line 234 of file MAX3100.cpp.

int peek ( void   )

peek like getc() but does NOT remove the byte from the buffer.

See also:
getc*(

Definition at line 228 of file MAX3100.cpp.

int putc ( int  c )

putc

Parameters:
intc The byte to write.

Definition at line 154 of file MAX3100.cpp.

void puts ( char *  s )

puts

Parameters:
char* The string to print.

Definition at line 198 of file MAX3100.cpp.

int readable ( void   )

readable Are any byte(s) available in the RX buffer?

Returns:
0 if none, 1 otherwise.

Definition at line 285 of file MAX3100.h.

void setDevice ( int  i )

setDevice Give this device an "address".

Parameters:
inti An address to use in callbacks.

Definition at line 297 of file MAX3100.h.

void setParity ( int  p )

setParity

Set the parity of the system. Default is None.

Parameters:
ParityNone, Odd, Even

Definition at line 210 of file MAX3100.h.

void setStopBits ( int  i )

setStopBits

Set the number of stop bits. Default is One.

Parameters:
int1 or 2

Definition at line 281 of file MAX3100.cpp.

int writable ( void   )

writable Can we write a byte to teh serial stream?

Returns:
non-zero if we can, zero otherwise.

Definition at line 291 of file MAX3100.h.