sx_trng_config Struct

C

struct sx_trng_config {
    /** FIFO level below which the module leaves the idle state to refill the FIFO
     * 
     * In numbers of 128-bit blocks.
     * 
     * Set to 0 to use default.
     */
    unsigned int wakeup_level;
    
    /** Number of clock cycles to wait before sampling data from the noise source
     * 
     * Set to 0 to use default.
     */
    unsigned int init_wait;
    
    /** Number of clock cycles to wait before stopping the rings after the FIFO is full.
     * 
     * Set to 0 to use default.
     */
    unsigned int off_time_delay;
    
    /** Clock divider for the frequency at which the outputs of the rings are sampled.
     * 
     * Set to 0 to sample at APB interface clock frequency.
     */
    unsigned int sample_clock_div;
};

Description

Configuration parameters for the TRNG

SX_TRNG_INIT

C

typedef int (*FUNC_SX_TRNG_INIT)(struct sx_trng *ctx, const struct sx_trng_config *config);
#define SX_TRNG_INIT                              ((FUNC_SX_TRNG_INIT)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_TRNG_INIT)))

Description

TRNG Initialization

Parameters

ParamDescription
ctxTRNG context to be used in other operations
configpointer to optional configuration. NULL to use default

Returns

SX_OK SX_ERR_INCOMPATIBLE_HW

SX_TRNG_GET

C

typedef int (*FUNC_SX_TRNG_GET)(struct sx_trng *ctx, char *dst, size_t size);
#define SX_TRNG_GET                                    ((FUNC_SX_TRNG_GET)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_TRNG_GET)))

Description

Get random bytes

When this function returns ::SX_OK, \p size random bytes have been written to the \p dst memory location. If not enough random bytes are available, the function does not write any data to \p dst and returns ::SX_ERR_INSUFFICIENT.

Parameters

ParamDescription
ctxTRNG context to be used in other operations
dstDestination in memory to copy \p size bytes to
sizelength in bytes

Returns

SX_OK SX_ERR_INSUFFICIENT SX_ERR_HARDWARE_FAILURE

sx_trng Struct

C

struct sx_trng {
    struct sx_regs *regs;
    int conditioning_key_set;
    uint32_t control;
    uint32_t key[4];
    uint32_t wakeup_lvl;
    uint32_t swoff_timer;
    uint32_t clk_divider;
    uint32_t init_wait_cnt;
};

Description

Internal state of the TRNG hardware All members should be considered INTERNAL and may not be accessed directly.