TMPM4KxA Group Peripheral Driver User Manual  V1.0.4.0
txz_uart.h
Go to the documentation of this file.
1 
13 /*------------------------------------------------------------------------------*/
14 /* Define to prevent recursive inclusion */
15 /*------------------------------------------------------------------------------*/
16 #ifndef __UART_H
17 #define __UART_H
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /*------------------------------------------------------------------------------*/
24 /* Includes */
25 /*------------------------------------------------------------------------------*/
26 #include "txz_driver_def.h"
27 
38 /*------------------------------------------------------------------------------*/
39 /* Macro Definition */
40 /*------------------------------------------------------------------------------*/
51 #define UART_TX_FIFO_MAX ((uint32_t)0x00000008)
52 #define UART_RX_FIFO_MAX ((uint32_t)0x00000008) /* End of group UART_FifoMax */
56 
62 #define UART_HALF_CLOCK_UTxTXDA ((uint32_t)0x00000000)
63 #define UART_HALF_CLOCK_UTxTXDB ((uint32_t)0x00040000) /* End of group UART_HalfClockSelect */
67 
73 #define UART_HALF_CLOCK_MODE_1 ((uint32_t)0x00000000)
74 #define UART_HALF_CLOCK_MODE_2 ((uint32_t)0x00020000) /* End of group UART_HalfClockMode */
78 
84 #define UART_HALF_CLOCK_DISABLE ((uint32_t)0x00000000)
85 #define UART_HALF_CLOCK_ENABLE ((uint32_t)0x00010000) /* End of group UART_HalfClockCTR */
89 
95 #define UART_LOOPBACK_DISABLE ((uint32_t)0x00000000)
96 #define UART_LOOPBACK_ENABLE ((uint32_t)0x00008000) /* End of group UART_LoopBack */
100 
101 
107 #define UART_NOISE_FILTER_NON ((uint32_t)0x00000000)
108 #define UART_NOISE_FILTER_2_T0 ((uint32_t)0x00001000)
109 #define UART_NOISE_FILTER_4_T0 ((uint32_t)0x00002000)
110 #define UART_NOISE_FILTER_8_T0 ((uint32_t)0x00003000)
111 #define UART_NOISE_FILTER_2_CLOCK ((uint32_t)0x00004000)
112 #define UART_NOISE_FILTER_3_CLOCK ((uint32_t)0x00005000)
113 #define UART_NOISE_FILTER_4_CLOCK ((uint32_t)0x00006000)
114 #define UART_NOISE_FILTER_5_CLOCK ((uint32_t)0x00007000) /* End of group UART_NoiseFilter */
118 
119 
125 #define UART_CTS_DISABLE ((uint32_t)0x00000000)
126 #define UART_CTS_ENABLE ((uint32_t)0x00000400) /* End of group UART_CTSHandshake */
130 
131 
137 #define UART_RTS_DISABLE ((uint32_t)0x00000000)
138 #define UART_RTS_ENABLE ((uint32_t)0x00000200) /* End of group UART_RTSHandshake */
142 
143 
149 #define UART_DATA_COMPLEMENTION_DISABLE ((uint32_t)0x00000000)
150 #define UART_DATA_COMPLEMENTION_ENABLE ((uint32_t)0x00000040) /* End of group UART_DataComplementation */
154 
155 
161 #define UART_DATA_DIRECTION_LSB ((uint32_t)0x00000000)
162 #define UART_DATA_DIRECTION_MSB ((uint32_t)0x00000020) /* End of group UART_DataDirection */
166 
167 
173 #define UART_STOP_BIT_1 ((uint32_t)0x00000000)
174 #define UART_STOP_BIT_2 ((uint32_t)0x00000010) /* End of group UART_StopBit */
178 
179 
185 #define UART_PARITY_BIT_ODD ((uint32_t)0x00000000)
186 #define UART_PARITY_BIT_EVEN ((uint32_t)0x00000008) /* End of group UART_ParityBit */
190 
191 
197 #define UART_PARITY_DISABLE ((uint32_t)0x00000000)
198 #define UART_PARITY_ENABLE ((uint32_t)0x00000004) /* End of group UART_ParityEnable */
202 
203 
209 #define UART_DATA_LENGTH_7 ((uint32_t)0x00000000)
210 #define UART_DATA_LENGTH_8 ((uint32_t)0x00000001)
211 #define UART_DATA_LENGTH_9 ((uint32_t)0x00000002) /* End of group UART_DataLength */
215 
216 
223 #define UART_TX_FILL_RANGE_MIN ((uint32_t)0x00000000)
224 #define UART_TX_FILL_RANGE_MAX ((uint32_t)0x00000007) /* End of group UART_TxFillLevelRange */
228 
229 
236 #define UART_RX_FILL_RANGE_MIN ((uint32_t)0x00000001)
237 #define UART_RX_FILL_RANGE_MAX ((uint32_t)0x00000008) /* End of group UART_RxFillLevelRange */
241 
242 
248 #define UART_TX_FIFO_INT_DISABLE ((uint32_t)0x00000000)
249 #define UART_TX_FIFO_INT_ENABLE ((uint32_t)0x00000080) /* End of group UART_TxFIFOInterrupt */
253 
254 
260 #define UART_TX_INT_DISABLE ((uint32_t)0x00000000)
261 #define UART_TX_INT_ENABLE ((uint32_t)0x00000040) /* End of group UART_TxInterrupt */
265 
266 
272 #define UART_RX_FIFO_INT_DISABLE ((uint32_t)0x00000000)
273 #define UART_RX_FIFO_INT_ENABLE ((uint32_t)0x00000020) /* End of group UART_RxFIFOInterrupt */
277 
278 
284 #define UART_RX_INT_DISABLE ((uint32_t)0x00000000)
285 #define UART_RX_INT_ENABLE ((uint32_t)0x00000010) /* End of group UART_RxInterrupt */
289 
290 
296 #define UART_ERR_INT_DISABLE ((uint32_t)0x00000000)
297 #define UART_ERR_INT_ENABLE ((uint32_t)0x00000004) /* End of group UART_ErrorInterrupt */
301 
302 
308 #define UART_PLESCALER_1 ((uint32_t)0x00000000)
309 #define UART_PLESCALER_2 ((uint32_t)0x00000010)
310 #define UART_PLESCALER_4 ((uint32_t)0x00000020)
311 #define UART_PLESCALER_8 ((uint32_t)0x00000030)
312 #define UART_PLESCALER_16 ((uint32_t)0x00000040)
313 #define UART_PLESCALER_32 ((uint32_t)0x00000050)
314 #define UART_PLESCALER_64 ((uint32_t)0x00000060)
315 #define UART_PLESCALER_128 ((uint32_t)0x00000070)
316 #define UART_PLESCALER_256 ((uint32_t)0x00000080)
317 #define UART_PLESCALER_512 ((uint32_t)0x00000090) /* End of group UART_Prescaler */
321 
322 
328 #define UART_UARTxCLK_MASK ((uint32_t)0x00000000) /* End of group UART_Clock_Mask */
332 
333 
339 #define UART_DIVISION_DISABLE ((uint32_t)0x00000000)
340 #define UART_DIVISION_ENABLE ((uint32_t)0x00800000) /* End of group UART_Division */
344 
345 
352 #define UART_RANGE_K_MIN ((uint32_t)0x00000000)
353 #define UART_RANGE_K_MAX ((uint32_t)0x0000003F) /* End of group UART_RangeK */
357 
358 
365 #define UART_RANGE_N_MIN ((uint32_t)0x00000001)
366 #define UART_RANGE_N_MAX ((uint32_t)0x0000FFFF) /* End of group UART_RangeN */
370 
371 
377 #define UART_SETTING_MASK ((uint32_t)0x80000000)
378 #define UART_SETTING_ENABLE ((uint32_t)0x00000000)
379 #define UART_SETTING_DISABLE ((uint32_t)0x80000000) /* End of group UART_SettingEnable */
383 
384 
390 #define UART_TX_STATE_MASK ((uint32_t)0x00008000)
391 #define UART_TX_STATE_SLEEP ((uint32_t)0x00000000)
392 #define UART_TX_STATE_RUN ((uint32_t)0x00008000) /* End of group UART_TxState */
396 
397 
403 #define UART_TX_MASK ((uint32_t)0x00004000)
404 #define UART_TX_DONE ((uint32_t)0x00004000) /* End of group UART_TxDone */
408 
409 
415 #define UART_TX_REACH_FILL_MASK ((uint32_t)0x00002000)
416 #define UART_TX_REACH_FILL_LEVEL ((uint32_t)0x00002000) /* End of group UART_TxReachFillLevel */
420 
421 
427 #define UART_TX_FIFO_LEVEL_MASK ((uint32_t)0x00000F00) /* End of group UART_TxFifoLevel */
431 
432 
438 #define UART_RX_STATE_MASK ((uint32_t)0x00000080)
439 #define UART_RX_STATE_SLEEP ((uint32_t)0x00000000)
440 #define UART_RX_STATE_RUN ((uint32_t)0x00000080) /* End of group UART_RxState */
444 
445 
451 #define UART_RX_MASK ((uint32_t)0x00000040)
452 #define UART_RX_DONE ((uint32_t)0x00000040) /* End of group UART_RxDone */
456 
457 
463 #define UART_RX_REACH_FILL_MASK ((uint32_t)0x00000020)
464 #define UART_RX_REACH_FILL_LEVEL ((uint32_t)0x00000020) /* End of group UART_RxReachFillLevel */
468 
469 
475 #define UART_RX_FIFO_LEVEL_MASK ((uint32_t)0x0000000F) /* End of group UART_RxFifoLevel */
479 
480 
486 #define UART_TRIGGER_NO_ERR ((uint32_t)0x00000000)
487 #define UART_TRIGGER_ERR ((uint32_t)0x00000010) /* End of group UART_TxTriggerErr */
491 
492 
498 #define UART_OVERRUN_NO_ERR ((uint32_t)0x00000000)
499 #define UART_OVERRUN_ERR ((uint32_t)0x00000008) /* End of group UART_OverrunErr */
503 
504 
510 #define UART_PARITY_NO_ERR ((uint32_t)0x00000000)
511 #define UART_PARITY_ERR ((uint32_t)0x00000004) /* End of group UART_ParityErr */
515 
516 
522 #define UART_FRAMING_NO_ERR ((uint32_t)0x00000000)
523 #define UART_FRAMING_ERR ((uint32_t)0x00000002) /* End of group UART_FramingErr */
527 
528 
534 #define UART_BREAK_NO_ERR ((uint32_t)0x00000000)
535 #define UART_BREAK_ERR ((uint32_t)0x00000001) /* End of group UART_BreakErr */
539  /* End of group UART_Exported_define */
543 
544 /*------------------------------------------------------------------------------*/
545 /* Enumerated Type Definition */
546 /*------------------------------------------------------------------------------*/
552 /* no define */
553  /* End of group UART_Exported_define */
557 
558 /*------------------------------------------------------------------------------*/
559 /* Structure Definition */
560 /*------------------------------------------------------------------------------*/
566 /*----------------------------------*/
572 /*----------------------------------*/
573 typedef struct
574 {
575  uint8_t *p_data;
576  uint32_t num;
578 
579 /*----------------------------------*/
584 /*----------------------------------*/
585 typedef struct
586 {
587  uint16_t *p_data;
588  uint32_t num;
590 
591 /*----------------------------------*/
595 /*----------------------------------*/
596 typedef union
597 {
601 
602 /*----------------------------------*/
607 /*----------------------------------*/
608 typedef struct
609 {
610  uint8_t *p_data;
611  uint32_t num;
613 
614 /*----------------------------------*/
619 /*----------------------------------*/
620 typedef struct
621 {
622  uint16_t *p_data;
624  uint32_t num;
626 
627 /*----------------------------------*/
631 /*----------------------------------*/
632 typedef union
633 {
637 
638 /*----------------------------------*/
642 /*----------------------------------*/
643 typedef struct
644 {
645  uint32_t prsel;
647 } uart_clock_t;
648 
649 /*----------------------------------*/
653 /*----------------------------------*/
654 typedef struct
655 {
656  uint32_t ken;
658  uint32_t brk;
660  uint32_t brn;
663 
664 /*----------------------------------*/
668 /*----------------------------------*/
669 typedef struct
670 {
671  uint32_t inttx;
673  uint32_t level;
676 
677 /*----------------------------------*/
681 /*----------------------------------*/
682 typedef struct
683 {
684  uint32_t intrx;
686  uint32_t level;
689 
690 /*----------------------------------*/
694 /*----------------------------------*/
695 typedef struct
696 {
697  uint32_t id;
702  uint32_t inttx;
704  uint32_t intrx;
706  uint32_t interr;
712  uint32_t hct;
714  uint32_t hcm;
716  uint32_t hcc;
718  uint32_t lbc;
720  uint32_t nf;
722  uint32_t ctse;
724  uint32_t rtse;
726  uint32_t iv;
728  uint32_t dir;
730  uint32_t sblen;
732  uint32_t even;
734  uint32_t pe;
736  uint32_t sm;
739 
740 /*----------------------------------*/
744 /*----------------------------------*/
745 typedef struct
746 {
747  TSB_UART_TypeDef *p_instance;
749  /*------------------------------------------*/
753  /*------------------------------------------*/
754  struct
755  {
756  uint32_t rp;
758  void (*handler)(uint32_t id, TXZ_Result result);
759  } transmit;
760  /*------------------------------------------*/
764  /*------------------------------------------*/
765  struct
766  {
768  void (*handler)(uint32_t id, TXZ_Result result, uart_receive_t *p_info);
769  } receive;
770 } uart_t;
771  /* End of group UART_Exported_typedef */
775 
776 /*------------------------------------------------------------------------------*/
777 /* Functions */
778 /*------------------------------------------------------------------------------*/
783 TXZ_Result uart_init(uart_t *p_obj);
784 TXZ_Result uart_deinit(uart_t *p_obj);
785 TXZ_Result uart_discard_transmit(uart_t *p_obj);
786 TXZ_Result uart_discard_receive(uart_t *p_obj);
787 TXZ_Result uart_transmitIt(uart_t *p_obj, uart_transmit_t *p_info);
788 TXZ_Result uart_receiveIt(uart_t *p_obj, uart_receive_t *p_info);
789 void uart_transmit_irq_handler(uart_t *p_obj);
790 void uart_receive_irq_handler(uart_t *p_obj);
791 void uart_error_irq_handler(uart_t *p_obj);
792 TXZ_Result uart_get_status(uart_t *p_obj, uint32_t *p_status);
793 TXZ_Result uart_get_error(uart_t *p_obj, uint32_t *p_error);
794 TXZ_Result uart_get_boudrate_setting(uint32_t clock, uart_clock_t *p_clk, uint32_t boudrate, uart_boudrate_t *p_setting); /* End of group UART_Exported_functions */
798  /* End of group UART */
802  /* End of group Periph_Driver */
806 
807 #ifdef __cplusplus
808 }
809 #endif /* __cplusplus */
810 #endif /* __UART_H */
811 
812 
TXZ_Result uart_receiveIt(uart_t *p_obj, uart_receive_t *p_info)
Receive data. Non-Blocking Communication.
Definition: txz_uart.c:1248
Transmit data information structure definenition.
Definition: txz_uart.h:620
TXZ_Result uart_init(uart_t *p_obj)
Initialize the UART object.
Definition: txz_uart.c:852
void uart_transmit_irq_handler(uart_t *p_obj)
IRQ Handler for transmit.
Definition: txz_uart.c:1314
uint32_t prsel
Definition: txz_uart.h:645
Transmit FIFO setting.
Definition: txz_uart.h:669
uint32_t level
Definition: txz_uart.h:673
Transmit data information structure definenition.
Definition: txz_uart.h:632
uint32_t level
Definition: txz_uart.h:686
uint32_t nf
Definition: txz_uart.h:720
Initial setting structure definenition.
Definition: txz_uart.h:695
uint32_t sm
Definition: txz_uart.h:736
TXZ_Result uart_get_status(uart_t *p_obj, uint32_t *p_status)
Get status.
Definition: txz_uart.c:1697
Clock setting structure definenition.
Definition: txz_uart.h:643
TXZ_Result uart_get_error(uart_t *p_obj, uint32_t *p_error)
Get error information.
Definition: txz_uart.c:1740
uint32_t hcm
Definition: txz_uart.h:714
Receive event information structure definenition.
Definition: txz_uart.h:585
uart_clock_t clock
Definition: txz_uart.h:698
uint32_t rp
Definition: txz_uart.h:756
uint32_t num
Definition: txz_uart.h:588
uart_receive_t info
Definition: txz_uart.h:767
uint16_t * p_data
Definition: txz_uart.h:622
uint32_t hcc
Definition: txz_uart.h:716
UART handle structure definenition.
Definition: txz_uart.h:745
TSB_UART_TypeDef * p_instance
Definition: txz_uart.h:747
uint8_t * p_data
Definition: txz_uart.h:610
TXZ_Result uart_discard_receive(uart_t *p_obj)
Discard receive.
Definition: txz_uart.c:1049
uint32_t intrx
Definition: txz_uart.h:684
uint32_t id
Definition: txz_uart.h:697
TXZ_Result uart_get_boudrate_setting(uint32_t clock, uart_clock_t *p_clk, uint32_t boudrate, uart_boudrate_t *p_setting)
Get the setting of boudrate.
Definition: txz_uart.c:1775
uint32_t hct
Definition: txz_uart.h:712
uint32_t ctse
Definition: txz_uart.h:722
uint16_t * p_data
Definition: txz_uart.h:587
Receive event information structure definenition.
Definition: txz_uart.h:573
uart_initial_setting_t init
Definition: txz_uart.h:748
uint32_t brn
Definition: txz_uart.h:660
Transmit data information structure definenition.
Definition: txz_uart.h:608
uint32_t interr
Definition: txz_uart.h:706
uint8_t * p_data
Definition: txz_uart.h:575
uart_boudrate_t boudrate
Definition: txz_uart.h:700
Receive event information structure definenition.
Definition: txz_uart.h:596
All common macro and definition for TXZ peripheral drivers.
uint32_t ken
Definition: txz_uart.h:656
uint32_t lbc
Definition: txz_uart.h:718
TXZ_Result uart_deinit(uart_t *p_obj)
Release the UART object.
Definition: txz_uart.c:954
uart_transmit16_t tx16
Definition: txz_uart.h:635
uint32_t intrx
Definition: txz_uart.h:704
void uart_error_irq_handler(uart_t *p_obj)
IRQ Handler for error.
Definition: txz_uart.c:1567
uart_transmit8_t tx8
Definition: txz_uart.h:634
Boudrate setting structure definenition.
Definition: txz_uart.h:654
uart_transmit_t info
Definition: txz_uart.h:757
TXZ_Result uart_transmitIt(uart_t *p_obj, uart_transmit_t *p_info)
Transmit data. Non-Blocking Communication.
Definition: txz_uart.c:1107
uart_receive16_t rx16
Definition: txz_uart.h:599
uint32_t rtse
Definition: txz_uart.h:724
uint32_t num
Definition: txz_uart.h:576
uint32_t pe
Definition: txz_uart.h:734
uint32_t sblen
Definition: txz_uart.h:730
uart_rx_fifo_t rxfifo
Definition: txz_uart.h:710
uint32_t inttx
Definition: txz_uart.h:671
TXZ_Result uart_discard_transmit(uart_t *p_obj)
Discard transmit.
Definition: txz_uart.c:992
uint32_t num
Definition: txz_uart.h:611
uart_tx_fifo_t txfifo
Definition: txz_uart.h:708
uint32_t inttx
Definition: txz_uart.h:702
uart_receive8_t rx8
Definition: txz_uart.h:598
Receive FIFO setting.
Definition: txz_uart.h:682
uint32_t num
Definition: txz_uart.h:624
uint32_t even
Definition: txz_uart.h:732
uint32_t iv
Definition: txz_uart.h:726
uint32_t brk
Definition: txz_uart.h:658
void uart_receive_irq_handler(uart_t *p_obj)
IRQ Handler for receive.
Definition: txz_uart.c:1467
uint32_t dir
Definition: txz_uart.h:728