From: drowe67 Date: Mon, 22 Sep 2014 06:25:15 +0000 (+0000) Subject: PTT control working on a FT-817 X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=e22e3c30a0a278c4b7e5717c08e890e42cb3aaf4;p=freetel-svn-tracking.git PTT control working on a FT-817 git-svn-id: https://svn.code.sf.net/p/freetel/code@1848 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/stm32/Makefile b/codec2-dev/stm32/Makefile index 8915dec6..b1972297 100644 --- a/codec2-dev/stm32/Makefile +++ b/codec2-dev/stm32/Makefile @@ -167,6 +167,7 @@ src/init.c adcdac_ut.elf: $(ADCDAC_UT_SRCS) $(CC) $(CFLAGS) -O0 $^ -o $@ $(LIBPATHS) $(LIBS) + $(OBJCOPY) -O binary adcdac_ut.elf adcdac_ut.bin DAC_PLAY_SRCS=\ src/dac_play.c \ diff --git a/codec2-dev/stm32/inc/sm1000_leds_switches.h b/codec2-dev/stm32/inc/sm1000_leds_switches.h index 12542ce3..c5ba8953 100644 --- a/codec2-dev/stm32/inc/sm1000_leds_switches.h +++ b/codec2-dev/stm32/inc/sm1000_leds_switches.h @@ -34,6 +34,7 @@ void led_pwr(int state); void led_ptt(int state); void led_rt(int state); void led_err(int state); +void not_cptt(int state); int switch_ptt(void); int switch_select(void); diff --git a/codec2-dev/stm32/src/adcdac_ut.c b/codec2-dev/stm32/src/adcdac_ut.c index f18693ec..5901eea7 100644 --- a/codec2-dev/stm32/src/adcdac_ut.c +++ b/codec2-dev/stm32/src/adcdac_ut.c @@ -53,7 +53,7 @@ int main(void) { /* keep DAC FIFOs topped up */ - while(adc2_read(buf, SINE_SAMPLES) == -1); + while(adc1_read(buf, SINE_SAMPLES) == -1); dac2_write(buf, SINE_SAMPLES); } diff --git a/codec2-dev/stm32/src/sm1000_leds_switches.c b/codec2-dev/stm32/src/sm1000_leds_switches.c index bb2ab801..f936ca22 100644 --- a/codec2-dev/stm32/src/sm1000_leds_switches.c +++ b/codec2-dev/stm32/src/sm1000_leds_switches.c @@ -25,6 +25,7 @@ along with this program; if not, see . */ +#define _CPTT GPIO_Pin_10 #define LED_PWR GPIO_Pin_12 #define LED_PTT GPIO_Pin_13 #define LED_RT GPIO_Pin_14 @@ -44,7 +45,7 @@ void sm1000_leds_switches_init(void) { /* output pins */ - GPIO_InitStruct.GPIO_Pin = LED_PWR | LED_PTT | LED_RT | LED_ERR; + GPIO_InitStruct.GPIO_Pin = LED_PWR | LED_PTT | LED_RT | LED_ERR | _CPTT; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; @@ -58,7 +59,7 @@ void sm1000_leds_switches_init(void) { GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; /* we have our own external pull ups */ GPIO_Init(GPIOD, &GPIO_InitStruct); - } +} void led_pwr(int state) { if (state) @@ -88,6 +89,13 @@ void led_err(int state) { GPIOD->ODR &= ~(1 << 15); } +void not_cptt(int state) { + if (state) + GPIOD->ODR |= (1 << 10); + else + GPIOD->ODR &= ~(1 << 10); +} + int switch_ptt(void) { return GPIOD->IDR & (1 << 7); } diff --git a/codec2-dev/stm32/src/sm1000_main.c b/codec2-dev/stm32/src/sm1000_main.c index 147dad6d..544306c7 100644 --- a/codec2-dev/stm32/src/sm1000_main.c +++ b/codec2-dev/stm32/src/sm1000_main.c @@ -41,7 +41,7 @@ int main(void) { short adc8k[FREEDV_NSAMPLES]; short dac8k[FDMDV_OS_TAPS_8K+FREEDV_NSAMPLES]; - int nin, nout, i; + int nin, nout, i, analog_mode; /* init all the drivers for various peripherals */ @@ -50,10 +50,9 @@ int main(void) { adc_open(4*ADC_BUF_SZ); f = freedv_open(FREEDV_MODE_1600); - /* LEDs into a known state */ - - //led_pwr(1); led_ptt(0); led_rt(0); led_err(0); + /* put outputs into a known state */ + led_pwr(1); led_ptt(0); led_rt(0); led_err(0); not_cptt(1); /* clear filter memories */ @@ -61,9 +60,18 @@ int main(void) { adc16k[i] = 0.0; for(i=0; iODR &= ~(1 << 3); } @@ -92,22 +105,41 @@ int main(void) { /* Receive --------------------------------------------------------------------------*/ + not_cptt(1); led_ptt(0); + /* ADC1 is the demod in signal from the radio rx, DAC2 is the SM1000 speaker */ - nin = freedv_nin(f); - nout = nin; - f->total_bit_errors = 0; + if (analog_mode) { - if (adc1_read(&adc16k[FDMDV_OS_TAPS_16K], 2*nin) == 0) { - GPIOE->ODR = (1 << 3); - fdmdv_16_to_8_short(adc8k, &adc16k[FDMDV_OS_TAPS_16K], nin); - nout = freedv_rx(f, &dac8k[FDMDV_OS_TAPS_8K], adc8k); - //for(i=0; ifdmdv_stats.sync); led_err(f->total_bit_errors); - GPIOE->ODR &= ~(1 << 3); + /* force analog bypass when select down */ + + if (adc1_read(&adc16k[FDMDV_OS_TAPS_16K], FREEDV_NSAMPLES_16K) == 0) { + fdmdv_16_to_8_short(adc8k, &adc16k[FDMDV_OS_TAPS_16K], FREEDV_NSAMPLES); + for(i=0; itotal_bit_errors = 0; + + + if (adc1_read(&adc16k[FDMDV_OS_TAPS_16K], 2*nin) == 0) { + GPIOE->ODR = (1 << 3); + fdmdv_16_to_8_short(adc8k, &adc16k[FDMDV_OS_TAPS_16K], nin); + nout = freedv_rx(f, &dac8k[FDMDV_OS_TAPS_8K], adc8k); + fdmdv_8_to_16_short(dac16k, &dac8k[FDMDV_OS_TAPS_8K], nout); + dac2_write(dac16k, 2*nout); + led_rt(f->fdmdv_stats.sync); led_err(f->total_bit_errors); + GPIOE->ODR &= ~(1 << 3); + } } }