File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -698,6 +698,30 @@ struct SPIDomain {
698698 return check_error_code (error_code);
699699 }
700700
701+ /* *
702+ * @brief Sends and receives data over SPI in blocking mode.
703+ */
704+ template <typename T>
705+ bool transceive (T *tx_data, T *rx_data, size_t count) {
706+ size_t size = count * sizeof (T);
707+ if (size % frame_size != 0 ) {
708+ ErrorHandler (
709+ " SPI transaction size (%d) not aligned to frame size (%d)" ,
710+ size,
711+ frame_size
712+ );
713+ return false ;
714+ }
715+ auto error_code = HAL_SPI_TransmitReceive (
716+ &spi_instance.hspi ,
717+ (uint8_t *)tx_data,
718+ (uint8_t *)rx_data,
719+ size / frame_size,
720+ 10
721+ );
722+ return check_error_code (error_code);
723+ }
724+
701725 /* *
702726 * @brief Sends and receives a trivially copyable data type over SPI in blocking mode.
703727 */
You can’t perform that action at this time.
0 commit comments