Pratyush Mallick
/
nano_dac
this is testing
noos_mbed/include/clk.h@0:e8a1ba50c46b, 2021-01-14 (annotated)
- Committer:
- pmallick
- Date:
- Thu Jan 14 19:12:57 2021 +0530
- Revision:
- 0:e8a1ba50c46b
this is testing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pmallick | 0:e8a1ba50c46b | 1 | /***************************************************************************//** |
pmallick | 0:e8a1ba50c46b | 2 | * @file clk.h |
pmallick | 0:e8a1ba50c46b | 3 | * @brief Header file of Clock Driver. |
pmallick | 0:e8a1ba50c46b | 4 | * @author DBogdan (dragos.bogdan@analog.com) |
pmallick | 0:e8a1ba50c46b | 5 | ******************************************************************************** |
pmallick | 0:e8a1ba50c46b | 6 | * Copyright 2020(c) Analog Devices, Inc. |
pmallick | 0:e8a1ba50c46b | 7 | * |
pmallick | 0:e8a1ba50c46b | 8 | * All rights reserved. |
pmallick | 0:e8a1ba50c46b | 9 | * |
pmallick | 0:e8a1ba50c46b | 10 | * Redistribution and use in source and binary forms, with or without |
pmallick | 0:e8a1ba50c46b | 11 | * modification, are permitted provided that the following conditions are met: |
pmallick | 0:e8a1ba50c46b | 12 | * - Redistributions of source code must retain the above copyright |
pmallick | 0:e8a1ba50c46b | 13 | * notice, this list of conditions and the following disclaimer. |
pmallick | 0:e8a1ba50c46b | 14 | * - Redistributions in binary form must reproduce the above copyright |
pmallick | 0:e8a1ba50c46b | 15 | * notice, this list of conditions and the following disclaimer in |
pmallick | 0:e8a1ba50c46b | 16 | * the documentation and/or other materials provided with the |
pmallick | 0:e8a1ba50c46b | 17 | * distribution. |
pmallick | 0:e8a1ba50c46b | 18 | * - Neither the name of Analog Devices, Inc. nor the names of its |
pmallick | 0:e8a1ba50c46b | 19 | * contributors may be used to endorse or promote products derived |
pmallick | 0:e8a1ba50c46b | 20 | * from this software without specific prior written permission. |
pmallick | 0:e8a1ba50c46b | 21 | * - The use of this software may or may not infringe the patent rights |
pmallick | 0:e8a1ba50c46b | 22 | * of one or more patent holders. This license does not release you |
pmallick | 0:e8a1ba50c46b | 23 | * from the requirement that you obtain separate licenses from these |
pmallick | 0:e8a1ba50c46b | 24 | * patent holders to use this software. |
pmallick | 0:e8a1ba50c46b | 25 | * - Use of the software either in source or binary form, must be run |
pmallick | 0:e8a1ba50c46b | 26 | * on or directly connected to an Analog Devices Inc. component. |
pmallick | 0:e8a1ba50c46b | 27 | * |
pmallick | 0:e8a1ba50c46b | 28 | * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR |
pmallick | 0:e8a1ba50c46b | 29 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, |
pmallick | 0:e8a1ba50c46b | 30 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
pmallick | 0:e8a1ba50c46b | 31 | * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, |
pmallick | 0:e8a1ba50c46b | 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
pmallick | 0:e8a1ba50c46b | 33 | * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR |
pmallick | 0:e8a1ba50c46b | 34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
pmallick | 0:e8a1ba50c46b | 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
pmallick | 0:e8a1ba50c46b | 36 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
pmallick | 0:e8a1ba50c46b | 37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
pmallick | 0:e8a1ba50c46b | 38 | *******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 39 | #ifndef CLK_H_ |
pmallick | 0:e8a1ba50c46b | 40 | #define CLK_H_ |
pmallick | 0:e8a1ba50c46b | 41 | |
pmallick | 0:e8a1ba50c46b | 42 | /******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 43 | /***************************** Include Files **********************************/ |
pmallick | 0:e8a1ba50c46b | 44 | /******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 45 | #include <stdint.h> |
pmallick | 0:e8a1ba50c46b | 46 | |
pmallick | 0:e8a1ba50c46b | 47 | /******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 48 | /************************* Structure Declarations *****************************/ |
pmallick | 0:e8a1ba50c46b | 49 | /******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 50 | struct clk_hw { |
pmallick | 0:e8a1ba50c46b | 51 | void *dev; |
pmallick | 0:e8a1ba50c46b | 52 | int32_t (*dev_clk_enable)(); |
pmallick | 0:e8a1ba50c46b | 53 | int32_t (*dev_clk_disable)(); |
pmallick | 0:e8a1ba50c46b | 54 | int32_t (*dev_clk_recalc_rate)(); |
pmallick | 0:e8a1ba50c46b | 55 | int32_t (*dev_clk_set_rate)(); |
pmallick | 0:e8a1ba50c46b | 56 | int32_t (*dev_clk_round_rate)(); |
pmallick | 0:e8a1ba50c46b | 57 | }; |
pmallick | 0:e8a1ba50c46b | 58 | |
pmallick | 0:e8a1ba50c46b | 59 | struct clk { |
pmallick | 0:e8a1ba50c46b | 60 | struct clk_hw *hw; |
pmallick | 0:e8a1ba50c46b | 61 | uint32_t hw_ch_num; |
pmallick | 0:e8a1ba50c46b | 62 | const char *name; |
pmallick | 0:e8a1ba50c46b | 63 | }; |
pmallick | 0:e8a1ba50c46b | 64 | |
pmallick | 0:e8a1ba50c46b | 65 | /******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 66 | /************************ Functions Declarations ******************************/ |
pmallick | 0:e8a1ba50c46b | 67 | /******************************************************************************/ |
pmallick | 0:e8a1ba50c46b | 68 | |
pmallick | 0:e8a1ba50c46b | 69 | /* Start the clock. */ |
pmallick | 0:e8a1ba50c46b | 70 | int32_t clk_enable(struct clk * clk); |
pmallick | 0:e8a1ba50c46b | 71 | |
pmallick | 0:e8a1ba50c46b | 72 | /* Stop the clock. */ |
pmallick | 0:e8a1ba50c46b | 73 | int32_t clk_disable(struct clk * clk); |
pmallick | 0:e8a1ba50c46b | 74 | |
pmallick | 0:e8a1ba50c46b | 75 | /* Get the current frequency of the clock. */ |
pmallick | 0:e8a1ba50c46b | 76 | int32_t clk_recalc_rate(struct clk *clk, |
pmallick | 0:e8a1ba50c46b | 77 | uint64_t *rate); |
pmallick | 0:e8a1ba50c46b | 78 | |
pmallick | 0:e8a1ba50c46b | 79 | /* Round the desired frequency to a rate that the clock can actually output. */ |
pmallick | 0:e8a1ba50c46b | 80 | int32_t clk_round_rate(struct clk *clk, |
pmallick | 0:e8a1ba50c46b | 81 | uint64_t rate, |
pmallick | 0:e8a1ba50c46b | 82 | uint64_t *rounded_rate); |
pmallick | 0:e8a1ba50c46b | 83 | |
pmallick | 0:e8a1ba50c46b | 84 | /* Change the frequency of the clock. */ |
pmallick | 0:e8a1ba50c46b | 85 | int32_t clk_set_rate(struct clk *clk, |
pmallick | 0:e8a1ba50c46b | 86 | uint64_t rate); |
pmallick | 0:e8a1ba50c46b | 87 | |
pmallick | 0:e8a1ba50c46b | 88 | #endif // CLK_H_ |