pll  2.0.0.0
pll.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef PLL_H
36 #define PLL_H
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 
51 // -------------------------------------------------------------- PUBLIC MACROS
61 #define PLL_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.s1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
63  cfg.s0 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
64  cfg.oe = MIKROBUS( mikrobus, MIKROBUS_CS );
65 
71 #define PLL_OK 0
72 #define PLL_ERROR -1
73 
79 #define PLL_CLOCK_ENABLE 0x01
80 #define PLL_CLOCK_DISABLE 0x00
81  // End group macro
84 // --------------------------------------------------------------- PUBLIC TYPES
93 typedef struct
94 {
95  // Input/Output pins
96  pin_name_t s1;
97  pin_name_t s0;
98 
99  // Output pins
100  digital_out_t oe;
101 
102 } pll_t;
103 
107 typedef struct
108 {
109  // Additional gpio pins
110  pin_name_t s1;
111  pin_name_t s0;
112  pin_name_t oe;
113 
114 } pll_cfg_t;
115  // End types group
117 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
118 
124 #ifdef __cplusplus
125 extern "C"{
126 #endif
127 
136 void pll_cfg_setup ( pll_cfg_t *cfg );
137 
145 err_t pll_init ( pll_t *ctx, pll_cfg_t *cfg );
146 
158 void pll_set_clock_output ( pll_t *ctx, uint8_t mode );
159 
168 void pll_set_pll_4x ( pll_t *ctx );
169 
178 void pll_set_pll_5x ( pll_t *ctx );
179 
188 void pll_set_pll_6x ( pll_t *ctx );
189 
198 void pll_set_pll_8x ( pll_t *ctx );
199 
208 void pll_set_pll_2x ( pll_t *ctx );
209 
218 void pll_set_pll_3x ( pll_t *ctx );
219 
228 void pll_set_pll_3_125x ( pll_t *ctx );
229 
238 void pll_set_pll_6_25x ( pll_t *ctx );
239 
249 
250 #ifdef __cplusplus
251 }
252 #endif
253 #endif // _PLL_H_
254  // End public_function group
257 
258 // ------------------------------------------------------------------------- END
pll_set_pll_4x
void pll_set_pll_4x(pll_t *ctx)
Functions for settings PLL x4.
pll_set_pll_5_3125x
void pll_set_pll_5_3125x(pll_t *ctx)
Functions for settings PLL clock x5.3125.
pll_cfg_t::oe
pin_name_t oe
Definition: pll.h:112
pll_t::s1
pin_name_t s1
Definition: pll.h:96
pll_set_pll_6_25x
void pll_set_pll_6_25x(pll_t *ctx)
Functions for settings PLL clock x6.25.
pll_set_pll_8x
void pll_set_pll_8x(pll_t *ctx)
Functions for settings PLL x6.
pll_set_pll_2x
void pll_set_pll_2x(pll_t *ctx)
Functions for settings PLL x2.
pll_set_clock_output
void pll_set_clock_output(pll_t *ctx, uint8_t mode)
Functions for settings clock output.
pll_set_pll_5x
void pll_set_pll_5x(pll_t *ctx)
Functions for settings PLL x5.
pll_cfg_t
Click configuration structure definition.
Definition: pll.h:108
pll_t::oe
digital_out_t oe
Definition: pll.h:100
pll_set_pll_3_125x
void pll_set_pll_3_125x(pll_t *ctx)
Functions for settings PLL clock x3.125.
pll_init
err_t pll_init(pll_t *ctx, pll_cfg_t *cfg)
Initialization function.
pll_t
Click ctx object definition.
Definition: pll.h:94
pll_cfg_t::s0
pin_name_t s0
Definition: pll.h:111
pll_set_pll_3x
void pll_set_pll_3x(pll_t *ctx)
Functions for settings PLL x3.
pll_t::s0
pin_name_t s0
Definition: pll.h:97
pll_set_pll_6x
void pll_set_pll_6x(pll_t *ctx)
Functions for settings PLL x6.
pll_cfg_setup
void pll_cfg_setup(pll_cfg_t *cfg)
Config Object Initialization function.
pll_cfg_t::s1
pin_name_t s1
Definition: pll.h:110