SCOM Serial Communication Protocol
0.5.2
|
Main API file. More...
#include "hal.h"
#include "scom_frame_queue.h"
#include "scom_ack_frame.h"
#include <stdint.h>
#include <stdbool.h>
Go to the source code of this file.
Data Structures | |
struct | SCOMFrameBuffer |
Definition of the frame buffer used by SCOM. More... | |
struct | HAL_PACKED |
SCOM version record. More... | |
struct | HAL_PACKED |
SCOM version record. More... | |
struct | SCOMACKState |
Descriptor of the ACK state. More... | |
struct | SCOMStatistics |
Descriptor of the SCOM statistics. More... | |
struct | SCOMDataLinkDesc |
SCOM Data Link descriptor. More... | |
struct | SCOMMultiFrameDesc |
Definition of multiframe descriptor structure. More... | |
Macros | |
#define | SCOM_VER_HI 0 |
#define | SCOM_VER_LO 5 |
#define | SCOM_REVISION 0 |
#define | SCOM_DECLARE_FRAME_BUFFER(name, txQueueSize, rxQueueSize) |
This macro declares a frame buffer for SCOM as a fixed pool. More... | |
#define | SCOM_DECLARE_FRAME_BUFFER_USING_HEAP(name) |
This macro declares a frame buffer for SCOM that uses heap. More... | |
#define | SCOM_DEVICE_INFO_LEN (sizeof(((SCOMIdentity *)0)->version) + sizeof(((SCOMIdentity *)0)->deviceClass) + sizeof(((SCOMIdentity *)0)->deviceUID)) |
#define | SCOM_ERR__COMMUNICATION_ERROR 1 |
#define | SCOM_ERR__INTERNAL_ERROR 2 |
#define | SCOM_ERR__DATA_TOO_LARGE 3 |
#define | SCOM_ERR__TX_OVERLOAD 4 |
#define | SCOM_ERR__SYNCHRONIZATION_ERROR 5 |
Typedefs | |
typedef OSTime(* | SCOMClockSource )(void) |
typedef struct HAL_PACKED | SCOMVersion |
SCOM version record. More... | |
typedef struct HAL_PACKED | SCOMIdentity |
Definition of a structure that identifies an SCOM device. More... | |
typedef struct SCOMDataLinkDesc | SCOMDataLinkDesc |
SCOM Data Link descriptor. More... | |
typedef SCOMDataLinkDesc * | SCOMDataLink |
typedef bool(* | SCOMFrameReceptionHandler )(SCOMDataLink scom, SCOMFrame *frame) |
typedef void(* | SCOMAckReceptionHandler )(SCOMDataLink scom, uint8_t frame_type) |
typedef void(* | SCOMServiceHandler )(SCOMDataLinkDesc *scom, SCOMFrame *frame) |
Enumerations | |
enum | SCOMReceiverState { SCOM_RX_WAIT_FOR_SOF, SCOM_RX_ACK, SCOM_RX_FRAME, SCOM_BROKEN_LINK } |
Possible receiver states. More... | |
enum | SCOMConnectionState { SCOM_CONNECTION_UNINITIALIZED = 0, SCOM_CONNECTION_OPERATIONAL = 1, SCOM_CONNECTION_UNSYNCHRONIZED = 2, SCOM_CONNECTION_BROKEN = 3 } |
Possible SCOM connection states. More... | |
enum | SCOMResult { SCOM_RESULT_OK, SCOM_ERROR = 1, SCOM_RESULT_ERROR = 1, SCOM_TX_EMPTY, SCOM_TX_FULL, SCOM_INTERNAL_ERROR, SCOM_FRAME_RECEIVED, SCOM_RECEIVER_BLOCKED, SCOM_NO_FRAME, SCOM_TX_FRAME_BUFFER_OVERRUN, SCOM_RX_FRAME_DATA_TOO_LARGE, SCOM_FRAME_NOT_IN_BUFFER, SCOM_USART_TX_BUF_ERROR, SCOM_USART_RX_BUF_ERROR, SCOM_COMMUNICATION_ERROR, SCOM_TX_INTEGRITY_ERROR, SCOM_FILTER_LIST_FULL, SCOM_FILTER_TIMEOUT, SCOM_FILTER_ERROR, SCOM_SYNCHRONIZATION_ERROR, SCOM_NO_DEVICE, SCOM_RESULT_CRC_MISMATCH } |
Main API file.
SCOM Serial communication protocol.
Definition in file scom.h.
#define SCOM_DECLARE_FRAME_BUFFER | ( | name, | |
txQueueSize, | |||
rxQueueSize | |||
) |
This macro declares a frame buffer for SCOM as a fixed pool.
This macro provides a convenient way of declaring a frame buffer to be used by SCOM.
name | name of the resulting frame buffer structure |
txQueueSize | number of frames that will be available in the transmission queue |
rxQueueSize | number of frames that will be available in the reception queue |
#define SCOM_DECLARE_FRAME_BUFFER_USING_HEAP | ( | name | ) |
#define SCOM_DEVICE_INFO_LEN (sizeof(((SCOMIdentity *)0)->version) + sizeof(((SCOMIdentity *)0)->deviceClass) + sizeof(((SCOMIdentity *)0)->deviceUID)) |
#define SCOM_REVISION 0 |
Definition at line 15 of file scom.h.
Referenced by SCOM_Init().
#define SCOM_VER_HI 0 |
Definition at line 12 of file scom.h.
Referenced by SCOM_Init().
#define SCOM_VER_LO 5 |
Definition at line 13 of file scom.h.
Referenced by SCOM_Init().
typedef void(* SCOMAckReceptionHandler)(SCOMDataLink scom, uint8_t frame_type) |
typedef OSTime(* SCOMClockSource)(void) |
typedef SCOMDataLinkDesc* SCOMDataLink |
typedef struct SCOMDataLinkDesc SCOMDataLinkDesc |
SCOM Data Link descriptor.
typedef bool(* SCOMFrameReceptionHandler)(SCOMDataLink scom, SCOMFrame *frame) |
typedef struct HAL_PACKED SCOMIdentity |
Definition of a structure that identifies an SCOM device.
typedef void(* SCOMServiceHandler)(SCOMDataLinkDesc *scom, SCOMFrame *frame) |
typedef struct HAL_PACKED SCOMVersion |
SCOM version record.
enum SCOMConnectionState |
enum SCOMReceiverState |
enum SCOMResult |
Possible SCOM function results
SCOMResult SCOM_AllocFrame | ( | SCOMDataLink | scom, |
SCOMFrame ** | framePtr | ||
) |
Allocates new frame in the internal SCOM frame buffer, to allow direct access to SCOMFrame structure and avoid unnecessary copying of data. The allocated frame can later be sent using SCOM_SendAllocatedFrame or deleted using SCOM_UnlockFrame.
scom | SCOM handle |
framePtr | pointer to variable, where a pointer to an allocated SCOMFrame structure will be stored |
SCOM_RESULT_OK | on success - the framePtr holds a valid pointer to SCOMFrame |
SCOM_TX_FULL | if there is no more free space to allocate frame in the frame buffer |
SCOM_ERROR | if other error occurred |
Definition at line 706 of file scom.c.
References SCOMFrameQueueItem::frame, SCOMDataLinkDesc::frameBuffer, SCOM_ERROR, SCOM_RESULT_OK, SCOM_TX_FULL, SCOMFrameQueue_Lock(), and SCOMFrameBuffer::txFrameQueue.
SCOMDataLink SCOM_Create | ( | void | ) |
Creates an instance of SCOM descriptor.
Definition at line 146 of file scom.c.
Referenced by SCOM_ScanAndRun().
SCOMFrameBuffer* SCOM_CreateFrameBuffer | ( | size_t | rxBuffSize, |
size_t | txBuffSize | ||
) |
Allocates memory (using heap), creates and initializes a frame buffer for SCOM, of a given size. This frame buffer can than be used in a call to SCOM_Init. Alternatively, if heap memory allocation is discouraged, macro SCOM_DECLARE_FRAME_BUFFER can be used to declare the frame buffer statically.
rxBuffSize | number of incoming frames that can fit into the frame buffer |
txBuffSize | number of outgoing frames that can fit into the frame buffer |
Definition of a SCOM frame queue.
Frame pool items
First item in the queue
Pool size (number of managed items)
Pool access mutex
Definition at line 174 of file scom.c.
References SCOMFrameQueue::pool, SCOMFrameBuffer::rxFrameQueue, and SCOMFrameBuffer::txFrameQueue.
Referenced by SCOM_ScanAndRun().
SCOMResult SCOM_Deinit | ( | SCOMDataLink | scom | ) |
Deinitializes the SCOM protocol.
scom | SCOM descriptor |
void SCOM_Destroy | ( | SCOMDataLinkDesc *const | scom | ) |
Destroys an instance of SCOM descriptor.
scom | SCOM descriptor |
Definition at line 161 of file scom.c.
Referenced by SCOM_ScanAndRun().
void SCOM_DestroyFrameBuffer | ( | SCOMFrameBuffer * | frameBuffer | ) |
Destroys the frame buffer, previously created with a call to SCOM_CreateFrameBuffer.
frameBuffer | frame buffer to destroy |
SCOMResult SCOM_DisableConnectivityCheck | ( | SCOMDataLink | scom | ) |
Disable periodical connectivity check.
scom | SCOM descriptor |
SCOMResult SCOM_EnableConnectivityCheck | ( | SCOMDataLink | scom, |
uint32_t | checkPeriod | ||
) |
Enables periodical connectivity check. This forces the SCOM to send additional PING frames if needed to ensure, that a frame is exchanged at least once in a check period.
scom | SCOM descriptor |
checkPeriod | check period |
SCOMConnectionState SCOM_GetConnectionState | ( | const SCOMDataLinkDesc *const | scom | ) |
Checks SCOM connection state.
scom | SCOM descriptor |
SCOM_CONNECTION_UNINITIALIZED | SCOM connection is not initialized |
SCOM_CONNECTION_OPERATIONAL | connection is operational |
SCOM_CONNECTION_UNSYNCHRONIZED | connection lost synchronization |
SCOM_CONNECTION_BROKEN | connection was broken |
Definition at line 461 of file scom.c.
References SCOMDataLinkDesc::accessGuard, SCOMDataLinkDesc::connectionState, SCOM_ACCESS_GUARD_TIMEOUT, SCOM_CONNECTION_UNINITIALIZED, and SCOM_RESULT_ERROR.
IODevice SCOM_GetIODevice | ( | const SCOMDataLinkDesc *const | scom | ) |
Gets the IODevice associated with SCOM.
scom | SCOM descriptor |
Definition at line 482 of file scom.c.
References SCOMDataLinkDesc::iodevice.
SCOMFrame* SCOM_GetReceivedFrame | ( | SCOMDataLink | scom | ) |
Gets the oldest received frame that is waiting in the reception queue. The caller is responsible for deleting the frame once it is not needed anymore, through a call to SCOM_UnlockFrame.
scom | SCOM handle |
Definition at line 1065 of file scom.c.
References SCOMFrameQueueItem::frame, SCOMDataLinkDesc::frameBuffer, SCOMFrameBuffer::rxFrameQueue, and SCOMFrameQueue_GetFirstInQueue().
Referenced by SCOM_FilterProc().
SCOMStatistics SCOM_GetStatistics | ( | const SCOMDataLinkDesc *const | scom | ) |
Gets current SCOM statistics record.
scom | SCOM handle |
Definition at line 1109 of file scom.c.
References SCOMDataLinkDesc::accessGuard, SCOM_ACCESS_GUARD_TIMEOUT, and SCOMDataLinkDesc::stats.
SCOMResult SCOM_Init | ( | SCOMDataLink | scom, |
IODevice | iodevice, | ||
SCOMFrameBuffer * | frameBuffer, | ||
SCOMClockSource | clockSource, | ||
uint32_t | ackTimeout, | ||
uint32_t | deviceClass, | ||
uint8_t * | deviceUID, | ||
uint8_t | numberOfServices, | ||
uint8_t * | serviceIDs | ||
) |
Initializes the SCOM protocol on top of the provided IODevice object.
scom | SCOM descriptor |
iodevice | IODevice object used as a hardware interface for SCOM |
frameBuffer | pointer to a frame buffer structure (see SCOM_DECLARE_FRAME_BUFFER) |
clockSource | function returning current time |
ackTimeout | time used for detecting timeout in ACK reception |
deviceClass | class of the SCOM device |
deviceUID | unique identifier of the SCOM device |
numberOfServices | number of standard services that will be supported by the protocol - must be less or equal to SCOM_MAX_SERVICES |
serviceIDs | array of service identifiers (size equals to numberOfServices) |
Definition at line 230 of file scom.c.
References SCOMDataLinkDesc::accessGuard, SCOMDataLinkDesc::clockSource, SCOMDataLinkDesc::connectionState, SCOMDataLinkDesc::connectivityCheckIncommingCounter, SCOMDataLinkDesc::connectivityCheckOutgoingCounter, SCOMDataLinkDesc::connectivityCheckPeriod, HAL_PACKED::deviceClass, HAL_PACKED::deviceUID, SCOMACKState::frame, SCOMDataLinkDesc::frameBeingTransmitted, SCOMDataLinkDesc::frameBuffer, SCOMStatistics::framesReceived, SCOMStatistics::framesSent, SCOMDataLinkDesc::id, SCOMDataLinkDesc::iodevice, SCOMDataLinkDesc::lastConnectivityCheckTime, SCOMDataLinkDesc::lastFrameNumber, SCOMDataLinkDesc::multiCounter, SCOMStatistics::retransmissionsReceived, SCOMStatistics::retransmissionsSent, HAL_PACKED::revision, SCOMDataLinkDesc::rxAck, SCOMFrameBuffer::rxFrameQueue, SCOMDataLinkDesc::rxState, SCOM_ACK_SOF_CHARACTER, SCOM_CONNECTION_OPERATIONAL, SCOM_ERROR, SCOM_MAX_FRAME_FILTERS, SCOM_MAX_SERVICES, SCOM_RESULT_OK, SCOM_REVISION, SCOM_RX_WAIT_FOR_SOF, SCOM_VER_HI, SCOM_VER_LO, SCOMFrameQueue_Init(), SCOMDataLinkDesc::serviceCount, HAL_PACKED::soack, SCOMDataLinkDesc::stats, HAL_PACKED::sync, SCOMDataLinkDesc::timeout, SCOMDataLinkDesc::txCounter, SCOMFrameBuffer::txFrameQueue, HAL_PACKED::verHi, HAL_PACKED::verLo, and HAL_PACKED::version.
Referenced by SCOM_InitAsMonitor(), and SCOM_ScanAndRun().
SCOMResult SCOM_InitAsMonitor | ( | SCOMDataLink | scom, |
IODevice | iodevice, | ||
SCOMFrameBuffer * | frameBuffer, | ||
SCOMClockSource | clockSource, | ||
uint32_t | ackTimeout | ||
) |
Initializes the SCOM protocol on top of the provided IODevice object but as a protocol monitor only.
scom | SCOM descriptor |
iodevice | IODevice object used as a hardware interface for SCOM |
frameBuffer | pointer to a frame buffer structure (see SCOM_DECLARE_FRAME_BUFFER) |
clockSource | function returning current time |
ackTimeout | time used for detecting timeout in ACK reception |
Definition at line 363 of file scom.c.
References SCOMDataLinkDesc::monitorMode, SCOM_Init(), and SCOM_RESULT_OK.
bool SCOM_IsBusy | ( | SCOMDataLink | scom | ) |
Checks if SCOM is in the middle of some sending or receiving process.
scom | SCOM handle |
Definition at line 1044 of file scom.c.
References SCOMDataLinkDesc::frameBeingTransmitted, SCOMDataLinkDesc::frameBuffer, SCOM_FRAME_EMPTY, SCOM_FRAME_TX_SENT, SCOMFrameQueue_GetFirstInQueue(), SCOMFrameQueueItem::state, and SCOMFrameBuffer::txFrameQueue.
SCOMResult SCOM_Proc | ( | SCOMDataLink | scom | ) |
Implements the SCOM data link layer procedures. Must be called periodically (for ex. in an OS task).
scom | SCOM handle |
SCOM_RESULT_OK | on success |
SCOM_COMMUNICATION_ERROR | if a communication error was detected |
SCOM_SYNCHRONIZATION_ERROR | if link was desynchronized |
SCOM_ERROR | if other error occurred |
Definition at line 859 of file scom.c.
References SCOMDataLinkDesc::accessGuard, SCOMDataLinkDesc::clockSource, SCOMDataLinkDesc::connectionState, HAL_PACKED::crc, SCOMFrameQueueItem::frame, SCOMACKState::frame, SCOMDataLinkDesc::frameBeingReceived, SCOMDataLinkDesc::frameBeingTransmitted, SCOMDataLinkDesc::frameBuffer, SCOMStatistics::framesReceived, SCOMStatistics::framesSent, SCOMDataLinkDesc::iodevice, SCOMDataLinkDesc::lastConnectivityCheckTime, SCOMDataLinkDesc::receptionTime, SCOMStatistics::retransmissionsReceived, SCOMStatistics::retransmissionsSent, SCOMDataLinkDesc::rxAck, SCOMDataLinkDesc::rxState, SCOM_ACCESS_GUARD_TIMEOUT, SCOM_ACK_SOF_CHARACTER, SCOM_COMMUNICATION_ERROR, SCOM_CONNECTION_BROKEN, SCOM_CONNECTION_OPERATIONAL, SCOM_CONNECTION_UNSYNCHRONIZED, SCOM_ERROR, SCOM_FRAME_TX_READY_FOR_SEND, SCOM_RESULT_OK, SCOM_RX_ACK, SCOM_RX_FRAME, SCOM_RX_WAIT_FOR_SOF, SCOM_SOF_CHARACTER, SCOM_SYNCHRONIZATION_ERROR, SCOMAckFrame_CalculateCRC(), SCOMAckFrame_Initialize(), SCOMAckFrame_IsValidAck(), SCOMFrame_IsAcknowledged(), SCOMFrame_SetFrameNumber(), SCOMFrameQueue_GetFirstInQueue(), SCOMFrameQueue_Unlock(), SCOMDataLinkDesc::sendTime, SCOMFrameQueueItem::state, SCOMACKState::state, SCOMDataLinkDesc::stats, SCOMDataLinkDesc::timeout, SCOMDataLinkDesc::txAck, SCOMFrameBuffer::txFrameQueue, and HAL_PACKED::type.
void SCOM_ResetStatistics | ( | SCOMDataLink | scom | ) |
Resets SCOM statistics.
scom | SCOM handle |
SCOMResult SCOM_RunProcessingThread | ( | SCOMDataLink | scom | ) |
Creates and starts the thread that periodically calls the SCOM_Proc function, that actually runs the protocol engine.
scom | SCOM descriptor |
SCOMResult SCOM_SendAllocatedFrame | ( | SCOMDataLink | scom, |
SCOMFrame * | frame | ||
) |
Schedules transmission of a frame, that was previously allocated with SCOM_AllocFrame. The frame should have already these properties set: type, priority, dataSize. After being sent, the frame is automatically deleted (unlocked) - there is no need to explicitly call SCOM_UnlockFrame.
scom | SCOM handle |
frame | frame previously allocated with SCOM_AllocFrame |
SCOM_RESULT_OK | if the frame transmission was scheduled successfully |
SCOM_FRAME_NOT_IN_BUFFER | if the frame is not part of the SCOM frame buffer |
SCOM_ERROR | if other error occurred |
Definition at line 735 of file scom.c.
References SCOMDataLinkDesc::frameBuffer, HAL_PACKED::null, SCOM_ERROR, SCOM_FRAME_NOT_IN_BUFFER, SCOM_FRAME_TX_READY_FOR_SEND, SCOM_RESULT_OK, SCOM_SOF_CHARACTER, SCOMFrameQueue_GetItemByFrame(), SCOMFrameQueue_Insert(), HAL_PACKED::sof, SCOMFrameQueueItem::state, and SCOMFrameBuffer::txFrameQueue.
SCOMResult SCOM_SendAllocatedFrameWithoutACK | ( | SCOMDataLink | scom, |
SCOMFrame * | frame | ||
) |
Schedules transmission of a frame, that was previously allocated with SCOM_AllocFrame. The frame should have already these properties set: type, priority, dataSize. After being sent, the frame is automatically deleted (unlocked) - there is no need to explicitly call SCOM_UnlockFrame.
scom | SCOM handle |
frame | frame previously allocated with SCOM_AllocFrame |
SCOM_RESULT_OK | if the frame transmission was scheduled successfully |
SCOM_FRAME_NOT_IN_BUFFER | if the frame is not part of the SCOM frame buffer |
SCOM_ERROR | if other error occurred |
Definition at line 766 of file scom.c.
References SCOMDataLinkDesc::frameBuffer, HAL_PACKED::null, SCOM_ERROR, SCOM_FRAME_NOT_IN_BUFFER, SCOM_FRAME_TX_READY_FOR_SEND, SCOM_RESULT_OK, SCOM_SOF_CHARACTER, SCOMFrame_SetAcknowledgement(), SCOMFrameQueue_GetItemByFrame(), SCOMFrameQueue_Insert(), HAL_PACKED::sof, SCOMFrameQueueItem::state, and SCOMFrameBuffer::txFrameQueue.
SCOMResult SCOM_SendAllocatedMultiFrame | ( | SCOMDataLink | scom, |
SCOMFrame * | frame, | ||
SCOMMultiFrameDesc * | multiFrameDesc | ||
) |
Schedules transmission of a mulitframe, that was previously allocated with SCOM_AllocFrame. The frame should have already these properties set: type, priority, dataSize. After being sent, the frame is automatically deleted (unlocked) - there is no need to explicitly call SCOM_UnlockFrame.
scom | SCOM handle |
frame | frame previously allocated with SCOM_AllocFrame |
multiFrameDesc | pointer to a multiframe descriptor, that holds information about a multiframe sending process |
SCOM_RESULT_OK | if the frame transmission was scheduled successfully |
SCOM_FRAME_NOT_IN_BUFFER | if the frame is not part of the SCOM frame buffer |
SCOM_ERROR | if other error occurred |
Definition at line 650 of file scom.c.
References HAL_PACKED::ctrl, SCOMDataLinkDesc::frameBuffer, SCOMMultiFrameDesc::multi_id, SCOMDataLinkDesc::multiCounter, HAL_PACKED::multiframe, HAL_PACKED::null, HAL_PACKED::payload, SCOMMultiFrameDesc::progress, SCOM_ERROR, SCOM_FRAME_CTRL_MULTI_ID_MASK, SCOM_FRAME_NOT_IN_BUFFER, SCOM_FRAME_TX_READY_FOR_SEND, SCOM_RESULT_OK, SCOM_SOF_CHARACTER, SCOMFrameQueue_GetItemByFrame(), SCOMFrameQueue_Insert(), HAL_PACKED::size, HAL_PACKED::sof, SCOMFrameQueueItem::state, and SCOMFrameBuffer::txFrameQueue.
SCOMResult SCOM_SendFrame | ( | SCOMDataLink | scom, |
uint8_t | framePriority, | ||
uint8_t | frameType, | ||
const void * | frameData, | ||
uint8_t | frameDataSize | ||
) |
Schedules the frame transmission. The frame is copied (along with all the data) to the internal SCOM buffer. If there is no activity on the hardware interface then the frame will be sent at the next call to SCOM_Proc. However if there are other frames (older or with higher priority) the frame will wait for it's turn. This function may be called asynchronously with other SCOM functions and from ISRs.
scom | SCOM handle |
framePriority | priority of a frame |
frameType | type of frame |
frameData | data associated with the frame or NULL if there is no data |
frameDataSize | size of data to be associated with frame |
SCOMResult SCOM_SendFrameWithoutAck | ( | SCOMDataLink | scom, |
uint8_t | framePriority, | ||
uint8_t | frameType, | ||
const void * | frameData, | ||
uint8_t | frameDataSize | ||
) |
WARNING: THIS FUNCTION SENDS THE FRAME WITHOUT ACKNOWLEDGEMENT. NO RETRANSMISSION WILL BE HANDLED.
Schedules the frame transmission. The frame is copied (along with all the data) to the internal SCOM buffer. If there is no activity on the hardware interface then the frame will be sent at the next call to SCOM_Proc. However if there are other frames (older or with higher priority) the frame will wait for it's turn. This function may be called asynchronously with other SCOM functions and from ISRs.
scom | SCOM handle |
framePriority | priority of a frame |
frameType | type of frame |
frameData | data associated with the frame or NULL if there is no data |
frameDataSize | size of data to be associated with frame |
Definition at line 530 of file scom.c.
References HAL_PACKED::ctrl, SCOMFrameQueueItem::frame, SCOMDataLinkDesc::frameBuffer, HAL_PACKED::null, HAL_PACKED::payload, SCOM_ERROR, SCOM_FRAME_TX_READY_FOR_SEND, SCOM_RESULT_OK, SCOM_SOF_CHARACTER, SCOM_TX_FRAME_BUFFER_OVERRUN, SCOMFrame_SetAcknowledgement(), SCOMFrame_SetPriority(), SCOMFrameQueue_Insert(), SCOMFrameQueue_Lock(), HAL_PACKED::singleframe, HAL_PACKED::size, HAL_PACKED::sof, SCOMFrameQueueItem::state, SCOMFrameBuffer::txFrameQueue, and HAL_PACKED::type.
Referenced by SCOM_WaitForDevice().
SCOMResult SCOM_SendMultiFrame | ( | SCOMDataLink | scom, |
uint8_t | framePriority, | ||
uint8_t | frameType, | ||
const void * | frameData, | ||
uint32_t | frameDataSize, | ||
SCOMMultiFrameDesc * | multiFrameDesc | ||
) |
Schedules sending of another part of multi-frame packet. The resulting frame is copied (along with all the data) to the internal SCOM buffer, just like in the case of a standard SCOM frame.
scom | SCOM handle |
framePriority | priority of a frame |
frameType | type of frame |
frameData | data associated with the frame or NULL if there is no data |
frameDataSize | total size of data to send in multi-frame packet |
multiFrameDesc | pointer to a SCOMMultiFrameDesc structure where the information about multi-frame sending progress will be stored - used to enable iterative sending of multi-frames. |
Definition at line 574 of file scom.c.
References HAL_PACKED::ctrl, SCOMFrameQueueItem::frame, SCOMDataLinkDesc::frameBuffer, SCOMMultiFrameDesc::multi_id, SCOMDataLinkDesc::multiCounter, HAL_PACKED::multiframe, HAL_PACKED::null, HAL_PACKED::payload, SCOMMultiFrameDesc::progress, SCOM_ERROR, SCOM_FRAME_CTRL_MULTI_ID_MASK, SCOM_FRAME_TX_READY_FOR_SEND, SCOM_RESULT_OK, SCOM_SOF_CHARACTER, SCOM_TX_FRAME_BUFFER_OVERRUN, SCOMFrame_SetPriority(), SCOMFrameQueue_Insert(), SCOMFrameQueue_Lock(), HAL_PACKED::size, HAL_PACKED::sof, SCOMFrameQueueItem::state, SCOMFrameBuffer::txFrameQueue, and HAL_PACKED::type.
SCOMResult SCOM_SetAckReceptionHandlerFunc | ( | SCOMDataLink | scom, |
SCOMAckReceptionHandler | ackReceptionFunc | ||
) |
Sets the ACK reception handler. This handler is a function, that will be called by the SCOM each time an ACK is received.
scom | SCOM handle |
ackReceptionFunc | pointer to the handler function |
SCOMResult SCOM_SetFrameReceptionHandlerFunc | ( | SCOMDataLink | scom, |
SCOMFrameReceptionHandler | frameReceptionFunc | ||
) |
Sets the frame reception handler. This handler is a function, that will be called by the SCOM each time a frame is received. The handler just reacts on the frame, it does not send.
scom | SCOM handle |
frameReceptionFunc | pointer to the handler function |
SCOMResult SCOM_SetServiceHandler | ( | SCOMDataLink | scom, |
uint8_t | serviceID, | ||
SCOMServiceHandler | serviceHandlerFunc | ||
) |
Sets the service frame reception handler. This handler is a function that will be called by the SCOM each time a service frame with the matching serviceID is received. Note however, that all the serviceIDs that should be handled need to be defined during the call to SCOM_Init .
scom | SCOM handle |
serviceID | serviceID |
serviceHandlerFunc | pointer to the handler function |
Definition at line 841 of file scom.c.
References SCOM_MAX_SERVICES, SCOM_RESULT_ERROR, and SCOM_RESULT_OK.
void SCOM_StopProcessingThread | ( | SCOMDataLink | scom | ) |
Starts the thread, previously started with SCOM_RunProcessingThread.
scom | SCOM descriptor |
Definition at line 420 of file scom.c.
References SCOMDataLinkDesc::procTask.
Referenced by SCOM_ScanAndRun().
void SCOM_UnlockFrame | ( | SCOMDataLink | scom, |
SCOMFrame * | frame | ||
) |
Deletes the frame that was either received through a call to SCOM_GetReceivedFrame or was allocated using SCOM_AllocFrame, but was not sent using SCOM_SendAllocatedFrame.
scom | SCOM handle |
frame | frame to delete |
Definition at line 1086 of file scom.c.
References SCOMDataLinkDesc::frameBuffer, SCOMFrameBuffer::rxFrameQueue, SCOMFrameQueue_GetItemByFrame(), SCOMFrameQueue_Unlock(), and SCOMFrameBuffer::txFrameQueue.
Referenced by SCOM_FilterProc().