This commit is contained in:
nzasch
2022-01-03 17:52:27 +01:00
parent 9a2f5c0069
commit b9a7a1e15b
9 changed files with 168 additions and 50 deletions

View File

@@ -67,6 +67,8 @@ TIM_HandleTypeDef htim8;
UART_HandleTypeDef huart1;
DMA_HandleTypeDef hdma_usart1_tx;
PCD_HandleTypeDef hpcd_USB_FS;
/* USER CODE BEGIN PV */
volatile uint8_t tick;
@@ -96,6 +98,7 @@ static void MX_I2C1_Init(void);
static void MX_ADC2_Init(void);
static void MX_DAC3_Init(void);
static void MX_OPAMP2_Init(void);
static void MX_USB_PCD_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
@@ -146,13 +149,13 @@ void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef* hdac) {
// tx
void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef* hdac) {
// HAL_GPIO_TogglePin(OUT_GPIO_Port, OUT_Pin);
// HAL_GPIO_TogglePin(GPIO1_GPIO_Port, GPIO1_Pin);
tx_dac_buffer_toggle = 0;
half_tx_dac_buffer_empty = 1;
}
void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef* hdac) {
// HAL_GPIO_TogglePin(OUT_GPIO_Port, OUT_Pin);
// HAL_GPIO_TogglePin(GPIO1_GPIO_Port, GPIO1_Pin);
tx_dac_buffer_toggle = 1;
half_tx_dac_buffer_empty = 1;
}
@@ -347,6 +350,7 @@ int main(void)
MX_ADC2_Init();
MX_DAC3_Init();
MX_OPAMP2_Init();
MX_USB_PCD_Init();
/* USER CODE BEGIN 2 */
HAL_Delay(10);
@@ -383,32 +387,32 @@ int main(void)
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_GPIO_TogglePin(OUT_GPIO_Port, OUT_Pin);
HAL_GPIO_TogglePin(GPIO1_GPIO_Port, GPIO1_Pin);
// receive = transmit = 0;
if(receive){
if(rx_adc_buffer_ready){
// HAL_GPIO_WritePin(OUT_GPIO_Port, OUT_Pin, SET);
// HAL_GPIO_WritePin(GPIO1_GPIO_Port, GPIO1_Pin, SET);
rx_mixer(adc_buffer, RX_ADC_BUFFER_SIZE, if_I, if_Q, rx_nco1_increment);
// HAL_GPIO_WritePin(OUT_GPIO_Port, OUT_Pin, RESET);
// HAL_GPIO_WritePin(GPIO1_GPIO_Port, GPIO1_Pin, RESET);
rx_adc_buffer_ready = 0;
}
if(half_rx_dac_buffer_empty){
// HAL_GPIO_WritePin(OUT_GPIO_Port, OUT_Pin, SET);
// HAL_GPIO_WritePin(GPIO1_GPIO_Port, GPIO1_Pin, SET);
if (modulation == MOD_DC) dc_demodulator(if_I, LF_BUFFER_SIZE, prefilter_lf_buffer);
else if(modulation == MOD_LSB || modulation == MOD_USB) ssb_demodulator(if_I, if_Q, LF_BUFFER_SIZE, prefilter_lf_buffer, NCO2_INCREMENT);
else if (modulation == MOD_AM) am_demodulator(if_I, if_Q, LF_BUFFER_SIZE, prefilter_lf_buffer);
arm_fir_q31(&audio_filter_struct, prefilter_lf_buffer, lf_buffer[lf_buffer_toggle], AUDIO_FILTER_BLOCK_SIZE);
arm_fir_q31(&audio_filter_struct, prefilter_lf_buffer, lf_buffer[lf_buffer_toggle], RX_AUDIO_FILTER_BLOCK_SIZE);
// arm_fir_q31(&audio_filter_struct, prefilter_lf_buffer, lf_buffer_test[lf_buffer_toggle], AUDIO_FILTER_BLOCK_SIZE);
// HAL_GPIO_WritePin(OUT_GPIO_Port, OUT_Pin, RESET);
// HAL_GPIO_WritePin(GPIO1_GPIO_Port, GPIO1_Pin, RESET);
half_rx_dac_buffer_empty = 0;
}
}
if (transmit){
if(half_tx_dac_buffer_empty){
// HAL_GPIO_WritePin(OUT_GPIO_Port, OUT_Pin, SET);
// HAL_GPIO_WritePin(GPIO1_GPIO_Port, GPIO1_Pin, SET);
tx_mixer(tx_dac_buffer[tx_dac_buffer_toggle], TX_DAC_BUFFER_SIZE, if_I, if_Q, tx_nco1_increment);
half_tx_dac_buffer_empty = 0;
// HAL_GPIO_WritePin(OUT_GPIO_Port, OUT_Pin, RESET);
// HAL_GPIO_WritePin(GPIO1_GPIO_Port, GPIO1_Pin, RESET);
}
if(tx_adc_buffer_ready){
if (modulation == MOD_DC) dc_modulator(if_I, LF_BUFFER_SIZE, prefilter_lf_buffer);
@@ -478,14 +482,15 @@ void SystemClock_Config(void)
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV2;
RCC_OscInitStruct.PLL.PLLN = 28;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV6;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
@@ -1061,6 +1066,39 @@ static void MX_USART1_UART_Init(void)
}
/**
* @brief USB Initialization Function
* @param None
* @retval None
*/
static void MX_USB_PCD_Init(void)
{
/* USER CODE BEGIN USB_Init 0 */
/* USER CODE END USB_Init 0 */
/* USER CODE BEGIN USB_Init 1 */
/* USER CODE END USB_Init 1 */
hpcd_USB_FS.Instance = USB;
hpcd_USB_FS.Init.dev_endpoints = 8;
hpcd_USB_FS.Init.speed = PCD_SPEED_FULL;
hpcd_USB_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
hpcd_USB_FS.Init.Sof_enable = DISABLE;
hpcd_USB_FS.Init.low_power_enable = DISABLE;
hpcd_USB_FS.Init.lpm_enable = DISABLE;
hpcd_USB_FS.Init.battery_charging_enable = DISABLE;
if (HAL_PCD_Init(&hpcd_USB_FS) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USB_Init 2 */
/* USER CODE END USB_Init 2 */
}
/**
* Enable DMA controller clock
*/
@@ -1102,7 +1140,10 @@ static void MX_GPIO_Init(void)
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(OUT_GPIO_Port, OUT_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIO4_GPIO_Port, GPIO4_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, GPIO3_Pin|GPIO2_Pin|GPIO1_Pin, GPIO_PIN_RESET);
/*Configure GPIO pins : NC1_Pin NC2_Pin */
GPIO_InitStruct.Pin = NC1_Pin|NC2_Pin;
@@ -1118,12 +1159,25 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pin : OUT_Pin */
GPIO_InitStruct.Pin = OUT_Pin;
/*Configure GPIO pin : GPIO4_Pin */
GPIO_InitStruct.Pin = GPIO4_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
HAL_GPIO_Init(OUT_GPIO_Port, &GPIO_InitStruct);
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIO4_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : GPIO3_Pin GPIO2_Pin GPIO1_Pin */
GPIO_InitStruct.Pin = GPIO3_Pin|GPIO2_Pin|GPIO1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pin : PTT_Pin */
GPIO_InitStruct.Pin = PTT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(PTT_GPIO_Port, &GPIO_InitStruct);
}