From 84a9ccc328da1000a60b04bf0103479b2a2c7e69 Mon Sep 17 00:00:00 2001 From: Jon Szymaniak Date: Fri, 15 May 2015 12:59:32 -0400 Subject: [PATCH] nios: Define packet length in shared header --- fpga_common/include/nios_pkt_formats.h | 30 +++++++++++++++++++ .../software/bladeRF_nios/src/bladeRF_nios.c | 2 +- .../software/bladeRF_nios/src/pkt_handler.h | 6 ++-- .../software/bladeRF_nios/src/pkt_legacy.h | 4 +-- 4 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 fpga_common/include/nios_pkt_formats.h diff --git a/fpga_common/include/nios_pkt_formats.h b/fpga_common/include/nios_pkt_formats.h new file mode 100644 index 00000000..466e3cd8 --- /dev/null +++ b/fpga_common/include/nios_pkt_formats.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015 Nuand LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef BLADERF_NIOS_PKT_FORMATS_H_ +#define BLADERF_NIOS_PKT_FORMATS_H_ + +#include "nios_pkt_legacy.h" +#include "nios_pkt_retune.h" + +#define NIOS_PKT_LEN 16 + +#endif diff --git a/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/bladeRF_nios.c b/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/bladeRF_nios.c index 1d00c241..5179f4fc 100644 --- a/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/bladeRF_nios.c +++ b/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/bladeRF_nios.c @@ -99,7 +99,7 @@ int main(void) } /* Receive the rest of the message */ - while (count < PKT_BUFLEN) { + while (count < NIOS_PKT_LEN) { while (!fx3_uart_has_data()); set_request(&pkt, count++, fx3_uart_read()); } diff --git a/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/pkt_handler.h b/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/pkt_handler.h index 7329bc41..2f957529 100644 --- a/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/pkt_handler.h +++ b/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/pkt_handler.h @@ -26,6 +26,7 @@ #include #include +#include "nios_pkt_formats.h" #ifndef ARRAY_SIZE # define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) @@ -33,11 +34,10 @@ #define PKT_MAGIC_IDX 0 #define PKT_CFG_IDX 1 -#define PKT_BUFLEN 16 struct pkt_buf { - const uint8_t req[PKT_BUFLEN]; /* Request */ - uint8_t resp[PKT_BUFLEN]; /* Response */ + const uint8_t req[NIOS_PKT_LEN]; /* Request */ + uint8_t resp[NIOS_PKT_LEN]; /* Response */ }; diff --git a/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/pkt_legacy.h b/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/pkt_legacy.h index 7dc73c3e..f872c446 100644 --- a/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/pkt_legacy.h +++ b/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios/src/pkt_legacy.h @@ -26,10 +26,10 @@ #include #include "pkt_handler.h" -#include "nios_pkt_legacy.h" /* Shared definitions between NIOII & host */ +#include "nios_pkt_formats.h" #define PKT_LEGACY_MAGIC ((uint8_t) UART_PKT_MAGIC) -#define PKT_LEGACY_REQUIRED_BYTES PKT_BUFLEN +#define PKT_LEGACY_REQUIRED_BYTES NIOS_PKT_LEN void pkt_legacy(struct pkt_buf *b);