smartdof 2.0.0.0
Public function

Functions

void smartdof_cfg_setup (smartdof_cfg_t *cfg)
 Config Object Initialization function.
 
SMARTDOF_RETVAL smartdof_init (smartdof_t *ctx, smartdof_cfg_t *cfg)
 Initialization function.
 
uint8_t smartdof_default_cfg (smartdof_t *ctx)
 Click Default Configuration function.
 
void smartdof_i2c_write (smartdof_t *ctx, uint8_t *write_data, uint16_t n_bytes)
 Sending data bytes via I2C.
 
void smartdof_i2c_read (smartdof_t *ctx, uint8_t *read_data, uint16_t n_bytes)
 Receiving data bytes via I2C.
 
uint8_t smartdof_int_get (smartdof_t *ctx)
 Getting state of INT pin.
 
void smartdof_rst_set (smartdof_t *ctx, uint8_t pin_state)
 Setting RST pin state.
 
void smartdof_bt_set (smartdof_t *ctx, uint8_t pin_state)
 Setting BT pin state.
 
void smartdof_device_reset (smartdof_t *ctx, uint8_t boot_mode)
 Device reset.
 
float smartdof_q_point_to_float (int16_t sensor_data, uint8_t sensor_q_point)
 Q point (fixed point) value to float conversion.
 
void smartdof_send_packet (smartdof_t *ctx, uint8_t channel_number, uint16_t data_length, uint8_t *packet_data)
 Sending data packet.
 
uint8_t smartdof_receive_packet (smartdof_t *ctx, uint32_t n_cycles_timeout)
 Receiving data packet.
 
void smartdof_get_data (smartdof_t *ctx, uint8_t *data_header, uint16_t *data_length, uint8_t *data_buffer)
 Getting received data.
 
void smartdof_product_id_request (smartdof_t *ctx)
 Requesting product id.
 
uint8_t smartdof_product_id_response (smartdof_t *ctx, smartdof_pir_t *pir)
 Receiving product id response.
 
void smartdof_frs_write_request (smartdof_t *ctx, uint16_t data_length, uint16_t frs_type)
 Requesting FRS write.
 
void smartdof_frs_write_data_request (smartdof_t *ctx, uint16_t data_offset, uint32_t *data_buffer)
 Requesting FRS write data.
 
uint8_t smartdof_frs_write_response (smartdof_t *ctx, uint8_t *frs_status, uint16_t *data_offset)
 Receiving FRS write response.
 
void smartdof_frs_read_request (smartdof_t *ctx, uint16_t data_offset, uint16_t frs_type, uint16_t data_size)
 Requesting FRS read.
 
uint8_t smartdof_frs_read_response (smartdof_t *ctx, smartdof_rr_t *rr)
 Receiving FRS read response.
 
void smartdof_command_request (smartdof_t *ctx, uint8_t command_type, uint8_t *command_parameters)
 Requesting command.
 
uint8_t smartdof_command_response (smartdof_t *ctx, uint8_t *response_parameters)
 Receiving command response.
 
void smartdof_get_feature_request (smartdof_t *ctx, uint8_t feature_report_id)
 Requesting get feature request.
 
void smartdof_set_feature_command (smartdof_t *ctx, smartdof_sfc_t *sfc)
 Requesting set feature command.
 
uint8_t smartdof_get_feature_response (smartdof_t *ctx, smartdof_sfc_t *sfc)
 Receiving get feature response.
 
void smartdof_force_sensor_flush (smartdof_t *ctx, uint8_t sensor_id)
 Requesting force sensor flush.
 
uint8_t smartdof_flush_completed (smartdof_t *ctx, uint8_t *sensor_id)
 Receiving flush completed response.
 

Detailed Description

Function Documentation

◆ smartdof_bt_set()

void smartdof_bt_set ( smartdof_t * ctx,
uint8_t pin_state )

Setting BT pin state.

