/*--------------------------------------------------------------------------*/
/* UART1 Configuration                                                      */
/*--------------------------------------------------------------------------*/
#define NUCODEGEN_UART1_FUNCSEL_UART		0
#define NUCODEGEN_UART1_FUNCSEL_IrDA		2
#define NUCODEGEN_UART1_FUNCSEL_RS485		3

#define UART1_MATCH_ADDRSS1     0xC0
#define UART1_MATCH_ADDRSS2     0xA2
#define UART1_UNMATCH_ADDRSS1   0xB1
#define UART1_UNMATCH_ADDRSS2   0xD3

#define NUCODEGEN_UART1_CTS_HIGH_LEVEL_ACT   0
#define NUCODEGEN_UART1_CTS_LOW_LEVEL_ACT    1

#define NUCODEGEN_UART1_RTS_HIGH_LEVEL_ACT   0
#define NUCODEGEN_UART1_RTS_LOW_LEVEL_ACT    1

#define NUCODEGEN_UART1_RS485_ADD_MODE       0
#define NUCODEGEN_UART1_RS485_NMM_MODE       1


<! clock:  {"ALL" : "UART1" }; !>

<! pin:   {"UART1FunctionRadio":{ "NUCODEGEN_UART1_FUNCSEL_UART":        ["UART1_TXD","UART1_RXD"],
								  "NUCODEGEN_UART1_FUNCSEL_IrDA":        ["UART1_TXD","UART1_RXD"],
								  "NUCODEGEN_UART1_FUNCSEL_RS485":       ["UART1_TXD","UART1_RXD","UART1_nRTS"]
								 },

           "UART1AutoflowControlCheckbox":{"1":["UART1_nCTS","UART1_nRTS"]
		   }
        }; !>



#define NUCODEGEN_UART1_FUNCSEL			(<!id:UART1FunctionRadio;
										type:radio;
										label:UART1 Function Select;
										data:NUCODEGEN_UART1_FUNCSEL_UART;
										default:NUCODEGEN_UART1_FUNCSEL_UART;
										helper:;
										sort:false;
										enum:[NUCODEGEN_UART1_FUNCSEL_UART, NUCODEGEN_UART1_FUNCSEL_IrDA, NUCODEGEN_UART1_FUNCSEL_RS485];
										optionLabels:[UART, IrDA, RS485, Single Wire];
										vertical:false;
										dependencies:none;
										dependenciesOption:none;
										groupId:UART1Basic;
										groupName:Basic Configuration;!>)

#if (NUCODEGEN_UART1_FUNCSEL == NUCODEGEN_UART1_FUNCSEL_UART)
#define UART1_BAUD						(<!id:UART1Baudrateinteger;
										type:integer;
										label:UART1 Baud Rate ( 2400 bps ~ 1000000 bps );
										data:115200;
										default:115200;
										helper:Enter your UART1 baud rate.;
										sort:false;
										minimum:2400;
										maximum:1000000;
										dependencies:UART1FunctionRadio;
										dependenciesOption:NUCODEGEN_UART1_FUNCSEL_UART;
										groupId:UART1Basic;
										groupName:Basic Configuration;!>)


#define NUCODEGEN_UART1_LINE_CONFIG		(<!id:UART1SetLineConfigCheckbox;
										type:checkbox;
										label:Config UART1 Line Setting;
										data:0;
										default:0;
										sort:false;
										enum:[1];
										optionLabels:[Enable Config UART1 Line Setting];
										dependencies:UART1FunctionRadio;
										dependenciesOption:NUCODEGEN_UART1_FUNCSEL_UART;
										groupId:UART1Basic;
										groupName:Basic Configuration;!>)

#define NUCODEGEN_UART1_WORD_LEN	    (<!id:UART1WordLengthSelect;
										type:select;
										label:UART1 Word Length;
										data:UART_WORD_LEN_8;
										default:UART_WORD_LEN_8;
										helper:;
										sort:false;
										enum:[UART_WORD_LEN_5, UART_WORD_LEN_6, UART_WORD_LEN_7, UART_WORD_LEN_8];
										optionLabels:[5 bits, 6 bits, 7 bits, 8 bits];
										dependencies:UART1SetLineConfigCheckbox;
										dependenciesOption:1;
										groupId:UART1Basic;
										groupName:Basic Configuration;!>)

