Renesas PTX1xxR IoT-Reader API Version 7.3.1
Renesas Software Stack for IoT-Reader Applications
Topics | Data Structures | Macros | Typedefs | Enumerations | Functions
PTX NSC Hardware Abstraction Layer (HAL)
Collaboration diagram for PTX NSC Hardware Abstraction Layer (HAL):

Topics

 HAL Interface Diversity
 

Data Structures

struct  ptxHal_InitParam
 Initialization Parameters Structure. More...
 

Macros

#define PTX_HAL_MAX_TX_LEN   256
 
#define PTX_HAL_READ_TIMEOUT   500
 
#define PTX_HAL_WRITE_TIMEOUT   500
 

Typedefs

typedef enum ptxHal_InterfaceType ptxHal_InterfaceType_t
 
typedef struct ptxHal_InitParam ptxHal_InitParam_t
 Initialization Parameters Structure.
 
typedef struct ptxHalpptxHal_t
 Pointer to main HAL component.
 
typedef ptxStatus_t(* pptxHal_Cancel_t) (pptxHal_t halCtx)
 Cancel any operation on the HAL.
 
typedef ptxStatus_t(* pptxHal_TRx_t) (pptxHal_t halCtx, uint8_t *txBuf[], size_t txLen[], size_t numBuffers, uint8_t *rxBuf, size_t *rxLen)
 Send content of multiple buffers via the Interface, adding SOF if required, receive response.
 

Enumerations

enum  ptxHal_InterfaceType {
  ptxHal_InterfaceType_None , ptxHal_InterfaceType_I2C , ptxHal_InterfaceType_SPI , ptxHal_InterfaceType_UART ,
  ptxHal_InterfaceType_AAR_I2C , ptxHal_InterfaceType_AAR_SPI , ptxHal_InterfaceType_LPC , ptxHal_InterfaceType_USB ,
  ptxHal_InterfaceType_FTDI_SPI , ptxHal_InterfaceType_FTDI_I2C , ptxHal_InterfaceType_FTDI_UART , ptxHal_InterfaceType_MAX
}
 

Functions

ptxStatus_t ptxHal_AllocOpen (struct ptxHal *halCtx, struct ptxHal_InitParam *initParam)
 Initialize the HAL.
 
ptxStatus_t ptxHal_CloseDeAlloc (struct ptxHal *halCtx)
 Close the HAL.
 
ptxHal_InterfaceType_t ptxHal_GetActiveIfType (struct ptxHal *halCtx)
 Get the active HAL interface type.
 
ptxStatus_t ptxHal_Cancel (struct ptxHal *halCtx)
 Cancel any operation on the HAL.
 
ptxStatus_t ptxHal_ClearCancel (struct ptxHal *halCtx)
 Clear Cancel Flag .
 
ptxStatus_t ptxHal_SetTimeout (struct ptxHal *halCtx, uint32_t msTimeout)
 Set the timeout attribute for the interface device.
 
ptxStatus_t ptxHal_SetSpeed (struct ptxHal *halCtx, uint32_t bdSpeed)
 Set the communication interface speed.
 
ptxStatus_t ptxHal_SetBusAddress (struct ptxHal *halCtx, uint16_t busAddress)
 Set the bus address attribute for the I2C interface device.
 
ptxStatus_t ptxHal_HandshakeManual (struct ptxHal *halCtx, uint8_t enableHS)
 Set the state of handshake lines, if available.
 
ptxStatus_t ptxHal_SetFlowCtrlState (struct ptxHal *halCtx, uint8_t enableFc)
 Enable/disable flow control mode for the Uart interface device.
 
ptxStatus_t ptxHal_SetI2C_NoStopFlag (struct ptxHal *halCtx)
 Set I2C Not Stop Condition flag.
 
ptxStatus_t ptxHal_ClearI2C_NoStopFlag (struct ptxHal *halCtx)
 Clear I2C Not Stop Condition flag.
 
ptxStatus_t ptxHal_TRx (struct ptxHal *halCtx, uint8_t *txBuf[], size_t txLen[], size_t numBuffers, uint8_t *rxBuf, size_t *rxLen)
 Send content of multiple buffers via the Interface, adding SOF if required, receive response.
 
