diff options
author | Anastasiia Lazareva <n_lazareva@mail.ru> | 2017-09-08 16:28:18 +0300 |
---|---|---|
committer | Anastasiia Lazareva <n_lazareva@mail.ru> | 2017-09-08 16:28:18 +0300 |
commit | 8b4f4013377f1df23caaaafa15b49dee367ccbf5 (patch) | |
tree | 24fa2d27d3ace91182e23843baad03461dad8c7a | |
parent | 8d0a56d28c77a1bbc6319de2ee1fab60383a9bf7 (diff) |
TEMPORARY REMOVED TIMER FROM I2C
-rw-r--r-- | cm3cpp_i2c.cpp | 82 | ||||
-rw-r--r-- | cm3cpp_i2c.h | 2 |
2 files changed, 45 insertions, 39 deletions
diff --git a/cm3cpp_i2c.cpp b/cm3cpp_i2c.cpp index e06577f..b818254 100644 --- a/cm3cpp_i2c.cpp +++ b/cm3cpp_i2c.cpp @@ -53,7 +53,7 @@ I2c::I2c(Config i2c_conf) #ifndef FREERTOS _counter_ms->init(systick::Counter::Mode::ONE_SHOT, MAX_TRANSMIT_TIME_MS); #else - _counter_ms = new timers::OneShotTimer(MAX_TRANSMIT_TIME_MS); + //_counter_ms = new timers::OneShotTimer(MAX_TRANSMIT_TIME_MS); #endif } @@ -171,20 +171,22 @@ auto I2c::master_transfer(MasterTransferCfg cfg) -> Result //_counter_ms->start(); _send_start(); - while (_get_flag_status(MASTER_MODE_SELECTED) == Result::ERROR) { - if(_counter_ms->timeout()) { - result = TIMEOUT; - break; - } - } + while (_get_flag_status(MASTER_MODE_SELECTED) == Result::ERROR); +// { +// if(_counter_ms->timeout()) { +// result = TIMEOUT; +// break; +// } +// } _send_7bit_address(cfg.device_address, WRITE); - while (_get_flag_status(MASTER_TRANSMITTER_MODE_SELECTED) == Result::ERROR) { - if(_counter_ms->timeout()) { - result = TIMEOUT; - break; - } - } + while (_get_flag_status(MASTER_TRANSMITTER_MODE_SELECTED) == Result::ERROR); +// { +// if(_counter_ms->timeout()) { +// result = TIMEOUT; +// break; +// } +// } uint8_t index = 0; @@ -192,12 +194,13 @@ auto I2c::master_transfer(MasterTransferCfg cfg) -> Result { _send_data(cfg.write_buf[index]); - while (_get_flag_status(MASTER_BYTE_TRANSMITTED) == Result::ERROR) { - if(_counter_ms->timeout()) { - result = TIMEOUT; - break; - } - } + while (_get_flag_status(MASTER_BYTE_TRANSMITTED) == Result::ERROR); +// { +// if(_counter_ms->timeout()) { +// result = TIMEOUT; +// break; +// } +// } cfg.write_len--; index++; @@ -206,22 +209,24 @@ auto I2c::master_transfer(MasterTransferCfg cfg) -> Result uint16_t temp; if(cfg.read_len != 0) { _send_start(); - while (_get_flag_status(MASTER_MODE_SELECTED) == Result::ERROR) { - if(_counter_ms->timeout()) { - result = TIMEOUT; - break; - } - } + while (_get_flag_status(MASTER_MODE_SELECTED) == Result::ERROR); +// { +// if(_counter_ms->timeout()) { +// result = TIMEOUT; +// break; +// } +// } _enable_ack(); _send_7bit_address(cfg.device_address, READ); - while (_get_flag_status(MASTER_RECEIVER_MODE_SELECTED) == Result::ERROR) { - if(_counter_ms->timeout()) { - result = TIMEOUT; - break; - } - } + while (_get_flag_status(MASTER_RECEIVER_MODE_SELECTED) == Result::ERROR); +// { +// if(_counter_ms->timeout()) { +// result = TIMEOUT; +// break; +// } +// } uint8_t size_to_read = cfg.read_len; index = 0; @@ -231,12 +236,13 @@ auto I2c::master_transfer(MasterTransferCfg cfg) -> Result size_to_read--; if (!size_to_read) _disable_ack(); - while (_get_flag_status(MASTER_BYTE_RECEIVED) == Result::ERROR) { - if(_counter_ms->timeout()) { - result = TIMEOUT; - break; - } - } + while (_get_flag_status(MASTER_BYTE_RECEIVED) == Result::ERROR); +// { +// if(_counter_ms->timeout()) { +// result = TIMEOUT; +// break; +// } +// } uint8_t data = _get_data(); cfg.read_buf[index] = data; @@ -245,7 +251,7 @@ auto I2c::master_transfer(MasterTransferCfg cfg) -> Result } _send_stop(); - _counter_ms->stop(); + //_counter_ms->stop(); return result; } diff --git a/cm3cpp_i2c.h b/cm3cpp_i2c.h index 1a95d67..81bd2e9 100644 --- a/cm3cpp_i2c.h +++ b/cm3cpp_i2c.h @@ -199,7 +199,7 @@ private: #ifndef FREERTOS systick::Counter *_counter_ms; #else - timers::OneShotTimer *_counter_ms; + //timers::OneShotTimer *_counter_ms; #endif void _send_start(); |