#define NUCODEGEN_UART1_PARITY		    (<!id:UART1ParityBitSelect;
										type:select;
										label:UART1 Parity Bit;
										data:UART_PARITY_NONE;
										default:UART_PARITY_NONE;
										helper:;
										sort:false;
										enum:[UART_PARITY_NONE, UART_PARITY_ODD, UART_PARITY_EVEN, UART_PARITY_MARK, UART_PARITY_SPACE];
										optionLabels:[None, Odd, Even, Mark, Space];
										dependencies:UART1SetLineConfigCheckbox;
										dependenciesOption:1;
										groupId:UART1Basic;
										groupName:Basic Configuration;!>)

#define NUCODEGEN_UART1_STOP_BIT	    (<!id:UART1StopBitSelect;
										type:select;
										label:UART1 Stop Bits;
										data:UART_STOP_BIT_1;
										default:UART_STOP_BIT_1;
										helper:;
										sort:false;
										enum:[UART_STOP_BIT_1, UART_STOP_BIT_1_5, UART_STOP_BIT_2];
										optionLabels:[1, 1.5 (for Word Length 5bits), 2 (for Word Length 6-8bits)];
										dependencies:UART1SetLineConfigCheckbox;
										dependenciesOption:1;
										groupId:UART1Basic;
										groupName:Basic Configuration;!>)

#define NUCODEGEN_UART1_AUTOFLOW		(<!id:UART1AutoflowControlCheckbox;
										type:checkbox;
										label:UART1 Auto-flow Control;
										data:0;
										default:0;
										sort:false;
										enum:[1];
										optionLabels:[Enable UART1 Auto-flow Control];
										dependencies:UART1FunctionRadio;
										dependenciesOption:NUCODEGEN_UART1_FUNCSEL_UART;
										groupId:UART1Advanced;
										groupName:Advanced Configuration;!>)

#define NUCODEGEN_UART1_RTSACTLV_LOW	(<!id:UART1RTSACTLVLevelSelect;
										type:select;
										label:nRTS pin output active level;
										data:NUCODEGEN_UART1_RTS_LOW_LEVEL_ACT;
										default:NUCODEGEN_UART1_RTS_LOW_LEVEL_ACT;
										enum:[NUCODEGEN_UART1_RTS_HIGH_LEVEL_ACT,NUCODEGEN_UART1_RTS_LOW_LEVEL_ACT];
										optionLabels:[High level,Low level];
										dependencies:UART1AutoflowControlCheckbox;
										dependenciesOption:1;
										groupId:UART1Advanced;
										groupName:Advanced Configuration;!>)

#define NUCODEGEN_UART1_CTSACTLV_LOW	(<!id:UART1CTSACTLVLevelSelect;
										type:select;
										label:nCTS pin input active level;
										data:NUCODEGEN_UART1_CTS_LOW_LEVEL_ACT;
										default:NUCODEGEN_UART1_CTS_LOW_LEVEL_ACT;
										enum:[NUCODEGEN_UART1_CTS_HIGH_LEVEL_ACT,NUCODEGEN_UART1_CTS_LOW_LEVEL_ACT];
										optionLabels:[High level,Low level];
										dependencies:UART1AutoflowControlCheckbox;
										dependenciesOption:1;
										groupId:UART1Advanced;
										groupName:Advanced Configuration;!>)

#define NUCODEGEN_UART1_FIFO_RTSTRGLV	(<!id:UART1RTSTriggerLevelSelect;
										type:select;
										label:nRTS Trigger Level for Auto-flow Control;
										data:UART_FIFO_RTSTRGLV_1BYTE;
										default:UART_FIFO_RTSTRGLV_1BYTE;
										helper:;
										sort:false;
										enum:[UART_FIFO_RTSTRGLV_1BYTE, UART_FIFO_RTSTRGLV_4BYTES, UART_FIFO_RTSTRGLV_8BYTES, UART_FIFO_RTSTRGLV_14BYTES];
										optionLabels:[1 byte, 4 bytes, 8 bytes, 14 bytes];
										dependencies:UART1AutoflowControlCheckbox;
										dependenciesOption:1;
										groupId:UART1Advanced;
										groupName:Advanced Configuration;!>)

#define NUCODEGEN_UART1_PDMAEN		   (<!id:UART1PDMACheckbox;
										type:checkbox;
										label:PDMA Channel Control;
										data:0;
										default:0;
										sort:false;
										enum:[1];
										optionLabels:[Enable PDMA Channel];
										dependencies:UART1FunctionRadio;
										dependenciesOption:NUCODEGEN_UART1_FUNCSEL_UART;
										groupId:UART1PDMA;
										groupName:PDMA Configuration;!>)

