2121#include <device.h>
2222#include <dma.h>
2323
24- #define SYS_LOG_LEVEL CONFIG_SYS_LOG_DMA_LEVEL
25- #include <misc/sys_log.h>
24+ #if defined(CONFIG_STDOUT_CONSOLE )
25+ #include <stdio.h>
26+ #define DBG printf
27+ #else
28+ #include <misc/printk.h>
29+ #define DBG printk
30+ #endif
2631
2732#include <string.h>
2833
@@ -61,7 +66,7 @@ static void test_transfer(struct device *dev, void *data)
6166
6267static void test_error (struct device * dev , void * data )
6368{
64- SYS_LOG_ERR ("DMA could not proceed, an error occurred" );
69+ DBG ("DMA could not proceed, an error occurred\n " );
6570}
6671
6772void main (void )
@@ -73,13 +78,12 @@ void main(void)
7378 struct dma_channel_config dma_chan_cfg = {0 };
7479 struct dma_transfer_config dma_trans = {0 };
7580
76- SYS_LOG_DBG ("DMA memory to memory transfer started on %s" ,
77- DMA_DEVICE_NAME );
78- SYS_LOG_DBG ("Preparing DMA Controller" );
81+ DBG ("DMA memory to memory transfer started on %s\n" , DMA_DEVICE_NAME );
82+ DBG ("Preparing DMA Controller\n" );
7983
8084 dma = device_get_binding (DMA_DEVICE_NAME );
8185 if (!dma ) {
82- SYS_LOG_ERR ("Cannot get dma controller" );
86+ DBG ("Cannot get dma controller\n " );
8387 return ;
8488 }
8589
@@ -95,22 +99,22 @@ void main(void)
9599 dma_chan_cfg .callback_data = (void * )& chan_id ;
96100
97101 if (dma_channel_config (dma , chan_id , & dma_chan_cfg )) {
98- SYS_LOG_ERR ( " configuration" );
102+ DBG ( "Error: configuration\n " );
99103 return ;
100104 }
101105
102- SYS_LOG_DBG ("Starting the transfer and waiting for 1 second" );
106+ DBG ("Starting the transfer and waiting for 1 second\n " );
103107 dma_trans .block_size = strlen (tx_data );
104108 dma_trans .source_address = (uint32_t * )tx_data ;
105109 dma_trans .destination_address = (uint32_t * )rx_data [transfer_count ];
106110
107111 if (dma_transfer_config (dma , chan_id , & dma_trans )) {
108- SYS_LOG_ERR ( " transfer" );
112+ DBG ( "ERROR: transfer\n " );
109113 return ;
110114 }
111115
112116 if (dma_transfer_start (dma , chan_id )) {
113- SYS_LOG_ERR ( " transfer" );
117+ DBG ( "ERROR: transfer\n " );
114118 return ;
115119 }
116120
@@ -120,18 +124,18 @@ void main(void)
120124
121125 if (transfer_count < TRANSFER_LOOPS ) {
122126 transfer_count = TRANSFER_LOOPS ;
123- SYS_LOG_ERR ( " unfinished transfer" );
127+ DBG ( "ERROR: unfinished transfer\n " );
124128 if (dma_transfer_stop (dma , chan_id )) {
125- SYS_LOG_ERR ( " transfer stop" );
129+ DBG ( "ERROR: transfer stop\n " );
126130 }
127131 }
128132
129- SYS_LOG_DBG ("Each RX buffer should contain the full TX buffer string." );
130- SYS_LOG_DBG ("TX data: %s" , tx_data );
133+ DBG ("Each RX buffer should contain the full TX buffer string.\n " );
134+ DBG ("TX data: %s\n " , tx_data );
131135
132136 for (int i = 0 ; i < TRANSFER_LOOPS ; i ++ ) {
133- SYS_LOG_DBG ("RX data Loop %d: %s" , i , rx_data [i ]);
137+ DBG ("RX data Loop %d: %s\n " , i , rx_data [i ]);
134138 }
135139
136- SYS_LOG_INF ("Finished: DMA" );
140+ DBG ("Finished: DMA\n " );
137141}
0 commit comments