1 /*******************************************************************************
\r
2 * (c) Copyright 2011-2013 Microsemi SoC Products Group. All rights reserved.
\r
4 * SmartFusion2 Microcontroller Subsystem MMUART bare metal software driver
\r
7 * SVN $Revision: 5610 $
\r
8 * SVN $Date: 2013-04-05 14:19:30 +0100 (Fri, 05 Apr 2013) $
\r
10 /*=========================================================================*//**
\r
11 @mainpage SmartFusion2 MSS UART Bare Metal Driver.
\r
12 ==============================================================================
\r
13 @section intro_sec Introduction
\r
14 ==============================================================================
\r
15 The SmartFusion2 microcontroller subsystem (MSS) includes two multi-mode UART
\r
16 (MMUART) peripherals for serial communication. This driver provides a set of
\r
17 functions for controlling the MSS MMUARTs as part of a bare metal system
\r
18 where no operating system is available. These drivers can be adapted for use
\r
19 as part of an operating system, but the implementation of the adaptation layer
\r
20 between this driver and the operating system's driver model is outside the
\r
21 scope of this driver.
\r
22 Note: MSS UART is synonymous with MSS MMUART in this document.
\r
24 ==============================================================================
\r
25 @section hw_dependencies Hardware Flow Dependencies
\r
26 ==============================================================================
\r
27 The configuration of all features of the MSS MMUART peripherals is covered by
\r
28 this driver with the exception of the SmartFusion2 IOMUX configuration.
\r
29 SmartFusion2 allows multiple non-concurrent uses of some external pins through
\r
30 IOMUX configuration. This feature allows optimization of external pin usage by
\r
31 assigning external pins for use by either the microcontroller subsystem or the
\r
32 FPGA fabric. The MSS MMUART serial signals are routed through IOMUXs to the
\r
33 SmartFusion2 device external pins. The MSS MMUART serial signals may also be
\r
34 routed through IOMUXs to the SmartFusion2 FPGA fabric. For more information on
\r
35 IOMUX, refer to the IOMUX section of the SmartFusion2 Microcontroller
\r
36 Subsystem (MSS) User
\92s Guide.
\r
37 The IOMUXs are configured using the SmartFusion2 MSS configurator tool. You
\r
38 must ensure that the MSS MMUART peripherals are enabled and configured in the
\r
39 SmartFusion2 MSS configurator if you wish to use them. For more information on
\r
40 IOMUXs, refer to the IOMUX section of the SmartFusion2 Microcontroller
\r
41 Subsystem (MSS) User
\92s Guide.
\r
42 The base address, register addresses and interrupt number assignment for the
\r
43 MSS MMUART peripherals are defined as constants in the SmartFusion2 CMSIS HAL.
\r
44 You must ensure that the latest SmartFusion2 CMSIS HAL is included in the
\r
45 project settings of the software tool chain used to build your project and
\r
46 that it is generated into your project.
\r
48 ==============================================================================
\r
49 @section theory_op Theory of Operation
\r
50 ==============================================================================
\r
51 The MSS MMUART driver functions are grouped into the following categories:
\r
52 - Initialization and configuration functions
\r
53 - Polled transmit and receive functions
\r
54 - Interrupt driven transmit and receive functions
\r
56 --------------------------------
\r
57 Initialization and Configuration
\r
58 --------------------------------
\r
59 The MSS MMUART supports the following four broad modes of operation:
\r
60 - UART or USART mode
\r
63 - Smartcard or ISO 7816 mode
\r
64 The MSS MMUART driver provides the MSS_UART_init(), MSS_UART_lin_init(),
\r
65 MSS_UART_irda_init() and MSS_UART_smartcard_init() functions to initialize the
\r
66 MSS MMUARTs for operation in one of these modes. One of these initialization
\r
67 functions must be called before any other MSS MMUART driver functions can be
\r
68 called. The MSS MMUART operating modes are mutually exclusive; therefore only
\r
69 one of the initialization functions must be called. The first parameter of the
\r
70 initialization functions is a pointer to one of two global data structures
\r
71 used to store state information for each MSS MMUART. A pointer to these data
\r
72 structures is also used as the first parameter to many of the driver functions
\r
73 to identify which MSS MMUART will be used by the called function. The names of
\r
74 these two data structures are g_mss_uart0 and g_mss_uart1. Therefore, any call
\r
75 to an MSS MMUART function should be of the form
\r
76 MSS_UART_function_name( &g_mss_uart0, ... ) or
\r
77 MSS_UART_function_name( &g_mss_uart1, ... ).
\r
80 For the UART or USART modes of operation, the MSS MMUART driver is initialized
\r
81 through a call to the MSS_UART_init() function. This function takes the UART
\92s
\r
82 configuration as its parameters. The MSS_UART_init() function must be called
\r
83 before any other MSS MMUART driver functions can be called.
\r
84 The MSS_UART_init() function configures the baud rate based on the input baud
\r
85 rate parameter and if possible uses a fractional baud rate for greater
\r
86 precision. This function disables the LIN, IrDA and SmartCard modes.
\r
89 For the LIN mode of operation, the MSS MMUART driver is initialized through a
\r
90 call to the MSS_UART_lin_init() function. This function takes the LIN node
\92s
\r
91 configuration as its parameters. The MSS_UART_lin_init() function must be
\r
92 called before any other MSS MMUART driver functions can be called. The
\r
93 MSS_UART_lin_init() function configures the baud rate based on the input baud
\r
94 rate parameter and if possible uses a fractional baud rate for greater
\r
95 precision. This function disables the IrDA and SmartCard modes.
\r
96 The driver also provides the following LIN mode configuration functions:
\r
97 - MSS_UART_set_break()
\r
98 - MSS_UART_clear_break()
\r
99 - MSS_UART_set_pidpei_handler()
\r
100 - MSS_UART_set_linbreak_handler()
\r
101 - MSS_UART_set_linsync_handler()
\r
102 Note: These LIN mode configuration functions can only be called after the
\r
103 MSS_UART_lin_init() function is called.
\r
106 For the IrDA mode of operation, the driver is initialized through a call to
\r
107 the MSS_UART_irda_init() function. This function takes the IrDA node
\92s
\r
108 configuration as its parameters. The MSS_UART_irda_init() function must be
\r
109 called before any other MSS MMUART driver functions can be called. The
\r
110 MSS_UART_irda_init() function configures the baud rate based on the input baud
\r
111 rate parameter and if possible uses a fractional baud rate for greater
\r
112 precision. This function disables the LIN and SmartCard modes.
\r
114 Smartcard or ISO 7816 mode
\r
115 For the Smartcard or ISO 7816 mode of operation, the driver is initialized
\r
116 through a call to the MSS_UART_smartcard_init() function. This function takes
\r
117 the smartcard configuration as its parameters. The MSS_UART_smartcard_init()
\r
118 function must be called before any other MSS MMUART driver functions can be
\r
119 called. The MSS_UART_smartcard_init() function configures the baud rate based
\r
120 on the input baud rate parameter and if possible uses a fractional baud rate
\r
121 for greater precision. This function disables the LIN and IrDA modes.
\r
122 The driver also provides the following Smartcard mode configuration functions:
\r
123 - MSS_UART_enable_halfduplex()
\r
124 - MSS_UART_disable_halfduplex()
\r
125 - MSS_UART_set_nack_handler()
\r
126 Note: These Smartcard mode configuration functions can only be called after
\r
127 the MSS_UART_smartcard_init() function is called.
\r
129 Common Configuration Functions
\r
130 The driver also provides the configuration functions that can be used with all
\r
131 MSS MMUART operating modes. These common configuration functions are as
\r
133 - MSS_UART_set_rx_endian()
\r
134 - MSS_UART_set_tx_endian()
\r
135 - MSS_UART_enable_afclear()
\r
136 - MSS_UART_disable_afclear()
\r
137 - MSS_UART_enable_rx_timeout()
\r
138 - MSS_UART_disable_rx_timeout()
\r
139 - MSS_UART_enable_tx_time_guard()
\r
140 - MSS_UART_disable_tx_time_guard()
\r
141 - MSS_UART_set_address()
\r
142 - MSS_UART_set_ready_mode()
\r
143 - MSS_UART_set_usart_mode()
\r
144 - MSS_UART_set_filter_length()
\r
145 - MSS_UART_enable_afm()
\r
146 - MSS_UART_disable_afm()
\r
147 Note: These configuration functions can only be called after one of the
\r
148 MSS_UART_init(), MSS_UART_lin_init(), MSS_UART_irda_init() or
\r
149 MSS_UART_smartcard_init() functions is called.
\r
151 --------------------------------------
\r
152 Polled Transmit and Receive Operations
\r
153 --------------------------------------
\r
154 The driver can be used to transmit and receive data once initialized.
\r
155 Data is transmitted using the MSS_UART_polled_tx() function. This function is
\r
156 blocking, meaning that it will only return once the data passed to the
\r
157 function has been sent to the MSS MMUART hardware transmitter. Data received
\r
158 by the MSS MMUART hardware receiver can be read by the MSS_UART_get_rx()
\r
160 The MSS_UART_polled_tx_string() function is provided to transmit a NULL (
\91\0
\92)
\r
161 terminated string in polled mode. This function is blocking, meaning that it
\r
162 will only return once the data passed to the function has been sent to the MSS
\r
163 MMUART hardware transmitter.
\r
164 The MSS_UART_fill_tx_fifo() function fills the MSS MMUART hardware transmit
\r
165 FIFO with data from a buffer passed as a parameter and returns the number of
\r
166 bytes transferred to the FIFO. If the transmit FIFO is not empty when the
\r
167 MSS_UART_fill_tx_fifo() function is called it returns immediately without
\r
168 transferring any data to the FIFO.
\r
170 ---------------------------
\r
171 Interrupt Driven Operations
\r
172 ---------------------------
\r
173 The driver can also transmit or receive data under interrupt control, freeing
\r
174 your application to perform other tasks until an interrupt occurs indicating
\r
175 that the driver
\92s attention is required.
\r
178 The MSS MMUART driver supports all types of interrupt triggered by the MSS
\r
179 MMUART. The driver
\92s internal top level interrupt handler identifies the
\r
180 source of the MSS MMUART interrupt and calls the corresponding lower level
\r
181 handler function that you previously registered with the driver through calls
\r
182 to the MSS_UART_set_rx_handler(), MSS_UART_set_tx_handler(),
\r
183 MSS_UART_set_rxstatus_handler(), and MSS_UART_set_modemstatus_handler()
\r
184 functions. You are responsible for creating these lower level interrupt
\r
185 handlers as part of your application program and registering them with the
\r
187 Note: The SmartFusion2 CMSIS-PAL defines the UART0_IRQHandler() and
\r
188 UART1_IRQHandler() functions (with weak linkage) and assigns them as the
\r
189 interrupt service routines (ISR) for the MSS MMUART interrupt inputs to
\r
190 the Cortex-M3 NVIC. The MSS MMUART driver provides the implementation
\r
191 functions for both of these ISRs from which it calls its own internal
\r
192 top level, interrupt handler function.
\r
193 The MSS_UART_enable_irq() and MSS_UART_disable_irq() functions are used to
\r
194 enable or disable the received line status, received data available/character
\r
195 timeout, transmit holding register empty and modem status interrupts at the
\r
196 MSS MMUART level. The MSS_UART_enable_irq() function also enables the MSS
\r
197 MMUART instance interrupt at the Cortex-M3 level.
\r
200 Interrupt-driven transmit is initiated by a call to MSS_UART_irq_tx(),
\r
201 specifying the block of data to transmit. Your application is then free to
\r
202 perform other tasks and inquire later whether transmit has completed by
\r
203 calling the MSS_UART_tx_complete() function. The MSS_UART_irq_tx() function
\r
204 enables the UART
\92s transmit holding register empty (THRE) interrupt and then,
\r
205 when the interrupt goes active, the driver
\92s default THRE interrupt handler
\r
206 transfers the data block to the UART until the entire block is transmitted.
\r
207 Note: You can use the MSS_UART_set_tx_handler() function to assign an
\r
208 alternative handler to the THRE interrupt. In this case, you must not
\r
209 use the MSS_UART_irq_tx() function to initiate the transmit, as this
\r
210 will re-assign the driver
\92s default THRE interrupt handler to the THRE
\r
211 interrupt. Instead, your alternative THRE interrupt handler must include
\r
212 a call to the MSS_UART_fill_tx_fifo() function to transfer the data to
\r
216 Interrupt-driven receive is performed by first calling
\r
217 MSS_UART_set_rx_handler() to register a receive handler function that will be
\r
218 called by the driver whenever receive data is available. You must provide this
\r
219 receive handler function which must include a call to the MSS_UART_get_rx()
\r
220 function to actually read the received data.
\r
225 The function MSS_UART_get_rx_status() is used to read the receiver error
\r
226 status. This function returns the overrun, parity, framing, break, and FIFO
\r
227 error status of the receiver.
\r
228 The function MSS_UART_get_tx_status() is used to read the transmitter status.
\r
229 This function returns the transmit empty (TEMT) and transmit holding register
\r
230 empty (THRE) status of the transmitter.
\r
231 The function MSS_UART_get_modem_status() is used to read the modem status
\r
232 flags. This function returns the current value of the modem status register.
\r
237 The MSS_UART_set_loopback() function can be used to locally loopback the Tx
\r
238 and Rx lines of a UART. This is not to be confused with the loopback of UART0
\r
239 to UART1, which can be achieved through the microcontroller subsystem
\92s system
\r
242 *//*=========================================================================*/
\r
243 #ifndef __MSS_UART_H_
\r
244 #define __MSS_UART_H_ 1
\r
246 #include "../../CMSIS/m2sxxx.h"
\r
247 #include <stddef.h>
\r
253 /***************************************************************************//**
\r
255 The following definitions are used to specify standard baud rates as a
\r
256 parameter to the MSS_UART_init() function.
\r
258 #define MSS_UART_110_BAUD 110
\r
259 #define MSS_UART_300_BAUD 300
\r
260 #define MSS_UART_1200_BAUD 1200
\r
261 #define MSS_UART_2400_BAUD 2400
\r
262 #define MSS_UART_4800_BAUD 4800
\r
263 #define MSS_UART_9600_BAUD 9600
\r
264 #define MSS_UART_19200_BAUD 19200
\r
265 #define MSS_UART_38400_BAUD 38400
\r
266 #define MSS_UART_57600_BAUD 57600
\r
267 #define MSS_UART_115200_BAUD 115200
\r
268 #define MSS_UART_230400_BAUD 230400
\r
269 #define MSS_UART_460800_BAUD 460800
\r
270 #define MSS_UART_921600_BAUD 921600
\r
272 /***************************************************************************//**
\r
274 The following defines are used to build the value of the MSS_UART_init()
\r
275 function line_config parameter.
\r
277 #define MSS_UART_DATA_5_BITS ( (uint8_t) 0x00 )
\r
278 #define MSS_UART_DATA_6_BITS ( (uint8_t) 0x01 )
\r
279 #define MSS_UART_DATA_7_BITS ( (uint8_t) 0x02 )
\r
280 #define MSS_UART_DATA_8_BITS ( (uint8_t) 0x03 )
\r
282 /***************************************************************************//**
\r
284 The following defines are used to build the value of the MSS_UART_init()
\r
285 function line_config parameter.
\r
287 #define MSS_UART_NO_PARITY ( (uint8_t) 0x00 )
\r
288 #define MSS_UART_ODD_PARITY ( (uint8_t) 0x08 )
\r
289 #define MSS_UART_EVEN_PARITY ( (uint8_t) 0x18 )
\r
290 #define MSS_UART_STICK_PARITY_0 ( (uint8_t) 0x38 )
\r
291 #define MSS_UART_STICK_PARITY_1 ( (uint8_t) 0x28 )
\r
293 /***************************************************************************//**
\r
294 Number of Stop Bits
\r
295 The following defines are used to build the value of the MSS_UART_init()
\r
296 function line_config parameter.
\r
298 #define MSS_UART_ONE_STOP_BIT ( (uint8_t) 0x00 )
\r
299 #define MSS_UART_ONEHALF_STOP_BIT ( (uint8_t) 0x04 )
\r
300 #define MSS_UART_TWO_STOP_BITS ( (uint8_t) 0x04 )
\r
302 /***************************************************************************//**
\r
303 Receiver Error Status
\r
304 The following defines are used to determine the UART receiver error type.
\r
305 These bit mask constants are used with the return value of the
\r
306 MSS_UART_get_rx_status() function to find out if any errors occurred while
\r
309 #define MSS_UART_INVALID_PARAM ( (uint8_t)0xFF )
\r
310 #define MSS_UART_NO_ERROR ( (uint8_t)0x00 )
\r
311 #define MSS_UART_OVERUN_ERROR ( (uint8_t)0x02 )
\r
312 #define MSS_UART_PARITY_ERROR ( (uint8_t)0x04 )
\r
313 #define MSS_UART_FRAMING_ERROR ( (uint8_t)0x08 )
\r
314 #define MSS_UART_BREAK_ERROR ( (uint8_t)0x10 )
\r
315 #define MSS_UART_FIFO_ERROR ( (uint8_t)0x80 )
\r
317 /***************************************************************************//**
\r
319 The following definitions are used to determine the UART transmitter status.
\r
320 These bit mask constants are used with the return value of the
\r
321 MSS_UART_get_tx_status() function to find out the status of the transmitter.
\r
323 #define MSS_UART_TX_BUSY ( (uint8_t) 0x00 )
\r
324 #define MSS_UART_THRE ( (uint8_t) 0x20 )
\r
325 #define MSS_UART_TEMT ( (uint8_t) 0x40 )
\r
327 /***************************************************************************//**
\r
329 The following defines are used to determine the modem status. These bit
\r
330 mask constants are used with the return value of the
\r
331 MSS_UART_get_modem_status() function to find out the modem status of
\r
334 #define MSS_UART_DCTS ( (uint8_t) 0x01 )
\r
335 #define MSS_UART_DDSR ( (uint8_t) 0x02 )
\r
336 #define MSS_UART_TERI ( (uint8_t) 0x04 )
\r
337 #define MSS_UART_DDCD ( (uint8_t) 0x08 )
\r
338 #define MSS_UART_CTS ( (uint8_t) 0x10 )
\r
339 #define MSS_UART_DSR ( (uint8_t) 0x20 )
\r
340 #define MSS_UART_RI ( (uint8_t) 0x40 )
\r
341 #define MSS_UART_DCD ( (uint8_t) 0x80 )
\r
343 /***************************************************************************//**
\r
344 This typedef specifies the irq_mask parameter for the MSS_UART_enable_irq()
\r
345 and MSS_UART_disable_irq() functions. The driver defines a set of bit masks
\r
346 that are used to build the value of the irq_mask parameter. A bitwise OR of
\r
347 these bit masks is used to enable or disable multiple MSS MMUART interrupts.
\r
349 typedef uint16_t mss_uart_irq_t;
\r
351 /***************************************************************************//**
\r
352 The following defines specify the interrupt masks to enable and disable MSS
\r
353 MMUART interrupts. They are used to build the value of the irq_mask parameter
\r
354 for the MSS_UART_enable_irq() and MSS_UART_disable_irq() functions. A bitwise
\r
355 OR of these constants is used to enable or disable multiple interrupts.
\r
357 #define MSS_UART_RBF_IRQ 0x001
\r
358 #define MSS_UART_TBE_IRQ 0x002
\r
359 #define MSS_UART_LS_IRQ 0x004
\r
360 #define MSS_UART_MS_IRQ 0x008
\r
361 #define MSS_UART_RTO_IRQ 0x010
\r
362 #define MSS_UART_NACK_IRQ 0x020
\r
363 #define MSS_UART_PIDPE_IRQ 0x040
\r
364 #define MSS_UART_LINB_IRQ 0x080
\r
365 #define MSS_UART_LINS_IRQ 0x100
\r
366 #define MSS_UART_INVALID_IRQ UINT16_MAX
\r
368 /***************************************************************************//**
\r
369 This enumeration specifies the receiver FIFO trigger level. This is the number
\r
370 of bytes that must be received before the UART generates a receive data
\r
371 available interrupt. It provides the allowed values for the
\r
372 MSS_UART_set_rx_handler() function trigger_level parameter.
\r
375 MSS_UART_FIFO_SINGLE_BYTE = 0x00,
\r
376 MSS_UART_FIFO_FOUR_BYTES = 0x40,
\r
377 MSS_UART_FIFO_EIGHT_BYTES = 0x80,
\r
378 MSS_UART_FIFO_FOURTEEN_BYTES = 0xC0,
\r
379 MSS_UART_FIFO_INVALID_TRIG_LEVEL
\r
380 } mss_uart_rx_trig_level_t;
\r
382 /***************************************************************************//**
\r
383 This enumeration specifies the loopback configuration of the UART. It provides
\r
384 the allowed values for the MSS_UART_set_loopback() function
\92s loopback
\r
385 parameter. Use MSS_UART_LOCAL_LOOPBACK_ON to set up the UART to locally
\r
386 loopback its Tx and Rx lines. Use MSS_UART_REMOTE_LOOPBACK_ON to set up the
\r
387 UART in remote loopback mode.
\r
390 MSS_UART_LOCAL_LOOPBACK_OFF,
\r
391 MSS_UART_LOCAL_LOOPBACK_ON,
\r
392 MSS_UART_REMOTE_LOOPBACK_OFF,
\r
393 MSS_UART_REMOTE_LOOPBACK_ON,
\r
394 MSS_UART_AUTO_ECHO_OFF,
\r
395 MSS_UART_AUTO_ECHO_ON,
\r
396 MSS_UART_INVALID_LOOPBACK
\r
397 } mss_uart_loopback_t;
\r
399 /***************************************************************************//**
\r
400 IrDA input / output polarity.
\r
401 This enumeration specifies the RZI modem polarity for input and output signals.
\r
402 This is passed as parameters in MSS_UART_irda_init() function.
\r
405 MSS_UART_ACTIVE_LOW = 0u,
\r
406 MSS_UART_ACTIVE_HIGH = 1u,
\r
407 MSS_UART_INVALID_POLARITY
\r
408 } mss_uart_rzi_polarity_t;
\r
410 /***************************************************************************//**
\r
411 IrDA input / output pulse width.
\r
412 This enumeration specifies the RZI modem pulse width for input and output signals.
\r
413 This is passed as parameters in MSS_UART_irda_init() function.
\r
416 MSS_UART_3_BY_16 = 0u,
\r
417 MSS_UART_1_BY_4 = 1u,
\r
418 MSS_UART_INVALID_PW
\r
419 } mss_uart_rzi_pulsewidth_t;
\r
421 /***************************************************************************//**
\r
423 This enumeration specifies the MSB first or LSB first for MSS UART transmitter
\r
424 and receiver. The parameter of this type shall be passed in
\r
425 MSS_UART_set_rx_endian()and MSS_UART_set_tx_endian() functions.
\r
428 MSS_UART_LITTLEEND,
\r
430 MSS_UART_INVALID_ENDIAN
\r
431 } mss_uart_endian_t;
\r
433 /***************************************************************************//**
\r
434 Glitch filter length.
\r
435 This enumeration specifies the glitch filter length. The function
\r
436 MSS_UART_set_filter_length() accepts the parameter of this type.
\r
447 MSS_UART_INVALID_FILTER_LENGTH = 8
\r
448 } mss_uart_filter_length_t;
\r
450 /***************************************************************************//**
\r
451 TXRDY and RXRDY mode.
\r
452 This enumeration specifies the TXRDY and RXRDY signal modes. The function
\r
453 MSS_UART_set_ready_mode() accepts the parameter of this type.
\r
456 MSS_UART_READY_MODE0,
\r
457 MSS_UART_READY_MODE1,
\r
458 MSS_UART_INVALID_READY_MODE
\r
459 } mss_uart_ready_mode_t;
\r
461 /***************************************************************************//**
\r
462 USART mode of operation.
\r
463 This enumeration specifies the mode of operation of MSS UART when operating
\r
464 as USART. The function MSS_UART_set_usart_mode() accepts the parameter of this type.
\r
467 MSS_UART_ASYNC_MODE = 0,
\r
468 MSS_UART_SYNC_SLAVE_POS_EDGE_CLK = 1,
\r
469 MSS_UART_SYNC_SLAVE_NEG_EDGE_CLK = 2,
\r
470 MSS_UART_SYNC_MASTER_POS_EDGE_CLK = 3,
\r
471 MSS_UART_SYNC_MASTER_NEG_EDGE_CLK = 4,
\r
472 MSS_UART_INVALID_SYNC_MODE = 5
\r
473 } mss_uart_usart_mode_t;
\r
476 /***************************************************************************//**
\r
477 MSS UART instance type.
\r
478 This is type definition for MSS UART instance. You need to create and
\r
479 maintain a record of this type. This holds all data regarding the MSS UART
\r
482 typedef struct mss_uart_instance mss_uart_instance_t;
\r
484 /***************************************************************************//**
\r
485 Interrupt handler prototype.
\r
486 This typedef specifies the function prototype for MSS UART interrupt handlers.
\r
487 All interrupt handlers registered with the MSS UART driver must be of this type.
\r
488 The interrupt handlers are registered with the driver through the
\r
489 MSS_UART_set_rx_handler(), MSS_UART_set_tx_handler(),
\r
490 MSS_UART_set_rxstatus_handler(), and MSS_UART_set_modemstatus_handler()
\r
492 The this_uart parameter is a pointer to either g_mss_uart0 or g_mss_uart1 to
\r
493 identify the MSS UART to associate with the handler function.
\r
495 typedef void (*mss_uart_irq_handler_t)( mss_uart_instance_t * this_uart );
\r
497 /***************************************************************************//**
\r
499 There is one instance of this structure for each instance of the
\r
500 microcontroller subsystem
\92s UARTs. Instances of this structure are used to
\r
501 identify a specific UART. A pointer to an initialized instance of the
\r
502 mss_uart_instance_t structure is passed as the first parameter to
\r
503 MSS UART driver functions to identify which UART should perform the
\r
504 requested operation.
\r
506 struct mss_uart_instance{
\r
507 /* CMSIS related defines identifying the UART hardware. */
\r
508 UART_TypeDef * hw_reg; /*!< Pointer to UART registers. */
\r
509 IRQn_Type irqn; /*!< UART's Cortex-M3 NVIC interrupt number. */
\r
510 uint32_t baudrate; /*!< Operating baud rate. */
\r
511 uint8_t lineconfig; /*!< Line configuration parameters. */
\r
512 uint8_t status; /*!< Sticky line status. */
\r
514 /* transmit related info (used with interrupt driven transmit): */
\r
515 const uint8_t * tx_buffer; /*!< Pointer to transmit buffer. */
\r
516 uint32_t tx_buff_size; /*!< Transmit buffer size. */
\r
517 uint32_t tx_idx; /*!< Index within transmit buffer of next byte to transmit.*/
\r
519 /* line status interrupt handler:*/
\r
520 mss_uart_irq_handler_t linests_handler; /*!< Pointer to user registered line status handler. */
\r
521 /* receive interrupt handler:*/
\r
522 mss_uart_irq_handler_t rx_handler; /*!< Pointer to user registered receiver handler. */
\r
523 /* transmit interrupt handler:*/
\r
524 mss_uart_irq_handler_t tx_handler; /*!< Pointer to user registered transmit handler. */
\r
525 /* modem status interrupt handler:*/
\r
526 mss_uart_irq_handler_t modemsts_handler; /*!< Pointer to user registered modem status handler. */
\r
527 /* receiver timeout interrupt handler */
\r
528 mss_uart_irq_handler_t rto_handler; /*!< Pointer to user registered receiver timeout handler. */
\r
529 /* NACK interrupt handler */
\r
530 mss_uart_irq_handler_t nack_handler; /*!< Pointer to user registered NACK handler. */
\r
531 /* PID parity prror interrup handler */
\r
532 mss_uart_irq_handler_t pid_pei_handler; /*!< Pointer to user registered PID parity error handler. */
\r
533 /* LIN break interrupt handler */
\r
534 mss_uart_irq_handler_t break_handler; /*!< Pointer to user registered LIN break handler. */
\r
535 /* LIN sync detection interrupt handler */
\r
536 mss_uart_irq_handler_t sync_handler; /*!< Pointer to user registered LIN sync dectection handler. */
\r
539 /***************************************************************************//**
\r
540 This instance of mss_uart_instance_t holds all data related to the operations
\r
541 performed by UART0. The function MSS_UART_init() initializes this structure.
\r
542 A pointer to g_mss_uart0 is passed as the first parameter to MSS UART driver
\r
543 functions to indicate that UART0 should perform the requested operation.
\r
545 extern mss_uart_instance_t g_mss_uart0;
\r
547 /***************************************************************************//**
\r
548 This instance of mss_uart_instance_t holds all data related to the operations
\r
549 performed by UART1. The function MSS_UART_init() initializes this structure.
\r
550 A pointer to g_mss_uart1 is passed as the first parameter to MSS UART driver
\r
551 functions to indicate that UART1 should perform the requested operation.
\r
553 extern mss_uart_instance_t g_mss_uart1;
\r
555 /***************************************************************************//**
\r
556 The MSS_UART_init() function initializes and configures one of the SmartFusion2
\r
557 MSS UARTs with the configuration passed as a parameter. The configuration
\r
558 parameters are the baud_rate which is used to generate the baud value and the
\r
559 line_config which is used to specify the line configuration (bit length,
\r
560 stop bits and parity).
\r
563 The this_uart parameter is a pointer to an mss_uart_instance_t structure
\r
564 identifying the MSS UART hardware block to be initialized. There are two
\r
565 such data structures, g_mss_uart0 and g_mss_uart1, associated with MSS
\r
566 UART0 and MSS UART1 respectively. This parameter must point to either
\r
567 the g_mss_uart0 or g_mss_uart1 global data structure defined within
\r
571 The baud_rate parameter specifies the baud rate. It can be specified for
\r
572 common baud rates
\92 using the following defines:
\r
573 \95 MSS_UART_110_BAUD
\r
574 \95 MSS_UART_300_BAUD
\r
575 \95 MSS_UART_1200_BAUD
\r
576 \95 MSS_UART_2400_BAUD
\r
577 \95 MSS_UART_4800_BAUD
\r
578 \95 MSS_UART_9600_BAUD
\r
579 \95 MSS_UART_19200_BAUD
\r
580 \95 MSS_UART_38400_BAUD
\r
581 \95 MSS_UART_57600_BAUD
\r
582 \95 MSS_UART_115200_BAUD
\r
583 \95 MSS_UART_230400_BAUD
\r
584 \95 MSS_UART_460800_BAUD
\r
585 \95 MSS_UART_921600_BAUD
\r
586 Alternatively, any nonstandard baud rate can be specified by simply passing
\r
587 the actual required baud rate as the value for this parameter.
\r
590 The line_config parameter is the line configuration specifying the bit length,
\r
591 number of stop bits and parity settings. This is a bitwise OR of one value
\r
592 from each of the following groups of allowed values:
\r
593 \95 One of the following to specify the transmit/receive data bit length:
\r
594 MSS_UART_DATA_5_BITS
\r
595 MSS_UART_DATA_6_BITS,
\r
596 MSS_UART_DATA_7_BITS
\r
597 MSS_UART_DATA_8_BITS
\r
598 \95 One of the following to specify the parity setting:
\r
600 MSS_UART_EVEN_PARITY
\r
601 MSS_UART_ODD_PARITY
\r
602 MSS_UART_STICK_PARITY_0
\r
603 MSS_UART_STICK_PARITY_1
\r
604 \95 One of the following to specify the number of stop bits:
\r
605 MSS_UART_ONE_STOP_BIT
\r
606 MSS_UART_ONEHALF_STOP_BIT
\r
607 MSS_UART_TWO_STOP_BITS
\r
610 This function does not return a value.
\r
614 #include "mss_uart.h"
\r
618 MSS_UART_init(&g_mss_uart0,
\r
619 MSS_UART_57600_BAUD,
\r
620 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
629 mss_uart_instance_t* this_uart,
\r
630 uint32_t baud_rate,
\r
631 uint8_t line_config
\r
634 /***************************************************************************//**
\r
635 The MSS_UART_lin_init() function is used to initialize the MSS UART for
\r
636 LIN mode of operation. The configuration parameters are the baud_rate which is
\r
637 used to generate the baud value and the line_config which is used to specify
\r
638 the line configuration (bit length, stop bits and parity).
\r
641 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
642 structure identifying the MSS UART hardware block that will perform
\r
643 the requested function. There are two such data structures,
\r
644 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
645 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
646 global data structure defined within the UART driver.
\r
649 The baud_rate parameter specifies the baud rate. It can be specified for
\r
650 common baud rates
\92 using the following defines:
\r
651 \95 MSS_UART_110_BAUD
\r
652 \95 MSS_UART_300_BAUD
\r
653 \95 MSS_UART_1200_BAUD
\r
654 \95 MSS_UART_2400_BAUD
\r
655 \95 MSS_UART_4800_BAUD
\r
656 \95 MSS_UART_9600_BAUD
\r
657 \95 MSS_UART_19200_BAUD
\r
658 \95 MSS_UART_38400_BAUD
\r
659 \95 MSS_UART_57600_BAUD
\r
660 \95 MSS_UART_115200_BAUD
\r
661 \95 MSS_UART_230400_BAUD
\r
662 \95 MSS_UART_460800_BAUD
\r
663 \95 MSS_UART_921600_BAUD
\r
664 Alternatively, any nonstandard baud rate can be specified by simply passing
\r
665 the actual required baud rate as the value for this parameter.
\r
668 The line_config parameter is the line configuration specifying the bit length,
\r
669 number of stop bits and parity settings. This is a bitwise OR of one value
\r
670 from each of the following groups of allowed values:
\r
671 \95 One of the following to specify the transmit/receive data bit length:
\r
672 MSS_UART_DATA_5_BITS
\r
673 MSS_UART_DATA_6_BITS,
\r
674 MSS_UART_DATA_7_BITS
\r
675 MSS_UART_DATA_8_BITS
\r
676 \95 One of the following to specify the parity setting:
\r
678 MSS_UART_EVEN_PARITY
\r
679 MSS_UART_ODD_PARITY
\r
680 MSS_UART_STICK_PARITY_0
\r
681 MSS_UART_STICK_PARITY_1
\r
682 \95 One of the following to specify the number of stop bits:
\r
683 MSS_UART_ONE_STOP_BIT
\r
684 MSS_UART_ONEHALF_STOP_BIT
\r
685 MSS_UART_TWO_STOP_BITS
\r
688 This function does not return a value.
\r
692 #include "mss_uart.h"
\r
696 MSS_UART_lin_init(&g_mss_uart0,
\r
697 MSS_UART_57600_BAUD,
\r
698 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
707 mss_uart_instance_t* this_uart,
\r
708 uint32_t baud_rate,
\r
709 uint8_t line_config
\r
712 /***************************************************************************//**
\r
713 The MSS_UART_irda_init() function is used to initialize the MSS UART instance
\r
714 referenced by the parameter this_uart for IrDA mode of operation. This
\r
715 function must be called before calling any other IrDA functionality specific
\r
719 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
720 structure identifying the MSS UART hardware block that will perform
\r
721 the requested function. There are two such data structures,
\r
722 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
723 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
724 global data structure defined within the UART driver.
\r
727 The baud_rate parameter specifies the baud rate. It can be specified for
\r
728 common baud rates
\92 using the following defines:
\r
729 \95 MSS_UART_110_BAUD
\r
730 \95 MSS_UART_300_BAUD
\r
731 \95 MSS_UART_1200_BAUD
\r
732 \95 MSS_UART_2400_BAUD
\r
733 \95 MSS_UART_4800_BAUD
\r
734 \95 MSS_UART_9600_BAUD
\r
735 \95 MSS_UART_19200_BAUD
\r
736 \95 MSS_UART_38400_BAUD
\r
737 \95 MSS_UART_57600_BAUD
\r
738 \95 MSS_UART_115200_BAUD
\r
739 \95 MSS_UART_230400_BAUD
\r
740 \95 MSS_UART_460800_BAUD
\r
741 \95 MSS_UART_921600_BAUD
\r
742 Alternatively, any nonstandard baud rate can be specified by simply passing
\r
743 the actual required baud rate as the value for this parameter.
\r
746 The line_config parameter is the line configuration specifying the bit length,
\r
747 number of stop bits and parity settings. This is a bitwise OR of one value
\r
748 from each of the following groups of allowed values:
\r
749 \95 One of the following to specify the transmit/receive data bit length:
\r
750 MSS_UART_DATA_5_BITS
\r
751 MSS_UART_DATA_6_BITS,
\r
752 MSS_UART_DATA_7_BITS
\r
753 MSS_UART_DATA_8_BITS
\r
754 \95 One of the following to specify the parity setting:
\r
756 MSS_UART_EVEN_PARITY
\r
757 MSS_UART_ODD_PARITY
\r
758 MSS_UART_STICK_PARITY_0
\r
759 MSS_UART_STICK_PARITY_1
\r
760 \95 One of the following to specify the number of stop bits:
\r
761 MSS_UART_ONE_STOP_BIT
\r
762 MSS_UART_ONEHALF_STOP_BIT
\r
763 MSS_UART_TWO_STOP_BITS
\r
766 This function does not return a value.
\r
770 MSS_UART_irda_init(&g_mss_uart0,
\r
771 MSS_UART_57600_BAUD,
\r
772 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT,
\r
773 MSS_UART_ACTIVE_LOW,
\r
774 MSS_UART_ACTIVE_LOW,
\r
781 mss_uart_instance_t* this_uart,
\r
782 uint32_t baud_rate,
\r
783 uint8_t line_config,
\r
784 mss_uart_rzi_polarity_t rxpol,
\r
785 mss_uart_rzi_polarity_t txpol,
\r
786 mss_uart_rzi_pulsewidth_t pw
\r
789 /***************************************************************************//**
\r
790 The MSS_UART_smartcard_init() function is used to initialize the MSS UART
\r
791 for ISO 7816 (smartcard) mode of operation. The configuration parameters are
\r
792 the baud_rate which is used to generate the baud value and the line_config
\r
793 which is used to specify the line configuration (bit length, stop bits and parity).
\r
794 This function disables all other modes of the MSS UART instance pointed by
\r
795 the parameter this_uart.
\r
798 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
799 structure identifying the MSS UART hardware block that will perform
\r
800 the requested function. There are two such data structures,
\r
801 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
802 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
803 global data structure defined within the UART driver.
\r
806 The baud_rate parameter specifies the baud rate. It can be specified for
\r
807 common baud rates
\92 using the following defines:
\r
808 \95 MSS_UART_110_BAUD
\r
809 \95 MSS_UART_300_BAUD
\r
810 \95 MSS_UART_1200_BAUD
\r
811 \95 MSS_UART_2400_BAUD
\r
812 \95 MSS_UART_4800_BAUD
\r
813 \95 MSS_UART_9600_BAUD
\r
814 \95 MSS_UART_19200_BAUD
\r
815 \95 MSS_UART_38400_BAUD
\r
816 \95 MSS_UART_57600_BAUD
\r
817 \95 MSS_UART_115200_BAUD
\r
818 \95 MSS_UART_230400_BAUD
\r
819 \95 MSS_UART_460800_BAUD
\r
820 \95 MSS_UART_921600_BAUD
\r
821 Alternatively, any nonstandard baud rate can be specified by simply passing
\r
822 the actual required baud rate as the value for this parameter.
\r
825 The line_config parameter is the line configuration specifying the bit length,
\r
826 number of stop bits and parity settings. This is a bitwise OR of one value
\r
827 from each of the following groups of allowed values:
\r
828 \95 One of the following to specify the transmit/receive data bit length:
\r
829 MSS_UART_DATA_5_BITS
\r
830 MSS_UART_DATA_6_BITS,
\r
831 MSS_UART_DATA_7_BITS
\r
832 MSS_UART_DATA_8_BITS
\r
833 \95 One of the following to specify the parity setting:
\r
835 MSS_UART_EVEN_PARITY
\r
836 MSS_UART_ODD_PARITY
\r
837 MSS_UART_STICK_PARITY_0
\r
838 MSS_UART_STICK_PARITY_1
\r
839 \95 One of the following to specify the number of stop bits:
\r
840 MSS_UART_ONE_STOP_BIT
\r
841 MSS_UART_ONEHALF_STOP_BIT
\r
842 MSS_UART_TWO_STOP_BITS
\r
845 This function does not return a value.
\r
849 #include "mss_uart.h"
\r
853 MSS_UART_smartcard_init(&g_mss_uart0,
\r
854 MSS_UART_57600_BAUD,
\r
855 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
862 MSS_UART_smartcard_init
\r
864 mss_uart_instance_t* this_uart,
\r
865 uint32_t baud_rate,
\r
866 uint8_t line_config
\r
869 /***************************************************************************//**
\r
870 The function MSS_UART_polled_tx() is used to transmit data. It transfers the
\r
871 contents of the transmitter data buffer, passed as a function parameter, into
\r
872 the UART
\92s hardware transmitter FIFO. It returns when the full content of the
\r
873 transmit data buffer has been transferred to the UART
\92s transmit FIFO. It is
\r
874 safe to release or reuse the memory used as the transmitter data buffer once
\r
875 this function returns.
\r
877 Note: This function reads the UART
\92s line status register (LSR) to poll
\r
878 for the active state of the transmitter holding register empty (THRE) bit
\r
879 before transferring data from the data buffer to the transmitter FIFO. It
\r
880 transfers data to the transmitter FIFO in blocks of 16 bytes or less and
\r
881 allows the FIFO to empty before transferring the next block of data.
\r
883 Note: The actual transmission over the serial connection will still be
\r
884 in progress when this function returns. Use the MSS_UART_get_tx_status()
\r
885 function if you need to know when the transmitter is empty.
\r
888 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
889 structure identifying the MSS UART hardware block that will perform
\r
890 the requested function. There are two such data structures,
\r
891 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
892 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
893 global data structure defined within the UART driver.
\r
896 The pbuff parameter is a pointer to a buffer containing the data to
\r
900 The tx_size parameter specifies the size, in bytes, of the data to
\r
904 This function does not return a value.
\r
908 #include "mss_uart.h"
\r
912 uint8_t message[12] = "Hello World";
\r
914 MSS_UART_init(&g_mss_uart0,
\r
915 MSS_UART_57600_BAUD,
\r
916 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
918 MSS_UART_polled_tx(&g_mss_uart0, message, sizeof(message));
\r
927 mss_uart_instance_t * this_uart,
\r
928 const uint8_t * pbuff,
\r
932 /***************************************************************************//**
\r
933 The function MSS_UART_polled_tx_string() is used to transmit a NULL ('\0')
\r
934 terminated string. It transfers the text string, from the buffer starting at
\r
935 the address pointed to by p_sz_string into the UART
\92s hardware transmitter
\r
936 FIFO. It returns when the complete string has been transferred to the UART's
\r
937 transmit FIFO. It is safe to release or reuse the memory used as the string
\r
938 buffer once this function returns.
\r
940 Note: This function reads the UART
\92s line status register (LSR) to poll
\r
941 for the active state of the transmitter holding register empty (THRE) bit
\r
942 before transferring data from the data buffer to the transmitter FIFO. It
\r
943 transfers data to the transmitter FIFO in blocks of 16 bytes or less and
\r
944 allows the FIFO to empty before transferring the next block of data.
\r
946 Note: The actual transmission over the serial connection will still be
\r
947 in progress when this function returns. Use the MSS_UART_get_tx_status()
\r
948 function if you need to know when the transmitter is empty.
\r
951 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
952 structure identifying the MSS UART hardware block that will perform
\r
953 the requested function. There are two such data structures,
\r
954 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
955 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
956 global data structure defined within the UART driver.
\r
959 The p_sz_string parameter is a pointer to a buffer containing the NULL
\r
960 ('\0') terminated string to be transmitted.
\r
963 This function does not return a value.
\r
967 #include "mss_uart.h"
\r
971 uint8_t message[12] = "Hello World";
\r
973 MSS_UART_init(&g_mss_uart0,
\r
974 MSS_UART_57600_BAUD,
\r
975 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
977 MSS_UART_polled_tx_string(&g_mss_uart0, message);
\r
985 MSS_UART_polled_tx_string
\r
987 mss_uart_instance_t * this_uart,
\r
988 const uint8_t * p_sz_string
\r
992 /***************************************************************************//**
\r
993 The function MSS_UART_irq_tx() is used to initiate an interrupt-driven
\r
994 transmit. It returns immediately after making a note of the transmit buffer
\r
995 location and enabling transmit interrupts both at the UART and Cortex-M3 NVIC
\r
996 level. This function takes a pointer via the pbuff parameter to a memory
\r
997 buffer containing the data to transmit. The memory buffer specified through
\r
998 this pointer must remain allocated and contain the data to transmit until
\r
999 the transmit completion has been detected through calls to function
\r
1000 MSS_UART_tx_complete(). The actual transmission over the serial connection
\r
1001 is still in progress until calls to the MSS_UART_tx_complete() function
\r
1002 indicate transmit completion.
\r
1004 Note: The MSS_UART_irq_tx() function enables both the transmit holding
\r
1005 register empty (THRE) interrupt in the UART and the MSS UART instance
\r
1006 interrupt in the Cortex-M3 NVIC as part of its implementation.
\r
1008 Note: The MSS_UART_irq_tx() function assigns an internal default transmit
\r
1009 interrupt handler function to the UART
\92s THRE interrupt. This interrupt
\r
1010 handler overrides any custom interrupt handler that you may have previously
\r
1011 registered using the MSS_UART_set_tx_handler() function.
\r
1013 Note: The MSS_UART_irq_tx() function
\92s default transmit interrupt
\r
1014 handler disables the UART
\92s THRE interrupt when all of the data has
\r
1015 been transferred to the UART's transmit FIFO.
\r
1019 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1020 structure identifying the MSS UART hardware block that will perform
\r
1021 the requested function. There are two such data structures,
\r
1022 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1023 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1024 global data structure defined within the UART driver.
\r
1027 The pbuff parameter is a pointer to a buffer containing the data
\r
1028 to be transmitted.
\r
1031 The tx_size parameter specifies the size, in bytes, of the data
\r
1032 to be transmitted.
\r
1035 This function does not return a value.
\r
1039 #include "mss_uart.h"
\r
1043 uint8_t tx_buff[10] = "abcdefghi";
\r
1045 MSS_UART_init(&g_mss_uart0,
\r
1046 MSS_UART_57600_BAUD,
\r
1047 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
1049 MSS_UART_irq_tx(&g_mss_uart0, tx_buff, sizeof(tx_buff));
\r
1051 while(0 == MSS_UART_tx_complete(&g_mss_uart0))
\r
1062 mss_uart_instance_t * this_uart,
\r
1063 const uint8_t * pbuff,
\r
1067 /***************************************************************************//**
\r
1068 The MSS_UART_tx_complete() function is used to find out if the interrupt-driven
\r
1069 transmit previously initiated through a call to MSS_UART_irq_tx() is complete.
\r
1070 This is typically used to find out when it is safe to reuse or release the
\r
1071 memory buffer holding transmit data.
\r
1073 Note: The transfer of all of the data from the memory buffer to the UART
\92s
\r
1074 transmit FIFO and the actual transmission over the serial connection are both
\r
1075 complete when a call to the MSS_UART_tx_complete() function indicates transmit
\r
1079 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1080 structure identifying the MSS UART hardware block that will perform
\r
1081 the requested function. There are two such data structures,
\r
1082 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1083 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1084 global data structure defined within the UART driver.
\r
1087 This function return a non-zero value if transmit has completed, otherwise
\r
1091 See the MSS_UART_irq_tx() function for an example that uses the
\r
1092 MSS_UART_tx_complete() function.
\r
1095 MSS_UART_tx_complete
\r
1097 mss_uart_instance_t * this_uart
\r
1100 /***************************************************************************//**
\r
1101 The MSS_UART_get_rx() function reads the content of the UART receiver
\92s FIFO
\r
1102 and stores it in the receive buffer that is passed via the rx_buff function
\r
1103 parameter. It copies either the full contents of the FIFO into the receive
\r
1104 buffer, or just enough data from the FIFO to fill the receive buffer,
\r
1105 dependent upon the size of the receive buffer passed by the buff_size
\r
1106 parameter. The MSS_UART_get_rx() function returns the number of bytes copied
\r
1107 into the receive buffer .This function is non-blocking and will return 0
\r
1108 immediately if no data has been received.
\r
1110 Note: The MSS_UART_get_rx() function reads and accumulates the receiver
\r
1111 status of the MSS UART instance before reading each byte from the receiver's
\r
1112 data register/FIFO. This allows the driver to maintain a sticky record of any
\r
1113 receiver errors that occur as the UART receives each data byte; receiver
\r
1114 errors would otherwise be lost after each read from the receiver's data register.
\r
1115 A call to the MSS_UART_get_rx_status() function returns any receiver errors
\r
1116 accumulated during the execution of the MSS_UART_get_rx() function.
\r
1118 Note: If you need to read the error status for each byte received, set
\r
1119 the buff_size to 1 and read the receive line error status for each byte
\r
1120 using the MSS_UART_get_rx_status() function.
\r
1121 The MSS_UART_get_rx() function can be used in polled mode, where it is called
\r
1122 at regular intervals to find out if any data has been received, or in interrupt
\r
1123 driven-mode, where it is called as part of a receive handler that is called
\r
1124 by the driver as a result of data being received.
\r
1126 Note: In interrupt driven mode you should call the MSS_UART_get_rx()
\r
1127 function as part of the receive handler function that you register with
\r
1128 the MSS UART driver through a call to MSS_UART_set_rx_handler().
\r
1131 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1132 structure identifying the MSS UART hardware block that will perform
\r
1133 the requested function. There are two such data structures,
\r
1134 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1135 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1136 global data structure defined within the UART driver.
\r
1139 The rx_buff parameter is a pointer to a buffer where the received
\r
1143 The buff_size parameter specifies the size of the receive buffer in bytes.
\r
1146 This function returns the number of bytes that were copied into the
\r
1147 rx_buff buffer. It returns 0 if no data has been received.
\r
1149 Polled mode example:
\r
1153 uint8_t rx_buff[RX_BUFF_SIZE];
\r
1154 uint32_t rx_idx = 0;
\r
1156 MSS_UART_init(&g_mss_uart0,
\r
1157 MSS_UART_57600_BAUD,
\r
1158 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
1162 rx_size = MSS_UART_get_rx(&g_mss_uart0, rx_buff, sizeof(rx_buff));
\r
1165 process_rx_data(rx_buff, rx_size);
\r
1174 Interrupt driven example:
\r
1178 MSS_UART_init(&g_mss_uart1,
\r
1179 MSS_UART_57600_BAUD,
\r
1180 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
1182 MSS_UART_set_rx_handler(&g_mss_uart1,
\r
1184 MSS_UART_FIFO_SINGLE_BYTE);
\r
1194 void uart1_rx_handler(mss_uart_instance_t * this_uart)
\r
1196 uint8_t rx_buff[RX_BUFF_SIZE];
\r
1197 uint32_t rx_idx = 0;
\r
1198 rx_size = MSS_UART_get_rx(this_uart, rx_buff, sizeof(rx_buff));
\r
1199 process_rx_data(rx_buff, rx_size);
\r
1206 mss_uart_instance_t * this_uart,
\r
1207 uint8_t * rx_buff,
\r
1211 /***************************************************************************//**
\r
1212 The MSS_UART_set_rx_handler() function is used to register a receive handler
\r
1213 function that is called by the driver when a UART receive data available (RDA)
\r
1214 interrupt occurs. You must create and register the receive handler function
\r
1215 to suit your application and it must include a call to the MSS_UART_get_rx()
\r
1216 function to actually read the received data.
\r
1218 Note: The MSS_UART_set_rx_handler() function enables both the RDA
\r
1219 interrupt in the UART and the MSS UART instance interrupt in the Cortex-M3
\r
1221 of its implementation.
\r
1223 Note: You can disable the RDA interrupt once the data is received by
\r
1224 calling the MSS_UART_disable_irq() function. This is your choice and is
\r
1225 dependent upon your application.
\r
1229 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1230 structure identifying the MSS UART hardware block that will perform
\r
1231 the requested function. There are two such data structures,
\r
1232 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1233 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1234 global data structure defined within the UART driver.
\r
1237 The handler parameter is a pointer to a receive interrupt handler function
\r
1238 provided by your application that will be called as a result of a UART RDA
\r
1239 interrupt. This handler function must be of type mss_uart_irq_handler_t.
\r
1241 @param trigger_level
\r
1242 The trigger_level parameter is the receive FIFO trigger level. This
\r
1243 specifies the number of bytes that must be received before the UART
\r
1244 triggers an RDA interrupt.
\r
1247 This function does not return a value.
\r
1251 #include "mss_uart.h"
\r
1253 #define RX_BUFF_SIZE 64
\r
1255 uint8_t g_rx_buff[RX_BUFF_SIZE];
\r
1257 void uart0_rx_handler(mss_uart_instance_t * this_uart)
\r
1259 MSS_UART_get_rx(this_uart, &g_rx_buff[g_rx_idx], sizeof(g_rx_buff));
\r
1264 MSS_UART_init(&g_mss_uart0,
\r
1265 MSS_UART_57600_BAUD,
\r
1266 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
1268 MSS_UART_set_rx_handler(&g_mss_uart0,
\r
1270 MSS_UART_FIFO_SINGLE_BYTE);
\r
1281 MSS_UART_set_rx_handler
\r
1283 mss_uart_instance_t * this_uart,
\r
1284 mss_uart_irq_handler_t handler,
\r
1285 mss_uart_rx_trig_level_t trigger_level
\r
1288 /***************************************************************************//**
\r
1289 The MSS_UART_set_loopback() function is used to locally loopback the Tx and
\r
1290 Rx lines of a UART. This is not to be confused with the loopback of UART0
\r
1291 to UART1, which can be achieved through the microcontroller subsystem
\92s
\r
1295 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1296 structure identifying the MSS UART hardware block that will perform
\r
1297 the requested function. There are two such data structures,
\r
1298 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1299 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1300 global data structure defined within the UART driver.
\r
1303 The loopback parameter indicates whether or not the UART
\92s transmit
\r
1304 and receive lines should be looped back. Allowed values are as follows:
\r
1305 - MSS_UART_LOCAL_LOOPBACK_ON
\r
1306 - MSS_UART_LOCAL_LOOPBACK_OFF
\r
1307 - MSS_UART_REMOTE_LOOPBACK_ON
\r
1308 - MSS_UART_REMOTE_LOOPBACK_OFF
\r
1309 - MSS_UART_AUTO_ECHO_ON
\r
1310 - MSS_UART_AUTO_ECHO_OFF
\r
1313 This function does not return a value.
\r
1317 MSS_UART_init(&g_mss_uart0,
\r
1318 MSS_UART_57600_BAUD,
\r
1319 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
1321 MSS_UART_set_loopback(&g_mss_uart0, MSS_UART_LOCAL_LOOPBACK_OFF);
\r
1325 MSS_UART_set_loopback
\r
1327 mss_uart_instance_t * this_uart,
\r
1328 mss_uart_loopback_t loopback
\r
1331 /***************************************************************************//**
\r
1332 The MSS_UART_enable_irq() function enables the MSS UART interrupts specified
\r
1333 by the irq_mask parameter. The irq_mask parameter identifies the MSS UART
\r
1334 interrupts by bit position, as defined in the interrupt enable register (IER)
\r
1335 of MSS UART. The MSS UART interrupts and their identifying irq_mask bit
\r
1336 positions are as follows:
\r
1337 When an irq_mask bit position is set to 1, this function enables the
\r
1338 corresponding MSS UART interrupt in the IER register. When an irq_mask bit
\r
1339 position is set to 0, the corresponding interrupt
\92s state remains unchanged in
\r
1341 Note: The MSS_UART_enable_irq() function also enables the MSS UART instance
\r
1342 interrupt in the Cortex-M3 NVIC.
\r
1345 The this_uart parameter is a pointer to an mss_uart_instance_t structure
\r
1346 identifying the MSS UART hardware block that will perform the requested
\r
1347 function. There are two such data structures, g_mss_uart0 and g_mss_uart1,
\r
1348 associated with MSS UART0 and MSS UART1. This parameter must point to either
\r
1349 the g_mss_uart0 or g_mss_uart1 global data structure defined within the UART
\r
1353 The irq_mask parameter is used to select which of the MSS UART
\92s interrupts
\r
1354 you want to enable. The allowed value for the irq_mask parameter is one of
\r
1355 the following constants or a bitwise OR of more than one:
\r
1356 - MSS_UART_RBF_IRQ (bit mask = 0x001)
\r
1357 - MSS_UART_TBE_IRQ (bit mask = 0x002)
\r
1358 - MSS_UART_LS_IRQ (bit mask = 0x004)
\r
1359 - MSS_UART_MS_IRQ (bit mask = 0x008)
\r
1360 - MSS_UART_RTO_IRQ (bit mask = 0x010)
\r
1361 - MSS_UART_NACK_IRQ (bit mask = 0x020)
\r
1362 - MSS_UART_PIDPE_IRQ (bit mask = 0x040)
\r
1363 - MSS_UART_LINB_IRQ (bit mask = 0x080)
\r
1364 - MSS_UART_LINS_IRQ (bit mask = 0x100)
\r
1367 This function does not return a value.
\r
1371 MSS_UART_enable_irq(&g_mss_uart0,(MSS_UART_RBF_IRQ | MSS_UART_TBE_IRQ));
\r
1375 MSS_UART_enable_irq
\r
1377 mss_uart_instance_t * this_uart,
\r
1378 mss_uart_irq_t irq_mask
\r
1381 /***************************************************************************//**
\r
1382 The MSS_UART_disable_irq() function disables the MSS UART interrupts specified
\r
1383 by the irq_mask parameter. The irq_mask parameter identifies the MSS UART
\r
1384 interrupts by bit position, as defined in the interrupt enable register (IER)
\r
1385 of MSS UART. The MSS UART interrupts and their identifying bit positions are
\r
1387 When an irq_mask bit position is set to 1, this function disables the
\r
1388 corresponding MSS UART interrupt in the IER register. When an irq_mask bit
\r
1389 position is set to 0, the corresponding interrupt
\92s state remains unchanged in
\r
1391 Note: If you disable all four of the UART
\92s interrupts, the
\r
1392 MSS_UART_disable_irq() function also disables the MSS UART instance
\r
1393 interrupt in the Cortex-M3 NVIC.
\r
1396 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1397 structure identifying the MSS UART hardware block that will perform
\r
1398 the requested function. There are two such data structures,
\r
1399 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1400 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1401 global data structure defined within the UART driver.
\r
1404 The irq_mask parameter is used to select which of the MSS UART
\92s interrupts
\r
1405 you want to disable. The allowed value for the irq_mask parameter is one of
\r
1406 the following constants or a bitwise OR of more than one:
\r
1407 - MSS_UART_RBF_IRQ (bit mask = 0x001)
\r
1408 - MSS_UART_TBE_IRQ (bit mask = 0x002)
\r
1409 - MSS_UART_LS_IRQ (bit mask = 0x004)
\r
1410 - MSS_UART_MS_IRQ (bit mask = 0x008)
\r
1411 - MSS_UART_RTO_IRQ (bit mask = 0x010)
\r
1412 - MSS_UART_NACK_IRQ (bit mask = 0x020)
\r
1413 - MSS_UART_PIDPE_IRQ (bit mask = 0x040)
\r
1414 - MSS_UART_LINB_IRQ (bit mask = 0x080)
\r
1415 - MSS_UART_LINS_IRQ (bit mask = 0x100)
\r
1418 This function does not return a value.
\r
1422 MSS_UART_disable_irq(&g_mss_uart0, (MSS_UART_RBF_IRQ | MSS_UART_TBE_IRQ));
\r
1426 MSS_UART_disable_irq
\r
1428 mss_uart_instance_t * this_uart,
\r
1429 mss_uart_irq_t irq_mask
\r
1432 /***************************************************************************//**
\r
1433 The MSS_UART_set_pidpei_handler() function is used assign a custom interrupt
\r
1434 handler for the PIDPEI (PID parity error interrupt) when the MSS UART is
\r
1435 operating in LIN mode.
\r
1438 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1439 structure identifying the MSS UART hardware block that will perform
\r
1440 the requested function. There are two such data structures,
\r
1441 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1442 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1443 global data structure defined within the UART driver.
\r
1446 The handler parameter is the pointer to the custom handler function.
\r
1447 This parameter is of type mss_uart_irq_handler_t.
\r
1450 This function does not return a value.
\r
1454 MSS_UART_ set_pidpei_handler(&g_mss_uart0, my_pidpei_handler);
\r
1458 MSS_UART_set_pidpei_handler
\r
1460 mss_uart_instance_t * this_uart,
\r
1461 mss_uart_irq_handler_t handler
\r
1464 /***************************************************************************//**
\r
1465 The MSS_UART_set_linbreak_handler () function is used assign a custom
\r
1466 interrupt handler for the LIN Break detection interrupt when the MSS UART
\r
1467 is operating in LIN mode.
\r
1470 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1471 structure identifying the MSS UART hardware block that will perform
\r
1472 the requested function. There are two such data structures,
\r
1473 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1474 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1475 global data structure defined within the UART driver.
\r
1478 The handler parameter is the pointer to the custom handler function.
\r
1479 This parameter is of type mss_uart_irq_handler_t.
\r
1482 This function does not return a value.
\r
1485 MSS_UART_set_linbreak_handler(&g_mss_uart0, my_break_handler);
\r
1489 MSS_UART_set_linbreak_handler
\r
1491 mss_uart_instance_t * this_uart,
\r
1492 mss_uart_irq_handler_t handler
\r
1495 /***************************************************************************//**
\r
1496 The MSS_UART_set_linsync_handler() function is used assign a custom interrupt
\r
1497 handler for the LIN Sync character detection interrupt when the MSS UART
\r
1498 is operating in LIN mode.
\r
1501 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1502 structure identifying the MSS UART hardware block that will perform
\r
1503 the requested function. There are two such data structures,
\r
1504 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1505 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1506 global data structure defined within the UART driver.
\r
1509 The handler parameter is the pointer to the custom handler function.
\r
1510 This parameter is of type mss_uart_irq_handler_t.
\r
1513 This function does not return a value.
\r
1516 MSS_UART_set_linsync_handler(&g_mss_uart0, my_linsync_handler);
\r
1520 MSS_UART_set_linsync_handler
\r
1522 mss_uart_instance_t * this_uart,
\r
1523 mss_uart_irq_handler_t handler
\r
1526 /***************************************************************************//**
\r
1527 The MSS_UART_set_nack_handler() function is used assign a custom interrupt
\r
1528 handler for the NACK character detection interrupt when the MSS UART
\r
1529 is operating in Smartcard mode.
\r
1532 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1533 structure identifying the MSS UART hardware block that will perform
\r
1534 the requested function. There are two such data structures,
\r
1535 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1536 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1537 global data structure defined within the UART driver.
\r
1540 The handler parameter is the pointer to the custom handler function.
\r
1541 This parameter is of type mss_uart_irq_handler_t.
\r
1544 This function does not return a value.
\r
1547 MSS_UART_set_nack_handler(&g_mss_uart0, my_nack_handler);
\r
1551 MSS_UART_set_nack_handler
\r
1553 mss_uart_instance_t * this_uart,
\r
1554 mss_uart_irq_handler_t handler
\r
1557 /***************************************************************************//**
\r
1558 The MSS_UART_set_rx_timeout_handler() function is used assign a custom
\r
1559 interrupt handler for the receiver timeout interrupt when the MSS UART is
\r
1560 operating in mode. It finds application in IrDA mode of operation.
\r
1563 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1564 structure identifying the MSS UART hardware block that will perform
\r
1565 the requested function. There are two such data structures,
\r
1566 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1567 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1568 global data structure defined within the UART driver.
\r
1571 The handler parameter is the pointer to the custom handler function.
\r
1572 This parameter is of type mss_uart_irq_handler_t.
\r
1575 This function does not return a value.
\r
1578 MSS_UART_set_rx_timeout_handler(&g_mss_uart0, my_rxtimeout_handler);
\r
1582 MSS_UART_set_rx_timeout_handler
\r
1584 mss_uart_instance_t * this_uart,
\r
1585 mss_uart_irq_handler_t handler
\r
1588 /***************************************************************************//**
\r
1589 The MSS_UART_set_rxstatus_handler() function is used to register a receiver
\r
1590 status handler function that is called by the driver when a UART receiver
\r
1591 line status (RLS) interrupt occurs. You must create and register the handler
\r
1592 function to suit your application.
\r
1594 Note: The MSS_UART_set_rxstatus_handler() function enables both the RLS
\r
1595 interrupt in the UART and the MSS UART instance interrupt in the Cortex-M3
\r
1596 NVIC as part of its implementation.
\r
1598 Note: You can disable the RLS interrupt when required by calling the
\r
1599 MSS_UART_disable_irq() function. This is your choice and is dependent upon
\r
1603 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1604 structure identifying the MSS UART hardware block that will perform
\r
1605 the requested function. There are two such data structures,
\r
1606 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1607 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1608 global data structure defined within the UART driver.
\r
1611 The handler parameter is a pointer to a receiver line status interrupt
\r
1612 handler function provided by your application that will be called as a
\r
1613 result of a UART RLS interrupt. This handler function must be of type
\r
1614 mss_uart_irq_handler_t.
\r
1617 This function does not return a value.
\r
1621 #include "mss_uart.h"
\r
1623 void uart_rxsts_handler(mss_uart_instance_t * this_uart)
\r
1626 status = MSS_UART_get_rx_status(this_uart);
\r
1627 if(status & MSS_UART_OVERUN_ERROR)
\r
1629 discard_rx_data();
\r
1635 MSS_UART_init( &g_mss_uart0,
\r
1636 MSS_UART_57600_BAUD,
\r
1637 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY |
\r
1638 MSS_UART_ONE_STOP_BIT );
\r
1640 MSS_UART_set_rxstatus_handler(&g_mss_uart0, uart_rxsts_handler);
\r
1651 MSS_UART_set_rxstatus_handler
\r
1653 mss_uart_instance_t * this_uart,
\r
1654 mss_uart_irq_handler_t handler
\r
1657 /***************************************************************************//**
\r
1658 The MSS_UART_set_tx_handler() function is used to register a transmit handler
\r
1659 function that is called by the driver when a UART transmit holding register
\r
1660 empty (THRE) interrupt occurs. You must create and register the transmit
\r
1661 handler function to suit your application. You can use the
\r
1662 MSS_UART_fill_tx_fifo() function in your transmit handler function to
\r
1663 write data to the transmitter.
\r
1665 Note: The MSS_UART_set_tx_handler() function enables both the THRE
\r
1666 interrupt in the UART and the MSS UART instance interrupt in the Cortex-M3
\r
1667 NVIC as part of its implementation.
\r
1669 Note: You can disable the THRE interrupt when required by calling the
\r
1670 MSS_UART_disable_irq() function. This is your choice and is dependent upon
\r
1673 Note: The MSS_UART_irq_tx() function does not use the transmit handler
\r
1674 function that you register with the MSS_UART_set_tx_handler() function.
\r
1675 It uses its own internal THRE interrupt handler function that overrides
\r
1676 any custom interrupt handler that you register using the
\r
1677 MSS_UART_set_tx_handler() function.
\r
1680 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1681 structure identifying the MSS UART hardware block that will perform
\r
1682 the requested function. There are two such data structures,
\r
1683 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1684 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1685 global data structure defined within the UART driver.
\r
1688 The handler parameter is a pointer to a transmit interrupt handler
\r
1689 function provided by your application that will be called as a result
\r
1690 of a UART THRE interrupt. This handler function must be of type
\r
1691 mss_uart_irq_handler_t.
\r
1694 This function does not return a value.
\r
1698 #include "mss_uart.h"
\r
1700 uint8_t * g_tx_buffer;
\r
1701 size_t g_tx_size = 0;
\r
1703 void uart_tx_handler(mss_uart_instance_t * this_uart)
\r
1705 size_t size_in_fifo;
\r
1706 size_in_fifo = MSS_UART_fill_tx_fifo(this_uart,
\r
1707 (const uint8_t *)g_tx_buffer,
\r
1710 if(size_in_fifo == g_tx_size)
\r
1713 MSS_UART_disable_irq(this_uart, MSS_UART_TBE_IRQ);
\r
1717 g_tx_buffer = &g_tx_buffer[size_in_fifo];
\r
1718 g_tx_size = g_tx_size - size_in_fifo;
\r
1724 uint8_t message[12] = "Hello world";
\r
1726 MSS_UART_init(&g_mss_uart0,
\r
1727 MSS_UART_57600_BAUD,
\r
1728 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY |
\r
1729 MSS_UART_ONE_STOP_BIT);
\r
1731 g_tx_buffer = message;
\r
1732 g_tx_size = sizeof(message);
\r
1734 MSS_UART_set_tx_handler(&g_mss_uart0, uart_tx_handler);
\r
1745 MSS_UART_set_tx_handler
\r
1747 mss_uart_instance_t * this_uart,
\r
1748 mss_uart_irq_handler_t handler
\r
1751 /***************************************************************************//**
\r
1752 The MSS_UART_set_modemstatus_handler() function is used to register a modem
\r
1753 status handler function that is called by the driver when a UART modem status
\r
1754 (MS) interrupt occurs. You must create and register the handler function to
\r
1755 suit your application.
\r
1757 Note: The MSS_UART_set_modemstatus_handler() function enables both the MS
\r
1758 interrupt in the UART and the MSS UART instance interrupt in the Cortex-M3 NVIC
\r
1759 as part of its implementation.
\r
1761 Note: You can disable the MS interrupt when required by calling the
\r
1762 MSS_UART_disable_irq() function. This is your choice and is dependent
\r
1763 upon your application.
\r
1766 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1767 structure identifying the MSS UART hardware block that will perform
\r
1768 the requested function. There are two such data structures,
\r
1769 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1770 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1771 global data structure defined within the UART driver.
\r
1774 The handler parameter is a pointer to a modem status interrupt handler
\r
1775 function provided by your application that will be called as a result
\r
1776 of a UART MS interrupt. This handler function must be of type
\r
1777 mss_uart_irq_handler_t.
\r
1780 This function does not return a value.
\r
1784 #include "mss_uart.h"
\r
1786 void uart_modem_handler(mss_uart_instance_t * this_uart)
\r
1789 status = MSS_UART_get_modem_status(this_uart);
\r
1790 if(status & MSS_UART_CTS)
\r
1792 uart_cts_handler();
\r
1798 MSS_UART_init(&g_mss_uart0,
\r
1799 MSS_UART_57600_BAUD,
\r
1800 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY |
\r
1801 MSS_UART_ONE_STOP_BIT);
\r
1802 MSS_UART_set_modemstatus_handler(&g_mss_uart0, uart_modem_handler);
\r
1814 MSS_UART_set_modemstatus_handler
\r
1816 mss_uart_instance_t * this_uart,
\r
1817 mss_uart_irq_handler_t handler
\r
1820 /***************************************************************************//**
\r
1821 The MSS_UART_fill_tx_fifo() function fills the UART's hardware transmitter
\r
1822 FIFO with the data found in the transmitter buffer that is passed via the
\r
1823 tx_buffer function parameter. If the transmitter FIFO is not empty when
\r
1824 the function is called, the function returns immediately without transferring
\r
1825 any data to the FIFO; otherwise, the function transfers data from the
\r
1826 transmitter buffer to the FIFO until it is full or until the complete
\r
1827 contents of the transmitter buffer have been copied into the FIFO. The
\r
1828 function returns the number of bytes copied into the UART's transmitter FIFO.
\r
1830 Note: This function reads the UART
\92s line status register (LSR) to check
\r
1831 for the active state of the transmitter holding register empty (THRE) bit
\r
1832 before transferring data from the data buffer to the transmitter FIFO. If
\r
1833 THRE is 0, the function returns immediately, without transferring any data
\r
1834 to the FIFO. If THRE is 1, the function transfers up to 16 bytes of data
\r
1835 to the FIFO and then returns.
\r
1837 Note: The actual transmission over the serial connection will still be
\r
1838 in progress when this function returns. Use the MSS_UART_get_tx_status()
\r
1839 function if you need to know when the transmitter is empty.
\r
1842 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1843 structure identifying the MSS UART hardware block that will perform
\r
1844 the requested function. There are two such data structures,
\r
1845 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1846 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1847 global data structure defined within the UART driver.
\r
1850 The tx_buffer parameter is a pointer to a buffer containing the data
\r
1851 to be transmitted.
\r
1854 The tx_size parameter is the size in bytes, of the data to be transmitted.
\r
1857 This function returns the number of bytes copied into the UART's
\r
1862 void send_using_interrupt(uint8_t * pbuff, size_t tx_size)
\r
1864 size_t size_in_fifo;
\r
1865 size_in_fifo = MSS_UART_fill_tx_fifo(&g_mss_uart0, pbuff, tx_size);
\r
1870 MSS_UART_fill_tx_fifo
\r
1872 mss_uart_instance_t * this_uart,
\r
1873 const uint8_t * tx_buffer,
\r
1877 /***************************************************************************//**
\r
1878 The MSS_UART_get_rx_status() function returns the receiver error status of the
\r
1879 MSS UART instance. It reads both the current error status of the receiver from
\r
1880 the UART
\92s line status register (LSR) and the accumulated error status from
\r
1881 preceding calls to the MSS_UART_get_rx() function, and it combines them using
\r
1882 a bitwise OR. It returns the cumulative overrun, parity, framing, break and
\r
1883 FIFO error status of the receiver, since the previous call to
\r
1884 MSS_UART_get_rx_status(), as an 8-bit encoded value.
\r
1886 Note: The MSS_UART_get_rx() function reads and accumulates the receiver
\r
1887 status of the MSS UART instance before reading each byte from the receiver
\92s
\r
1888 data register/FIFO. The driver maintains a sticky record of the cumulative
\r
1889 receiver error status, which persists after the MSS_UART_get_rx() function
\r
1890 returns. The MSS_UART_get_rx_status() function clears the driver
\92s sticky
\r
1891 receiver error record before returning.
\r
1893 Note: The driver
\92s transmit functions also read the line status
\r
1894 register (LSR) as part of their implementation. When the driver reads the
\r
1895 LSR, the UART clears any active receiver error bits in the LSR. This could
\r
1896 result in the driver losing receiver errors. To avoid any loss of receiver
\r
1897 errors, the transmit functions also update the driver
\92s sticky record of the
\r
1898 cumulative receiver error status whenever they read the LSR.
\r
1901 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1902 structure identifying the MSS UART hardware block that will perform
\r
1903 the requested function. There are two such data structures,
\r
1904 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1905 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1906 global data structure defined within the UART driver.
\r
1909 This function returns the UART
\92s receiver error status as an 8-bit unsigned
\r
1910 integer. The returned value is 0 if no receiver errors occurred. The driver
\r
1911 provides a set of bit mask constants that should be compared with and/or
\r
1912 used to mask the returned value to determine the receiver error status.
\r
1913 When the return value is compared to the following bit masks, a non-zero
\r
1914 result indicates that the corresponding error occurred:
\r
1915 \95 MSS_UART_OVERRUN_ERROR (bit mask = 0x02)
\r
1916 \95 MSS_UART_PARITY_ERROR (bit mask = 0x04)
\r
1917 \95 MSS_UART_FRAMING_ERROR (bit mask = 0x08)
\r
1918 \95 MSS_UART_BREAK_ERROR (bit mask = 0x10)
\r
1919 \95 MSS_UART_FIFO_ERROR (bit mask = 0x80)
\r
1920 When the return value is compared to the following bit mask, a non-zero
\r
1921 result indicates that no error occurred:
\r
1922 \95 MSS_UART_NO_ERROR (bit mask = 0x00)
\r
1923 Upon unsuccessful execution, this function returns:
\r
1924 \95 MSS_UART_INVALID_PARAM (bit mask = 0xFF)
\r
1928 uint8_t rx_data[MAX_RX_DATA_SIZE];
\r
1929 uint8_t err_status;
\r
1930 err_status = MSS_UART_get_rx_status(&g_mss_uart0);
\r
1932 if(MSS_UART_NO_ERROR == err_status)
\r
1934 rx_size = MSS_UART_get_rx(&g_mss_uart0, rx_data, MAX_RX_DATA_SIZE);
\r
1939 MSS_UART_get_rx_status
\r
1941 mss_uart_instance_t * this_uart
\r
1944 /***************************************************************************//**
\r
1945 The MSS_UART_get_modem_status() function returns the modem status of the
\r
1946 MSS UART instance. It reads the modem status register (MSR) and returns
\r
1947 the 8 bit value. The bit encoding of the returned value is exactly the
\r
1948 same as the definition of the bits in the MSR.
\r
1951 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
1952 structure identifying the MSS UART hardware block that will perform
\r
1953 the requested function. There are two such data structures,
\r
1954 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
1955 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
1956 global data structure defined within the UART driver.
\r
1959 This function returns current state of the UART's MSR as an 8 bit
\r
1960 unsigned integer. The driver provides the following set of bit mask
\r
1961 constants that should be compared with and/or used to mask the
\r
1962 returned value to determine the modem status:
\r
1963 \95 MSS_UART_DCTS (bit mask = 0x01)
\r
1964 \95 MSS_UART_DDSR (bit mask = 0x02)
\r
1965 \95 MSS_UART_TERI (bit mask = 0x04)
\r
1966 \95 MSS_UART_DDCD (bit mask = 0x08)
\r
1967 \95 MSS_UART_CTS (bit mask = 0x10)
\r
1968 \95 MSS_UART_DSR (bit mask = 0x20)
\r
1969 \95 MSS_UART_RI (bit mask = 0x40)
\r
1970 \95 MSS_UART_DCD (bit mask = 0x80)
\r
1974 void uart_modem_status_isr(mss_uart_instance_t * this_uart)
\r
1977 status = MSS_UART_get_modem_status(this_uart);
\r
1978 if( status & MSS_UART_DCTS )
\r
1980 uart_dcts_handler();
\r
1982 if( status & MSS_UART_CTS )
\r
1984 uart_cts_handler();
\r
1990 MSS_UART_get_modem_status
\r
1992 mss_uart_instance_t * this_uart
\r
1995 /***************************************************************************//**
\r
1996 The MSS_UART_get_tx_status() function returns the transmitter status of the
\r
1997 MSS UART instance. It reads both the UART
\92s line status register (LSR) and
\r
1998 returns the status of the transmit holding register empty (THRE) and
\r
1999 transmitter empty (TEMT) bits.*
\r
2002 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2003 structure identifying the MSS UART hardware block that will perform
\r
2004 the requested function. There are two such data structures,
\r
2005 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2006 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2007 global data structure defined within the UART driver.
\r
2010 This function returns the UART
\92s transmitter status as an 8-bit unsigned
\r
2011 integer. The returned value is 0 if the transmitter status bits are not
\r
2012 set or the function execution failed. The driver provides a set of bit
\r
2013 mask constants that should be compared with and/or used to mask the
\r
2014 returned value to determine the transmitter status.
\r
2015 When the return value is compared to the following bit mask, a non-zero
\r
2016 result indicates that the corresponding transmitter status bit is set:
\r
2017 \95 MSS_UART_THRE (bit mask = 0x20)
\r
2018 \95 MSS_UART_TEMT (bit mask = 0x40)
\r
2019 When the return value is compared to the following bit mask, a non-zero
\r
2020 result indicates that the transmitter is busy or the function execution
\r
2022 \95 MSS_UART_TX_BUSY (bit mask = 0x00)
\r
2026 uint8_t tx_buff[10] = "abcdefghi";
\r
2027 MSS_UART_init(&g_mss_uart0,
\r
2028 MSS_UART_57600_BAUD,
\r
2029 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2031 MSS_UART_polled_tx(&g_mss_uart0, tx_buff, sizeof(tx_buff));
\r
2033 while(!(MSS_UART_TEMT & MSS_UART_get_tx_status(&g_mss_uart0)))
\r
2040 MSS_UART_get_tx_status
\r
2042 mss_uart_instance_t * this_uart
\r
2045 /***************************************************************************//**
\r
2046 The MSS_UART_set_break() function is used to send the break
\r
2047 (9 zeros after stop bit) signal on the TX line. This function can be used
\r
2048 only when the MSS UART is initialized in LIN mode by using MSS_UART_lin_init().
\r
2051 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2052 structure identifying the MSS UART hardware block that will perform
\r
2053 the requested function. There are two such data structures,
\r
2054 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2055 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2056 global data structure defined within the UART driver.
\r
2059 This function does not return a value.
\r
2063 MSS_UART_init(&g_mss_uart0,
\r
2064 MSS_UART_57600_BAUD,
\r
2065 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2067 MSS_UART_set_break(&g_mss_uart0);
\r
2071 MSS_UART_set_break
\r
2073 mss_uart_instance_t * this_uart
\r
2076 /***************************************************************************//**
\r
2077 The MSS_UART_clear_break() function is used to remove the break signal on the
\r
2078 TX line. This function can be used only when the MSS UART is initialized in
\r
2079 LIN mode by using MSS_UART_lin_init().
\r
2082 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2083 structure identifying the MSS UART hardware block that will perform
\r
2084 the requested function. There are two such data structures,
\r
2085 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2086 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2087 global data structure defined within the UART driver.
\r
2090 This function does not return a value.
\r
2094 MSS_UART_init(&g_mss_uart0,
\r
2095 MSS_UART_57600_BAUD,
\r
2096 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2098 MSS_UART_clear_break(&g_mss_uart0);
\r
2102 MSS_UART_clear_break
\r
2104 mss_uart_instance_t * this_uart
\r
2107 /***************************************************************************//**
\r
2108 The MSS_UART_enable_half_duplex() function is used to enable the half-duplex
\r
2109 (single wire) mode for the MSS UART. Though it finds application in Smartcard
\r
2110 mode, half-duplex mode can be used in other modes as well.
\r
2113 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2114 structure identifying the MSS UART hardware block that will perform
\r
2115 the requested function. There are two such data structures,
\r
2116 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2117 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2118 global data structure defined within the UART driver.
\r
2121 This function does not return a value.
\r
2125 MSS_UART_init(&g_mss_uart0,
\r
2126 MSS_UART_57600_BAUD,
\r
2127 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2129 MSS_UART_enable_half_duplex(&g_mss_uart0);
\r
2133 MSS_UART_enable_half_duplex
\r
2135 mss_uart_instance_t * this_uart
\r
2138 /***************************************************************************//**
\r
2139 The MSS_UART_disable_half_duplex() function is used to disable the half-duplex
\r
2140 (single wire) mode for the MSS UART. Though it finds application in Smartcard
\r
2141 mode, half-duplex mode can be used in other modes as well.
\r
2144 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2145 structure identifying the MSS UART hardware block that will perform
\r
2146 the requested function. There are two such data structures,
\r
2147 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2148 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2149 global data structure defined within the UART driver.
\r
2152 This function does not return a value.
\r
2156 MSS_UART_init(&g_mss_uart0,
\r
2157 MSS_UART_57600_BAUD,
\r
2158 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2160 MSS_UART_disable_half_duplex(&g_mss_uart0);
\r
2164 MSS_UART_disable_half_duplex
\r
2166 mss_uart_instance_t * this_uart
\r
2169 /***************************************************************************//**
\r
2170 The MSS_UART_set_rx_endian() function is used to configure the LSB first or
\r
2171 MSB first setting for MSS UART receiver
\r
2174 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2175 structure identifying the MSS UART hardware block that will perform
\r
2176 the requested function. There are two such data structures,
\r
2177 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2178 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2179 global data structure defined within the UART driver.
\r
2182 The endian parameter tells the LSB first or MSB first configuration.
\r
2183 This parameter is of type mss_uart_endian_t.
\r
2186 This function does not return a value.
\r
2190 MSS_UART_init(&g_mss_uart0,
\r
2191 MSS_UART_57600_BAUD,
\r
2192 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2194 MSS_UART_set_rx_endian(&g_mss_uart0, MSS_UART_LITTLEEND);
\r
2198 MSS_UART_set_rx_endian
\r
2200 mss_uart_instance_t * this_uart,
\r
2201 mss_uart_endian_t endian
\r
2204 /***************************************************************************//**
\r
2205 The MSS_UART_set_tx_endian() function is used to configure the LSB first or
\r
2206 MSB first setting for MSS UART transmitter.
\r
2209 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2210 structure identifying the MSS UART hardware block that will perform
\r
2211 the requested function. There are two such data structures,
\r
2212 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2213 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2214 global data structure defined within the UART driver.
\r
2217 The endian parameter tells the LSB first or MSB first configuration.
\r
2218 This parameter is of type mss_uart_endian_t.
\r
2221 This function does not return a value.
\r
2225 MSS_UART_init(&g_mss_uart0,
\r
2226 MSS_UART_57600_BAUD,
\r
2227 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2229 MSS_UART_set_tx_endian(&g_mss_uart0, MSS_UART_LITTLEEND);
\r
2233 MSS_UART_set_tx_endian
\r
2235 mss_uart_instance_t * this_uart,
\r
2236 mss_uart_endian_t endian
\r
2239 /***************************************************************************//**
\r
2240 The MSS_UART_set_filter_length () function is used to configure the glitch
\r
2241 filter length of the MSS UART. This should be configured in accordance with
\r
2242 the chosen baud rate.
\r
2245 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2246 structure identifying the MSS UART hardware block that will perform
\r
2247 the requested function. There are two such data structures,
\r
2248 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2249 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2250 global data structure defined within the UART driver.
\r
2253 The length parameter is of mss_uart_filter_length_t type that determines
\r
2254 the length of the glitch filter.
\r
2257 This function does not return a value.
\r
2261 MSS_UART_init(&g_mss_uart0,
\r
2262 MSS_UART_57600_BAUD,
\r
2263 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2265 MSS_UART_set_filter_length(&g_mss_uart0, MSS_UART_LEN2);
\r
2269 MSS_UART_set_filter_length
\r
2271 mss_uart_instance_t * this_uart,
\r
2272 mss_uart_filter_length_t length
\r
2275 /***************************************************************************//**
\r
2276 The MSS_UART_enable_afm() function is used to enable address flag detection
\r
2277 mode of the MSS UART
\r
2280 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2281 structure identifying the MSS UART hardware block that will perform
\r
2282 the requested function. There are two such data structures,
\r
2283 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2284 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2285 global data structure defined within the UART driver.
\r
2288 This function does not return a value.
\r
2292 MSS_UART_init(&g_mss_uart0,
\r
2293 MSS_UART_57600_BAUD,
\r
2294 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2296 MSS_UART_enable_afm(&g_mss_uart0);
\r
2300 MSS_UART_enable_afm
\r
2302 mss_uart_instance_t * this_uart
\r
2305 /***************************************************************************//**
\r
2306 The MSS_UART_disable_afm() function is used to disable address flag detection
\r
2307 mode of the MSS UART.
\r
2310 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2311 structure identifying the MSS UART hardware block that will perform
\r
2312 the requested function. There are two such data structures,
\r
2313 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2314 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2315 global data structure defined within the UART driver.
\r
2318 This function does not return a value.
\r
2322 MSS_UART_init(&g_mss_uart0,
\r
2323 MSS_UART_57600_BAUD,
\r
2324 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2326 MSS_UART_disable_afm(&g_mss_uart0);
\r
2330 MSS_UART_disable_afm
\r
2332 mss_uart_instance_t * this_uart
\r
2335 /***************************************************************************//**
\r
2336 The MSS_UART_enable_afclear () function is used to enable address flag clear
\r
2337 of the MSS UART. This should be used in conjunction with address flag
\r
2338 detection mode (AFM).
\r
2341 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2342 structure identifying the MSS UART hardware block that will perform
\r
2343 the requested function. There are two such data structures,
\r
2344 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2345 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2346 global data structure defined within the UART driver.
\r
2349 This function does not return a value.
\r
2353 MSS_UART_init(&g_mss_uart0,
\r
2354 MSS_UART_57600_BAUD,
\r
2355 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2357 MSS_UART_enable_afclear(&g_mss_uart0);
\r
2361 MSS_UART_enable_afclear
\r
2363 mss_uart_instance_t * this_uart
\r
2366 /***************************************************************************//**
\r
2367 The MSS_UART_disable_afclear () function is used to disable address flag
\r
2368 clear of the MSS UART. This should be used in conjunction with address flag
\r
2369 detection mode (AFM).
\r
2372 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2373 structure identifying the MSS UART hardware block that will perform
\r
2374 the requested function. There are two such data structures,
\r
2375 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2376 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2377 global data structure defined within the UART driver.
\r
2380 This function does not return a value.
\r
2384 MSS_UART_init(&g_mss_uart0,
\r
2385 MSS_UART_57600_BAUD,
\r
2386 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2388 MSS_UART_disable_afclear(&g_mss_uart0);
\r
2392 MSS_UART_disable_afclear
\r
2394 mss_uart_instance_t * this_uart
\r
2397 /***************************************************************************//**
\r
2398 The MSS_UART_enable_rx_timeout() function is used to enable and configure
\r
2399 the receiver timeout functionality of MSS UART. This function accepts the
\r
2400 timeout parameter and applies the timeout based up on the baud rate as per
\r
2401 the formula 4 x timeout x bit time.
\r
2404 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2405 structure identifying the MSS UART hardware block that will perform
\r
2406 the requested function. There are two such data structures,
\r
2407 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2408 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2409 global data structure defined within the UART driver.
\r
2412 The timeout parameter specifies the receiver timeout multiple.
\r
2413 It should be configured according to the baud rate in use.
\r
2416 This function does not return a value.
\r
2420 MSS_UART_init(&g_mss_uart0,
\r
2421 MSS_UART_57600_BAUD,
\r
2422 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2424 MSS_UART_enable_rx_timeout(&g_mss_uart0 , 24);
\r
2428 MSS_UART_enable_rx_timeout
\r
2430 mss_uart_instance_t * this_uart,
\r
2434 /***************************************************************************//**
\r
2435 The MSS_UART_disable_rx_timeout() function is used to disable the receiver
\r
2436 timeout functionality of MSS UART.
\r
2439 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2440 structure identifying the MSS UART hardware block that will perform
\r
2441 the requested function. There are two such data structures,
\r
2442 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2443 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2444 global data structure defined within the UART driver.
\r
2447 This function does not return a value.
\r
2451 MSS_UART_init(&g_mss_uart0,
\r
2452 MSS_UART_57600_BAUD,
\r
2453 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2455 MSS_UART_disable_rx_timeout(&g_mss_uart0);
\r
2459 MSS_UART_disable_rx_timeout
\r
2461 mss_uart_instance_t * this_uart
\r
2464 /***************************************************************************//**
\r
2465 The MSS_UART_enable_tx_time_guard() function is used to enable and configure
\r
2466 the transmitter time guard functionality of MSS UART. This function accepts
\r
2467 the timeguard parameter and applies the timeguard based up on the baud rate
\r
2468 as per the formula timeguard x bit time.
\r
2471 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2472 structure identifying the MSS UART hardware block that will perform
\r
2473 the requested function. There are two such data structures,
\r
2474 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2475 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2476 global data structure defined within the UART driver.
\r
2479 This function does not return a value.
\r
2483 MSS_UART_init(&g_mss_uart0,
\r
2484 MSS_UART_57600_BAUD,
\r
2485 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2487 MSS_UART_enable_tx_time_guard(&g_mss_uart0 , 24);
\r
2491 MSS_UART_enable_tx_time_guard
\r
2493 mss_uart_instance_t * this_uart,
\r
2497 /***************************************************************************//**
\r
2498 The MSS_UART_disable_tx_time_guard() function is used to disable the
\r
2499 transmitter time guard functionality of MSS UART.
\r
2502 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2503 structure identifying the MSS UART hardware block that will perform
\r
2504 the requested function. There are two such data structures,
\r
2505 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2506 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2507 global data structure defined within the UART driver.
\r
2510 This function does not return a value.
\r
2514 MSS_UART_init(&g_mss_uart0,
\r
2515 MSS_UART_57600_BAUD,
\r
2516 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2518 MSS_UART_disable_tx_time_guard(&g_mss_uart0);
\r
2522 MSS_UART_disable_tx_time_guard
\r
2524 mss_uart_instance_t * this_uart
\r
2527 /***************************************************************************//**
\r
2528 The MSS_UART_set_address() function is used to set the 8-bit address for
\r
2529 the MSS UART referenced by this_uart parameter.
\r
2532 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2533 structure identifying the MSS UART hardware block that will perform
\r
2534 the requested function. There are two such data structures,
\r
2535 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2536 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2537 global data structure defined within the UART driver.
\r
2540 The address parameter is the 8-bit address which is to be configured
\r
2541 to the MSS UART referenced by this_uart parameter.
\r
2544 This function does not return a value.
\r
2548 MSS_UART_init(&g_mss_uart0,
\r
2549 MSS_UART_57600_BAUD,
\r
2550 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2552 MSS_UART_set_address(&g_mss_uart0, 0xAA);
\r
2556 MSS_UART_set_address
\r
2558 mss_uart_instance_t * this_uart,
\r
2562 /***************************************************************************//**
\r
2563 The MSS_UART_set_ready_mode() function is used to configure the MODE0 or MODE1
\r
2564 to the TXRDY and RXRDY signals of the MSS UART referenced by this_uart
\r
2565 parameter. The mode parameter is used to provide the mode to be configured.
\r
2568 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2569 structure identifying the MSS UART hardware block that will perform
\r
2570 the requested function. There are two such data structures,
\r
2571 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2572 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2573 global data structure defined within the UART driver.
\r
2576 The mode parameter is the mss_uart_ready_mode_t type which is used to
\r
2577 configure the TXRDY and RXRDY signal modes.
\r
2580 This function does not return a value.
\r
2584 MSS_UART_init(&g_mss_uart0,
\r
2585 MSS_UART_57600_BAUD,
\r
2586 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2588 MSS_UART_set_ready_mode(&g_mss_uart0, MSS_UART_READY_MODE0);
\r
2592 MSS_UART_set_ready_mode
\r
2594 mss_uart_instance_t * this_uart,
\r
2595 mss_uart_ready_mode_t mode
\r
2598 /***************************************************************************//**
\r
2599 The MSS_UART_set_usart_mode() function is used to configure the MSS UART
\r
2600 referenced by the parameter this_uart in USART mode. Various USART modes
\r
2601 are supported which can be configured by the parameter mode of type
\r
2602 mss_uart_usart_mode_t.
\r
2605 The this_uart parameter is a pointer to an mss_uart_instance_t
\r
2606 structure identifying the MSS UART hardware block that will perform
\r
2607 the requested function. There are two such data structures,
\r
2608 g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
\r
2609 This parameter must point to either the g_mss_uart0 or g_mss_uart1
\r
2610 global data structure defined within the UART driver.
\r
2613 The mode parameter is the USART mode to be configured.
\r
2614 This parameter is of type mss_uart_usart_mode_t.
\r
2617 This function does not return a value.
\r
2621 MSS_UART_init(&g_mss_uart0,
\r
2622 MSS_UART_57600_BAUD,
\r
2623 MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
\r
2625 MSS_UART_set_usart_mode(&g_mss_uart0, MSS_UART_SYNC_MASTER_POS_EDGE_CLK);
\r
2629 MSS_UART_set_usart_mode
\r
2631 mss_uart_instance_t * this_uart,
\r
2632 mss_uart_usart_mode_t mode
\r
2635 #ifdef __cplusplus
\r
2639 #endif /* __MSS_UART_H_ */
\r