![]() |
ISF
2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
|
ISF Command Interpreter (CI) stream protocol header file. More...
#include "isf.h"
Go to the source code of this file.
Macros | |
#define | CI_STATUS_STREAM_SPECIFIC_STATUS (0xBF) |
These are the CI stream protocol errors provided to the host. More... | |
#define | CI_STATUS_STREAM_SPECIFIC_ERROR (0x40) |
#define | STREAM_CRC_ENABLED (1) |
Stream control: enable/disable CRC generation/checking. More... | |
#define | STREAM_CRC_DISABLED (0) |
Functions | |
struct | __attribute__ ((__packed__)) _ci_stream_element |
This structure contains the stream element information. More... | |
isf_status_t | isf_ci_stream_create (uint8 aStreamID, uint8 aNumElements, uint8 *apTriggerMask, ci_stream_element_t *apElementList) |
This API creates a stream. More... | |
isf_status_t | isf_ci_stream_update_data (uint8 aDataSetID, uint16 aLength, uint16 aOffset, uint8 *apSrc) |
This API updates the data of a dataset. More... | |
isf_status_t | isf_ci_stream_delete (uint8 aStreamID) |
This API deletes the given stream ID. More... | |
isf_status_t | isf_ci_stream_reset_trigger (uint8 aStreamID) |
This API resets the trigger bits of the the given stream ID. More... | |
ci_stream_config_t * | isf_ci_stream_get_config (uint8 aStreamID) |
This API gets the stream configuration of the specified stream ID. More... | |
isf_status_t | isf_ci_stream_get_trigger (uint8 aStreamID, uint8 *apTrigger) |
This API returns the trigger state of the given stream ID. More... | |
uint8 | isf_ci_stream_get_num_streams (void) |
This API returns the number of streams. More... | |
ci_stream_config_t * | isf_ci_stream_get_first (void) |
This API returns the configuration of the first stream in the linked list. More... | |
ci_stream_config_t * | isf_ci_stream_get_next (void) |
This API returns the configuration of the next stream in the linked list. More... | |
void | isf_ci_stream_set_CRC (boolean acrcEnable) |
This API sets the cyclic redundancy check (CRC) code generation to the requested state. More... | |
isf_status_t | ci_stream_init (uint8 aprotocolID, void *apInitData) |
This is a CI stream protocol intialization callback function pointer. More... | |
isf_status_t | ci_protocol_CB_stream (uint32 anumBytes, uint8 *apSrc, uint32 *apnumDestBytes, uint8 *apDest) |
This is a CI stream protocol callback function pointer. More... | |
void | isf_ci_stream_set_stream_enable () |
This API enables data stream. More... | |
void | isf_ci_stream_set_stream_disable () |
This API disables data stream. More... | |
Variables | |
ci_stream_element_t | |
ci_stream_config_t | |
ISF Command Interpreter (CI) stream protocol header file.
Definition in file isf_ci_stream.h.
#define CI_STATUS_STREAM_SPECIFIC_ERROR (0x40) |
Definition at line 93 of file isf_ci_stream.h.
#define CI_STATUS_STREAM_SPECIFIC_STATUS (0xBF) |
These are the CI stream protocol errors provided to the host.
Any errors identified by the stream protocol are returned to the host. These errors may be passed back to the host from the application. There are 7 bits allocated to contain error status resulting in 128 possible different status values.
Bit6 of the status byte is used to indicate error condition. If bit6 = 1, then the value in bit0-5 contains the specific error condition. If bit6 = 0, then the value in bit0-5 contains the specific status.
Definition at line 92 of file isf_ci_stream.h.
#define STREAM_CRC_DISABLED (0) |
Definition at line 178 of file isf_ci_stream.h.
Referenced by ci_protocol_CB_stream(), and isf_ci_stream_set_CRC().
#define STREAM_CRC_ENABLED (1) |
Stream control: enable/disable CRC generation/checking.
Definition at line 177 of file isf_ci_stream.h.
Referenced by ci_protocol_CB_stream(), isf_ci_stream_set_CRC(), and isf_ci_stream_update_data().
CI host stream command.
The host indicates which command the stream protocol runs. ci_commands_stream_enum is used to identify this command. The maximum number of possible commands is 128 represented by 7 bits.
Definition at line 29 of file isf_ci_stream.h.
Definition at line 95 of file isf_ci_stream.h.
struct __attribute__ | ( | (__packed__) | ) |
This structure contains the stream element information.
This structure contains the stream configuration information.
The stream element structure contains information of a dataset that includes an ID, the byte length, and the byte offset. Stream elements are part of the stream configuration structure.
The stream configuration structure contains information about the stream that includes the stream ID, number of elements, trigger masks, and element list.
Dataset ID
Length in bytes of the dataset
Offset n bytes of the dataset
Stream ID
Number of elements
Buffer containing the trigger mask bytes
Buffer containing the element list
Definition at line 190 of file isf_ci_stream.h.
isf_status_t ci_protocol_CB_stream | ( | uint32 | anumBytes, |
uint8 * | apSrc, | ||
uint32 * | apnumDestBytes, | ||
uint8 * | apDest | ||
) |
This is a CI stream protocol callback function pointer.
A callback that implements the CI stream protocol. This callback is invoked if a packet is received with a protocol ID matching the ID that was assigned to this protocol during initialization.
[in] | anumBytes | The number of bytes that the host has sent to the protocol. The data resides in the apSrc buffer. |
[in] | apSrc | Pointer to the received data from the host. |
[in,out] | apnumDestBytes | As an input, this parameter specifies maxinum size of the destination buffer apDest. As an output this parameter specifies the actual size of the number of bytes used in the buffer apDest. |
[out] | apDest | Pointer to the processed data. |
The | callback function returns the protocol ID value of the next protocol to be invoked. If no more protocols are to be called, the callback function returns a zero to notify the CI to sends the destination buffer to the host. |
Definition at line 1010 of file ci_protocol_stream.c.
isf_status_t ci_stream_init | ( | uint8 | aprotocolID, |
void * | apInitData | ||
) |
This is a CI stream protocol intialization callback function pointer.
A callback that implements the initialization for the CI stream protocol.
[in] | aprotocolID | The protocol ID assigned to the protocol. The protocol initialization function is required to save the ID and include the ID in data packets sent back to the host. |
[in] | apInitData | Pointer to the user defined data. |
ISF_SUCCESS | The initialization callback completed successfully. |
ISF_ERR_LIB_INIT | The initialization callback failed to initialize. |
Definition at line 85 of file ci_protocol_stream.c.
isf_status_t isf_ci_stream_create | ( | uint8 | aStreamID, |
uint8 | aNumElements, | ||
uint8 * | apTriggerMask, | ||
ci_stream_element_t * | apElementList | ||
) |
This API creates a stream.
This API creates a stream with the given parameters. It dynamically allocates memory to create a buffer to store all the information required to operation the stream.
[in] | aStreamID | Stream ID value. |
[in] | aNumElements | The number of elements or datasets in the stream. |
[in] | apTriggerMask | Pointer to the trigger mask buffer. This buffer consists if an array of byte(s) with each bit corresponding a dataset in the element list. Bit 0 of the first trigger byte corresponds to the first dataset in apElementList. Bit 1 of the first trigger byte corresponds to the second dataset in apElementList and so on. Each trigger byte can respresent up to 8 datasets in apElementList. |
During the creation process, the data from this buffer is copied over to the stream being created.
[in] | apElementList | Pointer to a buffer containing a list of datasets. Each dataset is defined in the list as follows: |
Offset Size Description 0 1 byte Dataset ID 1 2 bytes Length, msb first 3 2 bytes Offset, msb first
During the creation process, the data from this buffer is copied over to the stream being created.
ISF_SUCCESS | The stream was created successfully. |
CI_STATUS_STREAM_ERR_NULL_POINTER | The apTriggerMask and/or the apElementList pointers are NULL. |
CI_STATUS_STREAM_ERR_INVALID_NUM_PARM | The number of parameter bytes provided to create the stream is not sufficient. |
CI_STATUS_STREAM_ERR_NUMELEMENTS_INVALID | The aNumElements value is zero. |
CI_STATUS_STREAM_ERR_STREAMID_EXISTS | The aStreamID value specifies a stream ID that already exists. |
CI_STATUS_STREAM_ERR_OUT_OF_MEMORY | The system is out of memory and the stream cannot be created. |
Definition at line 243 of file ci_protocol_stream.c.
References CI_ALLOC_MEM_ZERO, CI_COPY_MEM, CI_FREE_MEM, CI_STATUS_STREAM_DATA_UPDATE, CI_STATUS_STREAM_ERR_NULL_POINTER, CI_STATUS_STREAM_ERR_NUMELEMENTS_INVALID, CI_STATUS_STREAM_ERR_OUT_OF_MEMORY, CI_STATUS_STREAM_ERR_STREAMID_EXISTS, ci_stream_config_t, ci_stream_element_t, ci_stream_get_num_element_bytes(), ci_stream_get_num_trig_bytes(), ci_stream_instance_t, ISF_SUCCESS, STREAM_COCO_BIT_MASK, STREAM_CRC_BYTESIZE, STREAM_PROTOCOL_OUTPUTPACKET_INDEX_COCO_STAT, STREAM_PROTOCOL_OUTPUTPACKET_INDEX_LENGTH_LSB, STREAM_PROTOCOL_OUTPUTPACKET_INDEX_LENGTH_MSB, STREAM_PROTOCOL_OUTPUTPACKET_INDEX_PROTOCOLID, STREAM_PROTOCOL_OUTPUTPACKET_INDEX_STREAMID, and TRUE.
Referenced by ci_protocol_CB_stream(), and rli_ci_app_callback().
isf_status_t isf_ci_stream_delete | ( | uint8 | aStreamID | ) |
This API deletes the given stream ID.
This API deletes the given stream ID. Its memory is deallocated and the stream linked list is reordered.
[in] | aStreamID | Stream ID value of the stream to delete. |
ISF_SUCCESS | The stream ID was found and the stream deleted. |
CI_STATUS_STREAM_ERR_STREAM_NOEXISTS | The aStreamID value specifies a stream ID that does not exists. |
Definition at line 168 of file ci_protocol_stream.c.
References CI_FREE_MEM, CI_STATUS_STREAM_ERR_STREAM_NOEXISTS, CI_STATUS_STREAM_ERR_STREAMID_NOEXISTS, and ISF_SUCCESS.
Referenced by ci_protocol_CB_stream(), and rli_ci_app_callback().
ci_stream_config_t* isf_ci_stream_get_config | ( | uint8 | aStreamID | ) |
This API gets the stream configuration of the specified stream ID.
[in] | aStreamID | Stream ID value of the configuration to retrieve. |
ci_stream_config_t* isf_ci_stream_get_first | ( | void | ) |
This API returns the configuration of the first stream in the linked list.
This API returns a pointer to the configuration of the first stream in the linked list. If no stream exists, NULL is returned.
Definition at line 118 of file ci_protocol_stream.c.
References ci_stream_config_t.
Referenced by ci_protocol_CB_stream().
ci_stream_config_t* isf_ci_stream_get_next | ( | void | ) |
This API returns the configuration of the next stream in the linked list.
This API returns a pointer to the configuration of the next stream in the linked list. The stream returned is the next stream in the list from the previous isf_ci_stream_get_first() or isf_ci_stream_get_next() call. If no stream exists, NULL is returned.
Definition at line 133 of file ci_protocol_stream.c.
References ci_stream_config_t.
Referenced by ci_protocol_CB_stream().
uint8 isf_ci_stream_get_num_streams | ( | void | ) |
This API returns the number of streams.
This API returns the number of streams that currently exists.
Definition at line 639 of file ci_protocol_stream.c.
Referenced by ci_protocol_CB_stream().
isf_status_t isf_ci_stream_get_trigger | ( | uint8 | aStreamID, |
uint8 * | apTrigger | ||
) |
This API returns the trigger state of the given stream ID.
This API returns the trigger state bytes of the given stream ID. The trigger state is copied to the trigger buffer provided by the caller.
[in] | aStreamID | Stream ID value of the stream to get the trigger state. |
[in,out] | apTrigger | Pointer to the trigger byte array. The trigger state of the stream is copied to this byte array. This value is NULL if the stream ID does not exists. The caller must provide an array large enough to hold all of the trigger bytes. |
Each bit in the trigger byte corresponds to a dataset.
ISF_SUCCESS | The stream ID was found and its trigger state reset to the trigger mask. |
CI_STATUS_STREAM_ERR | apTrigger is NULL. |
CI_STATUS_STREAM_ERR_STREAM_NOEXISTS | The aStreamID value specifies a stream ID that does not exists. |
Definition at line 656 of file ci_protocol_stream.c.
References CI_STATUS_STREAM_ERR, CI_STATUS_STREAM_ERR_STREAMID_NOEXISTS, ci_stream_get_num_trig_bytes(), and ISF_SUCCESS.
isf_status_t isf_ci_stream_reset_trigger | ( | uint8 | aStreamID | ) |
This API resets the trigger bits of the the given stream ID.
This API resets the trigger state of the given stream ID. The trigger state is set to the trigger mask that was provided during stream creation.
aStreamID | Stream ID value of the stream to reset the trigger state. |
ISF_SUCCESS | The stream ID was found and its trigger state reset to the trigger mask. |
CI_STATUS_STREAM_ERR_STREAM_NOEXISTS | The aStreamID value specifies a stream ID that does not exists. |
Definition at line 693 of file ci_protocol_stream.c.
References CI_STATUS_STREAM_ERR_STREAMID_NOEXISTS, ci_stream_get_num_trig_bytes(), and ISF_SUCCESS.
Referenced by ci_protocol_CB_stream().
void isf_ci_stream_set_CRC | ( | boolean | acrcEnable | ) |
This API sets the cyclic redundancy check (CRC) code generation to the requested state.
This API is used to enable or disable the CRC state. If enabled, CRC code is generated and sent as part of any data packets going to the host for the stream protocol. Also, any packet received from the host is expected to have a CRC bytes that are checked against the received data. If disabled, no CRC data is generated for packets going to the host and no CRC check is performed for packets received from the host.
The CRC used by the stream protocol is the CCITT CRC16. This method uses two bytes (16-bit). If CRC bytes are generated for a data packet destined for the host, the bytes are placed at the end of the packet but before the end marker byte (0x7E). The same CRC byte placement is expected of data packets from the host to the stream protocol.
If CRC is enabled by the host using the CI_CMD_STREAM_ENABLE_CRC command, the response packet to the host for this command will have the CRC bytes as part of the packet.
If CRC is disabled by the host using the CI_CMD_STREAM_DISABLE_CRC command, the response packet to the host for this command will NOT have the CRC bytes as part of the packet.
[in] | acrcEnable | Requested state of CRC. STREAM_CRC_ENABLED to enable CRC generation and checking. STREAM_CRC_DISABLED to disabke CRC generation and checking. |
Definition at line 725 of file ci_protocol_stream.c.
References ci_stream_ctrl_reg1_t::Bits, ci_stream_ctrl_reg1_t::enable_crc, STREAM_CRC_DISABLED, STREAM_CRC_ENABLED, and ci_stream_regs_t::StreamCtrlReg1.
Referenced by ci_protocol_CB_stream().
void isf_ci_stream_set_stream_disable | ( | ) |
This API disables data stream.
This API is used to enable data stream state. Data streaming is enabled by setting gStreamReg.StreamCtrlReg1.Bits.enable_stream_data = STREAM_PROTOCOL_DATA_DISABLED.
[in] | None |
Definition at line 1833 of file ci_protocol_stream.c.
References ci_stream_ctrl_reg1_t::Bits, ci_stream_ctrl_reg1_t::enable_stream_data, STREAM_PROTOCOL_DATA_DISABLED, and ci_stream_regs_t::StreamCtrlReg1.
void isf_ci_stream_set_stream_enable | ( | ) |
This API enables data stream.
This API is used to enable data stream state. Data streaming is enabled by setting gStreamReg.StreamCtrlReg1.Bits.enable_stream_data = STREAM_PROTOCOL_DATA_ENABLED.
[in] | None |
Definition at line 1821 of file ci_protocol_stream.c.
References ci_stream_ctrl_reg1_t::Bits, ci_stream_ctrl_reg1_t::enable_stream_data, STREAM_PROTOCOL_DATA_ENABLED, and ci_stream_regs_t::StreamCtrlReg1.
isf_status_t isf_ci_stream_update_data | ( | uint8 | aDataSetID, |
uint16 | aLength, | ||
uint16 | aOffset, | ||
uint8 * | apSrc | ||
) |
This API updates the data of a dataset.
This API updates the data of the given dataset ID. The data is updated under two conditions that must exist:
If a dataset in any streams meet these conditions, the overlapped region of the dataset data is updated and the trigger state bit associated with the dataset ID is cleared. If all trigger state bits of the stream is cleared, the data is sent to the host if stream update is enabled.
[in] | aDataSetID | ID of the dataset to update |
[in] | aLength | The byte length of data to update. |
[in] | aOffset | The offset of the data to update. It references the offset of the data buffer that the application makes available to the host. |
[in] | apSrc | Pointer to the source of the data to perform the update. If the dataset ID matches and the data region overlaps, the source data is copied to the stream buffer. |
ISF_SUCCESS | Dataset(s) data were updated. No data was sent to the host because not all trigger state bits are cleared. |
CI_STATUS_STREAM_ERR_NULL_POINTER | The apSrc is NULL. |
CI_STATUS_STREAM_ERR_DATASET_LENGTH_INVALID | The aLength value is zero. |
CI_STATUS_STREAM_ERR_SENDDATA_TO_HOST | An error was encountered in sending data to the host. |
CI_STATUS_STREAM_DATASETID_NOTUSED | The dataset ID was not found in any streams. No data was updated. |
CI_STATUS_STREAM_DATA_UPDATE | An update data packet was sent to the host. |
Definition at line 449 of file ci_protocol_stream.c.
References ci_stream_ctrl_reg1_t::Bits, ccitt_crc16_cal(), CI_COPY_MEM, ci_send_packet(), CI_STATUS_STREAM_DATA_UPDATE, CI_STATUS_STREAM_DATASETID_NOTUSED, CI_STATUS_STREAM_ERR_DATASET_LENGTH_INVALID, CI_STATUS_STREAM_ERR_NULL_POINTER, CI_STATUS_STREAM_ERR_SENDDATA_TO_HOST, CI_STREAM_DATASET_ID_BYTESIZE, ci_stream_element_t, ci_stream_get_num_trig_bytes(), CI_STREAM_OUTPUTPACKET_LENGTH_BYTESIZE, CI_STREAM_OUTPUTPACKET_STREAMID_BYTESIZE, CI_STREAM_PROTOCOL_ID_BYTESIZE, ci_stream_ctrl_reg1_t::enable_crc, ci_stream_ctrl_reg1_t::enable_stream_data, FALSE, ISF_SUCCESS, STREAM_CRC_BYTESIZE, STREAM_CRC_ENABLED, STREAM_PROTOCOL_CMD_STATUS_BYTESIZE, STREAM_PROTOCOL_DATA_ENABLED, STREAM_PROTOCOL_OUTPUTPACKET_INDEX_LENGTH_LSB, STREAM_PROTOCOL_OUTPUTPACKET_INDEX_LENGTH_MSB, ci_stream_regs_t::StreamCtrlReg1, and TRUE.
Referenced by App1_MainTask(), BasicApp1_MainTask(), and rli_PeriodicCallback().
ci_stream_config_t |
Definition at line 229 of file isf_ci_stream.h.
Referenced by __attribute__(), ci_protocol_CB_stream(), isf_ci_stream_create(), isf_ci_stream_get(), isf_ci_stream_get_first(), and isf_ci_stream_get_next().
ci_stream_element_t |
Definition at line 201 of file isf_ci_stream.h.
Referenced by ci_protocol_CB_stream(), ci_stream_get_num_element_bytes(), isf_ci_stream_create(), isf_ci_stream_update_data(), and rli_ci_app_callback().