12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639 |
- /*******************************************************************************
- * (c) Copyright 2011-2013 Microsemi SoC Products Group. All rights reserved.
- *
- * SmartFusion2 Microcontroller Subsystem MMUART bare metal software driver
- * public API.
- *
- * SVN $Revision: 5610 $
- * SVN $Date: 2013-04-05 18:49:30 +0530 (Fri, 05 Apr 2013) $
- */
- /*=========================================================================*//**
- @mainpage SmartFusion2 MSS UART Bare Metal Driver.
- ==============================================================================
- @section intro_sec Introduction
- ==============================================================================
- The SmartFusion2 microcontroller subsystem (MSS) includes two multi-mode UART
- (MMUART) peripherals for serial communication. This driver provides a set of
- functions for controlling the MSS MMUARTs as part of a bare metal system
- where no operating system is available. These drivers can be adapted for use
- as part of an operating system, but the implementation of the adaptation layer
- between this driver and the operating system's driver model is outside the
- scope of this driver.
- Note: MSS UART is synonymous with MSS MMUART in this document.
-
- ==============================================================================
- @section hw_dependencies Hardware Flow Dependencies
- ==============================================================================
- The configuration of all features of the MSS MMUART peripherals is covered by
- this driver with the exception of the SmartFusion2 IOMUX configuration.
- SmartFusion2 allows multiple non-concurrent uses of some external pins through
- IOMUX configuration. This feature allows optimization of external pin usage by
- assigning external pins for use by either the microcontroller subsystem or the
- FPGA fabric. The MSS MMUART serial signals are routed through IOMUXs to the
- SmartFusion2 device external pins. The MSS MMUART serial signals may also be
- routed through IOMUXs to the SmartFusion2 FPGA fabric. For more information on
- IOMUX, refer to the IOMUX section of the SmartFusion2 Microcontroller
- Subsystem (MSS) User’s Guide.
- The IOMUXs are configured using the SmartFusion2 MSS configurator tool. You
- must ensure that the MSS MMUART peripherals are enabled and configured in the
- SmartFusion2 MSS configurator if you wish to use them. For more information on
- IOMUXs, refer to the IOMUX section of the SmartFusion2 Microcontroller
- Subsystem (MSS) User’s Guide.
- The base address, register addresses and interrupt number assignment for the
- MSS MMUART peripherals are defined as constants in the SmartFusion2 CMSIS HAL.
- You must ensure that the latest SmartFusion2 CMSIS HAL is included in the
- project settings of the software tool chain used to build your project and
- that it is generated into your project.
-
- ==============================================================================
- @section theory_op Theory of Operation
- ==============================================================================
- The MSS MMUART driver functions are grouped into the following categories:
- - Initialization and configuration functions
- - Polled transmit and receive functions
- - Interrupt driven transmit and receive functions
-
- --------------------------------
- Initialization and Configuration
- --------------------------------
- The MSS MMUART supports the following four broad modes of operation:
- - UART or USART mode
- - LIN mode
- - IrDA mode
- - Smartcard or ISO 7816 mode
- The MSS MMUART driver provides the MSS_UART_init(), MSS_UART_lin_init(),
- MSS_UART_irda_init() and MSS_UART_smartcard_init() functions to initialize the
- MSS MMUARTs for operation in one of these modes. One of these initialization
- functions must be called before any other MSS MMUART driver functions can be
- called. The MSS MMUART operating modes are mutually exclusive; therefore only
- one of the initialization functions must be called. The first parameter of the
- initialization functions is a pointer to one of two global data structures
- used to store state information for each MSS MMUART. A pointer to these data
- structures is also used as the first parameter to many of the driver functions
- to identify which MSS MMUART will be used by the called function. The names of
- these two data structures are g_mss_uart0 and g_mss_uart1. Therefore, any call
- to an MSS MMUART function should be of the form
- MSS_UART_function_name( &g_mss_uart0, ... ) or
- MSS_UART_function_name( &g_mss_uart1, ... ).
-
- UART or USART Mode
- For the UART or USART modes of operation, the MSS MMUART driver is initialized
- through a call to the MSS_UART_init() function. This function takes the UART’s
- configuration as its parameters. The MSS_UART_init() function must be called
- before any other MSS MMUART driver functions can be called.
- The MSS_UART_init() function configures the baud rate based on the input baud
- rate parameter and if possible uses a fractional baud rate for greater
- precision. This function disables the LIN, IrDA and SmartCard modes.
-
- LIN mode
- For the LIN mode of operation, the MSS MMUART driver is initialized through a
- call to the MSS_UART_lin_init() function. This function takes the LIN node’s
- configuration as its parameters. The MSS_UART_lin_init() function must be
- called before any other MSS MMUART driver functions can be called. The
- MSS_UART_lin_init() function configures the baud rate based on the input baud
- rate parameter and if possible uses a fractional baud rate for greater
- precision. This function disables the IrDA and SmartCard modes.
- The driver also provides the following LIN mode configuration functions:
- - MSS_UART_set_break()
- - MSS_UART_clear_break()
- - MSS_UART_set_pidpei_handler()
- - MSS_UART_set_linbreak_handler()
- - MSS_UART_set_linsync_handler()
- Note: These LIN mode configuration functions can only be called after the
- MSS_UART_lin_init() function is called.
-
- IrDA mode
- For the IrDA mode of operation, the driver is initialized through a call to
- the MSS_UART_irda_init() function. This function takes the IrDA node’s
- configuration as its parameters. The MSS_UART_irda_init() function must be
- called before any other MSS MMUART driver functions can be called. The
- MSS_UART_irda_init() function configures the baud rate based on the input baud
- rate parameter and if possible uses a fractional baud rate for greater
- precision. This function disables the LIN and SmartCard modes.
-
- Smartcard or ISO 7816 mode
- For the Smartcard or ISO 7816 mode of operation, the driver is initialized
- through a call to the MSS_UART_smartcard_init() function. This function takes
- the smartcard configuration as its parameters. The MSS_UART_smartcard_init()
- function must be called before any other MSS MMUART driver functions can be
- called. The MSS_UART_smartcard_init() function configures the baud rate based
- on the input baud rate parameter and if possible uses a fractional baud rate
- for greater precision. This function disables the LIN and IrDA modes.
- The driver also provides the following Smartcard mode configuration functions:
- - MSS_UART_enable_halfduplex()
- - MSS_UART_disable_halfduplex()
- - MSS_UART_set_nack_handler()
- Note: These Smartcard mode configuration functions can only be called after
- the MSS_UART_smartcard_init() function is called.
-
- Common Configuration Functions
- The driver also provides the configuration functions that can be used with all
- MSS MMUART operating modes. These common configuration functions are as
- follows:
- - MSS_UART_set_rx_endian()
- - MSS_UART_set_tx_endian()
- - MSS_UART_enable_afclear()
- - MSS_UART_disable_afclear()
- - MSS_UART_enable_rx_timeout()
- - MSS_UART_disable_rx_timeout()
- - MSS_UART_enable_tx_time_guard()
- - MSS_UART_disable_tx_time_guard()
- - MSS_UART_set_address()
- - MSS_UART_set_ready_mode()
- - MSS_UART_set_usart_mode()
- - MSS_UART_set_filter_length()
- - MSS_UART_enable_afm()
- - MSS_UART_disable_afm()
- Note: These configuration functions can only be called after one of the
- MSS_UART_init(), MSS_UART_lin_init(), MSS_UART_irda_init() or
- MSS_UART_smartcard_init() functions is called.
-
- --------------------------------------
- Polled Transmit and Receive Operations
- --------------------------------------
- The driver can be used to transmit and receive data once initialized.
- Data is transmitted using the MSS_UART_polled_tx() function. This function is
- blocking, meaning that it will only return once the data passed to the
- function has been sent to the MSS MMUART hardware transmitter. Data received
- by the MSS MMUART hardware receiver can be read by the MSS_UART_get_rx()
- function.
- The MSS_UART_polled_tx_string() function is provided to transmit a NULL (‘\0’)
- terminated string in polled mode. This function is blocking, meaning that it
- will only return once the data passed to the function has been sent to the MSS
- MMUART hardware transmitter.
- The MSS_UART_fill_tx_fifo() function fills the MSS MMUART hardware transmit
- FIFO with data from a buffer passed as a parameter and returns the number of
- bytes transferred to the FIFO. If the transmit FIFO is not empty when the
- MSS_UART_fill_tx_fifo() function is called it returns immediately without
- transferring any data to the FIFO.
-
- ---------------------------
- Interrupt Driven Operations
- ---------------------------
- The driver can also transmit or receive data under interrupt control, freeing
- your application to perform other tasks until an interrupt occurs indicating
- that the driver’s attention is required.
-
- Interrupt Handlers
- The MSS MMUART driver supports all types of interrupt triggered by the MSS
- MMUART. The driver’s internal top level interrupt handler identifies the
- source of the MSS MMUART interrupt and calls the corresponding lower level
- handler function that you previously registered with the driver through calls
- to the MSS_UART_set_rx_handler(), MSS_UART_set_tx_handler(),
- MSS_UART_set_rxstatus_handler(), and MSS_UART_set_modemstatus_handler()
- functions. You are responsible for creating these lower level interrupt
- handlers as part of your application program and registering them with the
- driver.
- Note: The SmartFusion2 CMSIS-PAL defines the UART0_IRQHandler() and
- UART1_IRQHandler() functions (with weak linkage) and assigns them as the
- interrupt service routines (ISR) for the MSS MMUART interrupt inputs to
- the Cortex-M3 NVIC. The MSS MMUART driver provides the implementation
- functions for both of these ISRs from which it calls its own internal
- top level, interrupt handler function.
- The MSS_UART_enable_irq() and MSS_UART_disable_irq() functions are used to
- enable or disable the received line status, received data available/character
- timeout, transmit holding register empty and modem status interrupts at the
- MSS MMUART level. The MSS_UART_enable_irq() function also enables the MSS
- MMUART instance interrupt at the Cortex-M3 level.
-
- Transmitting Data
- Interrupt-driven transmit is initiated by a call to MSS_UART_irq_tx(),
- specifying the block of data to transmit. Your application is then free to
- perform other tasks and inquire later whether transmit has completed by
- calling the MSS_UART_tx_complete() function. The MSS_UART_irq_tx() function
- enables the UART’s transmit holding register empty (THRE) interrupt and then,
- when the interrupt goes active, the driver’s default THRE interrupt handler
- transfers the data block to the UART until the entire block is transmitted.
- Note: You can use the MSS_UART_set_tx_handler() function to assign an
- alternative handler to the THRE interrupt. In this case, you must not
- use the MSS_UART_irq_tx() function to initiate the transmit, as this
- will re-assign the driver’s default THRE interrupt handler to the THRE
- interrupt. Instead, your alternative THRE interrupt handler must include
- a call to the MSS_UART_fill_tx_fifo() function to transfer the data to
- the UART.
-
- Receiving Data
- Interrupt-driven receive is performed by first calling
- MSS_UART_set_rx_handler() to register a receive handler function that will be
- called by the driver whenever receive data is available. You must provide this
- receive handler function which must include a call to the MSS_UART_get_rx()
- function to actually read the received data.
-
- -----------
- UART Status
- -----------
- The function MSS_UART_get_rx_status() is used to read the receiver error
- status. This function returns the overrun, parity, framing, break, and FIFO
- error status of the receiver.
- The function MSS_UART_get_tx_status() is used to read the transmitter status.
- This function returns the transmit empty (TEMT) and transmit holding register
- empty (THRE) status of the transmitter.
- The function MSS_UART_get_modem_status() is used to read the modem status
- flags. This function returns the current value of the modem status register.
-
- --------
- Loopback
- --------
- The MSS_UART_set_loopback() function can be used to locally loopback the Tx
- and Rx lines of a UART. This is not to be confused with the loopback of UART0
- to UART1, which can be achieved through the microcontroller subsystem’s system
- registers.
-
- *//*=========================================================================*/
- #ifndef __MSS_UART_H_
- #define __MSS_UART_H_ 1
- #include "../../CMSIS/m2sxxx.h"
- #include <stddef.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- /***************************************************************************//**
- Baud rates
- The following definitions are used to specify standard baud rates as a
- parameter to the MSS_UART_init() function.
- */
- #define MSS_UART_110_BAUD 110
- #define MSS_UART_300_BAUD 300
- #define MSS_UART_1200_BAUD 1200
- #define MSS_UART_2400_BAUD 2400
- #define MSS_UART_4800_BAUD 4800
- #define MSS_UART_9600_BAUD 9600
- #define MSS_UART_19200_BAUD 19200
- #define MSS_UART_38400_BAUD 38400
- #define MSS_UART_57600_BAUD 57600
- #define MSS_UART_115200_BAUD 115200
- #define MSS_UART_230400_BAUD 230400
- #define MSS_UART_460800_BAUD 460800
- #define MSS_UART_921600_BAUD 921600
- /***************************************************************************//**
- Data Bits Length
- The following defines are used to build the value of the MSS_UART_init()
- function line_config parameter.
- */
- #define MSS_UART_DATA_5_BITS ( (uint8_t) 0x00 )
- #define MSS_UART_DATA_6_BITS ( (uint8_t) 0x01 )
- #define MSS_UART_DATA_7_BITS ( (uint8_t) 0x02 )
- #define MSS_UART_DATA_8_BITS ( (uint8_t) 0x03 )
- /***************************************************************************//**
- Parity
- The following defines are used to build the value of the MSS_UART_init()
- function line_config parameter.
- */
- #define MSS_UART_NO_PARITY ( (uint8_t) 0x00 )
- #define MSS_UART_ODD_PARITY ( (uint8_t) 0x08 )
- #define MSS_UART_EVEN_PARITY ( (uint8_t) 0x18 )
- #define MSS_UART_STICK_PARITY_0 ( (uint8_t) 0x38 )
- #define MSS_UART_STICK_PARITY_1 ( (uint8_t) 0x28 )
- /***************************************************************************//**
- Number of Stop Bits
- The following defines are used to build the value of the MSS_UART_init()
- function line_config parameter.
- */
- #define MSS_UART_ONE_STOP_BIT ( (uint8_t) 0x00 )
- #define MSS_UART_ONEHALF_STOP_BIT ( (uint8_t) 0x04 )
- #define MSS_UART_TWO_STOP_BITS ( (uint8_t) 0x04 )
- /***************************************************************************//**
- Receiver Error Status
- The following defines are used to determine the UART receiver error type.
- These bit mask constants are used with the return value of the
- MSS_UART_get_rx_status() function to find out if any errors occurred while
- receiving data.
- */
- #define MSS_UART_INVALID_PARAM ( (uint8_t)0xFF )
- #define MSS_UART_NO_ERROR ( (uint8_t)0x00 )
- #define MSS_UART_OVERUN_ERROR ( (uint8_t)0x02 )
- #define MSS_UART_PARITY_ERROR ( (uint8_t)0x04 )
- #define MSS_UART_FRAMING_ERROR ( (uint8_t)0x08 )
- #define MSS_UART_BREAK_ERROR ( (uint8_t)0x10 )
- #define MSS_UART_FIFO_ERROR ( (uint8_t)0x80 )
- /***************************************************************************//**
- Transmitter Status
- The following definitions are used to determine the UART transmitter status.
- These bit mask constants are used with the return value of the
- MSS_UART_get_tx_status() function to find out the status of the transmitter.
- */
- #define MSS_UART_TX_BUSY ( (uint8_t) 0x00 )
- #define MSS_UART_THRE ( (uint8_t) 0x20 )
- #define MSS_UART_TEMT ( (uint8_t) 0x40 )
- /***************************************************************************//**
- Modem Status
- The following defines are used to determine the modem status. These bit
- mask constants are used with the return value of the
- MSS_UART_get_modem_status() function to find out the modem status of
- the UART.
- */
- #define MSS_UART_DCTS ( (uint8_t) 0x01 )
- #define MSS_UART_DDSR ( (uint8_t) 0x02 )
- #define MSS_UART_TERI ( (uint8_t) 0x04 )
- #define MSS_UART_DDCD ( (uint8_t) 0x08 )
- #define MSS_UART_CTS ( (uint8_t) 0x10 )
- #define MSS_UART_DSR ( (uint8_t) 0x20 )
- #define MSS_UART_RI ( (uint8_t) 0x40 )
- #define MSS_UART_DCD ( (uint8_t) 0x80 )
- /***************************************************************************//**
- This typedef specifies the irq_mask parameter for the MSS_UART_enable_irq()
- and MSS_UART_disable_irq() functions. The driver defines a set of bit masks
- that are used to build the value of the irq_mask parameter. A bitwise OR of
- these bit masks is used to enable or disable multiple MSS MMUART interrupts.
- */
- typedef uint16_t mss_uart_irq_t;
- /***************************************************************************//**
- The following defines specify the interrupt masks to enable and disable MSS
- MMUART interrupts. They are used to build the value of the irq_mask parameter
- for the MSS_UART_enable_irq() and MSS_UART_disable_irq() functions. A bitwise
- OR of these constants is used to enable or disable multiple interrupts.
- */
- #define MSS_UART_RBF_IRQ 0x001
- #define MSS_UART_TBE_IRQ 0x002
- #define MSS_UART_LS_IRQ 0x004
- #define MSS_UART_MS_IRQ 0x008
- #define MSS_UART_RTO_IRQ 0x010
- #define MSS_UART_NACK_IRQ 0x020
- #define MSS_UART_PIDPE_IRQ 0x040
- #define MSS_UART_LINB_IRQ 0x080
- #define MSS_UART_LINS_IRQ 0x100
- #define MSS_UART_INVALID_IRQ UINT16_MAX
- /***************************************************************************//**
- This enumeration specifies the receiver FIFO trigger level. This is the number
- of bytes that must be received before the UART generates a receive data
- available interrupt. It provides the allowed values for the
- MSS_UART_set_rx_handler() function trigger_level parameter.
- */
- typedef enum {
- MSS_UART_FIFO_SINGLE_BYTE = 0x00,
- MSS_UART_FIFO_FOUR_BYTES = 0x40,
- MSS_UART_FIFO_EIGHT_BYTES = 0x80,
- MSS_UART_FIFO_FOURTEEN_BYTES = 0xC0,
- MSS_UART_FIFO_INVALID_TRIG_LEVEL
- } mss_uart_rx_trig_level_t;
- /***************************************************************************//**
- This enumeration specifies the loopback configuration of the UART. It provides
- the allowed values for the MSS_UART_set_loopback() function’s loopback
- parameter. Use MSS_UART_LOCAL_LOOPBACK_ON to set up the UART to locally
- loopback its Tx and Rx lines. Use MSS_UART_REMOTE_LOOPBACK_ON to set up the
- UART in remote loopback mode.
- */
- typedef enum {
- MSS_UART_LOCAL_LOOPBACK_OFF,
- MSS_UART_LOCAL_LOOPBACK_ON,
- MSS_UART_REMOTE_LOOPBACK_OFF,
- MSS_UART_REMOTE_LOOPBACK_ON,
- MSS_UART_AUTO_ECHO_OFF,
- MSS_UART_AUTO_ECHO_ON,
- MSS_UART_INVALID_LOOPBACK
- } mss_uart_loopback_t;
- /***************************************************************************//**
- IrDA input / output polarity.
- This enumeration specifies the RZI modem polarity for input and output signals.
- This is passed as parameters in MSS_UART_irda_init() function.
- */
- typedef enum {
- MSS_UART_ACTIVE_LOW = 0u,
- MSS_UART_ACTIVE_HIGH = 1u,
- MSS_UART_INVALID_POLARITY
- } mss_uart_rzi_polarity_t;
- /***************************************************************************//**
- IrDA input / output pulse width.
- This enumeration specifies the RZI modem pulse width for input and output signals.
- This is passed as parameters in MSS_UART_irda_init() function.
- */
- typedef enum {
- MSS_UART_3_BY_16 = 0u,
- MSS_UART_1_BY_4 = 1u,
- MSS_UART_INVALID_PW
- } mss_uart_rzi_pulsewidth_t;
- /***************************************************************************//**
- Tx / Rx endianess.
- This enumeration specifies the MSB first or LSB first for MSS UART transmitter
- and receiver. The parameter of this type shall be passed in
- MSS_UART_set_rx_endian()and MSS_UART_set_tx_endian() functions.
- */
- typedef enum {
- MSS_UART_LITTLEEND,
- MSS_UART_BIGEND,
- MSS_UART_INVALID_ENDIAN
- } mss_uart_endian_t;
- /***************************************************************************//**
- Glitch filter length.
- This enumeration specifies the glitch filter length. The function
- MSS_UART_set_filter_length() accepts the parameter of this type.
- */
- typedef enum {
- MSS_UART_LEN0 = 0,
- MSS_UART_LEN1 = 1,
- MSS_UART_LEN2 = 2,
- MSS_UART_LEN3 = 3,
- MSS_UART_LEN4 = 4,
- MSS_UART_LEN5 = 5,
- MSS_UART_LEN6 = 6,
- MSS_UART_LEN7 = 7,
- MSS_UART_INVALID_FILTER_LENGTH = 8
- } mss_uart_filter_length_t;
- /***************************************************************************//**
- TXRDY and RXRDY mode.
- This enumeration specifies the TXRDY and RXRDY signal modes. The function
- MSS_UART_set_ready_mode() accepts the parameter of this type.
- */
- typedef enum {
- MSS_UART_READY_MODE0,
- MSS_UART_READY_MODE1,
- MSS_UART_INVALID_READY_MODE
- } mss_uart_ready_mode_t;
- /***************************************************************************//**
- USART mode of operation.
- This enumeration specifies the mode of operation of MSS UART when operating
- as USART. The function MSS_UART_set_usart_mode() accepts the parameter of this type.
- */
- typedef enum {
- MSS_UART_ASYNC_MODE = 0,
- MSS_UART_SYNC_SLAVE_POS_EDGE_CLK = 1,
- MSS_UART_SYNC_SLAVE_NEG_EDGE_CLK = 2,
- MSS_UART_SYNC_MASTER_POS_EDGE_CLK = 3,
- MSS_UART_SYNC_MASTER_NEG_EDGE_CLK = 4,
- MSS_UART_INVALID_SYNC_MODE = 5
- } mss_uart_usart_mode_t;
- /***************************************************************************//**
- MSS UART instance type.
- This is type definition for MSS UART instance. You need to create and
- maintain a record of this type. This holds all data regarding the MSS UART
- instance
- */
- typedef struct mss_uart_instance mss_uart_instance_t;
- /***************************************************************************//**
- Interrupt handler prototype.
- This typedef specifies the function prototype for MSS UART interrupt handlers.
- All interrupt handlers registered with the MSS UART driver must be of this type.
- The interrupt handlers are registered with the driver through the
- MSS_UART_set_rx_handler(), MSS_UART_set_tx_handler(),
- MSS_UART_set_rxstatus_handler(), and MSS_UART_set_modemstatus_handler()
- functions.
- The this_uart parameter is a pointer to either g_mss_uart0 or g_mss_uart1 to
- identify the MSS UART to associate with the handler function.
- */
- typedef void (*mss_uart_irq_handler_t)( mss_uart_instance_t * this_uart );
- /***************************************************************************//**
- mss_uart_instance.
- There is one instance of this structure for each instance of the
- microcontroller subsystem’s UARTs. Instances of this structure are used to
- identify a specific UART. A pointer to an initialized instance of the
- mss_uart_instance_t structure is passed as the first parameter to
- MSS UART driver functions to identify which UART should perform the
- requested operation.
- */
- struct mss_uart_instance{
- /* CMSIS related defines identifying the UART hardware. */
- UART_TypeDef * hw_reg; /*!< Pointer to UART registers. */
- IRQn_Type irqn; /*!< UART's Cortex-M3 NVIC interrupt number. */
- uint32_t baudrate; /*!< Operating baud rate. */
- uint8_t lineconfig; /*!< Line configuration parameters. */
- uint8_t status; /*!< Sticky line status. */
- /* transmit related info (used with interrupt driven transmit): */
- const uint8_t * tx_buffer; /*!< Pointer to transmit buffer. */
- uint32_t tx_buff_size; /*!< Transmit buffer size. */
- uint32_t tx_idx; /*!< Index within transmit buffer of next byte to transmit.*/
- /* line status interrupt handler:*/
- mss_uart_irq_handler_t linests_handler; /*!< Pointer to user registered line status handler. */
- /* receive interrupt handler:*/
- mss_uart_irq_handler_t rx_handler; /*!< Pointer to user registered receiver handler. */
- /* transmit interrupt handler:*/
- mss_uart_irq_handler_t tx_handler; /*!< Pointer to user registered transmit handler. */
- /* modem status interrupt handler:*/
- mss_uart_irq_handler_t modemsts_handler; /*!< Pointer to user registered modem status handler. */
- /* receiver timeout interrupt handler */
- mss_uart_irq_handler_t rto_handler; /*!< Pointer to user registered receiver timeout handler. */
- /* NACK interrupt handler */
- mss_uart_irq_handler_t nack_handler; /*!< Pointer to user registered NACK handler. */
- /* PID parity prror interrup handler */
- mss_uart_irq_handler_t pid_pei_handler; /*!< Pointer to user registered PID parity error handler. */
- /* LIN break interrupt handler */
- mss_uart_irq_handler_t break_handler; /*!< Pointer to user registered LIN break handler. */
- /* LIN sync detection interrupt handler */
- mss_uart_irq_handler_t sync_handler; /*!< Pointer to user registered LIN sync dectection handler. */
- };
- /***************************************************************************//**
- This instance of mss_uart_instance_t holds all data related to the operations
- performed by UART0. The function MSS_UART_init() initializes this structure.
- A pointer to g_mss_uart0 is passed as the first parameter to MSS UART driver
- functions to indicate that UART0 should perform the requested operation.
- */
- extern mss_uart_instance_t g_mss_uart0;
- /***************************************************************************//**
- This instance of mss_uart_instance_t holds all data related to the operations
- performed by UART1. The function MSS_UART_init() initializes this structure.
- A pointer to g_mss_uart1 is passed as the first parameter to MSS UART driver
- functions to indicate that UART1 should perform the requested operation.
- */
- extern mss_uart_instance_t g_mss_uart1;
- /***************************************************************************//**
- The MSS_UART_init() function initializes and configures one of the SmartFusion2
- MSS UARTs with the configuration passed as a parameter. The configuration
- parameters are the baud_rate which is used to generate the baud value and the
- line_config which is used to specify the line configuration (bit length,
- stop bits and parity).
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t structure
- identifying the MSS UART hardware block to be initialized. There are two
- such data structures, g_mss_uart0 and g_mss_uart1, associated with MSS
- UART0 and MSS UART1 respectively. This parameter must point to either
- the g_mss_uart0 or g_mss_uart1 global data structure defined within
- the UART driver..
- @param baud_rate
- The baud_rate parameter specifies the baud rate. It can be specified for
- common baud rates’ using the following defines:
- • MSS_UART_110_BAUD
- • MSS_UART_300_BAUD
- • MSS_UART_1200_BAUD
- • MSS_UART_2400_BAUD
- • MSS_UART_4800_BAUD
- • MSS_UART_9600_BAUD
- • MSS_UART_19200_BAUD
- • MSS_UART_38400_BAUD
- • MSS_UART_57600_BAUD
- • MSS_UART_115200_BAUD
- • MSS_UART_230400_BAUD
- • MSS_UART_460800_BAUD
- • MSS_UART_921600_BAUD
- Alternatively, any nonstandard baud rate can be specified by simply passing
- the actual required baud rate as the value for this parameter.
- @param line_config
- The line_config parameter is the line configuration specifying the bit length,
- number of stop bits and parity settings. This is a bitwise OR of one value
- from each of the following groups of allowed values:
- • One of the following to specify the transmit/receive data bit length:
- MSS_UART_DATA_5_BITS
- MSS_UART_DATA_6_BITS,
- MSS_UART_DATA_7_BITS
- MSS_UART_DATA_8_BITS
- • One of the following to specify the parity setting:
- MSS_UART_NO_PARITY
- MSS_UART_EVEN_PARITY
- MSS_UART_ODD_PARITY
- MSS_UART_STICK_PARITY_0
- MSS_UART_STICK_PARITY_1
- • One of the following to specify the number of stop bits:
- MSS_UART_ONE_STOP_BIT
- MSS_UART_ONEHALF_STOP_BIT
- MSS_UART_TWO_STOP_BITS
- @return
- This function does not return a value.
- Example:
- @code
- #include "mss_uart.h"
- int main(void)
- {
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
-
- return(0);
- }
- @endcode
- */
- void
- MSS_UART_init
- (
- mss_uart_instance_t* this_uart,
- uint32_t baud_rate,
- uint8_t line_config
- );
- /***************************************************************************//**
- The MSS_UART_lin_init() function is used to initialize the MSS UART for
- LIN mode of operation. The configuration parameters are the baud_rate which is
- used to generate the baud value and the line_config which is used to specify
- the line configuration (bit length, stop bits and parity).
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param baud_rate
- The baud_rate parameter specifies the baud rate. It can be specified for
- common baud rates’ using the following defines:
- • MSS_UART_110_BAUD
- • MSS_UART_300_BAUD
- • MSS_UART_1200_BAUD
- • MSS_UART_2400_BAUD
- • MSS_UART_4800_BAUD
- • MSS_UART_9600_BAUD
- • MSS_UART_19200_BAUD
- • MSS_UART_38400_BAUD
- • MSS_UART_57600_BAUD
- • MSS_UART_115200_BAUD
- • MSS_UART_230400_BAUD
- • MSS_UART_460800_BAUD
- • MSS_UART_921600_BAUD
- Alternatively, any nonstandard baud rate can be specified by simply passing
- the actual required baud rate as the value for this parameter.
- @param line_config
- The line_config parameter is the line configuration specifying the bit length,
- number of stop bits and parity settings. This is a bitwise OR of one value
- from each of the following groups of allowed values:
- • One of the following to specify the transmit/receive data bit length:
- MSS_UART_DATA_5_BITS
- MSS_UART_DATA_6_BITS,
- MSS_UART_DATA_7_BITS
- MSS_UART_DATA_8_BITS
- • One of the following to specify the parity setting:
- MSS_UART_NO_PARITY
- MSS_UART_EVEN_PARITY
- MSS_UART_ODD_PARITY
- MSS_UART_STICK_PARITY_0
- MSS_UART_STICK_PARITY_1
- • One of the following to specify the number of stop bits:
- MSS_UART_ONE_STOP_BIT
- MSS_UART_ONEHALF_STOP_BIT
- MSS_UART_TWO_STOP_BITS
- @return
- This function does not return a value.
- Example:
- @code
- #include "mss_uart.h"
- int main(void)
- {
- MSS_UART_lin_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
-
- return(0);
- }
- @endcode
- */
- void
- MSS_UART_lin_init
- (
- mss_uart_instance_t* this_uart,
- uint32_t baud_rate,
- uint8_t line_config
- );
- /***************************************************************************//**
- The MSS_UART_irda_init() function is used to initialize the MSS UART instance
- referenced by the parameter this_uart for IrDA mode of operation. This
- function must be called before calling any other IrDA functionality specific
- functions.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param baud_rate
- The baud_rate parameter specifies the baud rate. It can be specified for
- common baud rates’ using the following defines:
- • MSS_UART_110_BAUD
- • MSS_UART_300_BAUD
- • MSS_UART_1200_BAUD
- • MSS_UART_2400_BAUD
- • MSS_UART_4800_BAUD
- • MSS_UART_9600_BAUD
- • MSS_UART_19200_BAUD
- • MSS_UART_38400_BAUD
- • MSS_UART_57600_BAUD
- • MSS_UART_115200_BAUD
- • MSS_UART_230400_BAUD
- • MSS_UART_460800_BAUD
- • MSS_UART_921600_BAUD
- Alternatively, any nonstandard baud rate can be specified by simply passing
- the actual required baud rate as the value for this parameter.
- @param line_config
- The line_config parameter is the line configuration specifying the bit length,
- number of stop bits and parity settings. This is a bitwise OR of one value
- from each of the following groups of allowed values:
- • One of the following to specify the transmit/receive data bit length:
- MSS_UART_DATA_5_BITS
- MSS_UART_DATA_6_BITS,
- MSS_UART_DATA_7_BITS
- MSS_UART_DATA_8_BITS
- • One of the following to specify the parity setting:
- MSS_UART_NO_PARITY
- MSS_UART_EVEN_PARITY
- MSS_UART_ODD_PARITY
- MSS_UART_STICK_PARITY_0
- MSS_UART_STICK_PARITY_1
- • One of the following to specify the number of stop bits:
- MSS_UART_ONE_STOP_BIT
- MSS_UART_ONEHALF_STOP_BIT
- MSS_UART_TWO_STOP_BITS
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_irda_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT,
- MSS_UART_ACTIVE_LOW,
- MSS_UART_ACTIVE_LOW,
- MSS_UART_3_BY_16);
- @endcode
- */
- void
- MSS_UART_irda_init
- (
- mss_uart_instance_t* this_uart,
- uint32_t baud_rate,
- uint8_t line_config,
- mss_uart_rzi_polarity_t rxpol,
- mss_uart_rzi_polarity_t txpol,
- mss_uart_rzi_pulsewidth_t pw
- );
- /***************************************************************************//**
- The MSS_UART_smartcard_init() function is used to initialize the MSS UART
- for ISO 7816 (smartcard) mode of operation. The configuration parameters are
- the baud_rate which is used to generate the baud value and the line_config
- which is used to specify the line configuration (bit length, stop bits and parity).
- This function disables all other modes of the MSS UART instance pointed by
- the parameter this_uart.
-
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param baud_rate
- The baud_rate parameter specifies the baud rate. It can be specified for
- common baud rates’ using the following defines:
- • MSS_UART_110_BAUD
- • MSS_UART_300_BAUD
- • MSS_UART_1200_BAUD
- • MSS_UART_2400_BAUD
- • MSS_UART_4800_BAUD
- • MSS_UART_9600_BAUD
- • MSS_UART_19200_BAUD
- • MSS_UART_38400_BAUD
- • MSS_UART_57600_BAUD
- • MSS_UART_115200_BAUD
- • MSS_UART_230400_BAUD
- • MSS_UART_460800_BAUD
- • MSS_UART_921600_BAUD
- Alternatively, any nonstandard baud rate can be specified by simply passing
- the actual required baud rate as the value for this parameter.
- @param line_config
- The line_config parameter is the line configuration specifying the bit length,
- number of stop bits and parity settings. This is a bitwise OR of one value
- from each of the following groups of allowed values:
- • One of the following to specify the transmit/receive data bit length:
- MSS_UART_DATA_5_BITS
- MSS_UART_DATA_6_BITS,
- MSS_UART_DATA_7_BITS
- MSS_UART_DATA_8_BITS
- • One of the following to specify the parity setting:
- MSS_UART_NO_PARITY
- MSS_UART_EVEN_PARITY
- MSS_UART_ODD_PARITY
- MSS_UART_STICK_PARITY_0
- MSS_UART_STICK_PARITY_1
- • One of the following to specify the number of stop bits:
- MSS_UART_ONE_STOP_BIT
- MSS_UART_ONEHALF_STOP_BIT
- MSS_UART_TWO_STOP_BITS
- @return
- This function does not return a value.
- Example:
- @code
- #include "mss_uart.h"
- int main(void)
- {
- MSS_UART_smartcard_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
-
- return(0);
- }
- @endcode
- */
- void
- MSS_UART_smartcard_init
- (
- mss_uart_instance_t* this_uart,
- uint32_t baud_rate,
- uint8_t line_config
- );
- /***************************************************************************//**
- The function MSS_UART_polled_tx() is used to transmit data. It transfers the
- contents of the transmitter data buffer, passed as a function parameter, into
- the UART’s hardware transmitter FIFO. It returns when the full content of the
- transmit data buffer has been transferred to the UART’s transmit FIFO. It is
- safe to release or reuse the memory used as the transmitter data buffer once
- this function returns.
- Note: This function reads the UART’s line status register (LSR) to poll
- for the active state of the transmitter holding register empty (THRE) bit
- before transferring data from the data buffer to the transmitter FIFO. It
- transfers data to the transmitter FIFO in blocks of 16 bytes or less and
- allows the FIFO to empty before transferring the next block of data.
- Note: The actual transmission over the serial connection will still be
- in progress when this function returns. Use the MSS_UART_get_tx_status()
- function if you need to know when the transmitter is empty.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param pbuff
- The pbuff parameter is a pointer to a buffer containing the data to
- be transmitted.
- @param tx_size
- The tx_size parameter specifies the size, in bytes, of the data to
- be transmitted.
- @return
- This function does not return a value.
- Example:
- @code
- #include "mss_uart.h"
- int main(void)
- {
- uint8_t message[12] = "Hello World";
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
-
- MSS_UART_polled_tx(&g_mss_uart0, message, sizeof(message));
-
- return(0);
- }
- @endcode
- */
- void
- MSS_UART_polled_tx
- (
- mss_uart_instance_t * this_uart,
- const uint8_t * pbuff,
- uint32_t tx_size
- );
- /***************************************************************************//**
- The function MSS_UART_polled_tx_string() is used to transmit a NULL ('\0')
- terminated string. It transfers the text string, from the buffer starting at
- the address pointed to by p_sz_string into the UART’s hardware transmitter
- FIFO. It returns when the complete string has been transferred to the UART's
- transmit FIFO. It is safe to release or reuse the memory used as the string
- buffer once this function returns.
- Note: This function reads the UART’s line status register (LSR) to poll
- for the active state of the transmitter holding register empty (THRE) bit
- before transferring data from the data buffer to the transmitter FIFO. It
- transfers data to the transmitter FIFO in blocks of 16 bytes or less and
- allows the FIFO to empty before transferring the next block of data.
- Note: The actual transmission over the serial connection will still be
- in progress when this function returns. Use the MSS_UART_get_tx_status()
- function if you need to know when the transmitter is empty.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param p_sz_string
- The p_sz_string parameter is a pointer to a buffer containing the NULL
- ('\0') terminated string to be transmitted.
- @return
- This function does not return a value.
- Example:
- @code
- #include "mss_uart.h"
- int main(void)
- {
- uint8_t message[12] = "Hello World";
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
-
- MSS_UART_polled_tx_string(&g_mss_uart0, message);
-
- return(0);
- }
- @endcode
- */
- void
- MSS_UART_polled_tx_string
- (
- mss_uart_instance_t * this_uart,
- const uint8_t * p_sz_string
- );
- /***************************************************************************//**
- The function MSS_UART_irq_tx() is used to initiate an interrupt-driven
- transmit. It returns immediately after making a note of the transmit buffer
- location and enabling transmit interrupts both at the UART and Cortex-M3 NVIC
- level. This function takes a pointer via the pbuff parameter to a memory
- buffer containing the data to transmit. The memory buffer specified through
- this pointer must remain allocated and contain the data to transmit until
- the transmit completion has been detected through calls to function
- MSS_UART_tx_complete(). The actual transmission over the serial connection
- is still in progress until calls to the MSS_UART_tx_complete() function
- indicate transmit completion.
- Note: The MSS_UART_irq_tx() function enables both the transmit holding
- register empty (THRE) interrupt in the UART and the MSS UART instance
- interrupt in the Cortex-M3 NVIC as part of its implementation.
- Note: The MSS_UART_irq_tx() function assigns an internal default transmit
- interrupt handler function to the UART’s THRE interrupt. This interrupt
- handler overrides any custom interrupt handler that you may have previously
- registered using the MSS_UART_set_tx_handler() function.
- Note: The MSS_UART_irq_tx() function’s default transmit interrupt
- handler disables the UART’s THRE interrupt when all of the data has
- been transferred to the UART's transmit FIFO.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param pbuff
- The pbuff parameter is a pointer to a buffer containing the data
- to be transmitted.
- @param tx_size
- The tx_size parameter specifies the size, in bytes, of the data
- to be transmitted.
- @return
- This function does not return a value.
- Example:
- @code
- #include "mss_uart.h"
- int main(void)
- {
- uint8_t tx_buff[10] = "abcdefghi";
-
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
-
- MSS_UART_irq_tx(&g_mss_uart0, tx_buff, sizeof(tx_buff));
-
- while(0 == MSS_UART_tx_complete(&g_mss_uart0))
- {
- ;
- }
- return(0);
- }
- @endcode
- */
- void
- MSS_UART_irq_tx
- (
- mss_uart_instance_t * this_uart,
- const uint8_t * pbuff,
- uint32_t tx_size
- );
- /***************************************************************************//**
- The MSS_UART_tx_complete() function is used to find out if the interrupt-driven
- transmit previously initiated through a call to MSS_UART_irq_tx() is complete.
- This is typically used to find out when it is safe to reuse or release the
- memory buffer holding transmit data.
- Note: The transfer of all of the data from the memory buffer to the UART’s
- transmit FIFO and the actual transmission over the serial connection are both
- complete when a call to the MSS_UART_tx_complete() function indicates transmit
- completion.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function return a non-zero value if transmit has completed, otherwise
- it returns zero.
- Example:
- See the MSS_UART_irq_tx() function for an example that uses the
- MSS_UART_tx_complete() function.
- */
- int8_t
- MSS_UART_tx_complete
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_get_rx() function reads the content of the UART receiver’s FIFO
- and stores it in the receive buffer that is passed via the rx_buff function
- parameter. It copies either the full contents of the FIFO into the receive
- buffer, or just enough data from the FIFO to fill the receive buffer,
- dependent upon the size of the receive buffer passed by the buff_size
- parameter. The MSS_UART_get_rx() function returns the number of bytes copied
- into the receive buffer .This function is non-blocking and will return 0
- immediately if no data has been received.
- Note: The MSS_UART_get_rx() function reads and accumulates the receiver
- status of the MSS UART instance before reading each byte from the receiver's
- data register/FIFO. This allows the driver to maintain a sticky record of any
- receiver errors that occur as the UART receives each data byte; receiver
- errors would otherwise be lost after each read from the receiver's data register.
- A call to the MSS_UART_get_rx_status() function returns any receiver errors
- accumulated during the execution of the MSS_UART_get_rx() function.
- Note: If you need to read the error status for each byte received, set
- the buff_size to 1 and read the receive line error status for each byte
- using the MSS_UART_get_rx_status() function.
- The MSS_UART_get_rx() function can be used in polled mode, where it is called
- at regular intervals to find out if any data has been received, or in interrupt
- driven-mode, where it is called as part of a receive handler that is called
- by the driver as a result of data being received.
- Note: In interrupt driven mode you should call the MSS_UART_get_rx()
- function as part of the receive handler function that you register with
- the MSS UART driver through a call to MSS_UART_set_rx_handler().
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param rx_buff
- The rx_buff parameter is a pointer to a buffer where the received
- data is copied.
- @param buff_size
- The buff_size parameter specifies the size of the receive buffer in bytes.
- @return
- This function returns the number of bytes that were copied into the
- rx_buff buffer. It returns 0 if no data has been received.
- Polled mode example:
- @code
- int main( void )
- {
- uint8_t rx_buff[RX_BUFF_SIZE];
- uint32_t rx_idx = 0;
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
-
- while(1)
- {
- rx_size = MSS_UART_get_rx(&g_mss_uart0, rx_buff, sizeof(rx_buff));
- if(rx_size > 0)
- {
- process_rx_data(rx_buff, rx_size);
- }
- task_a();
- task_b();
- }
- return 0;
- }
- @endcode
- Interrupt driven example:
- @code
- int main( void )
- {
- MSS_UART_init(&g_mss_uart1,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
-
- MSS_UART_set_rx_handler(&g_mss_uart1,
- uart1_rx_handler,
- MSS_UART_FIFO_SINGLE_BYTE);
-
- while(1)
- {
- task_a();
- task_b();
- }
- return 0;
- }
- void uart1_rx_handler(mss_uart_instance_t * this_uart)
- {
- uint8_t rx_buff[RX_BUFF_SIZE];
- uint32_t rx_idx = 0;
- rx_size = MSS_UART_get_rx(this_uart, rx_buff, sizeof(rx_buff));
- process_rx_data(rx_buff, rx_size);
- }
- @endcode
- */
- size_t
- MSS_UART_get_rx
- (
- mss_uart_instance_t * this_uart,
- uint8_t * rx_buff,
- size_t buff_size
- );
- /***************************************************************************//**
- The MSS_UART_set_rx_handler() function is used to register a receive handler
- function that is called by the driver when a UART receive data available (RDA)
- interrupt occurs. You must create and register the receive handler function
- to suit your application and it must include a call to the MSS_UART_get_rx()
- function to actually read the received data.
- Note: The MSS_UART_set_rx_handler() function enables both the RDA
- interrupt in the UART and the MSS UART instance interrupt in the Cortex-M3
- NVIC as part
- of its implementation.
- Note: You can disable the RDA interrupt once the data is received by
- calling the MSS_UART_disable_irq() function. This is your choice and is
- dependent upon your application.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param handler
- The handler parameter is a pointer to a receive interrupt handler function
- provided by your application that will be called as a result of a UART RDA
- interrupt. This handler function must be of type mss_uart_irq_handler_t.
- @param trigger_level
- The trigger_level parameter is the receive FIFO trigger level. This
- specifies the number of bytes that must be received before the UART
- triggers an RDA interrupt.
- @return
- This function does not return a value.
- Example:
- @code
- #include "mss_uart.h"
- #define RX_BUFF_SIZE 64
- uint8_t g_rx_buff[RX_BUFF_SIZE];
- void uart0_rx_handler(mss_uart_instance_t * this_uart)
- {
- MSS_UART_get_rx(this_uart, &g_rx_buff[g_rx_idx], sizeof(g_rx_buff));
- }
- int main(void)
- {
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
-
- MSS_UART_set_rx_handler(&g_mss_uart0,
- uart0_rx_handler,
- MSS_UART_FIFO_SINGLE_BYTE);
-
- while(1)
- {
- ;
- }
- return(0);
- }
- @endcode
- */
- void
- MSS_UART_set_rx_handler
- (
- mss_uart_instance_t * this_uart,
- mss_uart_irq_handler_t handler,
- mss_uart_rx_trig_level_t trigger_level
- );
- /***************************************************************************//**
- The MSS_UART_set_loopback() function is used to locally loopback the Tx and
- Rx lines of a UART. This is not to be confused with the loopback of UART0
- to UART1, which can be achieved through the microcontroller subsystem’s
- system registers.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param loopback
- The loopback parameter indicates whether or not the UART’s transmit
- and receive lines should be looped back. Allowed values are as follows:
- - MSS_UART_LOCAL_LOOPBACK_ON
- - MSS_UART_LOCAL_LOOPBACK_OFF
- - MSS_UART_REMOTE_LOOPBACK_ON
- - MSS_UART_REMOTE_LOOPBACK_OFF
- - MSS_UART_AUTO_ECHO_ON
- - MSS_UART_AUTO_ECHO_OFF
-
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_set_loopback(&g_mss_uart0, MSS_UART_LOCAL_LOOPBACK_OFF);
- @endcode
- */
- void
- MSS_UART_set_loopback
- (
- mss_uart_instance_t * this_uart,
- mss_uart_loopback_t loopback
- );
- /***************************************************************************//**
- The MSS_UART_enable_irq() function enables the MSS UART interrupts specified
- by the irq_mask parameter. The irq_mask parameter identifies the MSS UART
- interrupts by bit position, as defined in the interrupt enable register (IER)
- of MSS UART. The MSS UART interrupts and their identifying irq_mask bit
- positions are as follows:
- When an irq_mask bit position is set to 1, this function enables the
- corresponding MSS UART interrupt in the IER register. When an irq_mask bit
- position is set to 0, the corresponding interrupt’s state remains unchanged in
- the IER register.
- Note: The MSS_UART_enable_irq() function also enables the MSS UART instance
- interrupt in the Cortex-M3 NVIC.
-
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t structure
- identifying the MSS UART hardware block that will perform the requested
- function. There are two such data structures, g_mss_uart0 and g_mss_uart1,
- associated with MSS UART0 and MSS UART1. This parameter must point to either
- the g_mss_uart0 or g_mss_uart1 global data structure defined within the UART
- driver.
- @param irq_mask
- The irq_mask parameter is used to select which of the MSS UART’s interrupts
- you want to enable. The allowed value for the irq_mask parameter is one of
- the following constants or a bitwise OR of more than one:
- - MSS_UART_RBF_IRQ (bit mask = 0x001)
- - MSS_UART_TBE_IRQ (bit mask = 0x002)
- - MSS_UART_LS_IRQ (bit mask = 0x004)
- - MSS_UART_MS_IRQ (bit mask = 0x008)
- - MSS_UART_RTO_IRQ (bit mask = 0x010)
- - MSS_UART_NACK_IRQ (bit mask = 0x020)
- - MSS_UART_PIDPE_IRQ (bit mask = 0x040)
- - MSS_UART_LINB_IRQ (bit mask = 0x080)
- - MSS_UART_LINS_IRQ (bit mask = 0x100)
-
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_enable_irq(&g_mss_uart0,(MSS_UART_RBF_IRQ | MSS_UART_TBE_IRQ));
- @endcode
- */
- void
- MSS_UART_enable_irq
- (
- mss_uart_instance_t * this_uart,
- mss_uart_irq_t irq_mask
- );
- /***************************************************************************//**
- The MSS_UART_disable_irq() function disables the MSS UART interrupts specified
- by the irq_mask parameter. The irq_mask parameter identifies the MSS UART
- interrupts by bit position, as defined in the interrupt enable register (IER)
- of MSS UART. The MSS UART interrupts and their identifying bit positions are
- as follows:
- When an irq_mask bit position is set to 1, this function disables the
- corresponding MSS UART interrupt in the IER register. When an irq_mask bit
- position is set to 0, the corresponding interrupt’s state remains unchanged in
- the IER register.
- Note: If you disable all four of the UART’s interrupts, the
- MSS_UART_disable_irq() function also disables the MSS UART instance
- interrupt in the Cortex-M3 NVIC.
-
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param irq_mask
- The irq_mask parameter is used to select which of the MSS UART’s interrupts
- you want to disable. The allowed value for the irq_mask parameter is one of
- the following constants or a bitwise OR of more than one:
- - MSS_UART_RBF_IRQ (bit mask = 0x001)
- - MSS_UART_TBE_IRQ (bit mask = 0x002)
- - MSS_UART_LS_IRQ (bit mask = 0x004)
- - MSS_UART_MS_IRQ (bit mask = 0x008)
- - MSS_UART_RTO_IRQ (bit mask = 0x010)
- - MSS_UART_NACK_IRQ (bit mask = 0x020)
- - MSS_UART_PIDPE_IRQ (bit mask = 0x040)
- - MSS_UART_LINB_IRQ (bit mask = 0x080)
- - MSS_UART_LINS_IRQ (bit mask = 0x100)
-
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_disable_irq(&g_mss_uart0, (MSS_UART_RBF_IRQ | MSS_UART_TBE_IRQ));
- @endcode
- */
- void
- MSS_UART_disable_irq
- (
- mss_uart_instance_t * this_uart,
- mss_uart_irq_t irq_mask
- );
- /***************************************************************************//**
- The MSS_UART_set_pidpei_handler() function is used assign a custom interrupt
- handler for the PIDPEI (PID parity error interrupt) when the MSS UART is
- operating in LIN mode.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param handler
- The handler parameter is the pointer to the custom handler function.
- This parameter is of type mss_uart_irq_handler_t.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_ set_pidpei_handler(&g_mss_uart0, my_pidpei_handler);
- @endcode
- */
- void
- MSS_UART_set_pidpei_handler
- (
- mss_uart_instance_t * this_uart,
- mss_uart_irq_handler_t handler
- );
- /***************************************************************************//**
- The MSS_UART_set_linbreak_handler () function is used assign a custom
- interrupt handler for the LIN Break detection interrupt when the MSS UART
- is operating in LIN mode.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param handler
- The handler parameter is the pointer to the custom handler function.
- This parameter is of type mss_uart_irq_handler_t.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_set_linbreak_handler(&g_mss_uart0, my_break_handler);
- @endcode
- */
- void
- MSS_UART_set_linbreak_handler
- (
- mss_uart_instance_t * this_uart,
- mss_uart_irq_handler_t handler
- );
- /***************************************************************************//**
- The MSS_UART_set_linsync_handler() function is used assign a custom interrupt
- handler for the LIN Sync character detection interrupt when the MSS UART
- is operating in LIN mode.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param handler
- The handler parameter is the pointer to the custom handler function.
- This parameter is of type mss_uart_irq_handler_t.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_set_linsync_handler(&g_mss_uart0, my_linsync_handler);
- @endcode
- */
- void
- MSS_UART_set_linsync_handler
- (
- mss_uart_instance_t * this_uart,
- mss_uart_irq_handler_t handler
- );
- /***************************************************************************//**
- The MSS_UART_set_nack_handler() function is used assign a custom interrupt
- handler for the NACK character detection interrupt when the MSS UART
- is operating in Smartcard mode.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param handler
- The handler parameter is the pointer to the custom handler function.
- This parameter is of type mss_uart_irq_handler_t.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_set_nack_handler(&g_mss_uart0, my_nack_handler);
- @endcode
- */
- void
- MSS_UART_set_nack_handler
- (
- mss_uart_instance_t * this_uart,
- mss_uart_irq_handler_t handler
- );
- /***************************************************************************//**
- The MSS_UART_set_rx_timeout_handler() function is used assign a custom
- interrupt handler for the receiver timeout interrupt when the MSS UART is
- operating in mode. It finds application in IrDA mode of operation.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param handler
- The handler parameter is the pointer to the custom handler function.
- This parameter is of type mss_uart_irq_handler_t.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_set_rx_timeout_handler(&g_mss_uart0, my_rxtimeout_handler);
- @endcode
- */
- void
- MSS_UART_set_rx_timeout_handler
- (
- mss_uart_instance_t * this_uart,
- mss_uart_irq_handler_t handler
- );
- /***************************************************************************//**
- The MSS_UART_set_rxstatus_handler() function is used to register a receiver
- status handler function that is called by the driver when a UART receiver
- line status (RLS) interrupt occurs. You must create and register the handler
- function to suit your application.
- Note: The MSS_UART_set_rxstatus_handler() function enables both the RLS
- interrupt in the UART and the MSS UART instance interrupt in the Cortex-M3
- NVIC as part of its implementation.
- Note: You can disable the RLS interrupt when required by calling the
- MSS_UART_disable_irq() function. This is your choice and is dependent upon
- your application.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param handler
- The handler parameter is a pointer to a receiver line status interrupt
- handler function provided by your application that will be called as a
- result of a UART RLS interrupt. This handler function must be of type
- mss_uart_irq_handler_t.
- @return
- This function does not return a value.
- Example:
- @code
- #include "mss_uart.h"
- void uart_rxsts_handler(mss_uart_instance_t * this_uart)
- {
- uint8_t status;
- status = MSS_UART_get_rx_status(this_uart);
- if(status & MSS_UART_OVERUN_ERROR)
- {
- discard_rx_data();
- }
- }
- int main(void)
- {
- MSS_UART_init( &g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY |
- MSS_UART_ONE_STOP_BIT );
-
- MSS_UART_set_rxstatus_handler(&g_mss_uart0, uart_rxsts_handler);
- while(1)
- {
- ;
- }
- return(0);
- }
- @endcode
- */
- void
- MSS_UART_set_rxstatus_handler
- (
- mss_uart_instance_t * this_uart,
- mss_uart_irq_handler_t handler
- );
- /***************************************************************************//**
- The MSS_UART_set_tx_handler() function is used to register a transmit handler
- function that is called by the driver when a UART transmit holding register
- empty (THRE) interrupt occurs. You must create and register the transmit
- handler function to suit your application. You can use the
- MSS_UART_fill_tx_fifo() function in your transmit handler function to
- write data to the transmitter.
- Note: The MSS_UART_set_tx_handler() function enables both the THRE
- interrupt in the UART and the MSS UART instance interrupt in the Cortex-M3
- NVIC as part of its implementation.
- Note: You can disable the THRE interrupt when required by calling the
- MSS_UART_disable_irq() function. This is your choice and is dependent upon
- your application.
- Note: The MSS_UART_irq_tx() function does not use the transmit handler
- function that you register with the MSS_UART_set_tx_handler() function.
- It uses its own internal THRE interrupt handler function that overrides
- any custom interrupt handler that you register using the
- MSS_UART_set_tx_handler() function.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param handler
- The handler parameter is a pointer to a transmit interrupt handler
- function provided by your application that will be called as a result
- of a UART THRE interrupt. This handler function must be of type
- mss_uart_irq_handler_t.
- @return
- This function does not return a value.
- Example:
- @code
- #include "mss_uart.h"
- uint8_t * g_tx_buffer;
- size_t g_tx_size = 0;
- void uart_tx_handler(mss_uart_instance_t * this_uart)
- {
- size_t size_in_fifo;
- size_in_fifo = MSS_UART_fill_tx_fifo(this_uart,
- (const uint8_t *)g_tx_buffer,
- g_tx_size);
-
- if(size_in_fifo == g_tx_size)
- {
- g_tx_size = 0;
- MSS_UART_disable_irq(this_uart, MSS_UART_TBE_IRQ);
- }
- else
- {
- g_tx_buffer = &g_tx_buffer[size_in_fifo];
- g_tx_size = g_tx_size - size_in_fifo;
- }
- }
- int main(void)
- {
- uint8_t message[12] = "Hello world";
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY |
- MSS_UART_ONE_STOP_BIT);
- g_tx_buffer = message;
- g_tx_size = sizeof(message);
- MSS_UART_set_tx_handler(&g_mss_uart0, uart_tx_handler);
- while(1)
- {
- ;
- }
- return(0);
- }
- @endcode
- */
- void
- MSS_UART_set_tx_handler
- (
- mss_uart_instance_t * this_uart,
- mss_uart_irq_handler_t handler
- );
- /***************************************************************************//**
- The MSS_UART_set_modemstatus_handler() function is used to register a modem
- status handler function that is called by the driver when a UART modem status
- (MS) interrupt occurs. You must create and register the handler function to
- suit your application.
- Note: The MSS_UART_set_modemstatus_handler() function enables both the MS
- interrupt in the UART and the MSS UART instance interrupt in the Cortex-M3 NVIC
- as part of its implementation.
- Note: You can disable the MS interrupt when required by calling the
- MSS_UART_disable_irq() function. This is your choice and is dependent
- upon your application.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param handler
- The handler parameter is a pointer to a modem status interrupt handler
- function provided by your application that will be called as a result
- of a UART MS interrupt. This handler function must be of type
- mss_uart_irq_handler_t.
- @return
- This function does not return a value.
- Example:
- @code
- #include "mss_uart.h"
- void uart_modem_handler(mss_uart_instance_t * this_uart)
- {
- uint8_t status;
- status = MSS_UART_get_modem_status(this_uart);
- if(status & MSS_UART_CTS)
- {
- uart_cts_handler();
- }
- }
- int main(void)
- {
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY |
- MSS_UART_ONE_STOP_BIT);
- MSS_UART_set_modemstatus_handler(&g_mss_uart0, uart_modem_handler);
- while(1)
- {
- ;
- }
- return(0);
- }
- @endcode
- */
- void
- MSS_UART_set_modemstatus_handler
- (
- mss_uart_instance_t * this_uart,
- mss_uart_irq_handler_t handler
- );
- /***************************************************************************//**
- The MSS_UART_fill_tx_fifo() function fills the UART's hardware transmitter
- FIFO with the data found in the transmitter buffer that is passed via the
- tx_buffer function parameter. If the transmitter FIFO is not empty when
- the function is called, the function returns immediately without transferring
- any data to the FIFO; otherwise, the function transfers data from the
- transmitter buffer to the FIFO until it is full or until the complete
- contents of the transmitter buffer have been copied into the FIFO. The
- function returns the number of bytes copied into the UART's transmitter FIFO.
- Note: This function reads the UART’s line status register (LSR) to check
- for the active state of the transmitter holding register empty (THRE) bit
- before transferring data from the data buffer to the transmitter FIFO. If
- THRE is 0, the function returns immediately, without transferring any data
- to the FIFO. If THRE is 1, the function transfers up to 16 bytes of data
- to the FIFO and then returns.
- Note: The actual transmission over the serial connection will still be
- in progress when this function returns. Use the MSS_UART_get_tx_status()
- function if you need to know when the transmitter is empty.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param tx_buffer
- The tx_buffer parameter is a pointer to a buffer containing the data
- to be transmitted.
- @param tx_size
- The tx_size parameter is the size in bytes, of the data to be transmitted.
- @return
- This function returns the number of bytes copied into the UART's
- transmitter FIFO.
- Example:
- @code
- void send_using_interrupt(uint8_t * pbuff, size_t tx_size)
- {
- size_t size_in_fifo;
- size_in_fifo = MSS_UART_fill_tx_fifo(&g_mss_uart0, pbuff, tx_size);
- }
- @endcode
- */
- size_t
- MSS_UART_fill_tx_fifo
- (
- mss_uart_instance_t * this_uart,
- const uint8_t * tx_buffer,
- size_t tx_size
- );
- /***************************************************************************//**
- The MSS_UART_get_rx_status() function returns the receiver error status of the
- MSS UART instance. It reads both the current error status of the receiver from
- the UART’s line status register (LSR) and the accumulated error status from
- preceding calls to the MSS_UART_get_rx() function, and it combines them using
- a bitwise OR. It returns the cumulative overrun, parity, framing, break and
- FIFO error status of the receiver, since the previous call to
- MSS_UART_get_rx_status(), as an 8-bit encoded value.
- Note: The MSS_UART_get_rx() function reads and accumulates the receiver
- status of the MSS UART instance before reading each byte from the receiver’s
- data register/FIFO. The driver maintains a sticky record of the cumulative
- receiver error status, which persists after the MSS_UART_get_rx() function
- returns. The MSS_UART_get_rx_status() function clears the driver’s sticky
- receiver error record before returning.
- Note: The driver’s transmit functions also read the line status
- register (LSR) as part of their implementation. When the driver reads the
- LSR, the UART clears any active receiver error bits in the LSR. This could
- result in the driver losing receiver errors. To avoid any loss of receiver
- errors, the transmit functions also update the driver’s sticky record of the
- cumulative receiver error status whenever they read the LSR.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function returns the UART’s receiver error status as an 8-bit unsigned
- integer. The returned value is 0 if no receiver errors occurred. The driver
- provides a set of bit mask constants that should be compared with and/or
- used to mask the returned value to determine the receiver error status.
- When the return value is compared to the following bit masks, a non-zero
- result indicates that the corresponding error occurred:
- • MSS_UART_OVERRUN_ERROR (bit mask = 0x02)
- • MSS_UART_PARITY_ERROR (bit mask = 0x04)
- • MSS_UART_FRAMING_ERROR (bit mask = 0x08)
- • MSS_UART_BREAK_ERROR (bit mask = 0x10)
- • MSS_UART_FIFO_ERROR (bit mask = 0x80)
- When the return value is compared to the following bit mask, a non-zero
- result indicates that no error occurred:
- • MSS_UART_NO_ERROR (bit mask = 0x00)
- Upon unsuccessful execution, this function returns:
- • MSS_UART_INVALID_PARAM (bit mask = 0xFF)
- Example:
- @code
- uint8_t rx_data[MAX_RX_DATA_SIZE];
- uint8_t err_status;
- err_status = MSS_UART_get_rx_status(&g_mss_uart0);
- if(MSS_UART_NO_ERROR == err_status)
- {
- rx_size = MSS_UART_get_rx(&g_mss_uart0, rx_data, MAX_RX_DATA_SIZE);
- }
- @endcode
- */
- uint8_t
- MSS_UART_get_rx_status
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_get_modem_status() function returns the modem status of the
- MSS UART instance. It reads the modem status register (MSR) and returns
- the 8 bit value. The bit encoding of the returned value is exactly the
- same as the definition of the bits in the MSR.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function returns current state of the UART's MSR as an 8 bit
- unsigned integer. The driver provides the following set of bit mask
- constants that should be compared with and/or used to mask the
- returned value to determine the modem status:
- • MSS_UART_DCTS (bit mask = 0x01)
- • MSS_UART_DDSR (bit mask = 0x02)
- • MSS_UART_TERI (bit mask = 0x04)
- • MSS_UART_DDCD (bit mask = 0x08)
- • MSS_UART_CTS (bit mask = 0x10)
- • MSS_UART_DSR (bit mask = 0x20)
- • MSS_UART_RI (bit mask = 0x40)
- • MSS_UART_DCD (bit mask = 0x80)
- Example:
- @code
- void uart_modem_status_isr(mss_uart_instance_t * this_uart)
- {
- uint8_t status;
- status = MSS_UART_get_modem_status(this_uart);
- if( status & MSS_UART_DCTS )
- {
- uart_dcts_handler();
- }
- if( status & MSS_UART_CTS )
- {
- uart_cts_handler();
- }
- }
- @endcode
- */
- uint8_t
- MSS_UART_get_modem_status
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_get_tx_status() function returns the transmitter status of the
- MSS UART instance. It reads both the UART’s line status register (LSR) and
- returns the status of the transmit holding register empty (THRE) and
- transmitter empty (TEMT) bits.*
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function returns the UART’s transmitter status as an 8-bit unsigned
- integer. The returned value is 0 if the transmitter status bits are not
- set or the function execution failed. The driver provides a set of bit
- mask constants that should be compared with and/or used to mask the
- returned value to determine the transmitter status.
- When the return value is compared to the following bit mask, a non-zero
- result indicates that the corresponding transmitter status bit is set:
- • MSS_UART_THRE (bit mask = 0x20)
- • MSS_UART_TEMT (bit mask = 0x40)
- When the return value is compared to the following bit mask, a non-zero
- result indicates that the transmitter is busy or the function execution
- failed.
- • MSS_UART_TX_BUSY (bit mask = 0x00)
- Example:
- @code
- uint8_t tx_buff[10] = "abcdefghi";
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_polled_tx(&g_mss_uart0, tx_buff, sizeof(tx_buff));
- while(!(MSS_UART_TEMT & MSS_UART_get_tx_status(&g_mss_uart0)))
- {
- ;
- }
- @endcode
- */
- uint8_t
- MSS_UART_get_tx_status
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_set_break() function is used to send the break
- (9 zeros after stop bit) signal on the TX line. This function can be used
- only when the MSS UART is initialized in LIN mode by using MSS_UART_lin_init().
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
-
- MSS_UART_set_break(&g_mss_uart0);
- @endcode
- */
- void
- MSS_UART_set_break
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_clear_break() function is used to remove the break signal on the
- TX line. This function can be used only when the MSS UART is initialized in
- LIN mode by using MSS_UART_lin_init().
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_clear_break(&g_mss_uart0);
- @endcode
- */
- void
- MSS_UART_clear_break
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_enable_half_duplex() function is used to enable the half-duplex
- (single wire) mode for the MSS UART. Though it finds application in Smartcard
- mode, half-duplex mode can be used in other modes as well.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_enable_half_duplex(&g_mss_uart0);
- @endcode
- */
- void
- MSS_UART_enable_half_duplex
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_disable_half_duplex() function is used to disable the half-duplex
- (single wire) mode for the MSS UART. Though it finds application in Smartcard
- mode, half-duplex mode can be used in other modes as well.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_disable_half_duplex(&g_mss_uart0);
- @endcode
- */
- void
- MSS_UART_disable_half_duplex
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_set_rx_endian() function is used to configure the LSB first or
- MSB first setting for MSS UART receiver
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
-
- @param endian
- The endian parameter tells the LSB first or MSB first configuration.
- This parameter is of type mss_uart_endian_t.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_set_rx_endian(&g_mss_uart0, MSS_UART_LITTLEEND);
- @endcode
- */
- void
- MSS_UART_set_rx_endian
- (
- mss_uart_instance_t * this_uart,
- mss_uart_endian_t endian
- );
- /***************************************************************************//**
- The MSS_UART_set_tx_endian() function is used to configure the LSB first or
- MSB first setting for MSS UART transmitter.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param endian
- The endian parameter tells the LSB first or MSB first configuration.
- This parameter is of type mss_uart_endian_t.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_set_tx_endian(&g_mss_uart0, MSS_UART_LITTLEEND);
- @endcode
- */
- void
- MSS_UART_set_tx_endian
- (
- mss_uart_instance_t * this_uart,
- mss_uart_endian_t endian
- );
- /***************************************************************************//**
- The MSS_UART_set_filter_length () function is used to configure the glitch
- filter length of the MSS UART. This should be configured in accordance with
- the chosen baud rate.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param length
- The length parameter is of mss_uart_filter_length_t type that determines
- the length of the glitch filter.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_set_filter_length(&g_mss_uart0, MSS_UART_LEN2);
- @endcode
- */
- void
- MSS_UART_set_filter_length
- (
- mss_uart_instance_t * this_uart,
- mss_uart_filter_length_t length
- );
- /***************************************************************************//**
- The MSS_UART_enable_afm() function is used to enable address flag detection
- mode of the MSS UART
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_enable_afm(&g_mss_uart0);
- @endcode
- */
- void
- MSS_UART_enable_afm
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_disable_afm() function is used to disable address flag detection
- mode of the MSS UART.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_disable_afm(&g_mss_uart0);
- @endcode
- */
- void
- MSS_UART_disable_afm
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_enable_afclear () function is used to enable address flag clear
- of the MSS UART. This should be used in conjunction with address flag
- detection mode (AFM).
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_enable_afclear(&g_mss_uart0);
- @endcode
- */
- void
- MSS_UART_enable_afclear
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_disable_afclear () function is used to disable address flag
- clear of the MSS UART. This should be used in conjunction with address flag
- detection mode (AFM).
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function does not return a value.
-
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_disable_afclear(&g_mss_uart0);
- @endcode
- */
- void
- MSS_UART_disable_afclear
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_enable_rx_timeout() function is used to enable and configure
- the receiver timeout functionality of MSS UART. This function accepts the
- timeout parameter and applies the timeout based up on the baud rate as per
- the formula 4 x timeout x bit time.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param timeout
- The timeout parameter specifies the receiver timeout multiple.
- It should be configured according to the baud rate in use.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_enable_rx_timeout(&g_mss_uart0 , 24);
- @endcode
- */
- void
- MSS_UART_enable_rx_timeout
- (
- mss_uart_instance_t * this_uart,
- uint8_t timeout
- );
- /***************************************************************************//**
- The MSS_UART_disable_rx_timeout() function is used to disable the receiver
- timeout functionality of MSS UART.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_disable_rx_timeout(&g_mss_uart0);
- @endcode
- */
- void
- MSS_UART_disable_rx_timeout
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_enable_tx_time_guard() function is used to enable and configure
- the transmitter time guard functionality of MSS UART. This function accepts
- the timeguard parameter and applies the timeguard based up on the baud rate
- as per the formula timeguard x bit time.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_enable_tx_time_guard(&g_mss_uart0 , 24);
- @endcode
- */
- void
- MSS_UART_enable_tx_time_guard
- (
- mss_uart_instance_t * this_uart,
- uint8_t timeguard
- );
- /***************************************************************************//**
- The MSS_UART_disable_tx_time_guard() function is used to disable the
- transmitter time guard functionality of MSS UART.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
-
- MSS_UART_disable_tx_time_guard(&g_mss_uart0);
- @endcode
- */
- void
- MSS_UART_disable_tx_time_guard
- (
- mss_uart_instance_t * this_uart
- );
- /***************************************************************************//**
- The MSS_UART_set_address() function is used to set the 8-bit address for
- the MSS UART referenced by this_uart parameter.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param address
- The address parameter is the 8-bit address which is to be configured
- to the MSS UART referenced by this_uart parameter.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
-
- MSS_UART_set_address(&g_mss_uart0, 0xAA);
- @endcode
- */
- void
- MSS_UART_set_address
- (
- mss_uart_instance_t * this_uart,
- uint8_t address
- );
- /***************************************************************************//**
- The MSS_UART_set_ready_mode() function is used to configure the MODE0 or MODE1
- to the TXRDY and RXRDY signals of the MSS UART referenced by this_uart
- parameter. The mode parameter is used to provide the mode to be configured.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param mode
- The mode parameter is the mss_uart_ready_mode_t type which is used to
- configure the TXRDY and RXRDY signal modes.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_set_ready_mode(&g_mss_uart0, MSS_UART_READY_MODE0);
- @endcode
- */
- void
- MSS_UART_set_ready_mode
- (
- mss_uart_instance_t * this_uart,
- mss_uart_ready_mode_t mode
- );
- /***************************************************************************//**
- The MSS_UART_set_usart_mode() function is used to configure the MSS UART
- referenced by the parameter this_uart in USART mode. Various USART modes
- are supported which can be configured by the parameter mode of type
- mss_uart_usart_mode_t.
- @param this_uart
- The this_uart parameter is a pointer to an mss_uart_instance_t
- structure identifying the MSS UART hardware block that will perform
- the requested function. There are two such data structures,
- g_mss_uart0 and g_mss_uart1, associated with MSS UART0 and MSS UART1.
- This parameter must point to either the g_mss_uart0 or g_mss_uart1
- global data structure defined within the UART driver.
- @param mode
- The mode parameter is the USART mode to be configured.
- This parameter is of type mss_uart_usart_mode_t.
- @return
- This function does not return a value.
- Example:
- @code
- MSS_UART_init(&g_mss_uart0,
- MSS_UART_57600_BAUD,
- MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
- MSS_UART_set_usart_mode(&g_mss_uart0, MSS_UART_SYNC_MASTER_POS_EDGE_CLK);
- @endcode
- */
- void
- MSS_UART_set_usart_mode
- (
- mss_uart_instance_t * this_uart,
- mss_uart_usart_mode_t mode
- );
- #ifdef __cplusplus
- }
- #endif
- #endif /* __MSS_UART_H_ */
|