Parameters
ctxClick object.
pin_stateState of BT pin

@description This function sets BT pin to HIGH state if pin_state is set to 1; sets BT pin to LOW state if pin_state is set to 0

Note
BT pin sets device into BOOT mode if held to LOW (0) during device reset

◆ smartdof_cfg_setup()

void smartdof_cfg_setup ( smartdof_cfg_t * cfg)

Config Object Initialization function.

Parameters
cfgClick configuration structure.

@description This function initializes click configuration structure to init state.

Note
All used pins will be set to unconnected state.

◆ smartdof_command_request()

void smartdof_command_request ( smartdof_t * ctx,
uint8_t command_type,
uint8_t * command_parameters )

Requesting command.

Parameters
ctxClick object.
command_typeCommand type to be requested [range : 1 - 127]
command_parametersBuffer that holds command parameters [parameter interpretation is defined for each command]

@description This function sends command request report to device

Note
This function is used to ask the device to perform some special operation or report some special data that is not part of normal sensor operation

◆ smartdof_command_response()

uint8_t smartdof_command_response ( smartdof_t * ctx,
uint8_t * response_parameters )

Receiving command response.

Parameters
ctxClick object.
response_parametersBuffer that holds command response parameters
Returns
0 if no error occured during data reception
1 if error occured during reception (INT pin did not go LOW during specifiod number of cycles (n_cycles_timeout))
1 if received data length does not equal 16 bytes (not including header bytes)
1 if report id does not equal product id response report (0xF1)

@description

This function receives command response report bytes
This function than checks if it received correct report (correct data length and correct report id)
This function than parses received data and returns parsed data to user
This function is used to report the results of some special operation or some special data that is not part of normal sensor operation

◆ smartdof_default_cfg()

uint8_t smartdof_default_cfg ( smartdof_t * ctx)

Click Default Configuration function.

Parameters
ctxClick object.

@description This function executes default configuration for SmartDof click.

◆ smartdof_device_reset()

void smartdof_device_reset ( smartdof_t * ctx,
uint8_t boot_mode )

Device reset.

Parameters
ctxClick object.
boot_modeDevice boot mode (normal or dfu - fw update)

@description This function resets device and sets it into normal or boot (dfu) mode

◆ smartdof_flush_completed()

uint8_t smartdof_flush_completed ( smartdof_t * ctx,
uint8_t * sensor_id )

Receiving flush completed response.

Parameters
ctxClick object.
sensor_idReport id of the sensor whose data was flushed
Returns
0 if no error occured during data reception
1 if error occured during reception (INT pin did not go LOW during specifiod number of cycles (n_cycles_timeout))
1 if received data length does not equal 2 bytes (not including header bytes)
1 if report id does not equal product id response report (0xEF)

@description

This function receives flush completed response report bytes
This function than checks if it received correct report (correct data length and correct report id)
This function than parses received data and returns parsed data to user

◆ smartdof_force_sensor_flush()

void smartdof_force_sensor_flush ( smartdof_t * ctx,
uint8_t sensor_id )

Requesting force sensor flush.

Parameters
ctxClick object.
sensor_idReport id of the sensor whose data is to be flushed

@description This function sends force sensor flush request report to device

Note
This function is executed in order to trigger a flush of outstanding data from a given sensor (e.g. before its batch settings would require it)

◆ smartdof_frs_read_request()

void smartdof_frs_read_request ( smartdof_t * ctx,
uint16_t data_offset,
uint16_t frs_type,
uint16_t data_size )

Requesting FRS read.

Parameters
ctxClick object.
data_offsetOffset ( expressed in number of 32-bit data words) from the beginning of the FRS record
frs_typeType of FRS record to read
data_sizeNumber of 32-bit data words to read

@description This function sends FRS read request report to device; If the data size is set to zero, then the entire record beginning at the offset value (data_offset) is returned

◆ smartdof_frs_read_response()

