updated example name”

This commit is contained in:
2017-06-10 17:57:47 +08:00
parent 5de4ac202c
commit c5327f8717
827 changed files with 1 additions and 1 deletions

View File

@@ -0,0 +1,183 @@
//******************************************************************************
//! \file npi_data.h
//! \brief NPI Data structures
//
// Revised: $Date: 2015-01-28 17:22:05 -0800 (Wed, 28 Jan 2015) $
// Revision: $Revision: 42106 $
//
// 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_DATA_H
#define NPI_DATA_H
#ifdef __cplusplus
extern "C"
{
#endif
// ****************************************************************************
// includes
// ****************************************************************************
#include <stdint.h>
#include <ti/drivers/UART.h>
#include <ti/drivers/SPI.h>
// ****************************************************************************
// defines
// ****************************************************************************
//! \brief NPI Constants
//!
#define NPI_MSG_SOF_VAL 0xFE
//! \brief NPI Command Type.
#define NPI_MSG_TYPE_POLL 0x00
#define NPI_MSG_TYPE_SYNCREQ 0x01
#define NPI_MSG_TYPE_ASYNC 0x02
#define NPI_MSG_TYPE_SYNCRSP 0x03
//! \brief NPI Message Lengths
#define NPI_MSG_CMD_LENGTH 2
#define NPI_MSG_LEN_LENGTH 2
#define NPI_MSG_HDR_LENGTH NPI_MSG_CMD_LENGTH + \
NPI_MSG_LEN_LENGTH
//! \brief NPI Subsystem IDs
//!
#define RPC_SYS_RES0 0
#define RPC_SYS_SYS 1
#define RPC_SYS_MAC 2
#define RPC_SYS_NWK 3
#define RPC_SYS_AF 4
#define RPC_SYS_ZDO 5
#define RPC_SYS_SAPI 6
#define RPC_SYS_UTIL 7
#define RPC_SYS_DBG 8
#define RPC_SYS_APP 9
#define RPC_SYS_RCAF 10
#define RPC_SYS_RCN 11
#define RPC_SYS_RCN_CLIENT 12
#define RPC_SYS_BOOT 13
#define RPC_SYS_ZIPTEST 14
#define RPC_SYS_DEBUG 15
#define RPC_SYS_PERIPHERALS 16
#define RPC_SYS_NFC 17
#define RPC_SYS_PB_NWK_MGR 18
#define RPC_SYS_PB_GW 19
#define RPC_SYS_PB_OTA_MGR 20
#define RPC_SYS_BLE_SNP 21
#define RPC_SYS_BLE_HCI 22
#define RPC_SYS_UNDEF1 23
#define RPC_SYS_UNDEF2 24
#define RPC_SYS_UNDEF3 25
#define RPC_SYS_UNDEF4 26
#define RPC_SYS_UNDEF5 27
#define RPC_SYS_UNDEF6 28
#define RPC_SYS_UNDEF7 29
#define RPC_SYS_UNDEF8 30
#define RPC_SYS_SRV_CTRL 31
//! \brief NPI Return Codes
#define NPI_SUCCESS 0
#define NPI_ROUTING_FULL 1
#define NPI_SS_NOT_FOUND 2
#define NPI_INCOMPLETE_PKT 3
#define NPI_INVALID_PKT 4
#define NPI_BUSY 5
#define NPI_TX_MSG_OVERSIZE 6
#define NPI_TASK_FAILURE 7
#define NPI_TASK_INVALID_PARAMS 8
//! \brief Reserved Subsystem ID
#define NPI_SS_RESERVED_ID 0x00
//! \brief Reserved ICall ID
#define NPI_ICALL_RESERVED_ID 0x00
//! \brief Masks for cmd0 bits of NPI message
#define NPI_CMD0_TYPE_MASK 0xE0
#define NPI_CMD0_TYPE_MASK_CLR 0x1F
#define NPI_CMD0_SS_MASK 0x1F
#define NPI_CMD0_SS_MASK_CLR 0xE0
#define NPI_SERIAL_TYPE_UART 0
#define NPI_SERIAL_TYPE_SPI 1 // Not supported
//! \brief Returns the message type of an NPI message
#define NPI_GET_MSG_TYPE(pMsg) ((pMsg->cmd0 & NPI_CMD0_TYPE_MASK)>> 5)
//! \brief Returns the subsystem ID of an NPI message
#define NPI_GET_SS_ID(pMsg) ((pMsg->cmd0) & NPI_CMD0_SS_MASK)
//! \brief Sets the message type of an NPI message
#define NPI_SET_MSG_TYPE(pMsg,TYPE) pMsg->cmd0 &= NPI_CMD0_TYPE_MASK_CLR; \
pMsg->cmd0 |= ( (TYPE & 0x3) << 5 );
//! \brief Sets the subsystem ID of an NPI message
#define NPI_SET_SS_ID(pMsg,SSID) pMsg->cmd0 &= NPI_CMD0_SS_MASK_CLR; \
pMsg->cmd0 |= ( (SSID & 0x1F) );
// ****************************************************************************
// typedefs
// ****************************************************************************
//! \brief Generic message NPI Frame. All messages sent over NPI Transport Layer
// will follow this structure. Any messages passed between NPI Task and
// subsystems will be of this type.
typedef struct _npiFrame_t
{
uint16_t dataLen;
uint8_t cmd0;
uint8_t cmd1;
uint8_t *pData;
} _npiFrame_t;
typedef union
{
UART_Params uartParams;
SPI_Params spiParams; // Not supported
} npiInterfaceParams;
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif /* NPI_DATA_H */

View File

@@ -0,0 +1,172 @@
//******************************************************************************
//! \file npi_task.h
//! \brief NPI is a TI RTOS Application Thread that provides a
//! \brief common Network Processor Interface framework.
//
// Revised: $Date: 2015-01-28 17:22:05 -0800 (Wed, 28 Jan 2015) $
// Revision: $Revision: 42106 $
//
// 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_TASK_H
#define NPI_TASK_H
#ifdef __cplusplus
extern "C"
{
#endif
// ****************************************************************************
// includes
// ****************************************************************************
#include "npi_data.h"
// ****************************************************************************
// defines
// ****************************************************************************
// ****************************************************************************
// typedefs
// ****************************************************************************
//! \brief Call back function that a subsystem must register with NPI Task to
// receive messages from the Host Processor
typedef void (*npiFromHostCBack_t)(_npiFrame_t *pNPIMsg);
//! \brief Call back function that a subsystem must register with NPI Task to
// receive forwarded messages from ICall
typedef void (*npiFromICallCBack_t)(uint8_t *pGenMsg);
typedef struct
{
uint16_t stackSize; //!< Configurable size of stack for NPI Task
uint16_t bufSize; //!< Buffer size of Tx/Rx Transport layer buffers
uint32_t mrdyPinID; //!< Pin ID Mrdy (only with Power Saving enabled)
uint32_t srdyPinID; //!< Pin ID Srdy (only with Power Saving enabled)
uint8_t portType; //!< NPI_SERIAL_TYPE_[UART,SPI]
uint8_t portBoardID; //!< Board ID for HW, i.e. CC2650_UART0
npiInterfaceParams portParams; //!< Params to initialize NPI port
} NPI_Params;
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
// -----------------------------------------------------------------------------
//! \brief Initialize a NPI_Params struct with default values
//!
//! \param[in] portType NPI_SERIAL_TYPE_[UART,SPI]
//! \param[in] params Pointer to NPI params to be initialized
//!
//! \return uint8_t Status NPI_SUCCESS, NPI_TASK_INVALID_PARAMS
// -----------------------------------------------------------------------------
extern uint8_t NPITask_Params_init(uint8_t portType, NPI_Params *params);
// -----------------------------------------------------------------------------
//! \brief Task creation function for NPI
//!
//! \param[in] params Pointer to NPI params which will be used to
//! initialize the NPI Task
//!
//! \return uint8_t Status NPI_SUCCESS, or NPI_TASK_FAILURE
// -----------------------------------------------------------------------------
extern uint8_t NPITask_open(NPI_Params *params);
// -----------------------------------------------------------------------------
//! \brief NPI Task close and tear down. Cannot be used with ICall because
//! ICall service cannot be un-enrolled
//!
//! \return uint8_t Status NPI_SUCCESS, or NPI_TASK_FAILURE
// -----------------------------------------------------------------------------
extern uint8_t NPITask_close(void);
// -----------------------------------------------------------------------------
//! \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 uint8_t Status NPI_SUCCESS, or NPI_SS_NOT_FOUND
// -----------------------------------------------------------------------------
extern uint8_t NPITask_sendToHost(_npiFrame_t *pMsg);
// -----------------------------------------------------------------------------
//! \brief API for subsystems to register for NPI messages received with
//! the specific ssID. All NPI messages will be passed to callback
//! provided
//!
//! \param[in] ssID The subsystem ID of NPI messages that should be routed
//! to pCB
//! \param[in] pCB The call back function that will receive NPI messages
//!
//! \return uint8_t Status NPI_SUCCESS, or NPI_ROUTING_FULL
// -----------------------------------------------------------------------------
extern uint8_t NPITask_regSSFromHostCB(uint8_t ssID, npiFromHostCBack_t pCB);
// -----------------------------------------------------------------------------
//! \brief API for subsystems to register for ICall messages received from
//! the specific source entity ID. All ICall messages will be passed
//! to the callback provided
//!
//! \param[in] icallID Source entity ID whose messages should be sent to pCB
//! pCB The call back function that will receive ICall messages
//!
//! \return uint8_t Status NPI_SUCCESS, or NPI_ROUTING_FULL
// -----------------------------------------------------------------------------
extern uint8_t NPITask_regSSFromICallCB(uint8_t icallID, npiFromICallCBack_t pCB);
// -----------------------------------------------------------------------------
//! \brief API to allocate an NPI frame of a given data length
//!
//! \param[in] len Length of data field of frame
//!
//! \return _npiFrame_t * Pointer to newly allocated frame
// -----------------------------------------------------------------------------
extern _npiFrame_t * NPITask_mallocFrame(uint16_t len);
// -----------------------------------------------------------------------------
//! \brief API to de-allocate an NPI frame
//!
//! \param[in] frame Pointer to NPI frame to be de-allocated
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITask_freeFrame(_npiFrame_t *frame);
#ifdef __cplusplus
}
#endif // extern "C"
#endif // end of NPI_TASK_H definition

View File

@@ -0,0 +1,193 @@
//******************************************************************************
//! \file npi_tl.h
//! \brief NPI Transport Layer API
//
// Revised: $Date: 2015-01-28 17:22:05 -0800 (Wed, 28 Jan 2015) $
// Revision: $Revision: 42106 $
//
// 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 "inc/npi_data.h"
#include "hal_types.h"
// ****************************************************************************
// defines
// ****************************************************************************
#if defined(NPI_USE_UART)
#define transportOpen NPITLUART_openTransport
#define transportClose NPITLUART_closeTransport
#define transportRead NPITLUART_readTransport
#define transportWrite NPITLUART_writeTransport
#define transportStopTransfer NPITLUART_stopTransfer
#define transportRemRdyEvent NPITLUART_handleRemRdyEvent
#elif defined(NPI_USE_SPI)
#define transportOpen NPITLSPI_openTransport
#define transportClose NPITLSPI_closeTransport
#define transportRead NPITLSPI_readTransport
#define transportWrite NPITLSPI_writeTransport
#define transportStopTransfer NPITLSPI_stopTransfer
#define transportRemRdyEvent NPITLSPI_handleRemRdyEvent
#endif //NPI_USE_UART
// ****************************************************************************
// typedefs
// ****************************************************************************
//! \brief Typedef for call back function mechanism to notify NPI Task that
//! an NPI transaction has occurred
typedef void (*npiRtosCB_t)(uint16_t sizeRx, uint16_t sizeTx);
//! \brief Typedef for call back function mechanism to notify NPI Task that
//! an Remote Ready edge has occurred
typedef void (*npiMrdyRtosCB_t)(uint8_t state);
//! \brief Struct for transport layer call backs
typedef struct
{
npiMrdyRtosCB_t remRdyCB;
npiRtosCB_t transCompleteCB;
} npiTLCallBacks;
typedef struct
{
uint16_t npiTLBufSize; //!< Buffer size of Tx/Rx Transport layer buffers
uint32_t mrdyPinID; //!< Pin ID Mrdy (only with Power Saving enabled)
uint32_t srdyPinID; //!< Pin ID Srdy (only with Power Saving enabled)
uint8_t portType; //!< NPI_SERIAL_TYPE_[UART,SPI]
uint8_t portBoardID; //!< Board ID for HW, i.e. CC2650_UART0
npiInterfaceParams portParams; //!< Params to initialize NPI port
npiTLCallBacks npiCallBacks; //!< Call backs to NPI Task
} NPITL_Params;
//*****************************************************************************
// 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, or SPI driver can be used.
//!
//! \param[in] params - Transport Layer parameters
//!
//! \return void
// -----------------------------------------------------------------------------
void NPITL_openTL(NPITL_Params *params);
// -----------------------------------------------------------------------------
//! \brief This routine closes the transport layer
//!
//! \return void
// -----------------------------------------------------------------------------
void NPITL_closeTL(void);
// -----------------------------------------------------------------------------
//! \brief This routine reads data from the transport layer based on len,
//! and places it into the buffer.
//!
//! \param[out] buf - Pointer to buffer to place read data.
//! \param[in] len - Number of bytes to read.
//!
//! \return uint16_t - the number of bytes read from transport
// -----------------------------------------------------------------------------
uint16_t NPITL_readTL(uint8_t *buf, uint16_t 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_t - NPI Error Code value
// -----------------------------------------------------------------------------
uint8_t NPITL_writeTL(uint8_t *buf, uint16_t len);
// -----------------------------------------------------------------------------
//! \brief This routine is used to handle an Rem RDY edge from the app
//! context. Certain operations such as UART_read() cannot be
//! performed from the actual hwi handler
//!
//! \return void
// -----------------------------------------------------------------------------
void NPITL_handleRemRdyEvent(void);
// -----------------------------------------------------------------------------
//! \brief This routine returns the max size receive buffer.
//!
//! \return uint16_t - max size of the receive buffer
// -----------------------------------------------------------------------------
uint16_t NPITL_getMaxRxBufSize(void);
// -----------------------------------------------------------------------------
//! \brief This routine returns the max size transmit buffer.
//!
//! \return uint16_t - max size of the transmit buffer
// -----------------------------------------------------------------------------
uint16_t NPITL_getMaxTxBufSize(void);
// -----------------------------------------------------------------------------
//! \brief Returns number of bytes that are unread in RxBuf
//!
//! \return uint16_t - number of unread bytes
// -----------------------------------------------------------------------------
uint16_t 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,131 @@
//******************************************************************************
//! \file npi_tl_spi.h
//! \brief NPI Transport Layer Module for SPI
//
// Revised: $Date: 2015-01-28 17:22:05 -0800 (Wed, 28 Jan 2015) $
// Revision: $Revision: 42106 $
//
// 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
// ****************************************************************************
#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] rxLen number of bytes received
//! \param[in] txLen number of bytes transmitted
//!
//! \return void
// -----------------------------------------------------------------------------
typedef void (*npiCB_t)(uint16_t rxLen, uint16_t txLen);
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
// -----------------------------------------------------------------------------
//! \brief This routine initializes the transport layer and opens the port
//! of the device.
//!
//! \param[in] portID ID value for board specific SPI port
//! \param[in] portParams Parameters used to initialize SPI port
//! \param[in] npiCBack Transport Layer call back function
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITLSPI_openTransport(uint8_t portID, SPI_Params *portParams,
npiCB_t npiCBack);
// -----------------------------------------------------------------------------
//! \brief This routine closes Transport Layer port
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITLSPI_closeTransport(void);
// -----------------------------------------------------------------------------
//! \brief This routine reads data from the transport layer
//! and places it into the buffer.
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITLSPI_readTransport(void);
// -----------------------------------------------------------------------------
//! \brief This routine initializes and begins a SPI transaction
//!
//! \param[in] len - Number of bytes to write.
//!
//! \return uint16_t - number of bytes written to transport
// -----------------------------------------------------------------------------
extern uint16_t NPITLSPI_writeTransport(uint16_t len);
// -----------------------------------------------------------------------------
//! \brief This routine stops any pending reads
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITLSPI_stopTransfer(void);
// -----------------------------------------------------------------------------
//! \brief This routine is called from the application context when REM RDY
//! is de-asserted
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITLSPI_handleRemRdyEvent(void);
#ifdef __cplusplus
}
#endif
#endif /* NPI_TL_SPI_H */

View File

@@ -0,0 +1,132 @@
//******************************************************************************
//! \file npi_tl_uart.h
//! \brief NPI Transport Layer Module for UART
//
// Revised: $Date: 2015-01-28 17:22:05 -0800 (Wed, 28 Jan 2015) $
// Revision: $Revision: 42106 $
//
// 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
// ****************************************************************************
// ****************************************************************************
// defines
// ****************************************************************************
// UART ISR Buffer define
#define UART_ISR_BUF_SIZE 128
// ****************************************************************************
// typedefs
// ****************************************************************************
// -----------------------------------------------------------------------------
//! \brief Typedef for call back function mechanism to notify NPI TL that
//! an NPI transaction has occurred
//! \param[in] rxLen number of bytes received
//! \param[in] txLen number of bytes transmitted
//!
//! \return void
// -----------------------------------------------------------------------------
typedef void (*npiCB_t)(uint16_t rxLen, uint16_t txLen);
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
// -----------------------------------------------------------------------------
//! \brief This routine initializes the transport layer and opens the port
//! of the device.
//!
//! \param[in] portID ID value for board specific UART port
//! \param[in] portParams Parameters used to initialize UART port
//! \param[in] npiCBack Transport Layer call back function
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITLUART_openTransport(uint8_t portID, UART_Params *portParams,
npiCB_t npiCBack);
// -----------------------------------------------------------------------------
//! \brief This routine closes Transport Layer port
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITLUART_closeTransport(void);
// -----------------------------------------------------------------------------
//! \brief This routine reads data from the UART
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITLUART_readTransport(void);
// -----------------------------------------------------------------------------
//! \brief This routine initializes and begins a UART transfer
//!
//! \param[in] len - Number of bytes to write.
//!
//! \return uint16_t - number of bytes written to transport
// -----------------------------------------------------------------------------
extern uint16_t NPITLUART_writeTransport(uint16_t len);
// -----------------------------------------------------------------------------
//! \brief This routine stops any pending reads
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITLUART_stopTransfer(void);
// -----------------------------------------------------------------------------
//! \brief This routine is called from the application context when REM RDY
//! is de-asserted
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPITLUART_handleRemRdyEvent(void);
#ifdef __cplusplus
}
#endif
#endif /* NPI_TL_UART_H */

