/** * @brief Writes data to a serial interface. * @param data1 : 1st buffer * @param data2 : 2nd buffer * @param n_bytes1: number of bytes in 1st buffer * @param n_bytes2: number of bytes in 2nd buffer * @retval None */ void Hal_Write_Serial(const void *data1, const void *data2, int32_t n_bytes1, int32_t n_bytes2) { struct timer t; Timer_Set(&t, CLOCK_SECOND / 10); #ifdef PRINT_CSV_FORMAT PRINT_CSV("00:00:00.000"); for (int i = 0; i < n_bytes1; i++) { PRINT_CSV(" %02x", ((uint8_t *) data1)[i]); } for (int i = 0; i < n_bytes2; i++) { PRINT_CSV(" %02x", ((uint8_t *) data2)[i]); } PRINT_CSV("\n"); #endif while (1) { if (BlueNRG_SPI_Write (&SpiHandle, (uint8_t *) data1, (uint8_t *) data2, n_bytes1, n_bytes2) == 0) break; if (Timer_Expired(&t)) { break; } } }
/** * @brief Writes data to a serial interface. * @param data1 : 1st buffer * @param data2 : 2nd buffer * @param n_bytes1: number of bytes in 1st buffer * @param n_bytes2: number of bytes in 2nd buffer * @retval None */ void Hal_Write_Serial(const void* data1, const void* data2, int32_t n_bytes1, int32_t n_bytes2) { /* New implementation (with DMA write) */ BlueNRG_SPI_Write((uint8_t *)data1,(uint8_t *)data2, n_bytes1, n_bytes2); }