Merge branch 'master' into PSDR_F7

Conflicts:
	Source/.settings/language.settings.xml
	Source/Debug/PSDR.hex
	Source/PSDR F4.launch
	Source/src/main.c

I2C is (finally working) ADC still not working.
This commit is contained in:
Michael Colton 2016-05-08 00:53:48 -06:00
commit ac513eaae0
11 changed files with 633 additions and 5713 deletions

Binary file not shown.

View file

@ -0,0 +1,371 @@
#MicroXplorer Configuration settings - do not modify
ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_10
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master
ADC1.NbrOfConversionFlag=1
ADC1.Rank-0\#ChannelRegularConversion=1
ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_3CYCLES
ADC1.master=1
ADC2.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_15
ADC2.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag
ADC2.NbrOfConversionFlag=1
ADC2.Rank-0\#ChannelRegularConversion=1
ADC2.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_3CYCLES
ADC3.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_10
ADC3.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag
ADC3.NbrOfConversionFlag=1
ADC3.Rank-0\#ChannelRegularConversion=1
ADC3.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_3CYCLES
File.Version=6
KeepUserPlacement=false
Mcu.Family=STM32F7
Mcu.IP0=ADC1
Mcu.IP1=ADC2
Mcu.IP10=TIM1
Mcu.IP11=USB_OTG_FS
Mcu.IP2=ADC3
Mcu.IP3=CORTEX_M7
Mcu.IP4=DAC
Mcu.IP5=I2C2
Mcu.IP6=NVIC
Mcu.IP7=RCC
Mcu.IP8=SPI2
Mcu.IP9=SYS
Mcu.IPNb=12
Mcu.Name=STM32F756VGTx
Mcu.Package=LQFP100
Mcu.Pin0=PE2
Mcu.Pin1=PE3
Mcu.Pin10=PC1
Mcu.Pin11=PC2
Mcu.Pin12=PC3
Mcu.Pin13=PA0/WKUP
Mcu.Pin14=PA1
Mcu.Pin15=PA2
Mcu.Pin16=PA3
Mcu.Pin17=PA4
Mcu.Pin18=PA5
Mcu.Pin19=PA6
Mcu.Pin2=PE4
Mcu.Pin20=PA7
Mcu.Pin21=PC4
Mcu.Pin22=PC5
Mcu.Pin23=PB0
Mcu.Pin24=PB1
Mcu.Pin25=PB2
Mcu.Pin26=PE7
Mcu.Pin27=PE8
Mcu.Pin28=PE9
Mcu.Pin29=PE10
Mcu.Pin3=PE6
Mcu.Pin30=PE11
Mcu.Pin31=PE12
Mcu.Pin32=PE13
Mcu.Pin33=PE14
Mcu.Pin34=PE15
Mcu.Pin35=PB10
Mcu.Pin36=PB11
Mcu.Pin37=PB12
Mcu.Pin38=PB13
Mcu.Pin39=PB14
Mcu.Pin4=PC13
Mcu.Pin40=PB15
Mcu.Pin41=PD8
Mcu.Pin42=PA10
Mcu.Pin43=PA11
Mcu.Pin44=PA12
Mcu.Pin45=PA13
Mcu.Pin46=PA14
Mcu.Pin47=PB3
Mcu.Pin48=VP_SYS_VS_Systick
Mcu.Pin49=VP_TIM1_VS_ControllerModeClock
Mcu.Pin5=PC14/OSC32_IN
Mcu.Pin6=PC15/OSC32_OUT
Mcu.Pin7=PH0/OSC_IN
Mcu.Pin8=PH1/OSC_OUT
Mcu.Pin9=PC0
Mcu.PinsNb=50
Mcu.UserConstants=
Mcu.UserName=STM32F756VGTx
MxCube.Version=4.14.0
MxDb.Version=DB.4.0.140
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true
PA0/WKUP.GPIOParameters=GPIO_Label
PA0/WKUP.GPIO_Label=AMP_SWITCH_A
PA0/WKUP.Locked=true
PA0/WKUP.Signal=GPIO_Output
PA1.GPIOParameters=GPIO_Label
PA1.GPIO_Label=BOOT1
PA1.Locked=true
PA1.Signal=GPIO_Input
PA10.Mode=OTG/Dual_Role_Device
PA10.Signal=USB_OTG_FS_ID
PA11.Mode=OTG/Dual_Role_Device
PA11.Signal=USB_OTG_FS_DM
PA12.Mode=OTG/Dual_Role_Device
PA12.Signal=USB_OTG_FS_DP
PA13.Mode=Trace-Asynchronous_SW
PA13.Signal=SYS_JTMS-SWDIO
PA14.Mode=Trace-Asynchronous_SW
PA14.Signal=SYS_JTCK-SWCLK
PA2.GPIOParameters=GPIO_Label
PA2.GPIO_Label=RX-Q_FILTERED
PA2.Locked=true
PA2.Signal=ADCx_IN2
PA3.GPIOParameters=GPIO_Label
PA3.GPIO_Label=RX-I_FILTERED
PA3.Locked=true
PA3.Signal=ADCx_IN3
PA4.GPIOParameters=GPIO_Label
PA4.GPIO_Label=DAC1
PA4.Locked=true
PA4.Signal=COMP_DAC1_group
PA5.GPIOParameters=GPIO_Label
PA5.GPIO_Label=DAC2
PA5.Locked=true
PA5.Signal=COMP_DAC2_group
PA6.Locked=true
PA6.Signal=GPIO_Output
PA7.GPIOParameters=GPIO_Label
PA7.GPIO_Label=IMP_BRIDGE_SWITCH_B
PA7.Locked=true
PA7.Signal=GPIO_Output
PB0.GPIOParameters=GPIO_Label
PB0.GPIO_Label=MAGNITUDE
PB0.Locked=true
PB0.Signal=ADCx_IN8
PB1.GPIOParameters=GPIO_Label
PB1.GPIO_Label=MIC_FILTERED
PB1.Locked=true
PB1.Signal=ADCx_IN9
PB10.Locked=true
PB10.Mode=I2C
PB10.Signal=I2C2_SCL
PB11.Locked=true
PB11.Mode=I2C
PB11.Signal=I2C2_SDA
PB12.GPIOParameters=GPIO_Label
PB12.GPIO_Label=FILTER_CS
PB12.Locked=true
PB12.Mode=NSS_Signal_Hard_Output
PB12.Signal=SPI2_NSS
PB13.GPIOParameters=GPIO_Label
PB13.GPIO_Label=FILTER/GAIN_POT_CLK
PB13.Locked=true
PB13.Mode=Full_Duplex_Master
PB13.Signal=SPI2_SCK
PB14.GPIOParameters=GPIO_Label
PB14.GPIO_Label=FILTER_MISO
PB14.Locked=true
PB14.Mode=Full_Duplex_Master
PB14.Signal=SPI2_MISO
PB15.GPIOParameters=GPIO_Label
PB15.GPIO_Label=FILTER/GAIN_POT_MOSI
PB15.Locked=true
PB15.Mode=Full_Duplex_Master
PB15.Signal=SPI2_MOSI
PB2.GPIOParameters=GPIO_Label
PB2.GPIO_Label=TX_RF_SWITCH_A
PB2.Locked=true
PB2.Signal=GPIO_Output
PB3.Mode=Trace-Asynchronous_SW
PB3.Signal=SYS_JTDO-SWO
PC0.Locked=true
PC0.Signal=ADCx_IN10
PC1.GPIOParameters=GPIO_Label
PC1.GPIO_Label=IMP_BRIDGE_SWITCH_A
PC1.Locked=true
PC1.Signal=GPIO_Output
PC13.GPIOParameters=GPIO_Label
PC13.GPIO_Label=LCD_LED
PC13.Locked=true
PC13.Signal=GPIO_Output
PC14/OSC32_IN.Locked=true
PC14/OSC32_IN.Mode=LSE-External-Oscillator
PC14/OSC32_IN.Signal=RCC_OSC32_IN
PC15/OSC32_OUT.Locked=true
PC15/OSC32_OUT.Mode=LSE-External-Oscillator
PC15/OSC32_OUT.Signal=RCC_OSC32_OUT
PC2.GPIOParameters=GPIO_Label
PC2.GPIO_Label=INAMP_ENABLE
PC2.Locked=true
PC2.Signal=GPIO_Output
PC3.GPIOParameters=GPIO_Label
PC3.GPIO_Label=TRX_SWITCH
PC3.Locked=true
PC3.Signal=GPIO_Output
PC4.GPIOParameters=GPIO_Label
PC4.GPIO_Label=HALF_VCC
PC4.Locked=true
PC4.Signal=ADCx_IN14
PC5.GPIOParameters=GPIO_Label
PC5.GPIO_Label=PHASE
PC5.Locked=true
PC5.Signal=ADCx_IN15
PCC.Checker=false
PCC.Line=STM32F7x6
PCC.MCU=STM32F756VGTx
PCC.MXVersion=4.14.0
PCC.PartNumber=STM32F756VGTx
PCC.Seq0=0
PCC.Series=STM32F7
PCC.Temperature=25
PCC.Vdd=3.3
PD8.GPIOParameters=GPIO_Label
PD8.GPIO_Label=FILTER_S1
PD8.Locked=true
PD8.Signal=GPIO_Output
PE10.GPIOParameters=GPIO_Label
PE10.GPIO_Label=FILTER_S0
PE10.Locked=true
PE10.Signal=GPIO_Output
PE11.GPIOParameters=GPIO_Label
PE11.GPIO_Label=LPF_POWER
PE11.Locked=true
PE11.Signal=GPIO_Output
PE12.GPIOParameters=GPIO_Label
PE12.GPIO_Label=LED_WHITE
PE12.Locked=true
PE12.Signal=GPIO_Output
PE13.GPIOParameters=GPIO_Label
PE13.GPIO_Label=LED_RED
PE13.Locked=true
PE13.Signal=GPIO_Output
PE14.GPIOParameters=GPIO_Label
PE14.GPIO_Label=AUDIO_AMP_SHDN
PE14.Locked=true
PE14.Signal=GPIO_Output
PE15.GPIOParameters=GPIO_Label
PE15.GPIO_Label=GPS_RESET
PE15.Locked=true
PE15.Signal=GPIO_Output
PE2.GPIOParameters=GPIO_Label
PE2.GPIO_Label=5V_REG_ENABLE
PE2.Locked=true
PE2.Signal=GPIO_Output
PE3.GPIOParameters=GPIO_Label
PE3.GPIO_Label=AMP_POWER
PE3.Locked=true
PE3.Signal=GPIO_Output
PE4.GPIOParameters=GPIO_Label
PE4.GPIO_Label=DAC_MUX
PE4.Locked=true
PE4.Signal=GPIO_Output
PE6.GPIOParameters=GPIO_Label
PE6.GPIO_Label=AMP_SWITCH_B
PE6.Locked=true
PE6.Signal=GPIO_Output
PE7.GPIOParameters=GPIO_Label
PE7.GPIO_Label=GPS_PPS
PE7.Locked=true
PE7.Signal=S_TIM1_ETR
PE8.GPIOParameters=GPIO_Label
PE8.GPIO_Label=FLIP_FLOP_POWER
PE8.Locked=true
PE8.Signal=GPIO_Output
PE9.GPIOParameters=GPIO_Label
PE9.GPIO_Label=F_SYNTH_CAL
PE9.Locked=true
PE9.Signal=S_TIM1_CH1
PH0/OSC_IN.Locked=true
PH0/OSC_IN.Mode=HSE-External-Oscillator
PH0/OSC_IN.Signal=RCC_OSC_IN
PH1/OSC_OUT.Locked=true
PH1/OSC_OUT.Mode=HSE-External-Oscillator
PH1/OSC_OUT.Signal=RCC_OSC_OUT
RCC.AHBFreq_Value=216000000
RCC.APB1CLKDivider=RCC_HCLK_DIV4
RCC.APB1Freq_Value=54000000
RCC.APB1TimFreq_Value=108000000
RCC.APB2CLKDivider=RCC_HCLK_DIV2
RCC.APB2Freq_Value=108000000
RCC.APB2TimFreq_Value=216000000
RCC.CECFreq_Value=32786.88524590164
RCC.CortexFreq_Value=216000000
RCC.EthernetFreq_Value=216000000
RCC.FCLKCortexFreq_Value=216000000
RCC.FamilyName=M
RCC.HCLKFreq_Value=216000000
RCC.HSE_VALUE=26000000
RCC.HSI_VALUE=16000000
RCC.I2C1Freq_Value=54000000
RCC.I2C2Freq_Value=54000000
RCC.I2C3Freq_Value=54000000
RCC.I2C4Freq_Value=54000000
RCC.I2SFreq_Value=192000000
RCC.IPParameters=FamilyName,HSI_VALUE,CECFreq_Value,HSE_VALUE,SDMMCFreq_Value,LSI_VALUE,VCOInputFreq_Value,VCOOutputFreq_Value,PLLCLKFreq_Value,PLLQCLKFreq_Value,RNGFreq_Value,USBFreq_Value,VCOSAIOutputFreq_Value,PLLSAIPCLKFreq_Value,PLLSAIoutputFreq_Value,PLLSAIQCLKFreq_Value,SAI1Freq_Value,SAI2Freq_Value,PLLSAIRCLKFreq_Value,LCDTFToutputFreq_Value,VCOI2SOutputFreq_Value,PLLI2SPCLKFreq_Value,SPDIFRXFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,I2SFreq_Value,PLLQoutputFreq_Value,PLLI2SRoutputFreq_Value,SYSCLKSource,EthernetFreq_Value,HCLKFreq_Value,AHBFreq_Value,CortexFreq_Value,FCLKCortexFreq_Value,APB1Freq_Value,APB1TimFreq_Value,I2C3Freq_Value,I2C4Freq_Value,USART2Freq_Value,LPTIM1Freq_Value,UART8Freq_Value,USART3Freq_Value,I2C2Freq_Value,UART5Freq_Value,I2C1Freq_Value,UART4Freq_Value,UART7Freq_Value,APB2Freq_Value,APB2TimFreq_Value,USART6Freq_Value,USART1Freq_Value,SYSCLKFreq_VALUE,MCO2PinFreq_Value,APB2CLKDivider,APB1CLKDivider,PLLM,PLLN,PLLQ
RCC.LCDTFToutputFreq_Value=96000000
RCC.LPTIM1Freq_Value=54000000
RCC.LSI_VALUE=32000
RCC.MCO2PinFreq_Value=216000000
RCC.PLLCLKFreq_Value=216000000
RCC.PLLI2SPCLKFreq_Value=192000000
RCC.PLLI2SQCLKFreq_Value=192000000
RCC.PLLI2SRCLKFreq_Value=192000000
RCC.PLLI2SRoutputFreq_Value=192000000
RCC.PLLM=13
RCC.PLLN=216
RCC.PLLQ=9
RCC.PLLQCLKFreq_Value=48000000
RCC.PLLQoutputFreq_Value=48000000
RCC.PLLSAIPCLKFreq_Value=192000000
RCC.PLLSAIQCLKFreq_Value=192000000
RCC.PLLSAIRCLKFreq_Value=192000000
RCC.PLLSAIoutputFreq_Value=192000000
RCC.RNGFreq_Value=48000000
RCC.SAI1Freq_Value=192000000
RCC.SAI2Freq_Value=192000000
RCC.SDMMCFreq_Value=216000000
RCC.SPDIFRXFreq_Value=192000000
RCC.SYSCLKFreq_VALUE=216000000
RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
RCC.UART4Freq_Value=54000000
RCC.UART5Freq_Value=54000000
RCC.UART7Freq_Value=54000000
RCC.UART8Freq_Value=54000000
RCC.USART1Freq_Value=108000000
RCC.USART2Freq_Value=54000000
RCC.USART3Freq_Value=54000000
RCC.USART6Freq_Value=108000000
RCC.USBFreq_Value=48000000
RCC.VCOI2SOutputFreq_Value=384000000
RCC.VCOInputFreq_Value=2000000
RCC.VCOOutputFreq_Value=432000000
RCC.VCOSAIOutputFreq_Value=384000000
SH.ADCx_IN10.0=ADC3_IN10,IN10
SH.ADCx_IN10.1=ADC1_IN10,IN10
SH.ADCx_IN10.ConfNb=2
SH.ADCx_IN14.0=ADC1_IN14,IN14
SH.ADCx_IN14.ConfNb=1
SH.ADCx_IN15.0=ADC2_IN15,IN15
SH.ADCx_IN15.ConfNb=1
SH.ADCx_IN2.0=ADC3_IN2,IN2
SH.ADCx_IN2.ConfNb=1
SH.ADCx_IN3.0=ADC2_IN3,IN3
SH.ADCx_IN3.ConfNb=1
SH.ADCx_IN8.0=ADC1_IN8,IN8
SH.ADCx_IN8.ConfNb=1
SH.ADCx_IN9.0=ADC1_IN9,IN9
SH.ADCx_IN9.ConfNb=1
SH.COMP_DAC1_group.0=DAC_OUT1,DAC_OUT1
SH.COMP_DAC1_group.ConfNb=1
SH.COMP_DAC2_group.0=DAC_OUT2,DAC_OUT2
SH.COMP_DAC2_group.ConfNb=1
SH.S_TIM1_CH1.0=TIM1_CH1,Input_Capture1_from_TI1
SH.S_TIM1_CH1.ConfNb=1
SH.S_TIM1_ETR.0=TIM1_ETR,TriggerSource_ETR
SH.S_TIM1_ETR.ConfNb=1
SPI2.CalculateBaudRate=27.0 MBits/s
SPI2.IPParameters=Mode,CalculateBaudRate,VirtualNSS
SPI2.Mode=SPI_MODE_MASTER
SPI2.VirtualNSS=VM_NSSHARD
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
VP_TIM1_VS_ControllerModeClock.Mode=Clock Mode
VP_TIM1_VS_ControllerModeClock.Signal=TIM1_VS_ControllerModeClock

