other/dma2mem: Fix typos and coding-style.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
README
|
README
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
This program demonstrates a little DMA MEM2MEM transfer. A string is send out
|
This program demonstrates a little DMA MEM2MEM transfer. A string is sent out
|
||||||
to USART1 and afterwards copied by DMA to another memory location. To check
|
to USART1 and afterwards copied by DMA to another memory location. To check
|
||||||
if the transfer was successful we send the destination string also out to
|
if the transfer was successful we send the destination string also out to
|
||||||
USART1.
|
USART1.
|
||||||
|
|||||||
@@ -67,8 +67,10 @@ void my_usart_print_string(u32 usart, char * s)
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
/* Exactly 20 bytes including '0' at the end.
|
/*
|
||||||
We want to transfer 32bit * 5 so it should fit */
|
* Exactly 20 bytes including '\0' at the end.
|
||||||
|
* We want to transfer 32bit * 5 so it should fit.
|
||||||
|
*/
|
||||||
char s1[20] = "Hello STM MEM2MEM\r\n";
|
char s1[20] = "Hello STM MEM2MEM\r\n";
|
||||||
char s2[20];
|
char s2[20];
|
||||||
|
|
||||||
@@ -94,7 +96,10 @@ int main(void)
|
|||||||
dma_set_memory_size(DMA1, DMA_CHANNEL1, DMA_CCR1_MSIZE_32BIT);
|
dma_set_memory_size(DMA1, DMA_CHANNEL1, DMA_CCR1_MSIZE_32BIT);
|
||||||
dma_set_peripheral_size(DMA1, DMA_CHANNEL1, DMA_CCR1_PSIZE_32BIT);
|
dma_set_peripheral_size(DMA1, DMA_CHANNEL1, DMA_CCR1_PSIZE_32BIT);
|
||||||
|
|
||||||
/* After each 32Bit we have to increase the addres because we use RAM. */
|
/*
|
||||||
|
* After every 32bits we have to increase the address because
|
||||||
|
* we use RAM.
|
||||||
|
*/
|
||||||
dma_enable_memory_increment_mode(DMA1, DMA_CHANNEL1);
|
dma_enable_memory_increment_mode(DMA1, DMA_CHANNEL1);
|
||||||
dma_enable_peripheral_increment_mode(DMA1, DMA_CHANNEL1);
|
dma_enable_peripheral_increment_mode(DMA1, DMA_CHANNEL1);
|
||||||
|
|
||||||
@@ -107,18 +112,19 @@ int main(void)
|
|||||||
/* Destination should be string s2. */
|
/* Destination should be string s2. */
|
||||||
dma_set_memory_address(DMA1, DMA_CHANNEL1, (u32)&s2);
|
dma_set_memory_address(DMA1, DMA_CHANNEL1, (u32)&s2);
|
||||||
|
|
||||||
/* Set number of DATA to transfer.
|
/*
|
||||||
Remember that this means not necessary bytes but MSIZE or PSIZE
|
* Set number of DATA to transfer.
|
||||||
depending from your source device. */
|
* Remember that this means not necessary bytes but MSIZE or PSIZE
|
||||||
|
* depending on your source device.
|
||||||
|
*/
|
||||||
dma_set_number_of_data(DMA1, DMA_CHANNEL1, 5);
|
dma_set_number_of_data(DMA1, DMA_CHANNEL1, 5);
|
||||||
|
|
||||||
/* Start DMA transfer. */
|
/* Start DMA transfer. */
|
||||||
dma_enable_channel(DMA1, DMA_CHANNEL1);
|
dma_enable_channel(DMA1, DMA_CHANNEL1);
|
||||||
|
|
||||||
/* TODO: write a function to get the interrupt flags. */
|
/* TODO: Write a function to get the interrupt flags. */
|
||||||
while (!(DMA_ISR(DMA1) & 0x0000001))
|
while (!(DMA_ISR(DMA1) & 0x0000001))
|
||||||
{
|
;
|
||||||
}
|
|
||||||
|
|
||||||
dma_disable_channel(DMA1, DMA_CHANNEL1);
|
dma_disable_channel(DMA1, DMA_CHANNEL1);
|
||||||
|
|
||||||
@@ -127,6 +133,7 @@ int main(void)
|
|||||||
my_usart_print_string(USART1, s2);
|
my_usart_print_string(USART1, s2);
|
||||||
|
|
||||||
gpio_clear(GPIOB, GPIO6); /* LED2 on */
|
gpio_clear(GPIOB, GPIO6); /* LED2 on */
|
||||||
|
|
||||||
while (1); /* Halt. */
|
while (1); /* Halt. */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user