33 static inline uint8 ci_get_first_data_mb(
uint8);
34 static inline uint8 ci_get_num_data_mb(
void);
37 static LWSEM_STRUCT sema_ci_mb_access;
41 static int32 ci_num_apps;
46 static uint8 ci_first_data_mb;
49 static uint8 ci_num_data_mb;
53 static uint32 ci_qr_mb_bit_mask;
57 static uint8 ci_protocol_id;
74 static uint32 ci_sp_writes;
83 _mqx_uint ret = !MQX_OK;
92 ret = _lwsem_wait_ticks(&sema_ci_mb_access, 0);
101 int8 qr_bytes_written = 0;
104 int8 qr_cont_cnt = 0;
109 qr_send_buf[0] = ci_protocol_id;
117 _task_stop_preemption();
134 if (prevIndex == (i-1))
171 #ifdef MBOX_ENABLE_CRC
194 _task_start_preemption();
202 _lwsem_post(&sema_ci_mb_access);
219 ret = _lwsem_wait_ticks(&sema_ci_mb_access, 0);
236 _task_stop_preemption();
239 max_bytes = ci_get_num_data_mb();
242 mb_num = ci_get_first_data_mb(aAppId);
247 while( (bytes_read < max_bytes) && (bytes_read < (
int32)anumBytes) )
249 *pTemp_dst++ = *pSrc++;
253 mb_write_bits |= (
uint32)(1 << mb_num++);
256 _task_start_preemption();
261 _lwsem_post(&sema_ci_mb_access);
263 return (
uint32)bytes_read;
275 ret = _lwsem_wait_ticks(&sema_ci_mb_access, 0);
288 _task_stop_preemption();
291 max_bytes = ci_get_num_data_mb();
295 pDst = (
uint8*)((
uint32)ci_get_first_data_mb(aAppId) + (
uint32)&pciMailboxes[0]);
299 while( (bytes_written < max_bytes) && (bytes_written < (
int32)anumBytes) )
301 *pDst++ = *pTemp_src++;
305 _task_start_preemption();
310 _lwsem_post(&sema_ci_mb_access);
312 return (
uint32)bytes_written;
341 _lwsem_wait_ticks(&sema_ci_mb_access, 0);
343 _task_stop_preemption();
348 ci_first_data_mb = 0;
350 ci_qr_mb_bit_mask = 0;
362 if (ci_first_data_mb == 0)
368 else if (end_found == 0)
376 #if (FIRST_QR_MAILBOX_NUM > FIRST_DATA_MAILBOX_NUM)
377 if ( (ci_first_data_mb) || (mb_num == 0) )
384 if (ci_first_data_mb)
398 #if (FIRST_QR_MAILBOX_NUM > FIRST_DATA_MAILBOX_NUM)
403 _task_start_preemption();
405 _lwsem_post(&sema_ci_mb_access);
464 if (mb_read_bits & (1 << bit_pos))
470 previous_app_id = host_packet.
appId;
476 }
while(++bit_pos < 32);
499 static inline uint8 ci_get_first_data_mb(
uint8 aAppId)
504 return ci_first_data_mb;
523 static inline uint8 ci_get_num_data_mb(
void)
555 if (_lwsem_create(&sema_ci_mb_access, 1) != MQX_OK)
589 _mem_zero(&devInfo,
sizeof(devInfo));
632 switch(apHostPacket->
cmd)
644 if ( (cnt == 0) || (cnt > (
sizeof(ciRegisters))) )
648 else if ( (offset >= (
sizeof(ciRegisters))) || ((cnt+offset) > (
sizeof(ciRegisters))) )
682 if(offset <
sizeof(ciRegisters.
qr_config))
695 new_qr_bits = old_qr_bit_mask | ci_qr_mb_bit_mask;
696 new_qr_bits ^= old_qr_bit_mask;
778 _mem_zero(&devInfo,
sizeof(devInfo));
812 #ifdef MBOX_ENABLE_CRC
832 pciMailboxes[rx_count] = apSrc[rx_count];
835 ci_sp_writes |= (
uint32)(1 << rx_count);
848 if ( ci_sp_writes & ci_qr_mb_bit_mask )
909 ciMailboxes[size + 0] = (
uint8)((
uint16)(crc16 & 0xff00) >> 8);
910 ciMailboxes[size + 1] = (
uint8)(crc16 & 0xff);
934 if (host_packet.
appId < ci_num_apps)
941 #ifdef DEBUG_TRACE_ENABLE
942 debug_trace_set(4, ci_debug_rx_packet_cnt);
954 #ifdef CI_DEBUG_ENABLE_LOOPBACK_CMD
971 if (host_packet.
appId != 0)
981 switch(host_packet.
cmd)
990 #ifdef MBOX_ENABLE_CRC
1014 #ifdef MBOX_ENABLE_CRC
#define CI_PROTOCOL_DATA_OFFSET
Define offset to where protocol data begins of the send/receive buffer that skips pass the protocol i...
ISF board support header files.
unsigned char uint8
This defines uint8 as unsigned char.
#define MB_RESP_BYTES_XFER
void _fw_device_info_get(device_info_t *info_ptr)
Command Interpreter Registers Structure. Contains all CI registers. .
#define MB_RESP_INDEX_STATUS_CC
#define NUM_QR_MAILBOXES
Maximum number of mailboxes available on this system for quick read. Note that not all mailboxes de...
This structure holds the ROM device information such as version and part number and is returned by th...
ci_funcp_t ci_callback[]
Command interpreter callbacks. The array index is the application ID.
isf_status_t ci_mbox_init(uint8 aprotocolID, void *apInitData)
#define MBOX_CRC_BYTE_SIZE
Define to enable CRC check. When enabled, CRC calculation is performed and CRC bytes are included in ...
#define MAX_NUM_MAILBOXES
Number of mailboxes available on this sytem.
ci_status_enum ci_status_t
Type definition for the CI status values.
Command Interpreter (CI) Protocol header file.
ci_response_t isf_app_callback_mbox(ci_host_cmd_packet_t *apHostPacket, ci_app_resp_packet_t *apAppPacket)
Callback function for mailbox application ID, ISF_APP_ID_MBOX.
#define qr_config_clear()
#define ci_get_wr_cmdId()
#define MAX_ISF_APPLICATIONS
Maximum number of applications.
qr_config_t qr_config[NUM_QR_MAILBOXES]
#define ci_insert_crc(insert_offset, crc16_value, pBuf)
unsigned long uint32
This defines uint32 as unsigned long.
#define CI_CMD_DEBUG_LOOPBACK
Debug commands.
ci_response_t isf_app_callback_dev_info(ci_host_cmd_packet_t *apHostPacket, ci_app_resp_packet_t *apAppPacket)
Callback function for the device info command, ISF_APP_ID_DEV_INFO.
Command interpreter task header file. This file is internal ISF code.
isf_status_t ci_protocol_CB_mbox(uint32 anumBytes, uint8 *apSrc, uint32 *apnumDestBytes, uint8 *apDest)
#define CI_PROTOCOL_ID_INDEX
Define the index of the send/receive buffer of where the protocol ID resides. Do not modify...
#define MB_RESP_INDEX_BYTES_XFER
#define CMD_PACKET_BITS
Mailboxes write bit. Bit setting for the 4 byte command packet from host. Bit position has same mea...
#define CI_STREAMING_MODE
#define ci_get_wr_offset(x)
#define MB_RESP_INDEX_COUNT
#define CI_PROTOCOL_ID_SIZE
Define the number of bytes for the protocol ID. Do not modify.
uint32 isf_ci_app_read(uint8 aAppId, uint32 anumBytes, uint8 *apDst)
This API reads data from the host via the mailboxes.
uint32 isf_ci_app_write(uint8 aAppId, uint32 anumBytes, uint8 *apSrc)
This API writes data to the host via the mailboxes.
#define ci_get_wr_appid()
isf_status_t ci_send_packet(uint32 anumBytes, uint8 *apSrc)
CI send packet - main function to send data to host.
#define MB_RESP_STATUS_CC
uint16 ccitt_crc16_cal(uint32 anumBytes, uint8 *apBuf)
This crc function contains the standard CCITT CRC 16-bit implementation.
long int32
This defines int32 as long.
Main ISF header file. Contains code common to all ISF components.
#define ci_get_first_mailbox(x)
API definitions, types, and macros for the Intelligent Sensing Framework (ISF) Command Interpreter (C...
General library initialization failure status.
ci_status_enum
ISF CI return status type.
ci_status_t isf_ci_qr_update(uint8 aAppId, int8 anumBytes, uint8 *apSrc)
This API updates the Quick-Read mailboxes.
#define APP_ID_NULL
Null application ID.
ci_response_t(* ci_funcp_t)(ci_host_cmd_packet_t *, ci_app_resp_packet_t *)
This is a CI callback function pointer.
ci_response_enum ci_qr_update(uint32 mb_read_bits)
Based upon mailbox bit mask, invoke the application's command interpreter callback to to update qui...
unsigned short uint16
This defines uint16 as unsigned short.
This structure enables an application to read from or write to the host.
int32 isf_status_t
ISF return status type.
#define NUM_DATA_MAILBOXES
Maximum number of mailboxes available on this system for data from/to host. Note that not all mailb...
#define MB_HOST_CMD_SIZE(x)
#define FIRST_DATA_MAILBOX_NUM
First mailbox number for data transfer at powerup. Note that the actual first mailbox available for d...
This structure contains host command information.
#define FIRST_QR_MAILBOX_NUM
First mailbox number that can be configured for quick read data. Quick read data can be written to t...
ci_response_enum
These are the CI errors provided to the host.
#define CI_CMD_LAST
The maximum enumeration value implemented as a valid CI command.
void ci_update_first_data_mb(void)
Finds the first mailbox available for data pay load, how many mailboxes are available for data pay ...
Command interpreter header file for the legacy mailbox protocol.
struct ci_ctrl_reg_t::@4 Bits
#define MB_RESP_INDEX_APP_ID