Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sun May 14 23:18:57 2017 +0000
Revision:
18:6a4db94011d3
Publishing again

Who changed what in which revision?

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