www.pudn.com > headset.rar > ring.c
#include "demohs.h" #include "hal.h" #include#ifdef DEV_BOARD_HS #include #endif static const audio_note twilight[] = { AUDIO_TEMPO(180), AUDIO_VOLUME(64), AUDIO_TIMBRE(sine), AUDIO_NOTE(E7, QUAVER), AUDIO_NOTE(F7, QUAVER), AUDIO_NOTE(E7, QUAVER), AUDIO_NOTE(C7, QUAVER), AUDIO_NOTE(E7, QUAVER), AUDIO_NOTE(F7, QUAVER), AUDIO_NOTE(E7, QUAVER), AUDIO_NOTE(C7, QUAVER), AUDIO_END }; #ifdef DEV_BOARD_HS static Delay delayRingPlay(TimerHandle h) { /* keep the compiler happy */ h=h; /* play the ring tone */ hsState.AudioRingHandle = AudioPlay(twilight); return D_NEVER; } #endif /* ringInd Called by the headset framework to tell us that a RING command has been received over RFCOMM (state =1) or that the ring duration has expired (state = 0) */ void ringInd(const HS_RING_IND_T * ind) { #ifdef DEV_BOARD_HS if(ind->state) { /* enable the codec */ PioSet(PIO_CODEC, CODEC_ON); /* small delay */ TimerAdd(D_mSEC(100), delayRingPlay); } else { if (!hsState.scoConnected) { /* disable the codec only if there is no sco up otherwise we'll be in trouble */ PioSet(PIO_CODEC, CODEC_OFF); } } #else if (ind->state) hsState.AudioRingHandle = AudioPlay(twilight); #endif }