]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
Make rpp_can_write() not to fail when previous TX request is pending
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 22 Oct 2014 16:01:12 +0000 (18:01 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 22 Oct 2014 16:01:12 +0000 (18:01 +0200)
Instead, the previous request is overwritten.

Also change the name of tx_con() to tx_pend(), which is more descriptive.

Needs to be tested: #1027

rpp/include/rpp/can.h
rpp/src/rpp/can.c

index 01b9b7c4d0d8933f242c6f9b3a3d8b24c53d5cda..8732d5b73b57765a3ae6e4c4964b963051fea768 100644 (file)
@@ -160,35 +160,41 @@ int8_t rpp_can_init(const struct rpp_can_config *config);
 /**
  * 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.
index 2faf97ed2fd4b735e28e6ba5a8091545f343406d..27f4aef31092e3a6f3ee637807add08ecd78834b 100644 (file)
@@ -633,7 +633,6 @@ int8_t rpp_can_init(const struct rpp_can_config *config)
 
 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];
@@ -643,16 +642,6 @@ int8_t rpp_can_write(rpp_can_hw_obj hw_obj, const struct rpp_can_pdu *pdu)
         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));
 
@@ -687,7 +676,7 @@ int8_t rpp_can_write(rpp_can_hw_obj hw_obj, const struct rpp_can_pdu *pdu)
 }
 
 
-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;
@@ -700,7 +689,7 @@ int8_t rpp_can_check_tx_con(rpp_can_hw_obj hw_obj, bool *tx_con)
     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;
 }