ISF  2.1
Intelligent Sensing Framework for Kinetis with Processor Expert
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
task_ci.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014, 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 
23 
24 /*! @brief Packet maker. Each packet is delineated by this character. */
25 #define CI_PACKET_MARKER (0x7E)
26 
27 
28 /*! @brief States for receiving a packet */
29 typedef enum
30 {
32  //! Receiver state: Waiting for a packet marker
34  //! Receiver state: Receiving data payload
37 
38 
39 /*! @brief States for sending a packet */
40 typedef enum
41 {
43  //! Transmitter state: Send packet marker
45  //! Transmitter state: Send packet data
47  //! Transmitter state: Send end marker
50 
51 
52 /*!
53  * @brief This structure holds information to send a packet of data to the
54  * host. A task will fill the structure with the information and enable
55  * transmit buffer empty. The ISR will send the data byte by byte until
56  * all data is sent.
57  *
58  * @struct ci_tx_packet_t
59 */
60 typedef struct
61 {
62  volatile ci_tx_state_t txState; //! Internal transmit state
63  volatile uint32 bytesLeft; //! How many bytes left to transfered.
64  volatile uint8 *pTxbuf; //! Buffer to send
66 
67 /*!
68  * @brief This structure holds information to receive a packet of data to the
69  * host. CI will fill the structure with the information as it receives
70  * it from the ISR and will notify the CI task when a packet has been fully
71  * received.
72  *
73  * @struct ci_rx_packet_t
74 */
75 typedef struct
76 {
77  volatile ci_recv_state_t rxState; //! Internal receive state
78  volatile uint8 mbIndex; //! Mailbox index
79  volatile uint8 packetSize; //! Expected packet size
80  volatile uint8 *pRxbuf; //! Receive buffer
82 
83 
84 /*!
85  * @brief States for encoding/decoding escape characters.
86  */
87 typedef enum
88 {
91 
93 
94 
95 /*!
96  * @brief Packet received status.
97  */
98 typedef enum
99 {
103 
104 
105 
106 /*! @brief Memory allocation abstraction.
107  */
108 #define CI_ALLOC_MEM_ZERO(x) _lwmem_alloc_system_zero(x)
109 #define CI_FREE_MEM(x) _lwmem_free(x)
110 #define CI_COPY_MEM(src, dest, size) isf_mem_copy(src, dest, size)
111 
112 
113 /*! @brief Retrieve the protocol ID.
114  */
115 #define ci_get_protocol_id() ((uint8)ci_rx_packet.pRxbuf[CI_PROTOCOL_ID_INDEX])
116 
117 
118 extern void task_ci(uint32 initial_data);
119 extern isf_status_t ci_send_packet(uint32 anumBytes, uint8 *apSrc);
120 
121 
122 #endif /* TASK_CI_H_ */
ci_recv_state_t
States for receiving a packet.
Definition: task_ci.h:29
unsigned char uint8
This defines uint8 as unsigned char.
Definition: isf_types.h:18
ci_packet_recv_status_t
Packet received status.
Definition: task_ci.h:98
volatile uint32 bytesLeft
Internal transmit state.
Definition: task_ci.h:63
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:499
Transmitter state: Send packet marker.
Definition: task_ci.h:44
This structure holds information to receive a packet of data to the host. CI will fill the structure ...
Definition: task_ci.h:75
Receiver state: Waiting for a packet marker.
Definition: task_ci.h:33
volatile uint8 * pRxbuf
Expected packet size.
Definition: task_ci.h:80
volatile uint8 packetSize
Mailbox index.
Definition: task_ci.h:79
unsigned long uint32
This defines uint32 as unsigned long.
Definition: isf_types.h:36
volatile ci_tx_state_t txState
Definition: task_ci.h:62
volatile uint8 mbIndex
Internal receive state.
Definition: task_ci.h:78
ci_escape_state_enum
States for encoding/decoding escape characters.
Definition: task_ci.h:87
isf_status_t ci_send_packet(uint32 anumBytes, uint8 *apSrc)
CI send packet - main function to send data to host.
Definition: task_ci.c:342
ci_tx_state_t
States for sending a packet.
Definition: task_ci.h:40
volatile uint8 * pTxbuf
How many bytes left to transfered.
Definition: task_ci.h:64
This structure holds information to send a packet of data to the host. A task will fill the structure...
Definition: task_ci.h:60
Main ISF header file. Contains code common to all ISF components.
Transmitter state: Send packet data.
Definition: task_ci.h:46
int32 isf_status_t
ISF return status type.
Definition: isf.h:51
Transmitter state: Send end marker.
Definition: task_ci.h:48
Receiver state: Receiving data payload.
Definition: task_ci.h:35
volatile ci_recv_state_t rxState
Definition: task_ci.h:77