在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 基于新唐M0的M0516LAN的SIM900A的驅(qū)動測試

            基于新唐M0的M0516LAN的SIM900A的驅(qū)動測試

            作者: 時間:2016-11-29 來源:網(wǎng)絡(luò) 收藏
            基于新唐M0的M0516LAN的SIM900A的驅(qū)動測試

            元旦放假,急于趕一個小項(xiàng)目,做了一個M0516LAN驅(qū)動SIM900A的測試。第一次用SIM900A,其中遇到幾個小問題,調(diào)了好久,也問過群里用過SIM900A的幾位朋友才調(diào)通,在此感謝。最弱智的問題是我把NRESET接到了PWM3上,然后又啟動了PWM3,雖然后面把P43置成IO輸出卻不成功,然后大半晚上就那么悲劇掉了。新唐的庫是置成了復(fù)用功能再想置回IO,需要先DrvGPIO_InitFunction(E_FUNC_GPIO);才能配置IO功能的。我后來還是不啟動PWM就通過了開機(jī)過程。只要SIM900A開機(jī)了,NETLIGHT的LED就會閃爍,不管有沒有SIM卡。另外,所有SIM900A的AT命令都是以“”結(jié)束的。

            本文引用地址:http://www.biyoush.com/article/201611/323195.htm

            “sim900a.c ”文件源碼如下:

            #include
            #include

            #include "DriverDrvUART.h"
            #include "DriverDrvGPIO.h"
            #include "DriverDrvSYS.h"

            #define PWRKEY E_PORT2, E_PIN1
            #define NRESETE_PORT4, E_PIN3
            #define STATUS E_PORT2, E_PIN3
            #define RIE_PORT3, E_PIN2
            #define CTSE_PORT0, E_PIN0
            /*
            _________________________________________________
            |M0516LANSIM900A|
            ||
            |P21PWRKEY---->PWRKEY|
            |P43NRESET---->NRESET|
            |P23STATUS<----STATUS|
            |P32RI<----RI|
            |P00CTS1<----CTS|
            |P13TXD1---->RXD|
            |P12RXD1<----TXD|
            |_______________________________________________|
            */
            int UART1_init(void)
            {
            STR_UART_T sParam;

            /* Set UART1 Pin */
            DrvGPIO_InitFunction(E_FUNC_UART1);
            //outpw(&SYS->P1_MFP, (inpw(&SYS->P1_MFP) | (0x3<<10)) & ~(0x3<<2));
            //outpw(&SYS->P0_MFP, (inpw(&SYS->P0_MFP) | (0x3<<8)) & ~(0x3<<0));

            /* Select UART1 Clock Source From 12Mhz*/
            DrvSYS_SelectIPClockSource(E_SYS_UART_CLKSRC,0);

            /* UART1 Setting */
            sParam.u32BaudRate = 9600;
            sParam.u8cDataBits = DRVUART_DATABITS_8;
            sParam.u8cStopBits = DRVUART_STOPBITS_1;
            sParam.u8cParity = DRVUART_PARITY_NONE;
            sParam.u8cRxTriggerLevel= DRVUART_FIFO_1BYTES;

            if(DrvUART_Open(UART_PORT1,&sParam) != E_SUCCESS)
            {
            printf("UART1 open failed");
            return FALSE;
            }
            /* Enable Interrupt and install the call back function */
            //DrvUART_EnableInt(UART_PORT1, (DRVUART_RLSINT | DRVUART_RDAINT),UART1_INT_HANDLE);

            /* Disable Interrupt */
            //DrvUART_DisableInt(UART_PORT1,DRVUART_RLSINT | DRVUART_THREINT | DRVUART_RDAINT);

            return TRUE;
            }

            int SIM900A_Open(void)
            {
            int dly;

            DrvGPIO_ClrBit(PWRKEY);
            for(dly=0;dly<2000;dly++)DrvSYS_Delay(1000); //delay 1S
            DrvGPIO_SetBit(PWRKEY);

            for(dly=0;dly<3000;dly++)DrvSYS_Delay(1000); //delay 3S
            if(DrvGPIO_GetBit(STATUS))
            {
            printf("SIM900A Open Success!!!");
            return 1;
            }
            else
            {
            printf("SIM900A Open Failure!!!");
            return 0;
            }
            }

            int SIM900A_Close(void)
            {
            int dly;

            DrvGPIO_ClrBit(PWRKEY);
            for(dly=0;dly<6000;dly++)DrvSYS_Delay(1000); //delay 1S-5S
            DrvGPIO_SetBit(PWRKEY);

            for(dly=0;dly<4000;dly++)DrvSYS_Delay(1000); //delay 2S

            if(DrvGPIO_GetBit(STATUS))
            {
            printf("SIM900A Close Failure!!!");
            return 1;
            }
            else
            {
            printf("SIM900A Close Success!!!");
            return 0;
            }
            }

            int SIM900A_Reset(void)
            {
            int dly;

            DrvGPIO_ClrBit(NRESET);
            DrvSYS_Delay(100); //delay 20uS-50uS
            DrvGPIO_SetBit(NRESET);

            for(dly=0;dly<2000;dly++)DrvSYS_Delay(1000); //delay 2S
            if(DrvGPIO_GetBit(STATUS)==1)
            return 1;
            else
            return 0;
            }
            int SIM900A_init(void)
            {
            int ret =0;

            DrvGPIO_Open(STATUS, E_IO_INPUT);
            DrvGPIO_Open(RI, E_IO_INPUT);
            DrvGPIO_Open(CTS, E_IO_INPUT);
            DrvGPIO_Open(PWRKEY, E_IO_OUTPUT);
            DrvGPIO_Open(NRESET, E_IO_OUTPUT);

            DrvGPIO_SetBit(PWRKEY);
            DrvGPIO_SetBit(NRESET);

            ret = SIM900A_Open();
            UART1_init();

            return ret;
            }


            上一頁 1 2 下一頁

            評論


            技術(shù)專區(qū)

            關(guān)閉