| ISF 2.2 rev 5 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

task_ci.c
Go to the documentation of this file.
1 /*
2 *
3 * Copyright (c) 2015, Freescale Semiconductor, Inc.
4 *
5 */
6
7 /*!
8 * @file task_ci.c
9 *
10 * @brief Command Interpreter (CI) task source file that implements the top level
11 * CI protocol features and functionality. This file is internal ISF code.
12 *
13 */
14
15
16
17 #include "isf.h"
18 #include "isf_ci.h"
19 #include "task_ci.h"
20 #include "isf_ci_protocol.h"
21 #include "isf_devmsg.h"
22 #include "isf_ci_stream.h"
23 #include "isf_init.h"
24 extern void isf_system_sync(void);
25 extern uint32 get_ci_comm(void);
26
27 ci_packet_recv_status_t process_recv_byte (uint8 c);
28 static semaphore_t ci_sema_tx;
29 static ci_rx_packet_t ci_rx_packet;
30 static ci_tx_packet_t ci_tx_packet;
31 static uint8 protocol_max = 0;
32 const uint8 packet_marker = CI_PACKET_MARKER;
33 static uint32 ci_max_recv_size = 0;
34
35 dm_ChannelDescriptor_t dm_channel_desc;
36 dm_DeviceDescriptor_t dm_dev_desc;
37
38
39 static inline void reset_rx_packet() { \
40 ci_rx_packet.mbIndex = 0; \
41 ci_rx_packet.packetSize = 0; \
42 ci_rx_packet.rxState = CI_RX_STATE_WAITFORPACKETMARKER1; \
43 }
44
45 static inline void reset_tx_packet() { \
46 ci_tx_packet.bytesLeft = 0; \
47 ci_tx_packet.pTxbuf = NULL; \
48 ci_tx_packet.txState = CI_TX_STATE_NULL; \
49 }
50
51
52 extern const ci_protocol_t ci_protocol_table[];
53 extern ci_protocol_initdata_ptr_t ci_protocol_initptr_table[];
54 extern uint32 isf_ci_get_recv_size(void);
55
56 #define CI_TASK_NAME ISF_TASK_CI_NAME
57 /* Task1 task stack size */
58 #define CI_TASK_STACK_SIZE ISF_TASK_CI_STACK_SIZE
59 /* Task1 task priority value */
60 #define CI_TASK_PRIORITY ISF_TASK_CI_PRIORITY
61
62 OSA_TASK_DEFINE(CI, CI_TASK_STACK_SIZE);
63
64 void CI_task(os_task_param_t task_init_data);
65 // -------------------------------------------------------------------
66 // Debug only
67
68 //#define DEBUG_TRACE_ENABLE
69
70 #ifdef DEBUG_TRACE_ENABLE
71 volatile uint32 ci_debug_rx_packet_cnt = 0;
72 volatile uint32 ci_debug_tx_packet_cnt = 0;
73
74 volatile uint32 ci_debug_trace[16];
75 volatile uint8 ci_debug_trace_index = 0;
76
77 void debug_trace_set(uint8 step, uint32 data24)
78 {
79 ci_debug_trace[ci_debug_trace_index] = (uint32)( ((uint32)step << 24) | data24 );
80
81 ++ci_debug_trace_index;
82 if (ci_debug_trace_index >= 16)
83 ci_debug_trace_index = 0; // Wrap around
84 }
85 #endif // DEBUG_TRACE_ENABLE
86
87 // ---------------------------------------
88 //#define DEBUG_SAVE_RX_RAWCHARS
89
90 #ifdef DEBUG_SAVE_RX_RAWCHARS
91
92 void debug_rx_store(uint8 c);
93 void debug_rx_reset(void);
94
95 // Circular buffer to store rx chars.
96 volatile uint8 debug_rx_buf[32];
97 volatile uint32 debug_rx_index;
98
99 void debug_rx_store(uint8 c)
100 {
101 debug_rx_buf[debug_rx_index] = c;
102 ++debug_rx_index;
103 if (debug_rx_index >= 32)
104 debug_rx_index = 0; // Wrap around
105 }
106
107
108 void debug_rx_resetbuf(void)
109 {
110 debug_rx_index = 32;
111 do
112 {
113 debug_rx_buf[debug_rx_index-1] = 0;
114 } while(--debug_rx_index);
115 debug_rx_index = 0;
116 }
117 #endif
118
119
120
121 /*!
122 *
123 * @brief Process data received over comm port. Perform CI packet
124 * processing and return to caller status.
125 *
126 * @param (in) c - character to process
127 *
128 * @return process_recv_byte() returns a value of type
129 * ::ci_packet_recv_status_t indicating the status of
130 * the packet received status.
131 *
132 * @retval ::CI_PACKET_RECV_STATUS_NO indicating no packet has been
133 * received.
134 *
135 * @retval ::CI_PACKET_RECV_STATUS_YES indicating a packet has been
136 * received.
137 *
138 * @see task_ci()
139 */
140
141 ci_packet_recv_status_t process_recv_byte (uint8 c)
142 {
143
144 static boolean packetReceived = FALSE;
145 ci_packet_recv_status_t packet_status = CI_PACKET_RECV_STATUS_NO;
146
147 bool bRxPacketerror = FALSE;
148
149
150 #ifdef DEBUG_SAVE_RX_RAWCHARS
151 debug_rx_store(c);
152 #endif
153
154
155 // Process the character.
156 {
157 switch(ci_rx_packet.rxState)
158 {
159
160 case CI_RX_STATE_WAITFORPACKETMARKER1:
161
162 if (c == CI_PACKET_MARKER)
163 {
164 ci_rx_packet.mbIndex = 0;
165 ci_rx_packet.packetSize = 0;
166
167 // Wait for packet data if any.
168 ci_rx_packet.rxState = CI_RX_STATE_GETTINGPACKETDATA2;
169 }
170 // Else ignore the data. It could be a fragment of a packet.
171
172 break;
173
174
175 case CI_RX_STATE_GETTINGPACKETDATA2:
176 {
177 static volatile uint8 c_prev = 0;
178
179 if (c != CI_PACKET_MARKER)
180 {
181 // Got some real data (non-marker char).
182
183 // Do escape decode if needed.
184 if (c == 0x7D)
185 {
186 c_prev = c;
187
188 // ------------------------------------------------------
189 // Exit the case statement. Waiting for 2nd escape char.
190 // ------------------------------------------------------
191 break;
192 }
193 else if (c_prev == 0x7D)
194 {
195 if (c == 0x5D) {
196 c = 0x7D;
197 }
198 else if (c == 0x5E) {
199 c = CI_PACKET_MARKER;
200 }
201 else {
202 // ENGR302687: Handle erroneous escape sequence.
203 // Illegal escape sequence. Reset and wait for next packet.
204 bRxPacketerror = TRUE;
205 }
206 c_prev = 0;
207 }
208
209
210 // Escape decode done.
211 if (ci_rx_packet.mbIndex < ci_max_recv_size)
212 {
213 // Just got data byte, save it.
214
215 ci_rx_packet.pRxbuf[ci_rx_packet.mbIndex] = c;
216 ++ci_rx_packet.mbIndex;
217 }
218 else
219 {
220 // Error: receiving too many bytes.
221 // Reset and wait for next packet.
222 bRxPacketerror = TRUE;
223 }
224
225 }
226 else
227 {
228 // Got packet marker while waiting for data.
229
230 if (ci_rx_packet.mbIndex > 0)
231 {
232
233 if (ci_rx_packet.mbIndex >= CI_MIN_RX_BYTES)
234 {
235 // Got minimum amount of bytes for CI packet.
236
237 // Wait for next packet.
238 ci_rx_packet.rxState = CI_RX_STATE_WAITFORPACKETMARKER1;
239
240 // Set flag to process packet just received.
241 packetReceived = TRUE;
242
243 }
244 else
245 {
246 // This case means that we did not receive enough data.
247 // Reset and wait for next packet.
248 bRxPacketerror = TRUE;
249 }
250 }
251 else
252 {
253 // We got back to back packet marker. This 2nd packet marker will
254 // then be treated as a start marker. Go back to wait for data.
255
256 ci_rx_packet.rxState = CI_RX_STATE_GETTINGPACKETDATA2;
257 ci_rx_packet.mbIndex = 0;
258 ci_rx_packet.packetSize = 0;
259 }
260
261 }
262
263 }
264 break;
265
266 default:
267
268 // Unknown state.
269 bRxPacketerror = TRUE;
270
271 break;
272
273 } // switch
274
275 // Handle packet error.
276 if (bRxPacketerror == TRUE)
277 {
278 reset_rx_packet();
279 packetReceived = FALSE;
280
281 #ifdef DEBUG_SAVE_RX_RAWCHARS
282 debug_rx_resetbuf();
283 #endif
284
285
286
287 }
288 }
289
290
291
292 if (packetReceived == TRUE)
293 {
294
295 // TODO: IF this isr is being converted to SDK callback, return kStatus_UART_RxCallBackEnd
296 // here to indicate that all expected bytes have been received. Return 0 otherwise.
297
298 // Tell caller packet has been received.
299 packet_status = CI_PACKET_RECV_STATUS_YES;
300
301 // Reset
302 packetReceived = FALSE;
303
304 #ifdef DEBUG_SAVE_RX_RAWCHARS
305 debug_rx_resetbuf();
306 #endif
307
308 }
309
310 return packet_status;
311 }
312
313
314 /*!
315 *
316 * @brief CI send packet - main function to send data to host.
317 *
318 * @param anumBytes - number of bytes to transmit.
319 *
320 * @param apSrc - pointer to source of data to transmit.
321 *
322 * @return See ci_response_enum type for possible return values
323 *
324 * @errors None \n
325 *
326 * @constraints Only one caller can have access to the transmit operation.
327 * Other callers will be blocked by a semaphore until the
328 * current transmit operation has completed.
329 *
330 * @reentrant Yes. \n
331 *
332 * @libs \n
333 *
334 * @see \n
335 *
336 */
337
338 isf_status_t ci_send_packet(uint32 anumBytes, uint8 *apSrc)
339 {
340
341 isf_status_t ci_ret = !ISF_SUCCESS;
342 uint32_t ret = !ISF_SUCCESS;
343
344 if (anumBytes > 0)
345 {
346 ret = OSA_SemaWait(&ci_sema_tx, OSA_WAIT_FOREVER);
347 // For now try letting task switching in case comm speed is slow
348 // and let other tasks run.
349 //_task_stop_preemption();
350
351 // While waiting for buffer to be transmitted, we allow preemption
352 // because the operation is interrupt driven.
353
354 if (ret == ISF_SUCCESS)
355 {
356
357 ci_tx_packet.txState = CI_TX_STATE_SEND_STARTMARKER1;
358 ci_tx_packet.bytesLeft = anumBytes;
359 ci_tx_packet.pTxbuf = apSrc;
360
361
362
363 // If there are data to transmit, then do it.
364 if (ci_tx_packet.txState != CI_TX_STATE_NULL)
365 {
366 bool bDone = FALSE;
367
368 // NOTE: Must keep sending until the transmitter is full so that it
369 // will clear its transmit empty flag. The transmitter is double
370 // buffered and if you don't fill them up, the transmit empty flag
371 // is still set and you won't get another transmit empty interrupt.
372
373 while (bDone == FALSE)
374 {
375
376 switch(ci_tx_packet.txState)
377 {
378
379 case CI_TX_STATE_SEND_STARTMARKER1: // Send start marker
380
381 dm_device_write(&dm_dev_desc, 0, (uint8*)&packet_marker, 1, 1);
382
383 ci_tx_packet.txState = CI_TX_STATE_SEND_PACKETDATA2;
384 break;
385
386 case CI_TX_STATE_SEND_PACKETDATA2: // Send MB
387 {
388 static ci_escape_state_enum escapeState = CI_ESCAPE_STATE_WAIT_1ST_CHAR;
389 uint8 c = 0;
390 uint8 d;
391
392 c = *ci_tx_packet.pTxbuf;
393
394 if ((c == 0x7D) || (c == CI_PACKET_MARKER))
395 {
396 if (escapeState == CI_ESCAPE_STATE_WAIT_1ST_CHAR)
397 {
398 // Send first escape byte.
399 d = 0x7D;
400 dm_device_write(&dm_dev_desc, 0, (uint8*)&d, 1, 1);
401
402 escapeState = CI_ESCAPE_STATE_WAIT_2ND_CHAR; // Send 2nd escape byte next time.
403 }
404 else
405 {
406 // Send second escape byte.
407 if (c == 0x7D)
408 d = 0x5D;
409 else
410 d = 0x5E;
411 dm_device_write(&dm_dev_desc, 0, (uint8*)&d, 1, 1);
412 escapeState = CI_ESCAPE_STATE_WAIT_1ST_CHAR;
413
414 ++ci_tx_packet.pTxbuf;
415 --ci_tx_packet.bytesLeft;
416 }
417 }
418 else
419 {
420 // No escape encoding needed.
421 dm_device_write(&dm_dev_desc, 0, (uint8*)ci_tx_packet.pTxbuf++, 1, 1);
422
423 --ci_tx_packet.bytesLeft;
424 }
425
426 if (ci_tx_packet.bytesLeft == 0)
427 ci_tx_packet.txState = CI_TX_STATE_SEND_ENDMARKER4;
428 }
429
430 break;
431
432 case CI_TX_STATE_SEND_ENDMARKER4:
433
434 // All done transmitting packet. Wrap up.
435
436 // Send end marker.
437 dm_device_write(&dm_dev_desc, 0, (uint8*)&packet_marker, 1, 1);
438
439 // Reset state.
440 ci_tx_packet.txState = CI_TX_STATE_NULL;
441
442 #ifdef DEBUG_TRACE_ENABLE
443 ++ci_debug_tx_packet_cnt;
444 #endif
445
446 bDone = TRUE;
447
448 break;
449
450 default:
451 break;
452 }
453 }
454 }
455
456 }
457
458 OSA_SemaPost(&ci_sema_tx);
459 }
460
461 if (ret == ISF_SUCCESS)
462 ci_ret = (isf_status_t)ISF_SUCCESS;
463 else
464 ci_ret = (isf_status_t)ISF_CI_FAILURE;
465
466 return ci_ret;
467 }
468
469
470
471
472 /*!
473 *
474 * @brief Command Interpreter Task - main task to handle communication \n
475 * via mailboxes with the host.
476 *
477 * @param initial_data - value passed in when task is created, not used.
478 *
479 * @return None
480 *
481 * @errors \n
482 *
483 * @constraints \n
484 *
485 * @reentrant No.
486 *
487 * @libs \n
488 *
489 * @see main.c/MQX_template_list[]\n
490 *
491 */
492 void task_ci(uint32 initial_data)
493 {
494
495 //ci_response_t callback_ret;
496
497 while(1)
498 {
499
500 #ifdef DEBUG_TRACE_ENABLE
501 debug_trace_set(1, ci_debug_rx_packet_cnt);
502 #endif
503
504
505 // Wait to receive data from host.
506 {
507 uint8 char_cnt = 0;
508 uint8 c;
509
510 while(1)
511 {
512
513 if (ISF_SUCCESS == dm_device_read(&dm_dev_desc, 0, &c, 1, 1)) {
514 ++char_cnt;
515 if (process_recv_byte(c) == CI_PACKET_RECV_STATUS_YES)
516 break;
517 }
518
519 }
520 }
521
522
523 #ifdef DEBUG_TRACE_ENABLE
524 debug_trace_set(2, ci_debug_rx_packet_cnt);
525 #endif
526
527 #ifdef DEBUG_TRACE_ENABLE
528 debug_trace_set(3, ci_debug_rx_packet_cnt);
529 #endif
530
531
532 // CI packet processing.
533 {
534
535 // Number of bytes in packet minus CI wrapper.
536 uint32 size = ci_rx_packet.mbIndex - CI_PROTOCOL_ID_SIZE; // -1 for protocol id byte at beginning of packet.
537
538
539 // Set to failure so that if no matching protocol is defined we exit loop with error.
540 //callback_ret = ISF_CI_FAILURE;
541
542 uint8 protocol = 0;
543 uint8 id = ci_get_protocol_id();
544 while (protocol < protocol_max)
545 {
546 if ( (id > CI_PROTOCOL_ID_NULL) && (id <= CI_PROTOCOL_ID_MAX) && (ci_protocol_table[protocol].protcolID == id))
547 {
548 // Invoke the protocol.
549 if (ci_protocol_table[protocol].pProtocolCB != NULL)
550 {
551 //callback_ret = ((*((ci_protocol_callback_funcp_t)
552 // (ci_protocol_table[protocol].pProtocolCB)))(size, (uint8 *)&ci_rx_packet.pRxbuf[CI_PROTOCOL_DATA_OFFSET], 0, NULL));
553 ((*((ci_protocol_callback_funcp_t)
554 (ci_protocol_table[protocol].pProtocolCB)))(size, (uint8 *)&ci_rx_packet.pRxbuf[CI_PROTOCOL_DATA_OFFSET], 0, NULL));
555
556 break;
557 }
558 }
559 else
560 {
561 ++protocol;
562 }
563 }
564
565 // For now, we do not send anything back if error conditions occur such as:
566 // - The protocol id specifies a protocol that has not been implemented
567 // - The protocol callback returns an error (such as CRC error). In case of
568 // CRC failure, the packet is corrupted so there we can't use any of its
569 // information to know what/who to send the error to.
570
571 }
572
573 } // while loop
574
575 }
576
577
578
579 // See isf_ci.h for documentation
580 isf_status_t ci_init(void)
581 {
582
583 isf_status_t ret = ISF_SUCCESS;
584
585 OSA_SemaCreate(&ci_sema_tx, 1);
586
587 // Init transmitter/receiver packet states.
588 reset_rx_packet();
589 reset_tx_packet();
590
591 // Alloc mem for recv buffer.
592 ci_max_recv_size = isf_ci_get_recv_size();
593 ci_rx_packet.pRxbuf = CI_ALLOC_MEM_ZERO(ci_max_recv_size);
594
595 if (ci_rx_packet.pRxbuf == NULL)
596 return ISF_ERR_LIB_INIT;
597
598
599 protocol_max = 0;
600
601
602 // Get the number of defined protocols. Count number of pointers in array until we reach NULL
603 // or max num of allowable protocols. It is expected that the array is NULL terminated in the
604 // last element.
605 do
606 {
607
608 if ( (ci_protocol_table[protocol_max].pProtocolCB != NULL) &&
609 (ci_protocol_table[protocol_max].pProtocolInit != NULL) &&
610 (ci_protocol_table[protocol_max].protcolID > 0)
611 )
612 {
613 // Call the protocol's initialization and give it its ID.
614 ((*((ci_protocol_init_funcp_t)(ci_protocol_table[protocol_max].pProtocolInit)))
615 ( ci_protocol_table[protocol_max].protcolID, ci_protocol_initptr_table[protocol_max]));
616 }
617 else
618 {
619 break;
620 }
621
622 } while (++protocol_max < CI_MAX_PROTOCOL);
623
624
625 // Initialize communication channel via device messaging.
626 if (dm_channel_init(get_ci_comm(), &dm_channel_desc) != ISF_SUCCESS) {
627 return ISF_ERR_LIB_INIT;
628 }
629 if(COMM_STATE_INIT != dm_channel_get_state(&dm_channel_desc)){
630 return ISF_ERR_LIB_INIT;
631 }
632 if(ISF_SUCCESS != dm_channel_start(&dm_channel_desc)){
633 return ISF_ERR_LIB_INIT;
634 }
635 if(ISF_SUCCESS != dm_device_open(&dm_channel_desc, NULL, &dm_dev_desc)){
636 return ISF_ERR_LIB_INIT;
637 }
638
639 OSA_TaskCreate(CI_task, /* The task function entry */
640 (uint8_t *)CI_TASK_NAME, /* The name of this task */
641 CI_TASK_STACK_SIZE, /* The stack size in byte */
642 CI_stack, /* Pointer to the stack */
643 CI_TASK_PRIORITY, /* Initial priority of the task */
644 (task_param_t)(NULL), /* Pointer to be passed to the task when it is created */
645 false, /* This task will use not float register */
646 &CI_task_handler); /* Pointer to the task handler */
647
648 return ret;
649 }
650 /*!
651 *
652 * @brief Command Interpreter Task - main task to handle communication \n
653 * via mailboxes with the host.
654 *
655 * @param initial_data - value passed in when task is created, not used.
656 *
657 * @return None
658 *
659 * @errors \n
660 *
661 * @constraints \n
662 *
663 * @reentrant No.
664 *
665 * @libs \n
666 *
667 * @see
668 *
669 */
670 void CI_task(os_task_param_t task_init_data)
671 {
672 isf_system_sync();
673 task_ci(0);
674 }
675
676
677
678
679
680
681
682
683
684
685
686
687
CI_TX_STATE_NULL
Definition: task_ci.h:43
dm_channel_start
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
Definition: isf_device_messaging.c:137
CI_PROTOCOL_DATA_OFFSET
#define CI_PROTOCOL_DATA_OFFSET
Define offset to where protocol data begins of the send/receive buffer that skips pass the protocol i...
Definition: isf_ci_protocol.h:53
CI_MAX_PROTOCOL
#define CI_MAX_PROTOCOL
Define the maximum allowable CI protocols.
Definition: isf_ci_protocol.h:71
packet_marker
const uint8 packet_marker
Definition: task_ci.c:32
uint8
unsigned char uint8
Definition: isf_types.h:76
ci_packet_recv_status_t
ci_packet_recv_status_t
Packet received status.
Definition: task_ci.h:99
TRUE
#define TRUE
Definition: isf_types.h:82
CI_PROTOCOL_ID_MAX
Definition: isf_ci_protocol.h:36
CI_TASK_PRIORITY
#define CI_TASK_PRIORITY
Definition: task_ci.c:60
CI_PACKET_RECV_STATUS_YES
Definition: task_ci.h:102
ISF_CI_FAILURE
Definition: isf_ci.h:34
ISF_SUCCESS
Definition: isf.h:31
isf_ci_stream.h
ISF Command Interpreter (CI) stream protocol header file.
ci_tx_packet_t::bytesLeft
volatile uint32 bytesLeft
Internal transmit state.
Definition: task_ci.h:64
dm_device_open
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.
Definition: isf_device_messaging.c:227
CI_TASK_STACK_SIZE
#define CI_TASK_STACK_SIZE
Definition: task_ci.c:58
ci_protocol_initdata_ptr_t
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...
Definition: isf_ci_protocol.h:173
dm_channel_get_state
comm_State_t dm_channel_get_state(dm_ChannelDescriptor_t *apChannelDescriptor)
This function returns the channel state.
Definition: isf_device_messaging.c:100
get_ci_comm
uint32 get_ci_comm(void)
Definition: isf_sysconf_comms.c:93
CI_MIN_RX_BYTES
#define CI_MIN_RX_BYTES
Define the minimum number of bytes for the CI wrapper that encapsulates the protocol data...
Definition: isf_ci_protocol.h:65
isf_ci_protocol.h
Command Interpreter (CI) Protocol header file.
FALSE
#define FALSE
Definition: isf_types.h:86
CI_TX_STATE_SEND_STARTMARKER1
Transmitter state: Send packet marker.
Definition: task_ci.h:45
CI_PACKET_RECV_STATUS_NO
Definition: task_ci.h:101
CI_PROTOCOL_ID_NULL
Definition: isf_ci_protocol.h:27
ci_rx_packet_t
This structure holds information to receive a packet of data to the host. CI will fill the structure ...
Definition: task_ci.h:76
CI_RX_STATE_WAITFORPACKETMARKER1
Receiver state: Waiting for a packet marker.
Definition: task_ci.h:34
isf_system_sync
void isf_system_sync(void)
This function synchronizes the user tasks and the system initialization.
Definition: isf_init.c:50
ci_rx_packet_t::pRxbuf
volatile uint8 * pRxbuf
Expected packet size.
Definition: task_ci.h:81
ci_rx_packet_t::packetSize
volatile uint8 packetSize
Mailbox index.
Definition: task_ci.h:80
ci_tx_packet_t::txState
volatile ci_tx_state_t txState
Definition: task_ci.h:63
COMM_STATE_INIT
Definition: isf_comm.h:27
dm_dev_desc
dm_DeviceDescriptor_t dm_dev_desc
Definition: task_ci.c:36
dm_channel_desc
dm_ChannelDescriptor_t dm_channel_desc
Definition: task_ci.c:35
ci_protocol_t::protcolID
uint8 protcolID
Protocol destination buffer size.
Definition: isf_ci_protocol.h:163
dm_device_write
isf_status_t dm_device_write(dm_DeviceDescriptor_t *apDeviceDescriptor, int32 aOffset, uint8 *apWriteBuffer, uint32 aBuffsize, uint32 aNbyteWrite)
This function writes to a device.
Definition: isf_device_messaging.c:309
ci_send_packet
isf_status_t ci_send_packet(uint32 anumBytes, uint8 *apSrc)
CI send packet - main function to send data to host.
Definition: task_ci.c:338
ci_rx_packet_t::mbIndex
volatile uint8 mbIndex
Internal receive state.
Definition: task_ci.h:79
task_ci.h
Command interpreter task header file. This file is internal ISF code.
ci_init
isf_status_t ci_init(void)
This API initializes the Command Interpreter.
Definition: task_ci.c:580
CI_ESCAPE_STATE_WAIT_2ND_CHAR
Definition: task_ci.h:91
os_task_param_t
task_param_t os_task_param_t
Definition: mqx_ksdk.h:354
isf_ci_get_recv_size
uint32 isf_ci_get_recv_size(void)
CI Receive buffer size.
Definition: isf_ci_protocol.c:31
CI_PROTOCOL_ID_SIZE
#define CI_PROTOCOL_ID_SIZE
Define the number of bytes for the protocol ID. Do not modify.
Definition: isf_ci_protocol.h:47
ci_protocol_callback_funcp_t
isf_status_t(* ci_protocol_callback_funcp_t)(uint32 anumSrcBytes, uint8 *apSrc, uint32 *apnumDestBytes, uint8 *apDest)
This is a CI protocol callback function pointer.
Definition: isf_ci_protocol.h:116
ci_escape_state_enum
ci_escape_state_enum
States for encoding/decoding escape characters.
Definition: task_ci.h:88
ci_protocol_table
const ci_protocol_t ci_protocol_table[]
CI protocol routing table.
Definition: isf_ci_protocol.c:53
dm_channel_init
isf_status_t dm_channel_init(dm_ChannelId_t aChannelId, dm_ChannelDescriptor_t *apChannelDescriptor)
This function initializes a channel.
Definition: isf_device_messaging.c:48
ci_tx_packet_t::pTxbuf
volatile uint8 * pTxbuf
How many bytes left to transfered.
Definition: task_ci.h:65
process_recv_byte
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...
Definition: task_ci.c:141
ci_tx_packet_t
This structure holds information to send a packet of data to the host. A task will fill the structure...
Definition: task_ci.h:61
isf.h
Main ISF header file. Contains code common to all ISF components.
CI_ESCAPE_STATE_WAIT_1ST_CHAR
Definition: task_ci.h:90
CI_TX_STATE_SEND_PACKETDATA2
Transmitter state: Send packet data.
Definition: task_ci.h:47
ci_protocol_init_funcp_t
isf_status_t(* ci_protocol_init_funcp_t)(uint8 aprotocolID, void *apInitData)
This is a CI protocol intialization callback function pointer.
Definition: isf_ci_protocol.h:147
isf_ci.h
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Command Interpreter (C...
ISF_ERR_LIB_INIT
General library initialization failure status.
Definition: isf.h:34
ci_protocol_initptr_table
ci_protocol_initdata_ptr_t ci_protocol_initptr_table[]
CI protocol user defined initialization data pointer table.
Definition: isf_ci_protocol.c:42
isf_init.h
The isf_init.h file contains the task initialization attributes required for initialization of the fo...
CI_PACKET_MARKER
#define CI_PACKET_MARKER
Packet maker. Each packet is delineated by this character.
Definition: task_ci.h:26
dm_device_read
isf_status_t dm_device_read(dm_DeviceDescriptor_t *apDeviceDescriptor, int32 aOffset, uint8 *apReadBuffer, uint32 aBuffsize, uint32 aNbyteRead)
This function reads from a device.
Definition: isf_device_messaging.c:271
CI_TASK_NAME
#define CI_TASK_NAME
Definition: task_ci.c:56
OSA_TASK_DEFINE
OSA_TASK_DEFINE(CI, CI_TASK_STACK_SIZE)
task_ci
void task_ci(uint32 initial_data)
Command Interpreter Task - main task to handle communication via mailboxes with the host...
Definition: task_ci.c:492
isf_status_t
int32 isf_status_t
ISF return status type.
Definition: isf.h:76
CI_TX_STATE_SEND_ENDMARKER4
Transmitter state: Send end marker.
Definition: task_ci.h:49
CI_ALLOC_MEM_ZERO
#define CI_ALLOC_MEM_ZERO(x)
Memory allocation abstraction.
Definition: task_ci.h:113
uint32
unsigned long int uint32
Definition: isf_types.h:78
dm_DeviceDescriptor_struct
This structure defines a handle for the device.
Definition: isf_devmsg.h:61
CI_RX_STATE_GETTINGPACKETDATA2
Receiver state: Receiving data payload.
Definition: task_ci.h:36
ci_protocol_t
This structure binds a protocol ID to a set of related functions and data. When a packet is received ...
Definition: isf_ci_protocol.h:158
isf_devmsg.h
isf_devmsg.h defines the API definitions and types for the Intelligent Sensing (ISF) Device Messaging...
ci_get_protocol_id
#define ci_get_protocol_id()
Retrieve the protocol ID.
Definition: task_ci.h:121
dm_ChannelDescriptor_struct
This structure is a declaration of a channel descriptor type.
Definition: isf_devmsg.h:50
ci_rx_packet_t::rxState
volatile ci_recv_state_t rxState
Definition: task_ci.h:78
CI_task
void CI_task(os_task_param_t task_init_data)
Command Interpreter Task - main task to handle communication via mailboxes with the host...
Definition: task_ci.c:670
- © Freescale Semiconductor, Inc. 2016. All Rights Reserved.