?? func_volume.c
字號:
/******************************************************************************
*
* Purpose: Func_Volume.c
*
* Creator: Paul v/d Linden
*
* Version: $Revision: 12 $
*
* File Name: $Workfile: Func_Volume.c $
*
* Author: Paul v/d Linden
*
* 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 <ina90.h> /* _CLI, _SEI */
/*
* Volume Message
* Byte 1 : 64
* Byte 2 : Volume (value 1 to 127)
* Byte 16 : Checksum.
*/
#define MSG_SINGLE_VOLUME_STRA 66 //0x42
#define MSG_SINGLE_VOLUME_STRB 67 //0x43
#define MSG_SINGLE_VOLUME_STRC 68 //0x44
#define MSG_SINGLE_VOLUME_STRD 69 //0x45
#define MSG_TYPE_VOLUME 64 /* 0x40 */
#define MSG_TYPE_WIRLESS_DATA 65
#define MSG_TYPE_AUDIO_CONTROL 0x81
unsigned char Volume_Memory = START_UP_VOLUME;
unsigned char StreamCode;
/******************************************************************************
*
* Function Name : Handle_Volume_MainLoop
*
* Purpose : Handel the Volume Procedure.
*
* Arguments : none
*
* Return value : none
*
******************************************************************************/
void Handle_Volume_MainLoop(void)
{
static unsigned char Prev_PREV_SW;
static unsigned char Prev_NEXT_SW;
static unsigned char Prev_PLAY_PAUSE_STOP_SW;
if (
(VOL_UP_SW == 0) ||
(VOL_DOWN_SW == 0)
)
{
Wait_For_mSec(20);
if (Use_ModuleMode == CU)
{
/*###### CU ######*/
DATA_LED_ON;
#ifdef CODEC_CS4341
if (VOL_UP_SW == 0x00)
{
if (Volume_Memory >= MAX_VOLUME + 2) Volume_Memory -= 2; /* UP */
}
else if (VOL_DOWN_SW == 0x00)
{
if (Volume_Memory < 126) Volume_Memory += 2; /* DOWN */
}
#else
if (VOL_UP_SW == 0x00)
{
if (Volume_Memory <= MAX_VOLUME - 2) Volume_Memory += 2; // * UP * /
}
else if (VOL_DOWN_SW == 0x00)
{
if (Volume_Memory > 1) Volume_Memory -= 2; // * DOWN * /
}
#endif
TX_Data_send_array[0] = MSG_TYPE_VOLUME;
TX_Data_send_array[1] = Volume_Memory;
if (Use_Speaker_Enable_Bits & 0x01) Send_Message(STR_A, 1);
if (Use_Speaker_Enable_Bits & 0x02) Send_Message(STR_B, 1);
#ifdef USE_DUAL_CODEC
if (Use_Speaker_Enable_Bits & 0x04) Send_Message(STR_C, 1);
if (Use_Speaker_Enable_Bits & 0x08) Send_Message(STR_D, 1);
#endif
//WM100 Display Volume
//DispMessageVol (2,Volume_Memory);
Prog_Volume(Volume_Memory);
DATA_LED_OFF;
} /* CU */
else
{
/*###### MU ######*/
/* just write Both Audio Streams */
DATA_LED_ON;
#ifdef CODEC_CS4341
if (VOL_UP_SW == 0x00)
{
if (Volume_Memory >= MAX_VOLUME + 2) Volume_Memory -= 2; /* UP */
}
else if (VOL_DOWN_SW == 0x00)
{
if (Volume_Memory < 126) Volume_Memory += 2; /* DOWN */
}
#else
if (VOL_UP_SW == 0x00)
{
if (Volume_Memory <= MAX_VOLUME - 2) Volume_Memory += 2; // * UP * /
}
else if (VOL_DOWN_SW == 0x00)
{
if (Volume_Memory > 1) Volume_Memory -= 2; // * DOWN * /
}
#endif
//WM100 Display Volume
//DispMessageVol (2,Volume_Memory);
Set_Volume();
Prog_Volume(Volume_Memory);
/* send new volume back to CU */
TX_Data_send_array[0] = MSG_TYPE_VOLUME;
TX_Data_send_array[1] = Volume_Memory;
if (Data_Free_Up)
{
Send_Message(STR_FREE, 1); /* use free slots in nack applic */
}
else
{
if (Use_Speaker_Enable_Bits & 0x01) Send_Message(STR_A, 1);
else if (Use_Speaker_Enable_Bits & 0x02) Send_Message(STR_B, 1);
else if (Use_Speaker_Enable_Bits & 0x04) Send_Message(STR_C, 1);
else if (Use_Speaker_Enable_Bits & 0x08) Send_Message(STR_D, 1);
}
DATA_LED_OFF;
} /* MU */
} /* VOL_UP_SW | VOL_DOWN_SW */
if ((Prev_PREV_SW != PREV_SW) && (Use_ModuleMode == MU))
{
Prev_PREV_SW = PREV_SW;
if(PREV_SW == 0)
{
DATA_LED_ON;
TX_Data_send_array[0] = MSG_TYPE_WIRLESS_DATA;
TX_Data_send_array[1] = 0x03;
if (Data_Free_Up)
{
Send_Message(STR_FREE, 1); /* use free slots in nack applic */
}
else
{
if (Use_Speaker_Enable_Bits & 0x01) Send_Message(STR_A, 1);
else if (Use_Speaker_Enable_Bits & 0x02) Send_Message(STR_B, 1);
else if (Use_Speaker_Enable_Bits & 0x04) Send_Message(STR_C, 1);
else if (Use_Speaker_Enable_Bits & 0x08) Send_Message(STR_D, 1);
}
DATA_LED_OFF;
}
}
if ((Prev_NEXT_SW != NEXT_SW) && (Use_ModuleMode == MU))
{
Prev_NEXT_SW = NEXT_SW;
if (NEXT_SW == 0)
{
DATA_LED_ON;
TX_Data_send_array[0] = MSG_TYPE_WIRLESS_DATA;
TX_Data_send_array[1] = 0x02;
if (Data_Free_Up)
{
Send_Message(STR_FREE, 1); /* use free slots in nack applic */
}
else
{
if (Use_Speaker_Enable_Bits & 0x01) Send_Message(STR_A, 1);
else if (Use_Speaker_Enable_Bits & 0x02) Send_Message(STR_B, 1);
else if (Use_Speaker_Enable_Bits & 0x04) Send_Message(STR_C, 1);
else if (Use_Speaker_Enable_Bits & 0x08) Send_Message(STR_D, 1);
}
DATA_LED_OFF;
}
}
if ((Prev_PLAY_PAUSE_STOP_SW != PLAY_PAUSE_STOP_SW) && (Use_ModuleMode == MU))
{
Prev_PLAY_PAUSE_STOP_SW = PLAY_PAUSE_STOP_SW;
if (PLAY_PAUSE_STOP_SW == 0)
{
DATA_LED_ON;
TX_Data_send_array[0] = MSG_TYPE_WIRLESS_DATA;
TX_Data_send_array[1] = 0x09;
if (Data_Free_Up)
{
Send_Message(STR_FREE, 1); /* use free slots in nack applic */
}
else
{
if (Use_Speaker_Enable_Bits & 0x01) Send_Message(STR_A, 1);
else if (Use_Speaker_Enable_Bits & 0x02) Send_Message(STR_B, 1);
else if (Use_Speaker_Enable_Bits & 0x04) Send_Message(STR_C, 1);
else if (Use_Speaker_Enable_Bits & 0x08) Send_Message(STR_D, 1);
}
DATA_LED_OFF;
}
}
}
/******************************************************************************
*
* Function Name : Handle_Volume_RXMsg
*
* Purpose : Handle Incomming Volume Messages.
*
* Arguments : none
*
* Return value : none
*
******************************************************************************/
void Handle_Volume_RXMsg(void)
{
unsigned char CheckEqual=0;
if (Use_ModuleMode == MU)
{
/*###### MU ######*/
//WM100 Modification to the data received
if( RX_Data_recv_array[0] == MSG_TYPE_AUDIO_CONTROL){
//printf("Enter switch case.\r");
DATA_LED_ON;
Data_Led_Counter = 10; /* after 100 mSec Data Led goes OFF again*/
StreamCode = RX_Data_recv_array[1];
/* just write Both Audio Streams */
//printf("StreamCode = %X\r",RX_Data_recv_array[1]);
switch(StreamCode) //only press button status is activated //RX_Data_recv_array[1] == )
{
case 0: if(Flip_Status == 0) Volume_Memory = RX_Data_recv_array[2];
break;
case 1: if(Flip_Status == 1) Volume_Memory = RX_Data_recv_array[2];
break;
case 2: if(Flip_Status == 2) Volume_Memory = RX_Data_recv_array[2];
break;
case 3: if(Flip_Status == 3) Volume_Memory = RX_Data_recv_array[2];
break;
case 7:
Volume_Memory = RX_Data_recv_array[2];
break;
default:
CheckEqual = 1;
}
if(CheckEqual == 0) Set_VolumeToPipe(0);
//}
}
/* do not make big delays in this receive section, you loose data due to timeout on DARR79 */
//}
}
else
{
/*###### CU ######*/
if (RX_Data_recv_array[0] == MSG_TYPE_VOLUME)
{
DATA_LED_ON;
Data_Led_Counter = 10; /* after 100 mSec Data Led goes OFF again*/
Volume_Memory = RX_Data_recv_array[1]; /* Volume changed on MU, update CU */
}
}
Prog_Volume(Volume_Memory);
}
/******************************************************************************
*
* Function Name : Get_Volume
*
* Purpose : Get the contents of the Volume_Memory
*
* Arguments : none
*
* Return value : Volume_Memory
*
******************************************************************************/
unsigned char Get_Volume(void)
{
_CLI();
_EEGET(Volume_Memory, 0x12);
_SEI();
return(Volume_Memory);
}
/******************************************************************************
*
* Function Name : Set_Volume
*
* Purpose : Set the Volume of Codec line in channel.
*
* Arguments : none
*
* Return value : none
*
******************************************************************************/
void Set_Volume(void)
{
if (ApplicType != APPL_TYPE_MICROPHONE)
{
SetVolume(0x00, Volume_Memory); /* Left */
SetVolume(0x01, Volume_Memory); /* Right */
#ifdef USE_DUAL_CODEC
SetVolume(0x02, Volume_Memory); /* Left */
SetVolume(0x03, Volume_Memory); /* Right */
#endif
}
else
{
#ifndef PCB_EVK_2CH
SetInVolume(0x00, Volume_Memory); /* Left */
SetInVolume(0x01, Volume_Memory); /* Right */
#ifdef USE_DUAL_CODEC
SetInVolume(0x02, Volume_Memory); /* Left */
SetInVolume(0x03, Volume_Memory); /* Right */
#endif
#endif /* END PCB_EVK_2CH */
}
}
//WM100 New SetVolume function
void Set_VolumeToPipe(unsigned char PipeNR)
{
//int div;
if (ApplicType != APPL_TYPE_MICROPHONE)
{
if (StreamCode == 7) {
SetVolume(PipeNR, Volume_Memory); /* Left */
//#ifdef USE_DUAL_CODEC
// SetVolume(0x02, Volume_Memory); /* Left */
// SetVolume(0x03, Volume_Memory); /* Right */
//#endif
}
else {
SetVolume(PipeNR, Volume_Memory); //Set to Pipe W
//WM100 Dsiplay Volume
//DispMessageVol (2,Volume_Memory);
//LCDPutChar(0xFF,0xff,'a');
//WM
}
}
else
{
#ifndef PCB_EVK_2CH
SetInVolume(0x00, Volume_Memory); /* Left */
SetInVolume(0x01, Volume_Memory); /* Right */
#ifdef USE_DUAL_CODEC
SetInVolume(0x02, Volume_Memory); /* Left */
SetInVolume(0x03, Volume_Memory); /* Right */
#endif
#endif /* END PCB_EVK_2CH */
}
}
/******************************************************************************
*
* Function Name : Restore_Volume
*
* Purpose : Restore Volume_Memory and Set Volume on Codec or DARR79 reg.
*
* Arguments : Volume
*
* Return value : none
*
******************************************************************************/
void Restore_Volume(unsigned char Volume)
{
Volume_Memory = Volume;
Set_Volume();
}
/******************************************************************************
*
* Function Name : Prog_Volume
*
* Purpose :
*
* Arguments : Volume
*
* Return value : none
*
******************************************************************************/
void Prog_Volume(unsigned char Volume)
{
_CLI();
_EEPUT(0x12, Volume);
_SEI();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -