Commit 6117b128 authored by Lucas Russo's avatar Lucas Russo

hal/*/protocols/*/*_spi.h: move register definitions

Now, they are located in hal/include/protocols/smpr_spi_regs.h.
Also, updated the hal.mk file to search files in the new folder
parent 2a18989e
......@@ -11,7 +11,8 @@ include hal/msg/msg.mk
include hal/boards/boards.mk
std_hal_INCLUDE_DIRS = hal/include \
hal/include/hw
hal/include/hw \
hal/include/protocols
hal_OUT += $(dev_mngr_OUT) $(dev_io_OUT)
......
/*
* Copyright (C) 2014 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU LGPL, version 3 or any later version.
*/
#ifndef _SMPR_SPI_REGS_H_
#define _SMPR_SPI_REGS_H_
#include "wb_spi_regs.h"
/* Copied from wb_acq_core_regs.h */
#if defined( __GNUC__)
#define PACKED __attribute__ ((packed))
#else
#error "Unsupported compiler?"
#endif
/* Copied from wb_acq_core_regs.h */
#ifndef __WBGEN2_MACROS_DEFINED__
#define __WBGEN2_MACROS_DEFINED__
#define WBGEN2_GEN_MASK(offset, size) (((1<<(size))-1) << (offset))
#define WBGEN2_GEN_WRITE(value, offset, size) (((value) & ((1<<(size))-1)) << (offset))
#define WBGEN2_GEN_READ(reg, offset, size) (((reg) >> (offset)) & ((1<<(size))-1))
#define WBGEN2_SIGN_EXTEND(value, bits) (((value) & (1<<bits) ? ~((1<<(bits))-1): 0 ) | (value))
#endif
/* Our flags are: SPI_PROTO_CHAR_LEN_MASK | SPI_PROTO_SS_MASK */
#define SMPR_PROTO_SPI_SS_FLAGS_W(value) SPI_PROTO_SS_W(value)
#define SMPR_PROTO_SPI_SS_FLAGS_R(reg) SPI_PROTO_SS_R(reg)
#define SMPR_PROTO_SPI_CHARLEN_FLAGS_R(reg) \
SPI_PROTO_CTRL_CHAR_LEN_R(reg >> SPI_PROTO_SS_SIZE)
#define SMPR_PROTO_SPI_CHARLEN_FLAGS_W(value) \
SPI_PROTO_CTRL_CHAR_LEN_W(value << SPI_PROTO_SS_SIZE)
#endif
......@@ -11,6 +11,7 @@
#include "sm_pr.h"
#include "sm_pr_err.h"
#include "wb_spi_regs.h"
#include "smpr_spi_regs.h"
#define SM_PR_SPI_READBACK 1
#define SM_PR_SPI_MAX_TRIES 10
......@@ -22,15 +23,6 @@
#define SMPR_PROTO_SPI(self) ((smpr_proto_spi_t *) self->proto_handler)
/* Our flags are: SPI_PROTO_CHAR_LEN_MASK | SPI_PROTO_SS_MASK */
#define SMPR_PROTO_SPI_SS_FLAGS_R(reg) SPI_PROTO_SS_R(reg)
#define SMPR_PROTO_SPI_CHARLEN_FLAGS_R(reg) \
SPI_PROTO_CTRL_CHAR_LEN_R(reg >> SPI_PROTO_SS_SIZE)
#define SMPR_PROTO_SPI_SS_FLAGS_W(value) SPI_PROTO_SS_W(value)
#define SMPR_PROTO_SPI_CHARLEN_FLAGS_W(value) \
SPI_PROTO_CTRL_CHAR_LEN_W(value << SPI_PROTO_SS_SIZE)
/* SPI open arguments */
struct _spi_proto_args_t {
uint32_t sys_freq; /* System clock [Hz] */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment