Renesas PTX1xxR IoT-Reader API (non-OS) Version 7.3.1
Renesas Software Stack for IoT-Reader Applications (non-OS)
Data Structures | Macros | Typedefs | Functions
PTX NSC Platform API
Collaboration diagram for PTX NSC Platform API:

Data Structures

struct  ptxPLAT_ConfigPars
 Platform-specific parameter initializers. More...
 

Macros

#define PTX_PLAT_TRX_FLAGS_I2C_RESTART_CONDITION   0x01
 Platform-specific flags parameter initializers.
 
#define PTX_PLAT_HOST_SPEED_I2C_100000   (100000UL)
 Platform-dependent I2C speeds/bitrates (Attention: Bitrates highly dependent on the target system and might require adaption!)
 
#define PTX_PLAT_HOST_SPEED_I2C_400000   (400000UL)
 
#define PTX_PLAT_HOST_SPEED_I2C_1000000   (1000000UL)
 
#define PTX_PLAT_HOST_SPEED_I2C_3400000   (3400000UL)
 
#define PTX_PLAT_HOST_SPEED_I2C_MAX   PTX_PLAT_HOST_SPEED_I2C_3400000
 
#define PTX_PLAT_HOST_SPEED_UART_9600   (9600UL)
 Platform-dependent UART speeds/bitrates (Attention: Bitrates highly dependent on the target system and might require adaption!)
 
#define PTX_PLAT_HOST_SPEED_UART_14400   (14400UL)
 
#define PTX_PLAT_HOST_SPEED_UART_19200   (19200UL)
 
#define PTX_PLAT_HOST_SPEED_UART_28800   (28800UL)
 
#define PTX_PLAT_HOST_SPEED_UART_38400   (38400UL)
 
#define PTX_PLAT_HOST_SPEED_UART_57600   (57600UL)
 
#define PTX_PLAT_HOST_SPEED_UART_115200   (115200UL)
 
#define PTX_PLAT_HOST_SPEED_UART_230400   (230400UL)
 
#define PTX_PLAT_HOST_SPEED_UART_460800   (460800UL)
 
#define PTX_PLAT_HOST_SPEED_UART_921600   (921600UL)
 
#define PTX_PLAT_HOST_SPEED_UART_1843200   (1843200UL)
 
#define PTX_PLAT_HOST_SPEED_UART_3000000   (3000000UL)
 
#define PTX_PLAT_HOST_SPEED_UART_MAX   PTX_PLAT_HOST_SPEED_UART_3000000
 
#define PTX_PLAT_HOST_DEFAULT_UART_SPEED   PTX_PLAT_HOST_SPEED_UART_115200
 
#define PTX_PLAT_HOST_SPEED_SPI_1M   (1000000UL)
 Platform-dependent SPI speeds/bitrates (Attention: Bitrates highly dependent on the target system and might require adaption!)
 
#define PTX_PLAT_HOST_SPEED_SPI_5M   (5000000UL)
 
#define PTX_PLAT_HOST_SPEED_SPI_10M   (10000000UL)
 
#define PTX_PLAT_HOST_SPEED_SPI_MAX   PTX_PLAT_HOST_SPEED_SPI_10M
 

Typedefs

typedef void(* pptxPlat_RxCallBack_t) (void *ctx)
 Callback function for IRQ triggered (asynchronously).
 
typedef void(* pptxPlat_TimerCallBack_t) (void *ctx)
 Callback function for Timer Interrupt.
 
typedef struct ptxPLAT_ConfigPars ptxPLAT_ConfigPars_t
 Platform-specific parameter initializers.
 

Functions

ptxStatus_t ptxPLAT_AllocAndInit (struct ptxPlat **plat, struct ptxPLAT_ConfigPars *initParams)
 Allocate and initialize the PLAT context.
 
ptxStatus_t ptxPLAT_Deinit (struct ptxPlat *plat)
 De-initialize the PLAT context.
 
