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

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

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 {
32 CI_RX_STATE_NULL = 0,
33 //! Receiver state: Waiting for a packet marker
34 CI_RX_STATE_WAITFORPACKETMARKER1,
35 //! Receiver state: Receiving data payload
36 CI_RX_STATE_GETTINGPACKETDATA2
37 } ci_recv_state_t;
38
39
40 /*! @brief States for sending a packet */
41 typedef enum
42 {
43 CI_TX_STATE_NULL = 0,
44 //! Transmitter state: Send packet marker
45 CI_TX_STATE_SEND_STARTMARKER1,
46 //! Transmitter state: Send packet data
47 CI_TX_STATE_SEND_PACKETDATA2,
48 //! Transmitter state: Send end marker
49 CI_TX_STATE_SEND_ENDMARKER4
50 } ci_tx_state_t;
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
66 } ci_tx_packet_t;
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
82 } ci_rx_packet_t;
83
84
85 /*!
86 * @brief States for encoding/decoding escape characters.
87 */
88 typedef enum
89 {
90 CI_ESCAPE_STATE_WAIT_1ST_CHAR = 0,
91 CI_ESCAPE_STATE_WAIT_2ND_CHAR
92
93 } ci_escape_state_enum;
94
95
96 /*!
97 * @brief Packet received status.
98 */
99 typedef enum
100 {
101 CI_PACKET_RECV_STATUS_NO = 0,
102 CI_PACKET_RECV_STATUS_YES
103 } ci_packet_recv_status_t;
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_TX_STATE_NULL
Definition: task_ci.h:43
ci_recv_state_t
ci_recv_state_t
States for receiving a packet.
Definition: task_ci.h:30
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
CI_PACKET_RECV_STATUS_YES
Definition: task_ci.h:102
ci_tx_packet_t::bytesLeft
volatile uint32 bytesLeft
Internal transmit state.
Definition: task_ci.h:64
isf_ci_protocol.h
Command Interpreter (CI) Protocol header file.
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
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_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
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
ci_rx_packet_t::mbIndex
volatile uint8 mbIndex
Internal receive state.
Definition: task_ci.h:79
CI_ESCAPE_STATE_WAIT_2ND_CHAR
Definition: task_ci.h:91
CI_RX_STATE_NULL
Definition: task_ci.h:32
ci_escape_state_enum
ci_escape_state_enum
States for encoding/decoding escape characters.
Definition: task_ci.h:88
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_tx_state_t
ci_tx_state_t
States for sending a packet.
Definition: task_ci.h:41
ci_tx_packet_t::pTxbuf
volatile uint8 * pTxbuf
How many bytes left to transfered.
Definition: task_ci.h:65
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
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
uint32
unsigned long int uint32
Definition: isf_types.h:78
CI_RX_STATE_GETTINGPACKETDATA2
Receiver state: Receiving data payload.
Definition: task_ci.h:36
ci_rx_packet_t::rxState
volatile ci_recv_state_t rxState
Definition: task_ci.h:78
- © Freescale Semiconductor, Inc. 2016. All Rights Reserved.