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 ******************************************************************************
sahilmgandhi 18:6a4db94011d3 3 * @file clock.h
sahilmgandhi 18:6a4db94011d3 4 * @brief Header of clock hw module functions
sahilmgandhi 18:6a4db94011d3 5 * @internal
sahilmgandhi 18:6a4db94011d3 6 * @author ON Semiconductor
sahilmgandhi 18:6a4db94011d3 7 * $Rev: 3414 $
sahilmgandhi 18:6a4db94011d3 8 * $Date: 2015-06-05 13:27:04 +0530 (Fri, 05 Jun 2015) $
sahilmgandhi 18:6a4db94011d3 9 ******************************************************************************
sahilmgandhi 18:6a4db94011d3 10 * Copyright 2016 Semiconductor Components Industries LLC (d/b/a “ON Semiconductor”).
sahilmgandhi 18:6a4db94011d3 11 * All rights reserved. This software and/or documentation is licensed by ON Semiconductor
sahilmgandhi 18:6a4db94011d3 12 * under limited terms and conditions. The terms and conditions pertaining to the software
sahilmgandhi 18:6a4db94011d3 13 * and/or documentation are available at http://www.onsemi.com/site/pdf/ONSEMI_T&C.pdf
sahilmgandhi 18:6a4db94011d3 14 * (“ON Semiconductor Standard Terms and Conditions of Sale, Section 8 Software”) and
sahilmgandhi 18:6a4db94011d3 15 * if applicable the software license agreement. Do not use this software and/or
sahilmgandhi 18:6a4db94011d3 16 * documentation unless you have carefully read and you agree to the limited terms and
sahilmgandhi 18:6a4db94011d3 17 * conditions. By using this software and/or documentation, you agree to the limited
sahilmgandhi 18:6a4db94011d3 18 * terms and conditions.
sahilmgandhi 18:6a4db94011d3 19 *
sahilmgandhi 18:6a4db94011d3 20 * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
sahilmgandhi 18:6a4db94011d3 21 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
sahilmgandhi 18:6a4db94011d3 22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
sahilmgandhi 18:6a4db94011d3 23 * ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL,
sahilmgandhi 18:6a4db94011d3 24 * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
sahilmgandhi 18:6a4db94011d3 25 * @endinternal
sahilmgandhi 18:6a4db94011d3 26 *
sahilmgandhi 18:6a4db94011d3 27 * @ingroup clock
sahilmgandhi 18:6a4db94011d3 28 */
sahilmgandhi 18:6a4db94011d3 29
sahilmgandhi 18:6a4db94011d3 30 #ifndef CLOCK_H_
sahilmgandhi 18:6a4db94011d3 31 #define CLOCK_H_
sahilmgandhi 18:6a4db94011d3 32
sahilmgandhi 18:6a4db94011d3 33 /*************************************************************************************************
sahilmgandhi 18:6a4db94011d3 34 * *
sahilmgandhi 18:6a4db94011d3 35 * Header files *
sahilmgandhi 18:6a4db94011d3 36 * *
sahilmgandhi 18:6a4db94011d3 37 *************************************************************************************************/
sahilmgandhi 18:6a4db94011d3 38
sahilmgandhi 18:6a4db94011d3 39 #include "types.h"
sahilmgandhi 18:6a4db94011d3 40
sahilmgandhi 18:6a4db94011d3 41 /*************************************************************************************************
sahilmgandhi 18:6a4db94011d3 42 * *
sahilmgandhi 18:6a4db94011d3 43 * Symbolic Constants *
sahilmgandhi 18:6a4db94011d3 44 * *
sahilmgandhi 18:6a4db94011d3 45 *************************************************************************************************/
sahilmgandhi 18:6a4db94011d3 46
sahilmgandhi 18:6a4db94011d3 47 /** Peripherals clock disable defines /
sahilmgandhi 18:6a4db94011d3 48 * @details
sahilmgandhi 18:6a4db94011d3 49 */
sahilmgandhi 18:6a4db94011d3 50 #define CLOCK_TIMER0 (0x0) /**< <b> Timer 0 clock enable offset </b>*/
sahilmgandhi 18:6a4db94011d3 51 #define CLOCK_TIMER1 (0x1) /**< <b> Timer 1 clock enable offset </b>: */
sahilmgandhi 18:6a4db94011d3 52 #define CLOCK_TIMER2 (0x2) /**< <b> Timer 2 clock enable offset </b>: */
sahilmgandhi 18:6a4db94011d3 53 #define CLOCK_PAD0_0 (0x3) /**< <b> Unused offset </b> */
sahilmgandhi 18:6a4db94011d3 54 #define CLOCK_PAD0_1 (0x4) /**< <b> Unused offset </b> */
sahilmgandhi 18:6a4db94011d3 55 #define CLOCK_UART1 (0x5) /**< <b> UART 1 clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 56 #define CLOCK_SPI (0x6) /**< <b> SPI clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 57 #define CLOCK_I2C (0x7) /**< <b> I2C clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 58 #define CLOCK_UART2 (0x8) /**< <b> UART 2 clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 59 #define CLOCK_SPI2 (0x9) /**< <b> Unused offset </b>: */
sahilmgandhi 18:6a4db94011d3 60 #define CLOCK_WDOG (0xA) /**< <b> Watchdog clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 61 #define CLOCK_PWM (0xB) /**< <b> PWM clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 62 #define CLOCK_GPIO (0xC) /**< <b> GPIO clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 63 #define CLOCK_I2C2 (0xD) /**< <b> Unused offset </b> */
sahilmgandhi 18:6a4db94011d3 64 #define CLOCK_PAD2_1 (0xE) /**< <b> Unused offset </b> */
sahilmgandhi 18:6a4db94011d3 65 #define CLOCK_RTC (0xF) /**< <b> RTC clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 66 #define CLOCK_CROSSB (0x10) /**< <b> Crossbar clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 67 #define CLOCK_RAND (0x11) /**< <b> Randomizer clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 68 #define CLOCK_PAD3_0 (0x12) /**< <b> Unused offset </b> */
sahilmgandhi 18:6a4db94011d3 69 #define CLOCK_PAD3_1 (0x13) /**< <b> Unused offset </b> */
sahilmgandhi 18:6a4db94011d3 70 #define CLOCK_MACHW (0x14) /**< <b> macHw clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 71 #define CLOCK_ADC (0x15) /**< <b> ADC clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 72 #define CLOCK_AES (0x16) /**< <b> AES clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 73 #define CLOCK_FLASH (0x17) /**< <b> Flash controller clock enable offset</b> */
sahilmgandhi 18:6a4db94011d3 74 #define CLOCK_PAD4_0 (0x18) /**< <b> Unused offset </b> */
sahilmgandhi 18:6a4db94011d3 75 #define CLOCK_RFANA (0x19) /**< <b> rfAna clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 76 #define CLOCK_IO (0x1A) /**< <b> IO clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 77 #define CLOCK_PAD5_0 (0x1B) /**< <b> Unused offset </b> */
sahilmgandhi 18:6a4db94011d3 78 #define CLOCK_PAD (0x1C) /**< <b> Pad clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 79 #define CLOCK_PMU (0x1D) /**< <b> Pmu clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 80 #define CLOCK_DMA (0x1E) /**< <b> DMA clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 81 #define CLOCK_TEST (0x1F) /**< <b> Test controller clock enable offset </b> */
sahilmgandhi 18:6a4db94011d3 82
sahilmgandhi 18:6a4db94011d3 83 #define CLOCK_ENABLE(a) CLOCKREG->PDIS.WORD &= ~(1 << a)
sahilmgandhi 18:6a4db94011d3 84 #define CLOCK_DISABLE(a) CLOCKREG->PDIS.WORD |= (uint32_t)(1 << a)
sahilmgandhi 18:6a4db94011d3 85 #define CLOCK_IS_ENABLED(a) (((CLOCKREG->PDIS.WORD >> a) & 1)?0:1)
sahilmgandhi 18:6a4db94011d3 86
sahilmgandhi 18:6a4db94011d3 87 /*************************************************************************************************
sahilmgandhi 18:6a4db94011d3 88 * *
sahilmgandhi 18:6a4db94011d3 89 * Functions *
sahilmgandhi 18:6a4db94011d3 90 * *
sahilmgandhi 18:6a4db94011d3 91 *************************************************************************************************/
sahilmgandhi 18:6a4db94011d3 92
sahilmgandhi 18:6a4db94011d3 93 /** Function to initialize clocks
sahilmgandhi 18:6a4db94011d3 94 * @details
sahilmgandhi 18:6a4db94011d3 95 * The function initializes clocks.
sahilmgandhi 18:6a4db94011d3 96 * This initialization includes:
sahilmgandhi 18:6a4db94011d3 97 * - Enable of external 32mHz oscillator
sahilmgandhi 18:6a4db94011d3 98 * - Disable of all peripheral clocks (to be turned on selectively when used later in the application)
sahilmgandhi 18:6a4db94011d3 99 * - Setting core frequency
sahilmgandhi 18:6a4db94011d3 100 */
sahilmgandhi 18:6a4db94011d3 101 void fClockInit(void);
sahilmgandhi 18:6a4db94011d3 102
sahilmgandhi 18:6a4db94011d3 103 /** Function to get peripheral clock frequency
sahilmgandhi 18:6a4db94011d3 104 * @details
sahilmgandhi 18:6a4db94011d3 105 * The function checks and returns peripheral clock frequency
sahilmgandhi 18:6a4db94011d3 106 * @return Peripheral clock frequency
sahilmgandhi 18:6a4db94011d3 107 */
sahilmgandhi 18:6a4db94011d3 108 uint32_t fClockGetPeriphClockfrequency();
sahilmgandhi 18:6a4db94011d3 109
sahilmgandhi 18:6a4db94011d3 110 /** Function to get peripheral clock frequency
sahilmgandhi 18:6a4db94011d3 111 * @details
sahilmgandhi 18:6a4db94011d3 112 * The function checks which input clock is sourcing 32kHz clock domain.
sahilmgandhi 18:6a4db94011d3 113 * This domain can be either sourced by:
sahilmgandhi 18:6a4db94011d3 114 * - Internal 32kHz oscillator
sahilmgandhi 18:6a4db94011d3 115 * - External 32.768kHz oscillator
sahilmgandhi 18:6a4db94011d3 116 * @return 32kHz clock domain frequency
sahilmgandhi 18:6a4db94011d3 117 */
sahilmgandhi 18:6a4db94011d3 118 uint16_t fClockGet32kClockfrequency();
sahilmgandhi 18:6a4db94011d3 119
sahilmgandhi 18:6a4db94011d3 120 /** Function to enable peripheral clock
sahilmgandhi 18:6a4db94011d3 121 * @details
sahilmgandhi 18:6a4db94011d3 122 * The function enables clock of peripheral indicated by parameter
sahilmgandhi 18:6a4db94011d3 123 * @param deviceId Peripheral ID whose clock must be enabled.
sahilmgandhi 18:6a4db94011d3 124 */
sahilmgandhi 18:6a4db94011d3 125 void fClockEnablePeriph(uint8_t deviceId);
sahilmgandhi 18:6a4db94011d3 126
sahilmgandhi 18:6a4db94011d3 127 /** Function to disable peripheral clock
sahilmgandhi 18:6a4db94011d3 128 * @details
sahilmgandhi 18:6a4db94011d3 129 * The function disables clock of peripheral indicated by parameter
sahilmgandhi 18:6a4db94011d3 130 * @param deviceId ID Peripheral whose clock must be disabled.
sahilmgandhi 18:6a4db94011d3 131 */
sahilmgandhi 18:6a4db94011d3 132 void fClockDisablePeriph(uint8_t deviceId);
sahilmgandhi 18:6a4db94011d3 133
sahilmgandhi 18:6a4db94011d3 134 #endif /* CLOCK_H_ */