this is testing

Committer:
pmallick
Date:
Thu Jan 14 18:54:16 2021 +0530
Revision:
0:3afcd581558d
this is testing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pmallick 0:3afcd581558d 1 /***************************************************************************//**
pmallick 0:3afcd581558d 2 * @file timer.h
pmallick 0:3afcd581558d 3 * @brief Timer control module header.
pmallick 0:3afcd581558d 4 * @author Andrei Drimbarean (andrei.drimbarean@analog.com)
pmallick 0:3afcd581558d 5 ********************************************************************************
pmallick 0:3afcd581558d 6 * Copyright 2019(c) Analog Devices, Inc.
pmallick 0:3afcd581558d 7 *
pmallick 0:3afcd581558d 8 * All rights reserved.
pmallick 0:3afcd581558d 9 *
pmallick 0:3afcd581558d 10 * Redistribution and use in source and binary forms, with or without
pmallick 0:3afcd581558d 11 * modification, are permitted provided that the following conditions are met:
pmallick 0:3afcd581558d 12 * - Redistributions of source code must retain the above copyright
pmallick 0:3afcd581558d 13 * notice, this list of conditions and the following disclaimer.
pmallick 0:3afcd581558d 14 * - Redistributions in binary form must reproduce the above copyright
pmallick 0:3afcd581558d 15 * notice, this list of conditions and the following disclaimer in
pmallick 0:3afcd581558d 16 * the documentation and/or other materials provided with the
pmallick 0:3afcd581558d 17 * distribution.
pmallick 0:3afcd581558d 18 * - Neither the name of Analog Devices, Inc. nor the names of its
pmallick 0:3afcd581558d 19 * contributors may be used to endorse or promote products derived
pmallick 0:3afcd581558d 20 * from this software without specific prior written permission.
pmallick 0:3afcd581558d 21 * - The use of this software may or may not infringe the patent rights
pmallick 0:3afcd581558d 22 * of one or more patent holders. This license does not release you
pmallick 0:3afcd581558d 23 * from the requirement that you obtain separate licenses from these
pmallick 0:3afcd581558d 24 * patent holders to use this software.
pmallick 0:3afcd581558d 25 * - Use of the software either in source or binary form, must be run
pmallick 0:3afcd581558d 26 * on or directly connected to an Analog Devices Inc. component.
pmallick 0:3afcd581558d 27 *
pmallick 0:3afcd581558d 28 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED
pmallick 0:3afcd581558d 29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY
pmallick 0:3afcd581558d 30 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
pmallick 0:3afcd581558d 31 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
pmallick 0:3afcd581558d 32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
pmallick 0:3afcd581558d 33 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
pmallick 0:3afcd581558d 34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
pmallick 0:3afcd581558d 35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
pmallick 0:3afcd581558d 36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
pmallick 0:3afcd581558d 37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
pmallick 0:3afcd581558d 38 *******************************************************************************/
pmallick 0:3afcd581558d 39
pmallick 0:3afcd581558d 40 #ifndef SRC_TIMER_H_
pmallick 0:3afcd581558d 41 #define SRC_TIMER_H_
pmallick 0:3afcd581558d 42
pmallick 0:3afcd581558d 43 /******************************************************************************/
pmallick 0:3afcd581558d 44 /***************************** Include Files **********************************/
pmallick 0:3afcd581558d 45 /******************************************************************************/
pmallick 0:3afcd581558d 46
pmallick 0:3afcd581558d 47 #include <stdint.h>
pmallick 0:3afcd581558d 48
pmallick 0:3afcd581558d 49 /******************************************************************************/
pmallick 0:3afcd581558d 50 /*************************** Types Declarations *******************************/
pmallick 0:3afcd581558d 51 /******************************************************************************/
pmallick 0:3afcd581558d 52
pmallick 0:3afcd581558d 53 /**
pmallick 0:3afcd581558d 54 * @struct timer_desc
pmallick 0:3afcd581558d 55 * @brief Structure holding timer descriptor
pmallick 0:3afcd581558d 56 */
pmallick 0:3afcd581558d 57 struct timer_desc {
pmallick 0:3afcd581558d 58 /** timer ID */
pmallick 0:3afcd581558d 59 uint16_t id;
pmallick 0:3afcd581558d 60 /** timer count frequency (Hz) */
pmallick 0:3afcd581558d 61 uint32_t freq_hz;
pmallick 0:3afcd581558d 62 /** counter start value */
pmallick 0:3afcd581558d 63 uint32_t load_value;
pmallick 0:3afcd581558d 64 /** timer extra parameters (device specific) */
pmallick 0:3afcd581558d 65 void *extra;
pmallick 0:3afcd581558d 66 };
pmallick 0:3afcd581558d 67
pmallick 0:3afcd581558d 68 /**
pmallick 0:3afcd581558d 69 * @struct timer_init_param
pmallick 0:3afcd581558d 70 * @brief Structure holding the parameters for timer initialization
pmallick 0:3afcd581558d 71 */
pmallick 0:3afcd581558d 72 struct timer_init_param {
pmallick 0:3afcd581558d 73 /** timer ID */
pmallick 0:3afcd581558d 74 uint16_t id;
pmallick 0:3afcd581558d 75 /** timer count frequency (Hz) */
pmallick 0:3afcd581558d 76 uint32_t freq_hz;
pmallick 0:3afcd581558d 77 /** counter start value */
pmallick 0:3afcd581558d 78 uint32_t load_value;
pmallick 0:3afcd581558d 79 /** timer extra parameters (device specific) */
pmallick 0:3afcd581558d 80 void *extra;
pmallick 0:3afcd581558d 81 };
pmallick 0:3afcd581558d 82
pmallick 0:3afcd581558d 83 /******************************************************************************/
pmallick 0:3afcd581558d 84 /************************ Functions Declarations ******************************/
pmallick 0:3afcd581558d 85 /******************************************************************************/
pmallick 0:3afcd581558d 86
pmallick 0:3afcd581558d 87 /* Initialize hardware timer and the handler structure associated with it. */
pmallick 0:3afcd581558d 88 int32_t timer_init(struct timer_desc **desc,
pmallick 0:3afcd581558d 89 struct timer_init_param *param);
pmallick 0:3afcd581558d 90
pmallick 0:3afcd581558d 91 /* Free the memory allocated by timer_setup(). */
pmallick 0:3afcd581558d 92 int32_t timer_remove(struct timer_desc *desc);
pmallick 0:3afcd581558d 93
pmallick 0:3afcd581558d 94 /* Start a timer. */
pmallick 0:3afcd581558d 95 int32_t timer_start(struct timer_desc *desc);
pmallick 0:3afcd581558d 96
pmallick 0:3afcd581558d 97 /* Stop a timer from counting. */
pmallick 0:3afcd581558d 98 int32_t timer_stop(struct timer_desc *desc);
pmallick 0:3afcd581558d 99
pmallick 0:3afcd581558d 100 /* Get the value of the counter register for the timer. */
pmallick 0:3afcd581558d 101 int32_t timer_counter_get(struct timer_desc *desc, uint32_t *counter);
pmallick 0:3afcd581558d 102
pmallick 0:3afcd581558d 103 /* Set the timer counter register value. */
pmallick 0:3afcd581558d 104 int32_t timer_counter_set(struct timer_desc *desc, uint32_t new_val);
pmallick 0:3afcd581558d 105
pmallick 0:3afcd581558d 106 /* Get the timer clock frequency. */
pmallick 0:3afcd581558d 107 int32_t timer_count_clk_get(struct timer_desc *desc, uint32_t *freq_hz);
pmallick 0:3afcd581558d 108
pmallick 0:3afcd581558d 109 /* Set the timer clock frequency. */
pmallick 0:3afcd581558d 110 int32_t timer_count_clk_set(struct timer_desc *desc, uint32_t freq_hz);
pmallick 0:3afcd581558d 111
pmallick 0:3afcd581558d 112 #endif /* SRC_TIMER_H_ */
pmallick 0:3afcd581558d 113