27 #define MBOX_APP_DATA "MBOX App"
48 static inline uint8 ci_get_first_data_mb(
uint8);
49 static inline uint8 ci_get_num_data_mb(
void);
52 static semaphore_t sema_ci_mb_access;
55 static int32 ci_num_apps;
60 static uint8 ci_first_data_mb;
63 static uint8 ci_num_data_mb;
67 static uint32 ci_qr_mb_bit_mask;
71 static uint8 ci_protocol_id;
88 static uint32 ci_sp_writes;
93 .version_info = 0x0100,
111 ret = OSA_SemaWait(&sema_ci_mb_access, OSA_WAIT_FOREVER);
119 int8 qr_bytes_written = 0;
122 int8 qr_cont_cnt = 0;
127 qr_send_buf[0] = ci_protocol_id;
135 OSA_EnterCritical(kCriticalLockSched);
151 if (prevIndex == (i-1))
188 #ifdef MBOX_ENABLE_CRC
210 OSA_ExitCritical(kCriticalLockSched);
217 OSA_SemaPost(&sema_ci_mb_access);
233 ret = OSA_SemaWait(&sema_ci_mb_access, OSA_WAIT_FOREVER);
249 OSA_EnterCritical(kCriticalLockSched);
251 max_bytes = ci_get_num_data_mb();
254 mb_num = ci_get_first_data_mb(aAppId);
259 while( (bytes_read < max_bytes) && (bytes_read < (
int32)anumBytes) )
261 *pTemp_dst++ = *pSrc++;
265 mb_write_bits |= (
uint32)(1 << mb_num++);
267 OSA_ExitCritical(kCriticalLockSched);
271 OSA_SemaPost(&sema_ci_mb_access);
272 return (
uint32)bytes_read;
283 ret = OSA_SemaWait(&sema_ci_mb_access, OSA_WAIT_FOREVER);
294 OSA_EnterCritical(kCriticalLockSched);
300 pDst = (
uint8*)((
uint32)ci_get_first_data_mb(aAppId) + (
uint32)&pciMailboxes[0]);
302 while( (bytes_written < max_bytes) && (bytes_written < (
int32)anumBytes) )
304 pDst[bytes_written] = apSrc[bytes_written];
308 OSA_ExitCritical(kCriticalLockSched);
312 OSA_SemaPost(&sema_ci_mb_access);
313 return (
uint32)bytes_written;
341 OSA_SemaWait(&sema_ci_mb_access, OSA_WAIT_FOREVER);
342 OSA_EnterCritical(kCriticalLockSched);
346 ci_first_data_mb = 0;
348 ci_qr_mb_bit_mask = 0;
360 if (ci_first_data_mb == 0)
366 else if (end_found == 0)
374 #if (FIRST_QR_MAILBOX_NUM > FIRST_DATA_MAILBOX_NUM)
375 if ( (ci_first_data_mb) || (mb_num == 0) )
382 if (ci_first_data_mb)
396 #if (FIRST_QR_MAILBOX_NUM > FIRST_DATA_MAILBOX_NUM)
401 OSA_SemaPost(&sema_ci_mb_access);
402 OSA_ExitCritical(kCriticalLockSched);
461 if (mb_read_bits & (1 << bit_pos))
467 previous_app_id = host_packet.
appId;
473 }
while(++bit_pos < 32);
496 static inline uint8 ci_get_first_data_mb(
uint8 aAppId)
501 return ci_first_data_mb;
520 static inline uint8 ci_get_num_data_mb(
void)
550 if (OSA_SemaCreate(&sema_ci_mb_access, 1) !=
ISF_SUCCESS)
584 memset(&devInfo, 0,
sizeof(devInfo));
626 switch(apHostPacket->
cmd)
638 if ( (cnt == 0) || (cnt > (
sizeof(ciRegisters))) )
642 else if ( (offset >= (
sizeof(ciRegisters))) || ((cnt+offset) > (
sizeof(ciRegisters))) )
676 if(offset <
sizeof(ciRegisters.
qr_config))
689 new_qr_bits = old_qr_bit_mask | ci_qr_mb_bit_mask;
690 new_qr_bits ^= old_qr_bit_mask;
779 memset(&devInfo, 0,
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)
991 #ifdef MBOX_ENABLE_CRC
1015 #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...
#define MB_RESP_BYTES_XFER
uint16 version_info
ISF Embedded Application version information.
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 device id and number of EmbApps present...
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 ci_get_wr_cmdId()
#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 system.
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 MAX_ISF_APPLICATIONS
Maximum number of applications.
#define qr_config_clear()
qr_config_t qr_config[NUM_QR_MAILBOXES]
#define ci_insert_crc(insert_offset, crc16_value, pBuf)
uint8 appType
ISF Embedded Application type.
#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.
uint8 numBytes
ISF Embedded Application registered additional information/data size.
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.
ISF Application Type for MailBox Application.
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.
Main ISF header file. Contains code common to all ISF components.
unsigned short int uint16
#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_enum ci_qr_update(uint32 mb_read_bits)
Based upon mailbox bit mask, invoke the application's command interpreter callback to to update qui...
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.
struct ci_ctrl_reg_t::@3 Bits
#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 ...
ci_response_t(* ci_funcp_t)(ci_host_cmd_packet_t *, ci_app_resp_packet_t *)
This is a CI callback function pointer.
Command interpreter header file for the legacy mailbox protocol.
#define MB_RESP_INDEX_APP_ID
#define ci_get_wr_appid()
#define MAX_NUM_OUT_BUFFER
Number of output buffer available on this system.