sys_log: replace old debug macros at DMA sample

DMA sample application is now using new system log macros and updated
the .conf file.

JIRA: ZEP-311

Change-Id: I11dbd5c58205297751696e483fc049c1c4b7654c
Signed-off-by: Genaro Saucedo Tejada <genaro.saucedo.tejada@intel.com>
This commit is contained in:
Genaro Saucedo Tejada 2016-07-29 15:50:39 -05:00 committed by Andrew Boie
commit 9a8ff013ab
2 changed files with 19 additions and 21 deletions

View file

@ -1,2 +1,4 @@
CONFIG_DMA=y CONFIG_DMA=y
CONFIG_DMA_QMSI=y CONFIG_DMA_QMSI=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_DMA_LEVEL=4

View file

@ -21,13 +21,8 @@
#include <device.h> #include <device.h>
#include <dma.h> #include <dma.h>
#if defined(CONFIG_STDOUT_CONSOLE) #define SYS_LOG_LEVEL CONFIG_SYS_LOG_DMA_LEVEL
#include <stdio.h> #include <misc/sys_log.h>
#define DBG printf
#else
#include <misc/printk.h>
#define DBG printk
#endif
#include <string.h> #include <string.h>
@ -66,7 +61,7 @@ static void test_transfer(struct device *dev, void *data)
static void test_error(struct device *dev, void *data) static void test_error(struct device *dev, void *data)
{ {
DBG("DMA could not proceed, an error occurred\n"); SYS_LOG_ERR("DMA could not proceed, an error occurred");
} }
void main(void) void main(void)
@ -78,12 +73,13 @@ void main(void)
struct dma_channel_config dma_chan_cfg = {0}; struct dma_channel_config dma_chan_cfg = {0};
struct dma_transfer_config dma_trans = {0}; struct dma_transfer_config dma_trans = {0};
DBG("DMA memory to memory transfer started on %s\n", DMA_DEVICE_NAME); SYS_LOG_DBG("DMA memory to memory transfer started on %s",
DBG("Preparing DMA Controller\n"); DMA_DEVICE_NAME);
SYS_LOG_DBG("Preparing DMA Controller");
dma = device_get_binding(DMA_DEVICE_NAME); dma = device_get_binding(DMA_DEVICE_NAME);
if (!dma) { if (!dma) {
DBG("Cannot get dma controller\n"); SYS_LOG_ERR("Cannot get dma controller");
return; return;
} }
@ -99,22 +95,22 @@ void main(void)
dma_chan_cfg.callback_data = (void *)&chan_id; dma_chan_cfg.callback_data = (void *)&chan_id;
if (dma_channel_config(dma, chan_id, &dma_chan_cfg)) { if (dma_channel_config(dma, chan_id, &dma_chan_cfg)) {
DBG("Error: configuration\n"); SYS_LOG_ERR("configuration");
return; return;
} }
DBG("Starting the transfer and waiting for 1 second\n"); SYS_LOG_DBG("Starting the transfer and waiting for 1 second");
dma_trans.block_size = strlen(tx_data); dma_trans.block_size = strlen(tx_data);
dma_trans.source_address = (uint32_t *)tx_data; dma_trans.source_address = (uint32_t *)tx_data;
dma_trans.destination_address = (uint32_t *)rx_data[transfer_count]; dma_trans.destination_address = (uint32_t *)rx_data[transfer_count];
if (dma_transfer_config(dma, chan_id, &dma_trans)) { if (dma_transfer_config(dma, chan_id, &dma_trans)) {
DBG("ERROR: transfer\n"); SYS_LOG_ERR("transfer");
return; return;
} }
if (dma_transfer_start(dma, chan_id)) { if (dma_transfer_start(dma, chan_id)) {
DBG("ERROR: transfer\n"); SYS_LOG_ERR("transfer");
return; return;
} }
@ -124,18 +120,18 @@ void main(void)
if (transfer_count < TRANSFER_LOOPS) { if (transfer_count < TRANSFER_LOOPS) {
transfer_count = TRANSFER_LOOPS; transfer_count = TRANSFER_LOOPS;
DBG("ERROR: unfinished transfer\n"); SYS_LOG_ERR("unfinished transfer");
if (dma_transfer_stop(dma, chan_id)) { if (dma_transfer_stop(dma, chan_id)) {
DBG("ERROR: transfer stop\n"); SYS_LOG_ERR("transfer stop");
} }
} }
DBG("Each RX buffer should contain the full TX buffer string.\n"); SYS_LOG_DBG("Each RX buffer should contain the full TX buffer string.");
DBG("TX data: %s\n", tx_data); SYS_LOG_DBG("TX data: %s", tx_data);
for (int i = 0; i < TRANSFER_LOOPS; i++) { for (int i = 0; i < TRANSFER_LOOPS; i++) {
DBG("RX data Loop %d: %s\n", i, rx_data[i]); SYS_LOG_DBG("RX data Loop %d: %s", i, rx_data[i]);
} }
DBG("Finished: DMA\n"); SYS_LOG_INF("Finished: DMA");
} }