mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_WIZNET/TARGET_W7500x/system_W7500x.c@636:b0d178e9fa10, 2016-07-07 (annotated)
- Committer:
- lzbpli
- Date:
- Thu Jul 07 06:48:59 2016 +0000
- Revision:
- 636:b0d178e9fa10
- Parent:
- 619:034e698bc035
l053
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 558:0880f51c4036 | 1 | /**************************************************************************//** |
mbed_official | 558:0880f51c4036 | 2 | * @file system_CMSDK_CM0.c |
mbed_official | 558:0880f51c4036 | 3 | * @brief CMSIS Cortex-M0 Device Peripheral Access Layer Source File for |
mbed_official | 558:0880f51c4036 | 4 | * Device CMSDK |
mbed_official | 558:0880f51c4036 | 5 | * @version V3.01 |
mbed_official | 558:0880f51c4036 | 6 | * @date 06. March 2012 |
mbed_official | 558:0880f51c4036 | 7 | * |
mbed_official | 558:0880f51c4036 | 8 | * @note |
mbed_official | 558:0880f51c4036 | 9 | * Copyright (C) 2010-2012 ARM Limited. All rights reserved. |
mbed_official | 558:0880f51c4036 | 10 | * |
mbed_official | 558:0880f51c4036 | 11 | * @par |
mbed_official | 558:0880f51c4036 | 12 | * ARM Limited (ARM) is supplying this software for use with Cortex-M |
mbed_official | 558:0880f51c4036 | 13 | * processor based microcontrollers. This file can be freely distributed |
mbed_official | 558:0880f51c4036 | 14 | * within development tools that are supporting such ARM based processors. |
mbed_official | 558:0880f51c4036 | 15 | * |
mbed_official | 558:0880f51c4036 | 16 | * @par |
mbed_official | 558:0880f51c4036 | 17 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED |
mbed_official | 558:0880f51c4036 | 18 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF |
mbed_official | 558:0880f51c4036 | 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. |
mbed_official | 558:0880f51c4036 | 20 | * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR |
mbed_official | 558:0880f51c4036 | 21 | * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
mbed_official | 558:0880f51c4036 | 22 | * |
mbed_official | 558:0880f51c4036 | 23 | ******************************************************************************/ |
mbed_official | 558:0880f51c4036 | 24 | |
mbed_official | 558:0880f51c4036 | 25 | |
mbed_official | 558:0880f51c4036 | 26 | #include "system_W7500x.h" |
mbed_official | 558:0880f51c4036 | 27 | |
mbed_official | 558:0880f51c4036 | 28 | |
mbed_official | 558:0880f51c4036 | 29 | /*---------------------------------------------------------------------------- |
mbed_official | 558:0880f51c4036 | 30 | DEFINES |
mbed_official | 558:0880f51c4036 | 31 | *----------------------------------------------------------------------------*/ |
mbed_official | 558:0880f51c4036 | 32 | //#define SYSCLK_EXTERN_OSC |
mbed_official | 558:0880f51c4036 | 33 | |
mbed_official | 558:0880f51c4036 | 34 | |
mbed_official | 558:0880f51c4036 | 35 | |
mbed_official | 558:0880f51c4036 | 36 | /*---------------------------------------------------------------------------- |
mbed_official | 558:0880f51c4036 | 37 | Clock Variable definitions |
mbed_official | 558:0880f51c4036 | 38 | *----------------------------------------------------------------------------*/ |
mbed_official | 558:0880f51c4036 | 39 | uint32_t SystemFrequency = 0; /*!< System Clock Frequency (Core Clock) */ |
mbed_official | 558:0880f51c4036 | 40 | uint32_t SystemCoreClock = 0; /*!< Processor Clock Frequency */ |
mbed_official | 558:0880f51c4036 | 41 | |
mbed_official | 558:0880f51c4036 | 42 | |
mbed_official | 558:0880f51c4036 | 43 | /*---------------------------------------------------------------------------- |
mbed_official | 558:0880f51c4036 | 44 | Clock functions |
mbed_official | 558:0880f51c4036 | 45 | *----------------------------------------------------------------------------*/ |
mbed_official | 558:0880f51c4036 | 46 | void SystemCoreClockUpdate (void) /* Get Core Clock Frequency */ |
mbed_official | 558:0880f51c4036 | 47 | { |
mbed_official | 558:0880f51c4036 | 48 | uint8_t M,N,OD; |
mbed_official | 558:0880f51c4036 | 49 | |
mbed_official | 558:0880f51c4036 | 50 | #ifdef SYSCLK_EXTERN_OSC |
mbed_official | 558:0880f51c4036 | 51 | CRG->PLL_IFSR = CRG_PLL_IFSR_OCLK; |
mbed_official | 558:0880f51c4036 | 52 | #else |
mbed_official | 558:0880f51c4036 | 53 | CRG->PLL_IFSR = CRG_PLL_IFSR_RCLK; |
mbed_official | 558:0880f51c4036 | 54 | #endif |
mbed_official | 558:0880f51c4036 | 55 | OD = (1 << (CRG->PLL_FCR & 0x01)) * (1 << ((CRG->PLL_FCR & 0x02) >> 1)); |
mbed_official | 558:0880f51c4036 | 56 | N = (CRG->PLL_FCR >> 8 ) & 0x3F; |
mbed_official | 558:0880f51c4036 | 57 | M = (CRG->PLL_FCR >> 16) & 0x3F; |
mbed_official | 558:0880f51c4036 | 58 | |
mbed_official | 558:0880f51c4036 | 59 | #ifdef SYSCLK_EXTERN_OSC |
mbed_official | 558:0880f51c4036 | 60 | SystemCoreClock = EXTERN_XTAL * M / N * 1 / OD; |
mbed_official | 558:0880f51c4036 | 61 | #else |
mbed_official | 558:0880f51c4036 | 62 | SystemCoreClock = INTERN_XTAL * M / N * 1 / OD; |
mbed_official | 558:0880f51c4036 | 63 | #endif |
mbed_official | 558:0880f51c4036 | 64 | } |
mbed_official | 558:0880f51c4036 | 65 | |
mbed_official | 558:0880f51c4036 | 66 | uint32_t GetSystemClock() |
mbed_official | 558:0880f51c4036 | 67 | { |
mbed_official | 558:0880f51c4036 | 68 | return SystemCoreClock; |
mbed_official | 558:0880f51c4036 | 69 | } |
mbed_official | 558:0880f51c4036 | 70 | |
mbed_official | 558:0880f51c4036 | 71 | |
mbed_official | 558:0880f51c4036 | 72 | /** |
mbed_official | 558:0880f51c4036 | 73 | * Initialize the system |
mbed_official | 558:0880f51c4036 | 74 | * |
mbed_official | 558:0880f51c4036 | 75 | * @param none |
mbed_official | 558:0880f51c4036 | 76 | * @return none |
mbed_official | 558:0880f51c4036 | 77 | * |
mbed_official | 558:0880f51c4036 | 78 | * @brief Setup the microcontroller system. |
mbed_official | 558:0880f51c4036 | 79 | * Initialize the System. |
mbed_official | 558:0880f51c4036 | 80 | */ |
mbed_official | 558:0880f51c4036 | 81 | void SystemInit (void) |
mbed_official | 558:0880f51c4036 | 82 | { |
mbed_official | 558:0880f51c4036 | 83 | uint8_t M,N,OD; |
mbed_official | 558:0880f51c4036 | 84 | |
mbed_official | 558:0880f51c4036 | 85 | (*((volatile uint32_t *)(W7500x_TRIM_BGT))) = (*((volatile uint32_t *)(W7500x_INFO_BGT))); |
mbed_official | 558:0880f51c4036 | 86 | (*((volatile uint32_t *)(W7500x_TRIM_OSC))) = (*((volatile uint32_t *)(W7500x_INFO_OSC))); |
mbed_official | 558:0880f51c4036 | 87 | |
mbed_official | 558:0880f51c4036 | 88 | |
mbed_official | 558:0880f51c4036 | 89 | // Set PLL input frequency |
mbed_official | 558:0880f51c4036 | 90 | #ifdef SYSCLK_EXTERN_OSC |
mbed_official | 558:0880f51c4036 | 91 | CRG->PLL_IFSR = CRG_PLL_IFSR_OCLK; |
mbed_official | 558:0880f51c4036 | 92 | #else |
mbed_official | 558:0880f51c4036 | 93 | CRG->PLL_IFSR = CRG_PLL_IFSR_RCLK; |
mbed_official | 558:0880f51c4036 | 94 | #endif |
mbed_official | 558:0880f51c4036 | 95 | OD = (1 << (CRG->PLL_FCR & 0x01)) * (1 << ((CRG->PLL_FCR & 0x02) >> 1)); |
mbed_official | 558:0880f51c4036 | 96 | N = (CRG->PLL_FCR >> 8 ) & 0x3F; |
mbed_official | 558:0880f51c4036 | 97 | M = (CRG->PLL_FCR >> 16) & 0x3F; |
mbed_official | 558:0880f51c4036 | 98 | |
mbed_official | 558:0880f51c4036 | 99 | #ifdef SYSCLK_EXTERN_OSC |
mbed_official | 558:0880f51c4036 | 100 | SystemCoreClock = EXTERN_XTAL * M / N * 1 / OD; |
mbed_official | 558:0880f51c4036 | 101 | #else |
mbed_official | 558:0880f51c4036 | 102 | SystemCoreClock = INTERN_XTAL * M / N * 1 / OD; |
mbed_official | 558:0880f51c4036 | 103 | #endif |
mbed_official | 558:0880f51c4036 | 104 | } |