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 
42 #ifdef PREINIT_SUPPORTED
43 #include "preinit.h"
44 #endif
45 
46 #ifdef MikroCCoreVersion
47  #if MikroCCoreVersion >= 1
48  #include "delays.h"
49  #endif
50 #endif
51 
52 #include "drv_digital_out.h"
53 #include "drv_digital_in.h"
54 
55 // -------------------------------------------------------------- PUBLIC MACROS
65 #define PLL_MAP_MIKROBUS( cfg, mikrobus ) \
66  cfg.s1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
67  cfg.s0 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
68  cfg.oe = MIKROBUS( mikrobus, MIKROBUS_CS );
69 
75 #define PLL_OK 0
76 #define PLL_ERROR -1
77 
83 #define PLL_CLOCK_ENABLE 0x01
84 #define PLL_CLOCK_DISABLE 0x00
85  // End group macro
88 // --------------------------------------------------------------- PUBLIC TYPES
97 typedef struct
98 {
99  // Input/Output pins
100  pin_name_t s1;
101  pin_name_t s0;
102 
103  // Output pins
104  digital_out_t oe;
105 
106 } pll_t;
107 
111 typedef struct
112 {
113  // Additional gpio pins
114  pin_name_t s1;
115  pin_name_t s0;
116  pin_name_t oe;
117 
118 } pll_cfg_t;
119  // End types group
121 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
122 
128 #ifdef __cplusplus
129 extern "C"{
130 #endif
131 
140 void pll_cfg_setup ( pll_cfg_t *cfg );
141 
149 err_t pll_init ( pll_t *ctx, pll_cfg_t *cfg );
150 
162 void pll_set_clock_output ( pll_t *ctx, uint8_t mode );
163 
172 void pll_set_pll_4x ( pll_t *ctx );
173 
182 void pll_set_pll_5x ( pll_t *ctx );
183 
192 void pll_set_pll_6x ( pll_t *ctx );
193 
202 void pll_set_pll_8x ( pll_t *ctx );
203 
212 void pll_set_pll_2x ( pll_t *ctx );
213 
222 void pll_set_pll_3x ( pll_t *ctx );
223 
232 void pll_set_pll_3_125x ( pll_t *ctx );
233 
242 void pll_set_pll_6_25x ( pll_t *ctx );
243 
253 
254 #ifdef __cplusplus
255 }
256 #endif
257 #endif // _PLL_H_
258  // End public_function group
261 
262 // ------------------------------------------------------------------------- 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:116
pll_t::s1
pin_name_t s1
Definition: pll.h:100
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:112
pll_t::oe
digital_out_t oe
Definition: pll.h:104
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:98
pll_cfg_t::s0
pin_name_t s0
Definition: pll.h:115
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:101
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:114