/*******************************************************************************
* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*
* $Date: 2017-03-14 17:41:58 -0500 (Tue, 14 Mar 2017) $
* $Revision: 27017 $
*
******************************************************************************/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "max32625.h"
#include "clkman_regs.h"
#include "adc_regs.h"
#include "pwrseq_regs.h"
#include "pwrman_regs.h"
#include "icc_regs.h"
#include "flc_regs.h"
#include "rtc_regs.h"
#include "trim_regs.h"
#ifndef RO_FREQ
#define RO_FREQ 96000000
#endif
#ifndef LP0_POST_HOOK
#define LP0_POST_HOOK
#endif
extern void (* const __isr_vector[])(void);
uint32_t SystemCoreClock = RO_FREQ/2;
void SystemCoreClockUpdate(void)
{
#ifdef EMULATOR
SystemCoreClock = RO_FREQ;
#else /* real hardware */
if(MXC_PWRSEQ->reg0 & MXC_F_PWRSEQ_REG0_PWR_RCEN_RUN) {
/* 4 MHz source */
if(MXC_PWRSEQ->reg3 & MXC_F_PWRSEQ_REG3_PWR_RC_DIV) {
SystemCoreClock = (4000000 / (0x1 << ((MXC_PWRSEQ->reg3 & MXC_F_PWRSEQ_REG3_PWR_RC_DIV) >>
MXC_F_PWRSEQ_REG3_PWR_RC_DIV_POS)));
} else {
SystemCoreClock = 4000000;
}
} else {
/* 96 MHz source */
if(MXC_PWRSEQ->reg3 & MXC_F_PWRSEQ_REG3_PWR_RO_DIV) {
SystemCoreClock = (RO_FREQ / (0x1 << ((MXC_PWRSEQ->reg3 & MXC_F_PWRSEQ_REG3_PWR_RO_DIV) >>
MXC_F_PWRSEQ_REG3_PWR_RO_DIV_POS)));
} else {
SystemCoreClock = RO_FREQ;
}
}
#endif
}
void CLKMAN_TrimRO(void)
{
uint32_t running;
uint32_t trim;
/* Step 1: enable 32KHz RTC */
running = MXC_PWRSEQ->reg0 & MXC_F_PWRSEQ_REG0_PWR_RTCEN_RUN;
MXC_PWRSEQ->reg0 |= MXC_F_PWRSEQ_REG0_PWR_RTCEN_RUN;
/* Wait for RTC warm-up */
while(MXC_RTCCFG->osc_ctrl & MXC_F_RTC_OSC_CTRL_OSC_WARMUP_ENABLE) {}
/* Step 2: enable RO calibration complete interrupt */
MXC_ADC->intr |= MXC_F_ADC_INTR_RO_CAL_DONE_IE;
/* Step 3: clear RO calibration complete interrupt */
MXC_ADC->intr |= MXC_F_ADC_INTR_RO_CAL_DONE_IF;
/* Step 4: -- NO LONGER NEEDED / HANDLED BY STARTUP CODE -- */
/* Step 5: write initial trim to frequency calibration initial condition register */
trim = (MXC_PWRSEQ->reg6 & MXC_F_PWRSEQ_REG6_PWR_TRIM_OSC_VREF) >> MXC_F_PWRSEQ_REG6_PWR_TRIM_OSC_VREF_POS;
MXC_ADC->ro_cal1 = (MXC_ADC->ro_cal1 & ~MXC_F_ADC_RO_CAL1_TRM_INIT) |
((trim << MXC_F_ADC_RO_CAL1_TRM_INIT_POS) & MXC_F_ADC_RO_CAL1_TRM_INIT);
/* Step 6: load initial trim to active frequency trim register */
MXC_ADC->ro_cal0 |= MXC_F_ADC_RO_CAL0_RO_CAL_LOAD;
/* Step 7: enable frequency loop to control RO trim */
MXC_ADC->ro_cal0 |= MXC_F_ADC_RO_CAL0_RO_CAL_EN;
/* Step 8: run frequency calibration in atomic mode */
MXC_ADC->ro_cal0 |= MXC_F_ADC_RO_CAL0_RO_CAL_ATOMIC;
/* Step 9: waiting for ro_cal_done flag */
while(!(MXC_ADC->intr & MXC_F_ADC_INTR_RO_CAL_DONE_IF));
/* Step 10: stop frequency calibration */
MXC_ADC->ro_cal0 &= ~MXC_F_ADC_RO_CAL0_RO_CAL_RUN;
/* Step 11: disable RO calibration complete interrupt */
MXC_ADC->intr &= ~MXC_F_ADC_INTR_RO_CAL_DONE_IE;
/* Step 12: read final frequency trim value */
trim = (MXC_ADC->ro_cal0 & MXC_F_ADC_RO_CAL0_RO_TRM) >> MXC_F_ADC_RO_CAL0_RO_TRM_POS;
/* Step 13: write final trim to RO flash trim shadow register */
MXC_PWRSEQ->reg6 = (MXC_PWRSEQ->reg6 & ~MXC_F_PWRSEQ_REG6_PWR_TRIM_OSC_VREF) |
((trim << MXC_F_PWRSEQ_REG6_PWR_TRIM_OSC_VREF_POS) & MXC_F_PWRSEQ_REG6_PWR_TRIM_OSC_VREF);
/* Step 14: restore RTC status */
if (!running) {
MXC_PWRSEQ->reg0 &= ~MXC_F_PWRSEQ_REG0_PWR_RTCEN_RUN;
}
/* Step 15: disable frequency loop to control RO trim */
MXC_ADC->ro_cal0 &= ~MXC_F_ADC_RO_CAL0_RO_CAL_EN;
}
static void ICC_Enable(void)
{
/* Invalidate cache and wait until ready */
MXC_ICC->invdt_all = 1;
while (!(MXC_ICC->ctrl_stat & MXC_F_ICC_CTRL_STAT_READY));
/* Enable cache */
MXC_ICC->ctrl_stat |= MXC_F_ICC_CTRL_STAT_ENABLE;
/* Must invalidate a second time for proper use */
MXC_ICC->invdt_all = 1;
}
/* This function is called before C runtime initialization and can be
* implemented by the application for early initializations. If a value other
* than '0' is returned, the C runtime initialization will be skipped.
*
* You may over-ride this function in your program by defining a custom
* PreInit(), but care should be taken to reproduce the initilization steps
* or a non-functional system may result.
*/
__weak int PreInit(void)
{
/* Increase system clock to 96 MHz */
MXC_CLKMAN->clk_ctrl = MXC_V_CLKMAN_CLK_CTRL_SYSTEM_SOURCE_SELECT_96MHZ_RO;
/* Performance-measurement hook, may be defined as nothing */
LP0_POST_HOOK;
/* Enable cache here to reduce boot time */
ICC_Enable();
return 0;
}
/* This function can be implemented by the application to initialize the board */
__weak int Board_Init(void)
{
/* Do nothing */
return 0;
}
/* This function is called just before control is transferred to main().
*
* You may over-ride this function in your program by defining a custom
* SystemInit(), but care should be taken to reproduce the initialization
* steps or a non-functional system may result.
*/
__weak void SystemInit(void)
{
/* Configure the interrupt controller to use the application vector table in */
/* the application space */
#if defined ( __GNUC__)
/* IAR sets the VTOR pointer prior to SystemInit and causes stack corruption to change it here. */
__disable_irq(); /* Disable interrupts */
SCB->VTOR = (uint32_t)__isr_vector; /* set the Vector Table to point at our ISR table */
__DSB(); /* bus sync */
__enable_irq(); /* enable interrupts */
#endif /* __GNUC__ */
/* Copy trim information from shadow registers into power manager registers */
/* NOTE: Checks have been added to prevent bad/missing trim values from being loaded */
if ((MXC_FLC->ctrl & MXC_F_FLC_CTRL_INFO_BLOCK_VALID) &&
(MXC_TRIM->for_pwr_reg5 != 0x
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
DS18B20示例代码,含search rom的算法的 (114个子文件)
max32625.h.0000 42KB
max32625.h.0000 42KB
startup_max32625.s.0000 15KB
system_max32625.c.0000 12KB
mxc_config.h.0000 2KB
1wire.axf 367KB
system_max32625.c 12KB
DS18b20drv.c 9KB
main.c 5KB
addition.c 2KB
mxc_sys.crf 241KB
max14690.crf 237KB
nhd12832.crf 211KB
stdio.crf 208KB
main.crf 206KB
i2cm.crf 206KB
board.crf 204KB
ds18b20drv.crf 204KB
addition.crf 201KB
owm.crf 201KB
uart.crf 201KB
spim.crf 201KB
mx25.crf 198KB
pt.crf 198KB
led.crf 194KB
gpio.crf 193KB
system_max32625.crf 149KB
lp.crf 141KB
clkman.crf 99KB
ioman.crf 86KB
pmu.crf 80KB
pb.crf 79KB
flc.crf 68KB
aes.crf 64KB
nvic_table.crf 58KB
icc.crf 58KB
mxc_lock.crf 57KB
mxc_assert.crf 56KB
max14690.d 5KB
stdio.d 4KB
board.d 4KB
nhd12832.d 4KB
main.d 4KB
mxc_sys.d 4KB
led.d 4KB
ds18b20drv.d 4KB
uart.d 4KB
spim.d 4KB
mx25.d 3KB
i2cm.d 3KB
addition.d 3KB
owm.d 3KB
pt.d 3KB
gpio.d 3KB
system_max32625.d 2KB
lp.d 2KB
clkman.d 2KB
pb.d 2KB
pmu.d 1KB
ioman.d 1KB
aes.d 1KB
nvic_table.d 1KB
icc.d 1KB
flc.d 1KB
mxc_lock.d 1KB
mxc_assert.d 1KB
startup_max32625.d 70B
1wire_Target 1.dep 91KB
max32625.h 42KB
max32625.h 42KB
DS18b20drv.h 4KB
mxc_config.h 2KB
addition.h 413B
RTE_Components.h 344B
1wire.htm 64KB
1wire.build_log.htm 5KB
ExtDll.iex 19B
HAL - Shortcut.lnk 1KB
1wire.lnp 971B
startup_max32625.lst 55KB
1wire.map 142KB
mxc_sys.o 369KB
nhd12832.o 315KB
max14690.o 311KB
i2cm.o 280KB
owm.o 275KB
uart.o 265KB
spim.o 264KB
mx25.o 262KB
stdio.o 262KB
board.o 258KB
ds18b20drv.o 257KB
main.o 252KB
addition.o 249KB
gpio.o 249KB
pt.o 248KB
led.o 245KB
system_max32625.o 192KB
lp.o 185KB
clkman.o 136KB
共 114 条
- 1
- 2
资源评论
- 饼丶酱2020-05-18程序有问题,根本没有romid 搜索的相关代码
barthezqqa
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功