ptxStatus_t ptxPLAT_TRx (struct ptxPlat *plat, uint8_t *txBuf[], size_t txLen[], size_t numTxBuffers, uint8_t *rxBuf[], size_t *rxLen[], size_t numRxBuffers, uint8_t flags)
 Send and receive content of multiple buffers through the physical interface to the PTX1K.
 
ptxStatus_t ptxPLAT_WaitForInterrupt (struct ptxPlat *plat)
 Wait for any kind of interrupt to be triggered on the CPU. (Blocking)
 
ptxStatus_t ptxPLAT_StartWaitForRx (struct ptxPlat *plat, pptxPlat_RxCallBack_t irqCb, void *ctxIrqCb)
 Start waiting for IRQ to be triggered.(Not-blocking)
 
ptxStatus_t ptxPLAT_StopWaitForRx (struct ptxPlat *plat)
 Stop the waiting for IRQ.
 
ptxStatus_t ptxPLAT_Sleep (struct ptxPlat *plat, uint32_t sleep_ms)
 Sleep software execution.
 
void ptxPLAT_DisableInterrupts (struct ptxPlat *plat)
 Disable Interrupts.
 
void ptxPLAT_EnableInterrupts (struct ptxPlat *plat)
 Enable Interrupts.
 
ptxStatus_t ptxPLAT_ResetChip (struct ptxPlat *plat)
 Resets PTX1K.
 
ptxStatus_t ptxPLAT_GetInitializedTimer (struct ptxPlat *plat, struct ptxPlatTimer **timer)
 Get an initialized timer.
 
ptxStatus_t ptxPLAT_TimerStart (struct ptxPlat *plat, struct ptxPlatTimer *timer, uint32_t ms, uint8_t isBlock, pptxPlat_TimerCallBack_t fnISRCb, void *ISRCxt)
 Start timer for some milliseconds.
 
ptxStatus_t ptxPLAT_TimerIsElapsed (struct ptxPlat *plat, struct ptxPlatTimer *timer, uint8_t *isElapsed)
 Get Elapse state of the timer.
 
ptxStatus_t ptxPLAT_TimerDeinit (struct ptxPlat *plat, struct ptxPlatTimer *timer)
 De initialize the timer.
 
ptxStatus_t ptxPLAT_IsRxPending (struct ptxPlat *plat, uint8_t *isRxPending)
 It checks if Rx Operation is pending from PTX100X.
 
ptxStatus_t ptxPLAT_TriggerRx (struct ptxPlat *plat)
 It triggers Rx Operation from PTX100X (If rx operation pending)
 
uint8_t ptxPLAT_CheckRxActive (struct ptxPlat *plat)
 Check if PLAT interface reception is taking place at the moment.
 

Detailed Description

Macro Definition Documentation

◆ PTX_PLAT_HOST_DEFAULT_UART_SPEED

#define PTX_PLAT_HOST_DEFAULT_UART_SPEED   PTX_PLAT_HOST_SPEED_UART_115200

UART default Speed after reset.

◆ PTX_PLAT_HOST_SPEED_I2C_100000

#define PTX_PLAT_HOST_SPEED_I2C_100000   (100000UL)

Platform-dependent I2C speeds/bitrates (Attention: Bitrates highly dependent on the target system and might require adaption!)

I2C Standard (100 kHz).

◆ PTX_PLAT_HOST_SPEED_I2C_1000000

#define PTX_PLAT_HOST_SPEED_I2C_1000000   (1000000UL)

I2C Fast-Mode-Plus (up to 1 MHz).

◆ PTX_PLAT_HOST_SPEED_I2C_3400000

#define PTX_PLAT_HOST_SPEED_I2C_3400000   (3400000UL)

I2C High-Speed-Mode (up to 3.4 MHz).

◆ PTX_PLAT_HOST_SPEED_I2C_400000

#define PTX_PLAT_HOST_SPEED_I2C_400000   (400000UL)

I2C Fast-Mode (400 kHz).

◆ PTX_PLAT_HOST_SPEED_I2C_MAX

#define PTX_PLAT_HOST_SPEED_I2C_MAX   PTX_PLAT_HOST_SPEED_I2C_3400000

I2C Max. Speed/Bitrate

◆ PTX_PLAT_HOST_SPEED_SPI_10M

#define PTX_PLAT_HOST_SPEED_SPI_10M   (10000000UL)

SPI 10 MBit/s.

◆ PTX_PLAT_HOST_SPEED_SPI_1M

#define PTX_PLAT_HOST_SPEED_SPI_1M   (1000000UL)

Platform-dependent SPI speeds/bitrates (Attention: Bitrates highly dependent on the target system and might require adaption!)

SPI 1 MBit/s.

◆ PTX_PLAT_HOST_SPEED_SPI_5M

#define PTX_PLAT_HOST_SPEED_SPI_5M   (5000000UL)

SPI 5 MBit/s.

◆ PTX_PLAT_HOST_SPEED_SPI_MAX

#define PTX_PLAT_HOST_SPEED_SPI_MAX   PTX_PLAT_HOST_SPEED_SPI_10M

SPI Max. Speed/Bitrate

◆ PTX_PLAT_HOST_SPEED_UART_115200

#define PTX_PLAT_HOST_SPEED_UART_115200   (115200UL)

UART 115200 Baud.

◆ PTX_PLAT_HOST_SPEED_UART_14400

#define PTX_PLAT_HOST_SPEED_UART_14400   (14400UL)

UART 14400 Baud.

◆ PTX_PLAT_HOST_SPEED_UART_1843200

#define PTX_PLAT_HOST_SPEED_UART_1843200   (1843200UL)

UART 1843200 Baud.

◆ PTX_PLAT_HOST_SPEED_UART_19200

#define PTX_PLAT_HOST_SPEED_UART_19200   (19200UL)

UART 19200 Baud.

◆ PTX_PLAT_HOST_SPEED_UART_230400

#define PTX_PLAT_HOST_SPEED_UART_230400   (230400UL)

UART 230400 Baud.

◆ PTX_PLAT_HOST_SPEED_UART_28800

#define PTX_PLAT_HOST_SPEED_UART_28800   (28800UL)

UART 28800 Baud.

◆ PTX_PLAT_HOST_SPEED_UART_3000000

#define PTX_PLAT_HOST_SPEED_UART_3000000   (3000000UL)

UART 3000000 Baud.

◆ PTX_PLAT_HOST_SPEED_UART_38400

#define PTX_PLAT_HOST_SPEED_UART_38400   (38400UL)

UART 38400 Baud.

◆ PTX_PLAT_HOST_SPEED_UART_460800

#define PTX_PLAT_HOST_SPEED_UART_460800   (460800UL)

UART 460800 Baud.

◆ PTX_PLAT_HOST_SPEED_UART_57600

#define PTX_PLAT_HOST_SPEED_UART_57600   (57600UL)

UART 57600 Baud.

◆ PTX_PLAT_HOST_SPEED_UART_921600

#define PTX_PLAT_HOST_SPEED_UART_921600   (921600UL)

UART 921600 Baud.

◆ PTX_PLAT_HOST_SPEED_UART_9600

#define PTX_PLAT_HOST_SPEED_UART_9600   (9600UL)

Platform-dependent UART speeds/bitrates (Attention: Bitrates highly dependent on the target system and might require adaption!)

UART 9600 Baud.

◆ PTX_PLAT_HOST_SPEED_UART_MAX

#define PTX_PLAT_HOST_SPEED_UART_MAX   PTX_PLAT_HOST_SPEED_UART_3000000

UART Max. Speed/Bitrate

◆ PTX_PLAT_TRX_FLAGS_I2C_RESTART_CONDITION

#define PTX_PLAT_TRX_FLAGS_I2C_RESTART_CONDITION   0x01

Platform-specific flags parameter initializers.

Bit 0 ....: I2C: Restart-Condition required after Write-operation or not. Bit 1 - 3.: RFU Bit 4 - 7.: Custom Flags (free to use) I2C: If set, the restart condition should be issued after the write operation.

Function Documentation

◆ ptxPLAT_AllocAndInit()

