gh_i2c.c 18.1 KB
Newer Older
G
gokemicro 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
/******************************************************************************
**
** \file      gh_i2c.c
**
** \brief     I2C Interface..
**
**            Copyright:   2012 - 2016 (C) GoKe Microelectronics
**
** \attention THIS SAMPLE CODE IS PROVIDED AS IS. GOKE MICROELECTRONICS
**            ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR
**            OMMISSIONS.
**
** \note      Do not modify this file as it is generated automatically.
**
******************************************************************************/
#ifndef SRC_INLINE
#include "gh_i2c.h"
#endif

/*----------------------------------------------------------------------------*/
/* registers                                                                  */
/*----------------------------------------------------------------------------*/
#define REG_I2C_ENABLE_REAL                                 FIO_ADDRESS(I2C,0x70003000) /* read/write */
#define REG_I2C_CONTROL_REAL                                FIO_ADDRESS(I2C,0x70003004) /* read/write */
#define REG_I2C_DATA_REAL                                   FIO_ADDRESS(I2C,0x70003008) /* read/write */
#define REG_I2C_STATUS_REAL                                 FIO_ADDRESS(I2C,0x7000300C) /* read */
#define REG_I2C_PRESCALEL_REAL                              FIO_ADDRESS(I2C,0x70003010) /* read/write */
#define REG_I2C_PRESCALEH_REAL                              FIO_ADDRESS(I2C,0x70003014) /* read/write */
#define REG_I2C_FMCONTROL_REAL                              FIO_ADDRESS(I2C,0x70003018) /* read/write */
#define REG_I2C_FMDATA_REAL                                 FIO_ADDRESS(I2C,0x7000301C) /* read/write */

/*----------------------------------------------------------------------------*/
/* bit group structures                                                       */
/*----------------------------------------------------------------------------*/
typedef union { /* I2C_ENABLE */
    U32 all;
    struct {
        U32 en                          : 1;
        U32                             : 31;
    } bitc;
} GH_I2C_ENABLE_REAL_S;

typedef union { /* I2C_CONTROL */
    U32 all;
    struct {
        U32 ack                         : 1;
        U32 intflag                     : 1;
        U32 start                       : 1;
        U32 stop                        : 1;
        U32                             : 28;
    } bitc;
} GH_I2C_CONTROL_REAL_S;

typedef union { /* I2C_DATA */
    U32 all;
    struct {
        U32 data                        : 8;
        U32                             : 24;
    } bitc;
} GH_I2C_DATA_REAL_S;

typedef union { /* I2C_STATUS */
    U32 all;
    struct {
        U32 mode                        : 1;
        U32                             : 31;
    } bitc;
} GH_I2C_STATUS_REAL_S;

typedef union { /* I2C_PRESCALEL */
    U32 all;
    struct {
        U32 scale                       : 8;
        U32                             : 24;
    } bitc;
} GH_I2C_PRESCALEL_REAL_S;

typedef union { /* I2C_PRESCALEH */
    U32 all;
    struct {
        U32 scale                       : 8;
        U32                             : 24;
    } bitc;
} GH_I2C_PRESCALEH_REAL_S;

typedef union { /* I2C_FMCONTROL */
    U32 all;
    struct {
        U32                             : 1;
        U32 is                          : 1;
        U32 start                       : 1;
        U32 stop                        : 1;
        U32                             : 28;
    } bitc;
} GH_I2C_FMCONTROL_REAL_S;

typedef union { /* I2C_FMDATA */
    U32 all;
    struct {
        U32 data                        : 8;
        U32                             : 24;
    } bitc;
} GH_I2C_FMDATA_REAL_S;


