File tree 1 file changed +7
-1
lines changed
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 19
19
#include " SERCOM.h"
20
20
#include " variant.h"
21
21
22
+ #ifndef WIRE_RISE_TIME_NANOSECONDS
23
+ // Default rise time in nanoseconds, based on 4.7K ohm pull up resistors
24
+ // you can override this value in your variant if needed
25
+ #define WIRE_RISE_TIME_NANOSECONDS 125
26
+ #endif
27
+
22
28
SERCOM::SERCOM (Sercom* s)
23
29
{
24
30
sercom = s;
@@ -445,7 +451,7 @@ void SERCOM::initMasterWIRE( uint32_t baudrate )
445
451
// sercom->I2CM.INTENSET.reg = SERCOM_I2CM_INTENSET_MB | SERCOM_I2CM_INTENSET_SB | SERCOM_I2CM_INTENSET_ERROR ;
446
452
447
453
// Synchronous arithmetic baudrate
448
- sercom->I2CM .BAUD .bit .BAUD = SystemCoreClock / ( 2 * baudrate) - 1 ;
454
+ sercom->I2CM .BAUD .bit .BAUD = SystemCoreClock / ( 2 * baudrate) - 5 - (((SystemCoreClock / 1000000 ) * WIRE_RISE_TIME_NANOSECONDS) / ( 2 * 1000 )) ;
449
455
}
450
456
451
457
void SERCOM::prepareNackBitWIRE ( void )
You can’t perform that action at this time.
0 commit comments