pioag_init.c

来自「bluetooth audio gateway」· C语言 代码 · 共 56 行

C
56
字号

#include "pioag.h"
#include "pioag_private.h"
#include "ag.h"

#include <button.h>
#include <pio.h>
#include <ps.h>
#include <string.h>
#include <timer.h>


struct PioAgStruct PioAgState;


/*
    pioAgInit

    Called as soon as the application starts up. This function starts 
    up the Embedded Audio Gateway (EAG) by calling its start function
    This function initialises the application layer and IO blocks.
    The state variables are reset and the timers enabled.
*/
void pioAgInit(void)
{   
    uint16 pin_length = 0;

    /* Initialise PIOs used for MMI */
    PioSetDir((LED1 | LED2), ~0);
       
    /* Initialise Buttons - change function depending on end hardware */
    ButtonInit((PIO_ENTER1 | PIO_ENTER2), ButtonOrGate); /* ButtonDirect */

    /* Initialise State Variable */        
    PioAgState.pinLengthBytes = 0;
    PioAgState.pinCode = 0;    
    PioAgState.inquiryComplete = 0;    
    PioAgState.connectAsSlave = 0;    
    PioAgState.timerHandle = NULL_TIMER;
    PioAgState.connectionTimerHandle = NULL_TIMER;
    PioAgState.handle = UNDEFINED_HANDLE;    

    /* Check the PS to decide if we have a PIN or not */
    if(PsRetrieve(PIO_AG_PS_PIN_LENGTH, &pin_length, 1) && pin_length)
        PioAgState.pinEntered = 1;
    else
        PioAgState.pinEntered = 0;

    /* 
        Start the application - for now it is assumed that this interface
        of the Audio Gateway only supports the Headset Profile AG and not the
        Hands-Free AG 
    */
    startReqAction(0, agHeadsetProfile);
}

⌨️ 快捷键说明

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