zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.5k stars 6.43k forks source link

OS flag never cleared in RV-8263-C8 driver #77602

Open Kampi opened 2 weeks ago

Kampi commented 2 weeks ago

Describe the bug

rtc_get_time returns error -61 when reading the time from a RV-8263-C8 RTC which means that the OS flag is set.

To Reproduce

Use the rtc_get_time API call with a RV-8263-C8 device.

Expected behavior

OS flag should be cleared when reading the time and the flag is set so the next read will be successful.

Environment (please complete the following information)

Additional context

The OS flag is never cleared and so the oscillator doesn´t run anymore if the flag is set. The flag must be cleared by software.

@jakubtopic We missed this in our initial discussion about the OS flag. There is an issue that get_time doesn´t work anymore as soon as the flag is set. I would like solve this issue in this way in rv8263c8_time_get:

    /* Return an error when the oscillator is stopped. */
    if (regs[0] & RV8263_BM_OS) {
        /* Clear the OS flag. */
        regs[0] &= ~RV8263_BM_OS;
        i2c_reg_write_byte_dt(&config->i2c_bus, RV8263C8_REGISTER_SECONDS, &regs[0]);
        return -ENODATA;
    }

So the application get´s an error when the flag is set and the flag is reset. If this error happens again the application will get the same error again.

What do you think? I think it´s the best way to handle it because you have to clear it by software every time.

henrikbrixandersen commented 2 weeks ago

Please use our bug template when reporting bugs. You need to edit this issue to include the information requested in https://github.com/zephyrproject-rtos/zephyr/blob/main/.github/ISSUE_TEMPLATE/001_bug_report.md