View file

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1973458297" name="Debug">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-12953173521901507" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
<configuration id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.1950335458" name="Release">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="5998203251556263" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
</project>

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,7 @@
#define I2C_H_ #define I2C_H_
#include <hal.h> #include <hal.h>
//#include "register_map.h"
//#include "stm32f4xx_hal_i2c.h" //#include "stm32f4xx_hal_i2c.h"
#define SI5338_ADDRESS 0x70 #define SI5338_ADDRESS 0x70

View file

@ -4,7 +4,7 @@
//#define PSDR2 2 //#define PSDR2 2
//#define PSDR25 3 //#define PSDR25 3
#define PSDR257 4 #define PSDR257 4
#define ARM_MATH_CM7 //#define ARM_MATH_CM7
//#define PSDR_BOARD PSDR2 //#define PSDR_BOARD PSDR2

View file

@ -23,7 +23,7 @@ void initAdc()
AdcHandle1.Instance = ADC1; AdcHandle1.Instance = ADC1;
AdcHandle1.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2; AdcHandle1.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV4;
AdcHandle1.Init.Resolution = ADC_RESOLUTION12b; AdcHandle1.Init.Resolution = ADC_RESOLUTION12b;
AdcHandle1.Init.ScanConvMode = DISABLE; AdcHandle1.Init.ScanConvMode = DISABLE;
AdcHandle1.Init.ContinuousConvMode = ENABLE; AdcHandle1.Init.ContinuousConvMode = ENABLE;
@ -45,7 +45,7 @@ void initAdc()
AdcHandle2.Instance = ADC2; AdcHandle2.Instance = ADC2;
AdcHandle2.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2; AdcHandle2.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV4;
AdcHandle2.Init.Resolution = ADC_RESOLUTION12b; AdcHandle2.Init.Resolution = ADC_RESOLUTION12b;
AdcHandle2.Init.ScanConvMode = DISABLE; AdcHandle2.Init.ScanConvMode = DISABLE;
AdcHandle2.Init.ContinuousConvMode = ENABLE; AdcHandle2.Init.ContinuousConvMode = ENABLE;
@ -66,7 +66,7 @@ void initAdc()
AdcHandle3.Instance = ADC3; AdcHandle3.Instance = ADC3;
AdcHandle3.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2; AdcHandle3.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV4;
AdcHandle3.Init.Resolution = ADC_RESOLUTION12b; AdcHandle3.Init.Resolution = ADC_RESOLUTION12b;
AdcHandle3.Init.ScanConvMode = DISABLE; AdcHandle3.Init.ScanConvMode = DISABLE;
AdcHandle3.Init.ContinuousConvMode = ENABLE; AdcHandle3.Init.ContinuousConvMode = ENABLE;
@ -124,14 +124,16 @@ void initAdc()
void adcGetConversion() void adcGetConversion()
{ {
HAL_ADC_PollForConversion(&AdcHandle1, 10); HAL_StatusTypeDef result = HAL_ADC_PollForConversion(&AdcHandle1, 10);
HAL_ADC_PollForConversion(&AdcHandle2, 10); result = HAL_ADC_PollForConversion(&AdcHandle2, 10);
HAL_ADC_PollForConversion(&AdcHandle3, 10); result = HAL_ADC_PollForConversion(&AdcHandle3, 10);
if (result == HAL_OK)
{
/* Check if the continous conversion of regular channel is finished */ /* Check if the continous conversion of regular channel is finished */
if(HAL_ADC_GetState(&AdcHandle1) == HAL_ADC_STATE_EOC_REG if(HAL_ADC_GetState(&AdcHandle1) == 0x300 /*HAL_ADC_STATE_REG_EOC*/
&& HAL_ADC_GetState(&AdcHandle2) == HAL_ADC_STATE_EOC_REG && HAL_ADC_GetState(&AdcHandle2) == 0x300 /*HAL_ADC_STATE_REG_EOC*/
&& HAL_ADC_GetState(&AdcHandle3) == HAL_ADC_STATE_EOC_REG) && HAL_ADC_GetState(&AdcHandle3) == 0x300 /*HAL_ADC_STATE_REG_EOC*/)
{ {
/*##-5- Get the converted value of regular channel ########################*/ /*##-5- Get the converted value of regular channel ########################*/
uhADCxConvertedValue1 = HAL_ADC_GetValue(&AdcHandle1); uhADCxConvertedValue1 = HAL_ADC_GetValue(&AdcHandle1);
@ -141,6 +143,9 @@ void initAdc()
} }
}
void adcStartConversion() void adcStartConversion()
{ {
if(HAL_ADC_Start(&AdcHandle1) != HAL_OK) if(HAL_ADC_Start(&AdcHandle1) != HAL_OK)

View file

@ -44,43 +44,43 @@ long long freqToReg(long long frequency)
} }
void setFreq(long frequency) //void setFreq(long frequency)
{ //{
long long freg = freqToReg(frequency); // long long freg = freqToReg(frequency);
//
//
//HAL_GPIO_WritePin(ddsReset.port, ddsReset.pin, 1); // //HAL_GPIO_WritePin(ddsReset.port, ddsReset.pin, 1);
ddsPrefix(); // ddsPrefix();
//sendToDds(0x2100, 0x2100); // //sendToDds(0x2100, 0x2100);
//sendToDds(0x0010001100000000 , 0x0010001100000000); // //sendToDds(0x0010001100000000 , 0x0010001100000000);
sendToDds(0b0010001000000000 , 0b0010001000000000); // sendToDds(0b0010001000000000 , 0b0010001000000000);
ddsSuffix(); // ddsSuffix();
//
//HAL_GPIO_WritePin(ddsReset.port, ddsReset.pin, 0); // //HAL_GPIO_WritePin(ddsReset.port, ddsReset.pin, 0);
//HAL_GPIO_WritePin(ddsReset.port, ddsReset.pin, 1); // //HAL_GPIO_WritePin(ddsReset.port, ddsReset.pin, 1);
//sendToDds(0x50c7); // //sendToDds(0x50c7);
//sendToDds(0x4000); // //sendToDds(0x4000);
ddsPrefix(); // ddsPrefix();
sendToDds(((freg & 0b0011111111111111) | 0b0100000000000000), // sendToDds(((freg & 0b0011111111111111) | 0b0100000000000000),
((freg & 0b0011111111111111) | 0b0100000000000000)); // ((freg & 0b0011111111111111) | 0b0100000000000000));
ddsSuffix(); // ddsSuffix();
ddsPrefix(); // ddsPrefix();
sendToDds(((freg >> 14 & 0b0011111111111111) | 0b0100000000000000), // sendToDds(((freg >> 14 & 0b0011111111111111) | 0b0100000000000000),
(((freg >> 14) & 0b0011111111111111) | 0b0100000000000000)); // (((freg >> 14) & 0b0011111111111111) | 0b0100000000000000));
ddsSuffix(); // ddsSuffix();
ddsPrefix(); // ddsPrefix();
//sendToDds(0xc000, 0xc000); // //sendToDds(0xc000, 0xc000);
sendToDds(0xc000, 0xc000 | 3072); // sendToDds(0xc000, 0xc000 | 3072);
ddsSuffix(); // ddsSuffix();
// ddsPrefix(); // // ddsPrefix();
// sendToDds(0b1100000000000000); // // sendToDds(0b1100000000000000);
// ddsSuffix(); // // ddsSuffix();
//
//
//
// ddsPrefix(); // // ddsPrefix();
// sendToDds(0x2000, 0x2000); // // sendToDds(0x2000, 0x2000);
// ddsSuffix(); // // ddsSuffix();
//
// HAL_GPIO_WritePin(ddsReset.port, ddsReset.pin, 0); //// HAL_GPIO_WritePin(ddsReset.port, ddsReset.pin, 0);
} //}

View file

@ -386,18 +386,18 @@ hal_setupPins (void)
//ADC1 //ADC1
gpioInitStructure.Pin = RX_Q.pin; gpioInitStructure.Pin = RX_Q.pin;
gpioInitStructure.Speed = GPIO_SPEED_FAST; //gpioInitStructure.Speed = GPIO_SPEED_FAST;
gpioInitStructure.Mode = GPIO_MODE_ANALOG; gpioInitStructure.Mode = GPIO_MODE_ANALOG;
gpioInitStructure.Pull = GPIO_NOPULL; gpioInitStructure.Pull = GPIO_NOPULL;
gpioInitStructure.Alternate = 0; //gpioInitStructure.Alternate = 0;
HAL_GPIO_Init (RX_Q.port, &gpioInitStructure); HAL_GPIO_Init (RX_Q.port, &gpioInitStructure);
//ADC2 //ADC2
gpioInitStructure.Pin = RX_I.pin; gpioInitStructure.Pin = RX_I.pin;
gpioInitStructure.Speed = GPIO_SPEED_FAST; //gpioInitStructure.Speed = GPIO_SPEED_FAST;
gpioInitStructure.Mode = GPIO_MODE_ANALOG; gpioInitStructure.Mode = GPIO_MODE_ANALOG;
gpioInitStructure.Pull = GPIO_NOPULL; gpioInitStructure.Pull = GPIO_NOPULL;
gpioInitStructure.Alternate = 0; //gpioInitStructure.Alternate = 0;
HAL_GPIO_Init (RX_I.port, &gpioInitStructure); HAL_GPIO_Init (RX_I.port, &gpioInitStructure);
//DDS Pins //DDS Pins

View file

@ -175,13 +175,13 @@ unsigned char Reg_Store[][3] = {
{ 29,0x90,0xFF}, { 29,0x90,0xFF},
{ 30,0xB0,0xFF}, { 30,0xB0,0xFF},
{ 31,0xC0,0xFF}, { 31,0xC0,0xFF},
{ 32,0xE3,0xFF}, { 32,0xC0,0xFF},
{ 33,0xE3,0xFF}, { 33,0xCC,0xFF},
{ 34,0xE3,0xFF}, { 34,0xE3,0xFF},
{ 35,0x00,0xFF}, { 35,0x00,0xFF},
{ 36,0x06,0x1F}, { 36,0x06,0x1F},
{ 37,0x00,0x1F}, { 37,0x06,0x1F},
{ 38,0x00,0x1F}, { 38,0x06,0x1F},
{ 39,0x00,0x1F}, { 39,0x00,0x1F},
{ 40,0x63,0xFF}, { 40,0x63,0xFF},
{ 41,0x0C,0x7F}, { 41,0x0C,0x7F},
@ -191,18 +191,18 @@ unsigned char Reg_Store[][3] = {
{ 45,0x00,0xFF}, { 45,0x00,0xFF},
{ 46,0x00,0xFF}, { 46,0x00,0xFF},
{ 47,0x14,0x3F}, { 47,0x14,0x3F},
{ 48,0x38,0xFF}, { 48,0x2B,0xFF},
{ 49,0x00,0xFF}, { 49,0x00,0xFF},
{ 50,0xC4,0xFF}, { 50,0xC2,0xFF},
{ 51,0x07,0xFF}, { 51,0x27,0xFF},
{ 52,0x10,0xFF}, { 52,0x10,0xFF},
{ 53,0x00,0xFF}, { 53,0xD9,0xFF},
{ 54,0xB0,0xFF}, { 54,0x02,0xFF},
{ 55,0x00,0xFF}, { 55,0x84,0xFF},
{ 56,0x00,0xFF}, { 56,0x01,0xFF},
{ 57,0x00,0xFF}, { 57,0x00,0xFF},
{ 58,0x00,0xFF}, { 58,0x00,0xFF},
{ 59,0x01,0xFF}, { 59,0xB7,0xFF},
{ 60,0x00,0xFF}, { 60,0x00,0xFF},
{ 61,0x00,0xFF}, { 61,0x00,0xFF},
{ 62,0x00,0x3F}, { 62,0x00,0x3F},
@ -213,18 +213,18 @@ unsigned char Reg_Store[][3] = {
{ 67,0x00,0xFF}, { 67,0x00,0xFF},
{ 68,0x00,0xFF}, { 68,0x00,0xFF},
{ 69,0x00,0xFF}, { 69,0x00,0xFF},
{ 70,0x00,0xFF}, { 70,0x01,0xFF},
{ 71,0x00,0xFF}, { 71,0x00,0xFF},
{ 72,0x00,0xFF}, { 72,0x00,0xFF},
{ 73,0x00,0x3F}, { 73,0x00,0x3F},
{ 74,0x10,0xFF}, { 74,0x10,0xFF},
{ 75,0x00,0xFF}, { 75,0x38,0xFF},
{ 76,0x00,0xFF}, { 76,0xC3,0xFF},
{ 77,0x00,0xFF}, { 77,0x20,0xFF},
{ 78,0x00,0xFF}, { 78,0x00,0xFF},
{ 79,0x00,0xFF}, { 79,0x00,0xFF},
{ 80,0x00,0xFF}, { 80,0x00,0xFF},
{ 81,0x00,0xFF}, { 81,0x09,0xFF},
{ 82,0x00,0xFF}, { 82,0x00,0xFF},
{ 83,0x00,0xFF}, { 83,0x00,0xFF},
{ 84,0x00,0x3F}, { 84,0x00,0x3F},
@ -240,20 +240,20 @@ unsigned char Reg_Store[][3] = {
{ 94,0x00,0xFF}, { 94,0x00,0xFF},
{ 95,0x00,0x3F}, { 95,0x00,0x3F},
{ 96,0x10,0x00}, { 96,0x10,0x00},
{ 97,0x0F,0xFF}, { 97,0x9D,0xFF},
{ 98,0x2E,0xFF}, { 98,0x34,0xFF},
{ 99,0x24,0xFF}, { 99,0x1C,0xFF},
{100,0x00,0xFF}, {100,0x00,0xFF},
{101,0x00,0xFF}, {101,0x00,0xFF},
{102,0x00,0xFF}, {102,0x00,0xFF},
{103,0x19,0xFF}, {103,0x0D,0xFF},
{104,0x00,0xFF}, {104,0x00,0xFF},
{105,0x00,0xFF}, {105,0x00,0xFF},
{106,0x80,0xBF}, {106,0x80,0xBF},
{107,0x00,0xFF}, {107,0x00,0xFF},
{108,0x00,0xFF}, {108,0x00,0xFF},
{109,0x00,0xFF}, {109,0x00,0xFF},
{110,0xC0,0xFF}, {110,0x40,0xFF},
{111,0x00,0xFF}, {111,0x00,0xFF},
{112,0x00,0xFF}, {112,0x00,0xFF},
{113,0x00,0xFF}, {113,0x00,0xFF},
@ -491,7 +491,8 @@ unsigned char Reg_Store[][3] = {
{ 92,0x00,0x00}, { 92,0x00,0x00},
{ 93,0x00,0x00}, { 93,0x00,0x00},
{ 94,0x00,0x00}, { 94,0x00,0x00},
{255, 0, 0xFF} }; // set page bit to 0 {255, 0, 0xFF} };
unsigned char hello = 1; unsigned char hello = 1;
@ -575,6 +576,9 @@ void sendRegToSi5338(int increment)
unsigned char addr = Reg_Store[increment][0]; unsigned char addr = Reg_Store[increment][0];
unsigned char data = Reg_Store[increment][1]; unsigned char data = Reg_Store[increment][1];
unsigned char mask = Reg_Store[increment][2]; unsigned char mask = Reg_Store[increment][2];
// unsigned char addr = Reg_Store[increment].Reg_Addr;
// unsigned char data = Reg_Store[increment].Reg_Val;
// unsigned char mask = Reg_Store[increment].Reg_Mask;
// ignore registers with masks of 0x00 // ignore registers with masks of 0x00
if(mask != 0x00){ if(mask != 0x00){
@ -708,9 +712,23 @@ write_Si5338(230, 0x00); // OEB_ALL = 0
// } // }
//while(1); //while(1);
write_Si5338(31, 0xC1); //output driver off?
//Start us at a known frequency (in this case 14.06 which equals 7.03)
//TODO: Make this start at whatever the unit is supposed to power up at. Not hard coded
writeMultiSynthParameters(MULTISYNTH0, 201, 697, 703);
write_Si5338(31, 0xC0); //output driver off?
} }
void i2cLoop() {
unsigned long long vcoFreq = 2840000000;
double correctionFactor = 1;
void setFreq(unsigned long frequency)
{
//void i2cLoop() {
// put your main code here, to run repeatedly: // put your main code here, to run repeatedly:
//delay(400); //delay(400);
//write_Si5338(31, 0xC1); //output driver off? //write_Si5338(31, 0xC1); //output driver off?
@ -731,15 +749,34 @@ void i2cLoop() {
// if( integer >= 500) integer = 8; // if( integer >= 500) integer = 8;
// //
//} while (true); //} while (true);
//double desiredFrequency = 150.5;
//double measuredFrequency = 150.48806;
// correctionFactor = desiredFrequency/measuredFrequency;
// frequency *= correctionFactor;
frequency *= 2; //because the flipflops will devide it back down by 2
if(frequency < 5000000) return;
if(frequency > 350000000) return;
long integer = 199; unsigned long integer = vcoFreq / frequency;
long neumerator = 0;
//if((integer % 2) != 0) integer++;
unsigned long remainder = vcoFreq % frequency;
//do //do
//{ //{
writeMultiSynthParameters(MULTISYNTH0, integer, neumerator, 10000UL); //writeMultiSynthParameters(MULTISYNTH0, integer, neumerator, 10000UL);
//neumerator += 1000; //neumerator += 1000;
//if(neumerator > 9999) //if(neumerator > 9999)
//{ //{
@ -747,7 +784,7 @@ long neumerator = 0;
// integer++; // integer++;
//} //}
//if( integer >= 500) integer = 8; // if( integer >= 500) integer = 8;
//neumerator = (analogRead(A3) * 10); //578914 referal nu 801 435 7764 john thank you //neumerator = (analogRead(A3) * 10); //578914 referal nu 801 435 7764 john thank you
//integer = (analogRead(A2) /10) + 150; //integer = (analogRead(A2) /10) + 150;
@ -755,12 +792,23 @@ long neumerator = 0;
//} while (true); //} while (true);
write_Si5338(31, 0xC0); //output driver off? //write_Si5338(31, 0xC0); //output driver off?
//delay(400); //delay(400);
write_Si5338(31, 0xC1); //output driver off?
writeMultiSynthParameters(MULTISYNTH0, 397, 0, 10000UL);
write_Si5338(31, 0xC0); //output driver off?
while(frequency > 100000) //This value should be fine tuned. I thought the numerator and denominator could be 30 bits, but it seems to be less than 24
{
remainder /= 2;
frequency /= 2;
}
//write_Si5338(31, 0xC1); //output driver off?
writeMultiSynthParameters(MULTISYNTH0, integer, remainder , frequency);
//writeMultiSynthParameters(MULTISYNTH0, 232, 44960 , 122220);
//writeMultiSynthParameters(MULTISYNTH0, integer, /*neumerator*/ 0 , 1000000UL);
//write_Si5338(31, 0xC0); //output driver off?
} }

View file

@ -347,6 +347,7 @@ SysTick_Handler (void)
millis++; millis++;
timer_tick (); timer_tick ();
Tick(); Tick();
HAL_IncTick();
if(timingDelay > 0) timingDelay--; if(timingDelay > 0) timingDelay--;
} }
@ -719,6 +720,7 @@ void configUartPeripheral()
// __GPIOC_CLK_ENABLE(); // __GPIOC_CLK_ENABLE();
// __USART6_CLK_ENABLE(); // __USART6_CLK_ENABLE();
// //
// GPIO_InitTypeDef GPIO_InitStruct; // GPIO_InitTypeDef GPIO_InitStruct;
// //
//// //Setup TX Pin //// //Setup TX Pin
@ -821,6 +823,12 @@ main(int argc, char* argv[])
//__HAL_I2C_DISABLE(I2C2); //__HAL_I2C_DISABLE(I2C2);
//clearStuckBusyFlag(); //clearStuckBusyFlag();
RCC_PeriphCLKInitTypeDef i2cClk;
i2cClk.PeriphClockSelection = RCC_PERIPHCLK_I2C2;
i2cClk.I2c2ClockSelection = RCC_I2C2CLKSOURCE_PCLK1;
HAL_RCCEx_PeriphCLKConfig(&i2cClk);
handleI2C.Instance = I2C2; handleI2C.Instance = I2C2;
HAL_I2C_DeInit(&handleI2C); HAL_I2C_DeInit(&handleI2C);
@ -834,6 +842,7 @@ handleI2C.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
handleI2C.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; handleI2C.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED;
handleI2C.Init.OwnAddress1 = 0x30F; handleI2C.Init.OwnAddress1 = 0x30F;
handleI2C.Init.OwnAddress2 = 0xFE; handleI2C.Init.OwnAddress2 = 0xFE;
handleI2C.Init.Timing = ((uint32_t)0x40912732); //Not sure how this is calculated, taken from EVAL example
if(HAL_I2C_Init(&handleI2C) != HAL_OK) if(HAL_I2C_Init(&handleI2C) != HAL_OK)
@ -846,8 +855,8 @@ if(HAL_I2C_Init(&handleI2C) != HAL_OK)
HAL_StatusTypeDef result = HAL_ERROR; HAL_StatusTypeDef result = HAL_ERROR;
//while(result!= HAL_OK) while(result!= HAL_OK)
// result = HAL_I2C_IsDeviceReady(&handleI2C, (0x70 << 1), 100, 100); //We need to shift the address to the left for it to work (because of the R/W bit) result = HAL_I2C_IsDeviceReady(&handleI2C, (0x70 << 1), 100, 100); //We need to shift the address to the left for it to work (because of the R/W bit)
//HAL_I2C_Master_Transmit(&hi2c, 230, 0x10, 1, 1000); //write_Si5338(230, 0x10); //OEB_ALL = 1 //HAL_I2C_Master_Transmit(&hi2c, 230, 0x10, 1, 1000); //write_Si5338(230, 0x10); //OEB_ALL = 1
@ -860,7 +869,7 @@ HAL_StatusTypeDef result = HAL_ERROR;
//HAL_I2C_Master_Transmit(handleI2C, 230, 0x4F, 1, 1000); //write_Si5338(230, 0x10); //OEB_ALL = 1 //HAL_I2C_Master_Transmit(handleI2C, 230, 0x4F, 1, 1000); //write_Si5338(230, 0x10); //OEB_ALL = 1
i2cSetup(); i2cSetup();
i2cLoop(); //i2cLoop();
//trace_puts(( == HAL_OK ? "SI5338 Ready" : "SI5338 Not ready")); //trace_puts(( == HAL_OK ? "SI5338 Ready" : "SI5338 Not ready"));
@ -903,7 +912,7 @@ i2cLoop();
setGainPot(255, 255); setGainPot(250, 250);
//testing Uart //testing Uart
configUartPeripheral(); configUartPeripheral();
@ -990,52 +999,67 @@ void drawSMeter()
enum menuItems enum menuItems
{ {
oneMhzPlace = 0, volumeMenuItem = 0,
hundredKhzPlace = 1, modeMenuItem,
tenKhzPlace = 2, megahertzMenuItem,
oneKhzPlace = 3, hundredKilohertzMenuItem,
hundredHzPlace = 4, tenKilohertzMenuItem,
tenHzPlace = 5, kilohertzMenuItem,
oneHzPlace = 6, hundredHertzMenuItem,
filterLower = 7, tenHertzMenuItem,
filterUpper = 8, hertzMenuItem,
modeMenu = 9, filterLowMenuItem,
volumeMenu = 10, filterHighMenuItem
}; };
//enum menuItems
//{
// oneMhzPlace = 0,
// hundredKhzPlace = 1,
// tenKhzPlace = 2,
// oneKhzPlace = 3,
// hundredHzPlace = 4,
// tenHzPlace = 5,
// oneHzPlace = 6,
// filterLower = 7,
// filterUpper = 8,
// modeMenu = 9,
// volumeMenu = 10,
//};
void updateMenu() void updateMenu()
{ {
switch(menuPos) switch(menuPos)
{ {
case oneMhzPlace: case megahertzMenuItem:
frequencyDialMultiplier = 1000000; frequencyDialMultiplier = 1000000;
updateVfo(); updateVfo();
break; break;
case hundredKhzPlace: case hundredKilohertzMenuItem:
frequencyDialMultiplier = 100000; frequencyDialMultiplier = 100000;
updateVfo(); updateVfo();
break; break;
case tenKhzPlace: case tenKilohertzMenuItem:
frequencyDialMultiplier = 10000; frequencyDialMultiplier = 10000;
updateVfo(); updateVfo();
break; break;
case oneKhzPlace: case kilohertzMenuItem:
frequencyDialMultiplier = 1000; frequencyDialMultiplier = 1000;
updateVfo(); updateVfo();
break; break;
case hundredHzPlace: case hundredHertzMenuItem:
frequencyDialMultiplier = 100; frequencyDialMultiplier = 100;
updateVfo(); updateVfo();
break; break;
case tenHzPlace: case tenHertzMenuItem:
frequencyDialMultiplier = 10; frequencyDialMultiplier = 10;
updateVfo(); updateVfo();
break; break;
case oneHzPlace: case hertzMenuItem:
frequencyDialMultiplier = 1; frequencyDialMultiplier = 1;
updateVfo(); updateVfo();
break; break;
case filterLower: case filterLowMenuItem:
encoderPos = getPos(); encoderPos = getPos();
if(encoderPos != encoderLastPos) if(encoderPos != encoderLastPos)
{ {
@ -1047,7 +1071,7 @@ void updateMenu()
populateCoeficients(filterUpperLimit - filterLowerLimit, mode, filterLowerLimit); populateCoeficients(filterUpperLimit - filterLowerLimit, mode, filterLowerLimit);
} }
break; break;
case filterUpper: case filterHighMenuItem:
encoderPos = getPos(); encoderPos = getPos();
if(encoderPos != encoderLastPos) if(encoderPos != encoderLastPos)
{ {
@ -1059,7 +1083,7 @@ void updateMenu()
populateCoeficients(filterUpperLimit - filterLowerLimit, mode, filterLowerLimit); populateCoeficients(filterUpperLimit - filterLowerLimit, mode, filterLowerLimit);
} }
break; break;
case modeMenu: case modeMenuItem:
encoderPos = getPos(); encoderPos = getPos();
if(encoderPos != encoderLastPos) if(encoderPos != encoderLastPos)
{ {
@ -1071,7 +1095,7 @@ void updateMenu()
//Right now all this does is turns the AM decoder on and off, I guess. //Right now all this does is turns the AM decoder on and off, I guess.
} }
break; break;
case volumeMenu: case volumeMenuItem:
encoderPos = getPos(); encoderPos = getPos();
if(encoderPos != encoderLastPos) if(encoderPos != encoderLastPos)
{ {
@ -1116,11 +1140,13 @@ enum modes
AM = 2 AM = 2
}; };
void updateDisplay(uint8_t force) void updateDisplay(uint8_t force)
{ {
displayUpdating = 1; displayUpdating = 1;
static char freqChar[14]; static char freqChar[15];
static char lastFreqChar[] = {'$','$','$','$','$','$','$','$','$','$','$','$','$','$',}; static char lastFreqChar[] = {'$','$','$','$','$','$','$','$','$','$','$','$','$','$','$',};
//Draw elements that don't normally change. Static icons, etc. //Draw elements that don't normally change. Static icons, etc.
if(force) if(force)
@ -1129,46 +1155,71 @@ void updateDisplay(uint8_t force)
Adafruit_GFX_drawColorBitmap(150, 90, bitmapMode, 40,12, MASKWHITE); Adafruit_GFX_drawColorBitmap(150, 90, bitmapMode, 40,12, MASKWHITE);
Adafruit_GFX_fillTriangle(126,119,136,124,136,114,ILI9340_WHITE); Adafruit_GFX_fillTriangle(126,119,136,124,136,114,ILI9340_WHITE);
Adafruit_GFX_drawColorBitmap(150, 136, bitmapFilter, 47,12, MASKWHITE); Adafruit_GFX_drawColorBitmap(150, 136, bitmapFilter, 47,12, MASKWHITE);
drawNumber('.', freqHOffset + 16*2, freqVOffset + 0, MASKWHITE); drawNumber('.', freqHOffset + 16*3, freqVOffset + 0, MASKWHITE);
drawNumber('.', freqHOffset + 16*6, freqVOffset + 0, MASKWHITE); drawNumber('.', freqHOffset + 16*7, freqVOffset + 0, MASKWHITE);
Adafruit_GFX_drawColorBitmap(142, 162, bitmapSMeter, 155, 10, MASKWHITE); Adafruit_GFX_drawColorBitmap(142, 162, bitmapSMeter, 155, 10, MASKWHITE);
//Adafruit_GFX_drawColorBitmap(320 - 45 - 2, 240 - 46 - 2, bitmapHadLogo, 45, 46, MASKWHITE); //Adafruit_GFX_drawColorBitmap(320 - 45 - 2, 240 - 46 - 2, bitmapHadLogo, 45, 46, MASKWHITE);
} }
sprintf(&freqChar, "%8d", vfoAFrequency); sprintf(&freqChar, "%9d", vfoAFrequency);
//So on each of these elements, we update when the value changes, when we're forced to, when the item becomes selected, or unselected. //So on each of these elements, we update when the value changes, when we're forced to, when the item becomes selected, or unselected.
if(freqChar[0] != lastFreqChar[0] || force || (menuPos != menuLastPos && (menuPos == 0 || menuLastPos == 0))) if(freqChar[0] != lastFreqChar[0]
|| force
|| (menuPos != menuLastPos && (menuPos == megahertzMenuItem
|| menuLastPos == megahertzMenuItem)))
{ {
drawNumber(freqChar[0], freqHOffset + 16*0, freqVOffset + 0, menuPos == 0 ? MASKRED : MASKWHITE); drawNumber(freqChar[0], freqHOffset + 16*0, freqVOffset + 0,
menuPos == megahertzMenuItem ? MASKRED : MASKWHITE);
} }
if(freqChar[1] != lastFreqChar[1] || redItems[0] || force || (menuPos != menuLastPos && (menuPos == 0 || menuLastPos == 0))) if(freqChar[1] != lastFreqChar[1]
|| redItems[0]
|| force
|| (menuPos != menuLastPos && (menuPos == megahertzMenuItem
|| menuLastPos == megahertzMenuItem)))
{ {
drawNumber(freqChar[1], freqHOffset + 16*1, freqVOffset + 0, menuPos == 0 ? MASKRED : MASKWHITE); drawNumber(freqChar[1], freqHOffset + 16*1, freqVOffset + 0,
menuPos == megahertzMenuItem ? MASKRED : MASKWHITE);
} }
if(freqChar[2] != lastFreqChar[2] || force || (menuPos != menuLastPos && (menuPos == 1 || menuLastPos == 1))) if(freqChar[2] != lastFreqChar[2]
|| force
|| (menuPos != menuLastPos && (menuPos == megahertzMenuItem
|| menuLastPos == megahertzMenuItem)))
{ {
drawNumber(freqChar[2], freqHOffset + 16*3, freqVOffset + 0, menuPos == 1 ? MASKRED : MASKWHITE); drawNumber(freqChar[2], freqHOffset + 16*2, freqVOffset + 0,
menuPos == megahertzMenuItem ? MASKRED : MASKWHITE);
} }
if(freqChar[3] != lastFreqChar[3] || force || (menuPos != menuLastPos && (menuPos == 2 || menuLastPos == 2))) if(freqChar[3] != lastFreqChar[3]
|| force
|| (menuPos != menuLastPos && (menuPos == hundredKilohertzMenuItem
|| menuLastPos == hundredKilohertzMenuItem)))
{ {
drawNumber(freqChar[3], freqHOffset + 16*4, freqVOffset + 0, menuPos == 2 ? MASKRED : MASKWHITE); drawNumber(freqChar[3], freqHOffset + 16*4, freqVOffset + 0,
menuPos == hundredKilohertzMenuItem ? MASKRED : MASKWHITE);
} }
if(freqChar[4] != lastFreqChar[4] || force || (menuPos != menuLastPos && (menuPos == 3 || menuLastPos == 3))) if(freqChar[4] != lastFreqChar[4]
|| force
|| (menuPos != menuLastPos && (menuPos == tenKilohertzMenuItem
|| menuLastPos == tenKilohertzMenuItem)))
{ {
drawNumber(freqChar[4], freqHOffset + 16*5, freqVOffset + 0, menuPos == 3 ? MASKRED : MASKWHITE); drawNumber(freqChar[4], freqHOffset + 16*5, freqVOffset + 0,
menuPos == tenKilohertzMenuItem ? MASKRED : MASKWHITE);
} }
if(freqChar[5] != lastFreqChar[5] || force || (menuPos != menuLastPos && (menuPos == 4 || menuLastPos == 4))) if(freqChar[5] != lastFreqChar[5] || force || (menuPos != menuLastPos && (menuPos == kilohertzMenuItem || menuLastPos == kilohertzMenuItem)))
{ {
drawNumber(freqChar[5], freqHOffset + 16*7, freqVOffset + 0, menuPos == 4 ? MASKRED : MASKWHITE); drawNumber(freqChar[5], freqHOffset + 16*6, freqVOffset + 0, menuPos == kilohertzMenuItem ? MASKRED : MASKWHITE);
} }
if(freqChar[6] != lastFreqChar[6] || force || (menuPos != menuLastPos && (menuPos == 5 || menuLastPos == 5))) if(freqChar[6] != lastFreqChar[6] || force || (menuPos != menuLastPos && (menuPos == hundredHertzMenuItem || menuLastPos == hundredHertzMenuItem)))
{ {
drawNumber(freqChar[6], freqHOffset + 16*8, freqVOffset + 0, menuPos == 5 ? MASKRED : MASKWHITE); drawNumber(freqChar[6], freqHOffset + 16*8, freqVOffset + 0, menuPos == hundredHertzMenuItem ? MASKRED : MASKWHITE);
} }
if(freqChar[7] != lastFreqChar[7] || force || (menuPos != menuLastPos && (menuPos == 6 || menuLastPos == 6))) if(freqChar[7] != lastFreqChar[7] || force || (menuPos != menuLastPos && (menuPos == tenHertzMenuItem || menuLastPos == tenHertzMenuItem)))
{ {
drawNumber(freqChar[7], freqHOffset + 16*9, freqVOffset + 0, menuPos == 6 ? MASKRED : MASKWHITE); drawNumber(freqChar[7], freqHOffset + 16*9, freqVOffset + 0, menuPos == tenHertzMenuItem ? MASKRED : MASKWHITE);
}
if(freqChar[8] != lastFreqChar[8] || force || (menuPos != menuLastPos && (menuPos == hertzMenuItem || menuLastPos == hertzMenuItem)))
{
drawNumber(freqChar[8], freqHOffset + 16*10, freqVOffset + 0, menuPos == hertzMenuItem ? MASKRED : MASKWHITE);
} }
vfoALastFreq = vfoAFrequency; vfoALastFreq = vfoAFrequency;
@ -1176,7 +1227,11 @@ void updateDisplay(uint8_t force)
int redrawFilterBar = 0; int redrawFilterBar = 0;
if(mode != modeLast || filterLowerLimit != filterLastLowerLimit || force || (menuPos != menuLastPos && (menuPos == 7 || menuLastPos == 7))) if(mode != modeLast
|| filterLowerLimit != filterLastLowerLimit
|| force
|| (menuPos != menuLastPos && (menuPos == filterLowMenuItem
|| menuLastPos == filterLowMenuItem)))
{ {
sprintf(&freqChar, "%4d", filterLowerLimit * 40); sprintf(&freqChar, "%4d", filterLowerLimit * 40);
//Adafruit_GFX_setTextSize(2); //Adafruit_GFX_setTextSize(2);
@ -1186,7 +1241,7 @@ void updateDisplay(uint8_t force)
for(i = 0; i < 4; i++) for(i = 0; i < 4; i++)
{ {
//Adafruit_GFX_write(freqChar[i]); //Adafruit_GFX_write(freqChar[i]);
drawNumberSmall(freqChar[i], 205 + (i * 9), 137, menuPos == 7 ? MASKRED : MASKWHITE); drawNumberSmall(freqChar[i], 205 + (i * 9), 137, menuPos == filterLowMenuItem ? MASKRED : MASKWHITE);
} }
//Adafruit_GFX_setTextSize(3); //Adafruit_GFX_setTextSize(3);
@ -1194,7 +1249,11 @@ void updateDisplay(uint8_t force)
filterLastLowerLimit = filterLowerLimit; filterLastLowerLimit = filterLowerLimit;
} }
if(mode != modeLast || filterUpperLimit != filterLastUpperLimit || force || (menuPos != menuLastPos && (menuPos == 8 || menuLastPos == 8))) if(mode != modeLast
|| filterUpperLimit != filterLastUpperLimit
|| force
|| (menuPos != menuLastPos && (menuPos == filterHighMenuItem
|| menuLastPos == filterHighMenuItem)))
{ {
sprintf(&freqChar, "%-4d", filterUpperLimit * 40); sprintf(&freqChar, "%-4d", filterUpperLimit * 40);
//Adafruit_GFX_setTextSize(2); //Adafruit_GFX_setTextSize(2);
@ -1204,7 +1263,7 @@ void updateDisplay(uint8_t force)
for(i = 0; i < 4; i++) for(i = 0; i < 4; i++)
{ {
//Adafruit_GFX_write(freqChar[i]); //Adafruit_GFX_write(freqChar[i]);
drawNumberSmall(freqChar[i], 250 + (i * 9), 137, menuPos == 8 ? MASKRED : MASKWHITE); drawNumberSmall(freqChar[i], 250 + (i * 9), 137, menuPos == filterHighMenuItem ? MASKRED : MASKWHITE);
} }
//Adafruit_GFX_setTextSize(3); //Adafruit_GFX_setTextSize(3);
@ -1213,14 +1272,14 @@ void updateDisplay(uint8_t force)
} }
if(afGainLast != afGain || force || (menuPos != menuLastPos && (menuPos == volumeMenu || menuLastPos == volumeMenu))) if(afGainLast != afGain || force || (menuPos != menuLastPos && (menuPos == volumeMenuItem || menuLastPos == volumeMenuItem)))
{ {
sprintf(&freqChar, "%-4f", afGain * 100); sprintf(&freqChar, "%-4f", afGain * 100);
int i; int i;
for(i = 0; i < 4; i++) for(i = 0; i < 4; i++)
{ {
//Adafruit_GFX_write(freqChar[i]); //Adafruit_GFX_write(freqChar[i]);
drawNumberSmall(freqChar[i], 250 + (i * 9), 10, menuPos == volumeMenu ? MASKRED : MASKWHITE); drawNumberSmall(freqChar[i], 250 + (i * 9), 10, menuPos == volumeMenuItem ? MASKRED : MASKWHITE);
} }
afGainLast = afGain; afGainLast = afGain;
@ -1250,18 +1309,21 @@ void updateDisplay(uint8_t force)
} }
if(mode != modeLast || force || (menuPos != menuLastPos && (menuPos == 9 || menuLastPos == 9))) if(mode != modeLast
|| force
|| (menuPos != menuLastPos && (menuPos == modeMenuItem
|| menuLastPos == modeMenuItem)))
{ {
switch(mode) switch(mode)
{ {
case LSB: case LSB:
Adafruit_GFX_drawColorBitmap(196, 91, bitmapLSB, 28, 9, menuPos == 9 ? MASKRED : MASKWHITE); Adafruit_GFX_drawColorBitmap(196, 91, bitmapLSB, 28, 9, menuPos == modeMenuItem ? MASKRED : MASKWHITE);
break; break;
case USB: case USB:
Adafruit_GFX_drawColorBitmap(196, 91, bitmapUSB, 28, 9, menuPos == 9 ? MASKRED : MASKWHITE); Adafruit_GFX_drawColorBitmap(196, 91, bitmapUSB, 28, 9, menuPos == modeMenuItem ? MASKRED : MASKWHITE);
break; break;
case AM: case AM:
Adafruit_GFX_drawColorBitmap(196, 91, bitmapAM, 28, 9, menuPos == 9 ? MASKRED : MASKWHITE); Adafruit_GFX_drawColorBitmap(196, 91, bitmapAM, 28, 9, menuPos == modeMenuItem ? MASKRED : MASKWHITE);
break; break;
} }
@ -1503,8 +1565,8 @@ void updateVfo()
vfoAFrequency += frequencyDialMultiplier * (encoderLastPos - encoderPos); vfoAFrequency += frequencyDialMultiplier * (encoderLastPos - encoderPos);
if(vfoAFrequency < 1) vfoAFrequency = 1; if(vfoAFrequency < 2500000) vfoAFrequency = 2500000; //Currently, the code can only corectly drive down to 5MHz/2 = 2.5MHz
if(vfoAFrequency > 37500000) vfoAFrequency = 37500000; if(vfoAFrequency > 175000000) vfoAFrequency = 175000000; //Currently, the code can only correctly drive up to 350MHz/2 = 175MHz
encoderLastPos = encoderPos; encoderLastPos = encoderPos;
} }