Video library for GR-PEACH
Dependents: Trace_Program2 GR-PEACH_Camera_in_barcode GR-PEACH_LCD_sample GR-PEACH_LCD_4_3inch_sample ... more
Video library for GR-PEACH.
Hello World!
Import programGR-PEACH_Camera_in
Camera in sample for GR-PEACH. This sample works on GR-LYCHEE besides GR-PEACH.
API
Import library
Interface
See the Pinout page for more details
lvds/lvds_pll_main.c@4:aeefe5171463, 2016-06-30 (annotated)
- Committer:
- dkato
- Date:
- Thu Jun 30 11:00:37 2016 +0000
- Revision:
- 4:aeefe5171463
- Parent:
- 0:853f5b7408a7
Add ARGB4444 to graphics layer read format.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dkato | 0:853f5b7408a7 | 1 | /******************************************************************************* |
dkato | 0:853f5b7408a7 | 2 | * DISCLAIMER |
dkato | 0:853f5b7408a7 | 3 | * This software is supplied by Renesas Electronics Corporation and is only |
dkato | 0:853f5b7408a7 | 4 | * intended for use with Renesas products. No other uses are authorized. This |
dkato | 0:853f5b7408a7 | 5 | * software is owned by Renesas Electronics Corporation and is protected under |
dkato | 0:853f5b7408a7 | 6 | * all applicable laws, including copyright laws. |
dkato | 0:853f5b7408a7 | 7 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
dkato | 0:853f5b7408a7 | 8 | * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT |
dkato | 0:853f5b7408a7 | 9 | * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
dkato | 0:853f5b7408a7 | 10 | * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. |
dkato | 0:853f5b7408a7 | 11 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
dkato | 0:853f5b7408a7 | 12 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
dkato | 0:853f5b7408a7 | 13 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR |
dkato | 0:853f5b7408a7 | 14 | * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE |
dkato | 0:853f5b7408a7 | 15 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
dkato | 0:853f5b7408a7 | 16 | * Renesas reserves the right, without notice, to make changes to this software |
dkato | 0:853f5b7408a7 | 17 | * and to discontinue the availability of this software. By using this software, |
dkato | 0:853f5b7408a7 | 18 | * you agree to the additional terms and conditions found by accessing the |
dkato | 0:853f5b7408a7 | 19 | * following link: |
dkato | 0:853f5b7408a7 | 20 | * http://www.renesas.com/disclaimer |
dkato | 0:853f5b7408a7 | 21 | * Copyright (C) 2012 - 2015 Renesas Electronics Corporation. All rights reserved. |
dkato | 0:853f5b7408a7 | 22 | *******************************************************************************/ |
dkato | 0:853f5b7408a7 | 23 | /**************************************************************************//** |
dkato | 0:853f5b7408a7 | 24 | * @file lvds_pll_main.c |
dkato | 0:853f5b7408a7 | 25 | * @version 1.00 |
dkato | 0:853f5b7408a7 | 26 | * $Rev: 199 $ |
dkato | 0:853f5b7408a7 | 27 | * $Date:: 2014-05-23 16:33:52 +0900#$ |
dkato | 0:853f5b7408a7 | 28 | * @brief lvds pll setting value |
dkato | 0:853f5b7408a7 | 29 | ******************************************************************************/ |
dkato | 0:853f5b7408a7 | 30 | |
dkato | 0:853f5b7408a7 | 31 | /****************************************************************************** |
dkato | 0:853f5b7408a7 | 32 | Includes <System Includes> , "Project Includes" |
dkato | 0:853f5b7408a7 | 33 | ******************************************************************************/ |
dkato | 0:853f5b7408a7 | 34 | #include <stdio.h> |
dkato | 0:853f5b7408a7 | 35 | #include <stdlib.h> |
dkato | 0:853f5b7408a7 | 36 | #include <math.h> |
dkato | 0:853f5b7408a7 | 37 | |
dkato | 0:853f5b7408a7 | 38 | #include "r_typedefs.h" |
dkato | 0:853f5b7408a7 | 39 | #include "lvds_pll_calc.h" |
dkato | 0:853f5b7408a7 | 40 | |
dkato | 0:853f5b7408a7 | 41 | /****************************************************************************** |
dkato | 0:853f5b7408a7 | 42 | Macro definitions |
dkato | 0:853f5b7408a7 | 43 | ******************************************************************************/ |
dkato | 0:853f5b7408a7 | 44 | /* FIN: LVDS PLL input frequency */ |
dkato | 0:853f5b7408a7 | 45 | #define FIN_MIN (9.0) /*!< The lower limit of the FIN */ |
dkato | 0:853f5b7408a7 | 46 | #define FIN_MAX (30.0) /*!< The upper limit of the FIN */ |
dkato | 0:853f5b7408a7 | 47 | /* FREF */ |
dkato | 0:853f5b7408a7 | 48 | #define FREF_MIN (2.5) /*!< The lower limit of the FREF */ |
dkato | 0:853f5b7408a7 | 49 | #define FREF_MAX (30.0) /*!< The upper limit of the FREF */ |
dkato | 0:853f5b7408a7 | 50 | /* FVCO: VCO output frequency */ |
dkato | 0:853f5b7408a7 | 51 | #define FVCO_MIN (750.0) /*!< The lower limit of the FVCO */ |
dkato | 0:853f5b7408a7 | 52 | #define FVCO_MAX (1630.0) /*!< The upper limit of the FVCO */ |
dkato | 0:853f5b7408a7 | 53 | /* FOUT: LVDS PLL output frequency */ |
dkato | 0:853f5b7408a7 | 54 | #define FOUT_MIN (0.0) /*!< The lower limit of the FOUT */ |
dkato | 0:853f5b7408a7 | 55 | #define FOUT_MAX (609.0) /*!< The upper limit of the FOUT */ |
dkato | 0:853f5b7408a7 | 56 | |
dkato | 0:853f5b7408a7 | 57 | #define DIVIDER_3 (7.0) /*!< The frequency dividing value for frequency divider 3 */ |
dkato | 0:853f5b7408a7 | 58 | |
dkato | 0:853f5b7408a7 | 59 | |
dkato | 0:853f5b7408a7 | 60 | /****************************************************************************** |
dkato | 0:853f5b7408a7 | 61 | Typedef definitions |
dkato | 0:853f5b7408a7 | 62 | ******************************************************************************/ |
dkato | 0:853f5b7408a7 | 63 | |
dkato | 0:853f5b7408a7 | 64 | |
dkato | 0:853f5b7408a7 | 65 | /****************************************************************************** |
dkato | 0:853f5b7408a7 | 66 | Variable Externs |
dkato | 0:853f5b7408a7 | 67 | ******************************************************************************/ |
dkato | 0:853f5b7408a7 | 68 | extern const double NIDIV_data[]; |
dkato | 0:853f5b7408a7 | 69 | extern const double NRD_data[]; |
dkato | 0:853f5b7408a7 | 70 | extern const double NFD_data[]; |
dkato | 0:853f5b7408a7 | 71 | extern const double NOD_data[]; |
dkato | 0:853f5b7408a7 | 72 | extern const double NODIV_data[]; |
dkato | 0:853f5b7408a7 | 73 | |
dkato | 0:853f5b7408a7 | 74 | |
dkato | 0:853f5b7408a7 | 75 | /****************************************************************************** |
dkato | 0:853f5b7408a7 | 76 | Private global variables and functions |
dkato | 0:853f5b7408a7 | 77 | ******************************************************************************/ |
dkato | 0:853f5b7408a7 | 78 | static double InputClock; |
dkato | 0:853f5b7408a7 | 79 | static double OutputClock; |
dkato | 0:853f5b7408a7 | 80 | static int LvdsUsed; |
dkato | 0:853f5b7408a7 | 81 | |
dkato | 0:853f5b7408a7 | 82 | |
dkato | 0:853f5b7408a7 | 83 | |
dkato | 0:853f5b7408a7 | 84 | /**************************************************************************//** |
dkato | 0:853f5b7408a7 | 85 | * @brief |
dkato | 0:853f5b7408a7 | 86 | * @param [in,out]param |
dkato | 0:853f5b7408a7 | 87 | * @param [in]fout |
dkato | 0:853f5b7408a7 | 88 | * @retval int |
dkato | 0:853f5b7408a7 | 89 | *****************************************************************************/ |
dkato | 0:853f5b7408a7 | 90 | static int compare_nodiv (pll_parameter_t * param, double fout) |
dkato | 0:853f5b7408a7 | 91 | { |
dkato | 0:853f5b7408a7 | 92 | int change; |
dkato | 0:853f5b7408a7 | 93 | const double * nodiv_list; |
dkato | 0:853f5b7408a7 | 94 | double diff_freq; |
dkato | 0:853f5b7408a7 | 95 | |
dkato | 0:853f5b7408a7 | 96 | change = 0; |
dkato | 0:853f5b7408a7 | 97 | nodiv_list = NODIV_data; |
dkato | 0:853f5b7408a7 | 98 | while (*nodiv_list != 0.0) { |
dkato | 0:853f5b7408a7 | 99 | diff_freq = fabs(OutputClock - (fout / *nodiv_list)); |
dkato | 0:853f5b7408a7 | 100 | if (param->comparison_freq > diff_freq) { |
dkato | 0:853f5b7408a7 | 101 | param->comparison_freq = diff_freq; |
dkato | 0:853f5b7408a7 | 102 | param->output_freq = fout / *nodiv_list; |
dkato | 0:853f5b7408a7 | 103 | param->nodiv = *nodiv_list; |
dkato | 0:853f5b7408a7 | 104 | change = 1; |
dkato | 0:853f5b7408a7 | 105 | } |
dkato | 0:853f5b7408a7 | 106 | nodiv_list++; |
dkato | 0:853f5b7408a7 | 107 | } |
dkato | 0:853f5b7408a7 | 108 | return change; |
dkato | 0:853f5b7408a7 | 109 | } |
dkato | 0:853f5b7408a7 | 110 | |
dkato | 0:853f5b7408a7 | 111 | /**************************************************************************//** |
dkato | 0:853f5b7408a7 | 112 | * @brief |
dkato | 0:853f5b7408a7 | 113 | * @param [in,out]param |
dkato | 0:853f5b7408a7 | 114 | * @param [in]fout |
dkato | 0:853f5b7408a7 | 115 | * @retval int |
dkato | 0:853f5b7408a7 | 116 | *****************************************************************************/ |
dkato | 0:853f5b7408a7 | 117 | static int compare_div3 (pll_parameter_t * param, double fout) |
dkato | 0:853f5b7408a7 | 118 | { |
dkato | 0:853f5b7408a7 | 119 | double diff_freq; |
dkato | 0:853f5b7408a7 | 120 | int change; |
dkato | 0:853f5b7408a7 | 121 | |
dkato | 0:853f5b7408a7 | 122 | change = 0; |
dkato | 0:853f5b7408a7 | 123 | diff_freq = fabs(OutputClock - (fout / DIVIDER_3)); |
dkato | 0:853f5b7408a7 | 124 | |
dkato | 0:853f5b7408a7 | 125 | if (param->comparison_freq > diff_freq) { |
dkato | 0:853f5b7408a7 | 126 | param->comparison_freq = diff_freq; |
dkato | 0:853f5b7408a7 | 127 | param->output_freq = fout / DIVIDER_3; |
dkato | 0:853f5b7408a7 | 128 | change = 1; |
dkato | 0:853f5b7408a7 | 129 | } |
dkato | 0:853f5b7408a7 | 130 | return change; |
dkato | 0:853f5b7408a7 | 131 | } |
dkato | 0:853f5b7408a7 | 132 | |
dkato | 0:853f5b7408a7 | 133 | /**************************************************************************//** |
dkato | 0:853f5b7408a7 | 134 | * @brief |
dkato | 0:853f5b7408a7 | 135 | * @param [out]param |
dkato | 0:853f5b7408a7 | 136 | * @retval None |
dkato | 0:853f5b7408a7 | 137 | *****************************************************************************/ |
dkato | 0:853f5b7408a7 | 138 | static void SeekValue (pll_parameter_t * param) |
dkato | 0:853f5b7408a7 | 139 | { |
dkato | 0:853f5b7408a7 | 140 | const double * nidiv_list; |
dkato | 0:853f5b7408a7 | 141 | const double * nrd_list; |
dkato | 0:853f5b7408a7 | 142 | const double * nfd_list; |
dkato | 0:853f5b7408a7 | 143 | const double * nod_list; |
dkato | 0:853f5b7408a7 | 144 | |
dkato | 0:853f5b7408a7 | 145 | double fin; |
dkato | 0:853f5b7408a7 | 146 | double fref; |
dkato | 0:853f5b7408a7 | 147 | double fvco; |
dkato | 0:853f5b7408a7 | 148 | double fout; |
dkato | 0:853f5b7408a7 | 149 | int ret; |
dkato | 0:853f5b7408a7 | 150 | |
dkato | 0:853f5b7408a7 | 151 | nidiv_list = NIDIV_data; |
dkato | 0:853f5b7408a7 | 152 | while (*nidiv_list != 0.0) { |
dkato | 0:853f5b7408a7 | 153 | fin = InputClock / *nidiv_list; |
dkato | 0:853f5b7408a7 | 154 | if ((fin < FIN_MIN) || (FIN_MAX < fin)) { |
dkato | 0:853f5b7408a7 | 155 | nidiv_list++; |
dkato | 0:853f5b7408a7 | 156 | continue; |
dkato | 0:853f5b7408a7 | 157 | } |
dkato | 0:853f5b7408a7 | 158 | nrd_list = NRD_data; |
dkato | 0:853f5b7408a7 | 159 | while (*nrd_list != 0.0) { |
dkato | 0:853f5b7408a7 | 160 | fref = fin / *nrd_list; |
dkato | 0:853f5b7408a7 | 161 | if ((fref < FREF_MIN) || (FREF_MAX < fref)) { |
dkato | 0:853f5b7408a7 | 162 | nrd_list++; |
dkato | 0:853f5b7408a7 | 163 | continue; |
dkato | 0:853f5b7408a7 | 164 | } |
dkato | 0:853f5b7408a7 | 165 | nfd_list = NFD_data; |
dkato | 0:853f5b7408a7 | 166 | while (*nfd_list != 0.0) { |
dkato | 0:853f5b7408a7 | 167 | fvco = fref * (*nfd_list); |
dkato | 0:853f5b7408a7 | 168 | if ((fvco < FVCO_MIN) || (FVCO_MAX < fvco)) { |
dkato | 0:853f5b7408a7 | 169 | nfd_list++; |
dkato | 0:853f5b7408a7 | 170 | continue; |
dkato | 0:853f5b7408a7 | 171 | } |
dkato | 0:853f5b7408a7 | 172 | nod_list = NOD_data; |
dkato | 0:853f5b7408a7 | 173 | while (*nod_list != 0.0) { |
dkato | 0:853f5b7408a7 | 174 | fout = fvco / *nod_list; |
dkato | 0:853f5b7408a7 | 175 | if ((fout < FOUT_MIN) || (FOUT_MAX < fout)) { |
dkato | 0:853f5b7408a7 | 176 | nod_list++; |
dkato | 0:853f5b7408a7 | 177 | continue; |
dkato | 0:853f5b7408a7 | 178 | } |
dkato | 0:853f5b7408a7 | 179 | |
dkato | 0:853f5b7408a7 | 180 | if (LvdsUsed == 0) { |
dkato | 0:853f5b7408a7 | 181 | ret = compare_nodiv(param, fout); |
dkato | 0:853f5b7408a7 | 182 | } else { |
dkato | 0:853f5b7408a7 | 183 | ret = compare_div3(param, fout); |
dkato | 0:853f5b7408a7 | 184 | } |
dkato | 0:853f5b7408a7 | 185 | if (ret != 0) { |
dkato | 0:853f5b7408a7 | 186 | param->nidiv = *nidiv_list; |
dkato | 0:853f5b7408a7 | 187 | param->nrd = *nrd_list; |
dkato | 0:853f5b7408a7 | 188 | param->nfd = *nfd_list; |
dkato | 0:853f5b7408a7 | 189 | param->nod = *nod_list; |
dkato | 0:853f5b7408a7 | 190 | } |
dkato | 0:853f5b7408a7 | 191 | nod_list++; |
dkato | 0:853f5b7408a7 | 192 | } |
dkato | 0:853f5b7408a7 | 193 | nfd_list++; |
dkato | 0:853f5b7408a7 | 194 | } |
dkato | 0:853f5b7408a7 | 195 | nrd_list++; |
dkato | 0:853f5b7408a7 | 196 | } |
dkato | 0:853f5b7408a7 | 197 | nidiv_list++; |
dkato | 0:853f5b7408a7 | 198 | } |
dkato | 0:853f5b7408a7 | 199 | } |
dkato | 0:853f5b7408a7 | 200 | /**************************************************************************//** |
dkato | 0:853f5b7408a7 | 201 | * @brief PLL value Calculation function |
dkato | 0:853f5b7408a7 | 202 | * @param[in] InClock : Input clock frequency [MHz] |
dkato | 0:853f5b7408a7 | 203 | * @param[in] OuClock : Output clock frequency [MHz] |
dkato | 0:853f5b7408a7 | 204 | * @param[in] Lvds : The LVDS output interface is used (=1) or not (=0) |
dkato | 0:853f5b7408a7 | 205 | * @param[out] result : pll_parameter_t |
dkato | 0:853f5b7408a7 | 206 | * @retval error (-1) |
dkato | 0:853f5b7408a7 | 207 | ******************************************************************************/ |
dkato | 0:853f5b7408a7 | 208 | int32_t lvds_pll_calc( |
dkato | 0:853f5b7408a7 | 209 | const double InClock, |
dkato | 0:853f5b7408a7 | 210 | const double OuClock, |
dkato | 0:853f5b7408a7 | 211 | const uint32_t Lvds, |
dkato | 0:853f5b7408a7 | 212 | pll_parameter_t * result ) |
dkato | 0:853f5b7408a7 | 213 | { |
dkato | 0:853f5b7408a7 | 214 | result->comparison_freq = 1000.0; |
dkato | 0:853f5b7408a7 | 215 | result->output_freq = 0.0; |
dkato | 0:853f5b7408a7 | 216 | result->nidiv = 0.0; |
dkato | 0:853f5b7408a7 | 217 | result->nrd = 0.0; |
dkato | 0:853f5b7408a7 | 218 | result->nfd = 0.0; |
dkato | 0:853f5b7408a7 | 219 | result->nod = 0.0; |
dkato | 0:853f5b7408a7 | 220 | result->nodiv = 0.0; |
dkato | 0:853f5b7408a7 | 221 | |
dkato | 0:853f5b7408a7 | 222 | InputClock = InClock; |
dkato | 0:853f5b7408a7 | 223 | OutputClock = OuClock; |
dkato | 0:853f5b7408a7 | 224 | LvdsUsed = Lvds; |
dkato | 0:853f5b7408a7 | 225 | |
dkato | 0:853f5b7408a7 | 226 | /* Calculation */ |
dkato | 0:853f5b7408a7 | 227 | SeekValue(result); |
dkato | 0:853f5b7408a7 | 228 | |
dkato | 0:853f5b7408a7 | 229 | result->nidiv = result->nidiv/2; |
dkato | 0:853f5b7408a7 | 230 | result->nodiv = result->nodiv/2; |
dkato | 0:853f5b7408a7 | 231 | if( result->nod <= 4 ) { |
dkato | 0:853f5b7408a7 | 232 | result->nod = result->nod/2; |
dkato | 0:853f5b7408a7 | 233 | } else if( result->nod == 8 ) { |
dkato | 0:853f5b7408a7 | 234 | result->nod = 3; |
dkato | 0:853f5b7408a7 | 235 | } else { |
dkato | 0:853f5b7408a7 | 236 | } |
dkato | 0:853f5b7408a7 | 237 | result->nrd -=1; /* nrd-1 */ |
dkato | 0:853f5b7408a7 | 238 | return 0; |
dkato | 0:853f5b7408a7 | 239 | } |