#define NUCODEGEN_UART1_PDMAEN_Msk		(<!id:UART1PDMASelectCheckbox;
										type:multipleselect;
										label:Channel Setting;
										data:0;
										default:0;
										sort:false;
                                        enum:[UART_INTEN_TXPDMAEN_Msk, UART_INTEN_RXPDMAEN_Msk];
										optionLabels:[Enable TX PDMA,Enable RX PDMA];
										dependencies:UART1PDMACheckbox;
										dependenciesOption:1;
									    groupId:UART1PDMA;
										groupName:PDMA Configuration;!>)

#define NUCODEGEN_UART1_INTEN			(<!id:UART1IntCheckbox;
										type:checkbox;
										label:UART1 Interrupt Control ;
										data:0;
										default:0;
										enum:[1];
										optionLabels:[Enable UART1 Interrupt];
										dependencies:UART1FunctionRadio;
										dependenciesOption:NUCODEGEN_UART1_FUNCSEL_UART;
										groupId:UART1Interrupt;
										groupName:Interrupt Configuration;!>)

#define NUCODEGEN_UART1_INT_MASK		(<!id:UART1INTMASKMultipleSelect;
										type:multipleselect;
										label:Select Interrupts;
										size:7;
										data:0;
										default:0;
										helper:If you would like to use the ' Transmit Holding Register Empty ' or ' Transmitter Empty ' Interrupt function ,you can add in code.;
										sort:false;
										enum:[UART_INTEN_RDAIEN_Msk, UART_INTEN_RLSIEN_Msk, UART_INTEN_MODEMIEN_Msk, UART_INTEN_RXTOIEN_Msk, UART_INTEN_BUFERRIEN_Msk, UART_INTEN_WKIEN_Msk, UART_INTEN_ABRIEN_Msk];
										optionLabels:[Receive Data Available, Receive Line Status, Modem Status, RX Time-Out, Buffer Error, Wake-Up, Auto-baud Rate];
										dependencies:UART1IntCheckbox;
										dependenciesOption:1;
										groupId:UART1Interrupt;
										groupName:Interrupt Configuration;!>)

#elif (NUCODEGEN_UART1_FUNCSEL == NUCODEGEN_UART1_FUNCSEL_IrDA)
#define UART1_IRDA_BAUD					(<!id:UART1IRDABaudrateinteger;
										type:integer;
										label:UART1 IrDA Baud Rate ( 2400 bps ~ 115200 bps );
										data:115200;
										default:115200;
										helper:Enter your UART1 IRDA baud rate.;
										sort:false;
										minimum:2400;
										maximum:115200;
										dependencies:UART1FunctionRadio;
										dependenciesOption:NUCODEGEN_UART1_FUNCSEL_IrDA;
										groupId:UART1Basic;
										groupName:Basic Configuration;!>)

#define NUCODEGEN_UART1_IRDA_MODE		(<!id:UART1IrDAModeRadio;
										type:radio;
										label:IrDA Receiver/Transmitter Selection;
										data:UART_IRDA_RXEN;
										default:UART_IRDA_RXEN;
										sort:false;
										enum:[UART_IRDA_RXEN, UART_IRDA_TXEN];
										optionLabels:[Rx mode, Tx mode];
										vertical:false;
										dependencies:UART1FunctionRadio;
										dependenciesOption:NUCODEGEN_UART1_FUNCSEL_IrDA;
										groupId:UART1Basic;
										groupName:Basic Configuration;!>)

#define NUCODEGEN_UART1_IRDA_INTEN		(<!id:UART1IRDAIntCheckbox;
										type:checkbox;
										label:UART1 IrDA Interrupt Control;
										data:0;
										default:0;
										enum:[1];
										optionLabels:[Enable UART1 IrDA Interrupt];
										dependencies:UART1FunctionRadio;
										dependenciesOption:NUCODEGEN_UART1_FUNCSEL_IrDA;
										groupId:UART1Interrupt;
										groupName:Interrupt Configuration;!>)

#define NUCODEGEN_UART1_IRDA_INT_MASK	(<!id:UART1IRDAINTMASKMultipleSelect;
										type:multipleselect;
										label:Select Interrupts;
										size:2;
										data:0;
										default:0;
										helper:If you would like to use the ' Transmit Holding Register Empty ' or ' Transmitter Empty ' Interrupt function ,you can add in code.;
										sort:false;
										enum:[UART_INTEN_RDAIEN_Msk, UART_INTEN_RXTOIEN_Msk];
										optionLabels:[Receive Data Available, RX Time-Out];
										dependencies:UART1IRDAIntCheckbox;
										dependenciesOption:1;
										groupId:UART1Interrupt;
										groupName:Interrupt Configuration;!>)