uint8_t smartdof_frs_read_response ( smartdof_t * ctx,
smartdof_rr_t * rr )

Receiving FRS read response.

Parameters
ctxClick object.
rrClick FRS read response object.
Structure Members:
- uint8_t data_length - number of received 32-bit data words
- uint8_t read_status - status of FRS read operation
- uint16_t data_offset - offset ( expressed in number of 32-bit data words) from the beginning of the FRS record
- uint32_t data_buffer[] - buffer in which data words are to be stored
- uint16_t frs_type - FRS record type to be read
 
Returns
0 if no error occured during data reception
1 if error occured during reception (INT pin did not go LOW during specifiod number of cycles (n_cycles_timeout))
1 if received data length does not equal 16 bytes (not including header bytes)
1 if report id does not equal product id response report (0xF3)

@description

This function receives FRS read response report bytes
This function than checks if it received correct report (correct data length and correct report id)
This function than parses received data and returns parsed data to user
Once a read request has been received, the FSP3xx generates read responses until the request record or portion of a record is returned
Read status can be : 0 - no error 1, - unrecognized FRS type, 2 - busy, 3 - read record completed, 4 - offset out of range, 5 - record empty, 
                     6 - read block completed (if block size requested), 7 - read block completed and read record completed,
                     8 - device error (DFU flash memory device unavailable), 9-15 - reserved

◆ smartdof_frs_write_data_request()

void smartdof_frs_write_data_request ( smartdof_t * ctx,
uint16_t data_offset,
uint32_t * data_buffer )

Requesting FRS write data.

Parameters
ctxClick object.
data_offsetOffset (expressed in number of 32-bit data words) from the beginning of the FRS record
data_bufferTwo 32-bit words of data to be written to the FRS record

@description This function sends FRS write data request report to device

Note
This function is to be called after specifying FRS record to write to by 'smartdof_frsWriteRequest()' function

◆ smartdof_frs_write_request()

void smartdof_frs_write_request ( smartdof_t * ctx,
uint16_t data_length,
uint16_t frs_type )

Requesting FRS write.

Parameters
ctxClick object.
data_lengthLength in 32-bit words of the record to be written
frs_typeType of FRS record to be sent

@description This function is used to initiate writing FRS record, by sending product FRS write request report to device

Note
If the length of record (data_length) is set to 0 then the entire record is erased

◆ smartdof_frs_write_response()

uint8_t smartdof_frs_write_response ( smartdof_t * ctx,
uint8_t * frs_status,
uint16_t * data_offset )

Receiving FRS write response.

Parameters
ctxClick object.
frs_statusStatus of previous write operation
data_offsetOffset ( expressed in number of 32-bit data words) from the beginning of the FRS record
Returns
0 if no error occured during data reception
1 if error occured during reception (INT pin did not go LOW during specifiod number of cycles (n_cycles_timeout))
1 if received data length does not equal 4 bytes (not including header bytes)
1 if report id does not equal product id response report (0xF5)

@description

 This function receives FRS write response report bytes
 This function than checks if it received correct report (correct data length and correct report id)
 This function than parses received data and returns parsed data to user
 This function is to be called after 'smartdof_frsWriteRequest()' and 'smartdof_frsWriteDataRequest()' functions

◆ smartdof_get_data()

void smartdof_get_data ( smartdof_t * ctx,
uint8_t * data_header,
uint16_t * data_length,
uint8_t * data_buffer )

Getting received data.

Parameters
ctxClick object.
data_headerReceived header bytes
data_lengthLength of received data (not including header bytes)
data_bufferReceived data bytes

@description This function returns data received by 'smartdof_receive_packet()' function to user

Note
This function returns received header bytes, data length in bytes (not including header bytes) and data bytes to user

@recomanded Provide 'data_buffer[]' with size of 1020 bytes as that is maximum number of data bytes that can be received (not including header bytes)

◆ smartdof_get_feature_request()

