⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uda1341.c

📁 44B0板子的检测程序 包括键盘 LED LCD SEG
💻 C
字号:
#include "s3c44b0.h"#include "uda1341.h"#define AUDIO_BASE      0x100000#define L3_ADDR_DATA0   0x14#define L3_ADDR_DATA1   0x15#define L3_ADDR_STATUS  0x16#define rGPIO_L3        rPDATG#define L3_MOD_BIT      0x10 //GPC4#define L3_CLK_BIT      0x20 //GPC5#define L3_DAT_BIT      0x40 //GPC6#define L3_MSK_BIT      0x8F //ALLunsigned char l3_data0_0  = 0x00; //(00)000000unsigned char l3_status_0 = 0x20; //(0)0100000unsigned char l3_status_1 = 0x80; //(1)0000000void iis_init(void);void l3_init(void);void l3_gen_wait(void);void l3_gen_addr(unsigned char addr);void l3_gen_data(unsigned char data);void l3_gen_wait(void){    int i;    for (i=0; i<20; i++);}void l3_gen_addr(unsigned char addr){    int i;    unsigned char a;    unsigned int t, r;    a = addr;    t = rGPIO_L3&L3_MSK_BIT;    // mod 1, clk 1, dat 1    r = t|L3_MOD_BIT|L3_CLK_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();    // mod 1, clk 0, dat 1    r = t|L3_MOD_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();    // mod 1, clk 1, dat 1    r = t|L3_MOD_BIT|L3_CLK_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();    // mod 0, clk 1, dat 1    r = t|L3_CLK_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();    for (i=0; i<8; i++)    {        // mod 0, clk 0, dat ?        if (a&0x01)            r = t|L3_DAT_BIT;        else            r = t;        rGPIO_L3 = r;        l3_gen_wait();        // mod 0, clk 1, dat ?        if (a&0x01)            r = t|L3_CLK_BIT|L3_DAT_BIT;        else            r = t|L3_CLK_BIT;        rGPIO_L3 = r;        l3_gen_wait();        a = a>>1;    }    // mod 0, clk 1, dat 1    r = t|L3_CLK_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();    // mod 1, clk 1, dat 1    r = t|L3_MOD_BIT|L3_CLK_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();    // mod 1, clk 0, dat 1    r = t|L3_MOD_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();    // mod 1, clk 1, dat 1    r = t|L3_MOD_BIT|L3_CLK_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();}void l3_gen_data(unsigned char data){    int i;    unsigned char d;    unsigned int t, r;    d = data;    t = rGPIO_L3&L3_MSK_BIT;    // mod 1, clk 1, dat 1    r = t|L3_MOD_BIT|L3_CLK_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();    // mod 0, clk 1, dat 1    r = t|L3_CLK_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();    // mod 1, clk 1, dat 1    r = t|L3_MOD_BIT|L3_CLK_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();    for (i=0; i<8; i++)    {        // mod 1, clk 0, dat ?        if (d&0x01)            r = t|L3_MOD_BIT|L3_DAT_BIT;        else            r = t|L3_MOD_BIT;        rGPIO_L3 = r;        l3_gen_wait();        // mod 1, clk 1, dat ?        if (d&0x01)            r = t|L3_MOD_BIT|L3_CLK_BIT|L3_DAT_BIT;        else            r = t|L3_MOD_BIT|L3_CLK_BIT;        rGPIO_L3 = r;        l3_gen_wait();        d = d>>1;    }    // mod 1, clk 1, dat 1    r = t|L3_MOD_BIT|L3_CLK_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();    // mod 0, clk 1, dat 1    r = t|L3_CLK_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();    // mod 1, clk 1, dat 1    r = t|L3_MOD_BIT|L3_CLK_BIT|L3_DAT_BIT;    rGPIO_L3 = r;    l3_gen_wait();}void iis_init(void){    rIISMOD  = 0x089; //master, transmit, low, iis, 16-bit, 256fs, 32fs    rIISPSR  = 0x011; //44.1k*256 = 112896k ?= 40M/4 =10M    rIISFCON = 0x300; //normal, normal, enable, enable, -, -    rIISCON  = 0x003; //start}void l3_init(void){    l3_gen_addr(L3_ADDR_STATUS);    l3_gen_data(l3_status_0);    l3_gen_data(l3_status_1);}void cmd_iis(void){    unsigned int cnt;    unsigned short *buf;    cnt = 0;    buf = (unsigned short *)AUDIO_BASE;    iis_init();    l3_init();    /*    for (;;)    {        unsigned short au;        rIISMOD = 0x049;        au = rIISFIF;        rIISMOD = 0x089;        rIISFIF =  au;    }    */    /*    for (;;)    {                if ((rIISCON&0x40)==0) rIISFIF = (signed short)(0);        if ((rIISCON&0x40)==0) rIISFIF = (signed short)(0);        if ((rIISCON&0x40)==0) rIISFIF = (signed short)(40);        if ((rIISCON&0x40)==0) rIISFIF = (signed short)(0);        if ((rIISCON&0x40)==0) rIISFIF = (signed short)(0);        if ((rIISCON&0x40)==0) rIISFIF = (signed short)(0);        if ((rIISCON&0x40)==0) rIISFIF = (signed short)(-40);        if ((rIISCON&0x40)==0) rIISFIF = (signed short)(0);        //if ((rIISCON&0x40)==0) rIISFIF = (signed short)(0);        //if ((rIISCON&0x40)==0) rIISFIF = (signed short)(0);        //if ((rIISCON&0x40)==0) rIISFIF = (signed short)(1000);        //if ((rIISCON&0x40)==0) rIISFIF = (signed short)(0);        //if ((rIISCON&0x40)==0) rIISFIF = (signed short)(0);        //if ((rIISCON&0x40)==0) rIISFIF = (signed short)(0);        //if ((rIISCON&0x40)==0) rIISFIF = (signed short)(-1000);    }    */    ///*    for (;;)    {        if ((rIISCON&0x80)==0)        {            rIISFIF = *buf;            buf++;            cnt++;        }        if (cnt>=0x80000)        {            buf = (unsigned short *)AUDIO_BASE;            cnt = 0;        }    }    //*/}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -