@@ -427,12 +427,7 @@ void i2c_attachSlaveRxEvent(i2c_t *obj, void (*function)(uint8_t*, int) )
427
427
return ;
428
428
429
429
obj -> i2c_onSlaveReceive = function ;
430
- #ifdef STM32F1xx
431
- obj -> i2cTxRxBufferSize = 0 ;
432
- HAL_I2C_Slave_Receive_IT (& (obj -> handle ), obj -> i2cTxRxBuffer , I2C_TXRX_BUFFER_SIZE );
433
- #else
434
430
HAL_I2C_EnableListen_IT (& (obj -> handle ));
435
- #endif
436
431
}
437
432
438
433
/** @brief sets function called before a slave write operation
@@ -446,60 +441,9 @@ void i2c_attachSlaveTxEvent(i2c_t *obj, void (*function)(void) )
446
441
return ;
447
442
448
443
obj -> i2c_onSlaveTransmit = function ;
449
- #ifdef STM32F1xx
450
- /* Fill i2c buffer with data to transmit otherwize the buffer will be empty
451
- when master will read the data for the first time */
452
- obj -> i2cTxRxBufferSize = 0 ;
453
- obj -> i2c_onSlaveTransmit ();
454
- HAL_I2C_Slave_Transmit_IT (& (obj -> handle ), obj -> i2cTxRxBuffer , obj -> i2cTxRxBufferSize );
455
- #else
456
444
HAL_I2C_EnableListen_IT (& (obj -> handle ));
457
- #endif
458
- }
459
-
460
- #ifdef STM32F1xx
461
-
462
- /** @brief Slave Tx Transfer completed callback.
463
- * @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
464
- * the configuration information for the specified I2C.
465
- * @retval None
466
- */
467
- void HAL_I2C_SlaveTxCpltCallback (I2C_HandleTypeDef * hi2c )
468
- {
469
- i2c_t * obj = get_i2c_obj (hi2c );
470
-
471
- if (NULL != obj -> i2c_onSlaveTransmit ) {
472
- // reset buffer size and fill buffer with new data before the next Tx
473
- obj -> i2cTxRxBufferSize = 0 ;
474
- obj -> i2c_onSlaveTransmit ();
475
- HAL_I2C_Slave_Transmit_IT (hi2c , obj -> i2cTxRxBuffer , obj -> i2cTxRxBufferSize );
476
- }
477
- }
478
-
479
- /**
480
- * @brief Slave Rx Transfer completed callback.
481
- * @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
482
- * the configuration information for the specified I2C.
483
- * @retval None
484
- */
485
- void HAL_I2C_SlaveRxCpltCallback (I2C_HandleTypeDef * hi2c )
486
- {
487
- uint8_t nbData = 0 ;
488
- i2c_t * obj = get_i2c_obj (hi2c );
489
-
490
- if (NULL != obj -> i2c_onSlaveReceive ) {
491
- nbData = I2C_TXRX_BUFFER_SIZE - obj -> handle .XferCount ;
492
-
493
- if (nbData != 0 ) {
494
- obj -> i2c_onSlaveReceive (obj -> i2cTxRxBuffer , nbData );
495
- }
496
-
497
- HAL_I2C_Slave_Receive_IT (hi2c , obj -> i2cTxRxBuffer , I2C_TXRX_BUFFER_SIZE );
498
- }
499
445
}
500
446
501
- #else /* Others */
502
-
503
447
/**
504
448
* @brief Slave Address Match callback.
505
449
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
@@ -552,8 +496,6 @@ void HAL_I2C_ListenCpltCallback(I2C_HandleTypeDef *hi2c)
552
496
HAL_I2C_EnableListen_IT (hi2c );
553
497
}
554
498
555
- #endif /* STM32F1xx */
556
-
557
499
/**
558
500
* @brief I2C error callback.
559
501
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
@@ -562,11 +504,7 @@ void HAL_I2C_ListenCpltCallback(I2C_HandleTypeDef *hi2c)
562
504
*/
563
505
void HAL_I2C_ErrorCallback (I2C_HandleTypeDef * hi2c )
564
506
{
565
- #ifdef STM32F1xx
566
- UNUSED (hi2c );
567
- #else
568
507
HAL_I2C_EnableListen_IT (hi2c );
569
- #endif
570
508
}
571
509
572
510
/**
0 commit comments