void smartdof_get_feature_request ( smartdof_t * ctx,
uint8_t feature_report_id )

Requesting get feature request.

Parameters
ctxClick object.
feature_report_idReport id of the feature to be requested

@description This function sends get feature request report to device

◆ smartdof_get_feature_response()

uint8_t smartdof_get_feature_response ( smartdof_t * ctx,
smartdof_sfc_t * sfc )

Receiving get feature response.

Parameters
ctxClick object.
sfcClick set feature command object.
Structure Members:
- [out] uint8_t feature_report_id   - report id of the feature to be set
- [out] uint8_t feature_flags       - bit field that enables various device features
- [out] uint16_t change_sensitivity - 16-bit signed fixed point integer representing the value a sensor output must exceed in order to trigger
                                         another input report
- [out] uint32_t report_interval    - 32-bit unsigned integer representing the interval in microseconds between asynchronous input reports and the time
- [out] uint32_t batch_interval     - 32-bit unsigned integer controlling the maximum delay (in microseconds) between the time that a sensor is sampled
                                     that its data can be reported. The value 0 is reserved for do not delay and the value 0xFFFFFFFF is reserved
                                     for never trigger delivery on the basis of elapsed time
- [out] uint32_t sensor_specific_config - 32-bit field available for use by sensors requiring additional configuration options
Returns
0 if no error occured during data reception
1 if error occured during reception (INT pin did not go LOW during specifiod number of cycles (n_cycles_timeout))
1 if received data length does not equal 17 bytes (not including header bytes)
1 if report id does not equal product id response report (0xFC)

@description

This function receives get feature response report bytes
This function than checks if it received correct report (correct data length and correct report id)
This function than parses received data and returns parsed data to user

◆ smartdof_i2c_read()

void smartdof_i2c_read ( smartdof_t * ctx,
uint8_t * read_data,
uint16_t n_bytes )

Receiving data bytes via I2C.

Parameters
ctxClick object.
read_dataBuffer that holds data to be sent.
n_bytesNumber of bytes to send.

@description This function receives number of bytes (n_bytes) via I2C and stores those bytes into data buffer (read_data[])

◆ smartdof_i2c_write()

void smartdof_i2c_write ( smartdof_t * ctx,
uint8_t * write_data,
uint16_t n_bytes )

Sending data bytes via I2C.

Parameters
ctxClick object.
write_dataBuffer that holds data to be sent.
n_bytesNumber of bytes to send.

@description This function sends specified number of bytes (n_bytes) from data buffer (write_data[]) via I2C

◆ smartdof_init()

SMARTDOF_RETVAL smartdof_init ( smartdof_t * ctx,
smartdof_cfg_t * cfg )

Initialization function.

Parameters
ctxClick object.
cfgClick configuration structure.

@description This function initializes all necessary pins and peripherals used for this click.

◆ smartdof_int_get()

uint8_t smartdof_int_get ( smartdof_t * ctx)

Getting state of INT pin.

Parameters
ctxClick object.
Returns
0 if INT pin is in LOW state; 1 if INT pin is in HIGH state

@description This function returns INT pin state

◆ smartdof_product_id_request()

void smartdof_product_id_request ( smartdof_t * ctx)

Requesting product id.

Parameters
ctxClick object.

@description This function sends product id request report to device

◆ smartdof_product_id_response()

uint8_t smartdof_product_id_response ( smartdof_t * ctx,
smartdof_pir_t * pir )

Receiving product id response.

Parameters
ctxClick object.
pirClick product id response object.
Structure Members:
- uint8_t reset_cause - last cause of the processor reset
- uint16_t sw_version - device software version
- uint32_t sw_part_number - device software part number
- uint32_t sw_build_number - device software build number
- uint16_t sw_version_patch - device software version patch
Returns
0 if no error occured during data reception
1 if error occured during reception (INT pin did not go LOW during specifiod number of cycles (n_cycles_timeout))
1 if received data length does not equal 16 bytes (not including header bytes)
1 if report id does not equal product id response report (0xF8)

