Jump to main content
14.10.3.1.3 Workflow
Initialize system.
system_init();
Configure and enable module.
configure_rtc();
Create a RTC configuration structure to hold the desired RTC driver settings and fill it with the configuration values.
struct
rtc_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);
Note: This should always be performed before using the configuration struct to ensure that all values are initialized to known default settings.
Initialize the RTC module.
struct
rtc_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);
Create a RTC tamper configuration structure and fill it with the configuration values.
struct
rtc_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);
Enable the RTC module, so that it may begin counting.
rtc_count_enable(&rtc_instance);
Configure callback functionality.
configure_rtc_callbacks();
Register overflow callback.
rtc_count_register_callback(
&rtc_instance, rtc_tamper_callback, RTC_COUNT_CALLBACK_TAMPER);
Enable overflow callback.
rtc_count_enable_callback(&rtc_instance, RTC_COUNT_CALLBACK_TAMPER);
Configure the DMA.
Create a DMA resource configuration structure, which can be filled out to adjust the configuration of a single DMA transfer.
struct
dma_resource_config config;
Initialize the DMA resource configuration struct with the module's. default values.
dma_get_config_defaults(&config);
Note: This should always be performed before using the configuration struct to ensure that all values are initialized to known default settings.
Set extra configurations for the DMA resource. ADC_DMAC_ID_RESRDY trigger causes a beat transfer in this example.
config.peripheral_trigger = RTC_DMAC_ID_TIMESTAMP;
config.trigger_action = DMA_TRIGGER_ACTON_BEAT;
Allocate a DMA resource with the configurations.
dma_allocate(resource, &config);
Create a DMA transfer descriptor configuration structure, which can be filled out to adjust the configuration of a single DMA transfer.
struct
dma_descriptor_config descriptor_config;
Initialize the DMA transfer descriptor configuration struct with the module's default values.
dma_descriptor_get_config_defaults(&descriptor_config);
Note: This should always be performed before using the configuration struct to ensure that all values are initialized to known default settings.
Set the specific parameters for a DMA transfer with transfer size, source address, and destination address.
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;
Create the DMA transfer descriptor.
dma_descriptor_create(descriptor, &descriptor_config);
Add DMA descriptor to DMA resource.
dma_add_descriptor(&example_resource, &example_descriptor);
The online versions of the documents are provided as a courtesy. Verify all content and data in the device’s PDF documentation found on the device product page.