From 63cbb8facd9d9dc016f902bb312283f0b5f8d055 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 26 Oct 2018 08:58:18 +0200 Subject: Merge SoftI2C timer={0,1} code paths, adjust timing according to I2C spec It's occasionally slower than specified, but should never be too fast --- src/arch/msp430fr5969lp/arch.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/arch') diff --git a/src/arch/msp430fr5969lp/arch.cc b/src/arch/msp430fr5969lp/arch.cc index cde0503..1eb34b5 100644 --- a/src/arch/msp430fr5969lp/arch.cc +++ b/src/arch/msp430fr5969lp/arch.cc @@ -104,8 +104,14 @@ volatile char run_loop = 0; void Arch::delay_us(unsigned int const us) { - for (unsigned int i = 0; i < us/10; i++) { - __delay_cycles(F_CPU / 100000UL); + if (us < 10) { + for (unsigned int i = 0; i < us; i++) { + __delay_cycles(F_CPU / 1000000UL); + } + } else { + for (unsigned int i = 0; i < us/10; i++) { + __delay_cycles(F_CPU / 100000UL); + } } } void Arch::delay_ms(unsigned int const ms) -- cgit v1.2.3