テスト用のあれこれ共用フォルダ
Revision | bdeb9eaa67166f4dabbabdba88c91fed14587354 (tree) |
---|---|
Time | 2018-02-20 07:09:59 |
Author | takemasa <suikan@user...> |
Commiter | takemasa |
Added error printing to UART
@@ -105,6 +105,15 @@ public: | ||
105 | 105 | * and return true. If it doesn't match, just return false. |
106 | 106 | */ |
107 | 107 | 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; | |
108 | 117 | }; |
109 | 118 | /** |
110 | 119 | * \} |
@@ -165,6 +165,25 @@ bool Uart::ReceiveCompleteCallback(void* ptr) | ||
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
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 | + | |
168 | 187 | } /* namespace platform */ |
169 | 188 | |
170 | 189 | #endif // HAL_UART_MODULE_ENABLED |
@@ -169,6 +169,16 @@ class Uart : public AbstractUart | ||
169 | 169 | * This method have to be called from HAL_UART_RxCpltCallback(). See STM32F7 HAL manual for detail */ |
170 | 170 | |
171 | 171 | 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); | |
172 | 182 | protected: |
173 | 183 | UART_HandleTypeDef* uart_; |
174 | 184 |