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