system_init();
configure_rtc();
structrtc_count_config config_rtc_count;rtc_count_get_config_defaults(&config_rtc_count);config_rtc_count.prescaler = RTC_COUNT_PRESCALER_DIV_1;rtc_count_init(&rtc_instance, RTC, &config_rtc_count);
structrtc_count_config config_rtc_count;rtc_count_get_config_defaults(&config_rtc_count);config_rtc_count.prescaler = RTC_COUNT_PRESCALER_DIV_1;rtc_count_init(&rtc_instance, RTC, &config_rtc_count);
structrtc_tamper_config config_rtc_tamper;rtc_tamper_get_config_defaults(&config_rtc_tamper);config_rtc_tamper.dma_tamper_enable =true;config_rtc_tamper.in_cfg[0].level = RTC_TAMPER_LEVEL_RISING;config_rtc_tamper.in_cfg[0].action = RTC_TAMPER_INPUT_ACTION_CAPTURE;rtc_tamper_set_config(&rtc_instance, &config_rtc_tamper);
rtc_count_enable(&rtc_instance);
configure_rtc_callbacks();
rtc_count_register_callback(&rtc_instance, rtc_tamper_callback, RTC_COUNT_CALLBACK_TAMPER);
rtc_count_enable_callback(&rtc_instance, RTC_COUNT_CALLBACK_TAMPER);
structdma_resource_config config;
dma_get_config_defaults(&config);
config.peripheral_trigger = RTC_DMAC_ID_TIMESTAMP;config.trigger_action = DMA_TRIGGER_ACTON_BEAT;
dma_allocate(resource, &config);
structdma_descriptor_config descriptor_config;
dma_descriptor_get_config_defaults(&descriptor_config);
descriptor_config.beat_size = DMA_BEAT_SIZE_WORD;descriptor_config.dst_increment_enable =false;descriptor_config.src_increment_enable =false;descriptor_config.block_transfer_count = 1;descriptor_config.source_address = (uint32_t)(&rtc_instance.hw->MODE0.TIMESTAMP.reg);descriptor_config.destination_address = (uint32_t)(buffer_rtc_tamper);descriptor_config.next_descriptor_address = (uint32_t)descriptor;
dma_descriptor_create(descriptor, &descriptor_config);
dma_add_descriptor(&example_resource, &example_descriptor);