`上次给大家分享了一些资料,这次继续给大家补全一些资料。
由于文件太大,传起来很是麻烦,所以,大家自己下载下吧,里面 PCB,,原理图,Demo都很详细,也很周全。
链接:https://pan.baidu.com/s/1k5nFwFDRUKTFaabAE1qpCw
提取码:xtt7
下面就进入我们的正题吧,
之前一直想做智能家居这块,现在有了这个小板子,可以很大程度上,帮助我们解放双手,来实现很多语音指令及控制的交互,我这边先测试,调试通demo,然后烧录到我们的ISD9160板子上,后面的话,还计划串一块显示屏在这边,可以用语音控制,也可以用触摸控制,给家里老人,小朋友一个更好的体验。
这个喇叭,是之前废旧的笔记本电脑上拆解下来的,大家莫觉得怪。测试嘛,成功最重要。demo测试完成后,我这边又链接到了我的 单片机。
那么也就是在语音识别成功后,我这边会叫他开启或者关闭继电器,用于电器控制,
到此,还没有完全结束。
我这边写了一份协议,用于和带屏主板那边的交互,控制,至此,我这边还在调试成功,下期报告的时候,我会给大家带来一些成果。
GPIO部分,
- /*---------------------------------------------------------------------------------------------------------*/
- /* */
- /* Copyright(c) 2011 Nuvoton Technology Corp. All rights reserved. */
- /* */
- /*---------------------------------------------------------------------------------------------------------*/
- /* */
- /* Note: */
- /* If you meet Nu-Link (ICE) connection problem after program this code. */
- /* It may be caused by ISD9160 is still in power down mode. Just need to remove all power of PCBA */
- /* including the ICE. After power removal, keep hoding the wakeup button two seconds to consume the */
- /* remain power in ISD9160. After that you can try to connect with ICE again. */
- /*----------------------------------------------------------------------------------------------------------*/
- /* GPA0-GPA7 belong to LDO power plane, if LDO is off, and external pwoer is used for LDO power plane */
- /* Need to handle the circuit for external device on correct state after power down. */
- /* Like pull-high on CS, CLK, DI pins of SPI-flash. */
- /* All GPA0~GPA7 are in tri-state (high impedance) no matter LDO is on or off */
- /*----------------------------------------------------------------------------------------------------------*/
- #include
- #include "DriverDrvUART.h"
- #include "DriverDrvGPIO.h"
- #include "DriverDrvRTC.h"
- #include "DriverDrvOSC.h"
- #include "DriverDrvPMU.h"
- //#include "DriverDrvPWM.h"
- #include "DriverDrvI2S.h"
- #include "ISD9xx.h"
- /*---------------------------------------------------------------------------------------------------------*/
- /* Global variables */
- /*---------------------------------------------------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------------------------------*/
- /* Define functions prototype */
- /*---------------------------------------------------------------------------------------------------------*/
- void SysTimerDelay(uint32_t us)
- {
- SysTick->LOAD = us * 22; /* Assume the internal 22MHz RC used */
- SysTick->VAL = (0x00);
- SysTick->CTRL = (1 << SYSTICK_CLKSOURCE) | (1<
- /* Waiting for down-count to zero */
- while((SysTick->CTRL & (1 << 16)) == 0);
- }
- void Smpl_DrvPMU_SYSCLKinit(void)
- {
- UNLOCKREG();
- SYSCLK->CLKSEL0.HCLK_S = 0; /* Select HCLK source as OSC48 */
- SYSCLK->CLKDIV.HCLK_N = 9; /* Select no division */
- SYSCLK->CLKSEL0.OSCFSel = 1; /* 1= 32MHz, 0=48MHz */
- SYSCLK->PWRCON.XTL32K_EN = 1;
- SYSCLK->PWRCON.OSC10K_EN = 1;
- /* Enable RTC Clock */
- //SYSCLK->APBCLK.RTC_EN =1;
- //SYSCLK->APBCLK.I2S_EN = 1;
- //SYSCLK->APBCLK.ANA_EN = 1;
- LOCKREG();
- }
- void Smpl_DrvPMU_UARTinit(void)
- {
- STR_UART_T sParam;
- /* Set UART Pin */
- DrvGPIO_InitFunction(FUNC_UART0);
- /* UART Setting */
- sParam.u32BaudRate = 115200;
- sParam.u8cDataBits = DRVUART_DATABITS_8;
- sParam.u8cStopBits = DRVUART_STOPBITS_1;
- sParam.u8cParity = DRVUART_PARITY_NONE;
- sParam.u8cRxTriggerLevel= DRVUART_FIFO_1BYTES;
- DrvUART_Open(UART_PORT0,&sParam);
- }
- void PrintPwrCon(void)
- {
- printf("ICER register %08X
- ", NVIC->ICER[0]);
- printf("PFLAG register %02X
- ", M32(&SYSCLK->PFLAGCON));
- M32(&SYSCLK->PFLAGCON) = 0xff;
- printf("RSTSRC register %02X
- ", M32(&SYS->RSTSRC));
- M32(&SYS->RSTSRC) = 0xff;
- printf("PWRCON register %08X
- ", M32(&SYSCLK->PWRCON));
- printf("XTLEN=%d, OSC49=%d OSC10=%d STOP=%d SBPD=%d DPD=%d
- ",
- SYSCLK->PWRCON.XTL32K_EN,
- SYSCLK->PWRCON.OSC49M_EN,
- SYSCLK->PWRCON.OSC10K_EN,
- SYSCLK->PWRCON.STOP,
- SYSCLK->PWRCON.STANDBY_PD,
- SYSCLK->PWRCON.DEEP_PD);
- printf("PIN_ENB=%d, DPD_10K=%d TIMER=%d PIN_WAKE=%d TIMER_WAKE=%d POI_WAKE=%d TIMER=%d
- ",
- SYSCLK->PWRCON.PIN_ENB,
- SYSCLK->PWRCON.OSC10K_ENB,
- SYSCLK->PWRCON.TIMER_SEL,
- SYSCLK->PWRCON.PIN_WAKE,
- SYSCLK->PWRCON.TIMER_WAKE,
- SYSCLK->PWRCON.POI_WAKE,
- SYSCLK->PWRCON.TIMER_SEL_RD);
- }
- void Smpl_DrvPMU_SPDGPABCallback(uint32_t u32GpaStatus, uint32_t u32GpbStatus)
- {
- //DrvGPIO_DisableInt(GPA, 1);
- //printf("GPIO Wake up from Standby-Power-Down Mode
- ");
- }
- void InitGPIOWakeupInSPD(void)
- {
- // Clear interrupts.
-
- GPIOB->ISRC = GPIOB->ISRC;
- ////INT from GPA pin1 as an example wake up
-
- DrvGPIO_Open(GPB, 6, IO_INPUT);
- DrvGPIO_SetIntCallback(Smpl_DrvPMU_SPDGPABCallback);
- DrvGPIO_SetDebounceTime(3, DBCLKSRC_HCLK);
- DrvGPIO_EnableDebounce(GPB, 6);
- //DrvGPIO_EnableInt(GPB, 6, IO_BOTH_EDGE, MODE_EDGE);
- DrvGPIO_EnableInt(GPB, 6, IO_FALLING, MODE_EDGE);
- }
- void LdoOn(void)
- {
- SYSCLK->APBCLK.ANA_EN=1;
- ANA->LDOPD.PD=0;
- ANA->LDOSET=3;
- SysTimerDelay(6000);
- }
- /*-----------------------------------------------------------------------------------*/
- /* Using UART for testing PMU Samples */
- /* Test Item */
- /* It sends the messages to HyperTerminal. */
- /*-----------------------------------------------------------------------------------*/
- int32_t main(void)
- {
- uint32_t u32Temp, u32Counter;
- uint8_t u8Item;
- //S_DRVRTC_TIME_DATA_T sInitcTime;
- // Initial SYSCLK
- Smpl_DrvPMU_SYSCLKinit();
- LdoOn(); //May have leakage if no power on GPA0~A7, marked this line if power provided from outside
- //Initial UART
- //Smpl_DrvPMU_UARTinit();
- //printf("
- SPD WakeUp Test.
- ");
- // Set GPA1 to input
- DrvGPIO_Open(GPB, 6, IO_INPUT);
- GPIOB->ISRC = GPIOB->ISRC;
-
- UNLOCKREG();
- SYSCLK->APBCLK.SBRAM_EN = 1; //Enable standby RAM
- u32Counter= SBRAM->D[0];
- if(SYSCLK-> PFLAGCON.PD_FLAG == 0) //If power on, not wakeup from SPD
- {
- DrvGPIO_Open(GPB,2, IO_OUTPUT); //Use GPIOB2 to know the problem point
- DrvGPIO_ClrBit(GPB,2);
- DrvGPIO_Open(GPB,3, IO_OUTPUT); //Use GPIOB3 to know the problem point
- DrvGPIO_ClrBit(GPB,3);
- DrvGPIO_Open(GPB,4, IO_OUTPUT); //Use GPIOB4 to know the problem point
- DrvGPIO_SetBit(GPB,4);
- //SYSCLK->APBCLK.RTC_EN = 1; //Enable RTC clock
- SYSCLK->APBCLK.SBRAM_EN = 1; //Enable standby RAM
- u32Counter=0;
- SBRAM->D[0]=0;
- //printf("First Power on
- =====================
- ");
- //printf("===================
- ");
- }
- else
- {
- DrvGPIO_ClrBit(GPB,4);
- u32Counter++;
- SBRAM->D[0]=u32Counter;
- if((u32Counter&1)==1)
- {
- DrvGPIO_SetBit(GPB,2);
- //printf("u32Counter= %4d, GPB2 high
- ",u32Counter);
- }
- else
- {
- DrvGPIO_ClrBit(GPB,2);
- //printf("u32Counter= %4d, GPB2 low
- ",u32Counter);
- }
- }
- //PrintPwrCon();
- SYSCLK-> PFLAGCON.PD_FLAG = 1; //Clear the Standby PD flag
- InitGPIOWakeupInSPD();
- DrvPMU_StandbyPowerDown();
- DrvGPIO_SetBit(GPB,3); //Not really enter SPD if this instruction executed, remove Nu-Link dongle(ICE)
- while(1);
- }
复制代码
MIC部分。
很多例程,都在资料里面写的很详细,这里就不一一给大家赘述了,
不过,再次感谢大大通的支持,
`
0
|
|
|
|