ptxStatus_t ptxPLAT_AllocAndInit ( struct ptxPlat ** plat,
struct ptxPLAT_ConfigPars * initParams )

Allocate and initialize the PLAT context.

Note
This function provides an initialized Platform Context. Allocation of software resources and configuration of HW resources for the specific CPU, shall be performed by this function.
This function shall be successfully executed before any other call to the functions in this module.
Parameters
[in,out]platPointer to pointer where the allocated and initialized platform context is going to be provided.
[in]initParamsInitializers for platform context parameters, e.g. com interface speed and flow control.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxPLAT_CheckRxActive()

uint8_t ptxPLAT_CheckRxActive ( struct ptxPlat * plat)

Check if PLAT interface reception is taking place at the moment.

Note
The function is called in message reception loop after WFI -after CPU exits Sleep mode. This is relevant for UART interface since reception is interrupt driven (every byte received in ISR) and race condition might occur while checking if message has been received. If there is Rx activity on UART, WFI does not get called anymore in that loop. For other interfaces this function call always returns 0 and CPU enters sleep mode in every iteration.
Parameters
[in]platPointer to an initialized component structure.
Returns
Rx status: 0 - no rx activity, 1 - rx activity ongoing.

◆ ptxPLAT_Deinit()

ptxStatus_t ptxPLAT_Deinit ( struct ptxPlat * plat)

De-initialize the PLAT context.

This function deallocates and de-init the resources used by the Platform Component that were previously initialized by /ref ptxPLAT_AllocAndInit.

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

◆ ptxPLAT_DisableInterrupts()

void ptxPLAT_DisableInterrupts ( struct ptxPlat * plat)

Disable Interrupts.

This is used to disable IRQs from the underlying HW-platform.

Parameters
[in]platPointer to an initialized component structure.

◆ ptxPLAT_EnableInterrupts()

void ptxPLAT_EnableInterrupts ( struct ptxPlat * plat)

Enable Interrupts.

This is used to (re-)enable IRQs from the underlying HW-platform.

Parameters
[in]platPointer to an initialized component structure.

◆ ptxPLAT_GetInitializedTimer()

ptxStatus_t ptxPLAT_GetInitializedTimer ( struct ptxPlat * plat,
struct ptxPlatTimer ** timer )

Get an initialized timer.

Note
This function is in charge of provide an available (e.g.not in use) Timer, and initialize it.
This function shall be successfully executed before any other call to the functions in this module.
Parameters
[in]platPointer to an initialized component structure.
[out]timerPointer to pointer where the allocated and initialized timer context is going to be provided.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxPLAT_IsRxPending()

ptxStatus_t ptxPLAT_IsRxPending ( struct ptxPlat * plat,
uint8_t * isRxPending )

It checks if Rx Operation is pending from PTX100X.

Parameters
[in]platPointer to an initialized component structure.
[out]isRxPendingPointer to write if rx operation is pending. ( 1 if rx operation is pending, 0 if not )
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxPLAT_ResetChip()

ptxStatus_t ptxPLAT_ResetChip ( struct ptxPlat * plat)

Resets PTX1K.

This is used to reset the PTX1K-HW via the SEN-pin (optional, if connected)

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

◆ ptxPLAT_Sleep()

ptxStatus_t ptxPLAT_Sleep ( struct ptxPlat * plat,
uint32_t sleep_ms )

Sleep software execution.

This function returns when the time provided by /ref sleep_ms has elapsed.

Parameters
[in]platPointer to an initialized component structure.
[in]sleep_msNumber of milliseconds to sleep.
Note
It si expected that this function provides less error than 5% in the range of 1 - 1000 ms /ref sleep_ms
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxPLAT_StartWaitForRx()

ptxStatus_t ptxPLAT_StartWaitForRx ( struct ptxPlat * plat,
pptxPlat_RxCallBack_t irqCb,
void * ctxIrqCb )

Start waiting for IRQ to be triggered.(Not-blocking)

This function registers a CallBack function to be called by the platform (e.g. typically from ISR) when the IRQ has been triggered by the PTX1K.

Parameters
[in]platPointer to an initialized component structure.
[in]irqCbCallback function to be called from HW (PLatform) when the IRQ is triggered by PTX1K.
[in]ctxIrqCbContext to be used as first argument when invoking the callback.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxPLAT_StopWaitForRx()

ptxStatus_t ptxPLAT_StopWaitForRx ( struct ptxPlat * plat)

Stop the waiting for IRQ.

This function stops the asynchronous wait for IRQ triggered by /ref ptxPLAT_StartWaitForIRQ.

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

◆ ptxPLAT_TimerDeinit()

ptxStatus_t ptxPLAT_TimerDeinit ( struct ptxPlat * plat,
struct ptxPlatTimer * timer )

De initialize the timer.

Note
This function shall be called once that the timer has been used. It shall : 1./ Stop the timer in case that is still in-use. 2./ Release the timer to be available by the system.
Parameters
[in]platPointer to an initialized component structure.
[in]timerPointer to an initialized timer context.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxPLAT_TimerIsElapsed()

ptxStatus_t ptxPLAT_TimerIsElapsed ( struct ptxPlat * plat,
struct ptxPlatTimer * timer,
uint8_t * isElapsed )

Get Elapse state of the timer.

Note
This function shall be called once that the timer has been started
Parameters
[in]platPointer to an initialized component structure.
[in]timerPointer to an initialized timer context.
[out]isElapsedPointer where the elapse state is going to be written.(e.g. 1 if timer is elapsed, 0 if timer is not elapsed)
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxPLAT_TimerStart()

ptxStatus_t ptxPLAT_TimerStart ( struct ptxPlat * plat,
struct ptxPlatTimer * timer,
uint32_t ms,
uint8_t isBlock,
pptxPlat_TimerCallBack_t fnISRCb,
void * ISRCxt )

Start timer for some milliseconds.

Note
This function shall be able to be used on two different ways:
   1./ It blocks and waits until the time elapses.
   2./ It does not block, It register a callback that will be called asyncrhously when the time elapses.
Parameters
[in]platPointer to an initialized component structure.
[in]timerPointer to an initialized timer context.
[in]msMilliseconds to wait.
[in]isBlockSet to 0 if the function is blocking. Set to 1 if it blocks.
[in]fnISRCbCallback function that may be used in case of not-blocking call. NULL to be provided if not-used.
[in]ISRCxtContext to be used by /ref fnISRCb. NULL to be provided if not-used.
Returns
Status, indicating whether the operation was successful. See ptxStatus_t.

◆ ptxPLAT_TriggerRx()

ptxStatus_t ptxPLAT_TriggerRx ( struct ptxPlat * plat)

It triggers Rx Operation from PTX100X (If rx operation pending)

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

◆ ptxPLAT_TRx()

ptxStatus_t ptxPLAT_TRx ( struct ptxPlat * plat,
uint8_t * txBuf[],
size_t txLen[],
size_t numTxBuffers,
uint8_t * rxBuf[],
size_t * rxLen[],
size_t numRxBuffers,
uint8_t flags )

Send and receive content of multiple buffers through the physical interface to the PTX1K.

Note
The function transmits first the transmission buffers and then receive the buffers for receiving.

Sends the content of multiple buffers. 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]platPointer 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]numTxBuffersNumber of buffers whose data to transmit.
[in,out]rxBufArray of pointers to buffers where data is going to be received.
[in,out]rxLenArray of length of /rxBuf. As input parameter capacity of the buffers and as output actual number of bytes read out.
[in]numRxBuffersNumber of buffers with data to be received.
[in]flagsGeneral purpose flags for TRx-operation (specific to used host-interface).
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.

◆ ptxPLAT_WaitForInterrupt()

ptxStatus_t ptxPLAT_WaitForInterrupt ( struct ptxPlat * plat)

Wait for any kind of interrupt to be triggered on the CPU. (Blocking)

This function is expected to be used is expected to be used by upper layers for waiting for any asynchronous event to happen

Returns
Status, indicating whether the operation was successful. See ptxStatus_t.