54 #define LD_PARITY_ERROR 32
55 #define LD_FRAMING_ERROR 64
56 #define LD_OVERRUN_ERROR 128
57 #define LD_LINK_UP 256
58 #define LD_LINK_DOWN 512
74 #if !defined(LEDCOMM_USE_LCOM1) || defined(__DOXYGEN__)
75 #define LEDCOMM_USE_LCOM1 TRUE
78 #if !defined(LEDCOMM_USE_LCOM2) || defined(__DOXYGEN__)
79 #define LEDCOMM_USE_LCOM2 FALSE
82 #if !defined(LEDCOMM_BUFFERS_SIZE) || defined(__DOXYGEN__)
83 #define LEDCOMM_BUFFERS_SIZE 16
87 #define LEDCOMM_DEFAULT_SYNCS 18
88 #define LEDCOMM_DEFAULT_THRESHOLD 3000
90 #define LEDCOMM_DATA_BITS8 0
91 #define LEDCOMM_DATA_BITS7 1
92 #if !defined(LEDCOMM_DEFAULT_DATA_BITS) || defined(__DOXYGEN__)
93 #define LEDCOMM_DEFAULT_DATA_BITS LEDCOMM_DATA_BITS7
96 #define LEDCOMM_PARITY_NONE 0
97 #define LEDCOMM_PARITY 1
98 #if !defined(LEDCOMM_DEFAULT_PARITY) || defined(__DOXYGEN__)
99 #define LEDCOMM_DEFAULT_PARITY LEDCOMM_PARITY_NONE
102 #define LEDCOMM_PARITY_EVEN 0
103 #define LEDCOMM_PARITY_ODD 1
104 #define LEDCOMM_PARITY_SPACE 2
105 #define LEDCOMM_PARITY_MARK 3
106 #if !defined(LEDCOMM_DEFAULT_PARITY_TYPE) || defined(__DOXYGEN__)
107 #define LEDCOMM_DEFAULT_PARITY_TYPE LEDCOMM_PARITY_EVEN
122 #define _ledcomm_driver_data \
123 _base_asynchronous_channel_data \
129 OutputQueue oqueue; \
131 uint8_t ib[LEDCOMM_BUFFERS_SIZE]; \
133 uint8_t ob[LEDCOMM_BUFFERS_SIZE]; \
135 ioportid_t anode_port; \
136 ioportmask_t anode_pad; \
137 ioportid_t cathode_port; \
138 ioportmask_t cathode_pad; \
139 uint16_t threshold; \
141 uint8_t data_bits:1; \
143 uint8_t parity_type:2; \
144 uint8_t parity_flag:1; \
154 uint16_t rx_register; \
177 uint8_t parity_type:2;
200 #define _ledcomm_driver_methods \
201 _base_asynchronous_channel_methods
243 #define ldPut(ldp, b) chOQPut(&(ldp)->oqueue, b)
255 #define ldPutTimeout(ldp, b, t) chOQPutTimeout(&(ldp)->oqueue, b, t)
267 #define ldGet(ldp) chIQGet(&(ldp)->iqueue)
279 #define ldGetTimeout(ldp, t) chIQGetTimeout(&(ldp)->iqueue, t)
291 #define ldWrite(ldp, b, n) \
292 chOQWriteTimeout(&(ldp)->oqueue, b, n, TIME_INFINITE)
305 #define ldWriteTimeout(ldp, b, n, t) \
306 chOQWriteTimeout(&(ldp)->oqueue, b, n, t)
318 #define ldAsynchronousWrite(ldp, b, n) \
319 chOQWriteTimeout(&(ldp)->oqueue, b, n, TIME_IMMEDIATE)
331 #define ldRead(ldp, b, n) \
332 chIQReadTimeout(&(ldp)->iqueue, b, n, TIME_INFINITE)
345 #define ldReadTimeout(ldp, b, n, t) \
346 chIQReadTimeout(&(ldp)->iqueue, b, n, t)
358 #define ldAsynchronousRead(ldp, b, n) \
359 chIQReadTimeout(&(ldp)->iqueue, b, n, TIME_IMMEDIATE)
366 #if LEDCOMM_USE_LCOM1 && !defined(__DOXYGEN__)
369 #if LEDCOMM_USE_LCOM2 && !defined(__DOXYGEN__)
373 #if LEDCOMM_USE_GPTD1 && !defined(__DOXYGEN__)
374 #define GPTD_LEDComm GPTD1
377 #if LEDCOMM_USE_GPTD2 && !defined(__DOXYGEN__)
378 #define GPTD_LEDComm GPTD2
381 #if LEDCOMM_USE_EXTD1 && !defined(__DOXYGEN__)
382 #define EXTD_LEDComm EXTD1
385 #if LEDCOMM_USE_EXTD2 && !defined(__DOXYGEN__)
386 #define EXTD_LEDComm EXTD2
#define _ledcomm_driver_data
LEDCommDriver specific data.
void ldStart(LEDCommDriver_t *ldp, const LEDCommConfig_t *config)
Configures and starts the driver.
ioportid_t cathode_port
The port where the LED cathode is connected.
ldstate_t
Driver state machine possible states.
ioportid_t anode_port
The port where the LED anode is connected.
uint16_t threshold
The highest number of elapsed HAL ticks that represents a 'shine' – try LEDCOMM_DEFAULT_THRESHOLD (3...
uint32_t cathode_extmode
The processor-specific EXT mode used to configure the extcfg table.
LEDComm configuration header.
void ldStop(LEDCommDriver_t *ldp)
Stops the driver.
LEDCommDriver virtual methods table.
#define _ledcomm_driver_methods
LEDCommDriver specific methods.
void ldInit(void)
LEDComm Driver initialization.
LEDComm Driver configuration structure.
msg_t ldRequestDataI(LEDCommDriver_t *ldp)
Handles outgoing data.
void ldObjectInit(LEDCommDriver_t *ldp, qnotify_t inotify, qnotify_t onotify)
Initializes a generic full duplex driver object.
void ldIncomingDataI(LEDCommDriver_t *ldp, uint8_t b)
Handles incoming data.
const struct LEDCommDriverVMT * vmt
Virtual Methods Table.
Full duplex LEDComm driver class.
ioportmask_t cathode_pad
The pad where the LED cathode is connected.
ioportmask_t anode_pad
The pad where the LED anode is connected.