• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

テスト用のあれこれ共用フォルダ


Commit MetaInfo

Revisionbdeb9eaa67166f4dabbabdba88c91fed14587354 (tree)
Time2018-02-20 07:09:59
Authortakemasa <suikan@user...>
Commitertakemasa

Log Message

Added error printing to UART

Change Summary

Incremental Difference

--- a/stm32_development/murasaki/murasaki/abstractuart.hpp
+++ b/stm32_development/murasaki/murasaki/abstractuart.hpp
@@ -105,6 +105,15 @@ public:
105105 * and return true. If it doesn't match, just return false.
106106 */
107107 virtual bool ReceiveCompleteCallback(void* ptr) = 0;
108+ /**
109+ * @brief Handling error report of device.
110+ * @param ptr Pointer for generic use. Usually, points a struct of a UART device control
111+ * @return true if ptr matches with UART device and handle the error. false if ptr doesn7t match
112+ * A member function to detect error.
113+ *
114+ * The error handling is depend on the implementation.
115+ */
116+ virtual bool HandleError(void * ptr)= 0;
108117 };
109118 /**
110119 * \}
--- a/stm32_development/murasaki/murasaki/uart.cpp
+++ b/stm32_development/murasaki/murasaki/uart.cpp
@@ -165,6 +165,25 @@ bool Uart::ReceiveCompleteCallback(void* ptr)
165165 }
166166 }
167167
168+bool Uart::HandleError(void* ptr)
169+{
170+ MURASAKI_ASSERT(NULL != ptr)
171+
172+ if (uart_ == ptr) {
173+ // Check error, and print if exist.
174+ MURASAKI_PRINT_ERROR(uart_->ErrorCode & HAL_UART_ERROR_DMA);
175+ MURASAKI_PRINT_ERROR(uart_->ErrorCode & HAL_UART_ERROR_PE);
176+ MURASAKI_PRINT_ERROR(uart_->ErrorCode & HAL_UART_ERROR_NE);
177+ MURASAKI_PRINT_ERROR(uart_->ErrorCode & HAL_UART_ERROR_FE);
178+ MURASAKI_PRINT_ERROR(uart_->ErrorCode & HAL_UART_ERROR_ORE);
179+ MURASAKI_PRINT_ERROR(uart_->ErrorCode & HAL_UART_ERROR_DMA);
180+ return true; // report the ptr matched
181+ }
182+ else {
183+ return false; // report the ptr doesn't match
184+ }
185+}
186+
168187 } /* namespace platform */
169188
170189 #endif // HAL_UART_MODULE_ENABLED
--- a/stm32_development/murasaki/murasaki/uart.hpp
+++ b/stm32_development/murasaki/murasaki/uart.hpp
@@ -169,6 +169,16 @@ class Uart : public AbstractUart
169169 * This method have to be called from HAL_UART_RxCpltCallback(). See STM32F7 HAL manual for detail */
170170
171171 virtual bool ReceiveCompleteCallback(void* ptr);
172+ /**
173+ * @brief Error handling
174+ * @param ptr Pointer to UART_HandleTypeDef struct.
175+ * \return true: ptr matches with UART device and handle the error. false : doesn't match.
176+ * @details
177+ * A handle to print out the error message.
178+ *
179+ * Checks whether handle has error and if there is, print appropriate error. Then return.
180+ */
181+ virtual bool HandleError(void * ptr);
172182 protected:
173183 UART_HandleTypeDef* uart_;
174184