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

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Functions | Variables
ci_protocol_mbox.c File Reference

Command interpreter source file that implements the legacy mailbox protocol functionality. More...

`#include "isf.h"`
`#include "isf_ci.h"`
`#include "isf_ci_protocol.h"`
`#include "task_ci.h"`
`#include "ci_protocol_mbox.h"`
`#include "crc.h"`
Include dependency graph for ci_protocol_mbox.c:

Go to the source code of this file.

## Data Structures
struct | ci_mbox_app_info_t

## Macros
#define | MBOX_APP_DATA "MBOX App"

## Functions
ci_status_t | isf_ci_qr_update (uint8 aAppId, int8 anumBytes, uint8 *apSrc)
| This API updates the Quick-Read mailboxes. More...
uint32 | isf_ci_app_read (uint8 aAppId, uint32 anumBytes, uint8 *apDst)
| This API reads data from the host via the mailboxes. More...
uint32 | isf_ci_app_write (uint8 aAppId, uint32 anumBytes, uint8 *apSrc)
| This API writes data to the host via the mailboxes. More...
void | ci_update_first_data_mb (void)
| Finds the first mailbox available for data pay load, how many mailboxes are available for data pay load, and updates a bit mask that tracks which of the 32 mailboxes are used for quick read. More...
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 quick read mailboxes. More...
isf_status_t | ci_mbox_init (uint8 aprotocolID, void *apInitData)
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. More...
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. More...
isf_status_t | ci_protocol_CB_mbox (uint32 anumBytes, uint8 *apSrc, uint32 *apnumDestBytes, uint8 *apDest)

## Variables
ci_funcp_t | ci_callback []
| Command interpreter callbacks. The array index is the application ID. More...

## Detailed Description

Command interpreter source file that implements the legacy mailbox protocol functionality.

Definition in file ci_protocol_mbox.c.

## Macro Definition Documentation

#define MBOX_APP_DATA "MBOX App"

Definition at line 27 of file ci_protocol_mbox.c.

## Function Documentation

isf_status_t ci_mbox_init | ( | uint8 | aprotocolID,
|  | void * | apInitData
| ) |  |

Definition at line 528 of file ci_protocol_mbox.c.

References _fw_device_info_get(), qr_config_t::appId, qr_config_t::byte_id, ci_callback, CI_PROTOCOL_ID_INDEX, ci_update_first_data_mb(), ci_regs_t::ciCtrlReg, isf_ci_app_write(), ISF_ERR_LIB_INIT, ISF_SUCCESS, MAX_ISF_APPLICATIONS, MAX_NUM_MAILBOXES, ci_regs_t::qr_config, and ci_ctrl_reg_t::reg.

Here is the call graph for this function:

isf_status_t ci_protocol_CB_mbox | ( | uint32 | anumBytes,
|  | uint8 * | apSrc,
|  | uint32 * | apnumDestBytes,
|  | uint8 * | apDest
| ) |  |

Definition at line 795 of file ci_protocol_mbox.c.

References ci_host_cmd_packet_t::appId, ci_host_cmd_packet_t::byte_cnt, ci_app_resp_packet_t::bytes_left, ci_app_resp_packet_t::bytes_xfer, ccitt_crc16_cal(), ci_callback, CI_CMD_DEBUG_LOOPBACK, CI_CMD_LAST, CI_CMD_READ_VERSION, CI_CMD_RESET_APP, CI_CMD_UPDATE_QUICKREAD, CI_CMD_WRITE_CONFIG, CI_CMD_WRITE_SREC_FLASH, CI_ERROR_CB_NOT_REGISTERED, CI_ERROR_COMMAND, CI_ERROR_INVALID_LENGTH, CI_ERROR_NONE, CI_ERROR_PARAM, ci_get_first_mailbox, ci_get_wr_appid, ci_get_wr_cmd, ci_get_wr_cmdId, ci_get_wr_cnt, ci_get_wr_offset, ci_insert_crc, CI_INVALID_COUNT, CI_PROTOCOL_DATA_OFFSET, CI_PROTOCOL_ID_SIZE, CI_RW_NULL, ci_send_packet(), ci_host_cmd_packet_t::cmd, CMD_PACKET_BITS, COCO_BIT_MASK, FIRST_DATA_MAILBOX_NUM, ISF_SUCCESS, MAX_NUM_MAILBOXES, MB_APP_RESP_SIZE, MB_HOST_CMD, MB_HOST_CMD_SIZE, MB_RESP_APP_ID, MB_RESP_BYTES_XFER, MB_RESP_COUNT, MB_RESP_STATUS_CC, MBOX_CRC_BYTE_SIZE, ci_host_cmd_packet_t::offset, and ci_app_resp_packet_t::rw.

