4c880f4b0a
RTC drivers should validate the `struct rtc_time`'s contents against the provided `mask`. Promote this common code to a new rtc_utils file and modify existing drivers to use this functionality. Extend the test coverage to include verifying this behaviour. This is groundwork ahead of adding support for the RP2040's (as used in the Raspberry Pi Pico) RTC and alarm. Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
29 lines
671 B
C
29 lines
671 B
C
/*
|
|
* Copyright (c) 2023 Bjarki Arge Andreasen
|
|
* Copyright (c) 2024 Andrew Featherstone
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#ifndef ZEPHYR_DRIVERS_RTC_RTC_UTILS_H_
|
|
#define ZEPHYR_DRIVERS_RTC_RTC_UTILS_H_
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include <zephyr/drivers/rtc.h>
|
|
|
|
/**
|
|
* @brief Validate a datetime with a mask
|
|
*
|
|
* Ensure that any fields selected by mask contain a valid value.
|
|
*
|
|
* @param timeptr The time to set
|
|
* @param mask Mask of fields to validate
|
|
*
|
|
* @return true if the required fields are valid.
|
|
*/
|
|
bool rtc_utils_validate_rtc_time(const struct rtc_time *timeptr, uint16_t mask);
|
|
|
|
#endif /* ZEPHYR_DRIVERS_RTC_RTC_UTILS_H_ */
|