1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #include <stdint.h>
- #include <stdbool.h>
- #include "nrf.h"
- #include "nrf_erratas.h"
- #include "system_nrf51.h"
- #define __SYSTEM_CLOCK (16000000UL)
- #if defined ( __CC_ARM )
- uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK;
- #elif defined ( __ICCARM__ )
- __root uint32_t SystemCoreClock = __SYSTEM_CLOCK;
- #elif defined ( __GNUC__ )
- uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK;
- #endif
- void SystemCoreClockUpdate(void)
- {
- SystemCoreClock = __SYSTEM_CLOCK;
- }
- void SystemInit(void)
- {
-
-
- if (nrf51_errata_26())
- {
- *(uint32_t volatile *)0x40000504 = 0xC007FFDF;
- *(uint32_t volatile *)0x40006C18 = 0x00008000;
- }
-
- if (nrf51_errata_59())
- {
- NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos;
- }
-
- if (nrf51_errata_76()){
- if (*(uint32_t volatile *)0x4006EC00 != 1){
- *(uint32_t volatile *)0x4006EC00 = 0x9375;
- while (*(uint32_t volatile *)0x4006EC00 != 1){
- }
- }
- *(uint32_t volatile *)0x4006EC14 = 0xC0;
- }
- SystemCoreClockUpdate();
- }
|