driver: spi: use new logger

move SPI drivers to use new logger.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2018-09-22 21:13:18 -05:00
commit 88aa2ca49f
15 changed files with 141 additions and 146 deletions

View file

@ -34,25 +34,10 @@ config SPI_INIT_PRIORITY
help
Device driver initialization priority.
config SYS_LOG_SPI_LEVEL
int "SPI Driver Log level"
depends on SYS_LOG
default 0
range 0 4
help
Sets log level for SPI drivers.
module = SPI
module-str = spi
source "subsys/logging/Kconfig.template.log_config"
Levels are:
- 0 OFF, do not write
- 1 ERROR, only write SYS_LOG_ERR
- 2 WARNING, write SYS_LOG_WRN in addition to previous level
- 3 INFO, write SYS_LOG_INF in addition to previous levels
- 4 DEBUG, write SYS_LOG_DBG in addition to previous levels
config SPI_0
bool "SPI port 0"

View file

@ -181,7 +181,7 @@ static inline void spi_context_cs_configure(struct spi_context *ctx)
ctx->config->cs->gpio_pin,
spi_context_cs_inactive_value(ctx));
} else {
SYS_LOG_INF("CS control inhibited (no GPIO device)");
LOG_INF("CS control inhibited (no GPIO device)");
}
}
@ -212,7 +212,7 @@ void spi_context_buffers_setup(struct spi_context *ctx,
const struct spi_buf_set *rx_bufs,
u8_t dfs)
{
SYS_LOG_DBG("tx_bufs %p - rx_bufs %p - %u", tx_bufs, rx_bufs, dfs);
LOG_DBG("tx_bufs %p - rx_bufs %p - %u", tx_bufs, rx_bufs, dfs);
if (tx_bufs) {
ctx->current_tx = tx_bufs->buffers;
@ -244,7 +244,7 @@ void spi_context_buffers_setup(struct spi_context *ctx,
ctx->recv_frames = 0;
#endif /* CONFIG_SPI_SLAVE */
SYS_LOG_DBG("current_tx %p (%zu), current_rx %p (%zu),"
LOG_DBG("current_tx %p (%zu), current_rx %p (%zu),"
" tx buf/len %p/%zu, rx buf/len %p/%zu",
ctx->current_tx, ctx->tx_count,
ctx->current_rx, ctx->rx_count,
@ -259,7 +259,7 @@ void spi_context_update_tx(struct spi_context *ctx, u8_t dfs, u32_t len)
}
if (len > ctx->tx_len) {
SYS_LOG_ERR("Update exceeds current buffer");
LOG_ERR("Update exceeds current buffer");
return;
}
@ -277,7 +277,7 @@ void spi_context_update_tx(struct spi_context *ctx, u8_t dfs, u32_t len)
ctx->tx_buf += dfs * len;
}
SYS_LOG_DBG("tx buf/len %p/%zu", ctx->tx_buf, ctx->tx_len);
LOG_DBG("tx buf/len %p/%zu", ctx->tx_buf, ctx->tx_len);
}
static ALWAYS_INLINE
@ -307,7 +307,7 @@ void spi_context_update_rx(struct spi_context *ctx, u8_t dfs, u32_t len)
}
if (len > ctx->rx_len) {
SYS_LOG_ERR("Update exceeds current buffer");
LOG_ERR("Update exceeds current buffer");
return;
}
@ -325,7 +325,7 @@ void spi_context_update_rx(struct spi_context *ctx, u8_t dfs, u32_t len)
ctx->rx_buf += dfs * len;
}
SYS_LOG_DBG("rx buf/len %p/%zu", ctx->rx_buf, ctx->rx_len);
LOG_DBG("rx buf/len %p/%zu", ctx->rx_buf, ctx->rx_len);
}
static ALWAYS_INLINE

View file

