found irext example project

This commit is contained in:
2017-05-09 11:36:49 +08:00
parent 285a7b3a42
commit a51640d037
835 changed files with 265091 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
//******************************************************************************
//! \file npi_ble.h
//! \brief
//
// Revised $Date: 2015-01-29 11:51:00 -0800 (Thu, 29 Jan 2015) $
// Revision: $Revision: 42121 $
//
// Copyright 2015 Texas Instruments Incorporated. All rights reserved.
//
// IMPORTANT: Your use of this Software is limited to those specific rights
// granted under the terms of a software license agreement between the user
// who downloaded the software, his/her employer (which must be your employer)
// and Texas Instruments Incorporated (the "License"). You may not use this
// Software unless you agree to abide by the terms of the License. The License
// limits your use, and you acknowledge, that the Software may not be modified,
// copied or distributed unless used solely and exclusively in conjunction with
// a Texas Instruments radio frequency device, which is integrated into
// your product. Other than for the foregoing purpose, you may not use,
// reproduce, copy, prepare derivative works of, modify, distribute, perform,
// display or sell this Software and/or its documentation for any purpose.
//
// YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
// PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,l
// INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
// NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
// TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
// NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
// LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
// INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
// OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
// OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
// (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
//
// Should you have any questions regarding your right to use this Software,
// contact Texas Instruments Incorporated at www.TI.com.
//******************************************************************************
#ifndef NPIBLE_H
#define NPIBLE_H
#ifdef __cplusplus
extern "C"
{
#endif
// ****************************************************************************
// includes
// ****************************************************************************
#include "hal_types.h"
#include "OSAL.h"
// ****************************************************************************
// defines
// ****************************************************************************
// ****************************************************************************
// typedefs
// ****************************************************************************
typedef struct _npiPkt_t
{
osal_event_hdr_t hdr;
uint16 pktLen;
uint8 *pData;
}npiPkt_t;
typedef void (*npiCBack_t)(uint8 port, uint8 event);
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
extern void NPI_RegisterTask(uint8_t taskId);
#ifdef __cplusplus
}
#endif
#endif /* NPIBLE_H */

View File

