#include mess sorted out I think

This commit is contained in:
Paul Warren 2021-02-11 11:30:51 +11:00
parent 3a473c183c
commit 46bdb983b3
8 changed files with 80 additions and 52 deletions

View File

@ -10,15 +10,12 @@
//#ifdef PSDR257
#include "stm32f7xx.h"
//#include "stm32f746xx.h"
#include "stm32f746xx.h"
//#include "stm32f7xx_hal.h"
//#endif
#include <stdbool.h>
#include <Adafruit_ILI9340.h>
//#include <Adafruit_SSD1306.h>
#include "usart.h"
#define swap(a, b) { int16_t t = a; a = b; b = t; }

View File

@ -66,7 +66,7 @@ extern ADC_HandleTypeDef hadc2;
extern ADC_HandleTypeDef hadc3;
/* USER CODE BEGIN Private defines */
uint8_t wrongThings;
/* USER CODE END Private defines */
extern void _Error_Handler(char *, int);
@ -76,7 +76,15 @@ void MX_ADC2_Init(void);
void MX_ADC3_Init(void);
/* USER CODE BEGIN Prototypes */
__IO uint16_t uhADCxConvertedValue1;
__IO uint16_t uhADCxConvertedValue2;
__IO uint16_t uhADCxConvertedValue3;
uint8_t adcConfigured;
uint16_t sampleIndex;
volatile uint8_t sampleRun;
void adcGetConversion(void);
void adcStartConversion(void);
/* USER CODE END Prototypes */
#ifdef __cplusplus

View File

@ -55,7 +55,7 @@
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f7xx_hal.h"
#include "stm32f7xx.h"
#include "main.h"
/* USER CODE BEGIN Includes */

View File

@ -42,7 +42,7 @@
//#define ART_ACCLERATOR_ENABLE 1
#include "stm32f7xx.h"
#include "stm32f7xx_hal.h"
//#include "stm32f7xx_hal.h"
//#include "stm32f7xx_hal_conf.h"
//#include "stm32f7xx_hal.h"
//#include "stm32f7xx_hal_gpio.h"
@ -73,6 +73,7 @@
#include "Adafruit_ILI9340.h"
#include "string.h"
#include "images.h"
#include "frequency_control.h"
//#include "usart.h"
//TIM_HandleTypeDef TimHandle;

View File

@ -343,6 +343,60 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)
}
/* USER CODE BEGIN 1 */
void adcGetConversion(void)
{
HAL_StatusTypeDef result = HAL_ADC_PollForConversion(&hadc1, 100);
result = HAL_ADC_PollForConversion(&hadc2, 100);
result = HAL_ADC_PollForConversion(&hadc3, 100);
if (result == HAL_OK)
{
//while(HAL_ADC_GetState(&hadc1) != HAL_ADC_STATE_REG_EOC);
/* Check if the continous conversion of regular channel is finished */
// if(HAL_ADC_GetState(&hadc1) == 0x300 /*HAL_ADC_STATE_REG_EOC*/
// && HAL_ADC_GetState(&hadc2) == 0x300 /*HAL_ADC_STATE_REG_EOC*/
// && HAL_ADC_GetState(&hadc3) == 0x300 /*HAL_ADC_STATE_REG_EOC*/)
if(HAL_IS_BIT_SET(HAL_ADC_GetState(&hadc1), HAL_ADC_STATE_REG_EOC) &&
HAL_IS_BIT_SET(HAL_ADC_GetState(&hadc2), HAL_ADC_STATE_REG_EOC) &&
HAL_IS_BIT_SET(HAL_ADC_GetState(&hadc3), HAL_ADC_STATE_REG_EOC))
{
/*##-5- Get the converted value of regular channel ########################*/
uhADCxConvertedValue1 = HAL_ADC_GetValue(&hadc1);
uhADCxConvertedValue2 = HAL_ADC_GetValue(&hadc2);
uhADCxConvertedValue3 = HAL_ADC_GetValue(&hadc3);
}
}
}
void adcStartConversion(void)
{
if(HAL_ADC_Start(&hadc1) != HAL_OK)
{
/* Start Conversation Error */
//Error_Handler();
wrongThings++;
}
if(HAL_ADC_Start(&hadc2) != HAL_OK)
{
/* Start Conversation Error */
//Error_Handler();
wrongThings++;
}
if(HAL_ADC_Start(&hadc3) != HAL_OK)
{
/* Start Conversation Error */
//Error_Handler();
wrongThings++;
}
}
/* USER CODE END 1 */

