|
6 | 6 | /*! |
7 | 7 | @file adapter.cpp |
8 | 8 | @brief Adapters to treat M5HAL and TwoWire in the same way |
9 | | - @note Currently handles TwoWire directly, but will handle via M5HAL in the |
10 | | - future |
| 9 | + @note Currently handles TwoWire directly, but will handle via M5HAL in the future |
11 | 10 | */ |
12 | 11 | #include "adapter.hpp" |
13 | 12 | #include <cassert> |
@@ -56,10 +55,10 @@ class WireImpl : public Adapter::Impl { |
56 | 55 | public: |
57 | 56 | WireImpl(TwoWire& wire, const uint8_t addr) : Adapter::Impl(addr), _wire(&wire) |
58 | 57 | { |
59 | | - uint32_t w = (&wire == &Wire1); |
| 58 | + uint32_t w = (&wire != &Wire); |
60 | 59 | _sda = search_pin_number(idx_table[w][0]); |
61 | 60 | _scl = search_pin_number(idx_table[w][1]); |
62 | | - M5_LIB_LOGI("I2C SDA: %d, SCL: %d", _sda, _scl); |
| 61 | + M5_LIB_LOGI("I2C SDA:%d, SCL:%d", _sda, _scl); |
63 | 62 | } |
64 | 63 |
|
65 | 64 | virtual int16_t scl() const override |
@@ -96,8 +95,6 @@ class WireImpl : public Adapter::Impl { |
96 | 95 | virtual m5::hal::error::error_t readWithTransaction(uint8_t* data, const size_t len) override |
97 | 96 | { |
98 | 97 | assert(_addr); |
99 | | - //_wire->setClock(_clock); DON'T CALL |
100 | | - |
101 | 98 | if (data && _wire->requestFrom(_addr, len)) { |
102 | 99 | auto count = std::min(len, (size_t)_wire->available()); |
103 | 100 | for (size_t i = 0; i < count; ++i) { |
@@ -170,7 +167,7 @@ class WireImpl : public Adapter::Impl { |
170 | 167 | m5::hal::error::error_t write_with_transaction(const uint8_t addr, const uint8_t* data, const size_t len, |
171 | 168 | const bool stop) |
172 | 169 | { |
173 | | - _wire->setClock(_clock); // |
| 170 | + _wire->setClock(_clock); |
174 | 171 | _wire->beginTransmission(addr); |
175 | 172 | if (data) { |
176 | 173 | _wire->write(data, len); |
@@ -420,40 +417,3 @@ bool Adapter::popPin() |
420 | 417 |
|
421 | 418 | } // namespace unit |
422 | 419 | } // namespace m5 |
423 | | - |
424 | | -#if 0 |
425 | | -//CoreS3SE |
426 | | -18:02:03.752 > [ 3554][W][pin.cpp:65] restore(): restore pin:1 |
427 | | -18:02:03.758 > [ 3554][W][pin.cpp:67] restore(): restore IO_MUX_GPIO0_REG :00001a00 -> 00001b00 |
428 | | -18:02:03.766 > [ 3560][W][pin.cpp:69] restore(): restore GPIO_PIN0_REG :00000000 -> 00000004 |
429 | | -18:02:03.774 > [ 3568][W][pin.cpp:71] restore(): restore GPIO_FUNC0_OUT_SEL_CFG_REG:00000100 -> 00000059 |
430 | | -18:02:03.780 > [ 3576][W][pin.cpp:85] restore(): restore GPIO_ENABLE_REG:00001818 |
431 | | -18:02:03.784 > [ 3582][W][pin.cpp:65] restore(): restore pin:2 |
432 | | -18:02:03.792 > [ 3586][W][pin.cpp:67] restore(): restore IO_MUX_GPIO0_REG :00001a00 -> 00001b00 |
433 | | -18:02:03.800 > [ 3594][W][pin.cpp:69] restore(): restore GPIO_PIN0_REG :00000000 -> 00000004 |
434 | | -18:02:03.809 > [ 3602][W][pin.cpp:71] restore(): restore GPIO_FUNC0_OUT_SEL_CFG_REG:00000100 -> 0000005a |
435 | | -18:02:03.815 > [ 3611][W][pin.cpp:85] restore(): restore GPIO_ENABLE_REG:0000181a |
436 | | -18:02:03.822 > [ 3616][W][unit_MLX90614.cpp:311] start_periodic_measurement(): IIR:4 FIR:7 IT:140 |
437 | | -//NanoC6 |
438 | | -18:03:55.995 > [ 2432][W][pin.cpp:65] restore(): restore pin:1 |
439 | | -18:03:56.001 > [ 2432][W][pin.cpp:66] restore(): restore IO_MUX_GPIO0_REG :00001a02 -> 00001b02 |
440 | | -18:03:56.009 > [ 2439][W][pin.cpp:68] restore(): restore GPIO_PIN0_REG :00000000 -> 00000004 |
441 | | -18:03:56.017 > [ 2447][W][pin.cpp:70] restore(): restore GPIO_FUNC0_OUT_SEL_CFG_REG:00000080 -> 0000002d |
442 | | -18:03:56.023 > [ 2455][W][pin.cpp:85] restore(): restore GPIO_ENABLE_REG:00000000 |
443 | | -18:03:56.027 > [ 2461][W][pin.cpp:65] restore(): restore pin:2 |
444 | | -18:03:56.035 > [ 2465][W][pin.cpp:66] restore(): restore IO_MUX_GPIO0_REG :00001a02 -> 00001b02 |
445 | | -18:03:56.044 > [ 2473][W][pin.cpp:68] restore(): restore GPIO_PIN0_REG :00000000 -> 00000004 |
446 | | -18:03:56.051 > [ 2481][W][pin.cpp:70] restore(): restore GPIO_FUNC0_OUT_SEL_CFG_REG:00000080 -> 0000002e |
447 | | -18:03:56.058 > [ 2489][W][pin.cpp:85] restore(): restore GPIO_ENABLE_REG:00000002 |
448 | | -//Core |
449 | | -18:24:54.954 > [ 2690][W][pin.cpp:64] restore(): restore pin:22 |
450 | | -18:24:54.959 > [ 2690][W][pin.cpp:66] restore(): restore IO_MUX_GPIO0_REG :00002a08 -> 00002b08 |
451 | | -18:24:54.970 > [ 2697][W][pin.cpp:68] restore(): restore GPIO_PIN0_REG :00000000 -> 00000004 |
452 | | -18:24:54.975 > [ 2705][W][pin.cpp:70] restore(): restore GPIO_FUNC0_OUT_SEL_CFG_REG:00000100 -> 0000001d |
453 | | -18:24:54.987 > [ 2713][W][pin.cpp:84] restore(): restore GPIO_ENABLE_REG:0a84cf90 |
454 | | -18:24:54.992 > [ 2719][W][pin.cpp:64] restore(): restore pin:21 |
455 | | -18:24:54.998 > [ 2723][W][pin.cpp:66] restore(): restore IO_MUX_GPIO0_REG :00002a08 -> 00002b08 |
456 | | -18:24:55.003 > [ 2731][W][pin.cpp:68] restore(): restore GPIO_PIN0_REG :00000000 -> 00000004 |
457 | | -18:24:55.009 > [ 2739][W][pin.cpp:70] restore(): restore GPIO_FUNC0_OUT_SEL_CFG_REG:00000100 -> 0000001e |
458 | | -18:24:55.020 > [ 2747][W][pin.cpp:84] restore(): restore GPIO_ENABLE_REG:0ac4cf90 |
459 | | -#endif |
0 commit comments