@@ -0,0 +1,117 @@
//******************************************************************************
//! \file npi_config.h
//! \brief This file contains the Network Processor Interface (NPI),
//! which abstracts the physical link between the Application
//! Processor (AP) and the Network Processor (NP). The NPI
//! serves as the HAL's client for the SPI and UART drivers, and
//! provides API and callback services for its client.
//
// Revised $Date: 2015-04-10 15:19:48 -0700 (Fri, 10 Apr 2015) $
// Revision: $Revision: 43389 $
//
// Copyright 2015 Texas Instruments Incorporated. All rights reserved.
//
// IMPORTANT: Your use of this Software is limited to those specific rights
// granted under the terms of a software license agreement between the user
// who downloaded the software, his/her employer (which must be your employer)
// and Texas Instruments Incorporated (the "License"). You may not use this
// Software unless you agree to abide by the terms of the License. The License
// limits your use, and you acknowledge, that the Software may not be modified,
// copied or distributed unless used solely and exclusively in conjunction with
// a Texas Instruments radio frequency device, which is integrated into
// your product. Other than for the foregoing purpose, you may not use,
// reproduce, copy, prepare derivative works of, modify, distribute, perform,
// display or sell this Software and/or its documentation for any purpose.
//
// YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
// PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,l
// INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
// NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
// TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
// NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
// LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
// INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
// OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
// OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
// (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
//
// Should you have any questions regarding your right to use this Software,
// contact Texas Instruments Incorporated at www.TI.com.
//******************************************************************************
#ifndef NPI_CONFIG_H
#define NPI_CONFIG_H
#ifdef __cplusplus
extern "C"
{
#endif
// ****************************************************************************
// includes
// ****************************************************************************
#include "Board.h"
// ****************************************************************************
// defines
// ****************************************************************************
#if !defined(NPI_SPI_CONFIG)
#define NPI_SPI_CONFIG Board_SPI1
#endif
#ifdef POWER_SAVING
# if defined(NPI_USE_SPI)
# if (NPI_SPI_CONFIG == Board_SPI1)
# define MRDY_PIN Board_KEY_UP
# define SRDY_PIN Board_KEY_DOWN
# else
# error "ERROR: You must choose Board_SPI1 SPI module for NPI."
# endif
# elif defined(NPI_USE_UART)
# define MRDY_PIN Board_KEY_UP
# define SRDY_PIN Board_KEY_DOWN
# endif
# define SRDY_ENABLE() PIN_setOutputValue(hNpiHandshakePins, SRDY_PIN, 0) /* RTS low */
# define SRDY_DISABLE() PIN_setOutputValue(hNpiHandshakePins, SRDY_PIN, 1) /* RTS high */
#else // ! POWER_SAVING
# define SRDY_ENABLE()
# define SRDY_DISABLE()
#endif
#ifndef NPI_TL_BUF_SIZE
#define NPI_TL_BUF_SIZE 270
#endif
#define NPI_SPI_PAYLOAD_SIZE 255
#define NPI_SPI_HDR_LEN 4
#ifdef NPI_USE_SPI
# if (NPI_TL_BUF_SIZE - NPI_SPI_HDR_LEN) < NPI_SPI_PAYLOAD_SIZE
# define NPI_MAX_FRAG_SIZE (NPI_TL_BUF_SIZE - NPI_SPI_HDR_LEN)
# else
# define NPI_MAX_FRAG_SIZE NPI_SPI_PAYLOAD_SIZE
# endif
#elif NPI_USE_UART
# define NPI_MAX_FRAG_SIZE NPI_TL_BUF_SIZE
#else
# error "ERROR: NPI_USE_UART or NPI_USE_SPI must be defined."
#endif
// ****************************************************************************
// typedefs
// ****************************************************************************
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif /* NPI_CONFIG_H */

View File

@@ -0,0 +1,97 @@
//******************************************************************************
//! \file npi_data.h
//! \brief NPI Data structures
//
// Revised $Date: 2015-07-21 10:32:27 -0700 (Tue, 21 Jul 2015) $
// Revision: $Revision: 44380 $
//
// Copyright 2015 Texas Instruments Incorporated. All rights reserved.
//
// IMPORTANT: Your use of this Software is limited to those specific rights
// granted under the terms of a software license agreement between the user
// who downloaded the software, his/her employer (which must be your employer)
// and Texas Instruments Incorporated (the "License"). You may not use this
// Software unless you agree to abide by the terms of the License. The License
// limits your use, and you acknowledge, that the Software may not be modified,
// copied or distributed unless used solely and exclusively in conjunction with
// a Texas Instruments radio frequency device, which is integrated into
// your product. Other than for the foregoing purpose, you may not use,
// reproduce, copy, prepare derivative works of, modify, distribute, perform,
// display or sell this Software and/or its documentation for any purpose.
//
// YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
// PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,l
// INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
// NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
// TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
// NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
// LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
// INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
// OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
// OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
// (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
//
// Should you have any questions regarding your right to use this Software,
// contact Texas Instruments Incorporated at www.TI.com.
//******************************************************************************
#ifndef NPIDATA_H
#define NPIDATA_H
#ifdef __cplusplus
extern "C"
{
#endif
// ****************************************************************************
// includes
// ****************************************************************************
#include <stdint.h>
// ****************************************************************************
// defines
// ****************************************************************************
// ****************************************************************************
// typedefs
// ****************************************************************************
//! \brief NPI Command IDs.
//!
typedef enum
{
NPIMSG_Type_ASYNC = 0x00,
NPIMSG_Type_SYNCREQ = 0x01,
NPIMSG_Type_SYNCRSP = 0x02
} NPIMSG_Type;
//! \brief Structure to send an NPI message to the stack thread.
//!
typedef struct _npimsg_t
{
// Msg Type
uint_least8_t msgType;
// message buffer size
uint16_t pBufSize;
// message buffer
uint8_t *pBuf;
} NPIMSG_msg_t;
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif /* NPIDATA_H */

View File

@@ -0,0 +1,112 @@
//*****************************************************************************
//! \file npi_frame.h
//! \brief This file contains the Network Processor Interface (NPI)
//! data frame specific functions definitions.
//
// Revised $Date: 2015-01-29 11:51:00 -0800 (Thu, 29 Jan 2015) $
// Revision: $Revision: 42121 $
//
// Copyright 2015 Texas Instruments Incorporated. All rights reserved.
//
// IMPORTANT: Your use of this Software is limited to those specific rights
// granted under the terms of a software license agreement between the user
// who downloaded the software, his/her employer (which must be your employer)
// and Texas Instruments Incorporated (the "License"). You may not use this
// Software unless you agree to abide by the terms of the License. The License
// limits your use, and you acknowledge, that the Software may not be modified,
// copied or distributed unless used solely and exclusively in conjunction with
// a Texas Instruments radio frequency device, which is integrated into
// your product. Other than for the foregoing purpose, you may not use,
// reproduce, copy, prepare derivative works of, modify, distribute, perform,
// display or sell this Software and/or its documentation for any purpose.
//
// YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
// PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,l
// INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
// NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
// TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
// NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
// LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
// INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
// OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
// OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
// (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
//
// Should you have any questions regarding your right to use this Software,
// contact Texas Instruments Incorporated at www.TI.com.
//*****************************************************************************
#ifndef NPIFRAME_H
#define NPIFRAME_H
#ifdef __cplusplus
extern "C"
{
#endif
// ****************************************************************************
// includes
// ****************************************************************************
#include <inc/hw_types.h>
#include "npi_data.h"
// ****************************************************************************
// defines
// ****************************************************************************
// ****************************************************************************
// typedefs
// ****************************************************************************
//! \brief typedef for call back function to return a complete NPI message.
//! The npiFrame module encapsulates the collecting/parsing of the
//! complete message and returns via this callback the received message.
//! NOTE: the message buffer does NOT include the framing elements
//! (i.e. Start of Frame, FCS/CRC or similar).
typedef void (*npiIncomingFrameCBack_t)( uint8_t frameSize, uint8_t *pFrame,
NPIMSG_Type msgType );
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
// ----------------------------------------------------------------------------
//! \brief Initialize Frame module with NPI callbacks.
//!
//! \param[in] incomingFrameCB Call back for complete inbound (from host)
//! messages
//!
//! \return void
// ----------------------------------------------------------------------------
extern void NPIFrame_initialize(npiIncomingFrameCBack_t incomingFrameCB);
// ----------------------------------------------------------------------------
//! \brief Bundles message into Transport Layer frame and NPIMSG_msg_t
//! container. A transport layer specific version of this function
//! must be implemented.
//!
//! \param[in] pData Pointer to message buffer.
//!
//! \return void
// ----------------------------------------------------------------------------
extern NPIMSG_msg_t * NPIFrame_frameMsg(uint8_t *pIncomingMsg);
// ----------------------------------------------------------------------------
//! \brief Collects serial message buffer. Called based on events
//! received from the transport layer. When an entire message has
//! been successfully received, it is passed back to NPI task via
//! the callback function above: npiIncomingFrameCBack_t.
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPIFrame_collectFrameData(void);
#ifdef __cplusplus
}
#endif
#endif /* NPIFRAME_H */

View File

@@ -0,0 +1,102 @@
//******************************************************************************
//! \file npi_rxbuf.h
//! \brief NPI RX Buffer and utilities
//
// Revised $Date: 2015-04-13 13:27:37 -0700 (Mon, 13 Apr 2015) $
// Revision: $Revision: 43399 $
//
// Copyright 2015 Texas Instruments Incorporated. All rights reserved.
//
// IMPORTANT: Your use of this Software is limited to those specific rights
// granted under the terms of a software license agreement between the user
// who downloaded the software, his/her employer (which must be your employer)
// and Texas Instruments Incorporated (the "License"). You may not use this
// Software unless you agree to abide by the terms of the License. The License
// limits your use, and you acknowledge, that the Software may not be modified,
// copied or distributed unless used solely and exclusively in conjunction with
// a Texas Instruments radio frequency device, which is integrated into
// your product. Other than for the foregoing purpose, you may not use,
// reproduce, copy, prepare derivative works of, modify, distribute, perform,
// display or sell this Software and/or its documentation for any purpose.
//
// YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
// PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,l
// INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
// NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
// TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
// NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
// LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
// INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
// OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
// OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
// (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
//
// Should you have any questions regarding your right to use this Software,
// contact Texas Instruments Incorporated at www.TI.com.
//******************************************************************************
#ifndef NPIRXBUF_H
#define NPIRXBUF_H
#ifdef __cplusplus
extern "C"
{
#endif
// ****************************************************************************
// includes
// ****************************************************************************
#include "hal_types.h"
#include "OSAL.h"
#include "npi_config.h"
// ****************************************************************************
// defines
// ****************************************************************************
// ****************************************************************************
// typedefs
// ****************************************************************************
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
// -----------------------------------------------------------------------------
//! \brief NPIRxBuf_Read
//!
//! \param[in] len -
//!
//! \return uint16 -
// -----------------------------------------------------------------------------
uint16 NPIRxBuf_Read(uint16);
// -----------------------------------------------------------------------------
//! \brief Returns number of bytes that are unparsed in RxBuf
//!
//! \return uint16 -
// -----------------------------------------------------------------------------
uint16 NPIRxBuf_GetRxBufCount();
// -----------------------------------------------------------------------------
//! \brief Returns number of bytes that are available in RxBuf
//!
//! \return uint16 -
// -----------------------------------------------------------------------------
uint16 NPIRxBuf_GetRxBufAvail();
// -----------------------------------------------------------------------------
//! \brief NPIRxBuf_ReadFromRxBuf
//!
//! \return uint16 -
// -----------------------------------------------------------------------------
uint16 NPIRxBuf_ReadFromRxBuf(uint8_t *buf, uint16 len);
#ifdef __cplusplus
}
#endif
#endif /* NPIRXBUF_H */

View File

@@ -0,0 +1,144 @@
//******************************************************************************
//! \file npi_task.h
//! \brief NPI is a TI RTOS Application Thread that provides a
//! \brief common Network Processor Interface framework.
//
// Revised $Date: 2015-07-20 15:51:01 -0700 (Mon, 20 Jul 2015) $
// Revision: $Revision: 44375 $
//
// Copyright 2015 Texas Instruments Incorporated. All rights reserved.
//
// IMPORTANT: Your use of this Software is limited to those specific rights
// granted under the terms of a software license agreement between the user
// who downloaded the software, his/her employer (which must be your employer)
// and Texas Instruments Incorporated (the "License"). You may not use this
// Software unless you agree to abide by the terms of the License. The License
// limits your use, and you acknowledge, that the Software may not be modified,
// copied or distributed unless used solely and exclusively in conjunction with
// a Texas Instruments radio frequency device, which is integrated into
// your product. Other than for the foregoing purpose, you may not use,
// reproduce, copy, prepare derivative works of, modify, distribute, perform,
// display or sell this Software and/or its documentation for any purpose.
//
// YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
// PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,l
// INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
// NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
// TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
// NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
// LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
// INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
// OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
// OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
// (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
//
// Should you have any questions regarding your right to use this Software,
// contact Texas Instruments Incorporated at www.TI.com.
//******************************************************************************
#ifndef _NPITASK_H
#define _NPITASK_H
#ifdef __cplusplus
extern "C"
{
#endif
// ****************************************************************************
// includes
// ****************************************************************************
#include "npi_data.h"
// ****************************************************************************
// defines
// ****************************************************************************
// ****************************************************************************
// typedefs
// ****************************************************************************
// -----------------------------------------------------------------------------
//! \brief Typedef for call back function mechanism to reroute incoming NPI
//! messages.
//! NOTE: Definer MUST copy contents to local buffer. NPI task will
//! free this memory.
//! NOTE: The contained message buffer does NOT include any "framing"
//! bytes, ie. SOF, FCS etc.
//! \param[in] pMsg Pointer to "unframed" message buffer.
//!
//! \return void
// -----------------------------------------------------------------------------
typedef void (*npiIncomingEventCBack_t)(uint8_t *pMsg);
//! \brief numeration used to determine the type of NPI Rerouting requested
//! by the application.
//!
//! NONE: no rerouting despite callback non-null registered callback
//! func.
//! ECHO: Sends a copy of the NPI message to both the registered
//! application callback as well as to the stack task.
//! INTERCEPT: Sends the NPI message to the via the registered callback
//! and NOT to the stack task.
//!
typedef enum NPIEventRerouteType { NONE,
ECHO,
INTERCEPT } NPI_IncomingNPIEventRerouteType;
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
// -----------------------------------------------------------------------------
//! \brief NPI task creation function
//!
//! \return void
// -----------------------------------------------------------------------------
Void NPITask_createTask(uint32_t stackID);
// -----------------------------------------------------------------------------
//! \brief Register callback function to reroute incoming (from host)
//! NPI messages.
//!
//! \param[in] appRxCB Callback function.
//! \param[in] reRouteType Type of re-routing requested
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITask_registerIncomingRXEventAppCB(npiIncomingEventCBack_t appRxCB,
NPI_IncomingNPIEventRerouteType reRouteType);
// -----------------------------------------------------------------------------
//! \brief Register callback function to reroute outgoing (from stack)
//! NPI messages.
//!
//! \param[in] appTxCB Callback function.
//! \param[in] reRouteType Type of re-routing requested
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITask_registerIncomingTXEventAppCB(npiIncomingEventCBack_t appTxCB,
NPI_IncomingNPIEventRerouteType reRouteType);
// -----------------------------------------------------------------------------
//! \brief API for application task to send a message to the Host.
//! NOTE: It's assumed all message traffic to the stack will use
//! other (ICALL) APIs/Interfaces.
//!
//! \param[in] pMsg Pointer to "unframed" message buffer.
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITask_sendToHost(uint8_t *pMsg);
#ifdef __cplusplus
{
#endif // extern "C"
#endif // end of _NPITASK_H definition

View File

@@ -0,0 +1,177 @@
//******************************************************************************
//! \file npi_tl.h
//! \brief NPI Transport Layer API
//
// Revised $Date: 2015-07-20 15:51:01 -0700 (Mon, 20 Jul 2015) $
// Revision: $Revision: 44375 $
//
// Copyright 2015 Texas Instruments Incorporated. All rights reserved.
//
// IMPORTANT: Your use of this Software is limited to those specific rights
// granted under the terms of a software license agreement between the user
// who downloaded the software, his/her employer (which must be your employer)
// and Texas Instruments Incorporated (the "License"). You may not use this
// Software unless you agree to abide by the terms of the License. The License
// limits your use, and you acknowledge, that the Software may not be modified,
// copied or distributed unless used solely and exclusively in conjunction with
// a Texas Instruments radio frequency device, which is integrated into
// your product. Other than for the foregoing purpose, you may not use,
// reproduce, copy, prepare derivative works of, modify, distribute, perform,
// display or sell this Software and/or its documentation for any purpose.
//
// YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
// PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,l
// INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
// NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
// TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
// NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
// LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
// INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
// OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
// OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
// (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
//
// Should you have any questions regarding your right to use this Software,
// contact Texas Instruments Incorporated at www.TI.com.
//******************************************************************************
#ifndef NPI_TL_H
#define NPI_TL_H
#ifdef __cplusplus
extern "C"
{
#endif
// ****************************************************************************
// includes
// ****************************************************************************
#include "hal_types.h"
#include "inc/npi_config.h"
// ****************************************************************************
// defines
// ****************************************************************************
#if defined(NPI_USE_UART)
#define transportInit NPITLUART_initializeTransport
#define transportRead NPITLUART_readTransport
#define transportWrite NPITLUART_writeTransport
#define transportStopTransfer NPITLUART_stopTransfer
#define transportMrdyEvent NPITLUART_handleMrdyEvent
#elif defined(NPI_USE_SPI)
#define transportInit NPITLSPI_initializeTransport
#define transportRead NPITLSPI_readTransport
#define transportWrite NPITLSPI_writeTransport
#define transportStopTransfer NPITLSPI_stopTransfer
#define transportMrdyEvent NPITLSPI_handleMrdyEvent
#endif
// ****************************************************************************
// typedefs
// ****************************************************************************
// -----------------------------------------------------------------------------
//! \brief Typedef for call back function mechanism to notify NPI Task that
//! an NPI transaction has occurred
//! \param[in] int number of bytes either received or transmitted
//!
//! \return void
// -----------------------------------------------------------------------------
typedef void (*npiRtosCB_t)(int size);
// -----------------------------------------------------------------------------
//! \brief Typedef for call back function mechanism to notify NPI Task that
//! an MRDY edge has occurred
//! \param[in] void
//! \return void
// -----------------------------------------------------------------------------
typedef void (*npiMrdyRtosCB_t)();
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
// -----------------------------------------------------------------------------
//! \brief This routine initializes the transport layer and opens the port
//! of the device. Note that based on project defines, either the
//! UART, USB (CDC), or SPI driver can be used.
//!
//! \param[in] npiCBTx - Call back function for TX complete event
//! \param[in] npiCBRx - Call back function for RX event
//! \param[in] npiCBMrdy - Call back function for MRDY event
//!
//! \return void
// -----------------------------------------------------------------------------
void NPITL_initTL(npiRtosCB_t npiCBTx, npiRtosCB_t npiCBRx, npiRtosCB_t npiCBMrdy);
// -----------------------------------------------------------------------------
//! \brief This routine reads data from the transport layer based on len,
//! and places it into the buffer.
//!
//! \param[in] buf - Pointer to buffer to place read data.
//! \param[in] len - Number of bytes to read.
//!
//! \return uint16 - the number of bytes read from transport
// -----------------------------------------------------------------------------
uint16 NPITL_readTL(uint8 *buf, uint16 len);
// -----------------------------------------------------------------------------
//! \brief This routine writes data from the buffer to the transport layer.
//!
//! \param[in] buf - Pointer to buffer to write data from.
//! \param[in] len - Number of bytes to write.
//!
//! \return uint16 - the number of bytes written to transport
// -----------------------------------------------------------------------------
uint16 NPITL_writeTL(uint8 *buf, uint16 len);
// -----------------------------------------------------------------------------
//! \brief This routine is used to handle an MRDY edge from the application
//! context. Certain operations such as UART_read() cannot be
//! performed from the actual MRDY hwi handler
//!
//! \return void
// -----------------------------------------------------------------------------
void NPITL_handleMrdyEvent(void);
// -----------------------------------------------------------------------------
//! \brief This routine returns the max size receive buffer.
//!
//! \return uint16 - max size of the receive buffer
// -----------------------------------------------------------------------------
uint16 NPITL_getMaxRxBufSize(void);
// -----------------------------------------------------------------------------
//! \brief This routine returns the max size transmit buffer.
//!
//! \return uint16 - max size of the transmit buffer
// -----------------------------------------------------------------------------
uint16 NPITL_getMaxTxBufSize(void);
// -----------------------------------------------------------------------------
//! \brief Returns number of bytes that are unread in RxBuf
//!
//! \return uint16 - number of unread bytes
// -----------------------------------------------------------------------------
uint16 NPITL_getRxBufLen(void);
// -----------------------------------------------------------------------------
//! \brief This routine returns the state of transmission on NPI
//!
//! \return bool - state of NPI transmission - 1 - active, 0 - not active
// -----------------------------------------------------------------------------
bool NPITL_checkNpiBusy(void);
/*******************************************************************************
*/
#ifdef __cplusplus
}
#endif
#endif /* NPI_TL_H */

View File

@@ -0,0 +1,127 @@
//******************************************************************************
//! \file npi_tl_spi.h
//! \brief NPI Transport Layer Module for SPI
//
// Revised $Date: 2015-07-20 15:51:01 -0700 (Mon, 20 Jul 2015) $
// Revision: $Revision: 44375 $
//
// Copyright 2015 Texas Instruments Incorporated. All rights reserved.
//
// IMPORTANT: Your use of this Software is limited to those specific rights
// granted under the terms of a software license agreement between the user
// who downloaded the software, his/her employer (which must be your employer)
// and Texas Instruments Incorporated (the "License"). You may not use this
// Software unless you agree to abide by the terms of the License. The License
// limits your use, and you acknowledge, that the Software may not be modified,
// copied or distributed unless used solely and exclusively in conjunction with
// a Texas Instruments radio frequency device, which is integrated into
// your product. Other than for the foregoing purpose, you may not use,
// reproduce, copy, prepare derivative works of, modify, distribute, perform,
// display or sell this Software and/or its documentation for any purpose.
//
// YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
// PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,l
// INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
// NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
// TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
// NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
// LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
// INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
// OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
// OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
// (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
//
// Should you have any questions regarding your right to use this Software,
// contact Texas Instruments Incorporated at www.TI.com.
//******************************************************************************
#ifndef NPI_TL_SPI_H
#define NPI_TL_SPI_H
#ifdef __cplusplus
extern "C"
{
#endif
// ****************************************************************************
// includes
// ****************************************************************************
// ****************************************************************************
// defines
// ****************************************************************************
// SPI Slave baud rate
#define SPI_SLAVE_BAUD_RATE 8000000
#define NPI_SPI_HEADER_LEN 3
// ****************************************************************************
// typedefs
// ****************************************************************************
// -----------------------------------------------------------------------------
//! \brief Typedef for call back function mechanism to notify NPI TL that
//! an NPI transaction has occurred
//! \param[in] uint16 number of bytes received
//! \param[in] uint16 number of bytes transmitted
//!
//! \return void
// -----------------------------------------------------------------------------
typedef void (*npiCB_t)(uint16 Rxlen, uint16 Txlen);
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
// -----------------------------------------------------------------------------
//! \brief This routine initializes the transport layer and opens the port
//! of the device.
//!
//! \param[in] tRxBuf - pointer to NPI TL Tx Buffer
//! \param[in] tTxBuf - pointer to NPI TL Rx Buffer
//! \param[in] npiCBack - NPI TL call back function to be invoked at the end of
//! a SPI transaction
//!
//! \return void
// -----------------------------------------------------------------------------
void NPITLSPI_initializeTransport(Char *tRxBuf, Char *tTxBuf, npiCB_t npiCBack);
// -----------------------------------------------------------------------------
//! \brief This routine reads data from the transport layer
//! and places it into the buffer.
//!
//! \return void
// -----------------------------------------------------------------------------
void NPITLSPI_readTransport(void);
// -----------------------------------------------------------------------------
//! \brief This routine initializes and begins a SPI transaction
//!
//! \param[in] len - Number of bytes to write.
//!
//! \return uint16 - number of bytes written to transport
// -----------------------------------------------------------------------------
uint16 NPITLSPI_writeTransport(uint16);
// -----------------------------------------------------------------------------
//! \brief This routine stops any pending reads
//!
//! \return void
// -----------------------------------------------------------------------------
void NPITLSPI_stopTransfer(void);
// -----------------------------------------------------------------------------
//! \brief This routine is called from the application context when MRDY is
//! de-asserted
//!
//! \return void
// -----------------------------------------------------------------------------
void NPITLSPI_handleMrdyEvent(void);
#ifdef __cplusplus
}
#endif
#endif /* NPI_TL_SPI_H */

View File

@@ -0,0 +1,140 @@
//******************************************************************************
//! \file npi_tl_uart.h
//! \brief NPI Transport Layer Module for UART
//
// Revised $Date: 2015-07-20 15:51:01 -0700 (Mon, 20 Jul 2015) $
// Revision: $Revision: 44375 $
//
// Copyright 2015 Texas Instruments Incorporated. All rights reserved.
//
// IMPORTANT: Your use of this Software is limited to those specific rights
// granted under the terms of a software license agreement between the user
// who downloaded the software, his/her employer (which must be your employer)
// and Texas Instruments Incorporated (the "License"). You may not use this
// Software unless you agree to abide by the terms of the License. The License
// limits your use, and you acknowledge, that the Software may not be modified,
// copied or distributed unless used solely and exclusively in conjunction with
// a Texas Instruments radio frequency device, which is integrated into
// your product. Other than for the foregoing purpose, you may not use,
// reproduce, copy, prepare derivative works of, modify, distribute, perform,
// display or sell this Software and/or its documentation for any purpose.
//
// YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
// PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,l
// INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
// NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
// TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
// NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
// LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
// INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
// OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
// OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
// (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
//
// Should you have any questions regarding your right to use this Software,
// contact Texas Instruments Incorporated at www.TI.com.
//******************************************************************************
#ifndef NPI_TL_UART_H
#define NPI_TL_UART_H
#ifdef __cplusplus
extern "C"
{
#endif
// ****************************************************************************
// includes
// ****************************************************************************
#include "_hal_types.h"
// ****************************************************************************
// defines
// ****************************************************************************
#define NPI_UART_FC_THRESHOLD 48
#define NPI_UART_IDLE_TIMEOUT 6
#define NPI_UART_INT_ENABLE TRUE
#if !defined(NPI_UART_BR)
#define NPI_UART_BR 115200
#endif // !NPI_UART_BR
// UART ISR Buffer define
#define UART_ISR_BUF_SIZE 32
#define UART_ISR_BUF_CNT 2
// ****************************************************************************
// typedefs
// ****************************************************************************
// typedef unsigned short uint16;
// -----------------------------------------------------------------------------
//! \brief Typedef for call back function mechanism to notify NPI TL that
//! an NPI transaction has occurred
//! \param[in] uint16 number of bytes received
//! \param[in] uint16 number of bytes transmitted
//!
//! \return void
// -----------------------------------------------------------------------------
typedef void (*npiCB_t)(uint16 Rxlen, uint16 Txlen);
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
// -----------------------------------------------------------------------------
//! \brief This routine initializes the transport layer and opens the port
//! of the device.
//!
//! \param[in] tRxBuf - pointer to NPI TL Tx Buffer
//! \param[in] tTxBuf - pointer to NPI TL Rx Buffer
//! \param[in] npiCBack - NPI TL call back function to be invoked at the end of
//! a UART transaction
//!
//! \return void
// -----------------------------------------------------------------------------
void NPITLUART_initializeTransport(char *tRxBuf, char *tTxBuf, npiCB_t npiCBack);
// -----------------------------------------------------------------------------
//! \brief This routine reads data from the UART
//!
//! \return void
// -----------------------------------------------------------------------------
void NPITLUART_readTransport(void);
// -----------------------------------------------------------------------------
//! \brief This routine writes copies buffer addr to the transport layer.
//!
//! \param[in] len - Number of bytes to write.
//!
//! \return uint16 - number of bytes written to transport
// -----------------------------------------------------------------------------
uint16 NPITLUART_writeTransport(uint16);
// -----------------------------------------------------------------------------
//! \brief This routine stops any pending reads
//!
//! \return void
// -----------------------------------------------------------------------------
void NPITLUART_stopTransfer(void);
// -----------------------------------------------------------------------------
//! \brief This routine is called from the application context when MRDY is
//! de-asserted
//!
//! \return void
// -----------------------------------------------------------------------------
void NPITLUART_handleMrdyEvent(void);
#ifdef __cplusplus
}
#endif
#endif /* NPI_TL_UART_H */