zephyr/drivers/clock_control/nrf_clock_calibration.h
Krzysztof Chruscinski 6700f2f194 drivers: clock_control: nrf: reimplementation including API updates
Reimplementation of clock control driver for nrf platform. It includes
latest API changes: asynchronous starting and getting clock status.

Additionally, it implements calibration algorithm which optionally
skips calibration based on no temperature change. Internal temperature
sensor is used for that.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-10-04 17:15:39 +02:00

69 lines
1.5 KiB
C

/*
* Copyright (c) 2019 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_DRIVERS_CLOCK_CONTROL_NRF_CLOCK_CALIBRATION_H_
#define ZEPHYR_DRIVERS_CLOCK_CONTROL_NRF_CLOCK_CALIBRATION_H_
#include <device.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize LFCLK RC calibration.
*
* @param hfclk_dev HFCLK device.
*/
void z_nrf_clock_calibration_init(struct device *hfclk_dev);
/**
* @brief Calibration interrupts handler
*
* Must be called from clock interrupt context.
*/
void z_nrf_clock_calibration_isr(void);
/**
* @brief Start calibration.
*
* Function called when LFCLK RC clock is being started.
*
* @param dev LFCLK device.
*
* @retval true if clock can be started.
* @retval false if clock was not stopped due to ongoing calibration and don't
* need to be started again because it is still on.
*/
bool z_nrf_clock_calibration_start(struct device *dev);
/**
* @brief Notify calibration module about LF clock start
*
* @param dev LFCLK device.
*/
void z_nrf_clock_calibration_lfclk_started(struct device *dev);
/**
* @brief Stop calibration.
*
* Function called when LFCLK RC clock is being stopped.
*
* @param dev LFCLK device.
*
* @retval true if clock can be stopped.
* @retval false if due to ongoing calibration clock cannot be stopped. In that
* case calibration module will stop clock when calibration is
* completed.
*/
bool z_nrf_clock_calibration_stop(struct device *dev);
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_DRIVERS_CLOCK_CONTROL_NRF_CLOCK_CALIBRATION_H_ */