source: asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/targets/TARGET_RENESAS/TARGET_RZA1XX/common/rza_io_regrw.c@ 374

Last change on this file since 374 was 374, checked in by coas-nagasima, 5 years ago

mbed関連を更新
シリアルドライバをmbedのHALを使うよう変更
ファイルディスクリプタの処理を更新

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 9.9 KB
Line 
1/*******************************************************************************
2* DISCLAIMER
3* This software is supplied by Renesas Electronics Corporation and is only
4* intended for use with Renesas products. No other uses are authorized. This
5* software is owned by Renesas Electronics Corporation and is protected under
6* all applicable laws, including copyright laws.
7* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
8* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
9* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
10* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
11* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
12* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
13* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
14* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
15* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
16* Renesas reserves the right, without notice, to make changes to this software
17* and to discontinue the availability of this software. By using this software,
18* you agree to the additional terms and conditions found by accessing the
19* following link:
20* http://www.renesas.com/disclaimer
21* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
22*******************************************************************************/
23/*******************************************************************************
24* File Name : rza_io_regrw.c
25* $Rev: 1121 $
26* $Date:: 2014-08-06 17:09:53 +0900#$
27* Description : Low level register read/write
28*******************************************************************************/
29
30/******************************************************************************
31Includes <System Includes> , "Project Includes"
32******************************************************************************/
33#include "r_typedefs.h"
34
35#ifdef __CC_ARM
36#pragma arm section code = "CODE_IO_REGRW"
37#pragma arm section rodata = "CONST_IO_REGRW"
38#pragma arm section rwdata = "DATA_IO_REGRW"
39#pragma arm section zidata = "BSS_IO_REGRW"
40#endif
41
42/******************************************************************************
43Typedef definitions
44******************************************************************************/
45
46
47/******************************************************************************
48Macro definitions
49******************************************************************************/
50
51
52/******************************************************************************
53Imported global variables and functions (from other files)
54******************************************************************************/
55
56
57/******************************************************************************
58Exported global variables and functions (to be accessed by other files)
59******************************************************************************/
60
61
62/******************************************************************************
63Private global variables and functions
64******************************************************************************/
65
66
67/******************************************************************************
68* Function Name: RZA_IO_RegWrite_8
69* Description : IO register 8-bit write
70* Arguments : volatile uint8_t * ioreg : IO register for writing
71* : : Use register definition name of the
72* : : iodefine.h
73* : uint8_t write_value : Write value for the IO register
74* : uint8_t shift : The number of left shifts to the
75* : : target bit
76* : uint8_t mask : Mask value for the IO register
77* : : (Target bit : "1")
78* Return Value : None
79******************************************************************************/
80void RZA_IO_RegWrite_8(volatile uint8_t * ioreg, uint8_t write_value, uint8_t shift, uint8_t mask)
81{
82 uint8_t reg_value;
83
84 reg_value = *ioreg; /* Read from register */
85 reg_value = (reg_value & (~mask)) | (write_value << shift); /* Modify value */
86 *ioreg = reg_value; /* Write to register */
87}
88
89/******************************************************************************
90* Function Name: RZA_IO_RegWrite_16
91* Description : IO register 16-bit write
92* Arguments : volatile uint16_t * ioreg : IO register for writing
93* : : Use register definition name of the
94* : : iodefine.h
95* : uint16_t write_value : Write value for the IO register
96* : uint16_t shift : The number of left shifts to the
97* : : target bit
98* : uint16_t mask : Mask value for the IO register
99* : : (Target bit : "1")
100* Return Value : None
101******************************************************************************/
102void RZA_IO_RegWrite_16(volatile uint16_t * ioreg, uint16_t write_value, uint16_t shift, uint16_t mask)
103{
104 uint16_t reg_value;
105
106 reg_value = *ioreg; /* Read from register */
107 reg_value = (reg_value & (~mask)) | (write_value << shift); /* Modify value */
108 *ioreg = reg_value; /* Write to register */
109}
110
111/******************************************************************************
112* Function Name: RZA_IO_RegWrite_32
113* Description : IO register 32-bit write
114* Arguments : volatile uint32_t * ioreg : IO register for writing
115* : : Use register definition name of the
116* : : iodefine.h
117* : uint32_t write_value : Write value for the IO register
118* : uint32_t shift : The number of left shifts to the
119* : : target bit
120* : uint32_t mask : Mask value for the IO register
121* : : (Target bit : "1")
122* Return Value : None
123******************************************************************************/
124void RZA_IO_RegWrite_32(volatile uint32_t * ioreg, uint32_t write_value, uint32_t shift, uint32_t mask)
125{
126 uint32_t reg_value;
127
128 reg_value = *ioreg; /* Read from register */
129 reg_value = (reg_value & (~mask)) | (write_value << shift); /* Modify value */
130 *ioreg = reg_value; /* Write to register */
131}
132
133/******************************************************************************
134* Function Name: RZA_IO_RegRead_8
135* Description : IO register 8-bit read
136* Arguments : volatile uint8_t * ioreg : IO register for reading
137* : : Use register definition name of the
138* : : iodefine.h
139* : uint8_t shift : The number of right shifts to the
140* : : target bit
141* : uint8_t mask : Mask bit for the IO register
142* : : (Target bit: "1")
143* Return Value : uint8_t : Value of the obtained target bit
144******************************************************************************/
145uint8_t RZA_IO_RegRead_8(volatile uint8_t * ioreg, uint8_t shift, uint8_t mask)
146{
147 uint8_t reg_value;
148
149 reg_value = *ioreg; /* Read from register */
150 reg_value = (reg_value & mask) >> shift; /* Clear other bit and Bit shift */
151
152 return reg_value;
153}
154
155/******************************************************************************
156* Function Name: RZA_IO_RegRead_16
157* Description : IO register 16-bit read
158* Arguments : volatile uint16_t * ioreg : IO register for reading
159* : : Use register definition name of the
160* : : iodefine.h
161* : uint16_t shift : The number of right shifts to the
162* : : target bit
163* : uint16_t mask : Mask bit for the IO register
164* : : (Target bit: "1")
165* Return Value : uint16_t : Value of the obtained target bit
166******************************************************************************/
167uint16_t RZA_IO_RegRead_16(volatile uint16_t * ioreg, uint16_t shift, uint16_t mask)
168{
169 uint16_t reg_value;
170
171 reg_value = *ioreg; /* Read from register */
172 reg_value = (reg_value & mask) >> shift; /* Clear other bit and Bit shift */
173
174 return reg_value;
175}
176
177/******************************************************************************
178* Function Name: RZA_IO_RegRead_32
179* Description : IO register 32-bit read
180* Arguments : volatile uint32_t * ioreg : IO register for reading
181* : : Use register definition name of the
182* : : iodefine.h
183* : uint32_t shift : The number of right shifts to the
184* : : target bit
185* : uint32_t mask : Mask bit for the IO register
186* : : (Target bit: "1")
187* Return Value : uint32_t : Value of the obtained target bit
188******************************************************************************/
189uint32_t RZA_IO_RegRead_32(volatile uint32_t * ioreg, uint32_t shift, uint32_t mask)
190{
191 uint32_t reg_value;
192
193 reg_value = *ioreg; /* Read from register */
194 reg_value = (reg_value & mask) >> shift; /* Clear other bit and Bit shift */
195
196 return reg_value;
197}
198
199
200/* End of File */
Note: See TracBrowser for help on using the repository browser.