Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: platform_drivers LTC26X6 AD77681
cn0540_init_params.h
00001 /****************************************************************************** 00002 *Copyright (c)2020 Analog Devices, Inc. 00003 * 00004 * Licensed under the 2020-04-27-CN0540EC License(the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * 00007 ****************************************************************************/ 00008 00009 #ifndef _INIT_PARAMS_H_ 00010 #define _INIT_PARAMS_H_ 00011 00012 #ifdef __cplusplus 00013 extern "C" 00014 { 00015 #endif 00016 00017 #include <mbed.h> 00018 #include <stdint.h> 00019 #include "ad77681.h" 00020 #include "ltc26x6.h" 00021 //#include "cn0540_piezo.h" 00022 #include "platform_drivers.h" 00023 #include "platform_support.h" 00024 #include "spi_extra.h" 00025 #include "i2c_extra.h" 00026 #include "gpio.h" 00027 00028 /******************************************************************************/ 00029 /********************** Macros and Constants Definitions **********************/ 00030 /******************************************************************************/ 00031 00032 //DAC address 00033 #define LTC2606_I2C_ADDRESS 0x10 00034 //GPIOs pins 00035 #define ARD_RED_LED_PIN D0 00036 #define ARD_BLUE_LED_PIN D1 00037 #define DRDY_PIN D2 00038 #define ADC_RST_PIN D7 00039 #define ARD_BUF_EN_PIN D9 00040 00041 // Init params 00042 00043 // Init SPI extra parameters structure 00044 mbed_spi_init_param spi_init_extra_params = { 00045 .spi_clk_pin = SPI_SCK, 00046 .spi_miso_pin = SPI_MISO, 00047 .spi_mosi_pin = SPI_MOSI 00048 }; 00049 // SPI bus init parameters 00050 spi_init_param spi_params = { 00051 20000000, // SPI Speed 00052 SPI_CS, // SPI CS select index 00053 SPI_MODE_3, // SPI Mode 00054 &spi_init_extra_params, // SPI extra configurations 00055 }; 00056 00057 // Initial parameters for the ADC AD7768-1 00058 ad77681_init_param init_params = { 00059 00060 spi_params, // SPI parameters 00061 AD77681_ECO, // power_mode 00062 AD77681_MCLK_DIV_16, // mclk_div 00063 AD77681_CONV_CONTINUOUS, // conv_mode 00064 AD77681_AIN_SHORT, // diag_mux_sel 00065 false, // conv_diag_sel 00066 AD77681_CONV_24BIT, // conv_len 00067 AD77681_NO_CRC, // crc_sel 00068 0, // status bit 00069 AD77681_VCM_HALF_VCC, // VCM setup 00070 AD77681_AINn_ENABLED, // AIN- precharge buffer 00071 AD77681_AINp_ENABLED, // AIN+ precharge buffer 00072 AD77681_BUFn_ENABLED, // REF- buffer 00073 AD77681_BUFp_ENABLED, // REF+ buffer 00074 AD77681_FIR, // FIR Filter 00075 AD77681_SINC5_FIR_DECx32, // Decimate by 32 00076 0, // OS ratio of SINC3 00077 4096, // Reference voltage 00078 16384, // MCLK in kHz 00079 32000, // Sample rate in Hz 00080 1, // Data frame bytes 00081 }; 00082 00083 //Extra mbed_i2c_init_param 00084 mbed_i2c_init_param mbed_i2c_init_dac_extra_params = { 00085 .i2c_sda_pin = I2C_SDA, 00086 .i2c_scl_pin = I2C_SCL, 00087 }; 00088 00089 // Initial parameters for the DAC LTC2606's I2C bus 00090 i2c_init_param i2c_params_dac = { 00091 100000, // I2C speed (hz) 00092 LTC26X6_WRITE_ADDRESS(LTC2606_I2C_ADDRESS), // I2C slave address 00093 &mbed_i2c_init_dac_extra_params, 00094 }; 00095 00096 // Initial parameters for the DAC LTC2606 itself 00097 ltc26x6_init_param init_params_dac = { 00098 i2c_params_dac, // I2C parameters 00099 16, // Resolution (LTC2606) 00100 2.5, // Reference Voltage 00101 -0.001 // Typical offset 00102 }; 00103 00104 /* 00105 * User-defined coefficients for programmable FIR filter, max 56 coeffs 00106 * 00107 * Please note that, inserted coefficiets will be mirrored afterwards, 00108 * so you must insert only one half of all the coefficients. 00109 * 00110 * Please note your original filer must have ODD count of coefficients, 00111 * allowing internal ADC circuitry to mirror the coefficients properly. 00112 * 00113 * In case of usage lower count of coeffs than 56, please make sure, that 00114 * the variable 'count_of_active_coeffs' bellow, carries the correct number 00115 * of coeficients, allowing to fill the rest of the coeffs by zeroes 00116 * 00117 * Default coeffs: 00118 **/ 00119 const uint8_t count_of_active_coeffs = 56; 00120 00121 const float programmable_FIR[56] = { 00122 00123 -9.53674E-07, 00124 3.33786E-06, 00125 5.48363E-06, 00126 - 5.48363E-06, 00127 - 1.54972E-05, 00128 5.24521E-06, 00129 3.40939E-05, 00130 3.57628E-06, 00131 - 6.17504E-05, 00132 - 3.05176E-05, 00133 9.56059E-05, 00134 8.74996E-05, 00135 - 0.000124693, 00136 - 0.000186205, 00137 0.000128746, 00138 0.000333548, 00139 - 7.70092E-05, 00140 - 0.000524998, 00141 - 6.98566E-05, 00142 0.000738144, 00143 0.000353813, 00144 - 0.000924349, 00145 - 0.000809193, 00146 0.001007795, 00147 0.00144887, 00148 - 0.000886202, 00149 - 0.002248049, 00150 0.000440598, 00151 0.00312829, 00152 0.000447273, 00153 - 0.00394845, 00154 - 0.001870632, 00155 0.004499197, 00156 0.003867388, 00157 - 0.004512072, 00158 - 0.006392241, 00159 0.003675938, 00160 0.009288311, 00161 - 0.001663446, 00162 - 0.012270451, 00163 - 0.001842737, 00164 0.014911652, 00165 0.007131577, 00166 - 0.016633987, 00167 - 0.014478207, 00168 0.016674042, 00169 0.024231672, 00170 - 0.013958216, 00171 - 0.037100792, 00172 0.006659508, 00173 0.055086851, 00174 0.009580374, 00175 - 0.085582495, 00176 - 0.052207232, 00177 0.177955151, 00178 0.416601658, 00179 }; 00180 00181 #ifdef __cplusplus 00182 } 00183 #endif // __cplusplus 00184 #endif // !_INIT_PARAMS_H_ 00185 00186
Generated on Sun Jul 17 2022 08:53:29 by
1.7.2