Here is the call graph for this function:

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 quick read mailboxes.

Parameters

  (in) | mb_read_bits - Bit setting that indicates if a mailbox has been read. The corresponding mailbox quick read configuration is examined and its callback is invoked with command to update quick read registers. Each bit corresponds with each of the 32 mailboxes.

A bit that is set indicates that the corresponding
mailbox has been read.

Returns
  See ci_response_enum type for possible return values

Errors:
  None

Constraints:
  If another application is using the mailboxes, then the
  current calling application must wait until the other
  application has completed its operation on the mailboxes.

Reentrant: No.

Link Libraries:

See also

Definition at line 436 of file ci_protocol_mbox.c.

References APP_ID_NULL, qr_config_t::appId, ci_host_cmd_packet_t::appId, ci_host_cmd_packet_t::byte_cnt, ci_callback, CI_CMD_UPDATE_QUICKREAD, CI_ERROR_NONE, ci_host_cmd_packet_t::cmd, FIRST_QR_MAILBOX_NUM, ISF_APP_ID_NULL, ci_host_cmd_packet_t::offset, and ci_regs_t::qr_config.

Referenced by isf_app_callback_mbox().

Here is the caller graph for this function:

void ci_update_first_data_mb | ( | void |  | ) |

Finds the first mailbox available for data pay load, how many
mailboxes are available for data pay load, and updates a bit mask
that tracks which of the 32 mailboxes are used for quick read.

Returns
  None

Errors:
  None

Constraints:
  None

Reentrant: No.

Link Libraries:

See also

Definition at line 336 of file ci_protocol_mbox.c.

References APP_ID_NULL, qr_config_t::appId, FIRST_DATA_MAILBOX_NUM, FIRST_QR_MAILBOX_NUM, NUM_QR_MAILBOXES, and ci_regs_t::qr_config.

Referenced by ci_mbox_init(), and isf_app_callback_mbox().

Here is the caller graph for this function:

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.

Parameters

  packet_ptr | - host command packet
  mb_data_ptr | - pointer to first mailbox address containing data.

Returns
  See ci_response_enum type for possible return values

Errors:
  None

Constraints:
  If another application is using the mailboxes, then the
  current calling application must wait until the other
  application has completed its operation on the mailboxes.

Reentrant: Yes.

Link Libraries:

See also

Definition at line 768 of file ci_protocol_mbox.c.

References _fw_device_info_get(), ci_host_cmd_packet_t::appId, ci_app_resp_packet_t::bytes_left, ci_app_resp_packet_t::bytes_xfer, CI_ERROR_NONE, CI_RW_WRITE, isf_ci_app_write(), and ci_app_resp_packet_t::rw.

Here is the call graph for this function:

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.

This function is the mailbox application callback.

Parameters

  packet_ptr | - host command packet
  mb_data_ptr | - pointer to first mailbox address containing data.

Returns
  See ci_response_enum type for possible return values

Errors:
  None

Constraints:
  If another application is using the mailboxes, then the
  current calling application must wait until the other
  application has completed its operation on the mailboxes.

Reentrant: Yes.

Link Libraries:

See also

Definition at line 620 of file ci_protocol_mbox.c.

References ci_host_cmd_packet_t::appId, ci_host_cmd_packet_t::byte_cnt, ci_app_resp_packet_t::bytes_left, ci_app_resp_packet_t::bytes_xfer, CI_CMD_READ_APP_DATA, CI_CMD_READ_CONFIG, CI_CMD_READ_VERSION, CI_CMD_RESET_APP, CI_CMD_UPDATE_QUICKREAD, CI_CMD_WRITE_CONFIG, CI_ERROR_COMMAND, CI_ERROR_INVALID_LENGTH, CI_ERROR_NONE, CI_INVALID_COUNT, ci_qr_update(), CI_RW_NULL, CI_RW_READ, CI_RW_WRITE, ci_update_first_data_mb(), ci_regs_t::ciCtrlReg, ci_host_cmd_packet_t::cmd, isf_ci_app_read(), isf_ci_app_write(), ci_host_cmd_packet_t::offset, ci_regs_t::qr_config, qr_config_clear, ci_ctrl_reg_t::reg, and ci_app_resp_packet_t::rw.

Here is the call graph for this function:

uint32 isf_ci_app_read | ( | uint8 | aAppId,
|  | uint32 | anumBytes,
|  | uint8 * | apDst
| ) |  |

This API reads data from the host via the mailboxes.

This API function is called by an application that reads data from the host in response to a host command.

Parameters

  [in] | aAppId | ID of the application reading data from the host.
  [in] | anumBytes | The number of bytes to read from the mailboxes. The range is 1 to 28.
  [in] | apDst | Pointer to the destination where the data is to be stored.

