The following sequence is a basic example to animate the user style1 using ABM mode in Segment LCD1 Xplained Pro LCD glass.
Buffers used :
/* DMA buffer length */ #define BUFFER_LEN 30 /* DMA resource and descriptor */ struct dma_resource example_resource; COMPILER_ALIGNED(16) DmacDescriptor example_descriptor; static char user_scrolling_str[BUFFER_LEN] = {"HELLO WORLD "}; static volatile uint32_t dma_source_buf[BUFFER_LEN]; static volatile bool transfer_is_done = false; static volatile uint32_t dma_break = 0, dma_block_count = 0; /** prints Atmel in user style1 */ user_style_buf[1][30] = { 0x00000040,0x00070000,0x000D0060,0x00140002, // S 0x000600e0,0x000D0060,0x00130008,0x00020004, // T 0x000C0070,0x00130008,0x00020004,0x0008000a, // Y 0x00120000,0x00010005,0x0008002a,0x000E0003, // L 0x00010085,0x00070070,0x000E0023,0x00140022, // E 0x0000FF00,0x0000FF00,0x0000FF00,0x0000FF00 // 1 }
slcd_disable();
xpro_lcd_clear_all();
clear_buffer();
user_style_buf[1][30]
to dma_source_buf[]
and
counts the block count.
/* ABMCFG.SIZE = 3 ABMCFG.FCS = 1 */
config_size = 3;
config_fc_value = 0x0F;
config_fc = SLCD_FRAME_COUNTER_1;
/* write the SLCD ABM configurations in the respective registers */
slcd_set_automated_bit(config_size, config_fc);
/* Set the frame counter configurations and enable it */
slcd_set_frame_counter(config_fc,0,0x0F);
slcd_enable_frame_counter(config_fc);
slcd_enable();
is_bitmapping
, and load
the configuration structure with the following configuration parameters for the ABM
mode:/* Structure for the DMA resource configurations */ struct dma_resource_config config; /* Get the default configuration */ dma_get_config_defaults(&config); if( true == is_bitmapping ){ /* Set the peripheral trigger source */ config.peripheral_trigger = SLCD_DMAC_ID_ABMDRDY; /* Set the trigger action */ config.trigger_action = DMA_TRIGGER_ACTON_BEAT; }
configure_dma_resource(&example_resource);
is_bitmapping
, get the default configuration of DMA resource
configuration, and load the configuration structure with the following configuration
parameters for the ABM
mode:/* Structure for the DMA descriptor configurations */ struct dma_descriptor_config descriptor_config; if( true == is_scrolling ){ /* Get the default configuration */ dma_descriptor_get_config_defaults(&descriptor_config); descriptor_config.beat_size = DMA_BEAT_SIZE_WORD; descriptor_config.src_increment_enable = true; descriptor_config.dst_increment_enable = false; descriptor_config.step_size = (DMA_ADDRESS_INCREMENT_STEP_SIZE_1); descriptor_config.step_selection = DMA_STEPSEL_SRC; descriptor_config.block_action = DMA_BLOCK_ACTION_INT; /* Block count manipulated run time from the scrolling string */ descriptor_config.block_transfer_count = dma_block_count; descriptor_config.source_address = (uint32_t)dma_source_buf + (dma_block_count * sizeof(dma_source_buf[0])); descriptor_config.destination_address = (uint32_t)(&SLCD->ISDATA.reg); descriptor_config.next_descriptor_address =( uint32_t )descriptor; /* Create a DMA descriptor */ dma_descriptor_create(descriptor, &descriptor_config); }
configure_dma_descriptor(&example_resource);
dma_register_callback(&example_resource, dma_callback,DMA_CALLBACK_TRANSFER_DONE); dma_enable_callback(&example_resource, DMA_CALLBACK_TRANSFER_DONE);
/** Start DMA transfer once DMA gets the peripheral
* trigger from the ABM then the data transfer starts */
dma_start_transfer_job(&example_resource);
/* Enable ABM mode */
slcd_enable_automated_bit();