ptxStatus_t ptxHal_WaitForInterrupt (struct ptxHal *halCtx)
 Wait for Interrupt.
 
ptxStatus_t ptxHal_SetKeepNssActive (struct ptxHal *halCtx)
 Keeps NSS Active after a Trx Operation (SPI specific).
 
ptxStatus_t ptxHal_ClearKeepNssActive (struct ptxHal *halCtx)
 Clear Keeps NSS Active after a Trx Operation (SPI specific).
 

Bit-coded values, interface specific.

Put the values (using logical OR for more than one value to be set) into the CommParam member of ptxHal_InitParam_t.

Serial:
Bit(s)      7       6       5       4       3       2       1       0
Meaning                                                     |STOPBIT|
#define PTX_HAL_COMMPARAM_SERIAL_STOPBIT_MASK   3 /* */
 
#define PTX_HAL_COMMPARAM_SERIAL_ONESTOPBIT   0 /* */
 
#define PTX_HAL_COMMPARAM_SERIAL_ONE5STOPBITS   1 /* */
 
#define PTX_HAL_COMMPARAM_SERIAL_TWOSTOPBITS   2 /* */
 
#define PTX_HAL_COMMPARAM_SERIAL_INIT_SPEED   (115200UL) /* */
 

Detailed Description

Macro Definition Documentation

◆ PTX_HAL_COMMPARAM_SERIAL_INIT_SPEED

#define PTX_HAL_COMMPARAM_SERIAL_INIT_SPEED   (115200UL) /* */

Serial interface initial speed.

◆ PTX_HAL_COMMPARAM_SERIAL_ONE5STOPBITS

#define PTX_HAL_COMMPARAM_SERIAL_ONE5STOPBITS   1 /* */

Serial interface specific parameter, 1.5 stop bits:

◆ PTX_HAL_COMMPARAM_SERIAL_ONESTOPBIT

#define PTX_HAL_COMMPARAM_SERIAL_ONESTOPBIT   0 /* */

Serial interface specific parameter, one stop bit:

◆ PTX_HAL_COMMPARAM_SERIAL_STOPBIT_MASK

#define PTX_HAL_COMMPARAM_SERIAL_STOPBIT_MASK   3 /* */

Mask for the stop bits. Internally used.

◆ PTX_HAL_COMMPARAM_SERIAL_TWOSTOPBITS

#define PTX_HAL_COMMPARAM_SERIAL_TWOSTOPBITS   2 /* */

Serial interface specific parameter, two stop bit:

◆ PTX_HAL_MAX_TX_LEN

#define PTX_HAL_MAX_TX_LEN   256

HAL max transfer length.

◆ PTX_HAL_READ_TIMEOUT

#define PTX_HAL_READ_TIMEOUT   500

Hal read timeout in ms.

◆ PTX_HAL_WRITE_TIMEOUT

#define PTX_HAL_WRITE_TIMEOUT   500

Hal write timeout in ms.

Typedef Documentation

◆ pptxHal_Cancel_t

typedef ptxStatus_t(* pptxHal_Cancel_t) (pptxHal_t halCtx)

Cancel any operation on the HAL.

Cancels pending operations in the HAL but returns immediately. The function does not wait for the canceled operation to finish.

Parameters
[in]halCtxPointer to an allocated and initialized structure.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ pptxHal_TRx_t

typedef ptxStatus_t(* pptxHal_TRx_t) (pptxHal_t halCtx, uint8_t *txBuf[], size_t txLen[], size_t numBuffers, uint8_t *rxBuf, size_t *rxLen)

Send content of multiple buffers via the Interface, adding SOF if required, receive response.

Sends the content of multiple buffers and prepends SOF, if set in the transmission parameter field of the component. In an implementation-specific way, the function concatenates sending of content of multiple buffers. The implementation is hardware-specific, but the interface is such that the underlying code can be tweaked for maximum performance (e.g. Gather-DMA on some embedded systems, of just multi-send on others).
The receive function returns the bytes received during I/O. Some interfaces have additional requirements like having to keep CS asserted or to apply repeated a start condition. The Exchange function allows for requirements like these.

