导航

    Freqchip开发者论坛

    • 注册
    • 登录
    • 搜索
    • 版块
    • 最新
    1. 主页
    2. 热门
    3. 周
    • 日
    • 周
    • 月

    • M

      FR800x-U加强版的的 SARADC怎么使用
      FR800x • • Mars

      2
      0
      赞同
      2
      帖子
      17
      浏览

      M

      使用的是内部1.2V的基准源,外部进行300K+100K分压,io口最高承受3.6V,-u版本的IOLDO参考源末端线性不准所以不建议使用外部3.3V的基准源 /* ****************************************************************************** * @file saradc_demo.c * @author FreqChip Firmware Team * @version V1.0.0 * @date 2025 * @brief SARADC demo based on driver_adc_pro. * * 与旧 ADC(driver_adc / adc_demo)的区别: * 1. 旧 ADC 引脚通道硬件固定,PD1 = AuxADC6 / ADC_CHANNEL_6 * (见 driver_gpio.h PortD MUX 的 GPIO_FUNCTION_8)。 * 2. SARADC 的 SARADC_CHANNEL_0~9 是逻辑通道,不绑死引脚。 * 采哪根脚由 ch_map_p 决定,PD1 对应 ADC_CH_MAP_PORTD_1。 * 3. loop_max_channel = N 时,硬件只轮询 CHANNEL_0 ~ CHANNEL_(N-1)。 * 单通道必须用 SARADC_CHANNEL_0,不能配 CHANNEL_1/6。 * 4. saradc_get_channel_data() 返回 10bit 原始码 (0~1023),需自行换算。 * * 电压换算(10bit): * Vpin(mV) = raw * Vref(mV) / 1024 * Vin(mV) = Vpin * 外部分压比 * 本板 PD1 有外部 4 分 1 电阻,1.2V 参考: * Vin(mV) = raw * 1200 * 4 / 1024 * 外部已分压时,内部 ATT 必须 BYPASS,否则会分压两次。 ****************************************************************************** */ #include "saradc_demo.h" #include "driver_gpio.h" #include "driver_pmu.h" #include "driver_adc_pro.h" #include "driver_system.h" #include "co_printf.h" #include "co_log.h" /* 10bit:Vin(mV) = raw * 参考电压(mV) * 分压比 / 1024 */ #define SARADC_RAW_TO_MV(raw, vref_mv, div) (((uint32_t)(raw) * (vref_mv) * (div)) / 1024) /** * @brief 把 GPIO 配成模拟输入:输入、无上下拉。 * SARADC 通过 ch_map_p 选脚,不再需要旧 ADC 的 GPIO_FUNCTION_8。 */ static void saradc_gpio_analog_init(enum_GPIOx_t port, uint32_t pin) { GPIO_InitTypeDef GPIO_Handle; GPIO_Handle.Pin = pin; GPIO_Handle.Mode = GPIO_MODE_INPUT; /* 模拟输入 */ GPIO_Handle.Pull = GPIO_NOPULL; /* 禁止上下拉,避免拉偏采样 */ gpio_init(port, &GPIO_Handle); } /** * @brief SARADC 公共初始化。 * 内部 1.2V 参考;clock_div 必须为偶数;sampling_cycle 建议 15。 */ static void saradc_common_init(saradc_InitConfig_t *Init) { Init->saradc_reference = SARADC_REF_INTERNAL_1P2V; /* 内部 1.2V 基准 */ Init->saradc_clock_div = 2; /* 采样时钟分频,最小 2 */ Init->saradc_sampling_cycle = 15; /* 采样周期,1~16 */ saradc_init(Init); } /************************************************************************************ * @fn saradc_demo * * @brief SARADC demo based on driver_adc_pro. * * @param fe_Demo: demo select. */ void saradc_demo(enum_SARADC_Demo_t fe_Demo) { saradc_InitConfig_t saradc_InitConfig; saradc_LoopConfig_t LoopConfig; saradc_ChannelConfig_t ChannelConfig; uint16_t raw; __SYSTEM_ADC_CLK_ENABLE(); /* 打开 ADC/SARADC 时钟 */ __SYSTEM_GPIO_CLK_ENABLE(); /* 打开 GPIO 时钟,才能配引脚 */ switch (fe_Demo) { /* * 单通道:采 PD1。 * 逻辑通道用 CHANNEL_0(loop_max=1 只转 CH0)。 * 引脚用 ADC_CH_MAP_PORTD_1,不是旧的 ADC_CHANNEL_6。 * 外部已有 4 分 1,内部 ATT 旁路。 */ case SARADC_DEMO_SINGLE_CHANNEL: { saradc_gpio_analog_init(GPIO_D, GPIO_PIN_1); saradc_common_init(&saradc_InitConfig); LoopConfig.loop_max_channel = 1; /* 只转 CH0 */ LoopConfig.loop_interval_mode = SARADC_INTVL_DISABLE; /* 通道间不插间隔 */ LoopConfig.loop_interval_len = 0; LoopConfig.loop_FIFO_enable = SARADC_FUNC_DISABLE; /* 不用 FIFO,读通道寄存器 */ LoopConfig.loop_FIFO_channel_sel = 0; LoopConfig.loop_FIFO_almost_threshold = 0; saradc_loop_config(&LoopConfig); ChannelConfig.ch_mode = SARADC_CH_MODE_SINGLE; /* 单端 */ ChannelConfig.ch_map_p = ADC_CH_MAP_PORTD_1; /* 正极接到 PD1 */ ChannelConfig.ch_map_n = ADC_CH_MAP_VSSA; /* 负极接模拟地 */ ChannelConfig.ch_voltage_divider = SARADC_VOLTAGE_DIVIDER_BYPASS;/* 内部不再分压 */ ChannelConfig.ch_source_follower_en = SARADC_FUNC_DISABLE; saradc_channel_config(SARADC_CHANNEL_0, &ChannelConfig); saradc_loop_convert_start(); /* 启动循环转换 */ co_delay_100us(1500); /* 等待模拟建立 */ co_printf("SDK V1.5 SARADC start\r\n"); while (1) { /* 该逻辑通道转换完成才会置位 */ if (saradc_get_channel_valid_status(SARADC_CHANNEL_0)) { raw = saradc_get_channel_data(SARADC_CHANNEL_0); /* 10bit raw */ /* 1.2V 参考 + 外部 4 分 1:Vin = raw * 1200 * 4 / 1024 */ co_printf("SDK V1.5 SARADC raw=%d, mv=%d\r\n", raw, SARADC_RAW_TO_MV(raw, 1200, 4)); } co_delay_100us(2000); } } /* * 多通道:PD0~PD3 映射到逻辑 CH0~CH3。 * loop_max_channel 必须等于实际通道数 4,否则后面的通道不会转换。 */ case SARADC_DEMO_MULTI_CHANNEL: { saradc_gpio_analog_init(GPIO_D, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); saradc_common_init(&saradc_InitConfig); LoopConfig.loop_max_channel = 4; /* 转 CH0~CH3 */ LoopConfig.loop_interval_mode = SARADC_INTVL_DISABLE; LoopConfig.loop_interval_len = 0; LoopConfig.loop_FIFO_enable = SARADC_FUNC_DISABLE; LoopConfig.loop_FIFO_channel_sel = 0; LoopConfig.loop_FIFO_almost_threshold = 0; saradc_loop_config(&LoopConfig); ChannelConfig.ch_mode = SARADC_CH_MODE_SINGLE; ChannelConfig.ch_map_n = ADC_CH_MAP_VSSA; ChannelConfig.ch_voltage_divider = SARADC_VOLTAGE_DIVIDER_0P25; /* 内部 1/4,无外部分压时可用 */ ChannelConfig.ch_source_follower_en = SARADC_FUNC_DISABLE; ChannelConfig.ch_map_p = ADC_CH_MAP_PORTD_0; saradc_channel_config(SARADC_CHANNEL_0, &ChannelConfig); ChannelConfig.ch_map_p = ADC_CH_MAP_PORTD_1; saradc_channel_config(SARADC_CHANNEL_1, &ChannelConfig); ChannelConfig.ch_map_p = ADC_CH_MAP_PORTD_2; saradc_channel_config(SARADC_CHANNEL_2, &ChannelConfig); ChannelConfig.ch_map_p = ADC_CH_MAP_PORTD_3; saradc_channel_config(SARADC_CHANNEL_3, &ChannelConfig); saradc_loop_convert_start(); while (1) { for (int i = 0; i < 4; i++) { if (saradc_get_channel_valid_status((enum_saradc_channel_t)i)) { raw = saradc_get_channel_data((enum_saradc_channel_t)i); co_printf("CH[%d] raw=%d, mv=%d\r\n", i, raw, SARADC_RAW_TO_MV(raw, 1200, 4)); } } co_delay_100us(2000); } } /* * 内部 1/4 VBAT。 * 模拟前端已做电池分压,通道 ATT 旁路;换算时再 *4 得到 VBAT。 */ case SARADC_DEMO_VBAT: { saradc_common_init(&saradc_InitConfig); saradc_vbat_measure_enable(); /* 打开内部 VBAT 分压电路 */ LoopConfig.loop_max_channel = 1; LoopConfig.loop_interval_mode = SARADC_INTVL_DISABLE; LoopConfig.loop_interval_len = 0; LoopConfig.loop_FIFO_enable = SARADC_FUNC_DISABLE; LoopConfig.loop_FIFO_channel_sel = 0; LoopConfig.loop_FIFO_almost_threshold = 0; saradc_loop_config(&LoopConfig); ChannelConfig.ch_mode = SARADC_CH_MODE_SINGLE; ChannelConfig.ch_map_p = ADC_CH_MAP_VBAT; /* 内部 VBAT */ ChannelConfig.ch_map_n = ADC_CH_MAP_VSSA; ChannelConfig.ch_voltage_divider = SARADC_VOLTAGE_DIVIDER_BYPASS; ChannelConfig.ch_source_follower_en = SARADC_FUNC_DISABLE; saradc_channel_config(SARADC_CHANNEL_0, &ChannelConfig); saradc_loop_convert_start(); while (1) { if (saradc_get_channel_valid_status(SARADC_CHANNEL_0)) { raw = saradc_get_channel_data(SARADC_CHANNEL_0); co_printf("1/4 VBAT raw=%d, vbat=%d mV\r\n", raw, SARADC_RAW_TO_MV(raw, 1200, 4)); } co_delay_100us(2000); } } /* * 核温 VBE,无外部分压,换算比取 1。 */ case SARADC_DEMO_VBE: { saradc_common_init(&saradc_InitConfig); saradc_vbe_measure_enable(); /* 打开内部温度传感 */ LoopConfig.loop_max_channel = 1; LoopConfig.loop_interval_mode = SARADC_INTVL_DISABLE; LoopConfig.loop_interval_len = 0; LoopConfig.loop_FIFO_enable = SARADC_FUNC_DISABLE; LoopConfig.loop_FIFO_channel_sel = 0; LoopConfig.loop_FIFO_almost_threshold = 0; saradc_loop_config(&LoopConfig); ChannelConfig.ch_mode = SARADC_CH_MODE_SINGLE; ChannelConfig.ch_map_p = ADC_CH_MAP_VBEP; /* VBE 正极 */ ChannelConfig.ch_map_n = ADC_CH_MAP_VSSA; ChannelConfig.ch_voltage_divider = SARADC_VOLTAGE_DIVIDER_BYPASS; ChannelConfig.ch_source_follower_en = SARADC_FUNC_DISABLE; saradc_channel_config(SARADC_CHANNEL_0, &ChannelConfig); saradc_loop_convert_start(); while (1) { if (saradc_get_channel_valid_status(SARADC_CHANNEL_0)) { raw = saradc_get_channel_data(SARADC_CHANNEL_0); co_printf("VBE raw=%d, mv=%d\r\n", raw, SARADC_RAW_TO_MV(raw, 1200, 1)); } co_delay_100us(2000); } } default: break; } }
    • 黄

      fr8008怎么实现 SysTick ?
      FR800x • • 黄书剑

      2
      0
      赞同
      2
      帖子
      75
      浏览

      M

      如下 /* * INCLUDE FILES **************************************************************************************** */ #include <stdio.h> #include <string.h> #include "gap_api.h" #include "gatt_api.h" #include "ble_stack.h" #include "app_config.h" #include "jump_table.h" #include "co_log.h" #include "plf.h" #include "driver_system.h" #include "driver_pmu.h" #include "driver_uart.h" #include "ble_simple_peripheral.h" #include "simple_gatt_service.h" #undef LOG_LOCAL_LEVEL #define LOG_LOCAL_LEVEL (LOG_LEVEL_INFO) const char *app_tag = "project"; #define SYSTEM_STACK_SIZE 0x800 void patch_init(void); void disable_ch_sel_2(void); void conn_req_rssi_filter(int8_t rssi_value); void systick_init(void); void systick_delay_ms(uint32_t ms); void systick_delay_us(uint32_t us); uint32_t systick_get_ms(void); /* * LOCAL VARIABLES */ static volatile uint32_t g_systick_ms = 0; __attribute__((section("stack_section"))) static uint32_t system_stack[SYSTEM_STACK_SIZE/sizeof(uint32_t)]; const struct jump_table_version_t _jump_table_version __attribute__((section("jump_table_3"))) = { .stack_top_address = &system_stack[SYSTEM_STACK_SIZE/sizeof(uint32_t)], .firmware_version = 0x00000000, }; const struct jump_table_image_t _jump_table_image __attribute__((section("jump_table_1"))) = { .image_type = IMAGE_TYPE_APP, .image_size = 0x20000, }; /********************************************************************* * @fn SysTick_Handler * * @brief 1ms tick. Overrides the WEAK handler in boot_vectors. */ void SysTick_Handler(void) { g_systick_ms++; } /********************************************************************* * @fn systick_init * * @brief Start SysTick at 1ms. Must be called after system_set_clock(). */ void systick_init(void) { uint32_t ticks = system_get_clock() / 1000; if ((ticks == 0) || ((ticks - 1) > SysTick_LOAD_RELOAD_Msk)) { return; } SysTick_Config(ticks); } /********************************************************************* * @fn systick_get_ms * * @brief Milliseconds since systick_init. Does not advance in sleep. */ uint32_t systick_get_ms(void) { return g_systick_ms; } /********************************************************************* * @fn systick_delay_ms * * @brief Blocking delay. Do not call with interrupts disabled. */ void systick_delay_ms(uint32_t ms) { uint32_t start = g_systick_ms; while ((uint32_t)(g_systick_ms - start) < ms) { } } /********************************************************************* * @fn systick_delay_us * * @brief Blocking us delay. Temporarily uses SysTick as a one-shot, * then restores the 1ms tick. */ void systick_delay_us(uint32_t us) { uint32_t clk = system_get_clock(); uint32_t ticks_per_us; uint32_t max_us; if ((us == 0) || (clk < 1000000)) { return; } ticks_per_us = clk / 1000000; max_us = SysTick_LOAD_RELOAD_Msk / ticks_per_us; while (us) { uint32_t chunk = (us > max_us) ? max_us : us; SysTick->CTRL = 0; SysTick->LOAD = ticks_per_us * chunk - 1; SysTick->VAL = 0; SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk; while ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == 0) { } us -= chunk; } systick_init(); } /********************************************************************* * @fn user_entry_before_sleep_imp * * @brief Before system goes to sleep mode, user_entry_before_sleep_imp() * will be called, MCU peripherals can be configured properly before * system goes to sleep, for example, some MCU peripherals need to be * used during the system is in sleep mode. * * @param None. * * * @return None. */ __attribute__((section("ram_code"))) void user_entry_before_sleep_imp(void) { /* SysTick uses CPU clock and would wake the core every 1ms */ SysTick->CTRL = 0; pmu_calibration_stop(); uart_putc_noint_no_wait(UART0, 's'); co_delay_100us(1); pmu_set_pin_to_PMU(GPIO_PORT_A, (1<<GPIO_BIT_1)); pmu_set_pin_to_PMU(GPIO_PORT_A, (1<<GPIO_BIT_0)|(1<<GPIO_BIT_4)); pmu_set_pin_dir(GPIO_PORT_A, (1<<GPIO_BIT_0)|(1<<GPIO_BIT_4),GPIO_DIR_IN); pmu_set_pin_pull(GPIO_PORT_A, (1<<GPIO_BIT_0)|(1<<GPIO_BIT_4),GPIO_PULL_NONE); pmu_oscap_set(0); } /********************************************************************* * @fn user_entry_after_sleep_imp * * @brief After system wakes up from sleep mode, user_entry_after_sleep_imp() * will be called, MCU peripherals need to be initialized again, * this can be done in user_entry_after_sleep_imp(). MCU peripherals * status will not be kept during the sleep. * * @param None. * * * @return None. */ __attribute__((section("ram_code"))) void user_entry_after_sleep_imp(void) { pmu_set_pin_to_CPU(GPIO_PORT_A, (1<<GPIO_BIT_0)); system_set_port_mux(GPIO_PORT_A, GPIO_BIT_0, PORTA0_FUNC_UART0_RXD); system_set_port_mux(GPIO_PORT_A, GPIO_BIT_1, PORTA1_FUNC_UART0_TXD); uart_init(UART0, 1152); fr_uart_enableIrq(UART0, Uart_irq_erbfi); /* RC calibration start. Ensure the accuracy of sleep wake time */ pmu_calibration_start(PMU_CALI_SEL_RCLFOSC, LP_RC_CALIB_CNT); uart_putc_noint_no_wait(UART0, 'w'); co_delay_100us(1); NVIC_EnableIRQ(PMU_IRQn); systick_init(); } __attribute__((section("ram_code"))) void main_loop(void) { while(1) { if(ble_stack_schedule_allow()) { /*user code should be add here*/ /* schedule internal stack event */ ble_stack_schedule(); } GLOBAL_INT_DISABLE(); switch(ble_stack_sleep_check()) { case 2: { ble_stack_enter_sleep(); } break; default: break; } GLOBAL_INT_RESTORE(); ble_stack_schedule_backward(); } } /********************************************************************* * @fn proj_init * * @brief Main entrancy of user application. This function is called after BLE stack * is initialized, and all the application code will be executed from here. * In that case, application layer initializtion can be startd here. * * @param None. * * * @return None. */ void proj_init(void) { LOG_INFO(app_tag, "BLE Peripheral\r\n"); co_printf("%s\r\n",__func__); systick_delay_ms(500); co_printf("%s\r\n",__TIME__); // Application layer initialization, can included bond manager init, // advertising parameters init, scanning parameter init, GATT service adding, etc. simple_peripheral_init(); }
    • Y

      FR8008GP-U RTC例程有没有?
      FR800x • • yjx

      2
      0
      赞同
      2
      帖子
      35
      浏览

      M

      RTC.c驱动部分 /* ****************************************************************************** * @file driver_rtc.c * @author FreqChip Firmware Team * @version V1.0.0 * @date 2021 * @brief rtc module driver. * This file provides firmware functions to manage the * Real Time Clock (RTC) peripheral ****************************************************************************** * @attention * * Copyright (c) 2021 FreqChip. * All rights reserved. ****************************************************************************** */ #include "driver_rtc.h" str_Time_t AlarmTime_A; str_Time_t AlarmTime_B; /********************************************************************* * @fn rtc_GetCount * * @brief Get rtc current counter value * * @param None. * @return None. */ void rtc_init(void) { uint8_t lu8_TempValue; /* RTC clock enable */ lu8_TempValue = ool_read(PMU_REG_CLK_EN); ool_write(PMU_REG_CLK_EN, lu8_TempValue | PMU_RTC_CLK_EN); /* RTC Reset disable */ lu8_TempValue = ool_read(PMU_REG_RST_CTRL); ool_write(PMU_REG_RST_CTRL, lu8_TempValue & ~PMU_RTC_SFT_RST); } /********************************************************************* * @fn rtc_AlarmConfig * * @brief rtc alarm config * * @param fe_Alarm: alarm select. lu8_hour: hour lu8_Minute: minute lu8_Second: second * @return None. */ void rtc_AlarmConfig(e_alarm_t fe_Alarm, uint32_t fu32_hour, uint32_t fu32_Minute, uint32_t fu32_Second) { uint32_t lu32_Second; lu32_Second = fu32_hour * 3600; lu32_Second += fu32_Minute * 60; lu32_Second += fu32_Second; switch (fe_Alarm) { case AlARM_A: { /* Timing backup */ if (AlarmTime_A.FirstBackup == 0) AlarmTime_A.FirstBackup = lu32_Second; AlarmTime_A.CycleBackup = lu32_Second; /* Convert to count value */ lu32_Second *= pmu_get_rc_clk(false); lu32_Second += rtc_GetCount(); pmu_enable_isr(PMU_RTC_ALMA_INT_EN); ool_pd_write32(PMU_REG_PD_RTC_ALARMA_CNT_0, lu32_Second); rtc_AlarmEnable(AlARM_A); }break; case AlARM_B: { /* Timing backup */ if (AlarmTime_B.FirstBackup == 0) AlarmTime_B.FirstBackup = lu32_Second; AlarmTime_B.CycleBackup = lu32_Second; /* Convert to count value */ lu32_Second *= pmu_get_rc_clk(false); lu32_Second += rtc_GetCount(); pmu_enable_isr(PMU_RTC_ALMB_INT_EN); ool_pd_write32(PMU_REG_PD_RTC_ALARMB_CNT_0, lu32_Second); rtc_AlarmEnable(AlARM_B); }break; default: break; } } /********************************************************************* * @fn rtc_GetCount * * @brief Get rtc current counter value * * @param None. * @return lu32_CountValue: rtc current counter value. */ uint32_t rtc_GetCount(void) { uint32_t lu32_CountValue; lu32_CountValue = ool_pd_read32(PMU_REG_PD_RTC_UPD_CNT_0); return lu32_CountValue; } /********************************************************************* * @fn rtc_CountUpdate * * @brief Update RTC counter * * @param fu32_Count: update value. * @return None. */ void rtc_CountUpdate(uint32_t fu32_Count) { uint8_t lu8_TempValue; ool_pd_write32(PMU_REG_PD_RTC_ALARMA_CNT_0, fu32_Count); lu8_TempValue = ool_pd_read(PMU_REG_PD_RTC_CTRL); ool_pd_write(PMU_REG_PD_RTC_CTRL, lu8_TempValue | PMU_RTC_UPD_EN); ool_pd_write(PMU_REG_PD_RTC_CTRL, lu8_TempValue & ~PMU_RTC_UPD_EN); AlarmTime_A.FirstBackup = 0; AlarmTime_B.FirstBackup = 0; } /********************************************************************* * @fn rtc_AlarmUpdate * * @brief rtc alarm Update. * Update according to the periodic period in the rtc_AlarmConfig function. * * @param fe_Alarm: alarm select. */ void rtc_AlarmUpdate(e_alarm_t fe_Alarm) { uint32_t lu32_AddValue; uint32_t lu32_AlarmValue; /* Convert to count value */ if (fe_Alarm == AlARM_A) lu32_AddValue = AlarmTime_A.FirstBackup * pmu_get_rc_clk(false); else lu32_AddValue = AlarmTime_B.FirstBackup * pmu_get_rc_clk(false); lu32_AlarmValue = rtc_AlarmRead(fe_Alarm); lu32_AlarmValue += lu32_AddValue; rtc_AlarmSet(fe_Alarm, lu32_AlarmValue); } /********************************************************************* * @fn rtc_ClockEnable * * @brief RTC clock enable */ void rtc_ClockEnable(void) { uint8_t lu8_TempValue; /* RTC clock enable */ lu8_TempValue = ool_read(PMU_REG_CLK_EN); ool_write(PMU_REG_CLK_EN, lu8_TempValue | PMU_RTC_CLK_EN); } /********************************************************************* * @fn rtc_ClockDisable * * @brief RTC clock disable */ void rtc_ClockDisable(void) { uint8_t lu8_TempValue; /* RTC clock enable */ lu8_TempValue = ool_read(PMU_REG_CLK_EN); ool_write(PMU_REG_CLK_EN, lu8_TempValue & ~PMU_RTC_CLK_EN); } /********************************************************************* * @fn rtc_ResetEnable * * @brief RTC reset enable */ void rtc_ResetEnable(void) { uint8_t lu8_TempValue; /* RTC Reset disable */ lu8_TempValue = ool_read(PMU_REG_RST_CTRL); ool_write(PMU_REG_RST_CTRL, lu8_TempValue | PMU_RTC_SFT_RST); } /********************************************************************* * @fn rtc_ResetDisable * * @brief RTC reset disable */ void rtc_ResetDisable(void) { uint8_t lu8_TempValue; /* RTC Reset disable */ lu8_TempValue = ool_read(PMU_REG_RST_CTRL); ool_write(PMU_REG_RST_CTRL, lu8_TempValue & ~PMU_RTC_SFT_RST); } /********************************************************************* * @fn rtc_AlarmEnable * * @brief Alarm Enable */ void rtc_AlarmEnable(e_alarm_t fe_Alarm) { uint8_t lu8_TempValue; /* RTC Alarm Enable */ lu8_TempValue = ool_pd_read(PMU_REG_PD_RTC_CTRL); ool_pd_write(PMU_REG_PD_RTC_CTRL, lu8_TempValue | fe_Alarm); } /********************************************************************* * @fn rtc_ALarmDisable * * @brief Alarm Disable */ void rtc_AlarmDisable(e_alarm_t fe_Alarm) { uint8_t lu8_TempValue; /* RTC Alarm Disable */ lu8_TempValue = ool_pd_read(PMU_REG_PD_RTC_CTRL); ool_pd_write(PMU_REG_PD_RTC_CTRL, lu8_TempValue & ~fe_Alarm); } /********************************************************************* * @fn rtc_AlarmRead * * @brief read rtc alarm config value * * @param None. * @return lu32_ConfigValue: alarm config value. */ uint32_t rtc_AlarmRead(e_alarm_t fe_Alarm) { uint32_t lu32_ConfigValue; switch (fe_Alarm) { case AlARM_A: { lu32_ConfigValue = ool_pd_read32(PMU_REG_PD_RTC_ALARMA_CNT_0); }break; case AlARM_B: { lu32_ConfigValue = ool_pd_read32(PMU_REG_PD_RTC_ALARMB_CNT_0); }break; default: break; } return lu32_ConfigValue; } /********************************************************************* * @fn rtc_AlarmSet * * @brief Set rtc alarm config value * * @param None. * @return lu32_ConfigValue: alarm config value. */ void rtc_AlarmSet(e_alarm_t fe_Alarm, uint32_t fu32_ConfigValue) { switch (fe_Alarm) { case AlARM_A: { ool_pd_write32(PMU_REG_PD_RTC_ALARMA_CNT_0, fu32_ConfigValue); }break; case AlARM_B: { ool_pd_write32(PMU_REG_PD_RTC_ALARMB_CNT_0, fu32_ConfigValue); }break; } } /********************************************************************* * @fn rtc_AlarmHandler * * @brief Alarm interrupt handler */ __attribute__((section("ram_code"))) void rtc_AlarmHandler(void) { if (pmu_get_isr_state() & PMU_RTC_ALMA_INT_STATUS) { pmu_clear_isr_state(PMU_RTC_ALMA_INT_CLR); /* Update according to the periodic period in the rtc_AlarmConfig function. */ rtc_AlarmUpdate(AlARM_A); } else if (pmu_get_isr_state() & PMU_RTC_ALMB_INT_STATUS) { pmu_clear_isr_state(PMU_RTC_ALMB_INT_CLR); /* Update according to the periodic period in the rtc_AlarmConfig function. */ rtc_AlarmUpdate(AlARM_B); } }
    • Y

      FR2012BFlash占用问题
      FR201x • • yuyuyu1122

      2
      0
      赞同
      2
      帖子
      108
      浏览

      M

      io口时钟开了吗
    • C

      fr 8012 haq Как мне исправить ошибку? Я очень прошу,помогите мне!!!!!
      FR801xH • • CerXio28

      1
      0
      赞同
      1
      帖子
      51
      浏览

      尚无回复

    • 黄

      fr8018的System_Tick怎么实现呢?
      FR801xH • • 黄书剑

      1
      0
      赞同
      1
      帖子
      46
      浏览

      尚无回复