Spirit: Convert network driver to use STack packets vs. Basic packets. We need to use the STack packets in order to provide the source address.

This commit is contained in:
Gregory Nutt 2017-08-04 11:45:39 -06:00
parent df51b69895
commit 0d551cd0ac
5 changed files with 52 additions and 37 deletions

View File

@ -71,7 +71,7 @@
#include "spirit_linearfifo.h" #include "spirit_linearfifo.h"
#include "spirit_commands.h" #include "spirit_commands.h"
#include "spirit_radio.h" #include "spirit_radio.h"
#include "spirit_pktbasic.h" #include "spirit_pktstack.h"
#include "spirit_qi.h" #include "spirit_qi.h"
#include "spirit_management.h" #include "spirit_management.h"
#include "spirit_timer.h" #include "spirit_timer.h"
@ -286,9 +286,9 @@ static const struct radio_init_s g_radio_init =
SPIRIT_BANDWIDTH /* bandwidth selected in board.h */ SPIRIT_BANDWIDTH /* bandwidth selected in board.h */
}; };
/* Spirit PktBasic initialization */ /* Spirit PktSTack initialization */
static const struct pktbasic_init_s g_pktbasic_init = static const struct spirit_pktstack_init_s g_pktstack_init =
{ {
SPIRIT_SYNC_WORD, /* syncword selected in board.h */ SPIRIT_SYNC_WORD, /* syncword selected in board.h */
SPIRIT_PREAMBLE_LENGTH, /* premblen selected in board.h*/ SPIRIT_PREAMBLE_LENGTH, /* premblen selected in board.h*/
@ -301,11 +301,19 @@ static const struct pktbasic_init_s g_pktbasic_init =
SPIRIT_CRC_MODE, /* crcmode selected in board.h */ SPIRIT_CRC_MODE, /* crcmode selected in board.h */
#endif #endif
SPIRIT_CONTROL_LENGTH, /* ctrllen selected in board.h */ SPIRIT_CONTROL_LENGTH, /* ctrllen selected in board.h */
S_ENABLE, /* txdestaddr need to send address */
SPIRIT_EN_FEC, /* fec selected in board.h */ SPIRIT_EN_FEC, /* fec selected in board.h */
SPIRIT_EN_WHITENING /* datawhite selected in board.h */ SPIRIT_EN_WHITENING /* datawhite selected in board.h */
}; };
/* LLP Configuration */
static const struct spirit_pktstack_llp_s g_llp_init =
{
S_DISABLE, /* autoack */
S_DISABLE, /* piggyback */
PKT_N_RETX_3 /* maxretx */
};
/* GPIO Configuration. /* GPIO Configuration.
* *
* REVISIT: Assumes interrupt is on GPIO3. Might need to be configurable. * REVISIT: Assumes interrupt is on GPIO3. Might need to be configurable.
@ -331,7 +339,7 @@ static const struct spirit_csma_init_s g_csma_init =
}; };
#ifdef CONFIG_SPIRIT_PROMISICUOUS #ifdef CONFIG_SPIRIT_PROMISICUOUS
static struct pktbasic_addr_s g_addrinit = static struct spirit_pktstack_address_s g_addrinit =
{ {
S_DISABLE, /* Disable filtering on node address */ S_DISABLE, /* Disable filtering on node address */
SPIRIT_NODE_ADDR, /* Node address (Temporary, until assigned) */ SPIRIT_NODE_ADDR, /* Node address (Temporary, until assigned) */
@ -341,7 +349,7 @@ static struct pktbasic_addr_s g_addrinit =
SPIRIT_BCAST_ADDRESS /* Broadcast address */ SPIRIT_BCAST_ADDRESS /* Broadcast address */
}; };
#else #else
static struct pktbasic_addr_s g_addrinit = static struct spirit_pktstack_address_s g_addrinit =
{ {
S_ENABLE, /* Enable filtering on node address */ S_ENABLE, /* Enable filtering on node address */
SPIRIT_NODE_ADDR, /* Node address (Temporary, until assigned) */ SPIRIT_NODE_ADDR, /* Node address (Temporary, until assigned) */
@ -595,7 +603,7 @@ static int spirit_transmit(FAR struct spirit_driver_s *priv)
wlinfo("Payload length=%u\n", iob->io_len); wlinfo("Payload length=%u\n", iob->io_len);
ret = spirit_pktbasic_set_payloadlen(spirit, iob->io_len); ret = spirit_pktstack_set_payloadlen(spirit, iob->io_len);
if (ret < 0) if (ret < 0)
{ {
wlerr("ERROR: Failed to set payload length: %d\n", ret); wlerr("ERROR: Failed to set payload length: %d\n", ret);
@ -1047,7 +1055,7 @@ static void spirit_interrupt_work(FAR void *arg)
/* Read the packet into the I/O buffer */ /* Read the packet into the I/O buffer */
DEBUGVERIFY(spirit_fifo_read(spirit, iob->io_data, count)); DEBUGVERIFY(spirit_fifo_read(spirit, iob->io_data, count));
iob->io_len = spirit_pktbasic_get_rxpktlen(spirit); iob->io_len = spirit_pktstack_get_rxpktlen(spirit);
iob->io_offset = 0; iob->io_offset = 0;
iob->io_pktlen = iob->io_len; iob->io_pktlen = iob->io_len;
iob->io_flink = NULL; iob->io_flink = NULL;
@ -2041,21 +2049,28 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
/* Configures the SPIRIT1 packet handling logic */ /* Configures the SPIRIT1 packet handling logic */
wlinfo("Configure basic packets\n"); wlinfo("Configure STack packets\n");
ret = spirit_pktbasic_initialize(spirit, &g_pktbasic_init); ret = spirit_pktstack_initialize(spirit, &g_pktstack_init);
if (ret < 0) if (ret < 0)
{ {
wlerr("ERROR: spirit_radio_set_palevel_maxindex failed: %d\n", ret); wlerr("ERROR: spirit_radio_set_palevel_maxindex failed: %d\n", ret);
return ret; return ret;
} }
ret = spirit_pktstack_llp_initialize(spirit, &g_llp_init);
if (ret < 0)
{
wlerr("ERROR: spirit_pktstack_llp_initialize failed: %d\n", ret);
return ret;
}
/* Configure address filtering */ /* Configure address filtering */
wlinfo("Configure address filtering\n"); wlinfo("Configure address filtering\n");
ret = spirit_pktbasic_addr_initialize(spirit, &g_addrinit); ret = spirit_pktstack_address_initialize(spirit, &g_addrinit);
if (ret < 0) if (ret < 0)
{ {
wlerr("ERROR: spirit_pktbasic_addr_initialize failed: %d\n", ret); wlerr("ERROR: spirit_pktstack_address_initialize failed: %d\n", ret);
return ret; return ret;
} }

View File

@ -39,15 +39,15 @@
/* This module can be used to manage the configuration of Spirit Basic packets. /* This module can be used to manage the configuration of Spirit Basic packets.
* The user can obtain a packet configuration filling the structure struct * The user can obtain a packet configuration filling the structure struct
* pktbasic_init_s, defining in it some general parameters for the Spirit Basic * spirit_pktbasic_init_s, defining in it some general parameters for the Spirit Basic
* packet format. Another structure the user can fill is struct pktbasic_addr_s * packet format. Another structure the user can fill is struct spirit_pktbasic_addr_s
* to define the addresses which will be used during the communication. In * to define the addresses which will be used during the communication. In
* addition, functions to set the payload length and the destination address * addition, functions to set the payload length and the destination address
* are provided. * are provided.
* *
* Example: * Example:
* *
* struct pktbasic_init_s g_pkbasic_init = * struct spirit_pktbasic_init_s g_pkbasic_init =
* { * {
* PKT_PREAMBLE_LENGTH_08BYTES, # preamble length in bytes * PKT_PREAMBLE_LENGTH_08BYTES, # preamble length in bytes
* PKT_SYNC_LENGTH_4BYTES, # sync word length in bytes * PKT_SYNC_LENGTH_4BYTES, # sync word length in bytes
@ -61,7 +61,7 @@
* S_ENABLE # whitening * S_ENABLE # whitening
* }; * };
* *
* struct pktbasic_addr_s g_pktbasic_addrinit = * struct spirit_pktbasic_addr_s g_pktbasic_addrinit =
* { * {
* S_ENABLE, # enable/disable filtering on my address * S_ENABLE, # enable/disable filtering on my address
* 0x34, # my address (address of the current node) * 0x34, # my address (address of the current node)
@ -110,7 +110,7 @@
* users to set the main options for the Basic packet. * users to set the main options for the Basic packet.
*/ */
struct pktbasic_init_s struct spirit_pktbasic_init_s
{ {
uint32_t syncwords; /* Specifies the sync words. This parameter is uint32_t syncwords; /* Specifies the sync words. This parameter is
* a uint32_t word with format: * a uint32_t word with format:
@ -153,7 +153,7 @@ struct pktbasic_init_s
* correspondent filtering options. * correspondent filtering options.
*/ */
struct pktbasic_addr_s struct spirit_pktbasic_addr_s
{ {
uint8_t destfilter; /* If set RX packet is accepted if its destination uint8_t destfilter; /* If set RX packet is accepted if its destination
* address matches with srcaddr. This parameter * address matches with srcaddr. This parameter
@ -180,7 +180,7 @@ struct pktbasic_addr_s
* *
* Description: * Description:
* Initializes the Spirit Basic packet according to the specified parameters * Initializes the Spirit Basic packet according to the specified parameters
* in the struct pktbasic_init_s. Notice that this function sets the * in the struct spirit_pktbasic_init_s. Notice that this function sets the
* autofiltering option on CRC if it is set to any value different from * autofiltering option on CRC if it is set to any value different from
* BASIC_NO_CRC. * BASIC_NO_CRC.
* *
@ -194,7 +194,7 @@ struct pktbasic_addr_s
******************************************************************************/ ******************************************************************************/
int spirit_pktbasic_initialize(FAR struct spirit_library_s *spirit, int spirit_pktbasic_initialize(FAR struct spirit_library_s *spirit,
FAR const struct pktbasic_init_s *pktbasic); FAR const struct spirit_pktbasic_init_s *pktbasic);
/****************************************************************************** /******************************************************************************
* Name: spirit_pktbasic_get_setup * Name: spirit_pktbasic_get_setup
@ -213,14 +213,14 @@ int spirit_pktbasic_initialize(FAR struct spirit_library_s *spirit,
******************************************************************************/ ******************************************************************************/
int spirit_pktbasic_get_setup(FAR struct spirit_library_s *spirit, int spirit_pktbasic_get_setup(FAR struct spirit_library_s *spirit,
FAR struct pktbasic_init_s *pktbasic); FAR struct spirit_pktbasic_init_s *pktbasic);
/****************************************************************************** /******************************************************************************
* Name: spirit_pktbasic_addr_initialize * Name: spirit_pktbasic_addr_initialize
* *
* Description: * Description:
* Initializes the SPIRIT Basic packet addresses according to the specified * Initializes the SPIRIT Basic packet addresses according to the specified
* parameters in the struct pktbasic_init_s struct. * parameters in the struct spirit_pktbasic_init_s struct.
* *
* Input Parameters: * Input Parameters:
* spirit - Reference to a Spirit library state structure instance * spirit - Reference to a Spirit library state structure instance
@ -232,7 +232,7 @@ int spirit_pktbasic_get_setup(FAR struct spirit_library_s *spirit,
******************************************************************************/ ******************************************************************************/
int spirit_pktbasic_addr_initialize(FAR struct spirit_library_s *spirit, int spirit_pktbasic_addr_initialize(FAR struct spirit_library_s *spirit,
FAR struct pktbasic_addr_s *basicaddr); FAR struct spirit_pktbasic_addr_s *basicaddr);
/****************************************************************************** /******************************************************************************
* Name: spirit_pktbasic_get_addrsetup * Name: spirit_pktbasic_get_addrsetup
@ -251,7 +251,7 @@ int spirit_pktbasic_addr_initialize(FAR struct spirit_library_s *spirit,
******************************************************************************/ ******************************************************************************/
int spirit_pktbasic_get_addrsetup(FAR struct spirit_library_s *spirit, int spirit_pktbasic_get_addrsetup(FAR struct spirit_library_s *spirit,
FAR struct pktbasic_addr_s *basicaddr); FAR struct spirit_pktbasic_addr_s *basicaddr);
/****************************************************************************** /******************************************************************************
* Name: spirit_pktbasic_set_format * Name: spirit_pktbasic_set_format

View File

@ -436,7 +436,7 @@ int spirit_pkstack_set_rxsource_addrmask(FAR struct spirit_library_s *spirit,
uint8_t spirit_pktstack_get_rxsource_addrmask(FAR struct spirit_library_s *spirit); uint8_t spirit_pktstack_get_rxsource_addrmask(FAR struct spirit_library_s *spirit);
/****************************************************************************** /******************************************************************************
* Name: spirit_pkstack_get_rxpktlen * Name: spirit_pktstack_get_rxpktlen
* *
* Description: * Description:
* Returns the packet length field of the received packet. * Returns the packet length field of the received packet.
@ -449,7 +449,7 @@ uint8_t spirit_pktstack_get_rxsource_addrmask(FAR struct spirit_library_s *spiri
* *
******************************************************************************/ ******************************************************************************/
uint16_t spirit_pkstack_get_rxpktlen(FAR struct spirit_library_s *spirit); uint16_t spirit_pktstack_get_rxpktlen(FAR struct spirit_library_s *spirit);
/****************************************************************************** /******************************************************************************
* Name: spirit_pkstack_enable_rxsource_addrfilter * Name: spirit_pkstack_enable_rxsource_addrfilter

View File

@ -54,7 +54,7 @@
* *
* Description: * Description:
* Initializes the Spirit Basic packet according to the specified parameters * Initializes the Spirit Basic packet according to the specified parameters
* in the struct pktbasic_init_s. Notice that this function sets the * in the struct spirit_pktbasic_init_s. Notice that this function sets the
* autofiltering option on CRC if it is set to any value different from * autofiltering option on CRC if it is set to any value different from
* BASIC_NO_CRC. * BASIC_NO_CRC.
* *
@ -68,7 +68,7 @@
******************************************************************************/ ******************************************************************************/
int spirit_pktbasic_initialize(FAR struct spirit_library_s *spirit, int spirit_pktbasic_initialize(FAR struct spirit_library_s *spirit,
FAR const struct pktbasic_init_s *pktpasic) FAR const struct spirit_pktbasic_init_s *pktpasic)
{ {
uint8_t regval[4]; uint8_t regval[4];
uint8_t pktlenwidth; uint8_t pktlenwidth;
@ -230,7 +230,7 @@ int spirit_pktbasic_initialize(FAR struct spirit_library_s *spirit,
******************************************************************************/ ******************************************************************************/
int spirit_pktbasic_get_setup(FAR struct spirit_library_s *spirit, int spirit_pktbasic_get_setup(FAR struct spirit_library_s *spirit,
FAR struct pktbasic_init_s *pktbasic) FAR struct spirit_pktbasic_init_s *pktbasic)
{ {
uint8_t regval[10]; uint8_t regval[10];
int ret; int ret;
@ -301,7 +301,7 @@ int spirit_pktbasic_get_setup(FAR struct spirit_library_s *spirit,
* *
* Description: * Description:
* Initializes the SPIRIT Basic packet addresses according to the specified * Initializes the SPIRIT Basic packet addresses according to the specified
* parameters in the struct struct pktbasic_init_s struct. * parameters in the struct struct spirit_pktbasic_init_s struct.
* *
* Input Parameters: * Input Parameters:
* spirit - Reference to a Spirit library state structure instance * spirit - Reference to a Spirit library state structure instance
@ -313,7 +313,7 @@ int spirit_pktbasic_get_setup(FAR struct spirit_library_s *spirit,
******************************************************************************/ ******************************************************************************/
int spirit_pktbasic_addr_initialize(FAR struct spirit_library_s *spirit, int spirit_pktbasic_addr_initialize(FAR struct spirit_library_s *spirit,
FAR struct pktbasic_addr_s *basicaddr) FAR struct spirit_pktbasic_addr_s *basicaddr)
{ {
uint8_t regval[3]; uint8_t regval[3];
int ret; int ret;
@ -397,7 +397,7 @@ int spirit_pktbasic_addr_initialize(FAR struct spirit_library_s *spirit,
******************************************************************************/ ******************************************************************************/
int spirit_pktbasic_get_addrsetup(FAR struct spirit_library_s *spirit, int spirit_pktbasic_get_addrsetup(FAR struct spirit_library_s *spirit,
FAR struct pktbasic_addr_s *basicaddr) FAR struct spirit_pktbasic_addr_s *basicaddr)
{ {
uint8_t regval[3]; uint8_t regval[3];
int ret; int ret;

View File

@ -79,7 +79,7 @@ int spirit_pktstack_initialize(FAR struct spirit_library_s *spirit,
DEBUGASSERT(IS_PKT_SYNC_LENGTH(pktstack->synclen)); DEBUGASSERT(IS_PKT_SYNC_LENGTH(pktstack->synclen));
DEBUGASSERT(IS_PKT_CRC_MODE(pktstack->crcmode)); DEBUGASSERT(IS_PKT_CRC_MODE(pktstack->crcmode));
DEBUGASSERT(IS_PKT_LENGTH_WIDTH_BITS(pktstack->pktlenwidth)); DEBUGASSERT(IS_PKT_LENGTH_WIDTH_BITS(pktstack->pktlenwidth));
DEBUGASSERT(IS_PKT_CRC_MODE(pktstack->fixvarlen)); DEBUGASSERT(IS_PKT_FIX_VAR_LENGTH(pktstack->fixvarlen));
DEBUGASSERT(IS_SPIRIT_FUNCTIONAL_STATE(pktstack->fec)); DEBUGASSERT(IS_SPIRIT_FUNCTIONAL_STATE(pktstack->fec));
DEBUGASSERT(IS_SPIRIT_FUNCTIONAL_STATE(pktstack->datawhite)); DEBUGASSERT(IS_SPIRIT_FUNCTIONAL_STATE(pktstack->datawhite));
DEBUGASSERT(IS_PKT_CONTROL_LENGTH(pktstack->ctrllen)); DEBUGASSERT(IS_PKT_CONTROL_LENGTH(pktstack->ctrllen));
@ -554,7 +554,7 @@ int spirit_pktstack_set_format(FAR struct spirit_library_s *spirit)
/* Build value to be written. Also set to 0 the direct RX mode bits */ /* Build value to be written. Also set to 0 the direct RX mode bits */
regval &= 0x0f; regval &= 0x0f;
regval |= ((uint8_t) PCKTCTRL3_PCKT_FRMT_STACK); regval |= ((uint8_t)PCKTCTRL3_PCKT_FRMT_STACK);
/* Write the value to the PCKTCTRL3 register. */ /* Write the value to the PCKTCTRL3 register. */
@ -830,7 +830,7 @@ uint8_t spirit_pktstack_get_rxsource_addrmask(FAR struct spirit_library_s *spiri
} }
/****************************************************************************** /******************************************************************************
* Name: spirit_pkstack_get_rxpktlen * Name: spirit_pktstack_get_rxpktlen
* *
* Description: * Description:
* Returns the packet length field of the received packet. * Returns the packet length field of the received packet.
@ -843,7 +843,7 @@ uint8_t spirit_pktstack_get_rxsource_addrmask(FAR struct spirit_library_s *spiri
* *
******************************************************************************/ ******************************************************************************/
uint16_t spirit_pkstack_get_rxpktlen(FAR struct spirit_library_s *spirit) uint16_t spirit_pktstack_get_rxpktlen(FAR struct spirit_library_s *spirit)
{ {
uint8_t regval[2]; uint8_t regval[2];
uint16_t pktlen; uint16_t pktlen;