📄 philips1341.c
字号:
/*********************************************************************************************
* File: philips1341.c
* Author: embest
* Desc: LCD common macro define and function declare
* History:
*********************************************************************************************/
#include "2410lib.h"
/*------------------------------------------------------------------------------------------*/
/* macro define */
/*------------------------------------------------------------------------------------------*/
#define L3C (0x10) //GPB4=L3C
#define L3D (0x8) //GPB3=L3D
#define L3M (0x4) //GPB2=L3M
#define L3M_LOW() {rGPBDAT &= ~(L3M);}
#define L3M_HIGH() {rGPBDAT |= (L3M);}
#define L3C_LOW() {rGPBDAT &= ~(L3C);}
#define L3C_HIGH() {rGPBDAT |= (L3C);}
#define L3D_LOW() {rGPBDAT &= ~(L3D);}
#define L3D_HIGH() {rGPBDAT |= (L3D);}
#define FS441KHZ 1
/*------------------------------------------------------------------------------------------*/
/* function declare */
/*------------------------------------------------------------------------------------------*/
void write_l3addr(UINT8T ucData);
void write_l3data(UINT8T ucData, int nHalt);
void init_1341(char cMode);
/*********************************************************************************************
* name: init_1341
* func: Init philips 1341 chip
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
void init_1341(char cMode)
{
// Port Initialize
//GPB[4:2]=Output(L3CLOCK):Output(L3DATA):Output(L3MODE)
rGPBCON = rGPBCON & ~((1<<9)|(1<<7)|(1<<5)) | (1<<8)|(1<<6)|(1<<4);
rGPBUP = rGPBUP |(0x7<<2); //The pull up function is disabled GPB[4:2]
L3M_HIGH(); // L3M=H(start condition),L3C=H(start condition)
L3C_HIGH();
write_l3addr(0x14+2); // status (000101xx+10)
write_l3data(0x50,0); // 0,1,01,000,0: reset,384fs,no DCfilter,iis
write_l3addr(0x14+2); // status (000101xx+10)
write_l3data(0x10,0); // 0,0,01,000,0 no reset,384fs,no DCfilter,iis
// Set status register
write_l3addr(0x14+2); // status (000101xx+10)
write_l3data(0x81,0); // 1,0,0,0,0,0,11: OGS=0,IGS=0,ADC_NI,DAC_NI,sngl speed,AoffDon
write_l3addr(0x14+0); // data0 (000101xx+00)
write_l3data(0x0A,0);
// Record mode
if(cMode)
{
write_l3addr(0x14+2); // status (000101xx+10)
write_l3data(0xa2,0); // 1,0,1,0,0,0,10: OGS=0,IGS=1,ADC_NI,DAC_NI,sngl speed,AonDoff
write_l3addr(0x14+0); // data0 (000101xx+00)
write_l3data(0xc2,0); // 11000, 010 : DATA0, Extended addr(010)
write_l3data(0x4d,0); // 010, 011, 01 : DATA0, MS=9dB, Ch1=on, Ch2=off,
}
}
/*********************************************************************************************
* name: write_l3addr
* func: write control data address to 1341 through L3-interface
* para: ucData -- input, control data address
* ret: none
* modify:
* comment:
*********************************************************************************************/
void write_l3addr(UINT8T ucData)
{
INT32T i,j;
L3M_LOW(); // L3M=L
L3C_HIGH(); // L3C=H
for(j=0; j<4; j++) // tsu(L3) > 190ns
;
for(i=0; i<8; i++)
{
if(ucData&0x1) // if ucData bit is 'H'
{
L3C_LOW(); // L3C=L
L3D_HIGH(); // L3D=H
for(j=0; j<4; j++) // tcy(L3) > 500ns
;
L3C_HIGH(); // L3C=H
L3D_HIGH(); // L3D=H
for(j=0; j<4; j++) // tcy(L3) > 500ns
;
}
else // if ucData bit is 'L'
{
L3C_LOW(); // L3C=L
L3D_LOW(); // L3D=L
for(j=0; j<4; j++) // tcy(L3) > 500ns
;
L3C_HIGH(); // L3C=H
L3D_LOW(); // L3D=L
for(j=0; j<4; j++) // tcy(L3) > 500ns
;
}
ucData >>= 1;
}
L3C_HIGH(); // L3M=H,L3C=H
L3M_HIGH();
}
/*********************************************************************************************
* name: write_l3data
* func: write control data to 1341 through L3-interface
* para: ucData -- input, control data
* nHalt -- input, halt operate
* ret: none
* modify:
* comment:
*********************************************************************************************/
void write_l3data(UINT8T ucData,int nHalt)
{
INT32T i,j;
if(nHalt)
{
L3C_HIGH(); // L3C=H(while tstp, L3 interface halt condition)
for(j=0; j<4; j++) // tstp(L3) > 190ns
;
}
L3C_HIGH();
L3M_HIGH(); // L3M=H(in data transfer mode)
for(j=0; j<4; j++) // tsu(L3)D > 190ns
;
for( i=0; i<8; i++ )
{
if(ucData&0x1) // if data bit is 'H'
{
L3M_HIGH(); // L3M=H
L3C_LOW(); // L3C=L
L3D_HIGH(); // L3D=H
for(j=0; j<4; j++) // tcy(L3) > 500ns
;
L3M_HIGH(); // L3M=H
L3C_HIGH(); // L3C=L
L3D_HIGH();
for(j=0; j<4; j++) // tcy(L3) > 500ns
;
}
else // if data bit is 'L'
{
L3M_HIGH(); // L3M=H
L3C_LOW(); // L3C=L
L3D_LOW(); // L3D=L
for(j=0; j<4; j++) // tcy(L3) > 500ns
;
L3M_HIGH(); // L3M=H
L3C_HIGH(); // L3C=L
L3D_LOW(); // L3D=L
for(j=0; j<4; j++) // tcy(L3) > 500ns
;
}
ucData >>= 1;
}
L3C_HIGH(); // L3M=H,L3C=H
L3M_HIGH();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -