SEcube
SEcube Open Source Library - Host
Data Structures | Macros | Typedefs | Functions
L0.h File Reference

This file contains L0 functions and structures. More...

#include "se3_common.h"
#include "se3comm.h"
#include "crc16.h"

Go to the source code of this file.

Data Structures

struct  se3_device_info_
 SEcube Device Information structure. More...
 
struct  se3_device_
 SEcube Device structure. More...
 
struct  se3_disco_it_
 Discovery iterator. More...
 

Macros

#define SE3_NBLOCKS   (SE3_COMM_N-1)
 
#define SE3_TIMEOUT   (10000)
 
#define SE3_RES_SIZE_HEADER   (32)
 
#define SE3_SIZE_PAYLOAD_MAX   ((SE3_COMM_BLOCK * SE3_NBLOCKS) - SE3_REQ_SIZE_HEADER - (SE3_COMM_BLOCK * SE3_REQDATA_SIZE_HEADER))
 

Typedefs

typedef struct se3_device_info_ se3_device_info
 SEcube Device Information structure.
 
typedef struct se3_device_ se3_device
 SEcube Device structure.
 
typedef struct se3_disco_it_ se3_disco_it
 Discovery iterator.
 

Functions

uint16_t L0_TXRX (se3_device *device, uint16_t req_cmd, uint16_t req_cmdflags, uint16_t req_len, const uint8_t *req_data, uint16_t *resp_status, uint16_t *resp_len, uint8_t *resp_data)
 Main function for communicating with SEcube device. More...
 
uint16_t L0_echo (se3_device *device, const uint8_t *data_in, uint16_t data_in_len, uint8_t *data_out)
 Echo service. More...
 
uint16_t L0_factoryinit (se3_device *device, const uint8_t *serialno)
 Initialise SEcube device. More...
 
uint16_t L0_open (se3_device *dev, se3_device_info *dev_info, uint32_t timeout)
 Open SEcube device. More...
 
void L0_close (se3_device *dev)
 Close SEcube device. More...
 
bool L0_discover_serialno (uint8_t *serialno, se3_device_info *device)
 Discover Serial Number information. More...
 
void L0_discover_init (se3_disco_it *it)
 Initialise discovery iterator. More...
 
bool L0_discover_next (se3_disco_it *it)
 Increment discovery iterator. More...
 

Detailed Description

This file contains L0 functions and structures.

Function Documentation

void L0_close ( se3_device dev)

Close SEcube device.

Parameters
[in]devpointer to SEcube device structure
Returns
Error code or SE3_OK
void L0_discover_init ( se3_disco_it it)

Initialise discovery iterator.

Parameters
[in]ititerator
Returns
Error code or SE3_OK
bool L0_discover_next ( se3_disco_it it)

Increment discovery iterator.

Parameters
[in]ititerator
Returns
Error code or SE3_OK

Details

bool L0_discover_serialno ( uint8_t *  serialno,
se3_device_info device 
)

Discover Serial Number information.

Parameters
[in]serialnoSerial Number of SEcube device
[in]devicepointer to SEcube device structure
Returns
Error code or SE3_OK
uint16_t L0_echo ( se3_device device,
const uint8_t *  data_in,
uint16_t  data_in_len,
uint8_t *  data_out 
)

Echo service.

Parameters
[in]devicepointer to SEcube device structure
[in]data_inData to be sent
[in]data_in_lenLength of input data
[in]data_outData to be sent
Returns
Error code or SE3_OK

Details

uint16_t L0_factoryinit ( se3_device device,
const uint8_t *  serialno 
)

Initialise SEcube device.

Parameters
[in]devicepointer to SEcube device structure
[in]serialnoSerial Number to be set on SEcube device
Returns
Error code or SE3_OK

Before using the SEcube device, this function must be called. It can be used just once-

uint16_t L0_open ( se3_device dev,
se3_device_info dev_info,
uint32_t  timeout 
)

Open SEcube device.

Parameters
[in]devpointer to SEcube device structure
[in]dev_infoDevice Information structure
[in]timeouttimeout in ms
Returns
Error code or SE3_OK
uint16_t L0_TXRX ( se3_device device,
uint16_t  req_cmd,
uint16_t  req_cmdflags,
uint16_t  req_len,
const uint8_t *  req_data,
uint16_t *  resp_status,
uint16_t *  resp_len,
uint8_t *  resp_data 
)

Main function for communicating with SEcube device.

Parameters
[in]devicepointer to SEcube device structure
[in]req_cmdCommand to be executed
[in]req_cmdflagsFlag options for the command
[in]req_lenLength of the request
[in]req_dataarray containing the request
[in]resp_statusResponse status (received response or not)
[in]resp_lenLength of the response
[in]resp_dataarray containing the response
Returns
Error code or SE3_OK

The function receive payload data from upper levels; segment the data and write it to the device.

Parameters
resp_lenin: maximum size of resp_data, out: effective size of resp_data