/**
* Submit a CAN message for transmission.
*
- * Data pointed by @a pdu is copied to the given message box for
+ * Data pointed by @a pdu is copied to the given message object for
* transmission. A successful call to this function also resets the TX
- * confirmation that can be retrieved with rpp_can_check_tx_con().
+ * pending flag that can be retrieved with rpp_can_check_tx_pend().
*
- * @param[in] hw_obj Index of hardware object to use for transmission.
- * It is an index to rpp_can_config.tx_config.
+ * When the previously submitted transmission request is pending when
+ * this function is invoked again, the pending message is replaced by
+ * the new message. If this is not desired, the caller should only
+ * call this function when rpp_can_check_tx_pend() signals that no
+ * request is pending.
+ *
+ * @param[in] hw_obj Index of the hardware object to use for
+ * transmission. It is an index to rpp_can_config.tx_config.
*
* @param[in] pdu Message to send.
*
* @return @c SUCCESS if the message was successfully submitted for transmission,\n
- * @c -RPP_EINVAL if invalid hw_obj was specified,\n
- * @c -RPP_BUSY if previous transmission request is pending on the hardware object.
+ * @c -RPP_EINVAL if invalid hw_obj was specified.
+ *
*/
int8_t rpp_can_write(rpp_can_hw_obj hw_obj, const struct rpp_can_pdu *pdu);
/**
- * Checks whether a message was transmitted.
+ * Checks whether message transmission is pending.
*
* Call this function to check whether a message previously submitted
* for transmission with rpp_can_write() still waits for transmission
* or has already been transmitted to the bus.
* @param[in] hw_obj Hardware object to be checked.
- * @param[out] tx_con Where to store the TX confirmation flag. Its
+ * @param[out] tx_pend Where to store the TX pending flag. Its
* value will be @c true if a message waits for transmission and @c
* false otherwise.
- * @return @c SUCCESS if @a tx_con was updated with the requested value,\n
- * @c FAILURE if an error was detected.
+ * @return @c SUCCESS if @a tx_pend was updated with the requested value,\n
+ * @c FAILURE if an error was detected.
*/
-int8_t rpp_can_check_tx_con(rpp_can_hw_obj hw_obj, bool *tx_con);
+int8_t rpp_can_check_tx_pend(rpp_can_hw_obj hw_obj, bool *tx_pend);
/**
* Read a message from a message object.
int8_t rpp_can_write(rpp_can_hw_obj hw_obj, const struct rpp_can_pdu *pdu)
{
- uint32_t reg_index, bit_mask;
uint8_t i;
canBASE_t *controller;
struct rpp_can_tx_config *tx_cfg = &can_config->tx_config[hw_obj];
return -RPP_EINVAL;
}
- reg_index = (tx_cfg->msg_obj - 1) >> 5;
- bit_mask = 1 << ((tx_cfg->msg_obj - 1) & 0x1FU);
-
- // FIXME: Check whether sending should be aborted or message overwritten
- if (controller->TXRQx[reg_index] & bit_mask)
- {
- return -RPP_EBUSY;
- }
-
-
// Wait until IF1 is ready to use
while (controller->IF1STAT & (1U << 7));
}
-int8_t rpp_can_check_tx_con(rpp_can_hw_obj hw_obj, bool *tx_con)
+int8_t rpp_can_check_tx_pend(rpp_can_hw_obj hw_obj, bool *tx_pend)
{
uint32_t reg_index, bit_mask;
canBASE_t *controller;
reg_index = can_config->tx_config[hw_obj].msg_obj >> 5;
bit_mask = 1 << ((can_config->tx_config[hw_obj].msg_obj - 1) & 0x1FU);
- *tx_con = controller->TXRQx[reg_index] & bit_mask;
+ *tx_pend = controller->TXRQx[reg_index] & bit_mask;
return SUCCESS;
}