35 static LWSEM_STRUCT ci_sema_tx;
39 static uint8 protocol_max = 0;
41 static uint32 ci_max_recv_size = 0;
47 static inline void reset_rx_packet() { \
48 ci_rx_packet.mbIndex = 0; \
49 ci_rx_packet.packetSize = 0; \
53 static inline void reset_tx_packet() { \
54 ci_tx_packet.bytesLeft = 0; \
55 ci_tx_packet.pTxbuf = NULL; \
70 #ifdef DEBUG_TRACE_ENABLE
71 volatile uint32 ci_debug_rx_packet_cnt = 0;
72 volatile uint32 ci_debug_tx_packet_cnt = 0;
74 volatile uint32 ci_debug_trace[16];
75 volatile uint8 ci_debug_trace_index = 0;
79 ci_debug_trace[ci_debug_trace_index] = (
uint32)( ((
uint32)step << 24) | data24 );
81 ++ci_debug_trace_index;
82 if (ci_debug_trace_index >= 16)
83 ci_debug_trace_index = 0;
85 #endif // DEBUG_TRACE_ENABLE
90 #ifdef DEBUG_SAVE_RX_RAWCHARS
92 void debug_rx_store(
uint8 c);
93 void debug_rx_reset(
void);
96 volatile uint8 debug_rx_buf[32];
97 volatile uint32 debug_rx_index;
99 void debug_rx_store(
uint8 c)
101 debug_rx_buf[debug_rx_index] = c;
103 if (debug_rx_index >= 32)
108 void debug_rx_resetbuf(
void)
113 debug_rx_buf[debug_rx_index-1] = 0;
114 }
while(--debug_rx_index);
144 static boolean packetReceived =
FALSE;
148 bool bRxPacketerror =
FALSE;
151 #ifdef DEBUG_SAVE_RX_RAWCHARS
178 static volatile uint8 c_prev = 0;
194 else if (c_prev == 0x7D)
199 else if (c == 0x5E) {
205 bRxPacketerror =
TRUE;
212 if (ci_rx_packet.
mbIndex < ci_max_recv_size)
223 bRxPacketerror =
TRUE;
242 packetReceived =
TRUE;
251 bRxPacketerror =
TRUE;
272 bRxPacketerror =
TRUE;
279 if (bRxPacketerror ==
TRUE)
282 packetReceived =
FALSE;
284 #ifdef DEBUG_SAVE_RX_RAWCHARS
296 if (packetReceived ==
TRUE)
306 packetReceived =
FALSE;
308 #ifdef DEBUG_SAVE_RX_RAWCHARS
314 return packet_status;
346 _mqx_uint ret = !MQX_OK;
351 ret = _lwsem_wait_ticks(&ci_sema_tx, 0);
365 ci_tx_packet.
pTxbuf = apSrc;
379 while (bDone ==
FALSE)
448 #ifdef DEBUG_TRACE_ENABLE
449 ++ci_debug_tx_packet_cnt;
464 _lwsem_post(&ci_sema_tx);
507 #ifdef DEBUG_TRACE_ENABLE
508 debug_trace_set(1, ci_debug_rx_packet_cnt);
530 #ifdef DEBUG_TRACE_ENABLE
531 debug_trace_set(2, ci_debug_rx_packet_cnt);
534 #ifdef DEBUG_TRACE_ENABLE
535 debug_trace_set(3, ci_debug_rx_packet_cnt);
551 while (protocol < protocol_max)
556 if (ci_protocol_table[protocol].pProtocolCB != NULL)
590 _lwsem_create(&ci_sema_tx, 1);
601 if (ci_rx_packet.
pRxbuf == NULL)
614 if ( (ci_protocol_table[protocol_max].pProtocolCB != NULL) &&
615 (ci_protocol_table[protocol_max].pProtocolInit != NULL) &&
616 (ci_protocol_table[protocol_max].protcolID > 0)
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
#define CI_PROTOCOL_DATA_OFFSET
Define offset to where protocol data begins of the send/receive buffer that skips pass the protocol i...
ISF board support header files.
#define CI_MAX_PROTOCOL
Define the maximum allowable CI protocols.
#define ci_get_protocol_id()
Retrieve the protocol ID.
const uint8 packet_marker
unsigned char uint8
This defines uint8 as unsigned char.
ci_packet_recv_status_t
Packet received status.
ISF Command Interpreter (CI) stream protocol header file.
volatile uint32 bytesLeft
Internal transmit state.
isf_status_t(* ci_protocol_init_funcp_t)(uint8 aprotocolID, void *apInitData)
This is a CI protocol intialization callback function pointer.
isf_status_t dm_device_open(dm_ChannelDescriptor_t *apChannelDescriptor, void *apDevice, dm_DeviceDescriptor_t *apDeviceDescriptor)
This function creates a device handle for a device at a specified channel address.
void * ci_protocol_initdata_ptr_t
This is the pointer to the user defined data structure to be passed into the ci_protocol_init_funcp_t...
comm_State_t dm_channel_get_state(dm_ChannelDescriptor_t *apChannelDescriptor)
This function returns the channel state.
#define CI_MIN_RX_BYTES
Define the minimum number of bytes for the CI wrapper that encapsulates the protocol data...
Command Interpreter (CI) Protocol header file.
Transmitter state: Send packet marker.
This structure holds information to receive a packet of data to the host. CI will fill the structure ...
Receiver state: Waiting for a packet marker.
volatile uint8 * pRxbuf
Expected packet size.
volatile uint8 packetSize
Mailbox index.
volatile ci_tx_state_t txState
unsigned long uint32
This defines uint32 as unsigned long.
dm_DeviceDescriptor_t dm_dev_desc
dm_ChannelDescriptor_t dm_channel_desc
uint8 protcolID
Protocol destination buffer size.
isf_status_t dm_device_write(dm_DeviceDescriptor_t *apDeviceDescriptor, int32 aOffset, uint8 *apWriteBuffer, uint32 aBuffsize, uint32 aNbyteWrite)
This function writes to a device.
isf_status_t ci_send_packet(uint32 anumBytes, uint8 *apSrc)
CI send packet - main function to send data to host.
volatile uint8 mbIndex
Internal receive state.
Command interpreter task header file. This file is internal ISF code.
isf_status_t ci_init(void)
This API initializes the Command Interpreter.
uint32 isf_ci_get_recv_size(void)
CI Receive buffer size.
#define CI_PROTOCOL_ID_SIZE
Define the number of bytes for the protocol ID. Do not modify.
ci_escape_state_enum
States for encoding/decoding escape characters.
const ci_protocol_t ci_protocol_table[]
CI protocol routing table.
isf_status_t dm_channel_init(dm_ChannelId_t aChannelId, dm_ChannelDescriptor_t *apChannelDescriptor)
This function initializes a channel.
volatile uint8 * pTxbuf
How many bytes left to transfered.
ci_packet_recv_status_t process_recv_byte(uint8 c)
Process data received over comm port. Perform CI packet processing and return to caller status...
This structure holds information to send a packet of data to the host. A task will fill the structure...
Main ISF header file. Contains code common to all ISF components.
Transmitter state: Send packet data.
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Command Interpreter (C...
General library initialization failure status.
ci_protocol_initdata_ptr_t ci_protocol_initptr_table[]
CI protocol user defined initialization data pointer table.
#define CI_PACKET_MARKER
Packet maker. Each packet is delineated by this character.
isf_status_t dm_device_read(dm_DeviceDescriptor_t *apDeviceDescriptor, int32 aOffset, uint8 *apReadBuffer, uint32 aBuffsize, uint32 aNbyteRead)
This function reads from a device.
void task_ci(uint32 initial_data)
Command Interpreter Task - main task to handle communication via mailboxes with the host...
int32 isf_status_t
ISF return status type.
Transmitter state: Send end marker.
#define CI_ALLOC_MEM_ZERO(x)
Memory allocation abstraction.
This structure defines a handle for the device.
Receiver state: Receiving data payload.
This structure binds a protocol ID to a set of related functions and data. When a packet is received ...
isf_devmsg.h defines the API definitions and types for the Intelligent Sensing (ISF) Device Messaging...
ci_response_enum
These are the CI errors provided to the host.
isf_status_t(* ci_protocol_callback_funcp_t)(uint32 anumSrcBytes, uint8 *apSrc, uint32 *apnumDestBytes, uint8 *apDest)
This is a CI protocol callback function pointer.
This structure is a declaration of a channel descriptor type.
volatile ci_recv_state_t rxState