#elif (NUCODEGEN_UART1_FUNCSEL == NUCODEGEN_UART1_FUNCSEL_RS485)
#define UART1_RS485_BAUD				(<!id:UART1RS485Baudrateinteger;
										type:integer;
										label:UART1 RS485 Baud Rate ( 2400 bps ~ 1000000 bps );
										data:115200;
										default:115200;
										helper:Enter your UART1 RS485 baud rate.;
										sort:false;
										minimum:2400;
										maximum:1000000;
										dependencies:UART1FunctionRadio;
										dependenciesOption:NUCODEGEN_UART1_FUNCSEL_RS485;
										groupId:UART1Basic;
										groupName:Basic Configuration;!>)

#define NUCODEGEN_UART1_RS485_MODE		(<!id:UART1RS485CTLRadio;
										type:radio;
										label:RS485 Operation Mode;
										data:0;
										default:0;
										sort:false;
										enum:[NUCODEGEN_UART1_RS485_ADD_MODE, NUCODEGEN_UART1_RS485_NMM_MODE];
										optionLabels:[Auto Address Detection Operation Mode (AAD), Normal Multi-Drop Operation Mode (NMM) ];
										dependencies:UART1FunctionRadio;
										dependenciesOption:NUCODEGEN_UART1_FUNCSEL_RS485;
										groupId:UART1Advanced;
										groupName:Advanced Configuration;!>)

#define UART1_RS485_ADDRMV				(<!id:UART1RS485AddrMVInteger;
										type:integer;
										label:UART1 RS485 Address Match Value;
										data:0;
										default:0;
										helper:Enter your UART1 RS485 Address Match Value;
										minimum:0;
										maximum:255;
										dependencies:UART1RS485CTLRadio;
										dependenciesOption:NUCODEGEN_UART1_RS485_ADD_MODE;
										groupId:UART1Advanced;
										groupName:Advanced Configuration;!>)

#define NUCODEGEN_UART1_RS485_INTEN		(<!id:UART1RS485IntCheckbox;
										type:checkbox;
										label:UART1 RS485 Interrupt Control;
										data:0;
										default:0;
										enum:[1];
										optionLabels:[Enable UART1 RS485 Interrupt];
										dependencies:UART1FunctionRadio;
										dependenciesOption:NUCODEGEN_UART1_FUNCSEL_RS485;
										groupId:UART1Interrupt;
										groupName:Interrupt Configuration;!>)

#define NUCODEGEN_UART1_RS485_INT_MASK	(<!id:UART1RS485INTMASKMultipleSelect;
										type:multipleselect;
										label:Select Interrupts;
										size:5;
										data:0;
										default:0;
										helper:If you would like to use the ' Transmit Holding Register Empty ' or ' Transmitter Empty ' Interrupt function ,you can add in code.;
										sort:false;
										enum:[UART_INTEN_RDAIEN_Msk, UART_INTEN_RLSIEN_Msk, UART_INTEN_RXTOIEN_Msk, UART_INTEN_BUFERRIEN_Msk, UART_INTEN_WKIEN_Msk];
										optionLabels:[Receive Data Available, Receive Line Status, RX Time-Out, Buffer Error, Wake-Up];
										dependencies:UART1RS485IntCheckbox;
										dependenciesOption:1;
										groupId:UART1Interrupt;
										groupName:Interrupt Configuration;!>)

#define NUCODEGEN_UART1_WKRS485EN	   (<!id:UART1RS485WakeupCheckbox;
									   type:checkbox;
									   label:RS485 Address Match Wake up;
									   data:0;
									   default:0;
									   enum:[1];
									   optionLabels:[Enable Enable RS-485 Auto Address Detection Operation mode (AAD) Wake-up];
									   dependencies:UART1RS485CTLRadio;
									   dependenciesOption:NUCODEGEN_UART1_RS485_ADD_MODE;
                                       groupId:UART1Interrupt;
                                       groupName:Interrupt Configuration;!>)
#endif

