📄 main.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 = MAXIM 2830 Revision 1 (should always be zero)
* Bit 7 : 1 = Startup Sniffer on
*
* 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 Compressed during audio transfer.
*
* ConfigByte 3:
* Bit 0 : 1 = CU_With_Standalone_MU
* Bit 1 : free
* Bit 2 : 1 = Monitor_Func
* Bit 3 : 1 = MUCU Swap function active i.s.o. sniff
* Bit 4-7 : free
*
* Creator: Rob Lansbergen
*
* Version: $Revision: 5 $
*
* File Name: $Workfile: main.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 <ina90.h>
#include <stdio.h>
#include "defines.h"
int Key_PB2,PB0_Delay_High_Count;
char key_low,key_high,key_state;
char pb0_mute_delay_count0,pb0_mute_delay_count1; //delay 0.5s
/** For more information about this code check the Application node 2 **/
void MCU_Sleep_Idle(void);
void main(void)
{
Key_PB2=0;
PB0_Delay_High_Count=0;
pb0_mute_delay_count0=0;
pb0_mute_delay_count1=0;
key_low=0;
key_high=0;
key_state=0;
MCU_init();
DDRB = DDRB | 0x03; /* set PB 0, 1 to high OUT*/
DDRB = DDRB & 0xFB; /* 1111 1011 set PB 2 to LOW IN */
PORTB = PORTB & 0xFE; //PB0=0//
PORTB = PORTB | 0x02; //PB1=1//
pd5_mute_ctrl(0);
#ifdef CONT_TXRX
Cont_TX_RX(1, 3, 0); /* CONT_TX | RF3 | Ant A */
#else
/* This define is declared in MCU_Func.h */
FILL_CONFIG_BYTES; /* Fills the 3 config bytes to define application see top of source code */
init_application();
/* start DFE loop */
while (1)
{
if(PB0_Delay_High_Count!=300) //delay 3s
{
PB0_Delay_High_Count=PB0_Delay_High_Count+1;
if(PB0_Delay_High_Count==300)
{
PORTB=PORTB | 0x01;
}
}
Key_PB2=Key_PB2+1;
if(Key_PB2==20)
{
if(VOL_Close_Open_SW==0)
{
key_low=1;
key_high=0;
}
else
{
key_high=1;
if((key_low==1) &&(key_high==1))
{
if (!key_state)
{
key_state=1;
PORTB = PORTB & 0xFD; //PB1=0; mute
}
else
{
key_state=0;
PORTB = PORTB | 0x02; //PB1=1; no mute
}
}
key_low=0;
}
Key_PB2=0;
}
SetVolume_CS4341(0x00, 0x00);
Check_Application_Events();
/* Poll interrupt */
if (CHECK_INTERRUPT_PIN)
{
DARR_Interrupt_Handler();
}
// MCU_Sleep_Idle();
}
#endif
} /* end main */
void Write_Eeprom(void)
{
/*** This function should program the configuration bytes to Eeprom ***/
}
void MCU_Sleep_Idle(void)
{
MCUCR = MCUCR | 0x80; /* Set Sleep to Idle Mode */
_SLEEP(); /* Enter Sleep */
/* Important note: */
/* During Idle mode, ADC will automatically start to run in single conversion mode when CPU halts */
/* Analog input ADC6 is used to acquire battery level. */
/* When battery level falls below 2.8V, Codec shuts down and LED blinks */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -