CCL Example Application.
Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include "conf_ccl_example.h"
Macros | |
#define | BUF_LENGTH 10 |
Create arrays for storing modulator signal period and compare value. More... | |
Functions | |
void | configure_ccl_lut0 (void) |
static void | configure_dma_channel_0 (DmacDescriptor *descriptor) |
static void | configure_dma_channel_1 (DmacDescriptor *descriptor) |
void | configure_dma_evsys (void) |
static void | configure_dma_resource (struct dma_resource *resource) |
void | configure_dmac (void) |
void | configure_tc_alt (void) |
void | configure_tc_def (void) |
void | configure_tc_evsys (void) |
int | main (void) |
Variables | |
DmacDescriptor | descriptor0 |
Create descriptors for DMA. More... | |
DmacDescriptor | descriptor1 |
struct dma_resource | dma_ch_0 |
struct dma_resource | dma_ch_1 |
uint8_t | period_buffer [BUF_LENGTH] = {0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7} |
struct tc_module | tc_alt |
struct tc_module | tc_def |
Create structs for TC and DMA. More... | |
uint8_t | value_buffer [BUF_LENGTH] = {0x2,0x2,0x2,0x2,0x2,0x5,0x5,0x5,0x5,0x5} |
#define BUF_LENGTH 10 |
Create arrays for storing modulator signal period and compare value.
Referenced by configure_dma_channel_0(), and configure_dma_channel_1().
void configure_ccl_lut0 | ( | void | ) |
Creates a new configuration structure for CCL.
Apply the default settings.
Initialize CCL with the user settings.
Creates a new configuration structure for LUT0.
Apply the default settings.
Configure LUT0.
Set up LUT0 output pin.
Initialize and enable LUT0 with the user settings.
Enable CCL module.
|
static |
Creates a new configuration structure for the DMA descriptor.
Apply the default settings.
Configure the DMA descriptor.
References dma_descriptor_config::beat_size, dma_descriptor_config::block_action, dma_descriptor_config::block_transfer_count, BUF_LENGTH, descriptor_section, dma_descriptor_config::destination_address, DMA_ADDRESS_INCREMENT_STEP_SIZE_1, DMA_BEAT_SIZE_BYTE, DMA_BLOCK_ACTION_NOACT, dma_descriptor_create(), dma_descriptor_get_config_defaults(), DMA_STEPSEL_SRC, dma_descriptor_config::dst_increment_enable, dma_descriptor_config::next_descriptor_address, period_buffer, dma_descriptor_config::source_address, dma_descriptor_config::src_increment_enable, dma_descriptor_config::step_selection, dma_descriptor_config::step_size, and tc_alt.
Referenced by configure_dmac().
|
static |
Creates a new configuration structure for the DMA descriptor.
Apply the default settings.
Configure the DMA descriptor.
References dma_descriptor_config::beat_size, dma_descriptor_config::block_action, dma_descriptor_config::block_transfer_count, BUF_LENGTH, descriptor_section, dma_descriptor_config::destination_address, DMA_ADDRESS_INCREMENT_STEP_SIZE_1, DMA_BEAT_SIZE_BYTE, DMA_BLOCK_ACTION_NOACT, dma_descriptor_create(), dma_descriptor_get_config_defaults(), DMA_STEPSEL_SRC, dma_descriptor_config::dst_increment_enable, dma_descriptor_config::next_descriptor_address, dma_descriptor_config::source_address, dma_descriptor_config::src_increment_enable, dma_descriptor_config::step_selection, dma_descriptor_config::step_size, tc_alt, and value_buffer.
Referenced by configure_dmac().
void configure_dma_evsys | ( | void | ) |
Create new event structs.
Use generator CCL_ALTTC overflow.
Attach DMAC channel 0/1 as users.
References events_config::clock_source, events_config::edge_detect, events_allocate(), events_attach_user(), EVENTS_EDGE_DETECT_NONE, events_get_config_defaults(), EVENTS_PATH_RESYNCHRONIZED, GCLK_GENERATOR_1, events_config::generator, and events_config::path.
Referenced by main().
|
static |
Creates a new configuration structure for the DMA resource.
Apply the default settings.
Configure DMAC channel 0/1 to transfer data on TC overflow.
Allocate DMAC channel 0/1.
void configure_dmac | ( | void | ) |
Configure the DMA resources and channels.
Add both descriptors.
Enable both channels for transfer.
References configure_dma_channel_0(), configure_dma_channel_1(), configure_dma_resource(), descriptor0, descriptor1, dma_add_descriptor(), dma_ch_0, dma_ch_1, and dma_start_transfer_job().
Referenced by main().
void configure_tc_alt | ( | void | ) |
Creates a new configuration structure for CCL_ALTTC.
Apply the default settings.
Configure CCL_ALTTC.
Initialize and enable CCL_ALTTC with the user settings.
Creates a new configuration structure for CCL_ALTTC event.
Configure CCL_ALTTC event.
Enable CCL_ALTTC event.
References tc_config::clock_prescaler, tc_config::clock_source, tc_8bit_config::compare_capture_channel, tc_config::count_direction, tc_config::counter_8_bit, tc_config::counter_size, tc_config::double_buffering_enabled, tc_pwm_channel::enabled, tc_events::event_action, GCLK_GENERATOR_1, tc_events::generate_event_on_compare_channel, tc_events::generate_event_on_overflow, tc_events::invert_event_input, tc_events::on_event_perform_action, tc_8bit_config::period, tc_pwm_channel::pin_mux, tc_pwm_channel::pin_out, tc_config::pwm_channel, tc_config::reload_action, tc_config::run_in_standby, tc_alt, TC_CLOCK_PRESCALER_DIV1, TC_COMPARE_CAPTURE_CHANNEL_0, TC_COUNT_DIRECTION_UP, TC_COUNTER_SIZE_8BIT, tc_enable_events(), TC_EVENT_ACTION_INCREMENT_COUNTER, tc_get_config_defaults(), tc_init(), TC_RELOAD_ACTION_RESYNC, TC_WAVE_GENERATION_NORMAL_PWM, TC_WAVEFORM_INVERT_OUTPUT_NONE, tc_8bit_config::value, tc_config::wave_generation, and tc_config::waveform_invert_output.
Referenced by main().
void configure_tc_def | ( | void | ) |
Creates a new configuration structure for CCL_TC.
Apply the default settings.
Configure CCL_TC.
Initialize and enable CCL_TC with the user settings.
Creates a new configuration structure for CCL_TC event.
Configure CCL_TC event.
Enable CCL_TC event.
References tc_config::clock_prescaler, tc_config::clock_source, tc_8bit_config::compare_capture_channel, tc_config::count_direction, tc_config::counter_8_bit, tc_config::counter_size, tc_config::double_buffering_enabled, tc_pwm_channel::enabled, tc_events::event_action, GCLK_GENERATOR_1, tc_events::generate_event_on_compare_channel, tc_events::generate_event_on_overflow, tc_events::invert_event_input, tc_events::on_event_perform_action, tc_8bit_config::period, tc_pwm_channel::pin_mux, tc_pwm_channel::pin_out, tc_config::pwm_channel, tc_config::reload_action, tc_config::run_in_standby, TC_CLOCK_PRESCALER_DIV1, TC_COMPARE_CAPTURE_CHANNEL_0, TC_COUNT_DIRECTION_UP, TC_COUNTER_SIZE_8BIT, tc_def, tc_enable_events(), TC_EVENT_ACTION_OFF, tc_get_config_defaults(), tc_init(), TC_RELOAD_ACTION_GCLK, TC_WAVE_GENERATION_NORMAL_PWM, TC_WAVEFORM_INVERT_OUTPUT_NONE, tc_8bit_config::value, tc_config::wave_generation, and tc_config::waveform_invert_output.
Referenced by main().
void configure_tc_evsys | ( | void | ) |
Create new event structs.
Use generator CCL_TC overflow.
Attach CCL_ALTTC as user.
References events_config::clock_source, events_config::edge_detect, events_allocate(), events_attach_user(), EVENTS_EDGE_DETECT_NONE, events_get_config_defaults(), EVENTS_PATH_ASYNCHRONOUS, GCLK_GENERATOR_1, events_config::generator, and events_config::path.
Referenced by main().
int main | ( | void | ) |
Configure TC, DMAC and CCL.
Configure event system.
Enable CCL_TC and CCL_ALTTC.
Enter Standby sleep mode.
Keep alive while generating IR encoded signal.
References configure_ccl_lut0(), configure_dma_evsys(), configure_dmac(), configure_tc_alt(), configure_tc_def(), configure_tc_evsys(), system_init(), system_set_sleepmode(), system_sleep(), SYSTEM_SLEEPMODE_STANDBY, tc_alt, tc_def, and tc_enable().
DmacDescriptor descriptor0 |
Create descriptors for DMA.
Referenced by configure_dmac().
DmacDescriptor descriptor1 |
Referenced by configure_dmac().
struct dma_resource dma_ch_0 |
Referenced by configure_dmac().
struct dma_resource dma_ch_1 |
Referenced by configure_dmac().
uint8_t period_buffer[BUF_LENGTH] = {0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7} |
Referenced by configure_dma_channel_0().
struct tc_module tc_alt |
Referenced by configure_dma_channel_0(), configure_dma_channel_1(), configure_tc_alt(), and main().
struct tc_module tc_def |
Create structs for TC and DMA.
Referenced by configure_tc_def(), and main().
uint8_t value_buffer[BUF_LENGTH] = {0x2,0x2,0x2,0x2,0x2,0x5,0x5,0x5,0x5,0x5} |
Referenced by configure_dma_channel_1().