View File

@ -2,12 +2,8 @@
#include <stdbool.h>
#include "si5338.h"
#include "stm32f7xx_hal.h"
//#include "stm32f7xx_hal_i2c.h"
//#include "stm32f7xx_hal_rcc_ex.h"
#include "stm32f7xx.h"
#include "diag/Trace.h"
//#include "stm32f7xx_hal_i2c.h"
#define SI5338_ADDRESS 0x70
I2C_HandleTypeDef handleI2C;

View File

@ -90,7 +90,7 @@ void MX_GPIO_Init(void)
|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13|GPIO_PIN_1|TESTTEST_Pin|GPIO_PIN_3, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13|GPIO_PIN_1|GPIO_PIN_3, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8
@ -114,7 +114,7 @@ void MX_GPIO_Init(void)
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pins : PC13 PC1 PCPin PC3 */
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_1|TESTTEST_Pin|GPIO_PIN_3;
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_1|GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

View File

@ -65,6 +65,7 @@
/* USER CODE BEGIN Includes */
#include "main.h"
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
@ -291,36 +292,6 @@ void teardownPeripheralPower()
__I2C2_CLK_DISABLE();
}
void configDMA(SPI_HandleTypeDef *hspi)
{
hdma_tx.Instance = SPIx_TX_DMA_STREAM;
hdma_tx.Init.Channel = SPIx_TX_DMA_CHANNEL;
hdma_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_tx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_tx.Init.MemInc = DMA_MINC_ENABLE;
hdma_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; //DMA_MDATAALIGN_BYTE;
hdma_tx.Init.Mode = DMA_NORMAL;
hdma_tx.Init.Priority = DMA_PRIORITY_HIGH; //DMA_PRIORITY_VERY_HIGH;
hdma_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
hdma_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
hdma_tx.Init.MemBurst = DMA_MBURST_INC4;
hdma_tx.Init.PeriphBurst = DMA_PBURST_INC4;
HAL_DMA_Init(&hdma_tx);
/* Associate the initialized DMA handle to the the SPI handle */
__HAL_LINKDMA(hspi, hdmatx, hdma_tx);
/*##-4- Configure the NVIC for DMA #########################################*/
/* NVIC configuration for DMA transfer complete interrupt (SPI3_TX) */
HAL_NVIC_SetPriority(15/*SPIx_DMA_TX_IRQn*/, 4, 4);
HAL_NVIC_EnableIRQ(SPIx_DMA_TX_IRQn);
}
void doNothing()
{
@ -851,13 +822,13 @@ int main(void)
setupPeripheralPower();
hal_setupPins();
spi_init();
//spi_init();
configDMA(&SpiHandle );
// configDMA(&hspi1);
initFrequencySynth();
setFreq(vfoAFrequency);
setFrequency(vfoAFrequency);
timer_start();
@ -989,7 +960,7 @@ int main(void)
}
/* USER CODE END 3 */
}
/**
* @brief System Clock Configuration
@ -1430,9 +1401,10 @@ void updateDisplay(uint8_t force)
}
if(afGain * 0.99 )
menuLastPos = menuPos;
if(afGain * 0.99 == 1)
{
menuLastPos = menuPos;
}
displayUpdating = 0;
}
@ -1679,7 +1651,7 @@ void updateVfo(void)
if(vfoAFrequency != vfoALastFreq)
{
setFreq(vfoAFrequency);
setFrequency(vfoAFrequency);
}
}