@ -5,11 +5,12 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#define SYS_LOG_DOMAIN "SPI DW"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SPI_LEVEL
#include <logging/sys_log.h>
#define LOG_DOMAIN "SPI DW"
#define LOG_LEVEL CONFIG_SPI_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(spi_dw);
#if (CONFIG_SYS_LOG_SPI_LEVEL == 4)
#if (CONFIG_SPI_LOG_LEVEL == 4)
#define DBG_COUNTER_INIT() \
u32_t __cnt = 0
#define DBG_COUNTER_INC() \
@ -76,7 +77,7 @@ out:
spi_context_cs_control(&spi->ctx, false);
SYS_LOG_DBG("SPI transaction completed %s error",
LOG_DBG("SPI transaction completed %s error",
error ? "with" : "without");
spi_context_complete(&spi->ctx, error);
@ -148,7 +149,7 @@ static void push_data(struct device *dev)
write_txftlr(0, info->regs);
}
SYS_LOG_DBG("Pushed: %d", DBG_COUNTER_RESULT());
LOG_DBG("Pushed: %d", DBG_COUNTER_RESULT());
}
static void pull_data(struct device *dev)
@ -189,7 +190,7 @@ static void pull_data(struct device *dev)
write_rxftlr(spi->ctx.rx_len - 1, info->regs);
}
SYS_LOG_DBG("Pulled: %d", DBG_COUNTER_RESULT());
LOG_DBG("Pulled: %d", DBG_COUNTER_RESULT());
}
static int spi_dw_configure(const struct spi_dw_config *info,
@ -198,7 +199,7 @@ static int spi_dw_configure(const struct spi_dw_config *info,
{
u32_t ctrlr0 = 0;
SYS_LOG_DBG("%p (prev %p)", config, spi->ctx.config);
LOG_DBG("%p (prev %p)", config, spi->ctx.config);
if (spi_context_configured(&spi->ctx, config)) {
/* Nothing to do */
@ -208,19 +209,19 @@ static int spi_dw_configure(const struct spi_dw_config *info,
/* Verify if requested op mode is relevant to this controller */
if (config->operation & SPI_OP_MODE_SLAVE) {
if (!(info->op_modes & SPI_CTX_RUNTIME_OP_MODE_SLAVE)) {
SYS_LOG_ERR("Slave mode not supported");
LOG_ERR("Slave mode not supported");
return -ENOTSUP;
}
} else {
if (!(info->op_modes & SPI_CTX_RUNTIME_OP_MODE_MASTER)) {
SYS_LOG_ERR("Master mode not supported");
LOG_ERR("Master mode not supported");
return -ENOTSUP;
}
}
if (config->operation & (SPI_TRANSFER_LSB |
SPI_LINES_DUAL | SPI_LINES_QUAD)) {
SYS_LOG_ERR("Unsupported configuration");
LOG_ERR("Unsupported configuration");
return -EINVAL;
}
@ -258,7 +259,7 @@ static int spi_dw_configure(const struct spi_dw_config *info,
spi_context_cs_configure(&spi->ctx);
if (spi_dw_is_slave(spi)) {
SYS_LOG_DBG("Installed slave config %p:"
LOG_DBG("Installed slave config %p:"
" ws/dfs %u/%u, mode %u/%u/%u",
config,
SPI_WORD_SIZE_GET(config->operation), spi->dfs,
@ -269,7 +270,7 @@ static int spi_dw_configure(const struct spi_dw_config *info,
(SPI_MODE_GET(config->operation) &
SPI_MODE_LOOP) ? 1 : 0);
} else {
SYS_LOG_DBG("Installed master config %p: freq %uHz (div = %u),"
LOG_DBG("Installed master config %p: freq %uHz (div = %u),"
" ws/dfs %u/%u, mode %u/%u/%u, slave %u",
config, config->frequency,
SPI_DW_CLK_DIVIDER(config->frequency),
@ -319,7 +320,7 @@ static void spi_dw_update_txftlr(const struct spi_dw_config *info,
}
}
SYS_LOG_DBG("TxFTLR: %u", reg_data);
LOG_DBG("TxFTLR: %u", reg_data);
write_txftlr(reg_data, info->regs);
}
@ -415,7 +416,7 @@ static int transceive(struct device *dev,
DW_SPI_IMR_UNMASK;
write_imr(reg_data, info->regs);
SYS_LOG_DBG("Ctrlr0 0x%08x Ctrlr1 0x%04x Txftlr 0x%08x"
LOG_DBG("Ctrlr0 0x%08x Ctrlr1 0x%04x Txftlr 0x%08x"
" Rxftlr 0x%08x Imr 0x%02x",
read_ctrlr0(info->regs), read_ctrlr1(info->regs),
read_txftlr(info->regs), read_rxftlr(info->regs),
@ -423,7 +424,7 @@ static int transceive(struct device *dev,
spi_context_cs_control(&spi->ctx, true);
SYS_LOG_DBG("Enabling controller");
LOG_DBG("Enabling controller");
set_bit_ssienr(info->regs);
ret = spi_context_wait_for_completion(&spi->ctx);
@ -438,7 +439,7 @@ static int spi_dw_transceive(struct device *dev,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs)
{
SYS_LOG_DBG("%p, %p, %p", dev, tx_bufs, rx_bufs);
LOG_DBG("%p, %p, %p", dev, tx_bufs, rx_bufs);
return transceive(dev, config, tx_bufs, rx_bufs, false, NULL);
}
@ -450,7 +451,7 @@ static int spi_dw_transceive_async(struct device *dev,
const struct spi_buf_set *rx_bufs,
struct k_poll_signal *async)
{
SYS_LOG_DBG("%p, %p, %p, %p", dev, tx_bufs, rx_bufs, async);
LOG_DBG("%p, %p, %p, %p", dev, tx_bufs, rx_bufs, async);
return transceive(dev, config, tx_bufs, rx_bufs, true, async);
}
@ -477,7 +478,7 @@ void spi_dw_isr(struct device *dev)
int_status = read_isr(info->regs);
SYS_LOG_DBG("SPI %p int_status 0x%x - (tx: %d, rx: %d)", dev,
LOG_DBG("SPI %p int_status 0x%x - (tx: %d, rx: %d)", dev,
int_status, read_txflr(info->regs), read_rxflr(info->regs));
if (int_status & DW_SPI_ISR_ERRORS_MASK) {
@ -522,7 +523,7 @@ int spi_dw_init(struct device *dev)
write_imr(DW_SPI_IMR_MASK, info->regs);
clear_bit_ssienr(info->regs);
SYS_LOG_DBG("Designware SPI driver initialized on device: %p", dev);
LOG_DBG("Designware SPI driver initialized on device: %p", dev);
spi_context_unlock_unconditionally(&spi->ctx);

View file

@ -6,9 +6,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define SYS_LOG_DOMAIN "SPI Intel"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SPI_LEVEL
#include <logging/sys_log.h>
#define LOG_DOMAIN "SPI Intel"
#define LOG_LEVEL CONFIG_SPI_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(spi_intel);
#include <errno.h>
@ -47,7 +48,7 @@ out:
spi_context_cs_control(&spi->ctx, false);
SYS_LOG_DBG("SPI transaction completed %s error",
LOG_DBG("SPI transaction completed %s error",
error ? "with" : "without");
spi_context_complete(&spi->ctx, error ? -EIO : 0);
@ -120,7 +121,7 @@ static int spi_intel_configure(struct device *dev,
{
struct spi_intel_data *spi = dev->driver_data;
SYS_LOG_DBG("%p (0x%x), %p", dev, spi->regs, config);
LOG_DBG("%p (0x%x), %p", dev, spi->regs, config);
if (spi_context_configured(&spi->ctx, config)) {
/* Nothing to do */
@ -185,7 +186,7 @@ static int transceive(struct device *dev,
/* Check status */
if (test_bit_sscr0_sse(spi->regs) && test_bit_sssr_bsy(spi->regs)) {
SYS_LOG_DBG("Controller is busy");
LOG_DBG("Controller is busy");
return -EBUSY;
}
@ -218,7 +219,7 @@ static int spi_intel_transceive(struct device *dev,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs)
{
SYS_LOG_DBG("%p, %p, %p", dev, tx_bufs, rx_bufs);
LOG_DBG("%p, %p, %p", dev, tx_bufs, rx_bufs);
return transceive(dev, config, tx_bufs, rx_bufs, false, NULL);
}
@ -230,7 +231,7 @@ static int spi_intel_transceive_async(struct device *dev,
const struct spi_buf_set *rx_bufs,
struct k_poll_signal *async)
{
SYS_LOG_DBG("%p, %p, %p, %p", dev, tx_bufs, rx_bufs, async);
LOG_DBG("%p, %p, %p, %p", dev, tx_bufs, rx_bufs, async);
return transceive(dev, config, tx_bufs, rx_bufs, true, async);
}
@ -242,7 +243,7 @@ static int spi_intel_release(struct device *dev,
struct spi_intel_data *spi = dev->driver_data;
if (test_bit_sscr0_sse(spi->regs) && test_bit_sssr_bsy(spi->regs)) {
SYS_LOG_DBG("Controller is busy");
LOG_DBG("Controller is busy");
return -EBUSY;
}
@ -257,7 +258,7 @@ void spi_intel_isr(struct device *dev)
u32_t error = 0;
u32_t status;
SYS_LOG_DBG("%p", dev);
LOG_DBG("%p", dev);
status = read_sssr(spi->regs);
if (status & INTEL_SPI_SSSR_ROR) {
@ -296,7 +297,7 @@ static inline int spi_intel_setup(struct device *dev)
pci_bus_scan_init();
if (!pci_bus_scan(&spi->pci_dev)) {
SYS_LOG_DBG("Could not find device");
LOG_DBG("Could not find device");
return 0;
}
@ -339,7 +340,7 @@ int spi_intel_init(struct device *dev)
irq_enable(info->irq);
SYS_LOG_DBG("SPI Intel Driver initialized on device: %p", dev);
LOG_DBG("SPI Intel Driver initialized on device: %p", dev);
return 0;
}
@ -358,7 +359,7 @@ static int spi_intel_suspend(struct device *dev)
const struct spi_intel_config *info = dev->config->config_info;
struct spi_intel_data *spi = dev->driver_data;
SYS_LOG_DBG("%p", dev);
LOG_DBG("%p", dev);
clear_bit_sscr0_sse(spi->regs);
irq_disable(info->irq);
@ -373,7 +374,7 @@ static int spi_intel_resume_from_suspend(struct device *dev)
const struct spi_intel_config *info = dev->config->config_info;
struct spi_intel_data *spi = dev->driver_data;
SYS_LOG_DBG("%p", dev);
LOG_DBG("%p", dev);
set_bit_sscr0_sse(spi->regs);
irq_enable(info->irq);

View file

@ -4,8 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SPI_LEVEL
#include <logging/sys_log.h>
#define LOG_LEVEL CONFIG_SPI_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(spi_ll_stm32);
#include <misc/util.h>
#include <kernel.h>
@ -53,7 +54,7 @@ static int spi_stm32_get_err(SPI_TypeDef *spi)
u32_t sr = LL_SPI_ReadReg(spi, SR);
if (sr & SPI_STM32_ERR_MSK) {
SYS_LOG_ERR("%s: err=%d", __func__,
LOG_ERR("%s: err=%d", __func__,
sr & (u32_t)SPI_STM32_ERR_MSK);
/* OVR error must be explicitly cleared */
@ -269,7 +270,7 @@ static int spi_stm32_configure(struct device *dev,
}
if (br > ARRAY_SIZE(scaler)) {
SYS_LOG_ERR("Unsupported frequency %uHz, max %uHz, min %uHz",
LOG_ERR("Unsupported frequency %uHz, max %uHz, min %uHz",
config->frequency,
clock >> 1,
clock >> ARRAY_SIZE(scaler));
@ -336,7 +337,7 @@ static int spi_stm32_configure(struct device *dev,
spi_context_cs_configure(&data->ctx);
SYS_LOG_DBG("Installed config %p: freq %uHz (div = %u),"
LOG_DBG("Installed config %p: freq %uHz (div = %u),"
" mode %u/%u/%u, slave %u",
config, clock >> br, 1 << br,
(SPI_MODE_GET(config->operation) & SPI_MODE_CPOL) ? 1 : 0,

View file

@ -10,8 +10,9 @@
#include <clock_control.h>
#include <fsl_dspi.h>
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SPI_LEVEL
#include <logging/sys_log.h>
#define LOG_LEVEL CONFIG_SPI_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(spi_mcux_dspi);
#include "spi_context.h"
@ -90,7 +91,7 @@ static void spi_mcux_transfer_next_packet(struct device *dev)
status = DSPI_MasterTransferNonBlocking(base, &data->handle, &transfer);
if (status != kStatus_Success) {
SYS_LOG_ERR("Transfer could not start");
LOG_ERR("Transfer could not start");
}
}
@ -130,14 +131,14 @@ static int spi_mcux_configure(struct device *dev,
DSPI_MasterGetDefaultConfig(&master_config);
if (spi_cfg->slave > FSL_FEATURE_DSPI_CHIP_SELECT_COUNT) {
SYS_LOG_ERR("Slave %d is greater than %d",
LOG_ERR("Slave %d is greater than %d",
spi_cfg->slave, FSL_FEATURE_DSPI_CHIP_SELECT_COUNT);
return -EINVAL;
}
word_size = SPI_WORD_SIZE_GET(spi_cfg->operation);
if (word_size > FSL_FEATURE_DSPI_MAX_DATA_WIDTH) {
SYS_LOG_ERR("Word size %d is greater than %d",
LOG_ERR("Word size %d is greater than %d",
word_size, FSL_FEATURE_DSPI_MAX_DATA_WIDTH);
return -EINVAL;
}

View file

@ -9,8 +9,9 @@
#include <clock_control.h>
#include <fsl_lpspi.h>
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SPI_LEVEL
#include <logging/sys_log.h>
#define LOG_LEVEL CONFIG_SPI_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(spi_mcux_lpspi);
#include "spi_context.h"
@ -93,7 +94,7 @@ static void spi_mcux_transfer_next_packet(struct device *dev)
status = LPSPI_MasterTransferNonBlocking(base, &data->handle,
&transfer);
if (status != kStatus_Success) {
SYS_LOG_ERR("Transfer could not start");
LOG_ERR("Transfer could not start");
}
}
@ -133,7 +134,7 @@ static int spi_mcux_configure(struct device *dev,
LPSPI_MasterGetDefaultConfig(&master_config);
if (spi_cfg->slave > CHIP_SELECT_COUNT) {
SYS_LOG_ERR("Slave %d is greater than %d",
LOG_ERR("Slave %d is greater than %d",
spi_cfg->slave,
CHIP_SELECT_COUNT);
return -EINVAL;
@ -141,7 +142,7 @@ static int spi_mcux_configure(struct device *dev,
word_size = SPI_WORD_SIZE_GET(spi_cfg->operation);
if (word_size > MAX_DATA_WIDTH) {
SYS_LOG_ERR("Word size %d is greater than %d",
LOG_ERR("Word size %d is greater than %d",
word_size, MAX_DATA_WIDTH);
return -EINVAL;
}

View file

@ -7,9 +7,10 @@
#include <spi.h>
#include <nrfx_spi.h>
#define SYS_LOG_DOMAIN "spi_nrfx_spi"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SPI_LEVEL
#include <logging/sys_log.h>
#define LOG_DOMAIN "spi_nrfx_spi"
#define LOG_LEVEL CONFIG_SPI_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(spi_nrfx_spi);
#include "spi_context.h"
@ -92,29 +93,29 @@ static int configure(struct device *dev,
}
if (SPI_OP_MODE_GET(spi_cfg->operation) != SPI_OP_MODE_MASTER) {
SYS_LOG_ERR("Slave mode is not supported on %s",
LOG_ERR("Slave mode is not supported on %s",
dev->config->name);
return -EINVAL;
}
if (spi_cfg->operation & SPI_MODE_LOOP) {
SYS_LOG_ERR("Loopback mode is not supported");
LOG_ERR("Loopback mode is not supported");
return -EINVAL;
}
if ((spi_cfg->operation & SPI_LINES_MASK) != SPI_LINES_SINGLE) {
SYS_LOG_ERR("Only single line mode is supported");
LOG_ERR("Only single line mode is supported");
return -EINVAL;
}
if (SPI_WORD_SIZE_GET(spi_cfg->operation) != 8) {
SYS_LOG_ERR("Word sizes other than 8 bits"
LOG_ERR("Word sizes other than 8 bits"
" are not supported");
return -EINVAL;
}
if (spi_cfg->frequency < 125000) {
SYS_LOG_ERR("Frequencies lower than 125 kHz are not supported");
LOG_ERR("Frequencies lower than 125 kHz are not supported");
return -EINVAL;
}
@ -158,7 +159,7 @@ static void transfer_next_chunk(struct device *dev)
spi_context_cs_control(ctx, false);
SYS_LOG_DBG("Transaction finished with status %d", error);
LOG_DBG("Transaction finished with status %d", error);
spi_context_complete(ctx, error);
dev_data->busy = false;
@ -260,7 +261,7 @@ static int init_spi(struct device *dev, const nrfx_spi_config_t *config)
event_handler,
dev);
if (result != NRFX_SUCCESS) {
SYS_LOG_ERR("Failed to initialize device: %s",
LOG_ERR("Failed to initialize device: %s",
dev->config->name);
return -EBUSY;
}

View file

@ -8,9 +8,10 @@
#include <nrfx_spim.h>
#include <string.h>
#define SYS_LOG_DOMAIN "spi_nrfx_spim"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SPI_LEVEL
#include <logging/sys_log.h>
#define LOG_DOMAIN "spi_nrfx_spim"
#define LOG_LEVEL CONFIG_SPI_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(spi_nrfx_spim);
#include "spi_context.h"
@ -106,29 +107,29 @@ static int configure(struct device *dev,
}
if (SPI_OP_MODE_GET(spi_cfg->operation) != SPI_OP_MODE_MASTER) {
SYS_LOG_ERR("Slave mode is not supported on %s",
LOG_ERR("Slave mode is not supported on %s",
dev->config->name);
return -EINVAL;
}
if (spi_cfg->operation & SPI_MODE_LOOP) {
SYS_LOG_ERR("Loopback mode is not supported");
LOG_ERR("Loopback mode is not supported");
return -EINVAL;
}
if ((spi_cfg->operation & SPI_LINES_MASK) != SPI_LINES_SINGLE) {
SYS_LOG_ERR("Only single line mode is supported");
LOG_ERR("Only single line mode is supported");
return -EINVAL;
}
if (SPI_WORD_SIZE_GET(spi_cfg->operation) != 8) {
SYS_LOG_ERR("Word sizes other than 8 bits"
LOG_ERR("Word sizes other than 8 bits"
" are not supported");
return -EINVAL;
}
if (spi_cfg->frequency < 125000) {
SYS_LOG_ERR("Frequencies lower than 125 kHz are not supported");
LOG_ERR("Frequencies lower than 125 kHz are not supported");
return -EINVAL;
}
@ -187,7 +188,7 @@ static void transfer_next_chunk(struct device *dev)
spi_context_cs_control(ctx, false);
SYS_LOG_DBG("Transaction finished with status %d", error);
LOG_DBG("Transaction finished with status %d", error);
spi_context_complete(ctx, error);
dev_data->busy = false;
@ -289,7 +290,7 @@ static int init_spim(struct device *dev, const nrfx_spim_config_t *config)
event_handler,
dev);
if (result != NRFX_SUCCESS) {
SYS_LOG_ERR("Failed to initialize device: %s",
LOG_ERR("Failed to initialize device: %s",
dev->config->name);
return -EBUSY;
}

View file

@ -7,9 +7,10 @@
#include <spi.h>
#include <nrfx_spis.h>
#define SYS_LOG_DOMAIN "spi_nrfx_spis"
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SPI_LEVEL
#include <logging/sys_log.h>
#define LOG_DOMAIN "spi_nrfx_spis"
#define LOG_LEVEL CONFIG_SPI_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(spi_nrfx_spis);
#include "spi_context.h"
@ -69,29 +70,29 @@ static int configure(struct device *dev,
}
if (SPI_OP_MODE_GET(spi_cfg->operation) == SPI_OP_MODE_MASTER) {
SYS_LOG_ERR("Master mode is not supported on %s",
LOG_ERR("Master mode is not supported on %s",
dev->config->name);
return -EINVAL;
}
if (spi_cfg->operation & SPI_MODE_LOOP) {
SYS_LOG_ERR("Loopback mode is not supported");
LOG_ERR("Loopback mode is not supported");
return -EINVAL;
}
if ((spi_cfg->operation & SPI_LINES_MASK) != SPI_LINES_SINGLE) {
SYS_LOG_ERR("Only single line mode is supported");
LOG_ERR("Only single line mode is supported");
return -EINVAL;
}
if (SPI_WORD_SIZE_GET(spi_cfg->operation) != 8) {
SYS_LOG_ERR("Word sizes other than 8 bits"
LOG_ERR("Word sizes other than 8 bits"
" are not supported");
return -EINVAL;
}
if (spi_cfg->cs) {
SYS_LOG_ERR("CS control via GPIO is not supported");
LOG_ERR("CS control via GPIO is not supported");
return -EINVAL;
}
@ -153,11 +154,11 @@ static int transceive(struct device *dev,
/* Invalid configuration. */
} else if ((tx_bufs && tx_bufs->count > 1) ||
(rx_bufs && rx_bufs->count > 1)) {
SYS_LOG_ERR("Scattered buffers are not supported");
LOG_ERR("Scattered buffers are not supported");
error = -ENOTSUP;
} else if (tx_bufs && tx_bufs->buffers[0].len &&
!nrfx_is_in_ram(tx_bufs->buffers[0].buf)) {
SYS_LOG_ERR("Only buffers located in RAM are supported");
LOG_ERR("Only buffers located in RAM are supported");
error = -ENOTSUP;
} else {
spi_context_buffers_setup(&dev_data->ctx, tx_bufs, rx_bufs, 1);
@ -236,7 +237,7 @@ static int init_spis(struct device *dev, const nrfx_spis_config_t *config)
event_handler,
dev);
if (result != NRFX_SUCCESS) {
SYS_LOG_ERR("Failed to initialize device: %s",
LOG_ERR("Failed to initialize device: %s",
dev->config->name);
return -EBUSY;
}

View file

@ -4,8 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_SPI_LEVEL
#include <logging/sys_log.h>
#define LOG_LEVEL CONFIG_SPI_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(spi_sam0);
#include "spi_context.h"
#include <errno.h>

View file

@ -4,7 +4,7 @@ CONFIG_GPIO=y
CONFIG_SPI=y
CONFIG_SPI_0=y
CONFIG_SYS_LOG_SPI_LEVEL=1
CONFIG_SPI_LOG_LEVEL_INF=y
CONFIG_IEEE802154_CC2520=y
CONFIG_IEEE802154_CC2520_SPI_DRV_NAME="SPI_0"

View file

@ -4,7 +4,7 @@ CONFIG_GPIO=y
CONFIG_SPI=y
CONFIG_SPI_0=y
CONFIG_SYS_LOG_SPI_LEVEL=1
CONFIG_SPI_LOG_LEVEL_INF=y
CONFIG_IEEE802154_CC2520=y
CONFIG_IEEE802154_CC2520_SPI_DRV_NAME="SPI_0"

View file

@ -1,7 +1,7 @@
CONFIG_TEST=y
CONFIG_BOOT_BANNER=y
CONFIG_SYS_LOG=y
CONFIG_LOG=y
CONFIG_SPI=y
CONFIG_SPI_ASYNC=y
CONFIG_SYS_LOG_SPI_LEVEL=1
CONFIG_SPI_LOG_LEVEL_INF=y
CONFIG_ZTEST=y

View file

@ -4,8 +4,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define SYS_LOG_LEVEL SYS_LOG_LEVEL_DEBUG
#include <logging/sys_log.h>
#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(main);
#include <zephyr.h>
#include <misc/printk.h>
@ -74,7 +75,7 @@ static int cs_ctrl_gpio_config(void)
{
spi_cs.gpio_dev = device_get_binding(CS_CTRL_GPIO_DRV_NAME);
if (!spi_cs.gpio_dev) {
SYS_LOG_ERR("Cannot find %s!", CS_CTRL_GPIO_DRV_NAME);
LOG_ERR("Cannot find %s!", CS_CTRL_GPIO_DRV_NAME);
zassert_not_null(spi_cs.gpio_dev, "Invalid gpio device");
return -1;
}
@ -108,11 +109,11 @@ static int spi_complete_loop(struct device *dev, struct spi_config *spi_conf)
int ret;
SYS_LOG_INF("Start");
LOG_INF("Start");
ret = spi_transceive(dev, spi_conf, &tx, &rx);
if (ret) {
SYS_LOG_ERR("Code %d", ret);
LOG_ERR("Code %d", ret);
zassert_false(ret, "SPI transceive failed");
return ret;
}
@ -120,15 +121,15 @@ static int spi_complete_loop(struct device *dev, struct spi_config *spi_conf)
if (memcmp(buffer_tx, buffer_rx, BUF_SIZE)) {
to_display_format(buffer_tx, BUF_SIZE, buffer_print_tx);
to_display_format(buffer_rx, BUF_SIZE, buffer_print_rx);
SYS_LOG_ERR("Buffer contents are different: %s",
LOG_ERR("Buffer contents are different: %s",
buffer_print_tx);
SYS_LOG_ERR(" vs: %s",
LOG_ERR(" vs: %s",
buffer_print_rx);
zassert_false(1, "Buffer contents are different");
return -1;
}
SYS_LOG_INF("Passed");
LOG_INF("Passed");
return 0;
}
@ -157,13 +158,13 @@ static int spi_rx_half_start(struct device *dev, struct spi_config *spi_conf)
};
int ret;
SYS_LOG_INF("Start");
LOG_INF("Start");
(void)memset(buffer_rx, 0, BUF_SIZE);
ret = spi_transceive(dev, spi_conf, &tx, &rx);
if (ret) {
SYS_LOG_ERR("Code %d", ret);
LOG_ERR("Code %d", ret);
zassert_false(ret, "SPI transceive failed");
return -1;
}
@ -171,15 +172,15 @@ static int spi_rx_half_start(struct device *dev, struct spi_config *spi_conf)
if (memcmp(buffer_tx, buffer_rx, 8)) {
to_display_format(buffer_tx, 8, buffer_print_tx);
to_display_format(buffer_rx, 8, buffer_print_rx);
SYS_LOG_ERR("Buffer contents are different: %s",
LOG_ERR("Buffer contents are different: %s",
buffer_print_tx);
SYS_LOG_ERR(" vs: %s",
LOG_ERR(" vs: %s",
buffer_print_rx);
zassert_false(1, "Buffer contents are different");
return -1;
}
SYS_LOG_INF("Passed");
LOG_INF("Passed");
return 0;
}
@ -212,13 +213,13 @@ static int spi_rx_half_end(struct device *dev, struct spi_config *spi_conf)
};
int ret;
SYS_LOG_INF("Start");
LOG_INF("Start");
(void)memset(buffer_rx, 0, BUF_SIZE);
ret = spi_transceive(dev, spi_conf, &tx, &rx);
if (ret) {
SYS_LOG_ERR("Code %d", ret);
LOG_ERR("Code %d", ret);
zassert_false(ret, "SPI transceive failed");
return -1;
}
@ -226,15 +227,15 @@ static int spi_rx_half_end(struct device *dev, struct spi_config *spi_conf)
if (memcmp(buffer_tx+8, buffer_rx, 8)) {
to_display_format(buffer_tx + 8, 8, buffer_print_tx);
to_display_format(buffer_rx, 8, buffer_print_rx);
SYS_LOG_ERR("Buffer contents are different: %s",
LOG_ERR("Buffer contents are different: %s",
buffer_print_tx);
SYS_LOG_ERR(" vs: %s",
LOG_ERR(" vs: %s",
buffer_print_rx);
zassert_false(1, "Buffer contents are different");
return -1;
}
SYS_LOG_INF("Passed");
LOG_INF("Passed");
return 0;
}
@ -275,13 +276,13 @@ static int spi_rx_every_4(struct device *dev, struct spi_config *spi_conf)
};
int ret;
SYS_LOG_INF("Start");
LOG_INF("Start");
(void)memset(buffer_rx, 0, BUF_SIZE);
ret = spi_transceive(dev, spi_conf, &tx, &rx);
if (ret) {
SYS_LOG_ERR("Code %d", ret);
LOG_ERR("Code %d", ret);
zassert_false(ret, "SPI transceive failed");
return -1;
}
@ -289,24 +290,24 @@ static int spi_rx_every_4(struct device *dev, struct spi_config *spi_conf)
if (memcmp(buffer_tx + 4, buffer_rx, 4)) {
to_display_format(buffer_tx + 4, 4, buffer_print_tx);
to_display_format(buffer_rx, 4, buffer_print_rx);
SYS_LOG_ERR("Buffer contents are different: %s",
LOG_ERR("Buffer contents are different: %s",
buffer_print_tx);
SYS_LOG_ERR(" vs: %s",
LOG_ERR(" vs: %s",
buffer_print_rx);
zassert_false(1, "Buffer contents are different");
return -1;
} else if (memcmp(buffer_tx + 12, buffer_rx + 4, 4)) {
to_display_format(buffer_tx + 12, 4, buffer_print_tx);
to_display_format(buffer_rx + 4, 4, buffer_print_rx);
SYS_LOG_ERR("Buffer contents are different: %s",
LOG_ERR("Buffer contents are different: %s",
buffer_print_tx);
SYS_LOG_ERR(" vs: %s",
LOG_ERR(" vs: %s",
buffer_print_rx);
zassert_false(1, "Buffer contents are different");
return -1;
}
SYS_LOG_INF("Passed");
LOG_INF("Passed");
return 0;
}
@ -326,7 +327,7 @@ static void spi_async_call_cb(struct k_poll_event *async_evt,
{
int ret;
SYS_LOG_DBG("Polling...");
LOG_DBG("Polling...");
while (1) {
ret = k_poll(async_evt, 1, K_MSEC(200));
@ -365,16 +366,16 @@ static int spi_async_call(struct device *dev, struct spi_config *spi_conf)
};
int ret;
SYS_LOG_INF("Start");
LOG_INF("Start");
ret = spi_transceive_async(dev, spi_conf, &tx, &rx, &async_sig);
if (ret == -ENOTSUP) {
SYS_LOG_DBG("Not supported");
LOG_DBG("Not supported");
return 0;
}
if (ret) {
SYS_LOG_ERR("Code %d", ret);
LOG_ERR("Code %d", ret);
zassert_false(ret, "SPI transceive failed");
return -1;
}
@ -382,12 +383,12 @@ static int spi_async_call(struct device *dev, struct spi_config *spi_conf)
k_sem_take(&caller, K_FOREVER);
if (result) {
SYS_LOG_ERR("Call code %d", ret);
LOG_ERR("Call code %d", ret);
zassert_false(result, "SPI transceive failed");
return -1;
}
SYS_LOG_INF("Passed");
LOG_INF("Passed");
return 0;
}
@ -404,7 +405,7 @@ static int spi_resource_lock_test(struct device *lock_dev,
}
if (spi_release(lock_dev, spi_conf_lock)) {
SYS_LOG_ERR("Deadlock now?");
LOG_ERR("Deadlock now?");
zassert_false(1, "SPI release failed");
return -1;
}
@ -423,7 +424,7 @@ void testing_spi(void)
struct device *spi_slow;
struct device *spi_fast;
SYS_LOG_INF("SPI test on buffers TX/RX %p/%p", buffer_tx, buffer_rx);
LOG_INF("SPI test on buffers TX/RX %p/%p", buffer_tx, buffer_rx);
#if defined(CONFIG_SPI_LOOPBACK_CS_GPIO)
if (cs_ctrl_gpio_config()) {
@ -433,7 +434,7 @@ void testing_spi(void)
spi_slow = device_get_binding(SPI_DRV_NAME);
if (!spi_slow) {
SYS_LOG_ERR("Cannot find %s!\n", SPI_DRV_NAME);
LOG_ERR("Cannot find %s!\n", SPI_DRV_NAME);
zassert_not_null(spi_slow, "Invalid SPI device");
return;
}
@ -467,7 +468,7 @@ void testing_spi(void)
goto end;
}
SYS_LOG_INF("All tx/rx passed");
LOG_INF("All tx/rx passed");
end:
k_thread_abort(async_thread_id);
}