1 /*******************************************************************************
\r
3 * This software is supplied by Renesas Electronics Corporation and is only
\r
4 * intended for use with Renesas products. No other uses are authorized. This
\r
5 * software is owned by Renesas Electronics Corporation and is protected under
\r
6 * all applicable laws, including copyright laws.
\r
7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
\r
8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
\r
9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
\r
10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
\r
11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
\r
12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
\r
13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
\r
14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
\r
15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
\r
16 * Renesas reserves the right, without notice, to make changes to this software
\r
17 * and to discontinue the availability of this software. By using this software,
\r
18 * you agree to the additional terms and conditions found by accessing the
\r
20 * http://www.renesas.com/disclaimer
\r
22 * Copyright (C) 2012 Renesas Electronics Corporation. All rights reserved.
\r
23 *******************************************************************************/
\r
24 /*******************************************************************************
\r
25 * File Name : scif_uart_userdef.c
\r
28 * Device(s) : Aragon
\r
29 * Tool-Chain : DS-5 Ver 5.13
\r
32 * H/W Platform : Aragon CPU Board
\r
33 * Description : Aragon Sample Program - SCIF UART device driver (User define function)
\r
36 *******************************************************************************/
\r
38 /******************************************************************************
\r
39 Includes <System Includes> , "Project Includes"
\r
40 ******************************************************************************/
\r
42 #include "r_typedefs.h"
\r
43 #include "dev_drv.h" /* Device Driver common header */
\r
44 #include "devdrv_scif_uart.h" /* UART Driver header */
\r
45 #include "devdrv_intc.h" /* INTC Driver Header */
\r
46 #include "iodefine.h"
\r
48 /******************************************************************************
\r
50 ******************************************************************************/
\r
52 /******************************************************************************
\r
54 ******************************************************************************/
\r
56 /******************************************************************************
\r
57 Imported global variables and functions (from other files)
\r
58 ******************************************************************************/
\r
60 /******************************************************************************
\r
61 Exported global variables and functions (to be accessed by other files)
\r
62 ******************************************************************************/
\r
64 /******************************************************************************
\r
65 Private global variables and functions
\r
66 ******************************************************************************/
\r
68 /******************************************************************************
\r
69 * Function Name: Userdef_SCIF2_UART_Init
\r
71 * Arguments : uint8_t mode
\r
74 * Return Value : none
\r
75 ******************************************************************************/
\r
76 void Userdef_SCIF2_UART_Init(uint8_t mode, uint16_t cks, uint8_t scbrr)
\r
78 /* ==== SCIF initial setting ==== */
\r
79 /* ---- Serial control register (SCSCR2) setting ---- */
\r
80 /* SCIF transmitting and receiving operations stop */
\r
81 SCIF2.SCSCR.WORD = 0x0000;
\r
83 if (SCIF_UART_MODE_W == (mode & SCIF_UART_MODE_W))
\r
85 /* ---- FIFO control register (SCFCR2) setting ---- */
\r
86 SCIF2.SCFCR.BIT.TFRST = 1; /* Transmit FIFO reset */
\r
89 if (SCIF_UART_MODE_R == (mode & SCIF_UART_MODE_R))
\r
91 /* ---- FIFO control register (SCFCR2) setting ---- */
\r
92 /* SCIF transmitting and receiving operations stop */
\r
93 SCIF2.SCFCR.BIT.RFRST = 1;
\r
95 /* Receive FIFO data register reset */
\r
98 /* ---- Serial status register(SCFSR2) setting ---- */
\r
99 /* ER,BRK,DR bit clear */
\r
100 SCIF2.SCFSR.WORD &= 0xFF6E;
\r
102 /* ---- Line status register (SCLSR2) setting ---- */
\r
103 /* ORER bit clear */
\r
104 SCIF2.SCLSR.BIT.ORER = 0;
\r
106 /* ---- Serial control register (SCSCR2) setting ---- */
\r
107 /* B'00 : Internal CLK */
\r
108 SCIF2.SCSCR.BIT.CKE = 0x0;
\r
110 /* ---- Serial mode register (SCSMR2) setting ---- */
\r
111 /* Communication mode 0: Asynchronous mode */
\r
112 /* Character length 0: 8-bit data */
\r
113 /* Parity enable 0: Add and check are disabled */
\r
114 /* Stop bit length 0: 1 stop bit */
\r
115 /* Clock select cks(argument) */
\r
116 SCIF2.SCSMR.WORD = cks & 0x0003;
\r
118 /* ---- Sets the Serial extension mode register (SCEMR2) ---- */
\r
119 /* Baud rate generator double-speed mode, 0: Normal mode */
\r
120 /* Base clock select in asynchronous mode, */
\r
121 /* 0: Base clock is 16 times the bit rate */
\r
122 SCIF2.SCEMR.WORD = 0x0000;
\r
124 /* ---- Bit rate register (SCBRR2) setting ---- */
\r
125 SCIF2.SCBRR.BYTE = scbrr;
\r
127 /* ---- FIFO control register (SCFCR2) setting ---- */
\r
128 /* RTS output active trigger :Initial value */
\r
129 /* Receive FIFO data trigger :1-data */
\r
130 /* Transmit FIFO data trigger :0-data */
\r
131 /* Modem control enable :Disabled */
\r
132 /* Receive FIFO data register reset :Disabled */
\r
133 /* Loop-back test :Disabled */
\r
134 SCIF2.SCFCR.WORD = 0x0030;
\r
136 /* ---- Serial port register (SCSPTR2) setting ---- */
\r
137 /* Serial port break output(SPB2IO) 1: Enabled */
\r
138 /* Serial port break data(SPB2DT) 1: High-level */
\r
139 SCIF2.SCSPTR.WORD |= 0x0003;
\r