| ISF 2.1 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

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 {
31 CI_RX_STATE_NULL = 0,
32 //! Receiver state: Waiting for a packet marker
33 CI_RX_STATE_WAITFORPACKETMARKER1,
34 //! Receiver state: Receiving data payload
35 CI_RX_STATE_GETTINGPACKETDATA2
36 } ci_recv_state_t;
37
38
39 /*! @brief States for sending a packet */
40 typedef enum
41 {
42 CI_TX_STATE_NULL = 0,
43 //! Transmitter state: Send packet marker
44 CI_TX_STATE_SEND_STARTMARKER1,
45 //! Transmitter state: Send packet data
46 CI_TX_STATE_SEND_PACKETDATA2,
47 //! Transmitter state: Send end marker
48 CI_TX_STATE_SEND_ENDMARKER4
49 } ci_tx_state_t;
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
65 } ci_tx_packet_t;
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
81 } ci_rx_packet_t;
82
83
84 /*!
85 * @brief States for encoding/decoding escape characters.
86 */
87 typedef enum
88 {
89 CI_ESCAPE_STATE_WAIT_1ST_CHAR = 0,
90 CI_ESCAPE_STATE_WAIT_2ND_CHAR
91
92 } ci_escape_state_enum;
93
94
95 /*!
96 * @brief Packet received status.
97 */
98 typedef enum
99 {
100 CI_PACKET_RECV_STATUS_NO = 0,
101 CI_PACKET_RECV_STATUS_YES
102 } ci_packet_recv_status_t;
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_TX_STATE_NULL
Definition: task_ci.h:42
ci_recv_state_t
ci_recv_state_t
States for receiving a packet.
Definition: task_ci.h:29
uint8
unsigned char uint8
This defines uint8 as unsigned char.
Definition: isf_types.h:18
ci_packet_recv_status_t
ci_packet_recv_status_t
Packet received status.
Definition: task_ci.h:98
CI_PACKET_RECV_STATUS_YES
Definition: task_ci.h:101
ci_tx_packet_t::bytesLeft
volatile uint32 bytesLeft
Internal transmit state.
Definition: task_ci.h:63
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:499
CI_TX_STATE_SEND_STARTMARKER1
Transmitter state: Send packet marker.
Definition: task_ci.h:44
CI_PACKET_RECV_STATUS_NO
Definition: task_ci.h:100
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:75
CI_RX_STATE_WAITFORPACKETMARKER1
Receiver state: Waiting for a packet marker.
Definition: task_ci.h:33
ci_rx_packet_t::pRxbuf
volatile uint8 * pRxbuf
Expected packet size.
Definition: task_ci.h:80
ci_rx_packet_t::packetSize
volatile uint8 packetSize
Mailbox index.
Definition: task_ci.h:79
uint32
unsigned long uint32
This defines uint32 as unsigned long.
Definition: isf_types.h:36
ci_tx_packet_t::txState
volatile ci_tx_state_t txState
Definition: task_ci.h:62
ci_rx_packet_t::mbIndex
volatile uint8 mbIndex
Internal receive state.
Definition: task_ci.h:78
CI_ESCAPE_STATE_WAIT_2ND_CHAR
Definition: task_ci.h:90
CI_RX_STATE_NULL
Definition: task_ci.h:31
ci_escape_state_enum
ci_escape_state_enum
States for encoding/decoding escape characters.
Definition: task_ci.h:87
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:342
ci_tx_state_t
ci_tx_state_t
States for sending a packet.
Definition: task_ci.h:40
ci_tx_packet_t::pTxbuf
volatile uint8 * pTxbuf
How many bytes left to transfered.
Definition: task_ci.h:64
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:60
isf.h
Main ISF header file. Contains code common to all ISF components.
CI_ESCAPE_STATE_WAIT_1ST_CHAR
Definition: task_ci.h:89
CI_TX_STATE_SEND_PACKETDATA2
Transmitter state: Send packet data.
Definition: task_ci.h:46
isf_status_t
int32 isf_status_t
ISF return status type.
Definition: isf.h:51
CI_TX_STATE_SEND_ENDMARKER4
Transmitter state: Send end marker.
Definition: task_ci.h:48
CI_RX_STATE_GETTINGPACKETDATA2
Receiver state: Receiving data payload.
Definition: task_ci.h:35
ci_rx_packet_t::rxState
volatile ci_recv_state_t rxState
Definition: task_ci.h:77
- © Freescale Semiconductor, Inc. 2015. All Rights Reserved.