File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 1919#include " SERCOM.h"
2020#include " variant.h"
2121
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+
2228SERCOM::SERCOM (Sercom* s)
2329{
2430 sercom = s;
@@ -445,7 +451,7 @@ void SERCOM::initMasterWIRE( uint32_t baudrate )
445451// sercom->I2CM.INTENSET.reg = SERCOM_I2CM_INTENSET_MB | SERCOM_I2CM_INTENSET_SB | SERCOM_I2CM_INTENSET_ERROR ;
446452
447453 // 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 )) ;
449455}
450456
451457void SERCOM::prepareNackBitWIRE ( void )
You can’t perform that action at this time.
0 commit comments