@description

- This function receives product id response report bytes
- This function than checks if it received correct report (correct data length and correct report id)
- This function than parses received data and returns parsed data to user
- Reset causes can be : 0 - Not Applicable, 1 - Power On Reset, 2 - Internal System Reset, 3 - Watchdog Timeout, 4 - External Reset, 5 - Other

◆ smartdof_q_point_to_float()

float smartdof_q_point_to_float ( int16_t sensor_data,
uint8_t sensor_q_point )

Q point (fixed point) value to float conversion.

Parameters
sensor_data
sensor_q_point
Returns
converted floating point value

@description This function converts fixed point value (sensor_data) with specified Q point (sensor_Qpoint) to floating point value (return value)

Note
Each sensor has a specific Q point for its data

@recomended Obtain Q point values via 'frs_read_request()' function

◆ smartdof_receive_packet()

uint8_t smartdof_receive_packet ( smartdof_t * ctx,
uint32_t n_cycles_timeout )

Receiving data packet.

Parameters
ctxClick object.
n_cycles_timeoutNumber of cycles to wait for INT pin to go LOW
Returns
0 if no error occured during data reception; 1 if error occured during reception ( 1 if INT pin did not go LOW during specifiod number of cycles ( n_cycles_timeout ) )

@description This function receives data packet from device

Note
This function waits for INT pin to go LOW
This function than receives 4 header bytes
This function than parses header bytes to get data length of entire packet and stores header bytes to header buffer
This function than waits for INT pin to go LOW again, receives entire packet and stores packet data to data buffer

@recomended Retrieve header bytes, data length and data bytes with 'smartdof_getData()' function

◆ smartdof_rst_set()

void smartdof_rst_set ( smartdof_t * ctx,
uint8_t pin_state )

Setting RST pin state.

Parameters
ctxClick object.
pin_stateState of RST pin

@description This function sets RST pin to HIGH state if pin_state is set to 1; sets RST pin to LOW state if pin_state is set to 0

Note
RST pin resets the device if set to LOW (0) and than to HIGH (1)

◆ smartdof_send_packet()

void smartdof_send_packet ( smartdof_t * ctx,
uint8_t channel_number,
uint16_t data_length,
uint8_t * packet_data )

Sending data packet.

Parameters
ctxClick object.
channel_numberChannel for sending data
data_lengthLength of data to be sent (in bytes, not including header bytes)
packet_dataBuffer that holds data to be sent (not including header bytes)

@description This function forms a packet of data by attaching proper header to data by setting data length (data_length + 4), channel and channel sequence number bytes

Note
This function auto increments channel sequence number every time data is sent over that channel and the maximum number of bytes to be sent (not including header bytes) is 1020

◆ smartdof_set_feature_command()

void smartdof_set_feature_command ( smartdof_t * ctx,
smartdof_sfc_t * sfc )

Requesting set feature command.

Parameters
ctxClick object.
sfcClick set feature command object.
Structure Members:
- [in] uint8_t feature_report_id   - report id of the feature to be set
- [in] uint8_t feature_flags       - bit field that enables various device features
- [in] uint16_t change_sensitivity - 16-bit signed fixed point integer representing the value a sensor output must exceed in order to trigger
                                         another input report
- [in] uint32_t report_interval    - 32-bit unsigned integer representing the interval in microseconds between asynchronous input reports and the time
- [in] uint32_t batch_interval     - 32-bit unsigned integer controlling the maximum delay (in microseconds) between the time that a sensor is sampled
                                     that its data can be reported. The value 0 is reserved for do not delay and the value 0xFFFFFFFF is reserved
                                     for never trigger delivery on the basis of elapsed time
- [in] uint32_t sensor_specific_config - 32-bit field available for use by sensors requiring additional configuration options

@description This function sends set feature request report to device