?? main_func.c
字號:
/******************************************************************************
*
* Purpose: Example Code for different applications
*
* the different applications are configured by 3 config bytes
*
* ConfigByte 1:
* Bit 0-4 : Application selection
* Bit 5 : 1 = MU, 0 = CU
* Bit 6 : 1 = Use Continuous RX TX
* Bit 7 : 1 = Use MU CU Swap
*
* ConfigByte 2:
* Bit 0-3 : Stream Enable
* Bit 4 : 1 = Auto Snooze enable auto powerdown when no audio is detected
* Bit 5 : Reserved (Production) (should always be zero)
* Bit 6 : 1 = Use SPDIF as Audio Interface | 0 = I2S
* Bit 7 : 1 = Use Nack Report
*
* ConfigByte 3:
* Bit 0 : 1 = Use Own WLAN Detection
* Bit 1-6 : free
* Bit 7 : 1 = Use automatic application detection (MU only)
*
*
* Creator: Rob Lansbergen
*
* Version: $Revision: 55 $
*
* File Name: $Workfile: main_func.c $
*
* Author: Rob Lansbergen
*
* Check in: $Author: Chong.cheeleong $
*
* The information is provided 揳s is?without any express or implied warranty
* of any kind, * including warranties of merchantability, noninfringement of
* intellectual property, or fitness for any particular purpose. In no event sha
* Wireless Sound Solutions and/or its affiliate companies, or its suppliers be
* liable for any damages whatsoever arising out of the use of or inability to
* use the information or the materials. Wireless Sound Solutions, its affiliate
* companies, and its suppliers further do not warrant the accuracy or
* completeness of information, text, graphics, or other items contained within
* materials. Wireless Sound Solutions, Inc., may make changes to materials, or
* the products described within, at any time, without notice.
* ?007 Wireless Sound Solutions. All rights reserved. Wireless Sound Solutions
* STS and STS-wireless are trademarks of Wireless Sound Solutions.
*******************************************************************************/
/*
** Include files
** -------------
*/
#include <stdio.h>
#include "defines.h"
#include "main.h"
/*
** Public data definitions
** -----------------------
*/
APPLIC_MODE_TYPE Use_ModuleMode = MU;
TYPE_LED_STATE Sync_Led_Status = LED_OFF;
unsigned char Use_Application = 0;
unsigned char Use_Continuous_RX_TX = 0;
unsigned char Use_Speaker_Enable_Bits = 0;
unsigned char Use_Audio_Detection = 0;
unsigned char Use_SPDIF = 0;
unsigned char Use_NackReport = 0;
//unsigned char Use_CU_With_Standalone_MU = 0; /* MU Running with Eeprom */
unsigned char Use_MU_CU_Swap = 0;
unsigned char Use_I2C_Log_Write = 0;
unsigned char Use_I2C_Log_Read = 0;
unsigned char Use_Own_WLAN_Detection = 0;
unsigned char Use_MAX2834 = 0;
unsigned char Use_Auto_Config = 0;
unsigned char ApplicType = 0;
unsigned char Data_Free_Up = 0;
unsigned char InSync_Detected = 0;
unsigned char Error_Code = 1;
unsigned char Connect_Bit = BIT_CONNECT;
unsigned char Data_Led_Counter = 0;
unsigned char Config_Byte1;
unsigned char Config_Byte2;
unsigned char Config_Byte3;
unsigned char Config_Byte4;
//unsigned char DispQuinData;
volatile unsigned char Quin_Counter = 0;
volatile unsigned char Flip_Counter = 0;
volatile unsigned char Error_Prescaler = 0;
volatile unsigned char Sec_Prescaler = 0;
volatile unsigned char MS100_Prescaler;
volatile unsigned char NAMG_200=0;
volatile unsigned char Sec_Event = 0;
volatile unsigned char Event_NACK = 0;
volatile unsigned char SA_Event_NACK = 0;
volatile unsigned char NACK_Sample_Time = 0;
volatile unsigned char amal_reg = 0;
volatile unsigned char Event_FLIP = 0;
volatile int RND_Value;
volatile unsigned char Rx_Events=0;
volatile unsigned char Mute_flag = 0 ; //有 mute message 標記 0=沒有 mute; 1=已經mute
volatile unsigned char NoAudio_flag = 0 ; //沒有 Audio 信號標記. 當收到TX 的 message后, 若是無audio 信息,則 NoAudio_flag=1; 若有audio信息, 則NoAudio_flag=0;
volatile unsigned char Mute_flash_flag = 0 ; //有 mute message 時閃燈標記
volatile unsigned char Mute_flash_Cnt ; // 有 mute message 時閃燈時間計時器記
volatile unsigned char NoSync_cnt=200; //沒有RF連接計時器, 初始值200 = 200*10ms = 2S
char key_mute;
extern int PB0_Delay_High_Count;
extern char pb0_mute_delay_count0,pb0_mute_delay_count1; //delay 0.5s
void init_application(void);
/*
** Private macro constants
** -----------------------
*/
/*
** Private type definitions
** ------------------------
*/
/*
** Private function prototypes
** ---------------------------
*/
/*
** Private data definitions
** ------------------------
*/
/*
** Private macro functions
** -----------------------
*/
/*
** Public functions
** ----------------
*/
/******************************************************************************
*
* Function Name : init_application
*
* Purpose : Initialisation procedure of the application
*
* Arguments : none
*
* Return value : none
*
******************************************************************************/
void init_application(void)
{
#ifdef DEBUG
Wait_For_mSec(50); /* DEBUG_ONLY :Until internal RC has stable clock for RS232 */
putstring("STS\r");
Wait_For_mSec(50);
putstring("Config_Byte1 = ");
puthex(Config_Byte1);
putchar('\r');
putstring("Config_Byte2 = ");
puthex(Config_Byte2);
putchar('\r');
putstring("Config_Byte3 = ");
puthex(Config_Byte3);
putchar('\r');
#endif
RESET_DARR(0);
Wait_For_mSec(100); /* delay to make sure the reset goes low (RC time) */
RESET_DARR(1);
Wait_For_mSec(100);
putstring("Reset DARR80 Up\r");
/* Move Config byte bits to readably variables */
Use_Application = Config_Byte1 & 0x1F; //=2
/* Setup Global Config Data */
if (Config_Byte1 & 0x20) {Use_ModuleMode = MU;}
else {Use_ModuleMode = CU;}
Use_Continuous_RX_TX = (Config_Byte1 & 0x40) >> 6; //=0
Use_MU_CU_Swap = (Config_Byte1 & 0x80) >> 7; //=0
Use_Speaker_Enable_Bits = Config_Byte2 & 0x0F; //=7
Use_Audio_Detection = (Config_Byte2 & 0x10) >> 4; //=0
Use_SPDIF = (Config_Byte2 & 0x40) >> 6; //=0
Use_NackReport = (Config_Byte2 & 0x80) >> 7; //=1
Use_Own_WLAN_Detection = Config_Byte3 & 0x01; //=1
Use_Auto_Config = Config_Byte3 & 0x80; //=0
if(Use_Auto_Config)
{
//Auto_Configuration_State = InSync_Leadtime;
Config_Byte2 |= 0x80;
Use_NackReport = 1; /* Nack report is needed when using auto Config */
//printf("Nack Report\r");
}
/******************************/
/*** Load global ApplicType ***/
/******************************/
ApplicType = APPL_TYPE_NACK;
if (Use_Application == 4) ApplicType = APPL_TYPE_HEADSET;
if (Use_Application == 5) ApplicType = APPL_TYPE_HEADSET;
if ((Use_ModuleMode == MU) && (ApplicType == APPL_TYPE_NACK))
{
#ifdef DEBUG
putstring("Data_Free_Up set NACK\r");
#endif
Data_Free_Up = 1;
}
else
{
Data_Free_Up = 0;
}
if (Use_Continuous_RX_TX) //maybe no used
{
//putstring("Loading Continuous Mode\r");
if (Use_ModuleMode == MU) Cont_TX_RX(0, 2, 0);
else Cont_TX_RX(1, 2, 0);
}
// /*-------------//Allan add-------------------
CODEC_RESET(0); // * Reset * /
// * Initialise DARR80 * /
if (Init_DARR() != 0)
{
Sync_Led_Status = LED_INIT_ERROR;
Error_Code = 1; // * blink one's every 4 seconds * /
while(1){}; // * init error * /
}
//CODEC_RESET(1); // * Remove reset * /
// //-------------//Allan add-------------------*/
#ifdef Target_MU
Wait_For_mSec(100);
/* Configure Codec */
if (Config_Codec() != 0)
{
Sync_Led_Status = LED_INIT_ERROR;
Error_Code = 2; /* blink twice's every 4 seconds */
while(1){}; /* init error */
}
#else
#endif
/*
// * Initialise DARR80 * /
if (Init_DARR() != 0)
{
#ifdef DEBUG
putstring("Init_DARR ERROR\r");
#endif
Sync_Led_Status = LED_INIT_ERROR;
Error_Code = 1; // * blink one's every 4 seconds * /
while(1){}; // * init error * /
}
*/
/* Check Global Config Data Consistency II, with ApplicType set */
if (
(Use_ModuleMode == MU) &&
(ApplicType != APPL_TYPE_MICROPHONE)
)
{
Use_Audio_Detection = 0;
}
/* Setup volume correction */
if (ApplicType == APPL_TYPE_MICROPHONE)
{
Volume_Memory = 0x17 << 3;
}
/* init Connect Procedure */
Handle_Connect_Init();
/* init Own WLAN Detection Procedure */
if (Use_Own_WLAN_Detection) //maybe no used
{
Handle_Own_WLAN_Detection_Init();
BadLink_Cnt = 50;
}
/* init Auto_Configuration Detection Procedure */
Auto_Configuration_State = InSync_Leadtime;
#ifdef PCB_PNP80_UNIVERSAL_TRX
Sync_Led_Status = LED_SYNC_STATUS;
#endif
} /* END init_application */
/******************************************************************************
*
* Function Name : Check_Application_Events
*
* Purpose : Main application DFE loop functions
*
* Arguments : none
*
* Return value : none
*
******************************************************************************/
void Check_Application_Events(void)
{
if (Use_ModuleMode==MU)
{
/* Codec Power Control */
// Codec_PowerControl(InSync_Detected);
}
if((Use_ModuleMode == MU)&&(Use_Continuous_RX_TX == 0)&&(Use_MU_CU_Swap ==0))
{
/********************************************/
/*** Automatic Detection Application by MU ***/
/********************************************/
if(Use_Auto_Config)
{
Handle_Auto_Config_Detection_MainLoop();
}
}
/************************/
/*** Connected Button ***/
/************************/
Handle_Connect_MainLoop();
/**********************/
/*** Volume Buttons ***/
/**********************/
Handle_Volume_MainLoop();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -