码迷,mamicode.com
首页 > 其他好文 > 详细

表驱动法用于寄存器初始化

时间:2020-05-01 22:29:49      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:mode   getch   clu   ring   com   cts   ini   http   imp   

                                                                                         一般这种手册,寄存器一大堆,看的头大。

                                             

#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include<stdlib.h>
#include <dos.h>
#include <conio.h>

/**
* Default value for a register.  We use an array of structs rather
* than a simple array as many modern devices have very sparse
* register maps.
*
* @reg: Register address.
* @def: Register default value.
*/
struct reg_default {
    unsigned int reg;
    unsigned int def;
};

#define ENDMARKER { 0xffff, 0xffffffff}
#define DEV_ADDR   (0x2D)

struct reg_default IC_Codec_init_table[] =
{
    { 0x013C,0x000A000C},
    { 0x0114,0x00000008 },
    { 0x0164,0x0000000D },
    { 0x0168,0x0000000D},
    { 0x016C,0x0000000D },
    { 0x0170,0x0000000D },
    { 0x0134,0x0000001F },
    { 0x0210,0x0000001F },
    { 0x0104,0x00000001 },
    { 0x0204,0x00000001 },
    { 0x0450,0x03F00120 },
    { 0x0454,0x003C0014 },
    { 0x0458,0x00C80780 },
    { 0x045C,0x000C0008 },
    { 0x0460,0x001A0438 },
    { 0x0464,0x00000001 },
    { 0x04A0,0x00448006 },
    { 0x04A0,0x00048006 },
    { 0x0504,0x00000004 },
    { 0x0480,0x03020100 },
    { 0x0484,0x08050704 },
    { 0x0488,0x0F0E0A09 },
    { 0x048C,0x100D0C0B },
    { 0x0490,0x12111716 },
    { 0x0494,0x1B151413 },
    { 0x0498,0x061A1918 },
    { 0x049C,0x00000263},
    ENDMARKER
};


static int i2c_write( int dev_addr, int reg_addr, int reg_value)
{
    printf("i2c write reg \n");

    return 0;
}

int main()
{
    int i = 0;

    while (IC_Codec_init_table[i].reg != 0xffff)
    {
        i2c_write(DEV_ADDR, IC_Codec_init_table[i].reg, IC_Codec_init_table[i].def);
        i++;

    }

    getchar();

    return 0;
}

 技术图片

表驱动法用于寄存器初始化

标签:mode   getch   clu   ring   com   cts   ini   http   imp   

原文地址:https://www.cnblogs.com/nowroot/p/12815038.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!