Returns
  isf_ci_app_read() returns a value of type uint32 containing the number of bytes read from the mailboxes written by the host.

Constraints:
  The following constraints must be observed when using this function. If these constraints are not met, this API returns a zero for the number of bytes read from the mailboxes.
  - anumBytes must be within the valid range of 1 to 28.
  - apDst cannot be NULL.

Reentrant: Yes

Link Libraries:
  isf_core.lib

See also
  isf_ci_app_write()

Definition at line 226 of file ci_protocol_mbox.c.

References ISF_SUCCESS.

Referenced by App1_ci_app_callback(), BasicApp1_CI_Callback(), isf_app_callback_mbox(), and rli_ci_app_callback().

Here is the caller graph for this function:

uint32 isf_ci_app_write | ( | uint8 | aAppId,
|  | uint32 | anumBytes,
|  | uint8 * | apSrc
| ) |  |

This API writes data to the host via the mailboxes.

This API function is called by an application that sends data to the host in response to a host command. Data is sent to the host via the mailboxes.

Parameters

  [in] | aAppId | ID of application writing data to the host.
  [in] | anumBytes | The number of bytes to write to the mailboxes. The range is 1 to 28.
  [in] | apSrc | Pointer to the source of the data to write to the host.

Returns
  isf_ci_app_write() returns a value of type uint32 which is the number of bytes written to the mailboxes for the host to retrieve.

Constraints:
  The following constraints must be observed when using this function. If these constraints are not met, this API returns a zero for the number of bytes read from the mailboxes.
  - anumBytes must be within the valid range of 1 to 28.
  - apSrc cannot be NULL.

Reentrant: Yes

Link Libraries:
  isf_core.lib

See also
  isf_ci_app_read()

Definition at line 277 of file ci_protocol_mbox.c.

References ISF_SUCCESS, and MAX_NUM_OUT_BUFFER.

Referenced by App1_ci_app_callback(), BasicApp1_CI_Callback(), ci_mbox_init(), isf_app_callback_dev_info(), isf_app_callback_mbox(), and rli_ci_app_callback().

Here is the caller graph for this function:

ci_status_t isf_ci_qr_update | ( | uint8 | aAppId,
|  | int8 | anumBytes,
|  | uint8 * | apSrc
| ) |  |

This API updates the Quick-Read mailboxes.

This API function is called by an application to write data to the host via the mailboxes designated as Quick-Read for that application. The host must configure the mailboxes for Quick-Read by configuring the mailbox application. The host reads these Quick-Read mailboxes directly without sending a command to the CI.

Parameters

  [in] | aAppId | ID of the application writing data to the mailboxes for the host.
  [in] | anumBytes | The number of bytes to write to the mailboxes. The range is 1 to 28.
  [in] | apSrc | Pointer to the source of the data to write to the mailboxes designated as Quick-Read for the application specified in appId.

Returns
  isf_ci_qr_update() returns a value of type ci_status_t providing the status of the Quick-Read operation.

Return values

  ISF_SUCCESS | The Quick-Read update completed successfully.
  ISF_CI_FAILURE | A timeout error occurred while waiting for the mailboxes to be free for updates.

Constraints:
  The following constraints must be observed when using this function. If these constraints are not met, this API returns an error.
  - anumbytes must be within the valid range of 1 to 28.
  - apSrc cannot be NULL.

Reentrant: Yes

Link Libraries:
  isf_core.lib

See also
  ci_status_t

Definition at line 100 of file ci_protocol_mbox.c.

References qr_config_t::appId, ci_ctrl_reg_t::Bits, ci_ctrl_reg_t::blockTransferMode, qr_config_t::byte_id, ccitt_crc16_cal(), ci_insert_crc, CI_PROTOCOL_DATA_OFFSET, CI_PROTOCOL_ID_SIZE, CI_RESP_QUICKREAD, ci_send_packet(), CI_STREAMING_MODE, ci_regs_t::ciCtrlReg, FIRST_QR_MAILBOX_NUM, ISF_CI_FAILURE, ISF_SUCCESS, MAX_NUM_MAILBOXES, MB_APP_RESP_SIZE, MB_RESP_INDEX_APP_ID, MB_RESP_INDEX_BYTES_XFER, MB_RESP_INDEX_COUNT, MB_RESP_INDEX_STATUS_CC, MBOX_CRC_BYTE_SIZE, NUM_QR_MAILBOXES, and ci_regs_t::qr_config.

Referenced by App1_ci_app_callback(), and App1_MainTask().

Here is the call graph for this function:

Here is the caller graph for this function:
- © Freescale Semiconductor, Inc. 2016. All Rights Reserved.