/*----------------------------------------------------------------------------*/
/* mirror variables                                                           */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/* register I2C_ENABLE (read/write)                                           */
/*----------------------------------------------------------------------------*/
GH_INLINE void GH_I2C_set_ENABLE(U8 index, U32 data)
{
    GH_I2C_ENABLE_REAL_S real;
    GH_I2C_ENABLE_S dummy;
    dummy.all = data ;
    real.bitc.en = dummy.bitc.en;
    *(volatile U32 *)(REG_I2C_ENABLE_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = real.all;
}
GH_INLINE U32  GH_I2C_get_ENABLE(U8 index)
{
    GH_I2C_ENABLE_REAL_S real;
    GH_I2C_ENABLE_S dummy;
     dummy.all =  0;
     real.all = (*(volatile U32 *)(REG_I2C_ENABLE_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    dummy.bitc.en = real.bitc.en;
    return dummy.all;
}
GH_INLINE void GH_I2C_set_ENABLE_en(U8 index, U8 data)
{
    GH_I2C_ENABLE_REAL_S d;
    d.all = *(volatile U32 *)(REG_I2C_ENABLE_REAL + index * FIO_MOFFSET(I2C,0x00004000));
    d.bitc.en = data;
    *(volatile U32 *)(REG_I2C_ENABLE_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = d.all;
}
GH_INLINE U8   GH_I2C_get_ENABLE_en(U8 index)
{
    GH_I2C_ENABLE_REAL_S tmp_value;
    U32 value = (*(volatile U32 *)(REG_I2C_ENABLE_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    tmp_value.all = value;
    return tmp_value.bitc.en;
}

/*----------------------------------------------------------------------------*/
/* register I2C_CONTROL (read/write)                                          */
/*----------------------------------------------------------------------------*/
GH_INLINE void GH_I2C_set_CONTROL(U8 index, U32 data)
{
    GH_I2C_CONTROL_REAL_S real;
    GH_I2C_CONTROL_S dummy;
    dummy.all = data ;
    real.bitc.ack = dummy.bitc.ack;
    real.bitc.intflag = dummy.bitc.intflag;
    real.bitc.start = dummy.bitc.start;
    real.bitc.stop = dummy.bitc.stop;
    *(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = real.all;
}
GH_INLINE U32  GH_I2C_get_CONTROL(U8 index)
{
    GH_I2C_CONTROL_REAL_S real;
    GH_I2C_CONTROL_S dummy;
     dummy.all =  0;
     real.all = (*(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    dummy.bitc.ack = real.bitc.ack;
    dummy.bitc.intflag = real.bitc.intflag;
    dummy.bitc.start = real.bitc.start;
    dummy.bitc.stop = real.bitc.stop;
    return dummy.all;
}
GH_INLINE void GH_I2C_set_CONTROL_ack(U8 index, U8 data)
{
    GH_I2C_CONTROL_REAL_S d;
    d.all = *(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000));
    d.bitc.ack = data;
    *(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = d.all;
}
GH_INLINE U8   GH_I2C_get_CONTROL_ack(U8 index)
{
    GH_I2C_CONTROL_REAL_S tmp_value;
    U32 value = (*(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    tmp_value.all = value;
    return tmp_value.bitc.ack;
}
GH_INLINE void GH_I2C_set_CONTROL_IntFlag(U8 index, U8 data)
{
    GH_I2C_CONTROL_REAL_S d;
    d.all = *(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000));
    d.bitc.intflag = data;
    *(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = d.all;
}
GH_INLINE U8   GH_I2C_get_CONTROL_IntFlag(U8 index)
{
    GH_I2C_CONTROL_REAL_S tmp_value;
    U32 value = (*(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    tmp_value.all = value;
    return tmp_value.bitc.intflag;
}
GH_INLINE void GH_I2C_set_CONTROL_start(U8 index, U8 data)
{
    GH_I2C_CONTROL_REAL_S d;
    d.all = *(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000));
    d.bitc.start = data;
    *(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = d.all;
}
GH_INLINE U8   GH_I2C_get_CONTROL_start(U8 index)
{
    GH_I2C_CONTROL_REAL_S tmp_value;
    U32 value = (*(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    tmp_value.all = value;
    return tmp_value.bitc.start;
}
GH_INLINE void GH_I2C_set_CONTROL_stop(U8 index, U8 data)
{
    GH_I2C_CONTROL_REAL_S d;
    d.all = *(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000));
    d.bitc.stop = data;
    *(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = d.all;
}
GH_INLINE U8   GH_I2C_get_CONTROL_stop(U8 index)
{
    GH_I2C_CONTROL_REAL_S tmp_value;
    U32 value = (*(volatile U32 *)(REG_I2C_CONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    tmp_value.all = value;
    return tmp_value.bitc.stop;
}

/*----------------------------------------------------------------------------*/
/* register I2C_DATA (read/write)                                             */
/*----------------------------------------------------------------------------*/
GH_INLINE void GH_I2C_set_DATA(U8 index, U32 data)
{
    GH_I2C_DATA_REAL_S real;
    GH_I2C_DATA_S dummy;
    dummy.all = data ;
    real.bitc.data = dummy.bitc.data;
    *(volatile U32 *)(REG_I2C_DATA_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = real.all;
}
GH_INLINE U32  GH_I2C_get_DATA(U8 index)
{
    GH_I2C_DATA_REAL_S real;
    GH_I2C_DATA_S dummy;
     dummy.all =  0;
     real.all = (*(volatile U32 *)(REG_I2C_DATA_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    dummy.bitc.data = real.bitc.data;
    return dummy.all;
}
GH_INLINE void GH_I2C_set_DATA_Data(U8 index, U8 data)
{
    GH_I2C_DATA_REAL_S d;
    d.all = *(volatile U32 *)(REG_I2C_DATA_REAL + index * FIO_MOFFSET(I2C,0x00004000));
    d.bitc.data = data;
    *(volatile U32 *)(REG_I2C_DATA_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = d.all;
}
GH_INLINE U8   GH_I2C_get_DATA_Data(U8 index)
{
    GH_I2C_DATA_REAL_S tmp_value;
    U32 value = (*(volatile U32 *)(REG_I2C_DATA_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    tmp_value.all = value;
    return tmp_value.bitc.data;
}

/*----------------------------------------------------------------------------*/
/* register I2C_STATUS (read)                                                 */
/*----------------------------------------------------------------------------*/
GH_INLINE U32  GH_I2C_get_STATUS(U8 index)
{
    GH_I2C_STATUS_REAL_S real;
    GH_I2C_STATUS_S dummy;
     dummy.all =  0;
     real.all = (*(volatile U32 *)(REG_I2C_STATUS_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    dummy.bitc.mode = real.bitc.mode;
    return dummy.all;
}
GH_INLINE U8   GH_I2C_get_STATUS_mode(U8 index)
{
    GH_I2C_STATUS_REAL_S tmp_value;
    U32 value = (*(volatile U32 *)(REG_I2C_STATUS_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    tmp_value.all = value;
    return tmp_value.bitc.mode;
}

/*----------------------------------------------------------------------------*/
/* register I2C_PRESCALEL (read/write)                                        */
/*----------------------------------------------------------------------------*/
GH_INLINE void GH_I2C_set_PRESCALEL(U8 index, U32 data)
{
    GH_I2C_PRESCALEL_REAL_S real;
    GH_I2C_PRESCALEL_S dummy;
    dummy.all = data ;
    real.bitc.scale = dummy.bitc.scale;
    *(volatile U32 *)(REG_I2C_PRESCALEL_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = real.all;
}
GH_INLINE U32  GH_I2C_get_PRESCALEL(U8 index)
{
    GH_I2C_PRESCALEL_REAL_S real;
    GH_I2C_PRESCALEL_S dummy;
     dummy.all =  0;
     real.all = (*(volatile U32 *)(REG_I2C_PRESCALEL_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    dummy.bitc.scale = real.bitc.scale;
    return dummy.all;
}
GH_INLINE void GH_I2C_set_PRESCALEL_scale(U8 index, U8 data)
{
    GH_I2C_PRESCALEL_REAL_S d;
    d.all = *(volatile U32 *)(REG_I2C_PRESCALEL_REAL + index * FIO_MOFFSET(I2C,0x00004000));
    d.bitc.scale = data;
    *(volatile U32 *)(REG_I2C_PRESCALEL_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = d.all;
}
GH_INLINE U8   GH_I2C_get_PRESCALEL_scale(U8 index)
{
    GH_I2C_PRESCALEL_REAL_S tmp_value;
    U32 value = (*(volatile U32 *)(REG_I2C_PRESCALEL_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    tmp_value.all = value;
    return tmp_value.bitc.scale;
}

/*----------------------------------------------------------------------------*/
/* register I2C_PRESCALEH (read/write)                                        */
/*----------------------------------------------------------------------------*/
GH_INLINE void GH_I2C_set_PRESCALEH(U8 index, U32 data)
{
    GH_I2C_PRESCALEH_REAL_S real;
    GH_I2C_PRESCALEH_S dummy;
    dummy.all = data ;
    real.bitc.scale = dummy.bitc.scale;
    *(volatile U32 *)(REG_I2C_PRESCALEH_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = real.all;
}
GH_INLINE U32  GH_I2C_get_PRESCALEH(U8 index)
{
    GH_I2C_PRESCALEH_REAL_S real;
    GH_I2C_PRESCALEH_S dummy;
     dummy.all =  0;
     real.all = (*(volatile U32 *)(REG_I2C_PRESCALEH_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    dummy.bitc.scale = real.bitc.scale;
    return dummy.all;
}
GH_INLINE void GH_I2C_set_PRESCALEH_scale(U8 index, U8 data)
{
    GH_I2C_PRESCALEH_REAL_S d;
    d.all = *(volatile U32 *)(REG_I2C_PRESCALEH_REAL + index * FIO_MOFFSET(I2C,0x00004000));
    d.bitc.scale = data;
    *(volatile U32 *)(REG_I2C_PRESCALEH_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = d.all;
}
GH_INLINE U8   GH_I2C_get_PRESCALEH_scale(U8 index)
{
    GH_I2C_PRESCALEH_REAL_S tmp_value;
    U32 value = (*(volatile U32 *)(REG_I2C_PRESCALEH_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    tmp_value.all = value;
    return tmp_value.bitc.scale;
}

/*----------------------------------------------------------------------------*/
/* register I2C_FMCONTROL (read/write)                                        */
/*----------------------------------------------------------------------------*/
GH_INLINE void GH_I2C_set_FMCONTROL(U8 index, U32 data)
{
    GH_I2C_FMCONTROL_REAL_S real;
    GH_I2C_FMCONTROL_S dummy;
    dummy.all = data ;
    real.bitc.is = dummy.bitc.is;
    real.bitc.start = dummy.bitc.start;
    real.bitc.stop = dummy.bitc.stop;
    *(volatile U32 *)(REG_I2C_FMCONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = real.all;
}
GH_INLINE U32  GH_I2C_get_FMCONTROL(U8 index)
{
    GH_I2C_FMCONTROL_REAL_S real;
    GH_I2C_FMCONTROL_S dummy;
     dummy.all =  0;
     real.all = (*(volatile U32 *)(REG_I2C_FMCONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    dummy.bitc.is = real.bitc.is;
    dummy.bitc.start = real.bitc.start;
    dummy.bitc.stop = real.bitc.stop;
    return dummy.all;
}
GH_INLINE void GH_I2C_set_FMCONTROL_is(U8 index, U8 data)
{
    GH_I2C_FMCONTROL_REAL_S d;
    d.all = *(volatile U32 *)(REG_I2C_FMCONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000));
    d.bitc.is = data;
    *(volatile U32 *)(REG_I2C_FMCONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = d.all;
}
GH_INLINE U8   GH_I2C_get_FMCONTROL_is(U8 index)
{
    GH_I2C_FMCONTROL_REAL_S tmp_value;
    U32 value = (*(volatile U32 *)(REG_I2C_FMCONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    tmp_value.all = value;
    return tmp_value.bitc.is;
}
GH_INLINE void GH_I2C_set_FMCONTROL_start(U8 index, U8 data)
{
    GH_I2C_FMCONTROL_REAL_S d;
    d.all = *(volatile U32 *)(REG_I2C_FMCONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000));
    d.bitc.start = data;
    *(volatile U32 *)(REG_I2C_FMCONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = d.all;
}
GH_INLINE U8   GH_I2C_get_FMCONTROL_start(U8 index)
{
    GH_I2C_FMCONTROL_REAL_S tmp_value;
    U32 value = (*(volatile U32 *)(REG_I2C_FMCONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    tmp_value.all = value;
    return tmp_value.bitc.start;
}
GH_INLINE void GH_I2C_set_FMCONTROL_stop(U8 index, U8 data)
{
    GH_I2C_FMCONTROL_REAL_S d;
    d.all = *(volatile U32 *)(REG_I2C_FMCONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000));
    d.bitc.stop = data;
    *(volatile U32 *)(REG_I2C_FMCONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = d.all;
}
GH_INLINE U8   GH_I2C_get_FMCONTROL_stop(U8 index)
{
    GH_I2C_FMCONTROL_REAL_S tmp_value;
    U32 value = (*(volatile U32 *)(REG_I2C_FMCONTROL_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    tmp_value.all = value;
    return tmp_value.bitc.stop;
}

/*----------------------------------------------------------------------------*/
/* register I2C_FMDATA (read/write)                                           */
/*----------------------------------------------------------------------------*/
GH_INLINE void GH_I2C_set_FMDATA(U8 index, U32 data)
{
    GH_I2C_FMDATA_REAL_S real;
    GH_I2C_FMDATA_S dummy;
    dummy.all = data ;
    real.bitc.data = dummy.bitc.data;
    *(volatile U32 *)(REG_I2C_FMDATA_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = real.all;
}
GH_INLINE U32  GH_I2C_get_FMDATA(U8 index)
{
    GH_I2C_FMDATA_REAL_S real;
    GH_I2C_FMDATA_S dummy;
     dummy.all =  0;
     real.all = (*(volatile U32 *)(REG_I2C_FMDATA_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    dummy.bitc.data = real.bitc.data;
    return dummy.all;
}
GH_INLINE void GH_I2C_set_FMDATA_Data(U8 index, U8 data)
{
    GH_I2C_FMDATA_REAL_S d;
    d.all = *(volatile U32 *)(REG_I2C_FMDATA_REAL + index * FIO_MOFFSET(I2C,0x00004000));
    d.bitc.data = data;
    *(volatile U32 *)(REG_I2C_FMDATA_REAL + index * FIO_MOFFSET(I2C,0x00004000)) = d.all;
}
GH_INLINE U8   GH_I2C_get_FMDATA_Data(U8 index)
{
    GH_I2C_FMDATA_REAL_S tmp_value;
    U32 value = (*(volatile U32 *)(REG_I2C_FMDATA_REAL + index * FIO_MOFFSET(I2C,0x00004000)));

    tmp_value.all = value;
    return tmp_value.bitc.data;
}

/*----------------------------------------------------------------------------*/
/* init function                                                              */
/*----------------------------------------------------------------------------*/
GH_INLINE void GH_I2C_init(void)
{
    int i;

    for (i=0; i<2; i++)
    {
        GH_I2C_set_ENABLE(i, (U32)0x00000000);
    }
    for (i=0; i<2; i++)
    {
        GH_I2C_set_CONTROL(i, (U32)0x00000000);
    }
    for (i=0; i<2; i++)
    {
        GH_I2C_set_DATA(i, (U32)0x00000000);
    }
    for (i=0; i<2; i++)
    {
        GH_I2C_set_PRESCALEL(i, (U32)0x00000000);
    }
    for (i=0; i<2; i++)
    {
        GH_I2C_set_PRESCALEH(i, (U32)0x00000000);
    }
    for (i=0; i<2; i++)
    {
        GH_I2C_set_FMCONTROL(i, (U32)0x00000000);
    }
    for (i=0; i<2; i++)
    {
        GH_I2C_set_FMDATA(i, (U32)0x00000000);
    }
    /* read read-clear registers in order to set mirror variables */
}

/*----------------------------------------------------------------------------*/
/* end of file                                                                */
/*----------------------------------------------------------------------------*/