Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /**
sahilmgandhi 18:6a4db94011d3 2 ******************************************************************************
sahilmgandhi 18:6a4db94011d3 3 * @file stm32l0xx.h
sahilmgandhi 18:6a4db94011d3 4 * @author MCD Application Team
sahilmgandhi 18:6a4db94011d3 5 * @version V1.7.0
sahilmgandhi 18:6a4db94011d3 6 * @date 31-May-2016
sahilmgandhi 18:6a4db94011d3 7 * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer Header File.
sahilmgandhi 18:6a4db94011d3 8 * This file contains all the peripheral register's definitions, bits
sahilmgandhi 18:6a4db94011d3 9 * definitions and memory mapping for STM32L0xx devices.
sahilmgandhi 18:6a4db94011d3 10 *
sahilmgandhi 18:6a4db94011d3 11 * The file is the unique include file that the application programmer
sahilmgandhi 18:6a4db94011d3 12 * is using in the C source code, usually in main.c. This file contains:
sahilmgandhi 18:6a4db94011d3 13 * - Configuration section that allows to select:
sahilmgandhi 18:6a4db94011d3 14 * - The device used in the target application
sahilmgandhi 18:6a4db94011d3 15 * - To use or not the peripheral's drivers in application code(i.e.
sahilmgandhi 18:6a4db94011d3 16 * code will be based on direct access to peripheral's registers
sahilmgandhi 18:6a4db94011d3 17 * rather than drivers API), this option is controlled by
sahilmgandhi 18:6a4db94011d3 18 * "#define USE_HAL_DRIVER"
sahilmgandhi 18:6a4db94011d3 19 *
sahilmgandhi 18:6a4db94011d3 20 ******************************************************************************
sahilmgandhi 18:6a4db94011d3 21 * @attention
sahilmgandhi 18:6a4db94011d3 22 *
sahilmgandhi 18:6a4db94011d3 23 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
sahilmgandhi 18:6a4db94011d3 24 *
sahilmgandhi 18:6a4db94011d3 25 * Redistribution and use in source and binary forms, with or without modification,
sahilmgandhi 18:6a4db94011d3 26 * are permitted provided that the following conditions are met:
sahilmgandhi 18:6a4db94011d3 27 * 1. Redistributions of source code must retain the above copyright notice,
sahilmgandhi 18:6a4db94011d3 28 * this list of conditions and the following disclaimer.
sahilmgandhi 18:6a4db94011d3 29 * 2. Redistributions in binary form must reproduce the above copyright notice,
sahilmgandhi 18:6a4db94011d3 30 * this list of conditions and the following disclaimer in the documentation
sahilmgandhi 18:6a4db94011d3 31 * and/or other materials provided with the distribution.
sahilmgandhi 18:6a4db94011d3 32 * 3. Neither the name of STMicroelectronics nor the names of its contributors
sahilmgandhi 18:6a4db94011d3 33 * may be used to endorse or promote products derived from this software
sahilmgandhi 18:6a4db94011d3 34 * without specific prior written permission.
sahilmgandhi 18:6a4db94011d3 35 *
sahilmgandhi 18:6a4db94011d3 36 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
sahilmgandhi 18:6a4db94011d3 37 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sahilmgandhi 18:6a4db94011d3 38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
sahilmgandhi 18:6a4db94011d3 39 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
sahilmgandhi 18:6a4db94011d3 40 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sahilmgandhi 18:6a4db94011d3 41 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
sahilmgandhi 18:6a4db94011d3 42 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
sahilmgandhi 18:6a4db94011d3 43 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
sahilmgandhi 18:6a4db94011d3 44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
sahilmgandhi 18:6a4db94011d3 45 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
sahilmgandhi 18:6a4db94011d3 46 *
sahilmgandhi 18:6a4db94011d3 47 ******************************************************************************
sahilmgandhi 18:6a4db94011d3 48 */
sahilmgandhi 18:6a4db94011d3 49
sahilmgandhi 18:6a4db94011d3 50 /** @addtogroup CMSIS
sahilmgandhi 18:6a4db94011d3 51 * @{
sahilmgandhi 18:6a4db94011d3 52 */
sahilmgandhi 18:6a4db94011d3 53
sahilmgandhi 18:6a4db94011d3 54 /** @addtogroup stm32l0xx
sahilmgandhi 18:6a4db94011d3 55 * @{
sahilmgandhi 18:6a4db94011d3 56 */
sahilmgandhi 18:6a4db94011d3 57
sahilmgandhi 18:6a4db94011d3 58 #ifndef __STM32L0xx_H
sahilmgandhi 18:6a4db94011d3 59 #define __STM32L0xx_H
sahilmgandhi 18:6a4db94011d3 60
sahilmgandhi 18:6a4db94011d3 61 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 62 extern "C" {
sahilmgandhi 18:6a4db94011d3 63 #endif /* __cplusplus */
sahilmgandhi 18:6a4db94011d3 64
sahilmgandhi 18:6a4db94011d3 65 /** @addtogroup Library_configuration_section
sahilmgandhi 18:6a4db94011d3 66 * @{
sahilmgandhi 18:6a4db94011d3 67 */
sahilmgandhi 18:6a4db94011d3 68
sahilmgandhi 18:6a4db94011d3 69 /**
sahilmgandhi 18:6a4db94011d3 70 * @brief STM32 Family
sahilmgandhi 18:6a4db94011d3 71 */
sahilmgandhi 18:6a4db94011d3 72 #if !defined (STM32L0)
sahilmgandhi 18:6a4db94011d3 73 #define STM32L0
sahilmgandhi 18:6a4db94011d3 74 #endif /* STM32L0 */
sahilmgandhi 18:6a4db94011d3 75
sahilmgandhi 18:6a4db94011d3 76 /* Uncomment the line below according to the target STM32 device used in your
sahilmgandhi 18:6a4db94011d3 77 application
sahilmgandhi 18:6a4db94011d3 78 */
sahilmgandhi 18:6a4db94011d3 79
sahilmgandhi 18:6a4db94011d3 80 #if !defined (STM32L011xx) && !defined (STM32L021xx) && \
sahilmgandhi 18:6a4db94011d3 81 !defined (STM32L031xx) && !defined (STM32L041xx) && \
sahilmgandhi 18:6a4db94011d3 82 !defined (STM32L051xx) && !defined (STM32L052xx) && !defined (STM32L053xx) && \
sahilmgandhi 18:6a4db94011d3 83 !defined (STM32L061xx) && !defined (STM32L062xx) && !defined (STM32L063xx) && \
sahilmgandhi 18:6a4db94011d3 84 !defined (STM32L071xx) && !defined (STM32L072xx) && !defined (STM32L073xx) && \
sahilmgandhi 18:6a4db94011d3 85 !defined (STM32L081xx) && !defined (STM32L082xx) && !defined (STM32L083xx) \
sahilmgandhi 18:6a4db94011d3 86 /* #define STM32L011xx */
sahilmgandhi 18:6a4db94011d3 87 /* #define STM32L021xx */
sahilmgandhi 18:6a4db94011d3 88 /* #define STM32L031xx */ /*!< STM32L031C6, STM32L031E6, STM32L031F6, STM32L031G6, STM32L031K6 Devices */
sahilmgandhi 18:6a4db94011d3 89 /* #define STM32L041xx */ /*!< STM32L041C6, STM32L041E6, STM32L041F6, STM32L041G6, STM32L041K6 Devices */
sahilmgandhi 18:6a4db94011d3 90 /* #define STM32L051xx */ /*!< STM32L051K8, STM32L051C6, STM32L051C8, STM32L051R6, STM32L051R8 Devices */
sahilmgandhi 18:6a4db94011d3 91 /* #define STM32L052xx */ /*!< STM32L052K6, STM32L052K8, STM32L052C6, STM32L052C8, STM32L052R6, STM32L052R8 Devices */
sahilmgandhi 18:6a4db94011d3 92 /* #define STM32L053xx */ /*!< STM32L053C6, STM32L053C8, STM32L053R6, STM32L053R8 Devices */
sahilmgandhi 18:6a4db94011d3 93 /* #define STM32L061xx */ /*!< */
sahilmgandhi 18:6a4db94011d3 94 /* #define STM32L062xx */ /*!< STM32L062K8 */
sahilmgandhi 18:6a4db94011d3 95 /* #define STM32L063xx */ /*!< STM32L063C8, STM32L063R8 */
sahilmgandhi 18:6a4db94011d3 96 /* #define STM32L071xx */ /*!< */
sahilmgandhi 18:6a4db94011d3 97 /* #define STM32L072xx */ /*!< */
sahilmgandhi 18:6a4db94011d3 98 #define STM32L073xx /*!< STM32L073V8, STM32L073VB, STM32L073RB, STM32L073VZ, STM32L073RZ Devices */
sahilmgandhi 18:6a4db94011d3 99 /* #define STM32L081xx */ /*!< */
sahilmgandhi 18:6a4db94011d3 100 /* #define STM32L082xx */ /*!< */
sahilmgandhi 18:6a4db94011d3 101 /* #define STM32L083xx */ /*!< */
sahilmgandhi 18:6a4db94011d3 102 #endif
sahilmgandhi 18:6a4db94011d3 103
sahilmgandhi 18:6a4db94011d3 104 /* Tip: To avoid modifying this file each time you need to switch between these
sahilmgandhi 18:6a4db94011d3 105 devices, you can define the device in your toolchain compiler preprocessor.
sahilmgandhi 18:6a4db94011d3 106 */
sahilmgandhi 18:6a4db94011d3 107 #if !defined (USE_HAL_DRIVER)
sahilmgandhi 18:6a4db94011d3 108 /**
sahilmgandhi 18:6a4db94011d3 109 * @brief Comment the line below if you will not use the peripherals drivers.
sahilmgandhi 18:6a4db94011d3 110 In this case, these drivers will not be included and the application code will
sahilmgandhi 18:6a4db94011d3 111 be based on direct access to peripherals registers
sahilmgandhi 18:6a4db94011d3 112 */
sahilmgandhi 18:6a4db94011d3 113 #define USE_HAL_DRIVER
sahilmgandhi 18:6a4db94011d3 114 #endif /* USE_HAL_DRIVER */
sahilmgandhi 18:6a4db94011d3 115
sahilmgandhi 18:6a4db94011d3 116 /**
sahilmgandhi 18:6a4db94011d3 117 * @brief CMSIS Device version number V1.7.0
sahilmgandhi 18:6a4db94011d3 118 */
sahilmgandhi 18:6a4db94011d3 119 #define __STM32L0xx_CMSIS_VERSION_MAIN (0x01) /*!< [31:24] main version */
sahilmgandhi 18:6a4db94011d3 120 #define __STM32L0xx_CMSIS_VERSION_SUB1 (0x07) /*!< [23:16] sub1 version */
sahilmgandhi 18:6a4db94011d3 121 #define __STM32L0xx_CMSIS_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
sahilmgandhi 18:6a4db94011d3 122 #define __STM32L0xx_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */
sahilmgandhi 18:6a4db94011d3 123 #define __STM32L0xx_CMSIS_VERSION ((__STM32L0xx_CMSIS_VERSION_MAIN << 24)\
sahilmgandhi 18:6a4db94011d3 124 |(__STM32L0xx_CMSIS_VERSION_SUB1 << 16)\
sahilmgandhi 18:6a4db94011d3 125 |(__STM32L0xx_CMSIS_VERSION_SUB2 << 8 )\
sahilmgandhi 18:6a4db94011d3 126 |(__STM32L0xx_CMSIS_VERSION_RC))
sahilmgandhi 18:6a4db94011d3 127
sahilmgandhi 18:6a4db94011d3 128 /**
sahilmgandhi 18:6a4db94011d3 129 * @}
sahilmgandhi 18:6a4db94011d3 130 */
sahilmgandhi 18:6a4db94011d3 131
sahilmgandhi 18:6a4db94011d3 132 /** @addtogroup Device_Included
sahilmgandhi 18:6a4db94011d3 133 * @{
sahilmgandhi 18:6a4db94011d3 134 */
sahilmgandhi 18:6a4db94011d3 135 #if defined(STM32L011xx)
sahilmgandhi 18:6a4db94011d3 136 #include "stm32l011xx.h"
sahilmgandhi 18:6a4db94011d3 137 #elif defined(STM32L021xx)
sahilmgandhi 18:6a4db94011d3 138 #include "stm32l021xx.h"
sahilmgandhi 18:6a4db94011d3 139 #elif defined(STM32L031xx)
sahilmgandhi 18:6a4db94011d3 140 #include "stm32l031xx.h"
sahilmgandhi 18:6a4db94011d3 141 #elif defined(STM32L041xx)
sahilmgandhi 18:6a4db94011d3 142 #include "stm32l041xx.h"
sahilmgandhi 18:6a4db94011d3 143 #elif defined(STM32L051xx)
sahilmgandhi 18:6a4db94011d3 144 #include "stm32l051xx.h"
sahilmgandhi 18:6a4db94011d3 145 #elif defined(STM32L052xx)
sahilmgandhi 18:6a4db94011d3 146 #include "stm32l052xx.h"
sahilmgandhi 18:6a4db94011d3 147 #elif defined(STM32L053xx)
sahilmgandhi 18:6a4db94011d3 148 #include "stm32l053xx.h"
sahilmgandhi 18:6a4db94011d3 149 #elif defined(STM32L062xx)
sahilmgandhi 18:6a4db94011d3 150 #include "stm32l062xx.h"
sahilmgandhi 18:6a4db94011d3 151 #elif defined(STM32L063xx)
sahilmgandhi 18:6a4db94011d3 152 #include "stm32l063xx.h"
sahilmgandhi 18:6a4db94011d3 153 #elif defined(STM32L061xx)
sahilmgandhi 18:6a4db94011d3 154 #include "stm32l061xx.h"
sahilmgandhi 18:6a4db94011d3 155 #elif defined(STM32L071xx)
sahilmgandhi 18:6a4db94011d3 156 #include "stm32l071xx.h"
sahilmgandhi 18:6a4db94011d3 157 #elif defined(STM32L072xx)
sahilmgandhi 18:6a4db94011d3 158 #include "stm32l072xx.h"
sahilmgandhi 18:6a4db94011d3 159 #elif defined(STM32L073xx)
sahilmgandhi 18:6a4db94011d3 160 #include "stm32l073xx.h"
sahilmgandhi 18:6a4db94011d3 161 #elif defined(STM32L082xx)
sahilmgandhi 18:6a4db94011d3 162 #include "stm32l082xx.h"
sahilmgandhi 18:6a4db94011d3 163 #elif defined(STM32L083xx)
sahilmgandhi 18:6a4db94011d3 164 #include "stm32l083xx.h"
sahilmgandhi 18:6a4db94011d3 165 #elif defined(STM32L081xx)
sahilmgandhi 18:6a4db94011d3 166 #include "stm32l081xx.h"
sahilmgandhi 18:6a4db94011d3 167 #else
sahilmgandhi 18:6a4db94011d3 168 #error "Please select first the target STM32L0xx device used in your application (in stm32l0xx.h file)"
sahilmgandhi 18:6a4db94011d3 169 #endif
sahilmgandhi 18:6a4db94011d3 170
sahilmgandhi 18:6a4db94011d3 171 /**
sahilmgandhi 18:6a4db94011d3 172 * @}
sahilmgandhi 18:6a4db94011d3 173 */
sahilmgandhi 18:6a4db94011d3 174
sahilmgandhi 18:6a4db94011d3 175 /** @addtogroup Exported_types
sahilmgandhi 18:6a4db94011d3 176 * @{
sahilmgandhi 18:6a4db94011d3 177 */
sahilmgandhi 18:6a4db94011d3 178 typedef enum
sahilmgandhi 18:6a4db94011d3 179 {
sahilmgandhi 18:6a4db94011d3 180 RESET = 0,
sahilmgandhi 18:6a4db94011d3 181 SET = !RESET
sahilmgandhi 18:6a4db94011d3 182 } FlagStatus, ITStatus;
sahilmgandhi 18:6a4db94011d3 183
sahilmgandhi 18:6a4db94011d3 184 typedef enum
sahilmgandhi 18:6a4db94011d3 185 {
sahilmgandhi 18:6a4db94011d3 186 DISABLE = 0,
sahilmgandhi 18:6a4db94011d3 187 ENABLE = !DISABLE
sahilmgandhi 18:6a4db94011d3 188 } FunctionalState;
sahilmgandhi 18:6a4db94011d3 189 #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
sahilmgandhi 18:6a4db94011d3 190
sahilmgandhi 18:6a4db94011d3 191 typedef enum
sahilmgandhi 18:6a4db94011d3 192 {
sahilmgandhi 18:6a4db94011d3 193 ERROR = 0,
sahilmgandhi 18:6a4db94011d3 194 SUCCESS = !ERROR
sahilmgandhi 18:6a4db94011d3 195 } ErrorStatus;
sahilmgandhi 18:6a4db94011d3 196
sahilmgandhi 18:6a4db94011d3 197 /**
sahilmgandhi 18:6a4db94011d3 198 * @}
sahilmgandhi 18:6a4db94011d3 199 */
sahilmgandhi 18:6a4db94011d3 200
sahilmgandhi 18:6a4db94011d3 201
sahilmgandhi 18:6a4db94011d3 202 /** @addtogroup Exported_macro
sahilmgandhi 18:6a4db94011d3 203 * @{
sahilmgandhi 18:6a4db94011d3 204 */
sahilmgandhi 18:6a4db94011d3 205 #define SET_BIT(REG, BIT) ((REG) |= (BIT))
sahilmgandhi 18:6a4db94011d3 206
sahilmgandhi 18:6a4db94011d3 207 #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
sahilmgandhi 18:6a4db94011d3 208
sahilmgandhi 18:6a4db94011d3 209 #define READ_BIT(REG, BIT) ((REG) & (BIT))
sahilmgandhi 18:6a4db94011d3 210
sahilmgandhi 18:6a4db94011d3 211 #define CLEAR_REG(REG) ((REG) = (0x0))
sahilmgandhi 18:6a4db94011d3 212
sahilmgandhi 18:6a4db94011d3 213 #define WRITE_REG(REG, VAL) ((REG) = (VAL))
sahilmgandhi 18:6a4db94011d3 214
sahilmgandhi 18:6a4db94011d3 215 #define READ_REG(REG) ((REG))
sahilmgandhi 18:6a4db94011d3 216
sahilmgandhi 18:6a4db94011d3 217 #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
sahilmgandhi 18:6a4db94011d3 218
sahilmgandhi 18:6a4db94011d3 219 /**
sahilmgandhi 18:6a4db94011d3 220 * @}
sahilmgandhi 18:6a4db94011d3 221 */
sahilmgandhi 18:6a4db94011d3 222
sahilmgandhi 18:6a4db94011d3 223 #if defined (USE_HAL_DRIVER)
sahilmgandhi 18:6a4db94011d3 224 #include "stm32l0xx_hal.h"
sahilmgandhi 18:6a4db94011d3 225 #endif /* USE_HAL_DRIVER */
sahilmgandhi 18:6a4db94011d3 226
sahilmgandhi 18:6a4db94011d3 227 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 228 }
sahilmgandhi 18:6a4db94011d3 229 #endif /* __cplusplus */
sahilmgandhi 18:6a4db94011d3 230
sahilmgandhi 18:6a4db94011d3 231 #endif /* __STM32L0xx_H */
sahilmgandhi 18:6a4db94011d3 232 /**
sahilmgandhi 18:6a4db94011d3 233 * @}
sahilmgandhi 18:6a4db94011d3 234 */
sahilmgandhi 18:6a4db94011d3 235
sahilmgandhi 18:6a4db94011d3 236 /**
sahilmgandhi 18:6a4db94011d3 237 * @}
sahilmgandhi 18:6a4db94011d3 238 */
sahilmgandhi 18:6a4db94011d3 239
sahilmgandhi 18:6a4db94011d3 240
sahilmgandhi 18:6a4db94011d3 241
sahilmgandhi 18:6a4db94011d3 242
sahilmgandhi 18:6a4db94011d3 243 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/