LEDComm
1.0
|
Generic (but slow) Serial Driver using an LED instead of TX and RX wires. More...
Functions | |
void | ldInit (void) |
LEDComm Driver initialization. More... | |
void | ldObjectInit (LEDCommDriver_t *ldp, qnotify_t inotify, qnotify_t onotify) |
Initializes a generic full duplex driver object. More... | |
void | ldStart (LEDCommDriver_t *ldp, const LEDCommConfig_t *config) |
Configures and starts the driver. More... | |
void | ldStop (LEDCommDriver_t *ldp) |
Stops the driver. More... | |
void | ldIncomingDataI (LEDCommDriver_t *ldp, uint8_t b) |
Handles incoming data. More... | |
msg_t | ldRequestDataI (LEDCommDriver_t *ldp) |
Handles outgoing data. More... | |
LEDComm status flags | |
#define | LD_PARITY_ERROR 32 |
Parity error happened. More... | |
#define | LD_FRAMING_ERROR 64 |
Framing error happened. More... | |
#define | LD_OVERRUN_ERROR 128 |
Overflow happened. More... | |
#define | LD_LINK_UP 256 |
Link detected. More... | |
#define | LD_LINK_DOWN 512 |
No link detected. More... | |
Generic (but slow) Serial Driver using an LED instead of TX and RX wires.
This module implements a generic half duplex serial driver that uses an LED instead of TX and RX wires. The driver implements a SerialDriver
interface and uses I/O Queues for communication. Event flags are used to notify the application about incoming data, outgoing data and other I/O events.
$(CHIBIOS)/ext
directory. The project Makefile
must be modified by adding $(CHIBIOS)/ext/ledcomm-X.Y.Z/ledcomm.c
to the CSRC
variable and $
(CHIBIOS)/ext/ledcomm-X.Y.Z
to the INCDIR
variable.The driver implements a state machine internally, not all the driver functionalities can be used in any moment, any transition not explicitly shown in the following diagram has to be considered an error and shall be captured by an assertion (if enabled).
#define LD_OVERRUN_ERROR 128 |
void ldInit | ( | void | ) |
LEDComm Driver initialization.
halInit()
, you must explicitly initialize the driver.Definition at line 296 of file ledcomm.c.
References ldObjectInit().
void ldObjectInit | ( | LEDCommDriver_t * | ldp, |
qnotify_t | inotify, | ||
qnotify_t | onotify | ||
) |
Initializes a generic full duplex driver object.
The HW dependent part of the initialization has to be performed outside, usually in the hardware initialization code.
[out] | ldp | pointer to a LEDCommDriver structure |
[in] | inotify | pointer to a callback function that is invoked when some data is read from the Queue. The value can be NULL . |
[in] | onotify | pointer to a callback function that is invoked when some data is written in the Queue. The value can be NULL . |
Definition at line 322 of file ledcomm.c.
References LD_STOP, LEDCOMM_BUFFERS_SIZE, and LEDCommDriver::vmt.
Referenced by ldInit().
void ldStart | ( | LEDCommDriver_t * | ldp, |
const LEDCommConfig_t * | config | ||
) |
Configures and starts the driver.
[in] | ldp | pointer to a LEDCommDriver object |
[in] | config | the architecture-dependent LEDComm driver configuration. If this parameter is set to NULL then a default configuration is used. |
Definition at line 341 of file ledcomm.c.
References LEDCommConfig_t::anode_pad, LEDCommConfig_t::anode_port, LEDCommConfig_t::cathode_extmode, LEDCommConfig_t::cathode_pad, LEDCommConfig_t::cathode_port, LEDCommConfig_t::data_bits, LD_READY, LD_STOP, LEDCOMM_DATA_BITS7, LEDCOMM_DEFAULT_SYNCS, and LEDCommConfig_t::threshold.
void ldStop | ( | LEDCommDriver_t * | ldp | ) |
Stops the driver.
Any thread waiting on the driver's queues will be awakened with the message Q_RESET
.
[in] | ldp | pointer to a LEDCommDriver object |
void ldIncomingDataI | ( | LEDCommDriver_t * | ldp, |
uint8_t | b | ||
) |
Handles incoming data.
This function must be called from the input interrupt service routine in order to enqueue incoming data and generate the related events.
[in] | ldp | pointer to a LEDCommDriver structure |
[in] | b | the byte to be written in the driver's Input Queue |
Definition at line 445 of file ledcomm.c.
References LD_OVERRUN_ERROR.
msg_t ldRequestDataI | ( | LEDCommDriver_t * | ldp | ) |
Handles outgoing data.
Must be called from the output interrupt service routine in order to get the next byte to be transmitted.
[in] | ldp | pointer to a LEDCommDriver structure |
Q_EMPTY | if the queue is empty (the lower driver usually disables the interrupt source when this happens). |