MAX77654 Ultra-Low Power PMIC Mbed Driver

Committer:
metin.ozkan@analog.com
Date:
Fri Mar 25 15:42:47 2022 +0300
Revision:
0:788f63dcf0a0
Child:
1:4ad70542956e
Initial Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
metin.ozkan@analog.com 0:788f63dcf0a0 1 /*******************************************************************************
metin.ozkan@analog.com 0:788f63dcf0a0 2 * Copyright (C) 2022 Maxim Integrated Products, Inc., All rights Reserved.
metin.ozkan@analog.com 0:788f63dcf0a0 3 *
metin.ozkan@analog.com 0:788f63dcf0a0 4 * This software is protected by copyright laws of the United States and
metin.ozkan@analog.com 0:788f63dcf0a0 5 * of foreign countries. This material may also be protected by patent laws
metin.ozkan@analog.com 0:788f63dcf0a0 6 * and technology transfer regulations of the United States and of foreign
metin.ozkan@analog.com 0:788f63dcf0a0 7 * countries. This software is furnished under a license agreement and/or a
metin.ozkan@analog.com 0:788f63dcf0a0 8 * nondisclosure agreement and may only be used or reproduced in accordance
metin.ozkan@analog.com 0:788f63dcf0a0 9 * with the terms of those agreements. Dissemination of this information to
metin.ozkan@analog.com 0:788f63dcf0a0 10 * any party or parties not specified in the license agreement and/or
metin.ozkan@analog.com 0:788f63dcf0a0 11 * nondisclosure agreement is expressly prohibited.
metin.ozkan@analog.com 0:788f63dcf0a0 12 *
metin.ozkan@analog.com 0:788f63dcf0a0 13 * The above copyright notice and this permission notice shall be included
metin.ozkan@analog.com 0:788f63dcf0a0 14 * in all copies or substantial portions of the Software.
metin.ozkan@analog.com 0:788f63dcf0a0 15 *
metin.ozkan@analog.com 0:788f63dcf0a0 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
metin.ozkan@analog.com 0:788f63dcf0a0 17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
metin.ozkan@analog.com 0:788f63dcf0a0 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
metin.ozkan@analog.com 0:788f63dcf0a0 19 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
metin.ozkan@analog.com 0:788f63dcf0a0 20 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
metin.ozkan@analog.com 0:788f63dcf0a0 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
metin.ozkan@analog.com 0:788f63dcf0a0 22 * OTHER DEALINGS IN THE SOFTWARE.
metin.ozkan@analog.com 0:788f63dcf0a0 23 *
metin.ozkan@analog.com 0:788f63dcf0a0 24 * Except as contained in this notice, the name of Maxim Integrated
metin.ozkan@analog.com 0:788f63dcf0a0 25 * Products, Inc. shall not be used except as stated in the Maxim Integrated
metin.ozkan@analog.com 0:788f63dcf0a0 26 * Products, Inc. Branding Policy.
metin.ozkan@analog.com 0:788f63dcf0a0 27 *
metin.ozkan@analog.com 0:788f63dcf0a0 28 * The mere transfer of this software does not imply any licenses
metin.ozkan@analog.com 0:788f63dcf0a0 29 * of trade secrets, proprietary technology, copyrights, patents,
metin.ozkan@analog.com 0:788f63dcf0a0 30 * trademarks, maskwork rights, or any other form of intellectual
metin.ozkan@analog.com 0:788f63dcf0a0 31 * property whatsoever. Maxim Integrated Products, Inc. retains all
metin.ozkan@analog.com 0:788f63dcf0a0 32 * ownership rights.
metin.ozkan@analog.com 0:788f63dcf0a0 33 *******************************************************************************
metin.ozkan@analog.com 0:788f63dcf0a0 34 */
metin.ozkan@analog.com 0:788f63dcf0a0 35
metin.ozkan@analog.com 0:788f63dcf0a0 36 #include <iostream>
metin.ozkan@analog.com 0:788f63dcf0a0 37 #include <Thread.h>
metin.ozkan@analog.com 0:788f63dcf0a0 38 #include "MAX77654.h"
metin.ozkan@analog.com 0:788f63dcf0a0 39 using namespace std;
metin.ozkan@analog.com 0:788f63dcf0a0 40
metin.ozkan@analog.com 0:788f63dcf0a0 41 #define POST_INTR_WORK_SIGNAL_ID 0x1
metin.ozkan@analog.com 0:788f63dcf0a0 42
metin.ozkan@analog.com 0:788f63dcf0a0 43 MAX77654::MAX77654(I2C *i2c, DigitalOut *powerPin, DigitalIn *dataPin, PinName IRQPin)
metin.ozkan@analog.com 0:788f63dcf0a0 44 {
metin.ozkan@analog.com 0:788f63dcf0a0 45 if (i2c == NULL || powerPin == NULL || dataPin == NULL)
metin.ozkan@analog.com 0:788f63dcf0a0 46 return;
metin.ozkan@analog.com 0:788f63dcf0a0 47
metin.ozkan@analog.com 0:788f63dcf0a0 48 i2c_handler = i2c;
metin.ozkan@analog.com 0:788f63dcf0a0 49 power_pin = powerPin;
metin.ozkan@analog.com 0:788f63dcf0a0 50 data_read = dataPin;
metin.ozkan@analog.com 0:788f63dcf0a0 51
metin.ozkan@analog.com 0:788f63dcf0a0 52 if (IRQPin != NC) {
metin.ozkan@analog.com 0:788f63dcf0a0 53 IRQDisableAll();
metin.ozkan@analog.com 0:788f63dcf0a0 54 post_intr_work_thread = new Thread();
metin.ozkan@analog.com 0:788f63dcf0a0 55 post_intr_work_thread->start(Callback<void()>(this, &MAX77654::PostInterruptWork));
metin.ozkan@analog.com 0:788f63dcf0a0 56
metin.ozkan@analog.com 0:788f63dcf0a0 57 this->irq_pin = new InterruptIn(IRQPin);
metin.ozkan@analog.com 0:788f63dcf0a0 58 this->irq_pin->fall(Callback<void()>(this, &MAX77654::InterruptHandler));
metin.ozkan@analog.com 0:788f63dcf0a0 59 this->irq_pin->enable_irq();
metin.ozkan@analog.com 0:788f63dcf0a0 60 } else {
metin.ozkan@analog.com 0:788f63dcf0a0 61 this->irq_pin = NULL;
metin.ozkan@analog.com 0:788f63dcf0a0 62 }
metin.ozkan@analog.com 0:788f63dcf0a0 63 }
metin.ozkan@analog.com 0:788f63dcf0a0 64
metin.ozkan@analog.com 0:788f63dcf0a0 65 MAX77654::~MAX77654()
metin.ozkan@analog.com 0:788f63dcf0a0 66 {
metin.ozkan@analog.com 0:788f63dcf0a0 67 if (post_intr_work_thread) {
metin.ozkan@analog.com 0:788f63dcf0a0 68 delete post_intr_work_thread;
metin.ozkan@analog.com 0:788f63dcf0a0 69 }
metin.ozkan@analog.com 0:788f63dcf0a0 70
metin.ozkan@analog.com 0:788f63dcf0a0 71 if (irq_pin) {
metin.ozkan@analog.com 0:788f63dcf0a0 72 delete irq_pin;
metin.ozkan@analog.com 0:788f63dcf0a0 73 }
metin.ozkan@analog.com 0:788f63dcf0a0 74 }
metin.ozkan@analog.com 0:788f63dcf0a0 75
metin.ozkan@analog.com 0:788f63dcf0a0 76 int MAX77654::read_register(uint8_t reg, uint8_t *value)
metin.ozkan@analog.com 0:788f63dcf0a0 77 {
metin.ozkan@analog.com 0:788f63dcf0a0 78 int rtn_val;
metin.ozkan@analog.com 0:788f63dcf0a0 79
metin.ozkan@analog.com 0:788f63dcf0a0 80 if (value == NULL) {
metin.ozkan@analog.com 0:788f63dcf0a0 81 return MAX77654_VALUE_NULL;
metin.ozkan@analog.com 0:788f63dcf0a0 82 }
metin.ozkan@analog.com 0:788f63dcf0a0 83
metin.ozkan@analog.com 0:788f63dcf0a0 84 rtn_val = i2c_handler->write(MAX77654_I2C_ADDRESS, (const char *)&reg, 1, true);
metin.ozkan@analog.com 0:788f63dcf0a0 85 if (rtn_val != 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 86 return MAX77654_WRITE_DATA_FAILED;
metin.ozkan@analog.com 0:788f63dcf0a0 87 }
metin.ozkan@analog.com 0:788f63dcf0a0 88
metin.ozkan@analog.com 0:788f63dcf0a0 89 rtn_val = i2c_handler->read(MAX77654_I2C_ADDRESS, (char *) value, 1, false);
metin.ozkan@analog.com 0:788f63dcf0a0 90 if (rtn_val < 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 91 return MAX77654_READ_DATA_FAILED;
metin.ozkan@analog.com 0:788f63dcf0a0 92 }
metin.ozkan@analog.com 0:788f63dcf0a0 93
metin.ozkan@analog.com 0:788f63dcf0a0 94 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 95 }
metin.ozkan@analog.com 0:788f63dcf0a0 96
metin.ozkan@analog.com 0:788f63dcf0a0 97 int MAX77654::write_register(uint8_t reg, const uint8_t *value)
metin.ozkan@analog.com 0:788f63dcf0a0 98 {
metin.ozkan@analog.com 0:788f63dcf0a0 99 int rtn_val;
metin.ozkan@analog.com 0:788f63dcf0a0 100 uint8_t local_data[2];
metin.ozkan@analog.com 0:788f63dcf0a0 101
metin.ozkan@analog.com 0:788f63dcf0a0 102 if (value == NULL) {
metin.ozkan@analog.com 0:788f63dcf0a0 103 return MAX77654_VALUE_NULL;
metin.ozkan@analog.com 0:788f63dcf0a0 104 }
metin.ozkan@analog.com 0:788f63dcf0a0 105
metin.ozkan@analog.com 0:788f63dcf0a0 106 local_data[0] = reg;
metin.ozkan@analog.com 0:788f63dcf0a0 107
metin.ozkan@analog.com 0:788f63dcf0a0 108 memcpy(&local_data[1], value, 1);
metin.ozkan@analog.com 0:788f63dcf0a0 109
metin.ozkan@analog.com 0:788f63dcf0a0 110 rtn_val = i2c_handler->write(MAX77654_I2C_ADDRESS, (const char *)local_data, sizeof(local_data));
metin.ozkan@analog.com 0:788f63dcf0a0 111 if (rtn_val != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 112 return MAX77654_WRITE_DATA_FAILED;
metin.ozkan@analog.com 0:788f63dcf0a0 113 }
metin.ozkan@analog.com 0:788f63dcf0a0 114
metin.ozkan@analog.com 0:788f63dcf0a0 115 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 116 }
metin.ozkan@analog.com 0:788f63dcf0a0 117
metin.ozkan@analog.com 0:788f63dcf0a0 118 #define SET_BIT_FIELD(address, reg_name, bit_field_name, value) \
metin.ozkan@analog.com 0:788f63dcf0a0 119 int ret; \
metin.ozkan@analog.com 0:788f63dcf0a0 120 ret = read_register(address, (uint8_t *)&(reg_name)); \
metin.ozkan@analog.com 0:788f63dcf0a0 121 if (ret) { \
metin.ozkan@analog.com 0:788f63dcf0a0 122 return ret; \
metin.ozkan@analog.com 0:788f63dcf0a0 123 } \
metin.ozkan@analog.com 0:788f63dcf0a0 124 bit_field_name = value; \
metin.ozkan@analog.com 0:788f63dcf0a0 125 ret = write_register(address, (uint8_t *)&(reg_name)); \
metin.ozkan@analog.com 0:788f63dcf0a0 126 if (ret) { \
metin.ozkan@analog.com 0:788f63dcf0a0 127 return ret; \
metin.ozkan@analog.com 0:788f63dcf0a0 128 }
metin.ozkan@analog.com 0:788f63dcf0a0 129
metin.ozkan@analog.com 0:788f63dcf0a0 130 int MAX77654::GetThermalOverload(ercflag_t *ercflag)
metin.ozkan@analog.com 0:788f63dcf0a0 131 {
metin.ozkan@analog.com 0:788f63dcf0a0 132 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 133 reg_ercflag_t reg_ercflag;
metin.ozkan@analog.com 0:788f63dcf0a0 134
metin.ozkan@analog.com 0:788f63dcf0a0 135 ret = read_register(ERCFLAG, (uint8_t *)&(reg_ercflag));
metin.ozkan@analog.com 0:788f63dcf0a0 136 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 137 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 138 }
metin.ozkan@analog.com 0:788f63dcf0a0 139
metin.ozkan@analog.com 0:788f63dcf0a0 140 *ercflag = (ercflag_t)reg_ercflag.bits.tovld;
metin.ozkan@analog.com 0:788f63dcf0a0 141
metin.ozkan@analog.com 0:788f63dcf0a0 142 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 143 }
metin.ozkan@analog.com 0:788f63dcf0a0 144
metin.ozkan@analog.com 0:788f63dcf0a0 145 int MAX77654::GetSysOvervoltageLockout(ercflag_t *ercflag)
metin.ozkan@analog.com 0:788f63dcf0a0 146 {
metin.ozkan@analog.com 0:788f63dcf0a0 147 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 148 reg_ercflag_t reg_ercflag;
metin.ozkan@analog.com 0:788f63dcf0a0 149
metin.ozkan@analog.com 0:788f63dcf0a0 150 ret = read_register(ERCFLAG, (uint8_t *)&(reg_ercflag));
metin.ozkan@analog.com 0:788f63dcf0a0 151 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 152 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 153 }
metin.ozkan@analog.com 0:788f63dcf0a0 154
metin.ozkan@analog.com 0:788f63dcf0a0 155 *ercflag = (ercflag_t)reg_ercflag.bits.sysovlo;
metin.ozkan@analog.com 0:788f63dcf0a0 156
metin.ozkan@analog.com 0:788f63dcf0a0 157 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 158 }
metin.ozkan@analog.com 0:788f63dcf0a0 159
metin.ozkan@analog.com 0:788f63dcf0a0 160 int MAX77654::GetSysUndervoltageLockout(ercflag_t *ercflag)
metin.ozkan@analog.com 0:788f63dcf0a0 161 {
metin.ozkan@analog.com 0:788f63dcf0a0 162 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 163 reg_ercflag_t reg_ercflag;
metin.ozkan@analog.com 0:788f63dcf0a0 164
metin.ozkan@analog.com 0:788f63dcf0a0 165 ret = read_register(ERCFLAG, (uint8_t *)&(reg_ercflag));
metin.ozkan@analog.com 0:788f63dcf0a0 166 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 167 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 168 }
metin.ozkan@analog.com 0:788f63dcf0a0 169
metin.ozkan@analog.com 0:788f63dcf0a0 170 *ercflag = (ercflag_t)reg_ercflag.bits.sysuvlo;
metin.ozkan@analog.com 0:788f63dcf0a0 171
metin.ozkan@analog.com 0:788f63dcf0a0 172 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 173 }
metin.ozkan@analog.com 0:788f63dcf0a0 174
metin.ozkan@analog.com 0:788f63dcf0a0 175 int MAX77654::GetManualResetTimer(ercflag_t *ercflag)
metin.ozkan@analog.com 0:788f63dcf0a0 176 {
metin.ozkan@analog.com 0:788f63dcf0a0 177 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 178 reg_ercflag_t reg_ercflag;
metin.ozkan@analog.com 0:788f63dcf0a0 179
metin.ozkan@analog.com 0:788f63dcf0a0 180 ret = read_register(ERCFLAG, (uint8_t *)&(reg_ercflag));
metin.ozkan@analog.com 0:788f63dcf0a0 181 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 182 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 183 }
metin.ozkan@analog.com 0:788f63dcf0a0 184
metin.ozkan@analog.com 0:788f63dcf0a0 185 *ercflag = (ercflag_t)reg_ercflag.bits.mrst;
metin.ozkan@analog.com 0:788f63dcf0a0 186
metin.ozkan@analog.com 0:788f63dcf0a0 187 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 188 }
metin.ozkan@analog.com 0:788f63dcf0a0 189
metin.ozkan@analog.com 0:788f63dcf0a0 190 int MAX77654::GetSoftwareOffFlag(ercflag_t *ercflag)
metin.ozkan@analog.com 0:788f63dcf0a0 191 {
metin.ozkan@analog.com 0:788f63dcf0a0 192 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 193 reg_ercflag_t reg_ercflag;
metin.ozkan@analog.com 0:788f63dcf0a0 194
metin.ozkan@analog.com 0:788f63dcf0a0 195 ret = read_register(ERCFLAG, (uint8_t *)&(reg_ercflag));
metin.ozkan@analog.com 0:788f63dcf0a0 196 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 197 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 198 }
metin.ozkan@analog.com 0:788f63dcf0a0 199
metin.ozkan@analog.com 0:788f63dcf0a0 200 *ercflag = (ercflag_t)reg_ercflag.bits.sft_off_f;
metin.ozkan@analog.com 0:788f63dcf0a0 201
metin.ozkan@analog.com 0:788f63dcf0a0 202 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 203 }
metin.ozkan@analog.com 0:788f63dcf0a0 204
metin.ozkan@analog.com 0:788f63dcf0a0 205 int MAX77654::GetSoftwareColdResetFlag(ercflag_t *ercflag)
metin.ozkan@analog.com 0:788f63dcf0a0 206 {
metin.ozkan@analog.com 0:788f63dcf0a0 207 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 208 reg_ercflag_t reg_ercflag;
metin.ozkan@analog.com 0:788f63dcf0a0 209
metin.ozkan@analog.com 0:788f63dcf0a0 210 ret = read_register(ERCFLAG, (uint8_t *)&(reg_ercflag));
metin.ozkan@analog.com 0:788f63dcf0a0 211 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 212 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 213 }
metin.ozkan@analog.com 0:788f63dcf0a0 214
metin.ozkan@analog.com 0:788f63dcf0a0 215 *ercflag = (ercflag_t)reg_ercflag.bits.sft_crst_f;
metin.ozkan@analog.com 0:788f63dcf0a0 216
metin.ozkan@analog.com 0:788f63dcf0a0 217 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 218 }
metin.ozkan@analog.com 0:788f63dcf0a0 219
metin.ozkan@analog.com 0:788f63dcf0a0 220 int MAX77654::GetWatchdogTimerOffFlag(ercflag_t *ercflag)
metin.ozkan@analog.com 0:788f63dcf0a0 221 {
metin.ozkan@analog.com 0:788f63dcf0a0 222 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 223 reg_ercflag_t reg_ercflag;
metin.ozkan@analog.com 0:788f63dcf0a0 224
metin.ozkan@analog.com 0:788f63dcf0a0 225 ret = read_register(ERCFLAG, (uint8_t *)&(reg_ercflag));
metin.ozkan@analog.com 0:788f63dcf0a0 226 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 227 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 228 }
metin.ozkan@analog.com 0:788f63dcf0a0 229
metin.ozkan@analog.com 0:788f63dcf0a0 230 *ercflag = (ercflag_t)reg_ercflag.bits.wdt_off;
metin.ozkan@analog.com 0:788f63dcf0a0 231
metin.ozkan@analog.com 0:788f63dcf0a0 232 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 233 }
metin.ozkan@analog.com 0:788f63dcf0a0 234
metin.ozkan@analog.com 0:788f63dcf0a0 235 int MAX77654::GetWatchdogTimerResetFlag(ercflag_t *ercflag)
metin.ozkan@analog.com 0:788f63dcf0a0 236 {
metin.ozkan@analog.com 0:788f63dcf0a0 237 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 238 reg_ercflag_t reg_ercflag;
metin.ozkan@analog.com 0:788f63dcf0a0 239
metin.ozkan@analog.com 0:788f63dcf0a0 240 ret = read_register(ERCFLAG, (uint8_t *)&(reg_ercflag));
metin.ozkan@analog.com 0:788f63dcf0a0 241 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 242 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 243 }
metin.ozkan@analog.com 0:788f63dcf0a0 244
metin.ozkan@analog.com 0:788f63dcf0a0 245 *ercflag = (ercflag_t)reg_ercflag.bits.wdt_rst;
metin.ozkan@analog.com 0:788f63dcf0a0 246
metin.ozkan@analog.com 0:788f63dcf0a0 247 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 248 }
metin.ozkan@analog.com 0:788f63dcf0a0 249
metin.ozkan@analog.com 0:788f63dcf0a0 250 int MAX77654::GetDeviceIdentification(didm_t *didm)
metin.ozkan@analog.com 0:788f63dcf0a0 251 {
metin.ozkan@analog.com 0:788f63dcf0a0 252 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 253 reg_stat_glbl_t reg_stat_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 254
metin.ozkan@analog.com 0:788f63dcf0a0 255 ret = read_register(STAT_GLBL, (uint8_t *)&(reg_stat_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 256 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 257 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 258 }
metin.ozkan@analog.com 0:788f63dcf0a0 259
metin.ozkan@analog.com 0:788f63dcf0a0 260 *didm = (didm_t)reg_stat_glbl.bits.didm;
metin.ozkan@analog.com 0:788f63dcf0a0 261
metin.ozkan@analog.com 0:788f63dcf0a0 262 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 263 }
metin.ozkan@analog.com 0:788f63dcf0a0 264
metin.ozkan@analog.com 0:788f63dcf0a0 265 int MAX77654::GetBOKInterruptStatus(bok_t* bok)
metin.ozkan@analog.com 0:788f63dcf0a0 266 {
metin.ozkan@analog.com 0:788f63dcf0a0 267 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 268 reg_stat_glbl_t reg_stat_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 269
metin.ozkan@analog.com 0:788f63dcf0a0 270 ret = read_register(STAT_GLBL, (uint8_t *)&(reg_stat_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 271 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 272 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 273 }
metin.ozkan@analog.com 0:788f63dcf0a0 274
metin.ozkan@analog.com 0:788f63dcf0a0 275 *bok = (bok_t)reg_stat_glbl.bits.bok;
metin.ozkan@analog.com 0:788f63dcf0a0 276
metin.ozkan@analog.com 0:788f63dcf0a0 277 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 278 }
metin.ozkan@analog.com 0:788f63dcf0a0 279
metin.ozkan@analog.com 0:788f63dcf0a0 280 int MAX77654::GetLDO0DropoutRisingStatus(dod0_s_t* dod0_s)
metin.ozkan@analog.com 0:788f63dcf0a0 281 {
metin.ozkan@analog.com 0:788f63dcf0a0 282 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 283 reg_stat_glbl_t reg_stat_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 284
metin.ozkan@analog.com 0:788f63dcf0a0 285 ret = read_register(STAT_GLBL, (uint8_t *)&(reg_stat_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 286 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 287 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 288 }
metin.ozkan@analog.com 0:788f63dcf0a0 289
metin.ozkan@analog.com 0:788f63dcf0a0 290 *dod0_s = (dod0_s_t)reg_stat_glbl.bits.dod0_s;
metin.ozkan@analog.com 0:788f63dcf0a0 291
metin.ozkan@analog.com 0:788f63dcf0a0 292 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 293 }
metin.ozkan@analog.com 0:788f63dcf0a0 294
metin.ozkan@analog.com 0:788f63dcf0a0 295 int MAX77654::GetLDO1DropoutRisingStatus(dod1_s_t* dod1_s)
metin.ozkan@analog.com 0:788f63dcf0a0 296 {
metin.ozkan@analog.com 0:788f63dcf0a0 297 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 298 reg_stat_glbl_t reg_stat_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 299
metin.ozkan@analog.com 0:788f63dcf0a0 300 ret = read_register(STAT_GLBL, (uint8_t *)&(reg_stat_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 301 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 302 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 303 }
metin.ozkan@analog.com 0:788f63dcf0a0 304
metin.ozkan@analog.com 0:788f63dcf0a0 305 *dod1_s = (dod1_s_t)reg_stat_glbl.bits.dod1_s;
metin.ozkan@analog.com 0:788f63dcf0a0 306
metin.ozkan@analog.com 0:788f63dcf0a0 307 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 308 }
metin.ozkan@analog.com 0:788f63dcf0a0 309
metin.ozkan@analog.com 0:788f63dcf0a0 310 int MAX77654::GetThermalAlarm2Status(tjal2_s_t* tjal2_s)
metin.ozkan@analog.com 0:788f63dcf0a0 311 {
metin.ozkan@analog.com 0:788f63dcf0a0 312 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 313 reg_stat_glbl_t reg_stat_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 314
metin.ozkan@analog.com 0:788f63dcf0a0 315 ret = read_register(STAT_GLBL, (uint8_t *)&(reg_stat_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 316 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 317 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 318 }
metin.ozkan@analog.com 0:788f63dcf0a0 319
metin.ozkan@analog.com 0:788f63dcf0a0 320 *tjal2_s = (tjal2_s_t)reg_stat_glbl.bits.tjal2_s;
metin.ozkan@analog.com 0:788f63dcf0a0 321
metin.ozkan@analog.com 0:788f63dcf0a0 322 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 323 }
metin.ozkan@analog.com 0:788f63dcf0a0 324
metin.ozkan@analog.com 0:788f63dcf0a0 325 int MAX77654::GetThermalAlarm1Status(tjal1_s_t* tjal1_s)
metin.ozkan@analog.com 0:788f63dcf0a0 326 {
metin.ozkan@analog.com 0:788f63dcf0a0 327 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 328 reg_stat_glbl_t reg_stat_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 329
metin.ozkan@analog.com 0:788f63dcf0a0 330 ret = read_register(STAT_GLBL, (uint8_t *)&(reg_stat_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 331 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 332 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 333 }
metin.ozkan@analog.com 0:788f63dcf0a0 334
metin.ozkan@analog.com 0:788f63dcf0a0 335 *tjal1_s = (tjal1_s_t)reg_stat_glbl.bits.tjal1_s;
metin.ozkan@analog.com 0:788f63dcf0a0 336
metin.ozkan@analog.com 0:788f63dcf0a0 337 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 338 }
metin.ozkan@analog.com 0:788f63dcf0a0 339
metin.ozkan@analog.com 0:788f63dcf0a0 340 int MAX77654::GetnENDebouncedStatus(stat_en_t* stat_en)
metin.ozkan@analog.com 0:788f63dcf0a0 341 {
metin.ozkan@analog.com 0:788f63dcf0a0 342 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 343 reg_stat_glbl_t reg_stat_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 344
metin.ozkan@analog.com 0:788f63dcf0a0 345 ret = read_register(STAT_GLBL, (uint8_t *)&(reg_stat_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 346 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 347 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 348 }
metin.ozkan@analog.com 0:788f63dcf0a0 349
metin.ozkan@analog.com 0:788f63dcf0a0 350 *stat_en = (stat_en_t)reg_stat_glbl.bits.stat_en;
metin.ozkan@analog.com 0:788f63dcf0a0 351
metin.ozkan@analog.com 0:788f63dcf0a0 352 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 353 }
metin.ozkan@analog.com 0:788f63dcf0a0 354
metin.ozkan@analog.com 0:788f63dcf0a0 355 int MAX77654::GetSoftwareVersionGateDrive(stat_irq_t* stat_irq)
metin.ozkan@analog.com 0:788f63dcf0a0 356 {
metin.ozkan@analog.com 0:788f63dcf0a0 357 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 358 reg_stat_glbl_t reg_stat_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 359
metin.ozkan@analog.com 0:788f63dcf0a0 360 ret = read_register(STAT_GLBL, (uint8_t *)&(reg_stat_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 361 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 362 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 363 }
metin.ozkan@analog.com 0:788f63dcf0a0 364
metin.ozkan@analog.com 0:788f63dcf0a0 365 *stat_irq = (stat_irq_t)reg_stat_glbl.bits.stat_irq;
metin.ozkan@analog.com 0:788f63dcf0a0 366
metin.ozkan@analog.com 0:788f63dcf0a0 367 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 368 }
metin.ozkan@analog.com 0:788f63dcf0a0 369
metin.ozkan@analog.com 0:788f63dcf0a0 370 int MAX77654::SetLDO1FaultInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 371 {
metin.ozkan@analog.com 0:788f63dcf0a0 372 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 373
metin.ozkan@analog.com 0:788f63dcf0a0 374 SET_BIT_FIELD(INTM_GLBL1, reg_intm_glbl1, reg_intm_glbl1.bits.ldo1_m, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 375
metin.ozkan@analog.com 0:788f63dcf0a0 376 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 377 }
metin.ozkan@analog.com 0:788f63dcf0a0 378
metin.ozkan@analog.com 0:788f63dcf0a0 379 int MAX77654::GetLDO1FaultInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 380 {
metin.ozkan@analog.com 0:788f63dcf0a0 381 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 382 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 383
metin.ozkan@analog.com 0:788f63dcf0a0 384 ret = read_register(INTM_GLBL1, (uint8_t *)&(reg_intm_glbl1));
metin.ozkan@analog.com 0:788f63dcf0a0 385 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 386 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 387 }
metin.ozkan@analog.com 0:788f63dcf0a0 388
metin.ozkan@analog.com 0:788f63dcf0a0 389 *intm = (intm_t)reg_intm_glbl1.bits.ldo1_m;
metin.ozkan@analog.com 0:788f63dcf0a0 390
metin.ozkan@analog.com 0:788f63dcf0a0 391 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 392 }
metin.ozkan@analog.com 0:788f63dcf0a0 393
metin.ozkan@analog.com 0:788f63dcf0a0 394 int MAX77654::SetLDO0FaultInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 395 {
metin.ozkan@analog.com 0:788f63dcf0a0 396 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 397
metin.ozkan@analog.com 0:788f63dcf0a0 398 SET_BIT_FIELD(INTM_GLBL1, reg_intm_glbl1, reg_intm_glbl1.bits.ldo0_m, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 399
metin.ozkan@analog.com 0:788f63dcf0a0 400 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 401 }
metin.ozkan@analog.com 0:788f63dcf0a0 402
metin.ozkan@analog.com 0:788f63dcf0a0 403 int MAX77654::GetLDO0FaultInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 404 {
metin.ozkan@analog.com 0:788f63dcf0a0 405 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 406 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 407
metin.ozkan@analog.com 0:788f63dcf0a0 408 ret = read_register(INTM_GLBL1, (uint8_t *)&(reg_intm_glbl1));
metin.ozkan@analog.com 0:788f63dcf0a0 409 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 410 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 411 }
metin.ozkan@analog.com 0:788f63dcf0a0 412
metin.ozkan@analog.com 0:788f63dcf0a0 413 *intm = (intm_t)reg_intm_glbl1.bits.ldo0_m;
metin.ozkan@analog.com 0:788f63dcf0a0 414
metin.ozkan@analog.com 0:788f63dcf0a0 415 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 416 }
metin.ozkan@analog.com 0:788f63dcf0a0 417
metin.ozkan@analog.com 0:788f63dcf0a0 418 int MAX77654::SetSBBTimeoutMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 419 {
metin.ozkan@analog.com 0:788f63dcf0a0 420 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 421
metin.ozkan@analog.com 0:788f63dcf0a0 422 SET_BIT_FIELD(INTM_GLBL1, reg_intm_glbl1, reg_intm_glbl1.bits.sbb_to_m, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 423
metin.ozkan@analog.com 0:788f63dcf0a0 424 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 425 }
metin.ozkan@analog.com 0:788f63dcf0a0 426
metin.ozkan@analog.com 0:788f63dcf0a0 427 int MAX77654::GetSBBTimeoutMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 428 {
metin.ozkan@analog.com 0:788f63dcf0a0 429 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 430 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 431
metin.ozkan@analog.com 0:788f63dcf0a0 432 ret = read_register(INTM_GLBL1, (uint8_t *)&(reg_intm_glbl1));
metin.ozkan@analog.com 0:788f63dcf0a0 433 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 434 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 435 }
metin.ozkan@analog.com 0:788f63dcf0a0 436
metin.ozkan@analog.com 0:788f63dcf0a0 437 *intm = (intm_t)reg_intm_glbl1.bits.sbb_to_m;
metin.ozkan@analog.com 0:788f63dcf0a0 438
metin.ozkan@analog.com 0:788f63dcf0a0 439 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 440 }
metin.ozkan@analog.com 0:788f63dcf0a0 441
metin.ozkan@analog.com 0:788f63dcf0a0 442 int MAX77654::SetGPI2RisingInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 443 {
metin.ozkan@analog.com 0:788f63dcf0a0 444 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 445
metin.ozkan@analog.com 0:788f63dcf0a0 446 SET_BIT_FIELD(INTM_GLBL1, reg_intm_glbl1, reg_intm_glbl1.bits.gpi2_rm, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 447
metin.ozkan@analog.com 0:788f63dcf0a0 448 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 449 }
metin.ozkan@analog.com 0:788f63dcf0a0 450
metin.ozkan@analog.com 0:788f63dcf0a0 451 int MAX77654::GetGPI2RisingInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 452 {
metin.ozkan@analog.com 0:788f63dcf0a0 453 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 454 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 455
metin.ozkan@analog.com 0:788f63dcf0a0 456 ret = read_register(INTM_GLBL1, (uint8_t *)&(reg_intm_glbl1));
metin.ozkan@analog.com 0:788f63dcf0a0 457 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 458 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 459 }
metin.ozkan@analog.com 0:788f63dcf0a0 460
metin.ozkan@analog.com 0:788f63dcf0a0 461 *intm = (intm_t)reg_intm_glbl1.bits.gpi2_rm;
metin.ozkan@analog.com 0:788f63dcf0a0 462
metin.ozkan@analog.com 0:788f63dcf0a0 463 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 464 }
metin.ozkan@analog.com 0:788f63dcf0a0 465
metin.ozkan@analog.com 0:788f63dcf0a0 466 int MAX77654::SetGPI2FallingInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 467 {
metin.ozkan@analog.com 0:788f63dcf0a0 468 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 469
metin.ozkan@analog.com 0:788f63dcf0a0 470 SET_BIT_FIELD(INTM_GLBL1, reg_intm_glbl1, reg_intm_glbl1.bits.gpi2_fm, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 471
metin.ozkan@analog.com 0:788f63dcf0a0 472 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 473 }
metin.ozkan@analog.com 0:788f63dcf0a0 474
metin.ozkan@analog.com 0:788f63dcf0a0 475 int MAX77654::GetGPI2FallingInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 476 {
metin.ozkan@analog.com 0:788f63dcf0a0 477 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 478 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 479
metin.ozkan@analog.com 0:788f63dcf0a0 480 ret = read_register(INTM_GLBL1, (uint8_t *)&(reg_intm_glbl1));
metin.ozkan@analog.com 0:788f63dcf0a0 481 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 482 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 483 }
metin.ozkan@analog.com 0:788f63dcf0a0 484
metin.ozkan@analog.com 0:788f63dcf0a0 485 *intm = (intm_t)reg_intm_glbl1.bits.gpi2_fm;
metin.ozkan@analog.com 0:788f63dcf0a0 486
metin.ozkan@analog.com 0:788f63dcf0a0 487 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 488 }
metin.ozkan@analog.com 0:788f63dcf0a0 489
metin.ozkan@analog.com 0:788f63dcf0a0 490 int MAX77654::SetGPI1RisingInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 491 {
metin.ozkan@analog.com 0:788f63dcf0a0 492 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 493
metin.ozkan@analog.com 0:788f63dcf0a0 494 SET_BIT_FIELD(INTM_GLBL1, reg_intm_glbl1, reg_intm_glbl1.bits.gpi1_rm, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 495
metin.ozkan@analog.com 0:788f63dcf0a0 496 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 497 }
metin.ozkan@analog.com 0:788f63dcf0a0 498
metin.ozkan@analog.com 0:788f63dcf0a0 499 int MAX77654::GetGPI1RisingInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 500 {
metin.ozkan@analog.com 0:788f63dcf0a0 501 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 502 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 503
metin.ozkan@analog.com 0:788f63dcf0a0 504 ret = read_register(INTM_GLBL1, (uint8_t *)&(reg_intm_glbl1));
metin.ozkan@analog.com 0:788f63dcf0a0 505 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 506 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 507 }
metin.ozkan@analog.com 0:788f63dcf0a0 508
metin.ozkan@analog.com 0:788f63dcf0a0 509 *intm = (intm_t)reg_intm_glbl1.bits.gpi1_rm;
metin.ozkan@analog.com 0:788f63dcf0a0 510
metin.ozkan@analog.com 0:788f63dcf0a0 511 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 512 }
metin.ozkan@analog.com 0:788f63dcf0a0 513
metin.ozkan@analog.com 0:788f63dcf0a0 514 int MAX77654::SetGPI1FallingInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 515 {
metin.ozkan@analog.com 0:788f63dcf0a0 516 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 517
metin.ozkan@analog.com 0:788f63dcf0a0 518 SET_BIT_FIELD(INTM_GLBL1, reg_intm_glbl1, reg_intm_glbl1.bits.gpi1_fm, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 519
metin.ozkan@analog.com 0:788f63dcf0a0 520 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 521 }
metin.ozkan@analog.com 0:788f63dcf0a0 522
metin.ozkan@analog.com 0:788f63dcf0a0 523 int MAX77654::GetGPI1FallingInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 524 {
metin.ozkan@analog.com 0:788f63dcf0a0 525 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 526 reg_intm_glbl1_t reg_intm_glbl1;
metin.ozkan@analog.com 0:788f63dcf0a0 527
metin.ozkan@analog.com 0:788f63dcf0a0 528 ret = read_register(INTM_GLBL1, (uint8_t *)&(reg_intm_glbl1));
metin.ozkan@analog.com 0:788f63dcf0a0 529 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 530 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 531 }
metin.ozkan@analog.com 0:788f63dcf0a0 532
metin.ozkan@analog.com 0:788f63dcf0a0 533 *intm = (intm_t)reg_intm_glbl1.bits.gpi1_fm;
metin.ozkan@analog.com 0:788f63dcf0a0 534
metin.ozkan@analog.com 0:788f63dcf0a0 535 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 536 }
metin.ozkan@analog.com 0:788f63dcf0a0 537
metin.ozkan@analog.com 0:788f63dcf0a0 538 int MAX77654::SetDropout0RisingInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 539 {
metin.ozkan@analog.com 0:788f63dcf0a0 540 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 541
metin.ozkan@analog.com 0:788f63dcf0a0 542 SET_BIT_FIELD(INTM_GLBL0, reg_intm_glbl0, reg_intm_glbl0.bits.dod0_rm, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 543
metin.ozkan@analog.com 0:788f63dcf0a0 544 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 545 }
metin.ozkan@analog.com 0:788f63dcf0a0 546
metin.ozkan@analog.com 0:788f63dcf0a0 547 int MAX77654::GetDropout0RisingInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 548 {
metin.ozkan@analog.com 0:788f63dcf0a0 549 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 550 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 551
metin.ozkan@analog.com 0:788f63dcf0a0 552 ret = read_register(INTM_GLBL0, (uint8_t *)&(reg_intm_glbl0));
metin.ozkan@analog.com 0:788f63dcf0a0 553 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 554 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 555 }
metin.ozkan@analog.com 0:788f63dcf0a0 556
metin.ozkan@analog.com 0:788f63dcf0a0 557 *intm = (intm_t)reg_intm_glbl0.bits.dod0_rm;
metin.ozkan@analog.com 0:788f63dcf0a0 558
metin.ozkan@analog.com 0:788f63dcf0a0 559 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 560 }
metin.ozkan@analog.com 0:788f63dcf0a0 561
metin.ozkan@analog.com 0:788f63dcf0a0 562 int MAX77654::SetDropout1RisingInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 563 {
metin.ozkan@analog.com 0:788f63dcf0a0 564 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 565
metin.ozkan@analog.com 0:788f63dcf0a0 566 SET_BIT_FIELD(INTM_GLBL0, reg_intm_glbl0, reg_intm_glbl0.bits.dod1_rm, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 567
metin.ozkan@analog.com 0:788f63dcf0a0 568 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 569 }
metin.ozkan@analog.com 0:788f63dcf0a0 570
metin.ozkan@analog.com 0:788f63dcf0a0 571 int MAX77654::GetDropout1RisingInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 572 {
metin.ozkan@analog.com 0:788f63dcf0a0 573 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 574 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 575
metin.ozkan@analog.com 0:788f63dcf0a0 576 ret = read_register(INTM_GLBL0, (uint8_t *)&(reg_intm_glbl0));
metin.ozkan@analog.com 0:788f63dcf0a0 577 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 578 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 579 }
metin.ozkan@analog.com 0:788f63dcf0a0 580
metin.ozkan@analog.com 0:788f63dcf0a0 581 *intm = (intm_t)reg_intm_glbl0.bits.dod1_rm;
metin.ozkan@analog.com 0:788f63dcf0a0 582
metin.ozkan@analog.com 0:788f63dcf0a0 583 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 584 }
metin.ozkan@analog.com 0:788f63dcf0a0 585
metin.ozkan@analog.com 0:788f63dcf0a0 586 int MAX77654::SetThermalAlarm2RisingInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 587 {
metin.ozkan@analog.com 0:788f63dcf0a0 588 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 589
metin.ozkan@analog.com 0:788f63dcf0a0 590 SET_BIT_FIELD(INTM_GLBL0, reg_intm_glbl0, reg_intm_glbl0.bits.tjal2_rm, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 591
metin.ozkan@analog.com 0:788f63dcf0a0 592 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 593 }
metin.ozkan@analog.com 0:788f63dcf0a0 594
metin.ozkan@analog.com 0:788f63dcf0a0 595 int MAX77654::GetThermalAlarm2RisingInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 596 {
metin.ozkan@analog.com 0:788f63dcf0a0 597 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 598 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 599
metin.ozkan@analog.com 0:788f63dcf0a0 600 ret = read_register(INTM_GLBL0, (uint8_t *)&(reg_intm_glbl0));
metin.ozkan@analog.com 0:788f63dcf0a0 601 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 602 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 603 }
metin.ozkan@analog.com 0:788f63dcf0a0 604
metin.ozkan@analog.com 0:788f63dcf0a0 605 *intm = (intm_t)reg_intm_glbl0.bits.tjal2_rm;
metin.ozkan@analog.com 0:788f63dcf0a0 606
metin.ozkan@analog.com 0:788f63dcf0a0 607 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 608 }
metin.ozkan@analog.com 0:788f63dcf0a0 609
metin.ozkan@analog.com 0:788f63dcf0a0 610 int MAX77654::SetThermalAlarm1RisingInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 611 {
metin.ozkan@analog.com 0:788f63dcf0a0 612 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 613
metin.ozkan@analog.com 0:788f63dcf0a0 614 SET_BIT_FIELD(INTM_GLBL0, reg_intm_glbl0, reg_intm_glbl0.bits.tjal1_rm, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 615
metin.ozkan@analog.com 0:788f63dcf0a0 616 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 617 }
metin.ozkan@analog.com 0:788f63dcf0a0 618
metin.ozkan@analog.com 0:788f63dcf0a0 619 int MAX77654::GetThermalAlarm1RisingInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 620 {
metin.ozkan@analog.com 0:788f63dcf0a0 621 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 622 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 623
metin.ozkan@analog.com 0:788f63dcf0a0 624 ret = read_register(INTM_GLBL0, (uint8_t *)&(reg_intm_glbl0));
metin.ozkan@analog.com 0:788f63dcf0a0 625 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 626 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 627 }
metin.ozkan@analog.com 0:788f63dcf0a0 628
metin.ozkan@analog.com 0:788f63dcf0a0 629 *intm = (intm_t)reg_intm_glbl0.bits.tjal1_rm;
metin.ozkan@analog.com 0:788f63dcf0a0 630
metin.ozkan@analog.com 0:788f63dcf0a0 631 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 632 }
metin.ozkan@analog.com 0:788f63dcf0a0 633
metin.ozkan@analog.com 0:788f63dcf0a0 634 int MAX77654::SetnENRisingInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 635 {
metin.ozkan@analog.com 0:788f63dcf0a0 636 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 637
metin.ozkan@analog.com 0:788f63dcf0a0 638 SET_BIT_FIELD(INTM_GLBL0, reg_intm_glbl0, reg_intm_glbl0.bits.nen_rm, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 639
metin.ozkan@analog.com 0:788f63dcf0a0 640 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 641 }
metin.ozkan@analog.com 0:788f63dcf0a0 642
metin.ozkan@analog.com 0:788f63dcf0a0 643 int MAX77654::GetnENRisingInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 644 {
metin.ozkan@analog.com 0:788f63dcf0a0 645 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 646 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 647
metin.ozkan@analog.com 0:788f63dcf0a0 648 ret = read_register(INTM_GLBL0, (uint8_t *)&(reg_intm_glbl0));
metin.ozkan@analog.com 0:788f63dcf0a0 649 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 650 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 651 }
metin.ozkan@analog.com 0:788f63dcf0a0 652
metin.ozkan@analog.com 0:788f63dcf0a0 653 *intm = (intm_t)reg_intm_glbl0.bits.nen_rm;
metin.ozkan@analog.com 0:788f63dcf0a0 654
metin.ozkan@analog.com 0:788f63dcf0a0 655 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 656 }
metin.ozkan@analog.com 0:788f63dcf0a0 657
metin.ozkan@analog.com 0:788f63dcf0a0 658 int MAX77654::SetnENFallingInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 659 {
metin.ozkan@analog.com 0:788f63dcf0a0 660 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 661
metin.ozkan@analog.com 0:788f63dcf0a0 662 SET_BIT_FIELD(INTM_GLBL0, reg_intm_glbl0, reg_intm_glbl0.bits.nen_fm, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 663
metin.ozkan@analog.com 0:788f63dcf0a0 664 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 665 }
metin.ozkan@analog.com 0:788f63dcf0a0 666
metin.ozkan@analog.com 0:788f63dcf0a0 667 int MAX77654::GetnENFallingInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 668 {
metin.ozkan@analog.com 0:788f63dcf0a0 669 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 670 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 671
metin.ozkan@analog.com 0:788f63dcf0a0 672 ret = read_register(INTM_GLBL0, (uint8_t *)&(reg_intm_glbl0));
metin.ozkan@analog.com 0:788f63dcf0a0 673 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 674 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 675 }
metin.ozkan@analog.com 0:788f63dcf0a0 676
metin.ozkan@analog.com 0:788f63dcf0a0 677 *intm = (intm_t)reg_intm_glbl0.bits.nen_fm;
metin.ozkan@analog.com 0:788f63dcf0a0 678
metin.ozkan@analog.com 0:788f63dcf0a0 679 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 680 }
metin.ozkan@analog.com 0:788f63dcf0a0 681
metin.ozkan@analog.com 0:788f63dcf0a0 682 int MAX77654::SetGPI0RisingInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 683 {
metin.ozkan@analog.com 0:788f63dcf0a0 684 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 685
metin.ozkan@analog.com 0:788f63dcf0a0 686 SET_BIT_FIELD(INTM_GLBL0, reg_intm_glbl0, reg_intm_glbl0.bits.gpi0_rm, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 687
metin.ozkan@analog.com 0:788f63dcf0a0 688 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 689 }
metin.ozkan@analog.com 0:788f63dcf0a0 690
metin.ozkan@analog.com 0:788f63dcf0a0 691 int MAX77654::GetGPI0RisingInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 692 {
metin.ozkan@analog.com 0:788f63dcf0a0 693 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 694 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 695
metin.ozkan@analog.com 0:788f63dcf0a0 696 ret = read_register(INTM_GLBL0, (uint8_t *)&(reg_intm_glbl0));
metin.ozkan@analog.com 0:788f63dcf0a0 697 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 698 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 699 }
metin.ozkan@analog.com 0:788f63dcf0a0 700
metin.ozkan@analog.com 0:788f63dcf0a0 701 *intm = (intm_t)reg_intm_glbl0.bits.gpi0_rm;
metin.ozkan@analog.com 0:788f63dcf0a0 702
metin.ozkan@analog.com 0:788f63dcf0a0 703 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 704 }
metin.ozkan@analog.com 0:788f63dcf0a0 705
metin.ozkan@analog.com 0:788f63dcf0a0 706 int MAX77654::SetGPI0FallingInterruptMask(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 707 {
metin.ozkan@analog.com 0:788f63dcf0a0 708 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 709
metin.ozkan@analog.com 0:788f63dcf0a0 710 SET_BIT_FIELD(INTM_GLBL0, reg_intm_glbl0, reg_intm_glbl0.bits.gpi0_fm, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 711
metin.ozkan@analog.com 0:788f63dcf0a0 712 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 713 }
metin.ozkan@analog.com 0:788f63dcf0a0 714
metin.ozkan@analog.com 0:788f63dcf0a0 715 int MAX77654::GetGPI0FallingInterruptMask(intm_t* intm)
metin.ozkan@analog.com 0:788f63dcf0a0 716 {
metin.ozkan@analog.com 0:788f63dcf0a0 717 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 718 reg_intm_glbl0_t reg_intm_glbl0;
metin.ozkan@analog.com 0:788f63dcf0a0 719
metin.ozkan@analog.com 0:788f63dcf0a0 720 ret = read_register(INTM_GLBL0, (uint8_t *)&(reg_intm_glbl0));
metin.ozkan@analog.com 0:788f63dcf0a0 721 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 722 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 723 }
metin.ozkan@analog.com 0:788f63dcf0a0 724
metin.ozkan@analog.com 0:788f63dcf0a0 725 *intm = (intm_t)reg_intm_glbl0.bits.gpi0_fm;
metin.ozkan@analog.com 0:788f63dcf0a0 726
metin.ozkan@analog.com 0:788f63dcf0a0 727 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 728 }
metin.ozkan@analog.com 0:788f63dcf0a0 729
metin.ozkan@analog.com 0:788f63dcf0a0 730 int MAX77654::SetnENInternalPullupResistor(pu_dis_t pu_dis)
metin.ozkan@analog.com 0:788f63dcf0a0 731 {
metin.ozkan@analog.com 0:788f63dcf0a0 732 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 733
metin.ozkan@analog.com 0:788f63dcf0a0 734 SET_BIT_FIELD(CNFG_GLBL, reg_cnfg_glbl, reg_cnfg_glbl.bits.pu_dis, pu_dis);
metin.ozkan@analog.com 0:788f63dcf0a0 735
metin.ozkan@analog.com 0:788f63dcf0a0 736 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 737 }
metin.ozkan@analog.com 0:788f63dcf0a0 738
metin.ozkan@analog.com 0:788f63dcf0a0 739 int MAX77654::GetnENInternalPullupResistor(pu_dis_t* pu_dis)
metin.ozkan@analog.com 0:788f63dcf0a0 740 {
metin.ozkan@analog.com 0:788f63dcf0a0 741 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 742 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 743
metin.ozkan@analog.com 0:788f63dcf0a0 744 ret = read_register(CNFG_GLBL, (uint8_t *)&(reg_cnfg_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 745 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 746 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 747 }
metin.ozkan@analog.com 0:788f63dcf0a0 748
metin.ozkan@analog.com 0:788f63dcf0a0 749 *pu_dis = (pu_dis_t)reg_cnfg_glbl.bits.pu_dis;
metin.ozkan@analog.com 0:788f63dcf0a0 750
metin.ozkan@analog.com 0:788f63dcf0a0 751 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 752 }
metin.ozkan@analog.com 0:788f63dcf0a0 753
metin.ozkan@analog.com 0:788f63dcf0a0 754 int MAX77654::SetManualResetTime(t_mrst_t t_mrst)
metin.ozkan@analog.com 0:788f63dcf0a0 755 {
metin.ozkan@analog.com 0:788f63dcf0a0 756 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 757
metin.ozkan@analog.com 0:788f63dcf0a0 758 SET_BIT_FIELD(CNFG_GLBL, reg_cnfg_glbl, reg_cnfg_glbl.bits.t_mrst, t_mrst);
metin.ozkan@analog.com 0:788f63dcf0a0 759
metin.ozkan@analog.com 0:788f63dcf0a0 760 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 761 }
metin.ozkan@analog.com 0:788f63dcf0a0 762
metin.ozkan@analog.com 0:788f63dcf0a0 763 int MAX77654::GetManualResetTime(t_mrst_t* t_mrst)
metin.ozkan@analog.com 0:788f63dcf0a0 764 {
metin.ozkan@analog.com 0:788f63dcf0a0 765 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 766 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 767
metin.ozkan@analog.com 0:788f63dcf0a0 768 ret = read_register(CNFG_GLBL, (uint8_t *)&(reg_cnfg_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 769 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 770 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 771 }
metin.ozkan@analog.com 0:788f63dcf0a0 772
metin.ozkan@analog.com 0:788f63dcf0a0 773 *t_mrst = (t_mrst_t)reg_cnfg_glbl.bits.t_mrst;
metin.ozkan@analog.com 0:788f63dcf0a0 774
metin.ozkan@analog.com 0:788f63dcf0a0 775 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 776 }
metin.ozkan@analog.com 0:788f63dcf0a0 777
metin.ozkan@analog.com 0:788f63dcf0a0 778 int MAX77654::SetMainBiasLowerPowerModeReq(sbia_lpm_t sbia_lpm)
metin.ozkan@analog.com 0:788f63dcf0a0 779 {
metin.ozkan@analog.com 0:788f63dcf0a0 780 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 781
metin.ozkan@analog.com 0:788f63dcf0a0 782 SET_BIT_FIELD(CNFG_GLBL, reg_cnfg_glbl, reg_cnfg_glbl.bits.sbia_lpm, sbia_lpm);
metin.ozkan@analog.com 0:788f63dcf0a0 783
metin.ozkan@analog.com 0:788f63dcf0a0 784 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 785 }
metin.ozkan@analog.com 0:788f63dcf0a0 786
metin.ozkan@analog.com 0:788f63dcf0a0 787 int MAX77654::GetMainBiasLowerPowerModeReq(sbia_lpm_t* sbia_lpm)
metin.ozkan@analog.com 0:788f63dcf0a0 788 {
metin.ozkan@analog.com 0:788f63dcf0a0 789 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 790 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 791
metin.ozkan@analog.com 0:788f63dcf0a0 792 ret = read_register(CNFG_GLBL, (uint8_t *)&(reg_cnfg_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 793 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 794 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 795 }
metin.ozkan@analog.com 0:788f63dcf0a0 796
metin.ozkan@analog.com 0:788f63dcf0a0 797 *sbia_lpm = (sbia_lpm_t)reg_cnfg_glbl.bits.sbia_lpm;
metin.ozkan@analog.com 0:788f63dcf0a0 798
metin.ozkan@analog.com 0:788f63dcf0a0 799 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 800 }
metin.ozkan@analog.com 0:788f63dcf0a0 801
metin.ozkan@analog.com 0:788f63dcf0a0 802 int MAX77654::SetMainBiasEnableReq(sbia_en_t sbia_en)
metin.ozkan@analog.com 0:788f63dcf0a0 803 {
metin.ozkan@analog.com 0:788f63dcf0a0 804 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 805
metin.ozkan@analog.com 0:788f63dcf0a0 806 SET_BIT_FIELD(CNFG_GLBL, reg_cnfg_glbl, reg_cnfg_glbl.bits.sbia_en, sbia_en);
metin.ozkan@analog.com 0:788f63dcf0a0 807
metin.ozkan@analog.com 0:788f63dcf0a0 808 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 809 }
metin.ozkan@analog.com 0:788f63dcf0a0 810
metin.ozkan@analog.com 0:788f63dcf0a0 811 int MAX77654::GetMainBiasEnableReq(sbia_en_t* sbia_en)
metin.ozkan@analog.com 0:788f63dcf0a0 812 {
metin.ozkan@analog.com 0:788f63dcf0a0 813 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 814 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 815
metin.ozkan@analog.com 0:788f63dcf0a0 816 ret = read_register(CNFG_GLBL, (uint8_t *)&(reg_cnfg_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 817 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 818 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 819 }
metin.ozkan@analog.com 0:788f63dcf0a0 820
metin.ozkan@analog.com 0:788f63dcf0a0 821 *sbia_en = (sbia_en_t)reg_cnfg_glbl.bits.sbia_en;
metin.ozkan@analog.com 0:788f63dcf0a0 822
metin.ozkan@analog.com 0:788f63dcf0a0 823 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 824 }
metin.ozkan@analog.com 0:788f63dcf0a0 825
metin.ozkan@analog.com 0:788f63dcf0a0 826 int MAX77654::SetnEnInputMode(nen_mode_t nen_mode)
metin.ozkan@analog.com 0:788f63dcf0a0 827 {
metin.ozkan@analog.com 0:788f63dcf0a0 828 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 829
metin.ozkan@analog.com 0:788f63dcf0a0 830 SET_BIT_FIELD(CNFG_GLBL, reg_cnfg_glbl, reg_cnfg_glbl.bits.nen_mode, nen_mode);
metin.ozkan@analog.com 0:788f63dcf0a0 831
metin.ozkan@analog.com 0:788f63dcf0a0 832 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 833 }
metin.ozkan@analog.com 0:788f63dcf0a0 834
metin.ozkan@analog.com 0:788f63dcf0a0 835 int MAX77654::GetnEnInputMode(nen_mode_t* nen_mode)
metin.ozkan@analog.com 0:788f63dcf0a0 836 {
metin.ozkan@analog.com 0:788f63dcf0a0 837 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 838 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 839
metin.ozkan@analog.com 0:788f63dcf0a0 840 ret = read_register(CNFG_GLBL, (uint8_t *)&(reg_cnfg_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 841 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 842 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 843 }
metin.ozkan@analog.com 0:788f63dcf0a0 844
metin.ozkan@analog.com 0:788f63dcf0a0 845 *nen_mode = (nen_mode_t)reg_cnfg_glbl.bits.nen_mode;
metin.ozkan@analog.com 0:788f63dcf0a0 846
metin.ozkan@analog.com 0:788f63dcf0a0 847 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 848 }
metin.ozkan@analog.com 0:788f63dcf0a0 849
metin.ozkan@analog.com 0:788f63dcf0a0 850 int MAX77654::SetDebounceTimerEnable(dben_nen_t dben_nen)
metin.ozkan@analog.com 0:788f63dcf0a0 851 {
metin.ozkan@analog.com 0:788f63dcf0a0 852 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 853
metin.ozkan@analog.com 0:788f63dcf0a0 854 SET_BIT_FIELD(CNFG_GLBL, reg_cnfg_glbl, reg_cnfg_glbl.bits.dben_nen, dben_nen);
metin.ozkan@analog.com 0:788f63dcf0a0 855
metin.ozkan@analog.com 0:788f63dcf0a0 856 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 857 }
metin.ozkan@analog.com 0:788f63dcf0a0 858
metin.ozkan@analog.com 0:788f63dcf0a0 859 int MAX77654::GetDebounceTimerEnable(dben_nen_t* dben_nen)
metin.ozkan@analog.com 0:788f63dcf0a0 860 {
metin.ozkan@analog.com 0:788f63dcf0a0 861 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 862 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 863
metin.ozkan@analog.com 0:788f63dcf0a0 864 ret = read_register(CNFG_GLBL, (uint8_t *)&(reg_cnfg_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 865 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 866 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 867 }
metin.ozkan@analog.com 0:788f63dcf0a0 868
metin.ozkan@analog.com 0:788f63dcf0a0 869 *dben_nen = (dben_nen_t)reg_cnfg_glbl.bits.dben_nen;
metin.ozkan@analog.com 0:788f63dcf0a0 870
metin.ozkan@analog.com 0:788f63dcf0a0 871 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 872 }
metin.ozkan@analog.com 0:788f63dcf0a0 873
metin.ozkan@analog.com 0:788f63dcf0a0 874 int MAX77654::SetSoftwareResetFunctions(sft_ctrl_t sft_ctrl)
metin.ozkan@analog.com 0:788f63dcf0a0 875 {
metin.ozkan@analog.com 0:788f63dcf0a0 876 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 877
metin.ozkan@analog.com 0:788f63dcf0a0 878 SET_BIT_FIELD(CNFG_GLBL, reg_cnfg_glbl, reg_cnfg_glbl.bits.sft_ctrl, sft_ctrl);
metin.ozkan@analog.com 0:788f63dcf0a0 879
metin.ozkan@analog.com 0:788f63dcf0a0 880 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 881 }
metin.ozkan@analog.com 0:788f63dcf0a0 882
metin.ozkan@analog.com 0:788f63dcf0a0 883 int MAX77654::GetSoftwareResetFunctions(sft_ctrl_t* sft_ctrl)
metin.ozkan@analog.com 0:788f63dcf0a0 884 {
metin.ozkan@analog.com 0:788f63dcf0a0 885 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 886 reg_cnfg_glbl_t reg_cnfg_glbl;
metin.ozkan@analog.com 0:788f63dcf0a0 887
metin.ozkan@analog.com 0:788f63dcf0a0 888 ret = read_register(CNFG_GLBL, (uint8_t *)&(reg_cnfg_glbl));
metin.ozkan@analog.com 0:788f63dcf0a0 889 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 890 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 891 }
metin.ozkan@analog.com 0:788f63dcf0a0 892
metin.ozkan@analog.com 0:788f63dcf0a0 893 *sft_ctrl = (sft_ctrl_t)reg_cnfg_glbl.bits.sft_ctrl;
metin.ozkan@analog.com 0:788f63dcf0a0 894
metin.ozkan@analog.com 0:788f63dcf0a0 895 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 896 }
metin.ozkan@analog.com 0:788f63dcf0a0 897
metin.ozkan@analog.com 0:788f63dcf0a0 898 int MAX77654::SetAlternateModeEnable(uint8_t channel, alt_gpio_t alt_gpio)
metin.ozkan@analog.com 0:788f63dcf0a0 899 {
metin.ozkan@analog.com 0:788f63dcf0a0 900 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 901 reg_cnfg_gpio0_t reg_cnfg_gpio0;
metin.ozkan@analog.com 0:788f63dcf0a0 902 SET_BIT_FIELD(CNFG_GPIO0, reg_cnfg_gpio0, reg_cnfg_gpio0.bits.alt_gpio0, alt_gpio);
metin.ozkan@analog.com 0:788f63dcf0a0 903 }
metin.ozkan@analog.com 0:788f63dcf0a0 904 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 905 reg_cnfg_gpio1_t reg_cnfg_gpio1;
metin.ozkan@analog.com 0:788f63dcf0a0 906 SET_BIT_FIELD(CNFG_GPIO1, reg_cnfg_gpio1, reg_cnfg_gpio1.bits.alt_gpio1, alt_gpio);
metin.ozkan@analog.com 0:788f63dcf0a0 907 }
metin.ozkan@analog.com 0:788f63dcf0a0 908 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 909 reg_cnfg_gpio2_t reg_cnfg_gpio2;
metin.ozkan@analog.com 0:788f63dcf0a0 910 SET_BIT_FIELD(CNFG_GPIO2, reg_cnfg_gpio2, reg_cnfg_gpio2.bits.alt_gpio2, alt_gpio);
metin.ozkan@analog.com 0:788f63dcf0a0 911 }
metin.ozkan@analog.com 0:788f63dcf0a0 912 else {
metin.ozkan@analog.com 0:788f63dcf0a0 913 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 914 }
metin.ozkan@analog.com 0:788f63dcf0a0 915
metin.ozkan@analog.com 0:788f63dcf0a0 916 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 917 }
metin.ozkan@analog.com 0:788f63dcf0a0 918
metin.ozkan@analog.com 0:788f63dcf0a0 919 int MAX77654::GetAlternateModeEnable(uint8_t channel, alt_gpio_t* alt_gpio)
metin.ozkan@analog.com 0:788f63dcf0a0 920 {
metin.ozkan@analog.com 0:788f63dcf0a0 921 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 922
metin.ozkan@analog.com 0:788f63dcf0a0 923 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 924 reg_cnfg_gpio0_t reg_cnfg_gpio0;
metin.ozkan@analog.com 0:788f63dcf0a0 925 ret = read_register(CNFG_GPIO0, (uint8_t *)&(reg_cnfg_gpio0));
metin.ozkan@analog.com 0:788f63dcf0a0 926 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 927 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 928 }
metin.ozkan@analog.com 0:788f63dcf0a0 929
metin.ozkan@analog.com 0:788f63dcf0a0 930 *alt_gpio = (alt_gpio_t)reg_cnfg_gpio0.bits.alt_gpio0;
metin.ozkan@analog.com 0:788f63dcf0a0 931 }
metin.ozkan@analog.com 0:788f63dcf0a0 932 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 933 reg_cnfg_gpio1_t reg_cnfg_gpio1;
metin.ozkan@analog.com 0:788f63dcf0a0 934 ret = read_register(CNFG_GPIO1, (uint8_t *)&(reg_cnfg_gpio1));
metin.ozkan@analog.com 0:788f63dcf0a0 935 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 936 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 937 }
metin.ozkan@analog.com 0:788f63dcf0a0 938
metin.ozkan@analog.com 0:788f63dcf0a0 939 *alt_gpio = (alt_gpio_t)reg_cnfg_gpio1.bits.alt_gpio1;
metin.ozkan@analog.com 0:788f63dcf0a0 940 }
metin.ozkan@analog.com 0:788f63dcf0a0 941 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 942 reg_cnfg_gpio2_t reg_cnfg_gpio2;
metin.ozkan@analog.com 0:788f63dcf0a0 943 ret = read_register(CNFG_GPIO2, (uint8_t *)&(reg_cnfg_gpio2));
metin.ozkan@analog.com 0:788f63dcf0a0 944 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 945 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 946 }
metin.ozkan@analog.com 0:788f63dcf0a0 947
metin.ozkan@analog.com 0:788f63dcf0a0 948 *alt_gpio = (alt_gpio_t)reg_cnfg_gpio2.bits.alt_gpio2;
metin.ozkan@analog.com 0:788f63dcf0a0 949 }
metin.ozkan@analog.com 0:788f63dcf0a0 950 else {
metin.ozkan@analog.com 0:788f63dcf0a0 951 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 952 }
metin.ozkan@analog.com 0:788f63dcf0a0 953
metin.ozkan@analog.com 0:788f63dcf0a0 954 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 955 }
metin.ozkan@analog.com 0:788f63dcf0a0 956
metin.ozkan@analog.com 0:788f63dcf0a0 957 int MAX77654::SetGPIDebounceTimerEnable(uint8_t channel, dben_gpi_t dben_gpi)
metin.ozkan@analog.com 0:788f63dcf0a0 958 {
metin.ozkan@analog.com 0:788f63dcf0a0 959 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 960 reg_cnfg_gpio0_t reg_cnfg_gpio0;
metin.ozkan@analog.com 0:788f63dcf0a0 961 SET_BIT_FIELD(CNFG_GPIO0, reg_cnfg_gpio0, reg_cnfg_gpio0.bits.dben_gpi, dben_gpi);
metin.ozkan@analog.com 0:788f63dcf0a0 962 }
metin.ozkan@analog.com 0:788f63dcf0a0 963 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 964 reg_cnfg_gpio1_t reg_cnfg_gpio1;
metin.ozkan@analog.com 0:788f63dcf0a0 965 SET_BIT_FIELD(CNFG_GPIO1, reg_cnfg_gpio1, reg_cnfg_gpio1.bits.dben_gpi, dben_gpi);
metin.ozkan@analog.com 0:788f63dcf0a0 966 }
metin.ozkan@analog.com 0:788f63dcf0a0 967 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 968 reg_cnfg_gpio2_t reg_cnfg_gpio2;
metin.ozkan@analog.com 0:788f63dcf0a0 969 SET_BIT_FIELD(CNFG_GPIO2, reg_cnfg_gpio2, reg_cnfg_gpio2.bits.dben_gpi, dben_gpi);
metin.ozkan@analog.com 0:788f63dcf0a0 970 }
metin.ozkan@analog.com 0:788f63dcf0a0 971 else {
metin.ozkan@analog.com 0:788f63dcf0a0 972 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 973 }
metin.ozkan@analog.com 0:788f63dcf0a0 974
metin.ozkan@analog.com 0:788f63dcf0a0 975 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 976 }
metin.ozkan@analog.com 0:788f63dcf0a0 977
metin.ozkan@analog.com 0:788f63dcf0a0 978 int MAX77654::GetGPIDebounceTimerEnable(uint8_t channel, dben_gpi_t* dben_gpi)
metin.ozkan@analog.com 0:788f63dcf0a0 979 {
metin.ozkan@analog.com 0:788f63dcf0a0 980 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 981
metin.ozkan@analog.com 0:788f63dcf0a0 982 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 983 reg_cnfg_gpio0_t reg_cnfg_gpio0;
metin.ozkan@analog.com 0:788f63dcf0a0 984 ret = read_register(CNFG_GPIO0, (uint8_t *)&(reg_cnfg_gpio0));
metin.ozkan@analog.com 0:788f63dcf0a0 985 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 986 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 987 }
metin.ozkan@analog.com 0:788f63dcf0a0 988
metin.ozkan@analog.com 0:788f63dcf0a0 989 *dben_gpi = (dben_gpi_t)reg_cnfg_gpio0.bits.dben_gpi;
metin.ozkan@analog.com 0:788f63dcf0a0 990 }
metin.ozkan@analog.com 0:788f63dcf0a0 991 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 992 reg_cnfg_gpio1_t reg_cnfg_gpio1;
metin.ozkan@analog.com 0:788f63dcf0a0 993 ret = read_register(CNFG_GPIO1, (uint8_t *)&(reg_cnfg_gpio1));
metin.ozkan@analog.com 0:788f63dcf0a0 994 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 995 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 996 }
metin.ozkan@analog.com 0:788f63dcf0a0 997
metin.ozkan@analog.com 0:788f63dcf0a0 998 *dben_gpi = (dben_gpi_t)reg_cnfg_gpio1.bits.dben_gpi;
metin.ozkan@analog.com 0:788f63dcf0a0 999 }
metin.ozkan@analog.com 0:788f63dcf0a0 1000 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 1001 reg_cnfg_gpio2_t reg_cnfg_gpio2;
metin.ozkan@analog.com 0:788f63dcf0a0 1002 ret = read_register(CNFG_GPIO2, (uint8_t *)&(reg_cnfg_gpio2));
metin.ozkan@analog.com 0:788f63dcf0a0 1003 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1004 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1005 }
metin.ozkan@analog.com 0:788f63dcf0a0 1006
metin.ozkan@analog.com 0:788f63dcf0a0 1007 *dben_gpi = (dben_gpi_t)reg_cnfg_gpio2.bits.dben_gpi;
metin.ozkan@analog.com 0:788f63dcf0a0 1008 }
metin.ozkan@analog.com 0:788f63dcf0a0 1009 else {
metin.ozkan@analog.com 0:788f63dcf0a0 1010 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 1011 }
metin.ozkan@analog.com 0:788f63dcf0a0 1012
metin.ozkan@analog.com 0:788f63dcf0a0 1013 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1014 }
metin.ozkan@analog.com 0:788f63dcf0a0 1015
metin.ozkan@analog.com 0:788f63dcf0a0 1016 int MAX77654::SetGPODataOutput(uint8_t channel, gpo_do_t gpo_do)
metin.ozkan@analog.com 0:788f63dcf0a0 1017 {
metin.ozkan@analog.com 0:788f63dcf0a0 1018
metin.ozkan@analog.com 0:788f63dcf0a0 1019 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 1020 reg_cnfg_gpio0_t reg_cnfg_gpio0;
metin.ozkan@analog.com 0:788f63dcf0a0 1021 SET_BIT_FIELD(CNFG_GPIO0, reg_cnfg_gpio0, reg_cnfg_gpio0.bits.gpo_do, gpo_do);
metin.ozkan@analog.com 0:788f63dcf0a0 1022 }
metin.ozkan@analog.com 0:788f63dcf0a0 1023 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 1024 reg_cnfg_gpio1_t reg_cnfg_gpio1;
metin.ozkan@analog.com 0:788f63dcf0a0 1025 SET_BIT_FIELD(CNFG_GPIO1, reg_cnfg_gpio1, reg_cnfg_gpio1.bits.gpo_do, gpo_do);
metin.ozkan@analog.com 0:788f63dcf0a0 1026 }
metin.ozkan@analog.com 0:788f63dcf0a0 1027 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 1028 reg_cnfg_gpio2_t reg_cnfg_gpio2;
metin.ozkan@analog.com 0:788f63dcf0a0 1029 SET_BIT_FIELD(CNFG_GPIO2, reg_cnfg_gpio2, reg_cnfg_gpio2.bits.gpo_do, gpo_do);
metin.ozkan@analog.com 0:788f63dcf0a0 1030 }
metin.ozkan@analog.com 0:788f63dcf0a0 1031 else {
metin.ozkan@analog.com 0:788f63dcf0a0 1032 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 1033 }
metin.ozkan@analog.com 0:788f63dcf0a0 1034
metin.ozkan@analog.com 0:788f63dcf0a0 1035 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1036 }
metin.ozkan@analog.com 0:788f63dcf0a0 1037
metin.ozkan@analog.com 0:788f63dcf0a0 1038 int MAX77654::GetGPODataOutput(uint8_t channel, gpo_do_t *gpo_do)
metin.ozkan@analog.com 0:788f63dcf0a0 1039 {
metin.ozkan@analog.com 0:788f63dcf0a0 1040 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1041
metin.ozkan@analog.com 0:788f63dcf0a0 1042 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 1043 reg_cnfg_gpio0_t reg_cnfg_gpio0;
metin.ozkan@analog.com 0:788f63dcf0a0 1044 ret = read_register(CNFG_GPIO0, (uint8_t *)&(reg_cnfg_gpio0));
metin.ozkan@analog.com 0:788f63dcf0a0 1045 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1046 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1047 }
metin.ozkan@analog.com 0:788f63dcf0a0 1048
metin.ozkan@analog.com 0:788f63dcf0a0 1049 *gpo_do = (gpo_do_t)reg_cnfg_gpio0.bits.gpo_do;
metin.ozkan@analog.com 0:788f63dcf0a0 1050 }
metin.ozkan@analog.com 0:788f63dcf0a0 1051 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 1052 reg_cnfg_gpio1_t reg_cnfg_gpio1;
metin.ozkan@analog.com 0:788f63dcf0a0 1053 ret = read_register(CNFG_GPIO1, (uint8_t *)&(reg_cnfg_gpio1));
metin.ozkan@analog.com 0:788f63dcf0a0 1054 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1055 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1056 }
metin.ozkan@analog.com 0:788f63dcf0a0 1057
metin.ozkan@analog.com 0:788f63dcf0a0 1058 *gpo_do = (gpo_do_t)reg_cnfg_gpio1.bits.gpo_do;
metin.ozkan@analog.com 0:788f63dcf0a0 1059 }
metin.ozkan@analog.com 0:788f63dcf0a0 1060 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 1061 reg_cnfg_gpio2_t reg_cnfg_gpio2;
metin.ozkan@analog.com 0:788f63dcf0a0 1062 ret = read_register(CNFG_GPIO2, (uint8_t *)&(reg_cnfg_gpio2));
metin.ozkan@analog.com 0:788f63dcf0a0 1063 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1064 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1065 }
metin.ozkan@analog.com 0:788f63dcf0a0 1066
metin.ozkan@analog.com 0:788f63dcf0a0 1067 *gpo_do = (gpo_do_t)reg_cnfg_gpio2.bits.gpo_do;
metin.ozkan@analog.com 0:788f63dcf0a0 1068 }
metin.ozkan@analog.com 0:788f63dcf0a0 1069 else {
metin.ozkan@analog.com 0:788f63dcf0a0 1070 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 1071 }
metin.ozkan@analog.com 0:788f63dcf0a0 1072
metin.ozkan@analog.com 0:788f63dcf0a0 1073 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1074 }
metin.ozkan@analog.com 0:788f63dcf0a0 1075
metin.ozkan@analog.com 0:788f63dcf0a0 1076 int MAX77654::SetGPODriveType(uint8_t channel, gpo_drv_t gpo_drv)
metin.ozkan@analog.com 0:788f63dcf0a0 1077 {
metin.ozkan@analog.com 0:788f63dcf0a0 1078 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 1079 reg_cnfg_gpio0_t reg_cnfg_gpio0;
metin.ozkan@analog.com 0:788f63dcf0a0 1080 SET_BIT_FIELD(CNFG_GPIO0, reg_cnfg_gpio0, reg_cnfg_gpio0.bits.gpo_drv, gpo_drv);
metin.ozkan@analog.com 0:788f63dcf0a0 1081 }
metin.ozkan@analog.com 0:788f63dcf0a0 1082 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 1083 reg_cnfg_gpio1_t reg_cnfg_gpio1;
metin.ozkan@analog.com 0:788f63dcf0a0 1084 SET_BIT_FIELD(CNFG_GPIO1, reg_cnfg_gpio1, reg_cnfg_gpio1.bits.gpo_drv, gpo_drv);
metin.ozkan@analog.com 0:788f63dcf0a0 1085 }
metin.ozkan@analog.com 0:788f63dcf0a0 1086 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 1087 reg_cnfg_gpio2_t reg_cnfg_gpio2;
metin.ozkan@analog.com 0:788f63dcf0a0 1088 SET_BIT_FIELD(CNFG_GPIO2, reg_cnfg_gpio2, reg_cnfg_gpio2.bits.gpo_drv, gpo_drv);
metin.ozkan@analog.com 0:788f63dcf0a0 1089 }
metin.ozkan@analog.com 0:788f63dcf0a0 1090 else {
metin.ozkan@analog.com 0:788f63dcf0a0 1091 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 1092 }
metin.ozkan@analog.com 0:788f63dcf0a0 1093
metin.ozkan@analog.com 0:788f63dcf0a0 1094 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1095 }
metin.ozkan@analog.com 0:788f63dcf0a0 1096
metin.ozkan@analog.com 0:788f63dcf0a0 1097 int MAX77654::GetGPODriveType(uint8_t channel, gpo_drv_t *gpo_drv)
metin.ozkan@analog.com 0:788f63dcf0a0 1098 {
metin.ozkan@analog.com 0:788f63dcf0a0 1099 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1100
metin.ozkan@analog.com 0:788f63dcf0a0 1101 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 1102 reg_cnfg_gpio0_t reg_cnfg_gpio0;
metin.ozkan@analog.com 0:788f63dcf0a0 1103 ret = read_register(CNFG_GPIO0, (uint8_t *)&(reg_cnfg_gpio0));
metin.ozkan@analog.com 0:788f63dcf0a0 1104 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1105 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1106 }
metin.ozkan@analog.com 0:788f63dcf0a0 1107
metin.ozkan@analog.com 0:788f63dcf0a0 1108 *gpo_drv = (gpo_drv_t)reg_cnfg_gpio0.bits.gpo_drv;
metin.ozkan@analog.com 0:788f63dcf0a0 1109 }
metin.ozkan@analog.com 0:788f63dcf0a0 1110 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 1111 reg_cnfg_gpio1_t reg_cnfg_gpio1;
metin.ozkan@analog.com 0:788f63dcf0a0 1112 ret = read_register(CNFG_GPIO1, (uint8_t *)&(reg_cnfg_gpio1));
metin.ozkan@analog.com 0:788f63dcf0a0 1113 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1114 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1115 }
metin.ozkan@analog.com 0:788f63dcf0a0 1116
metin.ozkan@analog.com 0:788f63dcf0a0 1117 *gpo_drv = (gpo_drv_t)reg_cnfg_gpio1.bits.gpo_drv;
metin.ozkan@analog.com 0:788f63dcf0a0 1118 }
metin.ozkan@analog.com 0:788f63dcf0a0 1119 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 1120 reg_cnfg_gpio2_t reg_cnfg_gpio2;
metin.ozkan@analog.com 0:788f63dcf0a0 1121 ret = read_register(CNFG_GPIO2, (uint8_t *)&(reg_cnfg_gpio2));
metin.ozkan@analog.com 0:788f63dcf0a0 1122 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1123 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1124 }
metin.ozkan@analog.com 0:788f63dcf0a0 1125
metin.ozkan@analog.com 0:788f63dcf0a0 1126 *gpo_drv = (gpo_drv_t)reg_cnfg_gpio2.bits.gpo_drv;
metin.ozkan@analog.com 0:788f63dcf0a0 1127 }
metin.ozkan@analog.com 0:788f63dcf0a0 1128 else {
metin.ozkan@analog.com 0:788f63dcf0a0 1129 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 1130 }
metin.ozkan@analog.com 0:788f63dcf0a0 1131
metin.ozkan@analog.com 0:788f63dcf0a0 1132 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1133 }
metin.ozkan@analog.com 0:788f63dcf0a0 1134
metin.ozkan@analog.com 0:788f63dcf0a0 1135 int MAX77654::SetGPIOInputValue(uint8_t channel, gpo_di_t gpo_di)
metin.ozkan@analog.com 0:788f63dcf0a0 1136 {
metin.ozkan@analog.com 0:788f63dcf0a0 1137 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 1138 reg_cnfg_gpio0_t reg_cnfg_gpio0;
metin.ozkan@analog.com 0:788f63dcf0a0 1139 SET_BIT_FIELD(CNFG_GPIO0, reg_cnfg_gpio0, reg_cnfg_gpio0.bits.gpo_di, gpo_di);
metin.ozkan@analog.com 0:788f63dcf0a0 1140 }
metin.ozkan@analog.com 0:788f63dcf0a0 1141 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 1142 reg_cnfg_gpio1_t reg_cnfg_gpio1;
metin.ozkan@analog.com 0:788f63dcf0a0 1143 SET_BIT_FIELD(CNFG_GPIO1, reg_cnfg_gpio1, reg_cnfg_gpio1.bits.gpo_di, gpo_di);
metin.ozkan@analog.com 0:788f63dcf0a0 1144 }
metin.ozkan@analog.com 0:788f63dcf0a0 1145 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 1146 reg_cnfg_gpio2_t reg_cnfg_gpio2;
metin.ozkan@analog.com 0:788f63dcf0a0 1147 SET_BIT_FIELD(CNFG_GPIO2, reg_cnfg_gpio2, reg_cnfg_gpio2.bits.gpo_di, gpo_di);
metin.ozkan@analog.com 0:788f63dcf0a0 1148 }
metin.ozkan@analog.com 0:788f63dcf0a0 1149 else {
metin.ozkan@analog.com 0:788f63dcf0a0 1150 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 1151 }
metin.ozkan@analog.com 0:788f63dcf0a0 1152
metin.ozkan@analog.com 0:788f63dcf0a0 1153 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1154 }
metin.ozkan@analog.com 0:788f63dcf0a0 1155
metin.ozkan@analog.com 0:788f63dcf0a0 1156 int MAX77654::GetGPIOInputValue(uint8_t channel, gpo_di_t *gpo_di)
metin.ozkan@analog.com 0:788f63dcf0a0 1157 {
metin.ozkan@analog.com 0:788f63dcf0a0 1158 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1159
metin.ozkan@analog.com 0:788f63dcf0a0 1160 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 1161 reg_cnfg_gpio0_t reg_cnfg_gpio0;
metin.ozkan@analog.com 0:788f63dcf0a0 1162 ret = read_register(CNFG_GPIO0, (uint8_t *)&(reg_cnfg_gpio0));
metin.ozkan@analog.com 0:788f63dcf0a0 1163 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1164 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1165 }
metin.ozkan@analog.com 0:788f63dcf0a0 1166
metin.ozkan@analog.com 0:788f63dcf0a0 1167 *gpo_di = (gpo_di_t)reg_cnfg_gpio0.bits.gpo_di;
metin.ozkan@analog.com 0:788f63dcf0a0 1168 }
metin.ozkan@analog.com 0:788f63dcf0a0 1169 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 1170 reg_cnfg_gpio1_t reg_cnfg_gpio1;
metin.ozkan@analog.com 0:788f63dcf0a0 1171 ret = read_register(CNFG_GPIO1, (uint8_t *)&(reg_cnfg_gpio1));
metin.ozkan@analog.com 0:788f63dcf0a0 1172 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1173 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1174 }
metin.ozkan@analog.com 0:788f63dcf0a0 1175
metin.ozkan@analog.com 0:788f63dcf0a0 1176 *gpo_di = (gpo_di_t)reg_cnfg_gpio1.bits.gpo_di;
metin.ozkan@analog.com 0:788f63dcf0a0 1177 }
metin.ozkan@analog.com 0:788f63dcf0a0 1178 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 1179 reg_cnfg_gpio2_t reg_cnfg_gpio2;
metin.ozkan@analog.com 0:788f63dcf0a0 1180 ret = read_register(CNFG_GPIO2, (uint8_t *)&(reg_cnfg_gpio2));
metin.ozkan@analog.com 0:788f63dcf0a0 1181 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1182 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1183 }
metin.ozkan@analog.com 0:788f63dcf0a0 1184
metin.ozkan@analog.com 0:788f63dcf0a0 1185 *gpo_di = (gpo_di_t)reg_cnfg_gpio2.bits.gpo_di;
metin.ozkan@analog.com 0:788f63dcf0a0 1186 }
metin.ozkan@analog.com 0:788f63dcf0a0 1187 else {
metin.ozkan@analog.com 0:788f63dcf0a0 1188 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 1189 }
metin.ozkan@analog.com 0:788f63dcf0a0 1190
metin.ozkan@analog.com 0:788f63dcf0a0 1191 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1192 }
metin.ozkan@analog.com 0:788f63dcf0a0 1193
metin.ozkan@analog.com 0:788f63dcf0a0 1194 int MAX77654::SetGPIODirection(uint8_t channel, gpo_dir_t gpo_dir)
metin.ozkan@analog.com 0:788f63dcf0a0 1195 {
metin.ozkan@analog.com 0:788f63dcf0a0 1196 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 1197 reg_cnfg_gpio0_t reg_cnfg_gpio0;
metin.ozkan@analog.com 0:788f63dcf0a0 1198 SET_BIT_FIELD(CNFG_GPIO0, reg_cnfg_gpio0, reg_cnfg_gpio0.bits.gpo_dir, gpo_dir);
metin.ozkan@analog.com 0:788f63dcf0a0 1199 }
metin.ozkan@analog.com 0:788f63dcf0a0 1200 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 1201 reg_cnfg_gpio1_t reg_cnfg_gpio1;
metin.ozkan@analog.com 0:788f63dcf0a0 1202 SET_BIT_FIELD(CNFG_GPIO1, reg_cnfg_gpio1, reg_cnfg_gpio1.bits.gpo_dir, gpo_dir);
metin.ozkan@analog.com 0:788f63dcf0a0 1203 }
metin.ozkan@analog.com 0:788f63dcf0a0 1204 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 1205 reg_cnfg_gpio2_t reg_cnfg_gpio2;
metin.ozkan@analog.com 0:788f63dcf0a0 1206 SET_BIT_FIELD(CNFG_GPIO2, reg_cnfg_gpio2, reg_cnfg_gpio2.bits.gpo_dir, gpo_dir);
metin.ozkan@analog.com 0:788f63dcf0a0 1207 }
metin.ozkan@analog.com 0:788f63dcf0a0 1208 else {
metin.ozkan@analog.com 0:788f63dcf0a0 1209 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 1210 }
metin.ozkan@analog.com 0:788f63dcf0a0 1211
metin.ozkan@analog.com 0:788f63dcf0a0 1212 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1213 }
metin.ozkan@analog.com 0:788f63dcf0a0 1214
metin.ozkan@analog.com 0:788f63dcf0a0 1215 int MAX77654::GetGPIODirection(uint8_t channel, gpo_dir_t *gpo_dir)
metin.ozkan@analog.com 0:788f63dcf0a0 1216 {
metin.ozkan@analog.com 0:788f63dcf0a0 1217 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1218
metin.ozkan@analog.com 0:788f63dcf0a0 1219 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 1220 reg_cnfg_gpio0_t reg_cnfg_gpio0;
metin.ozkan@analog.com 0:788f63dcf0a0 1221 ret = read_register(CNFG_GPIO0, (uint8_t *)&(reg_cnfg_gpio0));
metin.ozkan@analog.com 0:788f63dcf0a0 1222 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1223 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1224 }
metin.ozkan@analog.com 0:788f63dcf0a0 1225
metin.ozkan@analog.com 0:788f63dcf0a0 1226 *gpo_dir = (gpo_dir_t)reg_cnfg_gpio0.bits.gpo_dir;
metin.ozkan@analog.com 0:788f63dcf0a0 1227 }
metin.ozkan@analog.com 0:788f63dcf0a0 1228 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 1229 reg_cnfg_gpio1_t reg_cnfg_gpio1;
metin.ozkan@analog.com 0:788f63dcf0a0 1230 ret = read_register(CNFG_GPIO1, (uint8_t *)&(reg_cnfg_gpio1));
metin.ozkan@analog.com 0:788f63dcf0a0 1231 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1232 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1233 }
metin.ozkan@analog.com 0:788f63dcf0a0 1234
metin.ozkan@analog.com 0:788f63dcf0a0 1235 *gpo_dir = (gpo_dir_t)reg_cnfg_gpio1.bits.gpo_dir;
metin.ozkan@analog.com 0:788f63dcf0a0 1236 }
metin.ozkan@analog.com 0:788f63dcf0a0 1237 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 1238 reg_cnfg_gpio2_t reg_cnfg_gpio2;
metin.ozkan@analog.com 0:788f63dcf0a0 1239 ret = read_register(CNFG_GPIO2, (uint8_t *)&(reg_cnfg_gpio2));
metin.ozkan@analog.com 0:788f63dcf0a0 1240 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1241 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1242 }
metin.ozkan@analog.com 0:788f63dcf0a0 1243
metin.ozkan@analog.com 0:788f63dcf0a0 1244 *gpo_dir = (gpo_dir_t)reg_cnfg_gpio2.bits.gpo_dir;
metin.ozkan@analog.com 0:788f63dcf0a0 1245 }
metin.ozkan@analog.com 0:788f63dcf0a0 1246 else {
metin.ozkan@analog.com 0:788f63dcf0a0 1247 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 1248 }
metin.ozkan@analog.com 0:788f63dcf0a0 1249
metin.ozkan@analog.com 0:788f63dcf0a0 1250 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1251 }
metin.ozkan@analog.com 0:788f63dcf0a0 1252
metin.ozkan@analog.com 0:788f63dcf0a0 1253 int MAX77654::GetCID(void) {
metin.ozkan@analog.com 0:788f63dcf0a0 1254 char rbuf[1];
metin.ozkan@analog.com 0:788f63dcf0a0 1255 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1256
metin.ozkan@analog.com 0:788f63dcf0a0 1257 ret = read_register(CID, (uint8_t *)&(rbuf));
metin.ozkan@analog.com 0:788f63dcf0a0 1258 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1259 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1260 }
metin.ozkan@analog.com 0:788f63dcf0a0 1261
metin.ozkan@analog.com 0:788f63dcf0a0 1262 return *rbuf;
metin.ozkan@analog.com 0:788f63dcf0a0 1263 }
metin.ozkan@analog.com 0:788f63dcf0a0 1264
metin.ozkan@analog.com 0:788f63dcf0a0 1265 int MAX77654::SetWatchdogTimerPeriod(wdt_per_t wdt_per)
metin.ozkan@analog.com 0:788f63dcf0a0 1266 {
metin.ozkan@analog.com 0:788f63dcf0a0 1267 reg_cnfg_wdt_t reg_cnfg_wdt;
metin.ozkan@analog.com 0:788f63dcf0a0 1268
metin.ozkan@analog.com 0:788f63dcf0a0 1269 SET_BIT_FIELD(CNFG_WDT, reg_cnfg_wdt, reg_cnfg_wdt.bits.wdt_per, wdt_per);
metin.ozkan@analog.com 0:788f63dcf0a0 1270
metin.ozkan@analog.com 0:788f63dcf0a0 1271 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1272 }
metin.ozkan@analog.com 0:788f63dcf0a0 1273
metin.ozkan@analog.com 0:788f63dcf0a0 1274 int MAX77654::GetWatchdogTimerPeriod(wdt_per_t *wdt_per)
metin.ozkan@analog.com 0:788f63dcf0a0 1275 {
metin.ozkan@analog.com 0:788f63dcf0a0 1276 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1277 reg_cnfg_wdt_t reg_cnfg_wdt;
metin.ozkan@analog.com 0:788f63dcf0a0 1278
metin.ozkan@analog.com 0:788f63dcf0a0 1279 ret = read_register(CNFG_WDT, (uint8_t *)&(reg_cnfg_wdt));
metin.ozkan@analog.com 0:788f63dcf0a0 1280 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1281 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1282 }
metin.ozkan@analog.com 0:788f63dcf0a0 1283
metin.ozkan@analog.com 0:788f63dcf0a0 1284 *wdt_per = (wdt_per_t)reg_cnfg_wdt.bits.wdt_per;
metin.ozkan@analog.com 0:788f63dcf0a0 1285
metin.ozkan@analog.com 0:788f63dcf0a0 1286 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1287 }
metin.ozkan@analog.com 0:788f63dcf0a0 1288
metin.ozkan@analog.com 0:788f63dcf0a0 1289 int MAX77654::SetWatchdogTimerExpiredAction(wdt_mode_t wdt_mode)
metin.ozkan@analog.com 0:788f63dcf0a0 1290 {
metin.ozkan@analog.com 0:788f63dcf0a0 1291 reg_cnfg_wdt_t reg_cnfg_wdt;
metin.ozkan@analog.com 0:788f63dcf0a0 1292
metin.ozkan@analog.com 0:788f63dcf0a0 1293 SET_BIT_FIELD(CNFG_WDT, reg_cnfg_wdt, reg_cnfg_wdt.bits.wdt_mode, wdt_mode);
metin.ozkan@analog.com 0:788f63dcf0a0 1294
metin.ozkan@analog.com 0:788f63dcf0a0 1295 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1296 }
metin.ozkan@analog.com 0:788f63dcf0a0 1297
metin.ozkan@analog.com 0:788f63dcf0a0 1298 int MAX77654::GetWatchdogTimerExpiredAction(wdt_mode_t *wdt_mode)
metin.ozkan@analog.com 0:788f63dcf0a0 1299 {
metin.ozkan@analog.com 0:788f63dcf0a0 1300 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1301 reg_cnfg_wdt_t reg_cnfg_wdt;
metin.ozkan@analog.com 0:788f63dcf0a0 1302
metin.ozkan@analog.com 0:788f63dcf0a0 1303 ret = read_register(CNFG_WDT, (uint8_t *)&(reg_cnfg_wdt));
metin.ozkan@analog.com 0:788f63dcf0a0 1304 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1305 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1306 }
metin.ozkan@analog.com 0:788f63dcf0a0 1307
metin.ozkan@analog.com 0:788f63dcf0a0 1308 *wdt_mode = (wdt_mode_t)reg_cnfg_wdt.bits.wdt_mode;
metin.ozkan@analog.com 0:788f63dcf0a0 1309
metin.ozkan@analog.com 0:788f63dcf0a0 1310 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1311 }
metin.ozkan@analog.com 0:788f63dcf0a0 1312
metin.ozkan@analog.com 0:788f63dcf0a0 1313 int MAX77654::SetWatchdogTimerClearControl(wdt_clr_t wdt_clr)
metin.ozkan@analog.com 0:788f63dcf0a0 1314 {
metin.ozkan@analog.com 0:788f63dcf0a0 1315 reg_cnfg_wdt_t reg_cnfg_wdt;
metin.ozkan@analog.com 0:788f63dcf0a0 1316
metin.ozkan@analog.com 0:788f63dcf0a0 1317 SET_BIT_FIELD(CNFG_WDT, reg_cnfg_wdt, reg_cnfg_wdt.bits.wdt_clr, wdt_clr);
metin.ozkan@analog.com 0:788f63dcf0a0 1318
metin.ozkan@analog.com 0:788f63dcf0a0 1319 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1320 }
metin.ozkan@analog.com 0:788f63dcf0a0 1321
metin.ozkan@analog.com 0:788f63dcf0a0 1322 int MAX77654::GetWatchdogTimerClearControl(wdt_clr_t *wdt_clr)
metin.ozkan@analog.com 0:788f63dcf0a0 1323 {
metin.ozkan@analog.com 0:788f63dcf0a0 1324 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1325 reg_cnfg_wdt_t reg_cnfg_wdt;
metin.ozkan@analog.com 0:788f63dcf0a0 1326
metin.ozkan@analog.com 0:788f63dcf0a0 1327 ret = read_register(CNFG_WDT, (uint8_t *)&(reg_cnfg_wdt));
metin.ozkan@analog.com 0:788f63dcf0a0 1328 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1329 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1330 }
metin.ozkan@analog.com 0:788f63dcf0a0 1331
metin.ozkan@analog.com 0:788f63dcf0a0 1332 *wdt_clr = (wdt_clr_t)reg_cnfg_wdt.bits.wdt_clr;
metin.ozkan@analog.com 0:788f63dcf0a0 1333
metin.ozkan@analog.com 0:788f63dcf0a0 1334 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1335 }
metin.ozkan@analog.com 0:788f63dcf0a0 1336
metin.ozkan@analog.com 0:788f63dcf0a0 1337 int MAX77654::SetWatchdogTimerEnable(wdt_en_t wdt_en)
metin.ozkan@analog.com 0:788f63dcf0a0 1338 {
metin.ozkan@analog.com 0:788f63dcf0a0 1339 reg_cnfg_wdt_t reg_cnfg_wdt;
metin.ozkan@analog.com 0:788f63dcf0a0 1340
metin.ozkan@analog.com 0:788f63dcf0a0 1341 SET_BIT_FIELD(CNFG_WDT, reg_cnfg_wdt, reg_cnfg_wdt.bits.wdt_en, wdt_en);
metin.ozkan@analog.com 0:788f63dcf0a0 1342
metin.ozkan@analog.com 0:788f63dcf0a0 1343 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1344 }
metin.ozkan@analog.com 0:788f63dcf0a0 1345
metin.ozkan@analog.com 0:788f63dcf0a0 1346 int MAX77654::GetWatchdogTimerEnable(wdt_en_t *wdt_en)
metin.ozkan@analog.com 0:788f63dcf0a0 1347 {
metin.ozkan@analog.com 0:788f63dcf0a0 1348 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1349 reg_cnfg_wdt_t reg_cnfg_wdt;
metin.ozkan@analog.com 0:788f63dcf0a0 1350
metin.ozkan@analog.com 0:788f63dcf0a0 1351 ret = read_register(CNFG_WDT, (uint8_t *)&(reg_cnfg_wdt));
metin.ozkan@analog.com 0:788f63dcf0a0 1352 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1353 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1354 }
metin.ozkan@analog.com 0:788f63dcf0a0 1355
metin.ozkan@analog.com 0:788f63dcf0a0 1356 *wdt_en = (wdt_en_t)reg_cnfg_wdt.bits.wdt_en;
metin.ozkan@analog.com 0:788f63dcf0a0 1357
metin.ozkan@analog.com 0:788f63dcf0a0 1358 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1359 }
metin.ozkan@analog.com 0:788f63dcf0a0 1360
metin.ozkan@analog.com 0:788f63dcf0a0 1361 int MAX77654::SetFactorySetSafetyBit(wdt_lock_t wdt_lock)
metin.ozkan@analog.com 0:788f63dcf0a0 1362 {
metin.ozkan@analog.com 0:788f63dcf0a0 1363 reg_cnfg_wdt_t reg_cnfg_wdt;
metin.ozkan@analog.com 0:788f63dcf0a0 1364
metin.ozkan@analog.com 0:788f63dcf0a0 1365 SET_BIT_FIELD(CNFG_WDT, reg_cnfg_wdt, reg_cnfg_wdt.bits.wdt_lock, wdt_lock);
metin.ozkan@analog.com 0:788f63dcf0a0 1366
metin.ozkan@analog.com 0:788f63dcf0a0 1367 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1368 }
metin.ozkan@analog.com 0:788f63dcf0a0 1369
metin.ozkan@analog.com 0:788f63dcf0a0 1370 int MAX77654::GetFactorySetSafetyBit(wdt_lock_t *wdt_lock)
metin.ozkan@analog.com 0:788f63dcf0a0 1371 {
metin.ozkan@analog.com 0:788f63dcf0a0 1372 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1373 reg_cnfg_wdt_t reg_cnfg_wdt;
metin.ozkan@analog.com 0:788f63dcf0a0 1374
metin.ozkan@analog.com 0:788f63dcf0a0 1375 ret = read_register(CNFG_WDT, (uint8_t *)&(reg_cnfg_wdt));
metin.ozkan@analog.com 0:788f63dcf0a0 1376 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1377 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1378 }
metin.ozkan@analog.com 0:788f63dcf0a0 1379
metin.ozkan@analog.com 0:788f63dcf0a0 1380 *wdt_lock = (wdt_lock_t)reg_cnfg_wdt.bits.wdt_lock;
metin.ozkan@analog.com 0:788f63dcf0a0 1381
metin.ozkan@analog.com 0:788f63dcf0a0 1382 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1383 }
metin.ozkan@analog.com 0:788f63dcf0a0 1384
metin.ozkan@analog.com 0:788f63dcf0a0 1385 int MAX77654::GetMinimumVCHGINVoltageLoopStatus(stat_t *stat)
metin.ozkan@analog.com 0:788f63dcf0a0 1386 {
metin.ozkan@analog.com 0:788f63dcf0a0 1387 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1388 reg_stat_chg_a_t reg_stat_chg_a;
metin.ozkan@analog.com 0:788f63dcf0a0 1389
metin.ozkan@analog.com 0:788f63dcf0a0 1390 ret = read_register(STAT_CHG_A, (uint8_t *)&(reg_stat_chg_a));
metin.ozkan@analog.com 0:788f63dcf0a0 1391 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1392 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1393 }
metin.ozkan@analog.com 0:788f63dcf0a0 1394
metin.ozkan@analog.com 0:788f63dcf0a0 1395 *stat = (stat_t)reg_stat_chg_a.bits.vchgin_min_stat;
metin.ozkan@analog.com 0:788f63dcf0a0 1396
metin.ozkan@analog.com 0:788f63dcf0a0 1397 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1398 }
metin.ozkan@analog.com 0:788f63dcf0a0 1399
metin.ozkan@analog.com 0:788f63dcf0a0 1400 int MAX77654::GetCHGINCurrentLimitLoopStatus(stat_t *stat)
metin.ozkan@analog.com 0:788f63dcf0a0 1401 {
metin.ozkan@analog.com 0:788f63dcf0a0 1402 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1403 reg_stat_chg_a_t reg_stat_chg_a;
metin.ozkan@analog.com 0:788f63dcf0a0 1404
metin.ozkan@analog.com 0:788f63dcf0a0 1405 ret = read_register(STAT_CHG_A, (uint8_t *)&(reg_stat_chg_a));
metin.ozkan@analog.com 0:788f63dcf0a0 1406 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1407 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1408 }
metin.ozkan@analog.com 0:788f63dcf0a0 1409
metin.ozkan@analog.com 0:788f63dcf0a0 1410 *stat = (stat_t)reg_stat_chg_a.bits.ichgin_lim_stat;
metin.ozkan@analog.com 0:788f63dcf0a0 1411
metin.ozkan@analog.com 0:788f63dcf0a0 1412 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1413 }
metin.ozkan@analog.com 0:788f63dcf0a0 1414
metin.ozkan@analog.com 0:788f63dcf0a0 1415 int MAX77654::GetMinimumSYSVoltageLoopStatus(stat_t *stat)
metin.ozkan@analog.com 0:788f63dcf0a0 1416 {
metin.ozkan@analog.com 0:788f63dcf0a0 1417 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1418 reg_stat_chg_a_t reg_stat_chg_a;
metin.ozkan@analog.com 0:788f63dcf0a0 1419
metin.ozkan@analog.com 0:788f63dcf0a0 1420 ret = read_register(STAT_CHG_A, (uint8_t *)&(reg_stat_chg_a));
metin.ozkan@analog.com 0:788f63dcf0a0 1421 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1422 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1423 }
metin.ozkan@analog.com 0:788f63dcf0a0 1424
metin.ozkan@analog.com 0:788f63dcf0a0 1425 *stat = (stat_t)reg_stat_chg_a.bits.vsys_min_stat;
metin.ozkan@analog.com 0:788f63dcf0a0 1426
metin.ozkan@analog.com 0:788f63dcf0a0 1427 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1428 }
metin.ozkan@analog.com 0:788f63dcf0a0 1429
metin.ozkan@analog.com 0:788f63dcf0a0 1430 int MAX77654::GetMaximumJunctionTempLoopStatus(stat_t *stat)
metin.ozkan@analog.com 0:788f63dcf0a0 1431 {
metin.ozkan@analog.com 0:788f63dcf0a0 1432 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1433 reg_stat_chg_a_t reg_stat_chg_a;
metin.ozkan@analog.com 0:788f63dcf0a0 1434
metin.ozkan@analog.com 0:788f63dcf0a0 1435 ret = read_register(STAT_CHG_A, (uint8_t *)&(reg_stat_chg_a));
metin.ozkan@analog.com 0:788f63dcf0a0 1436 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1437 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1438 }
metin.ozkan@analog.com 0:788f63dcf0a0 1439
metin.ozkan@analog.com 0:788f63dcf0a0 1440 *stat = (stat_t)reg_stat_chg_a.bits.tj_reg_stat;
metin.ozkan@analog.com 0:788f63dcf0a0 1441
metin.ozkan@analog.com 0:788f63dcf0a0 1442 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1443 }
metin.ozkan@analog.com 0:788f63dcf0a0 1444
metin.ozkan@analog.com 0:788f63dcf0a0 1445 int MAX77654::GetBatteryTemperatureDetails(thm_dtls_t *thm_dtls)
metin.ozkan@analog.com 0:788f63dcf0a0 1446 {
metin.ozkan@analog.com 0:788f63dcf0a0 1447 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1448 reg_stat_chg_a_t reg_stat_chg_a;
metin.ozkan@analog.com 0:788f63dcf0a0 1449
metin.ozkan@analog.com 0:788f63dcf0a0 1450 ret = read_register(STAT_CHG_A, (uint8_t *)&(reg_stat_chg_a));
metin.ozkan@analog.com 0:788f63dcf0a0 1451 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1452 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1453 }
metin.ozkan@analog.com 0:788f63dcf0a0 1454
metin.ozkan@analog.com 0:788f63dcf0a0 1455 *thm_dtls = (thm_dtls_t)reg_stat_chg_a.bits.thm_dtls;
metin.ozkan@analog.com 0:788f63dcf0a0 1456
metin.ozkan@analog.com 0:788f63dcf0a0 1457 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1458 }
metin.ozkan@analog.com 0:788f63dcf0a0 1459
metin.ozkan@analog.com 0:788f63dcf0a0 1460 int MAX77654::GetChargerDetails(chg_dtls_t *chg_dtls)
metin.ozkan@analog.com 0:788f63dcf0a0 1461 {
metin.ozkan@analog.com 0:788f63dcf0a0 1462 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1463 reg_stat_chg_b_t reg_stat_chg_b;
metin.ozkan@analog.com 0:788f63dcf0a0 1464
metin.ozkan@analog.com 0:788f63dcf0a0 1465 ret = read_register(STAT_CHG_B, (uint8_t *)&(reg_stat_chg_b));
metin.ozkan@analog.com 0:788f63dcf0a0 1466 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1467 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1468 }
metin.ozkan@analog.com 0:788f63dcf0a0 1469
metin.ozkan@analog.com 0:788f63dcf0a0 1470 *chg_dtls = (chg_dtls_t)reg_stat_chg_b.bits.chg_dtls;
metin.ozkan@analog.com 0:788f63dcf0a0 1471
metin.ozkan@analog.com 0:788f63dcf0a0 1472 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1473 }
metin.ozkan@analog.com 0:788f63dcf0a0 1474
metin.ozkan@analog.com 0:788f63dcf0a0 1475 int MAX77654::GetCHGINStatusDetails(chgin_dtls_t *chgin_dtls)
metin.ozkan@analog.com 0:788f63dcf0a0 1476 {
metin.ozkan@analog.com 0:788f63dcf0a0 1477 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1478 reg_stat_chg_b_t reg_stat_chg_b;
metin.ozkan@analog.com 0:788f63dcf0a0 1479
metin.ozkan@analog.com 0:788f63dcf0a0 1480 ret = read_register(STAT_CHG_B, (uint8_t *)&(reg_stat_chg_b));
metin.ozkan@analog.com 0:788f63dcf0a0 1481 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1482 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1483 }
metin.ozkan@analog.com 0:788f63dcf0a0 1484
metin.ozkan@analog.com 0:788f63dcf0a0 1485 *chgin_dtls = (chgin_dtls_t)reg_stat_chg_b.bits.chgin_dtls;
metin.ozkan@analog.com 0:788f63dcf0a0 1486
metin.ozkan@analog.com 0:788f63dcf0a0 1487 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1488 }
metin.ozkan@analog.com 0:788f63dcf0a0 1489
metin.ozkan@analog.com 0:788f63dcf0a0 1490 int MAX77654::GetQuickChargerStatus(chg_t *chg)
metin.ozkan@analog.com 0:788f63dcf0a0 1491 {
metin.ozkan@analog.com 0:788f63dcf0a0 1492 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1493 reg_stat_chg_b_t reg_stat_chg_b;
metin.ozkan@analog.com 0:788f63dcf0a0 1494
metin.ozkan@analog.com 0:788f63dcf0a0 1495 ret = read_register(STAT_CHG_B, (uint8_t *)&(reg_stat_chg_b));
metin.ozkan@analog.com 0:788f63dcf0a0 1496 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1497 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1498 }
metin.ozkan@analog.com 0:788f63dcf0a0 1499
metin.ozkan@analog.com 0:788f63dcf0a0 1500 *chg = (chg_t)reg_stat_chg_b.bits.chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1501
metin.ozkan@analog.com 0:788f63dcf0a0 1502 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1503 }
metin.ozkan@analog.com 0:788f63dcf0a0 1504
metin.ozkan@analog.com 0:788f63dcf0a0 1505 int MAX77654::GetTimeSuspendedIndicator(time_sus_t *time_sus)
metin.ozkan@analog.com 0:788f63dcf0a0 1506 {
metin.ozkan@analog.com 0:788f63dcf0a0 1507 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1508 reg_stat_chg_b_t reg_stat_chg_b;
metin.ozkan@analog.com 0:788f63dcf0a0 1509
metin.ozkan@analog.com 0:788f63dcf0a0 1510 ret = read_register(STAT_CHG_B, (uint8_t *)&(reg_stat_chg_b));
metin.ozkan@analog.com 0:788f63dcf0a0 1511 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1512 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1513 }
metin.ozkan@analog.com 0:788f63dcf0a0 1514
metin.ozkan@analog.com 0:788f63dcf0a0 1515 *time_sus = (time_sus_t)reg_stat_chg_b.bits.time_sus;
metin.ozkan@analog.com 0:788f63dcf0a0 1516
metin.ozkan@analog.com 0:788f63dcf0a0 1517 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1518 }
metin.ozkan@analog.com 0:788f63dcf0a0 1519
metin.ozkan@analog.com 0:788f63dcf0a0 1520 int MAX77654::SetSYSCONFIGMBit(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1521 {
metin.ozkan@analog.com 0:788f63dcf0a0 1522 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1523
metin.ozkan@analog.com 0:788f63dcf0a0 1524 SET_BIT_FIELD(INT_M_CHG, reg_int_m_chg, reg_int_m_chg.bits.sys_cnfg_m, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 1525
metin.ozkan@analog.com 0:788f63dcf0a0 1526 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1527 }
metin.ozkan@analog.com 0:788f63dcf0a0 1528
metin.ozkan@analog.com 0:788f63dcf0a0 1529 int MAX77654::GetSYSCONFIGMBit(intm_t *intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1530 {
metin.ozkan@analog.com 0:788f63dcf0a0 1531 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1532 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1533
metin.ozkan@analog.com 0:788f63dcf0a0 1534 ret = read_register(INT_M_CHG, (uint8_t *)&(reg_int_m_chg));
metin.ozkan@analog.com 0:788f63dcf0a0 1535 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1536 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1537 }
metin.ozkan@analog.com 0:788f63dcf0a0 1538
metin.ozkan@analog.com 0:788f63dcf0a0 1539 *intm = (intm_t)reg_int_m_chg.bits.sys_cnfg_m;
metin.ozkan@analog.com 0:788f63dcf0a0 1540
metin.ozkan@analog.com 0:788f63dcf0a0 1541 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1542 }
metin.ozkan@analog.com 0:788f63dcf0a0 1543
metin.ozkan@analog.com 0:788f63dcf0a0 1544 int MAX77654::SetSYSCTRLMBit(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1545 {
metin.ozkan@analog.com 0:788f63dcf0a0 1546 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1547
metin.ozkan@analog.com 0:788f63dcf0a0 1548 SET_BIT_FIELD(INT_M_CHG, reg_int_m_chg, reg_int_m_chg.bits.sys_ctrl_m, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 1549
metin.ozkan@analog.com 0:788f63dcf0a0 1550 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1551 }
metin.ozkan@analog.com 0:788f63dcf0a0 1552
metin.ozkan@analog.com 0:788f63dcf0a0 1553 int MAX77654::GetSYSCTRLMBit(intm_t *intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1554 {
metin.ozkan@analog.com 0:788f63dcf0a0 1555 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1556 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1557
metin.ozkan@analog.com 0:788f63dcf0a0 1558 ret = read_register(INT_M_CHG, (uint8_t *)&(reg_int_m_chg));
metin.ozkan@analog.com 0:788f63dcf0a0 1559 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1560 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1561 }
metin.ozkan@analog.com 0:788f63dcf0a0 1562
metin.ozkan@analog.com 0:788f63dcf0a0 1563 *intm = (intm_t)reg_int_m_chg.bits.sys_ctrl_m;
metin.ozkan@analog.com 0:788f63dcf0a0 1564
metin.ozkan@analog.com 0:788f63dcf0a0 1565 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1566 }
metin.ozkan@analog.com 0:788f63dcf0a0 1567
metin.ozkan@analog.com 0:788f63dcf0a0 1568 int MAX77654::SetCHGINCTRLMBit(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1569 {
metin.ozkan@analog.com 0:788f63dcf0a0 1570 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1571
metin.ozkan@analog.com 0:788f63dcf0a0 1572 SET_BIT_FIELD(INT_M_CHG, reg_int_m_chg, reg_int_m_chg.bits.chgin_ctrl_m, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 1573
metin.ozkan@analog.com 0:788f63dcf0a0 1574 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1575 }
metin.ozkan@analog.com 0:788f63dcf0a0 1576
metin.ozkan@analog.com 0:788f63dcf0a0 1577 int MAX77654::GetCHGINCTRLMBit(intm_t *intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1578 {
metin.ozkan@analog.com 0:788f63dcf0a0 1579 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1580 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1581
metin.ozkan@analog.com 0:788f63dcf0a0 1582 ret = read_register(INT_M_CHG, (uint8_t *)&(reg_int_m_chg));
metin.ozkan@analog.com 0:788f63dcf0a0 1583 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1584 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1585 }
metin.ozkan@analog.com 0:788f63dcf0a0 1586
metin.ozkan@analog.com 0:788f63dcf0a0 1587 *intm = (intm_t)reg_int_m_chg.bits.chgin_ctrl_m;
metin.ozkan@analog.com 0:788f63dcf0a0 1588
metin.ozkan@analog.com 0:788f63dcf0a0 1589 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1590 }
metin.ozkan@analog.com 0:788f63dcf0a0 1591
metin.ozkan@analog.com 0:788f63dcf0a0 1592 int MAX77654::SetTJREGMBit(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1593 {
metin.ozkan@analog.com 0:788f63dcf0a0 1594 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1595
metin.ozkan@analog.com 0:788f63dcf0a0 1596 SET_BIT_FIELD(INT_M_CHG, reg_int_m_chg, reg_int_m_chg.bits.tj_reg_m, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 1597
metin.ozkan@analog.com 0:788f63dcf0a0 1598 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1599 }
metin.ozkan@analog.com 0:788f63dcf0a0 1600
metin.ozkan@analog.com 0:788f63dcf0a0 1601 int MAX77654::GetTJREGMBit(intm_t *intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1602 {
metin.ozkan@analog.com 0:788f63dcf0a0 1603 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1604 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1605
metin.ozkan@analog.com 0:788f63dcf0a0 1606 ret = read_register(INT_M_CHG, (uint8_t *)&(reg_int_m_chg));
metin.ozkan@analog.com 0:788f63dcf0a0 1607 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1608 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1609 }
metin.ozkan@analog.com 0:788f63dcf0a0 1610
metin.ozkan@analog.com 0:788f63dcf0a0 1611 *intm = (intm_t)reg_int_m_chg.bits.tj_reg_m;
metin.ozkan@analog.com 0:788f63dcf0a0 1612
metin.ozkan@analog.com 0:788f63dcf0a0 1613 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1614 }
metin.ozkan@analog.com 0:788f63dcf0a0 1615
metin.ozkan@analog.com 0:788f63dcf0a0 1616 int MAX77654::SetCHGINMBit(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1617 {
metin.ozkan@analog.com 0:788f63dcf0a0 1618 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1619
metin.ozkan@analog.com 0:788f63dcf0a0 1620 SET_BIT_FIELD(INT_M_CHG, reg_int_m_chg, reg_int_m_chg.bits.chgin_m, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 1621
metin.ozkan@analog.com 0:788f63dcf0a0 1622 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1623 }
metin.ozkan@analog.com 0:788f63dcf0a0 1624
metin.ozkan@analog.com 0:788f63dcf0a0 1625 int MAX77654::GetCHGINMBit(intm_t *intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1626 {
metin.ozkan@analog.com 0:788f63dcf0a0 1627 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1628 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1629
metin.ozkan@analog.com 0:788f63dcf0a0 1630 ret = read_register(INT_M_CHG, (uint8_t *)&(reg_int_m_chg));
metin.ozkan@analog.com 0:788f63dcf0a0 1631 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1632 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1633 }
metin.ozkan@analog.com 0:788f63dcf0a0 1634
metin.ozkan@analog.com 0:788f63dcf0a0 1635 *intm = (intm_t)reg_int_m_chg.bits.chgin_m;
metin.ozkan@analog.com 0:788f63dcf0a0 1636
metin.ozkan@analog.com 0:788f63dcf0a0 1637 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1638 }
metin.ozkan@analog.com 0:788f63dcf0a0 1639
metin.ozkan@analog.com 0:788f63dcf0a0 1640 int MAX77654::SetCHGMBit(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1641 {
metin.ozkan@analog.com 0:788f63dcf0a0 1642 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1643
metin.ozkan@analog.com 0:788f63dcf0a0 1644 SET_BIT_FIELD(INT_M_CHG, reg_int_m_chg, reg_int_m_chg.bits.chg_m, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 1645
metin.ozkan@analog.com 0:788f63dcf0a0 1646 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1647 }
metin.ozkan@analog.com 0:788f63dcf0a0 1648
metin.ozkan@analog.com 0:788f63dcf0a0 1649 int MAX77654::GetCHGMBit(intm_t *intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1650 {
metin.ozkan@analog.com 0:788f63dcf0a0 1651 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1652 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1653
metin.ozkan@analog.com 0:788f63dcf0a0 1654 ret = read_register(INT_M_CHG, (uint8_t *)&(reg_int_m_chg));
metin.ozkan@analog.com 0:788f63dcf0a0 1655 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1656 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1657 }
metin.ozkan@analog.com 0:788f63dcf0a0 1658
metin.ozkan@analog.com 0:788f63dcf0a0 1659 *intm = (intm_t)reg_int_m_chg.bits.chg_m;
metin.ozkan@analog.com 0:788f63dcf0a0 1660
metin.ozkan@analog.com 0:788f63dcf0a0 1661 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1662 }
metin.ozkan@analog.com 0:788f63dcf0a0 1663
metin.ozkan@analog.com 0:788f63dcf0a0 1664 int MAX77654::SetTHMMBit(intm_t intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1665 {
metin.ozkan@analog.com 0:788f63dcf0a0 1666 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1667
metin.ozkan@analog.com 0:788f63dcf0a0 1668 SET_BIT_FIELD(INT_M_CHG, reg_int_m_chg, reg_int_m_chg.bits.thm_m, intm);
metin.ozkan@analog.com 0:788f63dcf0a0 1669
metin.ozkan@analog.com 0:788f63dcf0a0 1670 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1671 }
metin.ozkan@analog.com 0:788f63dcf0a0 1672
metin.ozkan@analog.com 0:788f63dcf0a0 1673 int MAX77654::GetTHMMBit(intm_t *intm)
metin.ozkan@analog.com 0:788f63dcf0a0 1674 {
metin.ozkan@analog.com 0:788f63dcf0a0 1675 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1676 reg_int_m_chg_t reg_int_m_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 1677
metin.ozkan@analog.com 0:788f63dcf0a0 1678 ret = read_register(INT_M_CHG, (uint8_t *)&(reg_int_m_chg));
metin.ozkan@analog.com 0:788f63dcf0a0 1679 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1680 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1681 }
metin.ozkan@analog.com 0:788f63dcf0a0 1682
metin.ozkan@analog.com 0:788f63dcf0a0 1683 *intm = (intm_t)reg_int_m_chg.bits.thm_m;
metin.ozkan@analog.com 0:788f63dcf0a0 1684
metin.ozkan@analog.com 0:788f63dcf0a0 1685 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1686 }
metin.ozkan@analog.com 0:788f63dcf0a0 1687
metin.ozkan@analog.com 0:788f63dcf0a0 1688 int MAX77654::SetHOTJEITATemperature(thm_hot_t thm_hot)
metin.ozkan@analog.com 0:788f63dcf0a0 1689 {
metin.ozkan@analog.com 0:788f63dcf0a0 1690 reg_cnfg_chg_a_t reg_cnfg_chg_a;
metin.ozkan@analog.com 0:788f63dcf0a0 1691
metin.ozkan@analog.com 0:788f63dcf0a0 1692 SET_BIT_FIELD(CNFG_CHG_A, reg_cnfg_chg_a, reg_cnfg_chg_a.bits.thm_hot, thm_hot);
metin.ozkan@analog.com 0:788f63dcf0a0 1693
metin.ozkan@analog.com 0:788f63dcf0a0 1694 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1695 }
metin.ozkan@analog.com 0:788f63dcf0a0 1696
metin.ozkan@analog.com 0:788f63dcf0a0 1697 int MAX77654::GetHOTJEITATemperature(thm_hot_t *thm_hot)
metin.ozkan@analog.com 0:788f63dcf0a0 1698 {
metin.ozkan@analog.com 0:788f63dcf0a0 1699 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1700 reg_cnfg_chg_a_t reg_cnfg_chg_a;
metin.ozkan@analog.com 0:788f63dcf0a0 1701
metin.ozkan@analog.com 0:788f63dcf0a0 1702 ret = read_register(CNFG_CHG_A, (uint8_t *)&(reg_cnfg_chg_a));
metin.ozkan@analog.com 0:788f63dcf0a0 1703 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1704 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1705 }
metin.ozkan@analog.com 0:788f63dcf0a0 1706
metin.ozkan@analog.com 0:788f63dcf0a0 1707 *thm_hot = (thm_hot_t)reg_cnfg_chg_a.bits.thm_hot;
metin.ozkan@analog.com 0:788f63dcf0a0 1708
metin.ozkan@analog.com 0:788f63dcf0a0 1709 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1710 }
metin.ozkan@analog.com 0:788f63dcf0a0 1711
metin.ozkan@analog.com 0:788f63dcf0a0 1712 int MAX77654::SetWARMJEITATemperature(thm_warm_t thm_warm)
metin.ozkan@analog.com 0:788f63dcf0a0 1713 {
metin.ozkan@analog.com 0:788f63dcf0a0 1714 reg_cnfg_chg_a_t reg_cnfg_chg_a;
metin.ozkan@analog.com 0:788f63dcf0a0 1715
metin.ozkan@analog.com 0:788f63dcf0a0 1716 SET_BIT_FIELD(CNFG_CHG_A, reg_cnfg_chg_a, reg_cnfg_chg_a.bits.thm_warm, thm_warm);
metin.ozkan@analog.com 0:788f63dcf0a0 1717
metin.ozkan@analog.com 0:788f63dcf0a0 1718 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1719 }
metin.ozkan@analog.com 0:788f63dcf0a0 1720
metin.ozkan@analog.com 0:788f63dcf0a0 1721 int MAX77654::GetWARMJEITATemperature(thm_warm_t *thm_warm)
metin.ozkan@analog.com 0:788f63dcf0a0 1722 {
metin.ozkan@analog.com 0:788f63dcf0a0 1723 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1724 reg_cnfg_chg_a_t reg_cnfg_chg_a;
metin.ozkan@analog.com 0:788f63dcf0a0 1725
metin.ozkan@analog.com 0:788f63dcf0a0 1726 ret = read_register(CNFG_CHG_A, (uint8_t *)&(reg_cnfg_chg_a));
metin.ozkan@analog.com 0:788f63dcf0a0 1727 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1728 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1729 }
metin.ozkan@analog.com 0:788f63dcf0a0 1730
metin.ozkan@analog.com 0:788f63dcf0a0 1731 *thm_warm = (thm_warm_t)reg_cnfg_chg_a.bits.thm_warm;
metin.ozkan@analog.com 0:788f63dcf0a0 1732
metin.ozkan@analog.com 0:788f63dcf0a0 1733 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1734 }
metin.ozkan@analog.com 0:788f63dcf0a0 1735
metin.ozkan@analog.com 0:788f63dcf0a0 1736 int MAX77654::SetCOOLJEITATemperature(thm_cool_t thm_cool)
metin.ozkan@analog.com 0:788f63dcf0a0 1737 {
metin.ozkan@analog.com 0:788f63dcf0a0 1738 reg_cnfg_chg_a_t reg_cnfg_chg_a;
metin.ozkan@analog.com 0:788f63dcf0a0 1739
metin.ozkan@analog.com 0:788f63dcf0a0 1740 SET_BIT_FIELD(CNFG_CHG_A, reg_cnfg_chg_a, reg_cnfg_chg_a.bits.thm_cool, thm_cool);
metin.ozkan@analog.com 0:788f63dcf0a0 1741
metin.ozkan@analog.com 0:788f63dcf0a0 1742 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1743 }
metin.ozkan@analog.com 0:788f63dcf0a0 1744
metin.ozkan@analog.com 0:788f63dcf0a0 1745 int MAX77654::GetCOOLJEITATemperature(thm_cool_t *thm_cool)
metin.ozkan@analog.com 0:788f63dcf0a0 1746 {
metin.ozkan@analog.com 0:788f63dcf0a0 1747 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1748 reg_cnfg_chg_a_t reg_cnfg_chg_a;
metin.ozkan@analog.com 0:788f63dcf0a0 1749
metin.ozkan@analog.com 0:788f63dcf0a0 1750 ret = read_register(CNFG_CHG_A, (uint8_t *)&(reg_cnfg_chg_a));
metin.ozkan@analog.com 0:788f63dcf0a0 1751 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1752 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1753 }
metin.ozkan@analog.com 0:788f63dcf0a0 1754
metin.ozkan@analog.com 0:788f63dcf0a0 1755 *thm_cool = (thm_cool_t)reg_cnfg_chg_a.bits.thm_cool;
metin.ozkan@analog.com 0:788f63dcf0a0 1756
metin.ozkan@analog.com 0:788f63dcf0a0 1757 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1758 }
metin.ozkan@analog.com 0:788f63dcf0a0 1759
metin.ozkan@analog.com 0:788f63dcf0a0 1760 int MAX77654::SetCOLDJEITATemperature(thm_cold_t thm_cold)
metin.ozkan@analog.com 0:788f63dcf0a0 1761 {
metin.ozkan@analog.com 0:788f63dcf0a0 1762 reg_cnfg_chg_a_t reg_cnfg_chg_a;
metin.ozkan@analog.com 0:788f63dcf0a0 1763
metin.ozkan@analog.com 0:788f63dcf0a0 1764 SET_BIT_FIELD(CNFG_CHG_A, reg_cnfg_chg_a, reg_cnfg_chg_a.bits.thm_cold, thm_cold);
metin.ozkan@analog.com 0:788f63dcf0a0 1765
metin.ozkan@analog.com 0:788f63dcf0a0 1766 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1767 }
metin.ozkan@analog.com 0:788f63dcf0a0 1768
metin.ozkan@analog.com 0:788f63dcf0a0 1769 int MAX77654::GetCOLDJEITATemperature(thm_cold_t *thm_cold)
metin.ozkan@analog.com 0:788f63dcf0a0 1770 {
metin.ozkan@analog.com 0:788f63dcf0a0 1771 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1772 reg_cnfg_chg_a_t reg_cnfg_chg_a;
metin.ozkan@analog.com 0:788f63dcf0a0 1773
metin.ozkan@analog.com 0:788f63dcf0a0 1774 ret = read_register(CNFG_CHG_A, (uint8_t *)&(reg_cnfg_chg_a));
metin.ozkan@analog.com 0:788f63dcf0a0 1775 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1776 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1777 }
metin.ozkan@analog.com 0:788f63dcf0a0 1778
metin.ozkan@analog.com 0:788f63dcf0a0 1779 *thm_cold = (thm_cold_t)reg_cnfg_chg_a.bits.thm_cold;
metin.ozkan@analog.com 0:788f63dcf0a0 1780
metin.ozkan@analog.com 0:788f63dcf0a0 1781 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1782 }
metin.ozkan@analog.com 0:788f63dcf0a0 1783
metin.ozkan@analog.com 0:788f63dcf0a0 1784 int MAX77654::SetMinimumCHGINVoltage(vchgin_min_t vchgin_min)
metin.ozkan@analog.com 0:788f63dcf0a0 1785 {
metin.ozkan@analog.com 0:788f63dcf0a0 1786 reg_cnfg_chg_b_t reg_cnfg_chg_b;
metin.ozkan@analog.com 0:788f63dcf0a0 1787
metin.ozkan@analog.com 0:788f63dcf0a0 1788 SET_BIT_FIELD(CNFG_CHG_B, reg_cnfg_chg_b, reg_cnfg_chg_b.bits.vchgin_min, vchgin_min);
metin.ozkan@analog.com 0:788f63dcf0a0 1789
metin.ozkan@analog.com 0:788f63dcf0a0 1790 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1791 }
metin.ozkan@analog.com 0:788f63dcf0a0 1792
metin.ozkan@analog.com 0:788f63dcf0a0 1793 int MAX77654::GetMinimumCHGINVoltage(vchgin_min_t *vchgin_min)
metin.ozkan@analog.com 0:788f63dcf0a0 1794 {
metin.ozkan@analog.com 0:788f63dcf0a0 1795 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1796 reg_cnfg_chg_b_t reg_cnfg_chg_b;
metin.ozkan@analog.com 0:788f63dcf0a0 1797
metin.ozkan@analog.com 0:788f63dcf0a0 1798 ret = read_register(CNFG_CHG_B, (uint8_t *)&(reg_cnfg_chg_b));
metin.ozkan@analog.com 0:788f63dcf0a0 1799 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1800 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1801 }
metin.ozkan@analog.com 0:788f63dcf0a0 1802
metin.ozkan@analog.com 0:788f63dcf0a0 1803 *vchgin_min = (vchgin_min_t)reg_cnfg_chg_b.bits.vchgin_min;
metin.ozkan@analog.com 0:788f63dcf0a0 1804
metin.ozkan@analog.com 0:788f63dcf0a0 1805 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1806 }
metin.ozkan@analog.com 0:788f63dcf0a0 1807
metin.ozkan@analog.com 0:788f63dcf0a0 1808 int MAX77654::SetCHGINInputCurrentLimit(ichgin_lim_t ichgin_lim)
metin.ozkan@analog.com 0:788f63dcf0a0 1809 {
metin.ozkan@analog.com 0:788f63dcf0a0 1810 reg_cnfg_chg_b_t reg_cnfg_chg_b;
metin.ozkan@analog.com 0:788f63dcf0a0 1811
metin.ozkan@analog.com 0:788f63dcf0a0 1812 SET_BIT_FIELD(CNFG_CHG_B, reg_cnfg_chg_b, reg_cnfg_chg_b.bits.ichgin_lim, ichgin_lim);
metin.ozkan@analog.com 0:788f63dcf0a0 1813
metin.ozkan@analog.com 0:788f63dcf0a0 1814 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1815 }
metin.ozkan@analog.com 0:788f63dcf0a0 1816
metin.ozkan@analog.com 0:788f63dcf0a0 1817 int MAX77654::GetCHGINInputCurrentLimit(ichgin_lim_t *ichgin_lim)
metin.ozkan@analog.com 0:788f63dcf0a0 1818 {
metin.ozkan@analog.com 0:788f63dcf0a0 1819 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1820 reg_cnfg_chg_b_t reg_cnfg_chg_b;
metin.ozkan@analog.com 0:788f63dcf0a0 1821
metin.ozkan@analog.com 0:788f63dcf0a0 1822 ret = read_register(CNFG_CHG_B, (uint8_t *)&(reg_cnfg_chg_b));
metin.ozkan@analog.com 0:788f63dcf0a0 1823 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1824 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1825 }
metin.ozkan@analog.com 0:788f63dcf0a0 1826
metin.ozkan@analog.com 0:788f63dcf0a0 1827 *ichgin_lim = (ichgin_lim_t)reg_cnfg_chg_b.bits.ichgin_lim;
metin.ozkan@analog.com 0:788f63dcf0a0 1828
metin.ozkan@analog.com 0:788f63dcf0a0 1829 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1830 }
metin.ozkan@analog.com 0:788f63dcf0a0 1831
metin.ozkan@analog.com 0:788f63dcf0a0 1832 int MAX77654::SetPrequalificationChargeCurrent(i_pq_t i_pq)
metin.ozkan@analog.com 0:788f63dcf0a0 1833 {
metin.ozkan@analog.com 0:788f63dcf0a0 1834 reg_cnfg_chg_b_t reg_cnfg_chg_b;
metin.ozkan@analog.com 0:788f63dcf0a0 1835
metin.ozkan@analog.com 0:788f63dcf0a0 1836 SET_BIT_FIELD(CNFG_CHG_B, reg_cnfg_chg_b, reg_cnfg_chg_b.bits.i_pq, i_pq);
metin.ozkan@analog.com 0:788f63dcf0a0 1837
metin.ozkan@analog.com 0:788f63dcf0a0 1838 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1839 }
metin.ozkan@analog.com 0:788f63dcf0a0 1840
metin.ozkan@analog.com 0:788f63dcf0a0 1841 int MAX77654::GetPrequalificationChargeCurrent(i_pq_t *i_pq)
metin.ozkan@analog.com 0:788f63dcf0a0 1842 {
metin.ozkan@analog.com 0:788f63dcf0a0 1843 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1844 reg_cnfg_chg_b_t reg_cnfg_chg_b;
metin.ozkan@analog.com 0:788f63dcf0a0 1845
metin.ozkan@analog.com 0:788f63dcf0a0 1846 ret = read_register(CNFG_CHG_B, (uint8_t *)&(reg_cnfg_chg_b));
metin.ozkan@analog.com 0:788f63dcf0a0 1847 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1848 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1849 }
metin.ozkan@analog.com 0:788f63dcf0a0 1850
metin.ozkan@analog.com 0:788f63dcf0a0 1851 *i_pq = (i_pq_t)reg_cnfg_chg_b.bits.i_pq;
metin.ozkan@analog.com 0:788f63dcf0a0 1852
metin.ozkan@analog.com 0:788f63dcf0a0 1853 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1854 }
metin.ozkan@analog.com 0:788f63dcf0a0 1855
metin.ozkan@analog.com 0:788f63dcf0a0 1856 int MAX77654::SetBatteryChargerEnable(chg_en_t chg_en)
metin.ozkan@analog.com 0:788f63dcf0a0 1857 {
metin.ozkan@analog.com 0:788f63dcf0a0 1858 reg_cnfg_chg_b_t reg_cnfg_chg_b;
metin.ozkan@analog.com 0:788f63dcf0a0 1859
metin.ozkan@analog.com 0:788f63dcf0a0 1860 SET_BIT_FIELD(CNFG_CHG_B, reg_cnfg_chg_b, reg_cnfg_chg_b.bits.chg_en, chg_en);
metin.ozkan@analog.com 0:788f63dcf0a0 1861
metin.ozkan@analog.com 0:788f63dcf0a0 1862 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1863 }
metin.ozkan@analog.com 0:788f63dcf0a0 1864
metin.ozkan@analog.com 0:788f63dcf0a0 1865 int MAX77654::GetBatteryChargerEnable(chg_en_t *chg_en)
metin.ozkan@analog.com 0:788f63dcf0a0 1866 {
metin.ozkan@analog.com 0:788f63dcf0a0 1867 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1868 reg_cnfg_chg_b_t reg_cnfg_chg_b;
metin.ozkan@analog.com 0:788f63dcf0a0 1869
metin.ozkan@analog.com 0:788f63dcf0a0 1870 ret = read_register(CNFG_CHG_B, (uint8_t *)&(reg_cnfg_chg_b));
metin.ozkan@analog.com 0:788f63dcf0a0 1871 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1872 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1873 }
metin.ozkan@analog.com 0:788f63dcf0a0 1874
metin.ozkan@analog.com 0:788f63dcf0a0 1875 *chg_en = (chg_en_t)reg_cnfg_chg_b.bits.chg_en;
metin.ozkan@analog.com 0:788f63dcf0a0 1876
metin.ozkan@analog.com 0:788f63dcf0a0 1877 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1878 }
metin.ozkan@analog.com 0:788f63dcf0a0 1879
metin.ozkan@analog.com 0:788f63dcf0a0 1880 int MAX77654::SetBatteryPQVoltageThreshold(chg_pq_t chg_pq)
metin.ozkan@analog.com 0:788f63dcf0a0 1881 {
metin.ozkan@analog.com 0:788f63dcf0a0 1882 reg_cnfg_chg_c_t reg_cnfg_chg_c;
metin.ozkan@analog.com 0:788f63dcf0a0 1883
metin.ozkan@analog.com 0:788f63dcf0a0 1884 SET_BIT_FIELD(CNFG_CHG_C, reg_cnfg_chg_c, reg_cnfg_chg_c.bits.chg_pq, chg_pq);
metin.ozkan@analog.com 0:788f63dcf0a0 1885
metin.ozkan@analog.com 0:788f63dcf0a0 1886 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1887 }
metin.ozkan@analog.com 0:788f63dcf0a0 1888
metin.ozkan@analog.com 0:788f63dcf0a0 1889 int MAX77654::GetBatteryPQVoltageThreshold(chg_pq_t *chg_pq)
metin.ozkan@analog.com 0:788f63dcf0a0 1890 {
metin.ozkan@analog.com 0:788f63dcf0a0 1891 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1892 reg_cnfg_chg_c_t reg_cnfg_chg_c;
metin.ozkan@analog.com 0:788f63dcf0a0 1893
metin.ozkan@analog.com 0:788f63dcf0a0 1894 ret = read_register(CNFG_CHG_C, (uint8_t *)&(reg_cnfg_chg_c));
metin.ozkan@analog.com 0:788f63dcf0a0 1895 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1896 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1897 }
metin.ozkan@analog.com 0:788f63dcf0a0 1898
metin.ozkan@analog.com 0:788f63dcf0a0 1899 *chg_pq = (chg_pq_t)reg_cnfg_chg_c.bits.chg_pq;
metin.ozkan@analog.com 0:788f63dcf0a0 1900
metin.ozkan@analog.com 0:788f63dcf0a0 1901 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1902 }
metin.ozkan@analog.com 0:788f63dcf0a0 1903
metin.ozkan@analog.com 0:788f63dcf0a0 1904 int MAX77654::SetChargerTerminationCurrent(i_term_t i_term)
metin.ozkan@analog.com 0:788f63dcf0a0 1905 {
metin.ozkan@analog.com 0:788f63dcf0a0 1906 reg_cnfg_chg_c_t reg_cnfg_chg_c;
metin.ozkan@analog.com 0:788f63dcf0a0 1907
metin.ozkan@analog.com 0:788f63dcf0a0 1908 SET_BIT_FIELD(CNFG_CHG_C, reg_cnfg_chg_c, reg_cnfg_chg_c.bits.i_term, i_term);
metin.ozkan@analog.com 0:788f63dcf0a0 1909
metin.ozkan@analog.com 0:788f63dcf0a0 1910 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1911 }
metin.ozkan@analog.com 0:788f63dcf0a0 1912
metin.ozkan@analog.com 0:788f63dcf0a0 1913 int MAX77654::GetChargerTerminationCurrent(i_term_t *i_term)
metin.ozkan@analog.com 0:788f63dcf0a0 1914 {
metin.ozkan@analog.com 0:788f63dcf0a0 1915 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1916 reg_cnfg_chg_c_t reg_cnfg_chg_c;
metin.ozkan@analog.com 0:788f63dcf0a0 1917
metin.ozkan@analog.com 0:788f63dcf0a0 1918 ret = read_register(CNFG_CHG_C, (uint8_t *)&(reg_cnfg_chg_c));
metin.ozkan@analog.com 0:788f63dcf0a0 1919 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1920 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1921 }
metin.ozkan@analog.com 0:788f63dcf0a0 1922
metin.ozkan@analog.com 0:788f63dcf0a0 1923 *i_term = (i_term_t)reg_cnfg_chg_c.bits.i_term;
metin.ozkan@analog.com 0:788f63dcf0a0 1924
metin.ozkan@analog.com 0:788f63dcf0a0 1925 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1926 }
metin.ozkan@analog.com 0:788f63dcf0a0 1927
metin.ozkan@analog.com 0:788f63dcf0a0 1928 int MAX77654::SetTopOffTimerValue(t_topoff_t t_topoff)
metin.ozkan@analog.com 0:788f63dcf0a0 1929 {
metin.ozkan@analog.com 0:788f63dcf0a0 1930 reg_cnfg_chg_c_t reg_cnfg_chg_c;
metin.ozkan@analog.com 0:788f63dcf0a0 1931
metin.ozkan@analog.com 0:788f63dcf0a0 1932 SET_BIT_FIELD(CNFG_CHG_C, reg_cnfg_chg_c, reg_cnfg_chg_c.bits.t_topoff, t_topoff);
metin.ozkan@analog.com 0:788f63dcf0a0 1933
metin.ozkan@analog.com 0:788f63dcf0a0 1934 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1935 }
metin.ozkan@analog.com 0:788f63dcf0a0 1936
metin.ozkan@analog.com 0:788f63dcf0a0 1937 int MAX77654::GetTopOffTimerValue(t_topoff_t *t_topoff)
metin.ozkan@analog.com 0:788f63dcf0a0 1938 {
metin.ozkan@analog.com 0:788f63dcf0a0 1939 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1940 reg_cnfg_chg_c_t reg_cnfg_chg_c;
metin.ozkan@analog.com 0:788f63dcf0a0 1941
metin.ozkan@analog.com 0:788f63dcf0a0 1942 ret = read_register(CNFG_CHG_C, (uint8_t *)&(reg_cnfg_chg_c));
metin.ozkan@analog.com 0:788f63dcf0a0 1943 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1944 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1945 }
metin.ozkan@analog.com 0:788f63dcf0a0 1946
metin.ozkan@analog.com 0:788f63dcf0a0 1947 *t_topoff = (t_topoff_t)reg_cnfg_chg_c.bits.t_topoff;
metin.ozkan@analog.com 0:788f63dcf0a0 1948
metin.ozkan@analog.com 0:788f63dcf0a0 1949 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1950 }
metin.ozkan@analog.com 0:788f63dcf0a0 1951
metin.ozkan@analog.com 0:788f63dcf0a0 1952 int MAX77654::SetDieJunctionTemperature(tj_reg_t tj_reg)
metin.ozkan@analog.com 0:788f63dcf0a0 1953 {
metin.ozkan@analog.com 0:788f63dcf0a0 1954 reg_cnfg_chg_d_t reg_cnfg_chg_d;
metin.ozkan@analog.com 0:788f63dcf0a0 1955
metin.ozkan@analog.com 0:788f63dcf0a0 1956 SET_BIT_FIELD(CNFG_CHG_D, reg_cnfg_chg_d, reg_cnfg_chg_d.bits.tj_reg, tj_reg);
metin.ozkan@analog.com 0:788f63dcf0a0 1957
metin.ozkan@analog.com 0:788f63dcf0a0 1958 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1959 }
metin.ozkan@analog.com 0:788f63dcf0a0 1960
metin.ozkan@analog.com 0:788f63dcf0a0 1961 int MAX77654::GetDieJunctionTemperature(tj_reg_t *tj_reg)
metin.ozkan@analog.com 0:788f63dcf0a0 1962 {
metin.ozkan@analog.com 0:788f63dcf0a0 1963 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1964 reg_cnfg_chg_d_t reg_cnfg_chg_d;
metin.ozkan@analog.com 0:788f63dcf0a0 1965
metin.ozkan@analog.com 0:788f63dcf0a0 1966 ret = read_register(CNFG_CHG_D, (uint8_t *)&(reg_cnfg_chg_d));
metin.ozkan@analog.com 0:788f63dcf0a0 1967 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1968 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1969 }
metin.ozkan@analog.com 0:788f63dcf0a0 1970
metin.ozkan@analog.com 0:788f63dcf0a0 1971 *tj_reg = (tj_reg_t)reg_cnfg_chg_d.bits.tj_reg;
metin.ozkan@analog.com 0:788f63dcf0a0 1972
metin.ozkan@analog.com 0:788f63dcf0a0 1973 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1974 }
metin.ozkan@analog.com 0:788f63dcf0a0 1975
metin.ozkan@analog.com 0:788f63dcf0a0 1976 int MAX77654::SetSystemVoltageRegulation(vsys_reg_t vsys_reg)
metin.ozkan@analog.com 0:788f63dcf0a0 1977 {
metin.ozkan@analog.com 0:788f63dcf0a0 1978 reg_cnfg_chg_d_t reg_cnfg_chg_d;
metin.ozkan@analog.com 0:788f63dcf0a0 1979
metin.ozkan@analog.com 0:788f63dcf0a0 1980 SET_BIT_FIELD(CNFG_CHG_D, reg_cnfg_chg_d, reg_cnfg_chg_d.bits.vsys_reg, vsys_reg);
metin.ozkan@analog.com 0:788f63dcf0a0 1981
metin.ozkan@analog.com 0:788f63dcf0a0 1982 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1983 }
metin.ozkan@analog.com 0:788f63dcf0a0 1984
metin.ozkan@analog.com 0:788f63dcf0a0 1985 int MAX77654::GetSystemVoltageRegulation(vsys_reg_t *vsys_reg)
metin.ozkan@analog.com 0:788f63dcf0a0 1986 {
metin.ozkan@analog.com 0:788f63dcf0a0 1987 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1988 reg_cnfg_chg_d_t reg_cnfg_chg_d;
metin.ozkan@analog.com 0:788f63dcf0a0 1989
metin.ozkan@analog.com 0:788f63dcf0a0 1990 ret = read_register(CNFG_CHG_D, (uint8_t *)&(reg_cnfg_chg_d));
metin.ozkan@analog.com 0:788f63dcf0a0 1991 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 1992 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 1993 }
metin.ozkan@analog.com 0:788f63dcf0a0 1994
metin.ozkan@analog.com 0:788f63dcf0a0 1995 *vsys_reg = (vsys_reg_t)reg_cnfg_chg_d.bits.vsys_reg;
metin.ozkan@analog.com 0:788f63dcf0a0 1996
metin.ozkan@analog.com 0:788f63dcf0a0 1997 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 1998 }
metin.ozkan@analog.com 0:788f63dcf0a0 1999
metin.ozkan@analog.com 0:788f63dcf0a0 2000 int MAX77654::SetFastChargeCCValue(chg_cc_t chg_cc)
metin.ozkan@analog.com 0:788f63dcf0a0 2001 {
metin.ozkan@analog.com 0:788f63dcf0a0 2002 reg_cnfg_chg_e_t reg_cnfg_chg_e;
metin.ozkan@analog.com 0:788f63dcf0a0 2003
metin.ozkan@analog.com 0:788f63dcf0a0 2004 SET_BIT_FIELD(CNFG_CHG_E, reg_cnfg_chg_e, reg_cnfg_chg_e.bits.chg_cc, chg_cc);
metin.ozkan@analog.com 0:788f63dcf0a0 2005
metin.ozkan@analog.com 0:788f63dcf0a0 2006 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2007 }
metin.ozkan@analog.com 0:788f63dcf0a0 2008
metin.ozkan@analog.com 0:788f63dcf0a0 2009 int MAX77654::GetFastChargeCCValue(chg_cc_t *chg_cc)
metin.ozkan@analog.com 0:788f63dcf0a0 2010 {
metin.ozkan@analog.com 0:788f63dcf0a0 2011 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2012 reg_cnfg_chg_e_t reg_cnfg_chg_e;
metin.ozkan@analog.com 0:788f63dcf0a0 2013
metin.ozkan@analog.com 0:788f63dcf0a0 2014 ret = read_register(CNFG_CHG_E, (uint8_t *)&(reg_cnfg_chg_e));
metin.ozkan@analog.com 0:788f63dcf0a0 2015 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2016 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2017 }
metin.ozkan@analog.com 0:788f63dcf0a0 2018
metin.ozkan@analog.com 0:788f63dcf0a0 2019 *chg_cc = (chg_cc_t)reg_cnfg_chg_e.bits.chg_cc;
metin.ozkan@analog.com 0:788f63dcf0a0 2020
metin.ozkan@analog.com 0:788f63dcf0a0 2021 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2022 }
metin.ozkan@analog.com 0:788f63dcf0a0 2023
metin.ozkan@analog.com 0:788f63dcf0a0 2024 int MAX77654::SetFastChargSafetyTimer(t_fast_chg_t t_fast_chg)
metin.ozkan@analog.com 0:788f63dcf0a0 2025 {
metin.ozkan@analog.com 0:788f63dcf0a0 2026 reg_cnfg_chg_e_t reg_cnfg_chg_e;
metin.ozkan@analog.com 0:788f63dcf0a0 2027
metin.ozkan@analog.com 0:788f63dcf0a0 2028 SET_BIT_FIELD(CNFG_CHG_E, reg_cnfg_chg_e, reg_cnfg_chg_e.bits.t_fast_chg, t_fast_chg);
metin.ozkan@analog.com 0:788f63dcf0a0 2029
metin.ozkan@analog.com 0:788f63dcf0a0 2030 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2031 }
metin.ozkan@analog.com 0:788f63dcf0a0 2032
metin.ozkan@analog.com 0:788f63dcf0a0 2033 int MAX77654::GetFastChargSafetyTimer(t_fast_chg_t *t_fast_chg)
metin.ozkan@analog.com 0:788f63dcf0a0 2034 {
metin.ozkan@analog.com 0:788f63dcf0a0 2035 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2036 reg_cnfg_chg_e_t reg_cnfg_chg_e;
metin.ozkan@analog.com 0:788f63dcf0a0 2037
metin.ozkan@analog.com 0:788f63dcf0a0 2038 ret = read_register(CNFG_CHG_E, (uint8_t *)&(reg_cnfg_chg_e));
metin.ozkan@analog.com 0:788f63dcf0a0 2039 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2040 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2041 }
metin.ozkan@analog.com 0:788f63dcf0a0 2042
metin.ozkan@analog.com 0:788f63dcf0a0 2043 *t_fast_chg = (t_fast_chg_t)reg_cnfg_chg_e.bits.t_fast_chg;
metin.ozkan@analog.com 0:788f63dcf0a0 2044
metin.ozkan@analog.com 0:788f63dcf0a0 2045 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2046 }
metin.ozkan@analog.com 0:788f63dcf0a0 2047
metin.ozkan@analog.com 0:788f63dcf0a0 2048 int MAX77654::SetFastChargeCCJEITA(chg_cc_t chg_cc_jeita)
metin.ozkan@analog.com 0:788f63dcf0a0 2049 {
metin.ozkan@analog.com 0:788f63dcf0a0 2050 reg_cnfg_chg_f_t reg_cnfg_chg_f;
metin.ozkan@analog.com 0:788f63dcf0a0 2051
metin.ozkan@analog.com 0:788f63dcf0a0 2052 SET_BIT_FIELD(CNFG_CHG_F, reg_cnfg_chg_f, reg_cnfg_chg_f.bits.chg_cc_jeita, chg_cc_jeita);
metin.ozkan@analog.com 0:788f63dcf0a0 2053
metin.ozkan@analog.com 0:788f63dcf0a0 2054 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2055 }
metin.ozkan@analog.com 0:788f63dcf0a0 2056
metin.ozkan@analog.com 0:788f63dcf0a0 2057 int MAX77654::GetFastChargeCCJEITA(chg_cc_t *chg_cc_jeita)
metin.ozkan@analog.com 0:788f63dcf0a0 2058 {
metin.ozkan@analog.com 0:788f63dcf0a0 2059 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2060 reg_cnfg_chg_f_t reg_cnfg_chg_f;
metin.ozkan@analog.com 0:788f63dcf0a0 2061
metin.ozkan@analog.com 0:788f63dcf0a0 2062 ret = read_register(CNFG_CHG_F, (uint8_t *)&(reg_cnfg_chg_f));
metin.ozkan@analog.com 0:788f63dcf0a0 2063 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2064 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2065 }
metin.ozkan@analog.com 0:788f63dcf0a0 2066
metin.ozkan@analog.com 0:788f63dcf0a0 2067 *chg_cc_jeita = (chg_cc_t)reg_cnfg_chg_f.bits.chg_cc_jeita;
metin.ozkan@analog.com 0:788f63dcf0a0 2068
metin.ozkan@analog.com 0:788f63dcf0a0 2069 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2070 }
metin.ozkan@analog.com 0:788f63dcf0a0 2071
metin.ozkan@analog.com 0:788f63dcf0a0 2072 int MAX77654::SetThermistorEnable(thm_en_t thm_en)
metin.ozkan@analog.com 0:788f63dcf0a0 2073 {
metin.ozkan@analog.com 0:788f63dcf0a0 2074 reg_cnfg_chg_f_t reg_cnfg_chg_f;
metin.ozkan@analog.com 0:788f63dcf0a0 2075
metin.ozkan@analog.com 0:788f63dcf0a0 2076 SET_BIT_FIELD(CNFG_CHG_F, reg_cnfg_chg_f, reg_cnfg_chg_f.bits.thm_en, thm_en);
metin.ozkan@analog.com 0:788f63dcf0a0 2077
metin.ozkan@analog.com 0:788f63dcf0a0 2078 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2079 }
metin.ozkan@analog.com 0:788f63dcf0a0 2080
metin.ozkan@analog.com 0:788f63dcf0a0 2081 int MAX77654::GetThermistorEnable(thm_en_t *thm_en)
metin.ozkan@analog.com 0:788f63dcf0a0 2082 {
metin.ozkan@analog.com 0:788f63dcf0a0 2083 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2084 reg_cnfg_chg_f_t reg_cnfg_chg_f;
metin.ozkan@analog.com 0:788f63dcf0a0 2085
metin.ozkan@analog.com 0:788f63dcf0a0 2086 ret = read_register(CNFG_CHG_F, (uint8_t *)&(reg_cnfg_chg_f));
metin.ozkan@analog.com 0:788f63dcf0a0 2087 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2088 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2089 }
metin.ozkan@analog.com 0:788f63dcf0a0 2090
metin.ozkan@analog.com 0:788f63dcf0a0 2091 *thm_en = (thm_en_t)reg_cnfg_chg_f.bits.thm_en;
metin.ozkan@analog.com 0:788f63dcf0a0 2092
metin.ozkan@analog.com 0:788f63dcf0a0 2093 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2094 }
metin.ozkan@analog.com 0:788f63dcf0a0 2095
metin.ozkan@analog.com 0:788f63dcf0a0 2096 int MAX77654::SetFastChargeBatteryRegVolt(chg_cv_t chg_cv)
metin.ozkan@analog.com 0:788f63dcf0a0 2097 {
metin.ozkan@analog.com 0:788f63dcf0a0 2098 reg_cnfg_chg_g_t reg_cnfg_chg_g;
metin.ozkan@analog.com 0:788f63dcf0a0 2099
metin.ozkan@analog.com 0:788f63dcf0a0 2100 SET_BIT_FIELD(CNFG_CHG_G, reg_cnfg_chg_g, reg_cnfg_chg_g.bits.chg_cv, chg_cv);
metin.ozkan@analog.com 0:788f63dcf0a0 2101
metin.ozkan@analog.com 0:788f63dcf0a0 2102 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2103 }
metin.ozkan@analog.com 0:788f63dcf0a0 2104
metin.ozkan@analog.com 0:788f63dcf0a0 2105 int MAX77654::GetFastChargeBatteryRegVolt(chg_cv_t *chg_cv)
metin.ozkan@analog.com 0:788f63dcf0a0 2106 {
metin.ozkan@analog.com 0:788f63dcf0a0 2107 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2108 reg_cnfg_chg_g_t reg_cnfg_chg_g;
metin.ozkan@analog.com 0:788f63dcf0a0 2109
metin.ozkan@analog.com 0:788f63dcf0a0 2110 ret = read_register(CNFG_CHG_G, (uint8_t *)&(reg_cnfg_chg_g));
metin.ozkan@analog.com 0:788f63dcf0a0 2111 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2112 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2113 }
metin.ozkan@analog.com 0:788f63dcf0a0 2114
metin.ozkan@analog.com 0:788f63dcf0a0 2115 *chg_cv = (chg_cv_t)reg_cnfg_chg_g.bits.chg_cv;
metin.ozkan@analog.com 0:788f63dcf0a0 2116
metin.ozkan@analog.com 0:788f63dcf0a0 2117 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2118 }
metin.ozkan@analog.com 0:788f63dcf0a0 2119
metin.ozkan@analog.com 0:788f63dcf0a0 2120 int MAX77654::SetCHGINUSBSuspendMode(usbs_t usbs)
metin.ozkan@analog.com 0:788f63dcf0a0 2121 {
metin.ozkan@analog.com 0:788f63dcf0a0 2122 reg_cnfg_chg_g_t reg_cnfg_chg_g;
metin.ozkan@analog.com 0:788f63dcf0a0 2123
metin.ozkan@analog.com 0:788f63dcf0a0 2124 SET_BIT_FIELD(CNFG_CHG_G, reg_cnfg_chg_g, reg_cnfg_chg_g.bits.usbs, usbs);
metin.ozkan@analog.com 0:788f63dcf0a0 2125
metin.ozkan@analog.com 0:788f63dcf0a0 2126 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2127 }
metin.ozkan@analog.com 0:788f63dcf0a0 2128
metin.ozkan@analog.com 0:788f63dcf0a0 2129 int MAX77654::GetCHGINUSBSuspendMode(usbs_t *usbs)
metin.ozkan@analog.com 0:788f63dcf0a0 2130 {
metin.ozkan@analog.com 0:788f63dcf0a0 2131 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2132 reg_cnfg_chg_g_t reg_cnfg_chg_g;
metin.ozkan@analog.com 0:788f63dcf0a0 2133
metin.ozkan@analog.com 0:788f63dcf0a0 2134 ret = read_register(CNFG_CHG_G, (uint8_t *)&(reg_cnfg_chg_g));
metin.ozkan@analog.com 0:788f63dcf0a0 2135 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2136 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2137 }
metin.ozkan@analog.com 0:788f63dcf0a0 2138
metin.ozkan@analog.com 0:788f63dcf0a0 2139 *usbs = (usbs_t)reg_cnfg_chg_g.bits.usbs;
metin.ozkan@analog.com 0:788f63dcf0a0 2140
metin.ozkan@analog.com 0:788f63dcf0a0 2141 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2142 }
metin.ozkan@analog.com 0:788f63dcf0a0 2143
metin.ozkan@analog.com 0:788f63dcf0a0 2144 int MAX77654::SetFastChargeVoltageJEITA(chg_cv_t chg_cv_jeita)
metin.ozkan@analog.com 0:788f63dcf0a0 2145 {
metin.ozkan@analog.com 0:788f63dcf0a0 2146 reg_cnfg_chg_h_t reg_cnfg_chg_h;
metin.ozkan@analog.com 0:788f63dcf0a0 2147
metin.ozkan@analog.com 0:788f63dcf0a0 2148 SET_BIT_FIELD(CNFG_CHG_H, reg_cnfg_chg_h, reg_cnfg_chg_h.bits.chg_cv_jeita, chg_cv_jeita);
metin.ozkan@analog.com 0:788f63dcf0a0 2149
metin.ozkan@analog.com 0:788f63dcf0a0 2150 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2151 }
metin.ozkan@analog.com 0:788f63dcf0a0 2152
metin.ozkan@analog.com 0:788f63dcf0a0 2153 int MAX77654::GetFastChargeVoltageJEITA(chg_cv_t *chg_cv_jeita)
metin.ozkan@analog.com 0:788f63dcf0a0 2154 {
metin.ozkan@analog.com 0:788f63dcf0a0 2155 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2156 reg_cnfg_chg_h_t reg_cnfg_chg_h;
metin.ozkan@analog.com 0:788f63dcf0a0 2157
metin.ozkan@analog.com 0:788f63dcf0a0 2158 ret = read_register(CNFG_CHG_H, (uint8_t *)&(reg_cnfg_chg_h));
metin.ozkan@analog.com 0:788f63dcf0a0 2159 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2160 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2161 }
metin.ozkan@analog.com 0:788f63dcf0a0 2162
metin.ozkan@analog.com 0:788f63dcf0a0 2163 *chg_cv_jeita = (chg_cv_t)reg_cnfg_chg_h.bits.chg_cv_jeita;
metin.ozkan@analog.com 0:788f63dcf0a0 2164
metin.ozkan@analog.com 0:788f63dcf0a0 2165 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2166 }
metin.ozkan@analog.com 0:788f63dcf0a0 2167
metin.ozkan@analog.com 0:788f63dcf0a0 2168 int MAX77654::SetDischargeCurrentFullScale(imon_dischg_scale_t imon_dischg_scale)
metin.ozkan@analog.com 0:788f63dcf0a0 2169 {
metin.ozkan@analog.com 0:788f63dcf0a0 2170 reg_cnfg_chg_i_t reg_cnfg_chg_i;
metin.ozkan@analog.com 0:788f63dcf0a0 2171
metin.ozkan@analog.com 0:788f63dcf0a0 2172 SET_BIT_FIELD(CNFG_CHG_I, reg_cnfg_chg_i, reg_cnfg_chg_i.bits.imon_dischg_scale, imon_dischg_scale);
metin.ozkan@analog.com 0:788f63dcf0a0 2173
metin.ozkan@analog.com 0:788f63dcf0a0 2174 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2175 }
metin.ozkan@analog.com 0:788f63dcf0a0 2176
metin.ozkan@analog.com 0:788f63dcf0a0 2177 int MAX77654::GetDischargeCurrentFullScale(imon_dischg_scale_t *imon_dischg_scale)
metin.ozkan@analog.com 0:788f63dcf0a0 2178 {
metin.ozkan@analog.com 0:788f63dcf0a0 2179 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2180 reg_cnfg_chg_i_t reg_cnfg_chg_i;
metin.ozkan@analog.com 0:788f63dcf0a0 2181
metin.ozkan@analog.com 0:788f63dcf0a0 2182 ret = read_register(CNFG_CHG_I, (uint8_t *)&(reg_cnfg_chg_i));
metin.ozkan@analog.com 0:788f63dcf0a0 2183 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2184 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2185 }
metin.ozkan@analog.com 0:788f63dcf0a0 2186
metin.ozkan@analog.com 0:788f63dcf0a0 2187 *imon_dischg_scale = (imon_dischg_scale_t)reg_cnfg_chg_i.bits.imon_dischg_scale;
metin.ozkan@analog.com 0:788f63dcf0a0 2188
metin.ozkan@analog.com 0:788f63dcf0a0 2189 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2190 }
metin.ozkan@analog.com 0:788f63dcf0a0 2191
metin.ozkan@analog.com 0:788f63dcf0a0 2192 int MAX77654::SetAMUX(mux_sel_t mux_sel)
metin.ozkan@analog.com 0:788f63dcf0a0 2193 {
metin.ozkan@analog.com 0:788f63dcf0a0 2194 reg_cnfg_chg_i_t reg_cnfg_chg_i;
metin.ozkan@analog.com 0:788f63dcf0a0 2195
metin.ozkan@analog.com 0:788f63dcf0a0 2196 SET_BIT_FIELD(CNFG_CHG_I, reg_cnfg_chg_i, reg_cnfg_chg_i.bits.mux_sel, mux_sel);
metin.ozkan@analog.com 0:788f63dcf0a0 2197
metin.ozkan@analog.com 0:788f63dcf0a0 2198 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2199 }
metin.ozkan@analog.com 0:788f63dcf0a0 2200
metin.ozkan@analog.com 0:788f63dcf0a0 2201 int MAX77654::GetAMUX(mux_sel_t *mux_sel)
metin.ozkan@analog.com 0:788f63dcf0a0 2202 {
metin.ozkan@analog.com 0:788f63dcf0a0 2203 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2204 reg_cnfg_chg_i_t reg_cnfg_chg_i;
metin.ozkan@analog.com 0:788f63dcf0a0 2205
metin.ozkan@analog.com 0:788f63dcf0a0 2206 ret = read_register(CNFG_CHG_I, (uint8_t *)&(reg_cnfg_chg_i));
metin.ozkan@analog.com 0:788f63dcf0a0 2207 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2208 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2209 }
metin.ozkan@analog.com 0:788f63dcf0a0 2210
metin.ozkan@analog.com 0:788f63dcf0a0 2211 *mux_sel = (mux_sel_t)reg_cnfg_chg_i.bits.mux_sel;
metin.ozkan@analog.com 0:788f63dcf0a0 2212
metin.ozkan@analog.com 0:788f63dcf0a0 2213 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2214 }
metin.ozkan@analog.com 0:788f63dcf0a0 2215
metin.ozkan@analog.com 0:788f63dcf0a0 2216 int MAX77654::SetSBBTargetOutVoltage(uint8_t channel, tv_sbb_t tv_sbb)
metin.ozkan@analog.com 0:788f63dcf0a0 2217 {
metin.ozkan@analog.com 0:788f63dcf0a0 2218 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2219 reg_cnfg_sbb0_a_t reg_cnfg_sbb0_a;
metin.ozkan@analog.com 0:788f63dcf0a0 2220 SET_BIT_FIELD(CNFG_SBB0_A, reg_cnfg_sbb0_a, reg_cnfg_sbb0_a.bits.tv_sbb0, tv_sbb);
metin.ozkan@analog.com 0:788f63dcf0a0 2221 }
metin.ozkan@analog.com 0:788f63dcf0a0 2222 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2223 reg_cnfg_sbb1_a_t reg_cnfg_sbb1_a;
metin.ozkan@analog.com 0:788f63dcf0a0 2224 SET_BIT_FIELD(CNFG_SBB1_A, reg_cnfg_sbb1_a, reg_cnfg_sbb1_a.bits.tv_sbb1, tv_sbb);
metin.ozkan@analog.com 0:788f63dcf0a0 2225 }
metin.ozkan@analog.com 0:788f63dcf0a0 2226 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 2227 reg_cnfg_sbb2_a_t reg_cnfg_sbb2_a;
metin.ozkan@analog.com 0:788f63dcf0a0 2228 SET_BIT_FIELD(CNFG_SBB2_A, reg_cnfg_sbb2_a, reg_cnfg_sbb2_a.bits.tv_sbb2, tv_sbb);
metin.ozkan@analog.com 0:788f63dcf0a0 2229 }
metin.ozkan@analog.com 0:788f63dcf0a0 2230 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2231 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2232 }
metin.ozkan@analog.com 0:788f63dcf0a0 2233
metin.ozkan@analog.com 0:788f63dcf0a0 2234 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2235 }
metin.ozkan@analog.com 0:788f63dcf0a0 2236
metin.ozkan@analog.com 0:788f63dcf0a0 2237 int MAX77654::GetSBBTargetOutVoltage(uint8_t channel, tv_sbb_t *tv_sbb)
metin.ozkan@analog.com 0:788f63dcf0a0 2238 {
metin.ozkan@analog.com 0:788f63dcf0a0 2239 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2240
metin.ozkan@analog.com 0:788f63dcf0a0 2241 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2242 reg_cnfg_sbb0_a_t reg_cnfg_sbb0_a;
metin.ozkan@analog.com 0:788f63dcf0a0 2243 ret = read_register(CNFG_SBB0_A, (uint8_t *)&(reg_cnfg_sbb0_a));
metin.ozkan@analog.com 0:788f63dcf0a0 2244 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2245 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2246 }
metin.ozkan@analog.com 0:788f63dcf0a0 2247 *tv_sbb = (tv_sbb_t)reg_cnfg_sbb0_a.bits.tv_sbb0;
metin.ozkan@analog.com 0:788f63dcf0a0 2248 }
metin.ozkan@analog.com 0:788f63dcf0a0 2249 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2250 reg_cnfg_sbb1_a_t reg_cnfg_sbb1_a;
metin.ozkan@analog.com 0:788f63dcf0a0 2251 ret = read_register(CNFG_SBB1_A, (uint8_t *)&(reg_cnfg_sbb1_a));
metin.ozkan@analog.com 0:788f63dcf0a0 2252 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2253 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2254 }
metin.ozkan@analog.com 0:788f63dcf0a0 2255 *tv_sbb = (tv_sbb_t)reg_cnfg_sbb1_a.bits.tv_sbb1;
metin.ozkan@analog.com 0:788f63dcf0a0 2256 }
metin.ozkan@analog.com 0:788f63dcf0a0 2257 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 2258 reg_cnfg_sbb2_a_t reg_cnfg_sbb2_a;
metin.ozkan@analog.com 0:788f63dcf0a0 2259 ret = read_register(CNFG_SBB2_A, (uint8_t *)&(reg_cnfg_sbb2_a));
metin.ozkan@analog.com 0:788f63dcf0a0 2260 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2261 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2262 }
metin.ozkan@analog.com 0:788f63dcf0a0 2263 *tv_sbb = (tv_sbb_t)reg_cnfg_sbb2_a.bits.tv_sbb2;
metin.ozkan@analog.com 0:788f63dcf0a0 2264 }
metin.ozkan@analog.com 0:788f63dcf0a0 2265 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2266 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2267 }
metin.ozkan@analog.com 0:788f63dcf0a0 2268
metin.ozkan@analog.com 0:788f63dcf0a0 2269 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2270 }
metin.ozkan@analog.com 0:788f63dcf0a0 2271
metin.ozkan@analog.com 0:788f63dcf0a0 2272 int MAX77654::SetSIMOOperationMode(uint8_t channel, op_mode_t op_mode)
metin.ozkan@analog.com 0:788f63dcf0a0 2273 {
metin.ozkan@analog.com 0:788f63dcf0a0 2274 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2275 reg_cnfg_sbb0_b_t reg_cnfg_sbb0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2276 SET_BIT_FIELD(CNFG_SBB0_B, reg_cnfg_sbb0_b, reg_cnfg_sbb0_b.bits.op_mode, op_mode);
metin.ozkan@analog.com 0:788f63dcf0a0 2277 }
metin.ozkan@analog.com 0:788f63dcf0a0 2278 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2279 reg_cnfg_sbb1_b_t reg_cnfg_sbb1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2280 SET_BIT_FIELD(CNFG_SBB1_B, reg_cnfg_sbb1_b, reg_cnfg_sbb1_b.bits.op_mode, op_mode);
metin.ozkan@analog.com 0:788f63dcf0a0 2281 }
metin.ozkan@analog.com 0:788f63dcf0a0 2282 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 2283 reg_cnfg_sbb2_b_t reg_cnfg_sbb2_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2284 SET_BIT_FIELD(CNFG_SBB2_B, reg_cnfg_sbb2_b, reg_cnfg_sbb2_b.bits.op_mode, op_mode);
metin.ozkan@analog.com 0:788f63dcf0a0 2285 }
metin.ozkan@analog.com 0:788f63dcf0a0 2286 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2287 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2288 }
metin.ozkan@analog.com 0:788f63dcf0a0 2289
metin.ozkan@analog.com 0:788f63dcf0a0 2290 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2291 }
metin.ozkan@analog.com 0:788f63dcf0a0 2292
metin.ozkan@analog.com 0:788f63dcf0a0 2293 int MAX77654::GetSIMOOperationMode(uint8_t channel, op_mode_t *op_mode)
metin.ozkan@analog.com 0:788f63dcf0a0 2294 {
metin.ozkan@analog.com 0:788f63dcf0a0 2295 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2296
metin.ozkan@analog.com 0:788f63dcf0a0 2297 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2298 reg_cnfg_sbb0_b_t reg_cnfg_sbb0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2299 ret = read_register(CNFG_SBB0_B, (uint8_t *)&(reg_cnfg_sbb0_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2300 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2301 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2302 }
metin.ozkan@analog.com 0:788f63dcf0a0 2303 *op_mode = (op_mode_t)reg_cnfg_sbb0_b.bits.op_mode;
metin.ozkan@analog.com 0:788f63dcf0a0 2304 }
metin.ozkan@analog.com 0:788f63dcf0a0 2305 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2306 reg_cnfg_sbb1_b_t reg_cnfg_sbb1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2307 ret = read_register(CNFG_SBB1_B, (uint8_t *)&(reg_cnfg_sbb1_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2308 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2309 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2310 }
metin.ozkan@analog.com 0:788f63dcf0a0 2311 *op_mode = (op_mode_t)reg_cnfg_sbb1_b.bits.op_mode;
metin.ozkan@analog.com 0:788f63dcf0a0 2312 }
metin.ozkan@analog.com 0:788f63dcf0a0 2313 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 2314 reg_cnfg_sbb2_b_t reg_cnfg_sbb2_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2315 ret = read_register(CNFG_SBB2_B, (uint8_t *)&(reg_cnfg_sbb2_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2316 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2317 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2318 }
metin.ozkan@analog.com 0:788f63dcf0a0 2319 *op_mode = (op_mode_t)reg_cnfg_sbb2_b.bits.op_mode;
metin.ozkan@analog.com 0:788f63dcf0a0 2320 }
metin.ozkan@analog.com 0:788f63dcf0a0 2321 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2322 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2323 }
metin.ozkan@analog.com 0:788f63dcf0a0 2324
metin.ozkan@analog.com 0:788f63dcf0a0 2325 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2326 }
metin.ozkan@analog.com 0:788f63dcf0a0 2327
metin.ozkan@analog.com 0:788f63dcf0a0 2328 int MAX77654::SetSBBPeakCurrentLimit(uint8_t channel, ip_sbb_t ip_sbb)
metin.ozkan@analog.com 0:788f63dcf0a0 2329 {
metin.ozkan@analog.com 0:788f63dcf0a0 2330 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2331 reg_cnfg_sbb0_b_t reg_cnfg_sbb0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2332 SET_BIT_FIELD(CNFG_SBB0_B, reg_cnfg_sbb0_b, reg_cnfg_sbb0_b.bits.ip_sbb0, ip_sbb);
metin.ozkan@analog.com 0:788f63dcf0a0 2333 }
metin.ozkan@analog.com 0:788f63dcf0a0 2334 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2335 reg_cnfg_sbb1_b_t reg_cnfg_sbb1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2336 SET_BIT_FIELD(CNFG_SBB1_B, reg_cnfg_sbb1_b, reg_cnfg_sbb1_b.bits.ip_sbb1, ip_sbb);
metin.ozkan@analog.com 0:788f63dcf0a0 2337 }
metin.ozkan@analog.com 0:788f63dcf0a0 2338 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 2339 reg_cnfg_sbb2_b_t reg_cnfg_sbb2_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2340 SET_BIT_FIELD(CNFG_SBB2_B, reg_cnfg_sbb2_b, reg_cnfg_sbb2_b.bits.ip_sbb2, ip_sbb);
metin.ozkan@analog.com 0:788f63dcf0a0 2341 }
metin.ozkan@analog.com 0:788f63dcf0a0 2342 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2343 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2344 }
metin.ozkan@analog.com 0:788f63dcf0a0 2345
metin.ozkan@analog.com 0:788f63dcf0a0 2346 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2347 }
metin.ozkan@analog.com 0:788f63dcf0a0 2348
metin.ozkan@analog.com 0:788f63dcf0a0 2349 int MAX77654::GetSBBPeakCurrentLimit(uint8_t channel, ip_sbb_t *ip_sbb)
metin.ozkan@analog.com 0:788f63dcf0a0 2350 {
metin.ozkan@analog.com 0:788f63dcf0a0 2351 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2352
metin.ozkan@analog.com 0:788f63dcf0a0 2353 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2354 reg_cnfg_sbb0_b_t reg_cnfg_sbb0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2355 ret = read_register(CNFG_SBB0_B, (uint8_t *)&(reg_cnfg_sbb0_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2356 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2357 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2358 }
metin.ozkan@analog.com 0:788f63dcf0a0 2359 *ip_sbb = (ip_sbb_t)reg_cnfg_sbb0_b.bits.ip_sbb0;
metin.ozkan@analog.com 0:788f63dcf0a0 2360 }
metin.ozkan@analog.com 0:788f63dcf0a0 2361 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2362 reg_cnfg_sbb1_b_t reg_cnfg_sbb1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2363 ret = read_register(CNFG_SBB1_B, (uint8_t *)&(reg_cnfg_sbb1_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2364 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2365 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2366 }
metin.ozkan@analog.com 0:788f63dcf0a0 2367 *ip_sbb = (ip_sbb_t)reg_cnfg_sbb1_b.bits.ip_sbb1;
metin.ozkan@analog.com 0:788f63dcf0a0 2368 }
metin.ozkan@analog.com 0:788f63dcf0a0 2369 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 2370 reg_cnfg_sbb2_b_t reg_cnfg_sbb2_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2371 ret = read_register(CNFG_SBB2_B, (uint8_t *)&(reg_cnfg_sbb2_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2372 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2373 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2374 }
metin.ozkan@analog.com 0:788f63dcf0a0 2375 *ip_sbb = (ip_sbb_t)reg_cnfg_sbb2_b.bits.ip_sbb2;
metin.ozkan@analog.com 0:788f63dcf0a0 2376 }
metin.ozkan@analog.com 0:788f63dcf0a0 2377 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2378 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2379 }
metin.ozkan@analog.com 0:788f63dcf0a0 2380
metin.ozkan@analog.com 0:788f63dcf0a0 2381 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2382 }
metin.ozkan@analog.com 0:788f63dcf0a0 2383
metin.ozkan@analog.com 0:788f63dcf0a0 2384 int MAX77654::SetSBBActiveDischargeEnable(uint8_t channel, ade_sbb_t ade_sbb)
metin.ozkan@analog.com 0:788f63dcf0a0 2385 {
metin.ozkan@analog.com 0:788f63dcf0a0 2386 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2387 reg_cnfg_sbb0_b_t reg_cnfg_sbb0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2388 SET_BIT_FIELD(CNFG_SBB0_B, reg_cnfg_sbb0_b, reg_cnfg_sbb0_b.bits.ade_sbb0, ade_sbb);
metin.ozkan@analog.com 0:788f63dcf0a0 2389 }
metin.ozkan@analog.com 0:788f63dcf0a0 2390 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2391 reg_cnfg_sbb1_b_t reg_cnfg_sbb1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2392 SET_BIT_FIELD(CNFG_SBB1_B, reg_cnfg_sbb1_b, reg_cnfg_sbb1_b.bits.ade_sbb1, ade_sbb);
metin.ozkan@analog.com 0:788f63dcf0a0 2393 }
metin.ozkan@analog.com 0:788f63dcf0a0 2394 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 2395 reg_cnfg_sbb2_b_t reg_cnfg_sbb2_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2396 SET_BIT_FIELD(CNFG_SBB2_B, reg_cnfg_sbb2_b, reg_cnfg_sbb2_b.bits.ade_sbb2, ade_sbb);
metin.ozkan@analog.com 0:788f63dcf0a0 2397 }
metin.ozkan@analog.com 0:788f63dcf0a0 2398 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2399 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2400 }
metin.ozkan@analog.com 0:788f63dcf0a0 2401
metin.ozkan@analog.com 0:788f63dcf0a0 2402 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2403 }
metin.ozkan@analog.com 0:788f63dcf0a0 2404
metin.ozkan@analog.com 0:788f63dcf0a0 2405 int MAX77654::GetSBBActiveDischargeEnable(uint8_t channel, ade_sbb_t *ade_sbb)
metin.ozkan@analog.com 0:788f63dcf0a0 2406 {
metin.ozkan@analog.com 0:788f63dcf0a0 2407 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2408
metin.ozkan@analog.com 0:788f63dcf0a0 2409 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2410 reg_cnfg_sbb0_b_t reg_cnfg_sbb0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2411 ret = read_register(CNFG_SBB0_B, (uint8_t *)&(reg_cnfg_sbb0_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2412 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2413 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2414 }
metin.ozkan@analog.com 0:788f63dcf0a0 2415 *ade_sbb = (ade_sbb_t)reg_cnfg_sbb0_b.bits.ade_sbb0;
metin.ozkan@analog.com 0:788f63dcf0a0 2416 }
metin.ozkan@analog.com 0:788f63dcf0a0 2417 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2418 reg_cnfg_sbb1_b_t reg_cnfg_sbb1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2419 ret = read_register(CNFG_SBB1_B, (uint8_t *)&(reg_cnfg_sbb1_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2420 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2421 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2422 }
metin.ozkan@analog.com 0:788f63dcf0a0 2423 *ade_sbb = (ade_sbb_t)reg_cnfg_sbb1_b.bits.ade_sbb1;
metin.ozkan@analog.com 0:788f63dcf0a0 2424 }
metin.ozkan@analog.com 0:788f63dcf0a0 2425 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 2426 reg_cnfg_sbb2_b_t reg_cnfg_sbb2_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2427 ret = read_register(CNFG_SBB2_B, (uint8_t *)&(reg_cnfg_sbb2_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2428 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2429 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2430 }
metin.ozkan@analog.com 0:788f63dcf0a0 2431 *ade_sbb = (ade_sbb_t)reg_cnfg_sbb2_b.bits.ade_sbb2;
metin.ozkan@analog.com 0:788f63dcf0a0 2432 }
metin.ozkan@analog.com 0:788f63dcf0a0 2433 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2434 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2435 }
metin.ozkan@analog.com 0:788f63dcf0a0 2436
metin.ozkan@analog.com 0:788f63dcf0a0 2437 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2438 }
metin.ozkan@analog.com 0:788f63dcf0a0 2439
metin.ozkan@analog.com 0:788f63dcf0a0 2440 int MAX77654::SetSBBEnableControl(uint8_t channel, en_sbb_t en_sbb)
metin.ozkan@analog.com 0:788f63dcf0a0 2441 {
metin.ozkan@analog.com 0:788f63dcf0a0 2442 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2443 reg_cnfg_sbb0_b_t reg_cnfg_sbb0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2444 SET_BIT_FIELD(CNFG_SBB0_B, reg_cnfg_sbb0_b, reg_cnfg_sbb0_b.bits.en_sbb0, en_sbb);
metin.ozkan@analog.com 0:788f63dcf0a0 2445 }
metin.ozkan@analog.com 0:788f63dcf0a0 2446 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2447 reg_cnfg_sbb1_b_t reg_cnfg_sbb1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2448 SET_BIT_FIELD(CNFG_SBB1_B, reg_cnfg_sbb1_b, reg_cnfg_sbb1_b.bits.en_sbb1, en_sbb);
metin.ozkan@analog.com 0:788f63dcf0a0 2449 }
metin.ozkan@analog.com 0:788f63dcf0a0 2450 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 2451 reg_cnfg_sbb2_b_t reg_cnfg_sbb2_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2452 SET_BIT_FIELD(CNFG_SBB2_B, reg_cnfg_sbb2_b, reg_cnfg_sbb2_b.bits.en_sbb2, en_sbb);
metin.ozkan@analog.com 0:788f63dcf0a0 2453 }
metin.ozkan@analog.com 0:788f63dcf0a0 2454 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2455 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2456 }
metin.ozkan@analog.com 0:788f63dcf0a0 2457
metin.ozkan@analog.com 0:788f63dcf0a0 2458 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2459 }
metin.ozkan@analog.com 0:788f63dcf0a0 2460
metin.ozkan@analog.com 0:788f63dcf0a0 2461 int MAX77654::GetSBBEnableControl(uint8_t channel, en_sbb_t *en_sbb)
metin.ozkan@analog.com 0:788f63dcf0a0 2462 {
metin.ozkan@analog.com 0:788f63dcf0a0 2463 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2464
metin.ozkan@analog.com 0:788f63dcf0a0 2465 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2466 reg_cnfg_sbb0_b_t reg_cnfg_sbb0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2467 ret = read_register(CNFG_SBB0_B, (uint8_t *)&(reg_cnfg_sbb0_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2468 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2469 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2470 }
metin.ozkan@analog.com 0:788f63dcf0a0 2471 *en_sbb = (en_sbb_t)reg_cnfg_sbb0_b.bits.en_sbb0;
metin.ozkan@analog.com 0:788f63dcf0a0 2472 }
metin.ozkan@analog.com 0:788f63dcf0a0 2473 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2474 reg_cnfg_sbb1_b_t reg_cnfg_sbb1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2475 ret = read_register(CNFG_SBB1_B, (uint8_t *)&(reg_cnfg_sbb1_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2476 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2477 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2478 }
metin.ozkan@analog.com 0:788f63dcf0a0 2479 *en_sbb = (en_sbb_t)reg_cnfg_sbb1_b.bits.en_sbb1;
metin.ozkan@analog.com 0:788f63dcf0a0 2480 }
metin.ozkan@analog.com 0:788f63dcf0a0 2481 else if (channel == 2) {
metin.ozkan@analog.com 0:788f63dcf0a0 2482 reg_cnfg_sbb2_b_t reg_cnfg_sbb2_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2483 ret = read_register(CNFG_SBB2_B, (uint8_t *)&(reg_cnfg_sbb2_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2484 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2485 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2486 }
metin.ozkan@analog.com 0:788f63dcf0a0 2487 *en_sbb = (en_sbb_t)reg_cnfg_sbb2_b.bits.en_sbb2;
metin.ozkan@analog.com 0:788f63dcf0a0 2488 }
metin.ozkan@analog.com 0:788f63dcf0a0 2489 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2490 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2491 }
metin.ozkan@analog.com 0:788f63dcf0a0 2492
metin.ozkan@analog.com 0:788f63dcf0a0 2493 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2494 }
metin.ozkan@analog.com 0:788f63dcf0a0 2495
metin.ozkan@analog.com 0:788f63dcf0a0 2496 int MAX77654::SetCHGINInputCurrentLimit(ichgin_lim_def_t ichgin_lim_def)
metin.ozkan@analog.com 0:788f63dcf0a0 2497 {
metin.ozkan@analog.com 0:788f63dcf0a0 2498 reg_cnfg_sbb_top_t reg_cnfg_sbb_top;
metin.ozkan@analog.com 0:788f63dcf0a0 2499
metin.ozkan@analog.com 0:788f63dcf0a0 2500 SET_BIT_FIELD(CNFG_SBB_TOP, reg_cnfg_sbb_top, reg_cnfg_sbb_top.bits.ichgin_lim_def, ichgin_lim_def);
metin.ozkan@analog.com 0:788f63dcf0a0 2501
metin.ozkan@analog.com 0:788f63dcf0a0 2502 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2503 }
metin.ozkan@analog.com 0:788f63dcf0a0 2504
metin.ozkan@analog.com 0:788f63dcf0a0 2505 int MAX77654::GetCHGINInputCurrentLimit(ichgin_lim_def_t *ichgin_lim_def)
metin.ozkan@analog.com 0:788f63dcf0a0 2506 {
metin.ozkan@analog.com 0:788f63dcf0a0 2507 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2508 reg_cnfg_sbb_top_t reg_cnfg_sbb_top;
metin.ozkan@analog.com 0:788f63dcf0a0 2509
metin.ozkan@analog.com 0:788f63dcf0a0 2510 ret = read_register(CNFG_SBB_TOP, (uint8_t *)&(reg_cnfg_sbb_top));
metin.ozkan@analog.com 0:788f63dcf0a0 2511 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2512 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2513 }
metin.ozkan@analog.com 0:788f63dcf0a0 2514
metin.ozkan@analog.com 0:788f63dcf0a0 2515 *ichgin_lim_def = (ichgin_lim_def_t)reg_cnfg_sbb_top.bits.ichgin_lim_def;
metin.ozkan@analog.com 0:788f63dcf0a0 2516
metin.ozkan@analog.com 0:788f63dcf0a0 2517 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2518 }
metin.ozkan@analog.com 0:788f63dcf0a0 2519
metin.ozkan@analog.com 0:788f63dcf0a0 2520 int MAX77654::SetSBBDriveStrength(drv_sbb_t drv_sbb)
metin.ozkan@analog.com 0:788f63dcf0a0 2521 {
metin.ozkan@analog.com 0:788f63dcf0a0 2522 reg_cnfg_sbb_top_t reg_cnfg_sbb_top;
metin.ozkan@analog.com 0:788f63dcf0a0 2523
metin.ozkan@analog.com 0:788f63dcf0a0 2524 SET_BIT_FIELD(CNFG_SBB_TOP, reg_cnfg_sbb_top, reg_cnfg_sbb_top.bits.drv_sbb, drv_sbb);
metin.ozkan@analog.com 0:788f63dcf0a0 2525
metin.ozkan@analog.com 0:788f63dcf0a0 2526 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2527 }
metin.ozkan@analog.com 0:788f63dcf0a0 2528
metin.ozkan@analog.com 0:788f63dcf0a0 2529 int MAX77654::GetSBBDriveStrength(drv_sbb_t *drv_sbb)
metin.ozkan@analog.com 0:788f63dcf0a0 2530 {
metin.ozkan@analog.com 0:788f63dcf0a0 2531 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2532 reg_cnfg_sbb_top_t reg_cnfg_sbb_top;
metin.ozkan@analog.com 0:788f63dcf0a0 2533
metin.ozkan@analog.com 0:788f63dcf0a0 2534 ret = read_register(CNFG_SBB_TOP, (uint8_t *)&(reg_cnfg_sbb_top));
metin.ozkan@analog.com 0:788f63dcf0a0 2535 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2536 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2537 }
metin.ozkan@analog.com 0:788f63dcf0a0 2538
metin.ozkan@analog.com 0:788f63dcf0a0 2539 *drv_sbb = (drv_sbb_t)reg_cnfg_sbb_top.bits.drv_sbb;
metin.ozkan@analog.com 0:788f63dcf0a0 2540
metin.ozkan@analog.com 0:788f63dcf0a0 2541 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2542 }
metin.ozkan@analog.com 0:788f63dcf0a0 2543
metin.ozkan@analog.com 0:788f63dcf0a0 2544 int MAX77654::SetLDOTargetOutVoltage(uint8_t channel, tv_ldo_t tv_ldo)
metin.ozkan@analog.com 0:788f63dcf0a0 2545 {
metin.ozkan@analog.com 0:788f63dcf0a0 2546 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2547 reg_cnfg_ldo0_a_t reg_cnfg_ldo0_a;
metin.ozkan@analog.com 0:788f63dcf0a0 2548 SET_BIT_FIELD(CNFG_LDO0_A, reg_cnfg_ldo0_a, reg_cnfg_ldo0_a.bits.tv_ldo0, tv_ldo);
metin.ozkan@analog.com 0:788f63dcf0a0 2549 }
metin.ozkan@analog.com 0:788f63dcf0a0 2550 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2551 reg_cnfg_ldo1_a_t reg_cnfg_ldo1_a;
metin.ozkan@analog.com 0:788f63dcf0a0 2552 SET_BIT_FIELD(CNFG_LDO1_A, reg_cnfg_ldo1_a, reg_cnfg_ldo1_a.bits.tv_ldo1, tv_ldo);
metin.ozkan@analog.com 0:788f63dcf0a0 2553 }
metin.ozkan@analog.com 0:788f63dcf0a0 2554 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2555 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2556 }
metin.ozkan@analog.com 0:788f63dcf0a0 2557
metin.ozkan@analog.com 0:788f63dcf0a0 2558 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2559 }
metin.ozkan@analog.com 0:788f63dcf0a0 2560
metin.ozkan@analog.com 0:788f63dcf0a0 2561 int MAX77654::GetLDOTargetOutVoltage(uint8_t channel, tv_ldo_t *tv_ldo)
metin.ozkan@analog.com 0:788f63dcf0a0 2562 {
metin.ozkan@analog.com 0:788f63dcf0a0 2563 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2564
metin.ozkan@analog.com 0:788f63dcf0a0 2565 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2566 reg_cnfg_ldo0_a_t reg_cnfg_ldo0_a;
metin.ozkan@analog.com 0:788f63dcf0a0 2567 ret = read_register(CNFG_LDO0_A, (uint8_t *)&(reg_cnfg_ldo0_a));
metin.ozkan@analog.com 0:788f63dcf0a0 2568 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2569 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2570 }
metin.ozkan@analog.com 0:788f63dcf0a0 2571 *tv_ldo = (tv_ldo_t)reg_cnfg_ldo0_a.bits.tv_ldo0;
metin.ozkan@analog.com 0:788f63dcf0a0 2572 }
metin.ozkan@analog.com 0:788f63dcf0a0 2573 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2574 reg_cnfg_ldo1_a_t reg_cnfg_ldo1_a;
metin.ozkan@analog.com 0:788f63dcf0a0 2575 ret = read_register(CNFG_LDO1_A, (uint8_t *)&(reg_cnfg_ldo1_a));
metin.ozkan@analog.com 0:788f63dcf0a0 2576 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2577 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2578 }
metin.ozkan@analog.com 0:788f63dcf0a0 2579 *tv_ldo = (tv_ldo_t)reg_cnfg_ldo1_a.bits.tv_ldo1;
metin.ozkan@analog.com 0:788f63dcf0a0 2580 }
metin.ozkan@analog.com 0:788f63dcf0a0 2581 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2582 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2583 }
metin.ozkan@analog.com 0:788f63dcf0a0 2584
metin.ozkan@analog.com 0:788f63dcf0a0 2585 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2586 }
metin.ozkan@analog.com 0:788f63dcf0a0 2587
metin.ozkan@analog.com 0:788f63dcf0a0 2588 int MAX77654::SetLDOMode(uint8_t channel, ldo_md_t ldo_md)
metin.ozkan@analog.com 0:788f63dcf0a0 2589 {
metin.ozkan@analog.com 0:788f63dcf0a0 2590 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2591 reg_cnfg_ldo0_b_t reg_cnfg_ldo0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2592 SET_BIT_FIELD(CNFG_LDO0_B, reg_cnfg_ldo0_b, reg_cnfg_ldo0_b.bits.ldo0_md, ldo_md);
metin.ozkan@analog.com 0:788f63dcf0a0 2593 }
metin.ozkan@analog.com 0:788f63dcf0a0 2594 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2595 reg_cnfg_ldo1_b_t reg_cnfg_ldo1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2596 SET_BIT_FIELD(CNFG_LDO1_B, reg_cnfg_ldo1_b, reg_cnfg_ldo1_b.bits.ldo1_md, ldo_md);
metin.ozkan@analog.com 0:788f63dcf0a0 2597 }
metin.ozkan@analog.com 0:788f63dcf0a0 2598 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2599 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2600 }
metin.ozkan@analog.com 0:788f63dcf0a0 2601
metin.ozkan@analog.com 0:788f63dcf0a0 2602 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2603 }
metin.ozkan@analog.com 0:788f63dcf0a0 2604
metin.ozkan@analog.com 0:788f63dcf0a0 2605 int MAX77654::GetLDOMode(uint8_t channel, ldo_md_t *ldo_md)
metin.ozkan@analog.com 0:788f63dcf0a0 2606 {
metin.ozkan@analog.com 0:788f63dcf0a0 2607 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2608
metin.ozkan@analog.com 0:788f63dcf0a0 2609 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2610 reg_cnfg_ldo0_b_t reg_cnfg_ldo0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2611 ret = read_register(CNFG_LDO0_B, (uint8_t *)&(reg_cnfg_ldo0_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2612 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2613 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2614 }
metin.ozkan@analog.com 0:788f63dcf0a0 2615 *ldo_md = (ldo_md_t)reg_cnfg_ldo0_b.bits.ldo0_md;
metin.ozkan@analog.com 0:788f63dcf0a0 2616 }
metin.ozkan@analog.com 0:788f63dcf0a0 2617 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2618 reg_cnfg_ldo1_b_t reg_cnfg_ldo1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2619 ret = read_register(CNFG_LDO1_B, (uint8_t *)&(reg_cnfg_ldo1_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2620 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2621 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2622 }
metin.ozkan@analog.com 0:788f63dcf0a0 2623 *ldo_md = (ldo_md_t)reg_cnfg_ldo1_b.bits.ldo1_md;
metin.ozkan@analog.com 0:788f63dcf0a0 2624 }
metin.ozkan@analog.com 0:788f63dcf0a0 2625 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2626 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2627 }
metin.ozkan@analog.com 0:788f63dcf0a0 2628
metin.ozkan@analog.com 0:788f63dcf0a0 2629 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2630 }
metin.ozkan@analog.com 0:788f63dcf0a0 2631
metin.ozkan@analog.com 0:788f63dcf0a0 2632 int MAX77654::SetLDOActiveDischargeEnable(uint8_t channel, ade_ldo_t ade_ldo)
metin.ozkan@analog.com 0:788f63dcf0a0 2633 {
metin.ozkan@analog.com 0:788f63dcf0a0 2634 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2635 reg_cnfg_ldo0_b_t reg_cnfg_ldo0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2636 SET_BIT_FIELD(CNFG_LDO0_B, reg_cnfg_ldo0_b, reg_cnfg_ldo0_b.bits.ade_ldo0, ade_ldo);
metin.ozkan@analog.com 0:788f63dcf0a0 2637 }
metin.ozkan@analog.com 0:788f63dcf0a0 2638 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2639 reg_cnfg_ldo1_b_t reg_cnfg_ldo1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2640 SET_BIT_FIELD(CNFG_LDO1_B, reg_cnfg_ldo1_b, reg_cnfg_ldo1_b.bits.ade_ldo1, ade_ldo);
metin.ozkan@analog.com 0:788f63dcf0a0 2641 }
metin.ozkan@analog.com 0:788f63dcf0a0 2642 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2643 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2644 }
metin.ozkan@analog.com 0:788f63dcf0a0 2645
metin.ozkan@analog.com 0:788f63dcf0a0 2646 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2647 }
metin.ozkan@analog.com 0:788f63dcf0a0 2648
metin.ozkan@analog.com 0:788f63dcf0a0 2649 int MAX77654::GetLDOActiveDischargeEnable(uint8_t channel, ade_ldo_t *ade_ldo)
metin.ozkan@analog.com 0:788f63dcf0a0 2650 {
metin.ozkan@analog.com 0:788f63dcf0a0 2651 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2652
metin.ozkan@analog.com 0:788f63dcf0a0 2653 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2654 reg_cnfg_ldo0_b_t reg_cnfg_ldo0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2655 ret = read_register(CNFG_LDO0_B, (uint8_t *)&(reg_cnfg_ldo0_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2656 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2657 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2658 }
metin.ozkan@analog.com 0:788f63dcf0a0 2659 *ade_ldo = (ade_ldo_t)reg_cnfg_ldo0_b.bits.ade_ldo0;
metin.ozkan@analog.com 0:788f63dcf0a0 2660 }
metin.ozkan@analog.com 0:788f63dcf0a0 2661 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2662 reg_cnfg_ldo1_b_t reg_cnfg_ldo1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2663 ret = read_register(CNFG_LDO1_B, (uint8_t *)&(reg_cnfg_ldo1_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2664 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2665 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2666 }
metin.ozkan@analog.com 0:788f63dcf0a0 2667 *ade_ldo = (ade_ldo_t)reg_cnfg_ldo1_b.bits.ade_ldo1;
metin.ozkan@analog.com 0:788f63dcf0a0 2668 }
metin.ozkan@analog.com 0:788f63dcf0a0 2669 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2670 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2671 }
metin.ozkan@analog.com 0:788f63dcf0a0 2672
metin.ozkan@analog.com 0:788f63dcf0a0 2673 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2674 }
metin.ozkan@analog.com 0:788f63dcf0a0 2675
metin.ozkan@analog.com 0:788f63dcf0a0 2676 int MAX77654::SetLDOEnableControl(uint8_t channel, en_ldo_t en_ldo)
metin.ozkan@analog.com 0:788f63dcf0a0 2677 {
metin.ozkan@analog.com 0:788f63dcf0a0 2678 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2679 reg_cnfg_ldo0_b_t reg_cnfg_ldo0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2680 SET_BIT_FIELD(CNFG_LDO0_B, reg_cnfg_ldo0_b, reg_cnfg_ldo0_b.bits.en_ldo0, en_ldo);
metin.ozkan@analog.com 0:788f63dcf0a0 2681 }
metin.ozkan@analog.com 0:788f63dcf0a0 2682 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2683 reg_cnfg_ldo1_b_t reg_cnfg_ldo1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2684 SET_BIT_FIELD(CNFG_LDO1_B, reg_cnfg_ldo1_b, reg_cnfg_ldo1_b.bits.en_ldo1, en_ldo);
metin.ozkan@analog.com 0:788f63dcf0a0 2685 }
metin.ozkan@analog.com 0:788f63dcf0a0 2686 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2687 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2688 }
metin.ozkan@analog.com 0:788f63dcf0a0 2689
metin.ozkan@analog.com 0:788f63dcf0a0 2690 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2691 }
metin.ozkan@analog.com 0:788f63dcf0a0 2692
metin.ozkan@analog.com 0:788f63dcf0a0 2693 int MAX77654::GetLDOEnableControl(uint8_t channel, en_ldo_t *en_ldo)
metin.ozkan@analog.com 0:788f63dcf0a0 2694 {
metin.ozkan@analog.com 0:788f63dcf0a0 2695 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2696
metin.ozkan@analog.com 0:788f63dcf0a0 2697 if (channel == 0) {
metin.ozkan@analog.com 0:788f63dcf0a0 2698 reg_cnfg_ldo0_b_t reg_cnfg_ldo0_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2699 ret = read_register(CNFG_LDO0_B, (uint8_t *)&(reg_cnfg_ldo0_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2700 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2701 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2702 }
metin.ozkan@analog.com 0:788f63dcf0a0 2703 *en_ldo = (en_ldo_t)reg_cnfg_ldo0_b.bits.en_ldo0;
metin.ozkan@analog.com 0:788f63dcf0a0 2704 }
metin.ozkan@analog.com 0:788f63dcf0a0 2705 else if (channel == 1) {
metin.ozkan@analog.com 0:788f63dcf0a0 2706 reg_cnfg_ldo1_b_t reg_cnfg_ldo1_b;
metin.ozkan@analog.com 0:788f63dcf0a0 2707 ret = read_register(CNFG_LDO1_B, (uint8_t *)&(reg_cnfg_ldo1_b));
metin.ozkan@analog.com 0:788f63dcf0a0 2708 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2709 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2710 }
metin.ozkan@analog.com 0:788f63dcf0a0 2711 *en_ldo = (en_ldo_t)reg_cnfg_ldo1_b.bits.en_ldo1;
metin.ozkan@analog.com 0:788f63dcf0a0 2712 }
metin.ozkan@analog.com 0:788f63dcf0a0 2713 else {
metin.ozkan@analog.com 0:788f63dcf0a0 2714 return MAX77654_INVALID_CHANNEL_NUMBER;
metin.ozkan@analog.com 0:788f63dcf0a0 2715 }
metin.ozkan@analog.com 0:788f63dcf0a0 2716
metin.ozkan@analog.com 0:788f63dcf0a0 2717 return MAX77654_NO_ERROR;
metin.ozkan@analog.com 0:788f63dcf0a0 2718 }
metin.ozkan@analog.com 0:788f63dcf0a0 2719
metin.ozkan@analog.com 0:788f63dcf0a0 2720 int MAX77654::IRQDisableAll()
metin.ozkan@analog.com 0:788f63dcf0a0 2721 {
metin.ozkan@analog.com 0:788f63dcf0a0 2722 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2723 uint8_t reg = 0;
metin.ozkan@analog.com 0:788f63dcf0a0 2724 uint8_t status = 0;
metin.ozkan@analog.com 0:788f63dcf0a0 2725
metin.ozkan@analog.com 0:788f63dcf0a0 2726 //Disable Masks in INTM_GLBL1
metin.ozkan@analog.com 0:788f63dcf0a0 2727 ret = write_register(INTM_GLBL1, &reg);
metin.ozkan@analog.com 0:788f63dcf0a0 2728 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2729 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2730 }
metin.ozkan@analog.com 0:788f63dcf0a0 2731 //Disable Masks in INTM_GLBL0
metin.ozkan@analog.com 0:788f63dcf0a0 2732 ret = write_register(INTM_GLBL0, &reg);
metin.ozkan@analog.com 0:788f63dcf0a0 2733 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2734 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2735 }
metin.ozkan@analog.com 0:788f63dcf0a0 2736 //Disable Masks in INT_M_CHG
metin.ozkan@analog.com 0:788f63dcf0a0 2737 ret = write_register(INT_M_CHG, &reg);
metin.ozkan@analog.com 0:788f63dcf0a0 2738 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2739 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2740 }
metin.ozkan@analog.com 0:788f63dcf0a0 2741
metin.ozkan@analog.com 0:788f63dcf0a0 2742 // Clear Interrupt Flags in INT_GLBL1
metin.ozkan@analog.com 0:788f63dcf0a0 2743 ret = read_register(INT_GLBL1, &status);
metin.ozkan@analog.com 0:788f63dcf0a0 2744 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2745 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2746 }
metin.ozkan@analog.com 0:788f63dcf0a0 2747 // Clear Interrupt Flags in INT_GLBL0
metin.ozkan@analog.com 0:788f63dcf0a0 2748 ret = read_register(INT_GLBL0, &status);
metin.ozkan@analog.com 0:788f63dcf0a0 2749 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2750 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2751 }
metin.ozkan@analog.com 0:788f63dcf0a0 2752 // Clear Interrupt Flags in INT_CHG
metin.ozkan@analog.com 0:788f63dcf0a0 2753 ret = read_register(INT_CHG, &status);
metin.ozkan@analog.com 0:788f63dcf0a0 2754 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2755 return ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2756 }
metin.ozkan@analog.com 0:788f63dcf0a0 2757
metin.ozkan@analog.com 0:788f63dcf0a0 2758 return 0;
metin.ozkan@analog.com 0:788f63dcf0a0 2759 }
metin.ozkan@analog.com 0:788f63dcf0a0 2760
metin.ozkan@analog.com 0:788f63dcf0a0 2761 void MAX77654::SetInterruptHandler(int_glbl_t id, interrupt_handler_function func, void *cb)
metin.ozkan@analog.com 0:788f63dcf0a0 2762 {
metin.ozkan@analog.com 0:788f63dcf0a0 2763 interrupt_handler_list[id].func = func;
metin.ozkan@analog.com 0:788f63dcf0a0 2764 interrupt_handler_list[id].cb = cb;
metin.ozkan@analog.com 0:788f63dcf0a0 2765 }
metin.ozkan@analog.com 0:788f63dcf0a0 2766
metin.ozkan@analog.com 0:788f63dcf0a0 2767 void MAX77654::PostInterruptWork()
metin.ozkan@analog.com 0:788f63dcf0a0 2768 {
metin.ozkan@analog.com 0:788f63dcf0a0 2769 int ret;
metin.ozkan@analog.com 0:788f63dcf0a0 2770 uint8_t reg, inten, not_inten, mask;
metin.ozkan@analog.com 0:788f63dcf0a0 2771
metin.ozkan@analog.com 0:788f63dcf0a0 2772
metin.ozkan@analog.com 0:788f63dcf0a0 2773 while (true) {
metin.ozkan@analog.com 0:788f63dcf0a0 2774
metin.ozkan@analog.com 0:788f63dcf0a0 2775 ThisThread::flags_wait_any(POST_INTR_WORK_SIGNAL_ID);
metin.ozkan@analog.com 0:788f63dcf0a0 2776
metin.ozkan@analog.com 0:788f63dcf0a0 2777 // Check Interrupt Flags in INT_GLBL0
metin.ozkan@analog.com 0:788f63dcf0a0 2778 ret = read_register(INT_GLBL0, &reg);
metin.ozkan@analog.com 0:788f63dcf0a0 2779 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2780 return;
metin.ozkan@analog.com 0:788f63dcf0a0 2781 }
metin.ozkan@analog.com 0:788f63dcf0a0 2782
metin.ozkan@analog.com 0:788f63dcf0a0 2783 ret = read_register(INTM_GLBL0, &inten);
metin.ozkan@analog.com 0:788f63dcf0a0 2784 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2785 return;
metin.ozkan@analog.com 0:788f63dcf0a0 2786 }
metin.ozkan@analog.com 0:788f63dcf0a0 2787
metin.ozkan@analog.com 0:788f63dcf0a0 2788 not_inten = ~inten; // 0 means unmasked.
metin.ozkan@analog.com 0:788f63dcf0a0 2789
metin.ozkan@analog.com 0:788f63dcf0a0 2790 for (int i = 0; i < INT_GLBL1_GPI1_F; i++) {
metin.ozkan@analog.com 0:788f63dcf0a0 2791 mask = (1 << i);
metin.ozkan@analog.com 0:788f63dcf0a0 2792 if ((reg & mask) && (not_inten & mask)) {
metin.ozkan@analog.com 0:788f63dcf0a0 2793 if (interrupt_handler_list[i].func != NULL) {
metin.ozkan@analog.com 0:788f63dcf0a0 2794 interrupt_handler_list[i]
metin.ozkan@analog.com 0:788f63dcf0a0 2795 .func(interrupt_handler_list[i].cb);
metin.ozkan@analog.com 0:788f63dcf0a0 2796 }
metin.ozkan@analog.com 0:788f63dcf0a0 2797 }
metin.ozkan@analog.com 0:788f63dcf0a0 2798 }
metin.ozkan@analog.com 0:788f63dcf0a0 2799
metin.ozkan@analog.com 0:788f63dcf0a0 2800 // Check Interrupt Flags in INT_GLBL1
metin.ozkan@analog.com 0:788f63dcf0a0 2801 ret = read_register(INT_GLBL1, &reg);
metin.ozkan@analog.com 0:788f63dcf0a0 2802 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2803 return;
metin.ozkan@analog.com 0:788f63dcf0a0 2804 }
metin.ozkan@analog.com 0:788f63dcf0a0 2805
metin.ozkan@analog.com 0:788f63dcf0a0 2806 ret = read_register(INTM_GLBL1, &inten);
metin.ozkan@analog.com 0:788f63dcf0a0 2807 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2808 return;
metin.ozkan@analog.com 0:788f63dcf0a0 2809 }
metin.ozkan@analog.com 0:788f63dcf0a0 2810
metin.ozkan@analog.com 0:788f63dcf0a0 2811 not_inten = ~inten; // 0 means unmasked.
metin.ozkan@analog.com 0:788f63dcf0a0 2812
metin.ozkan@analog.com 0:788f63dcf0a0 2813 for (int i = INT_GLBL1_GPI1_F; i < INT_CHG_THM_I; i++) {
metin.ozkan@analog.com 0:788f63dcf0a0 2814 mask = (1 << (i - INT_GLBL1_GPI1_F));
metin.ozkan@analog.com 0:788f63dcf0a0 2815 if ((reg & mask) && (not_inten & mask)) {
metin.ozkan@analog.com 0:788f63dcf0a0 2816 if (interrupt_handler_list[i].func != NULL) {
metin.ozkan@analog.com 0:788f63dcf0a0 2817 interrupt_handler_list[i]
metin.ozkan@analog.com 0:788f63dcf0a0 2818 .func(interrupt_handler_list[i].cb);
metin.ozkan@analog.com 0:788f63dcf0a0 2819 }
metin.ozkan@analog.com 0:788f63dcf0a0 2820 }
metin.ozkan@analog.com 0:788f63dcf0a0 2821 }
metin.ozkan@analog.com 0:788f63dcf0a0 2822
metin.ozkan@analog.com 0:788f63dcf0a0 2823 // Check Interrupt Flags in INT_CHG
metin.ozkan@analog.com 0:788f63dcf0a0 2824 ret = read_register(INT_CHG, &reg);
metin.ozkan@analog.com 0:788f63dcf0a0 2825 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2826 return;
metin.ozkan@analog.com 0:788f63dcf0a0 2827 }
metin.ozkan@analog.com 0:788f63dcf0a0 2828
metin.ozkan@analog.com 0:788f63dcf0a0 2829 ret = read_register(INT_M_CHG, &inten);
metin.ozkan@analog.com 0:788f63dcf0a0 2830 if (ret != MAX77654_NO_ERROR) {
metin.ozkan@analog.com 0:788f63dcf0a0 2831 return;
metin.ozkan@analog.com 0:788f63dcf0a0 2832 }
metin.ozkan@analog.com 0:788f63dcf0a0 2833
metin.ozkan@analog.com 0:788f63dcf0a0 2834 not_inten = ~inten; // 0 means unmasked.
metin.ozkan@analog.com 0:788f63dcf0a0 2835
metin.ozkan@analog.com 0:788f63dcf0a0 2836 for (int i = INT_CHG_THM_I; i < INT_CHG_END; i++) {
metin.ozkan@analog.com 0:788f63dcf0a0 2837 mask = (1 << (i - INT_CHG_THM_I));
metin.ozkan@analog.com 0:788f63dcf0a0 2838 if ((reg & mask) && (not_inten & mask)) {
metin.ozkan@analog.com 0:788f63dcf0a0 2839 if (interrupt_handler_list[i].func != NULL) {
metin.ozkan@analog.com 0:788f63dcf0a0 2840 interrupt_handler_list[i]
metin.ozkan@analog.com 0:788f63dcf0a0 2841 .func(interrupt_handler_list[i].cb);
metin.ozkan@analog.com 0:788f63dcf0a0 2842 }
metin.ozkan@analog.com 0:788f63dcf0a0 2843 }
metin.ozkan@analog.com 0:788f63dcf0a0 2844 }
metin.ozkan@analog.com 0:788f63dcf0a0 2845 }
metin.ozkan@analog.com 0:788f63dcf0a0 2846 }
metin.ozkan@analog.com 0:788f63dcf0a0 2847 void MAX77654::InterruptHandler()
metin.ozkan@analog.com 0:788f63dcf0a0 2848 {
metin.ozkan@analog.com 0:788f63dcf0a0 2849 post_intr_work_thread->flags_set(POST_INTR_WORK_SIGNAL_ID);
metin.ozkan@analog.com 0:788f63dcf0a0 2850 }