ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
task_ci.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2015, Freescale Semiconductor, Inc.
4  *
5 */
6 
7 /*!
8  * @file task_ci.h
9  * @brief Command interpreter task header file. This file is internal ISF code.
10  *
11  */
12 
13 
14 
15 #ifndef TASK_CI_H_
16 #define TASK_CI_H_
17 
18 
19 //#include <IO_Map.h>
20 #include "isf.h"
21 #include "isf_ci_protocol.h"
22 #if !OS_MQXLITE
23 #include "fsl_os_abstraction.h"
24 #endif
25 /*! @brief Packet maker. Each packet is delineated by this character. */
26 #define CI_PACKET_MARKER (0x7E)
27 
28 
29 /*! @brief States for receiving a packet */
30 typedef enum
31 {
33  //! Receiver state: Waiting for a packet marker
35  //! Receiver state: Receiving data payload
38 
39 
40 /*! @brief States for sending a packet */
41 typedef enum
42 {
44  //! Transmitter state: Send packet marker
46  //! Transmitter state: Send packet data
48  //! Transmitter state: Send end marker
51 
52 
53 /*!
54  * @brief This structure holds information to send a packet of data to the
55  * host. A task will fill the structure with the information and enable
56  * transmit buffer empty. The ISR will send the data byte by byte until
57  * all data is sent.
58  *
59  * @struct ci_tx_packet_t
60 */
61 typedef struct
62 {
63  volatile ci_tx_state_t txState; //! Internal transmit state
64  volatile uint32 bytesLeft; //! How many bytes left to transfered.
65  volatile uint8 *pTxbuf; //! Buffer to send
67 
68 /*!
69  * @brief This structure holds information to receive a packet of data to the
70  * host. CI will fill the structure with the information as it receives
71  * it from the ISR and will notify the CI task when a packet has been fully
72  * received.
73  *
74  * @struct ci_rx_packet_t
75 */
76 typedef struct
77 {
78  volatile ci_recv_state_t rxState; //! Internal receive state
79  volatile uint8 mbIndex; //! Mailbox index
80  volatile uint8 packetSize; //! Expected packet size
81  volatile uint8 *pRxbuf; //! Receive buffer
83 
84 
85 /*!
86  * @brief States for encoding/decoding escape characters.
87  */
88 typedef enum
89 {
92 
94 
95 
96 /*!
97  * @brief Packet received status.
98  */
99 typedef enum
100 {
104 
105 
106 
107 /*! @brief Memory allocation abstraction.
108  */
109 #if OS_MQXLITE
110 #define CI_ALLOC_MEM_ZERO(x) _lwmem_alloc_system_zero(x)
111 #define CI_FREE_MEM(x) _lwmem_free(x)
112 #else
113 #define CI_ALLOC_MEM_ZERO(x) OSA_MemAllocZero(x)
114 #define CI_FREE_MEM(x) OSA_MemFree(x)
115 #endif
116 #define CI_COPY_MEM(src, dest, size) isf_mem_copy(src, dest, size)
117 
118 
119 /*! @brief Retrieve the protocol ID.
120  */
121 #define ci_get_protocol_id() ((uint8)ci_rx_packet.pRxbuf[CI_PROTOCOL_ID_INDEX])
122 
123 
124 extern void task_ci(uint32 initial_data);
125 extern isf_status_t ci_send_packet(uint32 anumBytes, uint8 *apSrc);
126 
127 
128 #endif /* TASK_CI_H_ */
ci_recv_state_t
States for receiving a packet.
Definition: task_ci.h:30
unsigned char uint8
Definition: isf_types.h:76
ci_packet_recv_status_t
Packet received status.
Definition: task_ci.h:99
volatile uint32 bytesLeft
Internal transmit state.
Definition: task_ci.h:64
Command Interpreter (CI) Protocol header file.
void task_ci(uint32 initial_data)
Command Interpreter Task - main task to handle communication via mailboxes with the host...
Definition: task_ci.c:492
Transmitter state: Send packet marker.
Definition: task_ci.h:45
This structure holds information to receive a packet of data to the host. CI will fill the structure ...
Definition: task_ci.h:76
Receiver state: Waiting for a packet marker.
Definition: task_ci.h:34
volatile uint8 * pRxbuf
Expected packet size.
Definition: task_ci.h:81
volatile uint8 packetSize
Mailbox index.
Definition: task_ci.h:80
volatile ci_tx_state_t txState
Definition: task_ci.h:63
volatile uint8 mbIndex
Internal receive state.
Definition: task_ci.h:79
ci_escape_state_enum
States for encoding/decoding escape characters.
Definition: task_ci.h:88
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_tx_state_t
States for sending a packet.
Definition: task_ci.h:41
volatile uint8 * pTxbuf
How many bytes left to transfered.
Definition: task_ci.h:65
This structure holds information to send a packet of data to the host. A task will fill the structure...
Definition: task_ci.h:61
Main ISF header file. Contains code common to all ISF components.
Transmitter state: Send packet data.
Definition: task_ci.h:47
int32 isf_status_t
ISF return status type.
Definition: isf.h:76
Transmitter state: Send end marker.
Definition: task_ci.h:49
unsigned long int uint32
Definition: isf_types.h:78
Receiver state: Receiving data payload.
Definition: task_ci.h:36
volatile ci_recv_state_t rxState
Definition: task_ci.h:78