Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 | attach_cs (void(*function)(int, int)=0) |
| irqMask Setup the mask for enable/disable interrupts. | |
| 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.
Definition at line 94 of file MAX3100.h.
Constructor & Destructor Documentation
| MAX3100 | ( | PinName | mosi, |
| PinName | miso, | ||
| PinName | sclk, | ||
| PinName | cs, | ||
| PinName | irq, | ||
| int | device = 0 |
||
| ) |
| MAX3100 | ( | SPI * | spi, |
| PinName | cs, | ||
| PinName | irq, | ||
| int | device = 0 |
||
| ) |
Member Function Documentation
| void attach_cs | ( | void(*)(int, int) | function = 0 ) |
irqMask Setup the mask for enable/disable interrupts.
- See also:
- example3.h
- Parameters:
-
PinName p The InterruptIn pin. attach_cs Attach a C style callback function pointer. Used if an external function is controlling the chip CS line. function A C function pointer
| void attach_cs | ( | T * | item, |
| void(T::*)(int, int) | method | ||
| ) |
| void attach_isr_user | ( | T * | item, |
| void(T::*)(int) | method | ||
| ) |
| void attach_isr_user | ( | void(*)(int) | function = 0 ) |
| 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.
- Parameters:
-
int A 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 | ) |
| void flushTxBuffer | ( | void | ) |
| 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. int size 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:
-
PinName SPI mosi PinName SPI miso PinName SPI sclk PinName DigitalOut cs PinName InterruptIn irq SPI * A pointer to a shared SPI bus
Definition at line 28 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 ) |
| void puts | ( | char * | s ) |
| int readable | ( | void | ) |
| void setDevice | ( | int | i ) |
| void setParity | ( | int | p ) |
| void setStopBits | ( | int | i ) |
setStopBits
Set the number of stop bits. Default is One.
- Parameters:
-
int 1 or 2
Definition at line 281 of file MAX3100.cpp.
Generated on Fri Jul 15 2022 23:15:48 by
1.7.2