Merge of the 2 sound_5ms() and audio.heartbeat() functions. Perhaps will be reverted, depending on what Mike thinks of it...
This commit is contained in:
@@ -419,7 +419,7 @@ extern "C" void TC2_IRQHandler()
|
|||||||
dummy = TC0->TC_CHANNEL[2].TC_SR;
|
dummy = TC0->TC_CHANNEL[2].TC_SR;
|
||||||
(void) dummy ; // Discard value - prevents compiler warning
|
(void) dummy ; // Discard value - prevents compiler warning
|
||||||
|
|
||||||
sound_5ms() ;
|
AUDIO_HEARTBEAT();
|
||||||
|
|
||||||
if ( ++pre_scale >= 2 ) {
|
if ( ++pre_scale >= 2 ) {
|
||||||
Tenms |= 1 ; // 10 mS has passed
|
Tenms |= 1 ; // 10 mS has passed
|
||||||
|
|||||||
+39
-45
@@ -42,10 +42,6 @@ audioQueue::audioQueue()
|
|||||||
t_queueWidx = 0;
|
t_queueWidx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define QUEUE_TONE(tf,ttl,tfi) queueTone(tf * 61 / 2, ttl * 10, tfi * 61 / 2)
|
|
||||||
|
|
||||||
|
|
||||||
// heartbeat is responsibile for issueing the audio tones and general square waves
|
// heartbeat is responsibile for issueing the audio tones and general square waves
|
||||||
// it is essentially the life of the class.
|
// it is essentially the life of the class.
|
||||||
// it is called every 10ms
|
// it is called every 10ms
|
||||||
@@ -55,56 +51,49 @@ void audioQueue::heartbeat()
|
|||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (toneTimeLeft == 0) {
|
|
||||||
if (tonePause == 0) {
|
|
||||||
if (t_queueRidx != t_queueWidx) {
|
|
||||||
toneFreq = queueToneFreq[t_queueRidx];
|
|
||||||
toneTimeLeft = queueToneLength[t_queueRidx];
|
|
||||||
toneFreqIncr = queueToneFreqIncr[t_queueRidx];
|
|
||||||
tonePause = queueTonePause[t_queueRidx];
|
|
||||||
if ((toneFreq == 0) || (toneTimeLeft == 0)) {
|
|
||||||
//SPEAKER_OFF;
|
|
||||||
}
|
|
||||||
if (!queueToneRepeat[t_queueRidx]--) {
|
|
||||||
t_queueRidx = (t_queueRidx + 1) % AUDIO_QUEUE_LENGTH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ((tone2Freq == 0) & (tone2TimeLeft == 0)) {
|
|
||||||
//SPEAKER_OFF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((toneFreq > 0) & (toneTimeLeft > 0)) {
|
|
||||||
QUEUE_TONE(toneFreq, toneTimeLeft, toneFreqIncr);
|
|
||||||
}
|
|
||||||
else if (((tone2Freq > 0) & (tone2TimeLeft > 0)) & (tonePause == 0)) {
|
|
||||||
//second flow tone here, priority on 1st, pause of 1st not allow to start second
|
|
||||||
QUEUE_TONE(tone2Freq, tone2TimeLeft, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toneTimeLeft > 0) {
|
if (toneTimeLeft > 0) {
|
||||||
|
if (toneChanged) {
|
||||||
|
toneChanged = 0;
|
||||||
|
set_frequency(toneFreq);
|
||||||
|
tone_start(0);
|
||||||
|
}
|
||||||
|
else if (toneFreqIncr && (toneTimeLeft&1) == 0) {
|
||||||
|
toneFreq += toneFreqIncr;
|
||||||
|
set_frequency(toneFreq);
|
||||||
|
}
|
||||||
toneTimeLeft--; //time gets counted down
|
toneTimeLeft--; //time gets counted down
|
||||||
toneFreq += toneFreqIncr;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (tonePause > 0) {
|
if (tonePause > 0) {
|
||||||
|
DACC->DACC_IDR = DACC_IDR_ENDTX ; // Disable interrupt
|
||||||
// SPEAKER_OFF;
|
// SPEAKER_OFF;
|
||||||
tonePause--; //time gets counted down
|
tonePause--; //time gets counted down
|
||||||
}
|
}
|
||||||
}
|
else if (t_queueRidx != t_queueWidx) {
|
||||||
|
toneChanged = 1;
|
||||||
if (tone2TimeLeft > 0) {
|
toneFreq = queueToneFreq[t_queueRidx];
|
||||||
tone2TimeLeft--; //time gets counted down
|
toneTimeLeft = queueToneLength[t_queueRidx];
|
||||||
}
|
toneFreqIncr = queueToneFreqIncr[t_queueRidx];
|
||||||
else {
|
tonePause = queueTonePause[t_queueRidx];
|
||||||
if (toneTimeLeft == 0) {
|
if (!queueToneRepeat[t_queueRidx]--) {
|
||||||
//SPEAKER_OFF;
|
t_queueRidx = (t_queueRidx + 1) % AUDIO_QUEUE_LENGTH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (tone2Pause > 0) {
|
else {
|
||||||
tone2Pause--; //time gets counted down
|
if (tone2TimeLeft > 0) {
|
||||||
|
if (tone2Changed) {
|
||||||
|
tone2Changed = 0;
|
||||||
|
set_frequency(toneFreq);
|
||||||
|
tone_start(0);
|
||||||
|
}
|
||||||
|
tone2TimeLeft--; //time gets counted down
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DACC->DACC_IDR = DACC_IDR_ENDTX ; // Disable interrupt
|
||||||
|
if (tone2Pause > 0) {
|
||||||
|
tone2Pause--; //time gets counted down
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +113,11 @@ inline uint8_t audioQueue::getToneLength(uint8_t tLen)
|
|||||||
void audioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
|
void audioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
|
||||||
uint8_t tFlags, int8_t tFreqIncr)
|
uint8_t tFlags, int8_t tFreqIncr)
|
||||||
{
|
{
|
||||||
|
// tLen *= 10;
|
||||||
|
// tPause *= 10;
|
||||||
|
|
||||||
if (tFlags & PLAY_SOUND_VARIO) {
|
if (tFlags & PLAY_SOUND_VARIO) {
|
||||||
|
tone2Changed = 1;
|
||||||
tone2Freq = tFreq;
|
tone2Freq = tFreq;
|
||||||
tone2TimeLeft = tLen;
|
tone2TimeLeft = tLen;
|
||||||
tone2Pause = tPause;
|
tone2Pause = tPause;
|
||||||
@@ -133,6 +126,7 @@ void audioQueue::play(uint8_t tFreq, uint8_t tLen, uint8_t tPause,
|
|||||||
tFreq += g_eeGeneral.speakerPitch + BEEP_OFFSET; // add pitch compensator
|
tFreq += g_eeGeneral.speakerPitch + BEEP_OFFSET; // add pitch compensator
|
||||||
tLen = getToneLength(tLen);
|
tLen = getToneLength(tLen);
|
||||||
if (tFlags & PLAY_NOW || (!busy() && empty())) {
|
if (tFlags & PLAY_NOW || (!busy() && empty())) {
|
||||||
|
toneChanged = 1;
|
||||||
toneFreq = tFreq;
|
toneFreq = tFreq;
|
||||||
toneTimeLeft = tLen;
|
toneTimeLeft = tLen;
|
||||||
tonePause = tPause;
|
tonePause = tPause;
|
||||||
|
|||||||
@@ -73,12 +73,14 @@ class audioQueue
|
|||||||
uint8_t t_queueRidx;
|
uint8_t t_queueRidx;
|
||||||
uint8_t t_queueWidx;
|
uint8_t t_queueWidx;
|
||||||
|
|
||||||
|
uint8_t toneChanged;
|
||||||
uint8_t toneFreq;
|
uint8_t toneFreq;
|
||||||
int8_t toneFreqIncr;
|
int8_t toneFreqIncr;
|
||||||
uint8_t toneTimeLeft;
|
uint8_t toneTimeLeft;
|
||||||
uint8_t tonePause;
|
uint8_t tonePause;
|
||||||
|
|
||||||
// vario
|
// vario
|
||||||
|
uint8_t tone2Changed;
|
||||||
uint8_t tone2Freq;
|
uint8_t tone2Freq;
|
||||||
uint8_t tone2TimeLeft;
|
uint8_t tone2TimeLeft;
|
||||||
uint8_t tone2Pause;
|
uint8_t tone2Pause;
|
||||||
|
|||||||
+65
-106
@@ -52,7 +52,7 @@ void audioDefevent( uint8_t e ) ;
|
|||||||
|
|
||||||
extern uint32_t Master_frequency ; // TODO in a .h?
|
extern uint32_t Master_frequency ; // TODO in a .h?
|
||||||
volatile uint8_t Buzzer_count ;
|
volatile uint8_t Buzzer_count ;
|
||||||
|
/*
|
||||||
struct t_sound_globals
|
struct t_sound_globals
|
||||||
{
|
{
|
||||||
uint32_t Next_freq ;
|
uint32_t Next_freq ;
|
||||||
@@ -63,7 +63,7 @@ struct t_sound_globals
|
|||||||
uint32_t Frequency_increment ;
|
uint32_t Frequency_increment ;
|
||||||
uint32_t Next_frequency_increment ;
|
uint32_t Next_frequency_increment ;
|
||||||
} Sound_g ;
|
} Sound_g ;
|
||||||
|
*/
|
||||||
|
|
||||||
// Must NOT be in flash, PDC needs a RAM source.
|
// Must NOT be in flash, PDC needs a RAM source.
|
||||||
uint16_t Sine_values[] =
|
uint16_t Sine_values[] =
|
||||||
@@ -162,22 +162,24 @@ void buzzer_sound( uint8_t time )
|
|||||||
void set_frequency( uint32_t frequency )
|
void set_frequency( uint32_t frequency )
|
||||||
{
|
{
|
||||||
register Tc *ptc ;
|
register Tc *ptc ;
|
||||||
register uint32_t timer ;
|
register uint32_t timer ;
|
||||||
|
|
||||||
timer = Master_frequency / (800 * frequency) ; // MCK/8 and 100 000 Hz
|
frequency = frequency * 61 / 2;
|
||||||
if ( timer > 65535 )
|
|
||||||
{
|
timer = Master_frequency / (800 * frequency) ; // MCK/8 and 100 000 Hz
|
||||||
timer = 65535 ;
|
if ( timer > 65535 )
|
||||||
}
|
{
|
||||||
if ( timer < 2 )
|
timer = 65535 ;
|
||||||
{
|
}
|
||||||
timer = 2 ;
|
if ( timer < 2 )
|
||||||
}
|
{
|
||||||
ptc = TC0 ; // Tc block 0 (TC0-2)
|
timer = 2 ;
|
||||||
ptc->TC_CHANNEL[1].TC_CCR = TC_CCR0_CLKDIS ; // Stop clock
|
}
|
||||||
ptc->TC_CHANNEL[1].TC_RC = timer ; // 100 000 Hz
|
ptc = TC0 ; // Tc block 0 (TC0-2)
|
||||||
ptc->TC_CHANNEL[1].TC_RA = timer >> 1 ;
|
ptc->TC_CHANNEL[1].TC_CCR = TC_CCR0_CLKDIS ; // Stop clock
|
||||||
ptc->TC_CHANNEL[1].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger)
|
ptc->TC_CHANNEL[1].TC_RC = timer ; // 100 000 Hz
|
||||||
|
ptc->TC_CHANNEL[1].TC_RA = timer >> 1 ;
|
||||||
|
ptc->TC_CHANNEL[1].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -185,22 +187,22 @@ void set_frequency( uint32_t frequency )
|
|||||||
void start_timer1()
|
void start_timer1()
|
||||||
{
|
{
|
||||||
register Tc *ptc ;
|
register Tc *ptc ;
|
||||||
register uint32_t timer ;
|
register uint32_t timer ;
|
||||||
|
|
||||||
// Enable peripheral clock TC0 = bit 23 thru TC5 = bit 28
|
// Enable peripheral clock TC0 = bit 23 thru TC5 = bit 28
|
||||||
PMC->PMC_PCER0 |= 0x01000000L ; // Enable peripheral clock to TC1
|
PMC->PMC_PCER0 |= 0x01000000L ; // Enable peripheral clock to TC1
|
||||||
|
|
||||||
timer = Master_frequency / 800000 ; // MCK/8 and 100 000 Hz
|
timer = Master_frequency / 800000 ; // MCK/8 and 100 000 Hz
|
||||||
ptc = TC0 ; // Tc block 0 (TC0-2)
|
ptc = TC0 ; // Tc block 0 (TC0-2)
|
||||||
ptc->TC_BCR = 0 ; // No sync
|
ptc->TC_BCR = 0 ; // No sync
|
||||||
ptc->TC_BMR = 0 ;
|
ptc->TC_BMR = 0 ;
|
||||||
ptc->TC_CHANNEL[1].TC_CMR = 0x00008000 ; // Waveform mode
|
ptc->TC_CHANNEL[1].TC_CMR = 0x00008000 ; // Waveform mode
|
||||||
ptc->TC_CHANNEL[1].TC_RC = timer ; // 100 000 Hz
|
ptc->TC_CHANNEL[1].TC_RC = timer ; // 100 000 Hz
|
||||||
ptc->TC_CHANNEL[1].TC_RA = timer >> 1 ;
|
ptc->TC_CHANNEL[1].TC_RA = timer >> 1 ;
|
||||||
ptc->TC_CHANNEL[1].TC_CMR = 0x0009C001 ; // 0000 0000 0000 1001 1100 0000 0000 0001
|
ptc->TC_CHANNEL[1].TC_CMR = 0x0009C001 ; // 0000 0000 0000 1001 1100 0000 0000 0001
|
||||||
// MCK/8, set @ RA, Clear @ RC waveform
|
// MCK/8, set @ RA, Clear @ RC waveform
|
||||||
ptc->TC_CHANNEL[1].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger)
|
ptc->TC_CHANNEL[1].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger)
|
||||||
Sound_g.Frequency = 1000 ;
|
// Sound_g.Frequency = 1000 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -210,46 +212,46 @@ void start_timer1()
|
|||||||
// So maybe it is automatically done
|
// So maybe it is automatically done
|
||||||
void init_dac()
|
void init_dac()
|
||||||
{
|
{
|
||||||
register Dacc *dacptr ;
|
register Dacc *dacptr ;
|
||||||
|
|
||||||
PMC->PMC_PCER0 |= 0x40000000L ; // Enable peripheral clock to DAC
|
PMC->PMC_PCER0 |= 0x40000000L ; // Enable peripheral clock to DAC
|
||||||
dacptr = DACC ;
|
dacptr = DACC ;
|
||||||
#ifdef REVB
|
#ifdef REVB
|
||||||
dacptr->DACC_MR = 0x0B000215L ; // 0000 1011 0000 0001 0000 0010 0001 0101
|
dacptr->DACC_MR = 0x0B000215L ; // 0000 1011 0000 0001 0000 0010 0001 0101
|
||||||
#else
|
#else
|
||||||
dacptr->DACC_MR = 0x0B010215L ; // 0000 1011 0000 0001 0000 0010 0001 0101
|
dacptr->DACC_MR = 0x0B010215L ; // 0000 1011 0000 0001 0000 0010 0001 0101
|
||||||
#endif
|
#endif
|
||||||
#ifdef REVB
|
#ifdef REVB
|
||||||
dacptr->DACC_CHER = 1 ; // Enable channel 0
|
dacptr->DACC_CHER = 1 ; // Enable channel 0
|
||||||
#else
|
#else
|
||||||
dacptr->DACC_CHER = 2 ; // Enable channel 1
|
dacptr->DACC_CHER = 2 ; // Enable channel 1
|
||||||
#endif
|
#endif
|
||||||
dacptr->DACC_CDR = 2048 ; // Half amplitude
|
dacptr->DACC_CDR = 2048 ; // Half amplitude
|
||||||
// Data for PDC must NOT be in flash, PDC needs a RAM source.
|
// Data for PDC must NOT be in flash, PDC needs a RAM source.
|
||||||
#ifndef SIMU
|
#ifndef SIMU
|
||||||
dacptr->DACC_TPR = (uint32_t) Sine_values ;
|
dacptr->DACC_TPR = (uint32_t) Sine_values ;
|
||||||
dacptr->DACC_TNPR = (uint32_t) Sine_values ;
|
dacptr->DACC_TNPR = (uint32_t) Sine_values ;
|
||||||
#endif
|
#endif
|
||||||
dacptr->DACC_TCR = 50 ; // words, 100 16 bit values
|
dacptr->DACC_TCR = 50 ; // words, 100 16 bit values
|
||||||
dacptr->DACC_TNCR = 50 ; // words, 100 16 bit values
|
dacptr->DACC_TNCR = 50 ; // words, 100 16 bit values
|
||||||
dacptr->DACC_PTCR = DACC_PTCR_TXTEN ;
|
dacptr->DACC_PTCR = DACC_PTCR_TXTEN ;
|
||||||
NVIC_EnableIRQ(DACC_IRQn) ;
|
NVIC_EnableIRQ(DACC_IRQn) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void DAC_IRQHandler()
|
extern "C" void DAC_IRQHandler()
|
||||||
{
|
{
|
||||||
// Data for PDC must NOT be in flash, PDC needs a RAM source.
|
// Data for PDC must NOT be in flash, PDC needs a RAM source.
|
||||||
#ifndef SIMU
|
#ifndef SIMU
|
||||||
DACC->DACC_TNPR = (uint32_t) Sine_values ;
|
DACC->DACC_TNPR = (uint32_t) Sine_values ;
|
||||||
#endif
|
#endif
|
||||||
DACC->DACC_TNCR = 50 ; // words, 100 16 bit values
|
DACC->DACC_TNCR = 50 ; // words, 100 16 bit values
|
||||||
if ( Sound_g.Tone_timer )
|
/* if ( Sound_g.Tone_timer )
|
||||||
{
|
{
|
||||||
if ( --Sound_g.Tone_timer == 0 )
|
if ( --Sound_g.Tone_timer == 0 )
|
||||||
{
|
{
|
||||||
DACC->DACC_IDR = DACC_IDR_ENDTX ;
|
DACC->DACC_IDR = DACC_IDR_ENDTX ;
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
// if ( Tone_ms_timer == 0 )
|
// if ( Tone_ms_timer == 0 )
|
||||||
// {
|
// {
|
||||||
// Tone_ms_timer = -1 ;
|
// Tone_ms_timer = -1 ;
|
||||||
@@ -259,59 +261,15 @@ extern "C" void DAC_IRQHandler()
|
|||||||
|
|
||||||
void end_sound()
|
void end_sound()
|
||||||
{
|
{
|
||||||
DACC->DACC_IDR = DACC_IDR_ENDTX ;
|
DACC->DACC_IDR = DACC_IDR_ENDTX ;
|
||||||
NVIC_DisableIRQ(DACC_IRQn) ;
|
NVIC_DisableIRQ(DACC_IRQn) ;
|
||||||
TWI0->TWI_IDR = TWI_IDR_TXCOMP ;
|
TWI0->TWI_IDR = TWI_IDR_TXCOMP ;
|
||||||
NVIC_DisableIRQ(TWI0_IRQn) ;
|
NVIC_DisableIRQ(TWI0_IRQn) ;
|
||||||
PMC->PMC_PCER0 &= ~0x00080000L ; // Disable peripheral clock to TWI0
|
PMC->PMC_PCER0 &= ~0x00080000L ; // Disable peripheral clock to TWI0
|
||||||
PMC->PMC_PCER0 &= ~0x40000000L ; // Disable peripheral clock to DAC
|
PMC->PMC_PCER0 &= ~0x40000000L ; // Disable peripheral clock to DAC
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every 5mS from interrupt routine
|
#if 0
|
||||||
void sound_5ms()
|
|
||||||
{
|
|
||||||
if ( Sound_g.Tone_ms_timer > 0 )
|
|
||||||
{
|
|
||||||
Sound_g.Tone_ms_timer -= 1 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( Sound_g.Tone_ms_timer == 0 )
|
|
||||||
{
|
|
||||||
if ( Sound_g.Sound_time )
|
|
||||||
{
|
|
||||||
Sound_g.Tone_ms_timer = ( Sound_g.Sound_time + 4 ) / 5 ;
|
|
||||||
if ( Sound_g.Next_freq ) // 0 => silence for time
|
|
||||||
{
|
|
||||||
Sound_g.Frequency = Sound_g.Next_freq ;
|
|
||||||
Sound_g.Frequency_increment = Sound_g.Next_frequency_increment ;
|
|
||||||
set_frequency( Sound_g.Frequency ) ;
|
|
||||||
tone_start( 0 ) ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DACC->DACC_IDR = DACC_IDR_ENDTX ; // Silence
|
|
||||||
}
|
|
||||||
Sound_g.Sound_time = 0 ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DACC->DACC_IDR = DACC_IDR_ENDTX ; // Disable interrupt
|
|
||||||
Sound_g.Tone_timer = 0 ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( ( Sound_g.Tone_ms_timer & 1 ) == 0 ) // Every 10 mS
|
|
||||||
{
|
|
||||||
if ( Sound_g.Frequency )
|
|
||||||
{
|
|
||||||
if ( Sound_g.Frequency_increment )
|
|
||||||
{
|
|
||||||
Sound_g.Frequency += Sound_g.Frequency_increment ;
|
|
||||||
set_frequency( Sound_g.Frequency ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// frequency in Hz, time in mS
|
// frequency in Hz, time in mS
|
||||||
void playTone( uint32_t frequency, uint32_t time )
|
void playTone( uint32_t frequency, uint32_t time )
|
||||||
{
|
{
|
||||||
@@ -322,7 +280,8 @@ void playTone( uint32_t frequency, uint32_t time )
|
|||||||
// Tone_ms_timer = ( time + 4 ) / 5 ;
|
// Tone_ms_timer = ( time + 4 ) / 5 ;
|
||||||
// tone_start( 0 ) ;
|
// tone_start( 0 ) ;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
uint32_t queueTone( uint32_t frequency, uint32_t time, uint32_t frequency_increment )
|
uint32_t queueTone( uint32_t frequency, uint32_t time, uint32_t frequency_increment )
|
||||||
{
|
{
|
||||||
if ( Sound_g.Sound_time == 0 )
|
if ( Sound_g.Sound_time == 0 )
|
||||||
@@ -334,19 +293,19 @@ uint32_t queueTone( uint32_t frequency, uint32_t time, uint32_t frequency_increm
|
|||||||
}
|
}
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// Time is in milliseconds
|
// Time is in milliseconds
|
||||||
void tone_start( register uint32_t time )
|
void tone_start( register uint32_t time )
|
||||||
{
|
{
|
||||||
PMC->PMC_PCER0 |= 0x40000000L ; // Enable peripheral clock to DAC
|
PMC->PMC_PCER0 |= 0x40000000L ; // Enable peripheral clock to DAC
|
||||||
Sound_g.Tone_timer = Sound_g.Frequency * time / 1000 ;
|
// Sound_g.Tone_timer = Sound_g.Frequency * time / 1000 ;
|
||||||
DACC->DACC_IER = DACC_IER_ENDTX ;
|
DACC->DACC_IER = DACC_IER_ENDTX ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tone_stop()
|
void tone_stop()
|
||||||
{
|
{
|
||||||
DACC->DACC_IDR = DACC_IDR_ENDTX ; // Disable interrupt
|
DACC->DACC_IDR = DACC_IDR_ENDTX ; // Disable interrupt
|
||||||
Sound_g.Tone_timer = 0 ;
|
// Sound_g.Tone_timer = 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2093,7 +2093,7 @@ void perMain()
|
|||||||
|
|
||||||
#if defined(PCBARM)
|
#if defined(PCBARM)
|
||||||
HAPTIC_HEARTBEAT();
|
HAPTIC_HEARTBEAT();
|
||||||
AUDIO_HEARTBEAT(); // the queue processing
|
// AUDIO_HEARTBEAT(); // the queue processing
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user