Parameters
[in]halCtxPointer to an initialized component structure.
[in]txBufArray of pointers to buffers with data to write.
[in]txLenArray of Number of bytes in the respective transmit buffer.
[in]numBuffersNumber of buffers whose data to transmit.
[in]rxBufPointer to a buffer that is going to receive the data.
[in,out]rxLenPointer to a variable that provides and receives the length information. Invoke the function with the maximum number of bytes to read which is the size of the rx buffer. When returning the function sets the referenced variable to the number of actually received bytes.
Note
If txBuf or txLen are NULL, then only receive operation is performed (if rx buffer and length are not NULL). For transmitting: individual buffers may be NULL or the length of individual buffers may be zero. It is required however that the total number of bytes to transfer is greater than zero and within the range the length field of the NSC-specific frame can transfer.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_InterfaceType_t

Hal Interface Types

Enumeration Type Documentation

◆ ptxHal_InterfaceType

Hal Interface Types

Enumerator
ptxHal_InterfaceType_None 

None.

ptxHal_InterfaceType_I2C 

System Native I2C;

ptxHal_InterfaceType_SPI 

System Native SPI;

ptxHal_InterfaceType_UART 

System Native UART;

ptxHal_InterfaceType_AAR_I2C 

Aardvark I2C;

ptxHal_InterfaceType_AAR_SPI 

Aardvark SPI;

ptxHal_InterfaceType_LPC 

LPC

ptxHal_InterfaceType_USB 

LPC, native firmware. Not a host setting

ptxHal_InterfaceType_FTDI_SPI 

FTDI (FT4232H) SPI;

ptxHal_InterfaceType_FTDI_I2C 

FTDI (FT4232H) I2C;

ptxHal_InterfaceType_FTDI_UART 

FTDI (FT4232H) UART;

Function Documentation

◆ ptxHal_AllocOpen()

ptxStatus_t ptxHal_AllocOpen ( struct ptxHal * halCtx,
struct ptxHal_InitParam * initParam )

Initialize the HAL.

Allocates and initializes all specific objects for a defined interface.

Parameters
[in]halCtxPointer to an allocated but non-initialized structure.
[in]initParamPointer to a temporary structure (stack-allocated) with initialization values.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t

◆ ptxHal_Cancel()

ptxStatus_t ptxHal_Cancel ( struct ptxHal * halCtx)

Cancel any operation on the HAL.

Cancels pending operations in the HAL but returns immediately. The function does not wait for the canceled operation to finish.

Parameters
[in]halCtxPointer to an allocated and initialized structure.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_ClearCancel()

ptxStatus_t ptxHal_ClearCancel ( struct ptxHal * halCtx)

Clear Cancel Flag .

In case Cancel is issues before a call to RX the flag still can cause the following receive operation to be canceled. This function clears the cancel flag.

Parameters
[in]halCtxPointer to an allocated and initialized structure.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_ClearI2C_NoStopFlag()

ptxStatus_t ptxHal_ClearI2C_NoStopFlag ( struct ptxHal * halCtx)

Clear I2C Not Stop Condition flag.

Parameters
[in]halCtxPointer to an allocated and initialized structure.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_ClearKeepNssActive()

ptxStatus_t ptxHal_ClearKeepNssActive ( struct ptxHal * halCtx)

Clear Keeps NSS Active after a Trx Operation (SPI specific).

Parameters
[in]halCtxPointer to an allocated and initialized structure.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_CloseDeAlloc()

ptxStatus_t ptxHal_CloseDeAlloc ( struct ptxHal * halCtx)

Close the HAL.

De-init and de-allocate all specific objects for a defined interface.

Parameters
[in]halCtxPointer to an allocated and initialized structure.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_GetActiveIfType()

ptxHal_InterfaceType_t ptxHal_GetActiveIfType ( struct ptxHal * halCtx)

Get the active HAL interface type.

Parameters
[in]halCtxPointer to an allocated and initialized structure.
Returns
Active interface type.

◆ ptxHal_HandshakeManual()

ptxStatus_t ptxHal_HandshakeManual ( struct ptxHal * halCtx,
uint8_t enableHS )

Set the state of handshake lines, if available.

Set the state of the handshake lines. Caution: This is only possible when auto control-flow is OFF (ptxHal_SetFlowCtrlState).

Parameters
[in]halCtxPointer to an allocated and initialized structure.
[in]enableHSWith 0 the lines is set to inactive; set to 1 in order to set control lines to active state.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_SetBusAddress()

ptxStatus_t ptxHal_SetBusAddress ( struct ptxHal * halCtx,
uint16_t busAddress )

Set the bus address attribute for the I2C interface device.

Control the interface. Set I2C address of the NFC chip.

Parameters
[in]halCtxPointer to an allocated and initialized structure.
[in]busAddressAddress of slave for interface.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_SetFlowCtrlState()

ptxStatus_t ptxHal_SetFlowCtrlState ( struct ptxHal * halCtx,
uint8_t enableFc )

Enable/disable flow control mode for the Uart interface device.

Control the interface. Set flow control to active or inactive. Initial state is inactive.

Parameters
[in]halCtxPointer to an allocated and initialized structure.
[in]enableFcWith 0 the mode is set to inactive; set to 1 in order to enable the mode.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_SetI2C_NoStopFlag()

ptxStatus_t ptxHal_SetI2C_NoStopFlag ( struct ptxHal * halCtx)

Set I2C Not Stop Condition flag.

Parameters
[in]halCtxPointer to an allocated and initialized structure.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_SetKeepNssActive()

ptxStatus_t ptxHal_SetKeepNssActive ( struct ptxHal * halCtx)

Keeps NSS Active after a Trx Operation (SPI specific).

Parameters
[in]halCtxPointer to an allocated and initialized structure.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_SetSpeed()

ptxStatus_t ptxHal_SetSpeed ( struct ptxHal * halCtx,
uint32_t bdSpeed )

Set the communication interface speed.

Control the interface. Set speed.

Parameters
[in]halCtxPointer to an allocated and initialized structure.
[in]bdSpeedSpeed, in baud-per-second.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_SetTimeout()

ptxStatus_t ptxHal_SetTimeout ( struct ptxHal * halCtx,
uint32_t msTimeout )

Set the timeout attribute for the interface device.

Control the interface. Set timeout parameter.

Parameters
[in]halCtxPointer to an allocated and initialized structure.
[in]msTimeoutTimeout interval, in ms.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_TRx()

ptxStatus_t ptxHal_TRx ( struct ptxHal * halCtx,
uint8_t * txBuf[],
size_t txLen[],
size_t numBuffers,
uint8_t * rxBuf,
size_t * rxLen )

Send content of multiple buffers via the Interface, adding SOF if required, receive response.

Sends the content of multiple buffers and prepends SOF, if set in the transmission parameter field of the component. In an implementation-specific way, the function concatenates sending of content of multiple buffers. The implementation is hardware-specific, but the interface is such that the underlying code can be tweaked for maximum performance (e.g. Gather-DMA on some embedded systems, of just multi-send on others).
The receive function returns the bytes received during I/O. Some interfaces have additional requirements like having to keep CS asserted or to apply repeated a start condition. The Exchange function allows for requirements like these.

Parameters
[in]halCtxPointer to an initialized component structure.
[in]txBufArray of pointers to buffers with data to write.
[in]txLenArray of Number of bytes in the respective transmit buffer.
[in]numBuffersNumber of buffers whose data to transmit.
[in]rxBufPointer to a buffer that is going to receive the data.
[in,out]rxLenPointer to a variable that provides and receives the length information. Invoke the function with the maximum number of bytes to read which is the size of the rx buffer. When returning the function sets the referenced variable to the number of actually received bytes.
Note
If txBuf or txLen are NULL, then only receive operation is performed (if rx buffer and length are not NULL). For transmitting: individual buffers may be NULL or the length of individual buffers may be zero. It is required however that the total number of bytes to transfer is greater than zero and within the range the length field of the NSC-specific frame can transfer.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxHal_WaitForInterrupt()

ptxStatus_t ptxHal_WaitForInterrupt ( struct ptxHal * halCtx)

Wait for Interrupt.

Parameters
[in]halCtxPointer to an allocated and initialized structure.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.