Re: RFC: Counter driver API
Tseng, Kuo-Lang <kuo-lang.tseng@...>
Sure. Below are a summary of the API and changes. Please let me know if anything else needs to be mentioned and I can add.
toggle quoted message
Show quoted text
The generic counter API will support 4 functions as summarized below. Based on this, the change includes implementation of the following 3 parts: 1) A generic counter API - this implements the counter.h in a counter driver framework. 2) Quark-specific counter drivers - implements the counter API for AON counter and AON timer devices in Quark. 3) A sample application that demonstrates the use of the generic counter API for counter usages. The old patch (https://gerrit.zephyrproject.org/r/#/c/474/) will be updated based on above three parts. The generic counter API that has feedback incorporated: /** * Start the counter device. If the device is a 'count up' counter the * counter initial value is set to zero. If it is a 'countdown' counter * the initial value is set to the maximum value supported by the device. * * @brief Start counter device in free running mode. * @param dev Pointer to the device structure for the driver instance. * @retval DEV_OK If successful. * @retval DEV_* Code otherwise. */ int counter_start(struct device *dev); /** * @brief Stop counter device. If alarm was set, this function also clears * the alarm setting. * @param dev Pointer to the device structure for the driver instance. * * @retval DEV_OK If successful. * @retval DEV_NO_SUPPORT if the device doesn't support stopping the * counter (e.g. free running counters). */ int counter_stop(struct device *dev); /** * @brief Read current counter value * @param dev Pointer to the device structure for the driver instance. * * @return 32-bit value */ uint32_t counter_read(struct device *dev); /** * Set an alarm. * * @brief Set an alarm. * @param dev Pointer to the device structure for the driver instance. * @param callback Pointer to the callback function. If this is NULL, this function * unsets the alarm. * @param count Number of counter ticks. * @param user_data pointer to user data * * @retval DEV_OK If successful. * @retval DEV_INVALID_OP If the counter was not started yet. * @retval DEV_NO_SUPPORT if the device doesn't support interrupt (e.g. * free running counters). */ int counter_set_alarm(struct device *dev, counter_callback_t callback, uint32_t count, void *user_data); typedef void (*counter_callback_t)(struct device *dev, void *user_data) -----Original Message----- |
|