#define NUCODEGEN_UART1_ABRDEN			(<!id:UART1AutobaudRateCheckbox;
										type:checkbox;
										label:Auto-baud Rate Detect;
										data:0;
										default:0;
										helper:Input pattern shall be 0x01.;
										sort:false;
										enum:[1];
										optionLabels:[Enable Auto-baud Rate Detect];
										dependencies:UART1FunctionRadio;
			                            dependenciesOption:NUCODEGEN_UART1_FUNCSEL_UART;
										groupId:UART1Advanced;
										groupName:Advanced Configuration;!>)

#define NUCODEGEN_UART1_TOCNTEN			(<!id:UART1TimeoutCounterCheckbox;
										type:checkbox;
										label:Receive Buffer Time Out Control;
										data:0;
										default:0;
										sort:false;
										enum:[1];
										optionLabels:[Enable Receive Buffer Time Out];
										dependencies:UART1FunctionRadio;
										dependenciesOption:NUCODEGEN_UART1_FUNCSEL_UART|NUCODEGEN_UART1_FUNCSEL_IrDA;
										groupId:UART1Interrupt;
										groupName:Interrupt Configuration;!>)

#if NUCODEGEN_UART1_TOCNTEN
#define UART1_TOCNT						(<!id:UART1TimeoutCountInteger;
										type:integer;
										label:Time Out Interrupt Comparator;
										data:40;
										default:40;
										helper:Enter your UART1 Time-Out Interrupt Comparator(The counting clock = Baud rate);
										minimum:40;
										maximum:255;
										dependencies:UART1TimeoutCounterCheckbox;
										dependenciesOption:1;
										groupId:UART1Interrupt;
										groupName:Interrupt Configuration;!>)
#endif



#define NUCODEGEN_UART1_RFITL		   (<!id:UART1RXTriggerLevelSelect;
									   type:select;
									   label:RX FIFO Threshold Interrupt;
									   data:UART_FIFO_RFITL_1BYTE;
									   default:UART_FIFO_RFITL_1BYTE;
									   helper:;
									   sort:false;
									   enum:[UART_FIFO_RFITL_1BYTE, UART_FIFO_RFITL_4BYTES, UART_FIFO_RFITL_8BYTES, UART_FIFO_RFITL_14BYTES];
									   optionLabels:[1 byte, 4 bytes, 8 bytes, 14 bytes];
									   dependencies:none;
									   dependenciesOption:none;
									   groupId:UART1Interrupt;
									   groupName:Interrupt Configuration;!>)

#define NUCODEGEN_UART1_WKDATEN 	   (<!id:UART1DataWakeupCheckbox;
									   type:checkbox;
									   label:Wake Up Source;
									   data:0;
									   default:0;
									   enum:[1];
									   optionLabels:[Enable Incoming Data Wake-up];
									   dependencies:UART1FunctionRadio;
									   dependenciesOption:NUCODEGEN_UART1_FUNCSEL_UART;
                                       groupId:UART1Interrupt;
									   groupName:Interrupt Configuration;!>)

#define NUCODEGEN_UART1_WKCTSEN 	   (<!id:UART1nCTSWakeupCheckbox;
									   type:checkbox;
									   label:<br>;
									   data:0;
								 	   default:0;
									   enum:[1];
									   optionLabels:[Enable nCTS Wake-up];
									   dependencies:UART1FunctionRadio;
									   dependenciesOption:NUCODEGEN_UART1_FUNCSEL_UART;
									   groupId:UART1Interrupt;
									   groupName:Interrupt Configuration;!>)

#define NUCODEGEN_UART1_WKRFRTEN 	  (<!id:UART1ReachedThresholdWakeupCheckbox;
									  type:checkbox;
									  label:<br>;
									  data:0;
									  default:0;
									  enum:[1];
									  optionLabels:[Enable Received Data FIFO Reached Threshold Wake-up];
									  dependencies:UART1FunctionRadio;
									  dependenciesOption:NUCODEGEN_UART1_FUNCSEL_UART;
									  groupId:UART1Interrupt;
									  groupName:Interrupt Configuration;!>)

#define NUCODEGEN_UART1_WKTOUTEN	  (<!id:UART1TimeoutWakeupCheckbox;
									  type:checkbox;
									  label:<br>;
									  data:0;
									  default:0;
									  enum:[1];
									  optionLabels:[Enable Received Data FIFO Reached Threshold Time-out Wake-up];
									  dependencies:UART1ReachedThresholdWakeupCheckbox;
									  dependenciesOption:1;
									  groupId:UART1Interrupt;
									  groupName:Interrupt Configuration;!>)