//====================================================================== //函 数 名: CCD_GetImage() //入口参数: 无 //返回值 : 无 //函数功能: CCD驱动以及采样 //====================================================================== void CCD_GetImage(uint32_t ADCx) { unsigned char i; SI_1; //SI端口置1 CK_1; //CK端口置1 SI_0; //SI端口置0 for (i = 0; i < COL; i++) { //延时决定了CCD中的电容器积累的电荷量,同时决定了其是否达到饱和状态或足以采集黑线的状态 //但是时间过长采集周期会变长,所以请使用蓝宙线性CCD上位机,根据实际图像效果调整延时. CK_0; DelayUs(100); IMAGE[i] =ADC_GetConversionValue(ADCx); CK_1; DelayUs(100); } CK_0; DelayUs(50); }
void reproduce_tono_whilePulsado(void){ int contador; if((PORTA & 0b00010000) != 0){ while(PORTB != 0xFF){ RA0 = ~RA0; DelayUs(807); } } if((PORTA & 0b00001000) != 0){ while(PORTB != 0xFF){ RA0 = ~RA0; DelayUs(1136); } } if((PORTA & 0b00000100) != 0){ while(PORTB != 0xFF){ RA0 = ~RA0; DelayUs(1517); } } if((PORTA & 0b00000010) != 0){ while(PORTB != 0xFF){ RA0 = ~RA0; DelayUs(2273); } } }
static int Rk618CodecReset(RK618_DEVICE_CLASS *dev) { int i; int change; unsigned int old, newVal; int ret; Codec618CmdWrite(dev, RK618_RESET, 0xfc); DelayUs(10); Codec618CmdWrite(dev, RK618_RESET, 0x43); DelayUs(10); for (i = 0; i < RK618_MFD_REG_LEN; i++) Codec618CmdWrite(dev, rk618_mfd_reg_defaults[i].reg, rk618_mfd_reg_defaults[i].value); memcpy(g_rk618_reg_cache, rk618_reg_defaults, sizeof(rk618_reg_defaults)); //close charge pump Codec618CmdWrite(dev, RK618_CLK_CHPUMP, 0x41); //bypass zero-crossing detection Codec618CmdWrite(dev, RK618_SINGNAL_ZC_CTL1, 0x3f); Codec618CmdWrite(dev, RK618_SINGNAL_ZC_CTL2, 0xff); //set ADC Power for MICBIAS //set ADC Power for MICBIAS Codec618CmdUpdataBits(dev, RK618_PWR_ADD1, RK618_ADC_PWRD, 0); return 0; }
void DelayMs(unsigned char cnt) { #if XTAL_FREQ <= 2MHZ do { DelayUs(996); } while(--cnt); #endif #if XTAL_FREQ >16MHZ unsigned char i; do { i = 100; do { DelayUs(10); } while(--i); } while(--cnt); #else #if XTAL_FREQ > 2MHZ unsigned char i; do { i = 4; do { DelayUs(250); } while(--i); } while(--cnt); #endif #endif }
void reproduce_tono(void){ int contador; //led verde -> 620Hz -> T=1614 us ->T/2=807 us -> 620 cycles if((PORTA & 0b00010000) != 0){ for(contador=0; contador<620; contador++){ RA0 = ~RA0; DelayUs(807); } } //led rojo ---> 440Hz --> T=2273 us --> T/2 = 1136 us --> 440cycles if((PORTA & 0b00001000) != 0){ for(contador=0; contador<440; contador++){ RA0 = ~RA0; DelayUs(1136); } } //led rojo ---> 329,628Hz --> T=3034 us --> T/2 = 1517 us --> 330cycles if((PORTA & 0b00000100) != 0){ for(contador=0; contador<400; contador++){ RA0 = ~RA0; DelayUs(1517); } } //led rojo ---> 220Hz --> T=4545 us --> T/2 = 2273 us --> 220cycles if((PORTA & 0b00000010) != 0){ for(contador=0; contador<400; contador++){ RA0 = ~RA0; DelayUs(2273); } } }
// resetta il bus 1-wire e rileva la presenza di dispositivi unsigned char OWReset(void) { unsigned char ow_detect; // variabile usata per rilevare la presenza di dispositivi 1wire TRIS_DQ=1; // avvio con linea in alta impedenza DQ=0; // predispongo uscita bassa TRIS_DQ=0; // linea in uscita // linea a livello basso per 500uS // nota: la linea deve essere tenuta a livello basso // minimo 480uS DelayUs(250); DelayUs(250); TRIS_DQ=1; // linea in alta impedenza // dopo che la linea è stata posta in alta impedenza // bisogna attendere dai 15 ai 60uS per una risposta DelayUs(100); // attendo 100uS per stare tranquillo ow_detect=DQ; // rilevo in che stato si trova la linea // l'impulso di presenza dura dai 60 ai 240uS // attendo 430uS dopo l'impulso di presenza DelayUs(230); DelayUs(200); // restituisco il valore ottenuto: // 0 = ci sono dispositivi (OW_PRESENCE) // 1 = non ci sono dispositivi (OW_NO_PRESENCE) return ow_detect; }
void WTV_Voice(u8 addr) { char i; WTV_RST_L;//rst=0; //delay_ms(5);//wait_5ms( ); // 5ms DelayMs(5 ); WTV_RST_H;//rst=1; //delay_ms(8);//wait_8ms( ); //8ms DelayMs(8 ); WTV_CS_L;//cs=0; //delay_ms(5);//wait_5ms( ); // 5ms DelayMs(5 ); for(i=0;i<8;i++) { //_CLI();//TR0=0; WTV_CLK_L;//scl=0; if(addr & 0x01) { WTV_DATA_H;//sda=1; } else WTV_DATA_L;//sda=0; addr>>=1; //delay_us(150);//wait_150us( ); // 300us DelayUs(150 ); WTV_CLK_H;//scl=1; //delay_us(150);//wait_150us( ); DelayUs(150 ); } WTV_CS_H;//cs=1; //_SEI();//TR0=1 }
bool DAC_TransmitByte(int data) { LD_Set; int i; if (data > 4096) return 0; for(i = 12; i > 0; i--){ if (data & 0x800) { SDI_Set; // When 1 is transfered SDI is high } else { SDI_Clear; // else is low } data <<= 1; DelayUs(1); CLK_Clear; DelayUs(1); CLK_Set; DelayUs(1); } CS_Set; // Deselect chip DelayUs(10); LD_Clear; // End of transfer, shift temp register to output DelayUs(10); LD_Set; // End of transfer, shift temp register to output return 1; }
int main(void) { DelayInit(); lcd16x2_init(LCD16X2_DISPLAY_ON_CURSOR_OFF_BLINK_OFF); SPIx_Init(); while (1) { // Enable slave SPIx_EnableSlave(); // Write command to slave to turn on LED blinking SPIx_Transfer((uint8_t) '1'); DelayUs(10); // Write command to slave for asking LED blinking status SPIx_Transfer((uint8_t) '?'); DelayUs(10); // Read LED blinking status (off/on) from slave by transmitting dummy byte receivedByte = SPIx_Transfer(0); // Disable slave SPIx_DisableSlave(); // Display LED blinking status lcd16x2_clrscr(); if (receivedByte == 0) { lcd16x2_puts("LED Blinking Off"); } else if (receivedByte == 1) { lcd16x2_puts("LED Blinking On"); } DelayMs(2500); // Enable slave SPIx_EnableSlave(); // Write command to slave to turn off LED blinking SPIx_Transfer((uint8_t) '0'); DelayUs(10); // Write command to slave for asking LED blinking status SPIx_Transfer((uint8_t) '?'); DelayUs(10); // Read LED blinking status (off/on) from slave by transmitting dummy byte receivedByte = SPIx_Transfer(0); // Disable slave SPIx_DisableSlave(); // Display LED blinking status lcd16x2_clrscr(); if (receivedByte == 0) { lcd16x2_puts("LED Blinking Off"); } else if (receivedByte == 1) { lcd16x2_puts("LED Blinking On"); } DelayMs(2500); } }
//**************************************** //发送setrec指令 void isd_setrec(unsigned char adl,unsigned char adh) { DelayMs(1); isd_send(adl); DelayUs(2); isd_send(adh); DelayUs(2); isd_send(0xa0); //发送setplay指令字节 SS=1; }
// leggo un singolo bit dalla linea unsigned char _OWReadBit(void) { DQ=0; // predispongo uscita bassa TRIS_DQ=0; // pin come uscita DelayUs(1); TRIS_DQ=1; // pin in alta impedenza // Devo aspettare minimo 10uS DelayUs(14); return DQ; // restituisco il valore sul quale si trova la linea }
/* Sets SI high for the rising edge of a clock pulse, then sets SI low before the falling edge. * * This initiates an output cycle for the following 128 clock cycles. * Photodiode integration for the next cycle begins on the 19th clock pulse folowing * the start of an output cycle. */ inline void TSL_StartOutputCycle(void) { /* Rising edge */ GPIO_WriteBit(GPIOE, TSL_SERIAL_PIN, Bit_SET); DelayUs(1); /* Make sure SI pin is high before CLK goes high */ GPIO_WriteBit(GPIOE, TSL_CLOCK_PIN, Bit_SET); DelayUs(TSL_CLOCK_DELAY_US); /* Falling edge */ GPIO_WriteBit(GPIOE, TSL_SERIAL_PIN, Bit_RESET); DelayUs(1); /* Make sure SI pin is low before CLK goes low */ GPIO_WriteBit(GPIOE, TSL_CLOCK_PIN, Bit_RESET); }
// scrivo un singolo bit sulla linea void _OWWriteBit(char bitval) { DQ=0; // predispongo uscita bassa TRIS_DQ=0; // pin come uscita per avviare il timeslot DelayUs(1); // se il bit vale 1, porto la linea in alta impedenza if(bitval==1) { TRIS_DQ=1; } DelayUs(100); // aspetto 100uS per la fine del timeslot TRIS_DQ=1; // riporto la linea come ingresso }
void DelayMs(unsigned char cnt) { #if XTAL_FREQ <= 2 do { DelayUs(996); } while(--cnt); #else unsigned char i; do { i = 4; do { DelayUs(250); } while(--i); } while(--cnt); #endif }
//******************************************* //录音键处理程序 //从指定地址开始录音的程序就是在这段里面 void setkey_treat(void) { set_key=1;//置IO口为1,准备读入数据 DelayUs(1); if(set_key==0) { if(count==0)//判断是否为上电或复位以来第一次按录音键 { st_add=170; } else { st_add=end_add+3; }//每段语言间隔3个地址 isd_powerup(); //AN键按下,ISD上电并延迟50ms isd_stopwrdn(); isd_powerup(); LED1=1;//录音指示灯亮,表示录音模式 isd_setrec(st_add&0x00ff,st_add>>8); //从指定的地址 if(INT==1)// 判定芯片有没有溢出 { isd_rec(); //发送录音指令 } time_total=st_add*2;//计时初始值计算 TR0=1;//开计时器 while(set_key==0);//等待本次录音结束 TR0=0;//录音结束后停止计时 isd_stop(); //发送4004停止命令 end_add=time_total/2+2;//计算语音的结束地址 LED1=0; //录音完毕,LED熄灭 count++;//录音段数自加 } }
/********************************************************************** * Function: InitAdc() * * Description: Initializes the ADC on the F2802x **********************************************************************/ void InitAdc(void) { asm(" EALLOW"); // Enable EALLOW protected register access //--- Reset the ADC module // Note: The ADC is already reset after a DSP reset, but this example is just showing // good coding practice to reset the peripheral before configuring it as you never // know why the DSP has started the code over again from the beginning). AdcRegs.ADCCTL1.bit.RESET = 1; // Reset the ADC // Must wait 2 ADCCLK periods for the reset to take effect. // Note that ADCCLK = SYSCLKOUT for F2802x/F2803x devices. asm(" NOP"); asm(" NOP"); //--- Power-up and configure the ADC AdcRegs.ADCCTL1.all = 0x00E4; // Power-up reference and main ADC // bit 15 0: RESET, ADC software reset, 0=no effect, 1=resets the ADC // bit 14 0: ADCENABLE, ADC enable, 0=disabled, 1=enabled // bit 13 0: ADCBSY, ADC busy, read-only // bit 12-8 0's: ADCBSYCHN, ADC busy channel, read-only // bit 7 1: ADCPWDN, ADC power down, 0=powered down, 1=powered up // bit 6 1: ADCBGPWD, ADC bandgap power down, 0=powered down, 1=powered up // bit 5 1: ADCREFPWD, ADC reference power down, 0=powered down, 1=powered up // bit 4 0: reserved // bit 3 0: ADCREFSEL, ADC reference select, 0=internal, 1=external // bit 2 1: INTPULSEPOS, INT pulse generation, 0=start of conversion, 1=end of conversion // bit 1 0: VREFLOCONV, VREFLO convert, 0=VREFLO not connected, 1=VREFLO connected to B5 // bit 0 0: Must write as 0. DelayUs(1000); // Wait 1 ms after power-up before using the ADC //--- Comparator 1 Configuration --> If (input + > input -) --> CompOut = 1 // If (input + < input -) --> CompOut = 0 Comp1Regs.COMPCTL.bit.COMPDACEN = 1; // Enable Comparator 1 Comp1Regs.COMPCTL.bit.CMPINV = 0; // If you want to invert the output Comp1Regs.COMPCTL.bit.COMPSOURCE = 0; // 1 Both comparator inputs connected to external pin // 0 Input - is generated internally via DAC and compared to an input + which is an external pin Comp1Regs.COMPCTL.bit.SYNCSEL = 0; //Asynchronous Comp1 Output Comp1Regs.COMPCTL.bit.QUALSEL = 0; // Don't Care Comp1Regs.DACVAL.bit.DACVAL = 500; // 10 bits [0-1023] Not used this time. Generates V = DACVAL * 3.3 / 1023 on DAC signal //--- Comparator 2 Configuration --> If (input + > input -) --> CompOut = 1 // If (input + < input -) --> CompOut = 0 Comp2Regs.COMPCTL.bit.COMPDACEN = 1; // Enable Comparator 2 Comp2Regs.COMPCTL.bit.CMPINV = 0; // If you want to invert the output Comp2Regs.COMPCTL.bit.COMPSOURCE = 0; // 1 Both comparator inputs connected to external pin // 0 Input - is generated internally via DAC and compared to an input + which is an external pin Comp2Regs.COMPCTL.bit.SYNCSEL = 0; //Asynchronous Comp1 Output Comp2Regs.COMPCTL.bit.QUALSEL = 0; // Don't Care Comp2Regs.DACVAL.bit.DACVAL = 0; // 10 bits [0-1023] Not used this time. Generates V = DACVAL * 3.3 / 1023 on DAC signal AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // It's already been enabled, but it's necessary to enable it for the comparator to work //--- Finish up AdcRegs.ADCCTL1.bit.ADCENABLE = 1; // Enable the ADC asm(" EDIS"); // Disable EALLOW protected register access } // end InitAdc()
void OW_loop() { if ( timeout ) { byte i; byte prevTimeout; timeout--; prevTimeout = timeout; CLRWDT(); // wait 10 ms or until a request was made for (i=40; i && (timeout == prevTimeout); i--) DelayUs(250); return; } OW_EnterSleep(); // go to sleep after 2 second of inactivity CLRWDT(); SLEEP(); NOP(); OW_LeaveSleep(); }
int main() { RCC_Configuration(); GPIO_Configuration(); RTC_Conf(); ConfirureTimerForDelay(); UsartConf(); NVIC_Configuration(); SystemCoreClockUpdate(); ws2812Init(); ws2812Send(black, 16); ws2812Send(black, 2); while(1) { GPIOC->BSRR |= 1<<0; delay10(); GPIOC->BRR |= 1<<0; DelayUs(10000); } }
void DAC_ClearOutput(void) { CS_Clear; // Select chip CLR_Clear; // Clear output DelayUs(100); CLR_Set; // Set CLR CS_Set; // Deselect chip }
void DelayMs(uchar ms) {char i; for (i=0;i<ms;i++) {DelayUs(1000); } return; }
void TSL_MeasurePixels(int32_t *x_pixels, int32_t *y_pixels) { uint16_t i, j; /* Clear indeterminant data from the sensor */ TSL_StartOutputCycle(); for (i = 0; i < TSL_PIXEL_COUNT; i++) { TSL_ClockPulse(); } TSL_ClockPulse(); DelayUs(TSL_SENSOR_DELAY_US); /* Assign values to the first measurement */; TSL_StartOutputCycle(); for (i = 0; i < TSL_PIXEL_COUNT; i++) { TSL_DualAnalogRead(&(x_pixels[i]), &(y_pixels[i])); //pixels[i] = TSL_AnalogRead(); TSL_ClockPulse(); } /* Clock out the high SI bit from the shift register */ /* This returns the analog output to a known high impedance state */ TSL_ClockPulse(); }
void write_code_P16C6XX( unsigned long address, unsigned char* data, char blocksize, char lastblock ) { char blockcounter; char i; unsigned int payload; if( (lastblock & BLOCKTYPE_FIRST) && (address > 0) ) { set_address_P16( address ); //set the initial address } for( blockcounter = 0; blockcounter < blocksize; blockcounter += 2 ) { for(i=0;i<25;i++) { payload = (((unsigned int) data[blockcounter])) | //MSB (((unsigned int) data[blockcounter + 1]) << 8); pic_send_14_bits( 6, 0x02, payload);//LSB pic_send_n_bits( 6, 0x08 ); //begin programming DelayUs( 100 ); pic_send_n_bits( 6, 0x0E ); //end programming if(pic_read_14_bits( 6, 0x04 )==payload&&i<22)i=22; //correct? do 3 more programming cycles. } pic_send_n_bits( 6, 0x06 ); //increment address } }
* void * * CALLED BY: * Main.c or MainStatusMachine.c * *============================================================================*/ void PWMOutputsDisable(void) { // start of PWMOutputsDisable() // HWI_disable(); // EPwm1Regs.AQCSFRC.bit.CSFA = 0x1; // EPwm2Regs.AQCSFRC.bit.CSFA = 0x1; // EPwm3Regs.AQCSFRC.bit.CSFA = 0x1; // EPwm4Regs.AQCSFRC.bit.CSFA = 0x1; // EPwm5Regs.AQCSFRC.bit.CSFA = 0x1; // EPwm6Regs.AQCSFRC.bit.CSFA = 0x1; // DelayUs(3); // EPwm1Regs.AQCSFRC.bit.CSFB = 0x1; // EPwm2Regs.AQCSFRC.bit.CSFB = 0x1; // EPwm3Regs.AQCSFRC.bit.CSFB = 0x1; // EPwm4Regs.AQCSFRC.bit.CSFB = 0x1; // EPwm5Regs.AQCSFRC.bit.CSFB = 0x1; // EPwm6Regs.AQCSFRC.bit.CSFB = 0x1; asm(" EALLOW"); EPwm1Regs.TZFRC.bit.OST = 1; EPwm2Regs.TZFRC.bit.OST = 1; EPwm3Regs.TZFRC.bit.OST = 1; EPwm4Regs.TZFRC.bit.OST = 1; EPwm5Regs.TZFRC.bit.OST = 1; EPwm6Regs.TZFRC.bit.OST = 1; EPwm1Regs.TZCTL.bit.TZA = 10; EPwm2Regs.TZCTL.bit.TZA = 10; EPwm3Regs.TZCTL.bit.TZA = 10; EPwm4Regs.TZCTL.bit.TZA = 10; EPwm5Regs.TZCTL.bit.TZA = 10; EPwm6Regs.TZCTL.bit.TZA = 10; asm(" EDIS"); DelayUs(3); asm(" EALLOW"); EPwm1Regs.TZFRC.bit.OST = 1; EPwm2Regs.TZFRC.bit.OST = 1; EPwm3Regs.TZFRC.bit.OST = 1; EPwm4Regs.TZFRC.bit.OST = 1; EPwm5Regs.TZFRC.bit.OST = 1; EPwm6Regs.TZFRC.bit.OST = 1; EPwm1Regs.TZCTL.bit.TZB = 10; EPwm2Regs.TZCTL.bit.TZB = 10; EPwm3Regs.TZCTL.bit.TZB = 10; EPwm4Regs.TZCTL.bit.TZB = 10; EPwm5Regs.TZCTL.bit.TZB = 10; EPwm6Regs.TZCTL.bit.TZB = 10; asm(" EDIS"); // HWI_enable();
/* ********************************************************************************************************* * CONNECTION RESET SEQUENCE * * Description : This sequence resets the interface only. The status register preserves its content. * Arguments : none * * Returns : none * Notes : * communication reset: DATA-line=1 and at least 9 SCK cycles followed by transstart * _____________________________________________________ ________ * DATA: |_______| * _ _ _ _ _ _ _ _ _ ___ ___ * SCK : __| |__| |__| |__| |__| |__| |__| |__| |__| |______| |___| |______ ********************************************************************************************************* */ void s_connectionreset(void) { unsigned char i; DATA_WR = 1; //set data pin high DATA_TRIS = 0; //set data pin an output SCK = 0; SCK_TRIS = 0; //set CLK pin an output low for(i=0; i<9; i++) //9 SCK cycles for connection reset sequence { SCK=1; DelayUs(1); SCK=0; DelayUs(1); } s_transstart(); //transmission start }
u8 ComRead(u8 data_s[]) { static u16 wait = 0; u8 i = 0,j = 0; u8 data = 0; wait = 0; COM_BIT_DR = 0;//设置为输入 while(COM_BIT_IN == 0) { if(wait < 60) { wait++; } else { return 0x44; } } if(wait > 25) { wait = 0; COM_BIT_DR = 1;//设置为输出 COM_BIT_OUT = 0; DelayUs(1); COM_BIT_DR = 0;//设置为输入 //开始接受数据 for(j = 0;j < 5;j++) { for(i=0;i<8;i++) { data<<=1; while(COM_BIT_IN == 1) { if(wait < 200) { wait++; } else { return 0x44; } } wait = 0; while(COM_BIT_IN == 0) { if(wait < 200) { wait++; } else { return 0x44; } } if(wait > 30) {//为1 data|=0x01; } wait = 0; } data_s[j] = data; data = 0; } if(data_s[4] == (data_s[0]+data_s[1]+data_s[2]+data_s[3])) {//累加校验 if(data_s[4] != 0) { return 0x88; } else { return 0x44; } } else { return 0x44; } } else {//时间不对 推出 return 0x44; } }
unsigned char ad8bit(unsigned char kanal) { kanal <<= 3; ADCON0 = 0xC1 | kanal; DelayUs(10); GODONE = 1; while (GODONE); return ADRESH; }
void DelayMs_ISR(unsigned char cnt){ #if XTAL_FREQ <= 2MHZ do { DelayUs(996); } while(--cnt); #endif #if XTAL_FREQ > 2MHZ unsigned char i; do { i = 4; do { DelayUs(250); } while(--i); } while(--cnt); #endif }
/////////////////////////////// ///检测总线是否为busy,若是,进行修复 ///@retval -1:成功 -0:失败 /////////////////////////////// bool I2C::I2C_CHACK_BUSY_FIX(uint32_t i2cClock,uint16_t sclPin,uint16_t sdaPin) { u8 Time_out=0; GPIO_InitTypeDef GPIO_InitStructure; while(I2C_GetFlagStatus(mI2C, I2C_FLAG_BUSY)&&Time_out<20) { RCC_APB1PeriphClockCmd(i2cClock,DISABLE);//开启I2C时钟 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);//开启scl sda时钟 /* Set GPIO frequency to 50MHz */ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; /* Select Output open-drain mode */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; /* Initialize I2Cx SCL Pin */ GPIO_InitStructure.GPIO_Pin = sclPin; GPIO_Init(GPIOB, &GPIO_InitStructure); /* Initialize I2Cx SDA Pin */ GPIO_InitStructure.GPIO_Pin = sdaPin; GPIO_Init(GPIOB, &GPIO_InitStructure); //模拟方式产生停止信号 GPIO_ResetBits(GPIOB, sclPin); GPIO_ResetBits(GPIOB, sdaPin); DelayUs(5); GPIO_SetBits(GPIOB, sclPin); DelayUs(5); GPIO_SetBits(GPIOB, sdaPin); DelayUs(5); I2CGPIODeInit(sclPin,sdaPin);//IO设置成默认值 RCC_APB1PeriphResetCmd(i2cClock,ENABLE);//重置clk时钟 防止有错误标志 RCC_APB1PeriphResetCmd(i2cClock,DISABLE);//关闭clk重置 RCC_APB1PeriphClockCmd(i2cClock,ENABLE);//开启I2C时钟 ++Time_out; } if(Time_out==20) return 0; return 1; }
/************************************ 从某个地址开始录音 ************************************/ void ISD4004_SetRec(uint z) { ISD4004_WriteChar(z%256); ISD4004_WriteChar(z/256); ISD4004_WriteChar(0xa0); ISD_SS_H; DelayUs(4); ISD4004_Rec(); //注意如果不加的话就只会播放一个音 }
/************************************ 写入8位数据 ************************************/ void ISD4004_WriteChar(uchar z) { uchar i,temp=z; ISD_SCLK_L; ISD_SS_L; for(i=0;i<8;i++) { if(0x01&temp) ISD_MOSI_H; else ISD_MOSI_L; temp=temp>>1; ISD_SCLK_H; DelayUs(2); ISD_SCLK_L; DelayUs(2); } }