View File

@@ -0,0 +1,140 @@
//******************************************************************************
//! \file npi_util.h
//! \brief NPI Utilities
//
// Revised: $Date: 2015-01-28 17:22:05 -0800 (Wed, 28 Jan 2015) $
// Revision: $Revision: 42106 $
//
// 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_UTIL_H
#define NPI_UTIL_H
#ifdef __cplusplus
extern "C"
{
#endif
// ****************************************************************************
// includes
// ****************************************************************************
#ifdef USE_ICALL
#include "ICall.h"
#else
#include <stdlib.h>
#endif //USE_ICALL
#include <ti/sysbios/knl/Queue.h>
#include <ti/sysbios/knl/Semaphore.h>
// ****************************************************************************
// defines
// ****************************************************************************
#ifdef USE_ICALL
#define NPIUTIL_MALLOC(size) ICall_malloc(size)
#define NPIUTIL_FREE(pMsg) ICall_free(pMsg)
#else
#define NPIUTIL_MALLOC(size) malloc(size)
#define NPIUTIL_FREE(pMsg) free(pMsg)
#endif
// ****************************************************************************
// typedefs
// ****************************************************************************
//! \brief Keys used to enter and exit critical sections
typedef struct _npiCSKey_t
{
uint_least16_t hwikey;
uint_least16_t taskkey;
} _npiCSKey_t;
//*****************************************************************************
// globals
//*****************************************************************************
//*****************************************************************************
// function prototypes
//*****************************************************************************
// -----------------------------------------------------------------------------
//! \brief Critical section entrance. Disables Tasks and HWI
//!
//! \return _npiCSKey_t CS Key used to later exit CS
// -----------------------------------------------------------------------------
extern _npiCSKey_t NPIUtil_EnterCS(void);
// -----------------------------------------------------------------------------
//! \brief Critical section exit. Enables Tasks and HWI
//!
//! \param key key obtained with corresponding call to EnterCS()
//!
//! \return void
// -----------------------------------------------------------------------------
extern void NPIUtil_ExitCS(_npiCSKey_t key);
// -----------------------------------------------------------------------------
//! \brief Initialize an RTOS queue to hold messages to be processed.
//!
//! \param pQueue - pointer to queue instance structure.
//!
//! \return A queue handle.
// -----------------------------------------------------------------------------
extern Queue_Handle NPIUtil_constructQueue(Queue_Struct *pQueue);
// -----------------------------------------------------------------------------
//! \brief Creates a queue node and puts the node in RTOS queue.
//!
//! \param msgQueue - queue handle.
//! \param sem - thread's event processing semaphore that queue is
//! associated with.
//! \param pMsg - pointer to message to be queued
//!
//! \return TRUE if message was queued, FALSE otherwise.
// -----------------------------------------------------------------------------
extern uint8_t NPIUtil_enqueueMsg(Queue_Handle msgQueue, Semaphore_Handle sem,
uint8_t *pMsg);
// -----------------------------------------------------------------------------
//! \brief Dequeues the message from the RTOS queue.
//!
//! \param msgQueue - queue handle.
//!
//! \return pointer to dequeued message, NULL otherwise.
// -----------------------------------------------------------------------------
extern uint8_t * NPIUtil_dequeueMsg(Queue_Handle msgQueue);
#ifdef __cplusplus
}
#endif
#endif /* NPI_UTIL_H */