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.
ADxxxx.h
00001 /***************************************************************************//** 00002 * @file AD1234.h 00003 * @brief Header file of AD1234 Driver. This driver suppors the following 00004 * devices: AD1234R, AD1235R, AD1236R 00005 * 00006 * @author FirstName LastName (email ID) 00007 ******************************************************************************** 00008 * Copyright 2013(c) Analog Devices, Inc. 00009 * 00010 * All rights reserved. 00011 * 00012 * Redistribution and use in source and binary forms, with or without 00013 * modification, 00014 * are permitted provided that the following conditions are met: 00015 * - Redistributions of source code must retain the above copyright 00016 * notice, this list of conditions and the following disclaimer. 00017 * - Redistributions in binary form must reproduce the above copyright 00018 * notice, this list of conditions and the following disclaimer in 00019 * the documentation and/or other materials provided with the 00020 * distribution. 00021 * - Neither the name of Analog Devices, Inc. nor the names of its 00022 * contributors may be used to endorse or promote products derived 00023 * from this software without specific prior written permission. 00024 * - The use of this software may or may not infringe the patent rights 00025 * of one or more patent holders. This license does not release you 00026 * from the requirement that you obtain separate licenses from these 00027 * patent holders to use this software. 00028 * - Use of the software either in source or binary form, must be run 00029 * on or directly connected to an Analog Devices Inc. component. 00030 * 00031 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR 00032 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, 00033 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00034 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, 00035 * INCIDENTAL,SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00036 * * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS 00037 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00038 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00039 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00040 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00041 * DAMAGE. 00042 * 00043 *******************************************************************************/ 00044 #include <stdint.h> 00045 #include "platform_drivers.h" 00046 00047 /***Read Write Defines***/ 00048 #define ADxxxx_RW 1 /* Read and Write */ 00049 #define ADxxxx_R 2 /* Read only */ 00050 #define ADxxxx_W 3 /* Write only */ 00051 00052 /***Register Defines***/ 00053 #define ADXXXX_POW_ON_REG 0x00 00054 #define ADXXXX_POW_REG 0x01 00055 #define ADXXXX_CALIBRATE_REG 0x02 00056 00057 00058 #define ADXXXX_REG_NUM 3 /*Number of registers*/ 00059 00060 #define ADXXXX_POW_FULL 0x04 00061 #define ADXXXX_POW_MED 0x03 00062 #define ADXXXX_POW_LOW 0x02 00063 #define ADXXXX_POW_IDLE 0x01 00064 00065 #define ADXXXX_CALIBRATED 1 00066 #define ADXXXX_NOT_CALIBRATED 0 00067 00068 /***Struct Definitions***/ 00069 00070 /*Struct to store values of the following 00071 four fields of each register*/ 00072 struct adxxxx_reg { 00073 int32_t address; 00074 int32_t value; 00075 int32_t size; 00076 int32_t rw; 00077 }; 00078 00079 extern struct adxxxx_reg adxxxx_all_regs[ADXXXX_REG_NUM]; 00080 00081 /*Struct to hold ADxxxx Specific Values*/ 00082 struct adxxxx_descriptor { 00083 spi_desc *spi_desc; /*SPI Descriptor*/ 00084 i2c_desc *i2c_desc; /*I2C Descriptor*/ 00085 struct adxxxx_reg *all_regs; /*Array of Register Structs*/ 00086 /*Any other fields you want can go 00087 below, some examples are provided*/ 00088 uint8_t is_calibrated; /*EXAMPLES*/ 00089 uint8_t power_level; 00090 }; 00091 00092 /*Struct to hold adxxxx communication info*/ 00093 struct adxxxx_init_params { 00094 spi_init_param spi_init; 00095 i2c_init_param i2c_params; 00096 /*Once again, you could put initial 00097 values here, which the setup 00098 function changes 00099 */ 00100 }; 00101 00102 /***Function Prototypes***/ 00103 00104 /*Function to setup the file descriptor and start serial communication*/ 00105 int adxxxx_setup(struct adxxxx_descriptor **device, struct adxxxx_init_params init_param); 00106 00107 /*Function to write all initial register values*/ 00108 int adxxxx_init_regs(struct adxxxx_descriptor *device); 00109 00110 /*Function to read from a register*/ 00111 int adxxx_read(struct adxxxx_descriptor *device, struct adxxxx_reg* reg); 00112 00113 /*Function to write from a register*/ 00114 int adxxx_write(struct adxxxx_descriptor *device, struct adxxxx_reg* reg, uint32_t data);
Generated on Thu Jul 14 2022 02:41:57 by
