refactor
This commit is contained in:
Binary file not shown.
@@ -63,12 +63,20 @@ void set_gain(void);
|
||||
#define NC1_GPIO_Port GPIOA
|
||||
#define NC2_Pin GPIO_PIN_2
|
||||
#define NC2_GPIO_Port GPIOA
|
||||
#define OUT_Pin GPIO_PIN_12
|
||||
#define OUT_GPIO_Port GPIOA
|
||||
#define T_SWDIO_Pin GPIO_PIN_13
|
||||
#define T_SWDIO_GPIO_Port GPIOA
|
||||
#define T_SWCLK_Pin GPIO_PIN_14
|
||||
#define T_SWCLK_GPIO_Port GPIOA
|
||||
#define GPIO4_Pin GPIO_PIN_15
|
||||
#define GPIO4_GPIO_Port GPIOA
|
||||
#define GPIO3_Pin GPIO_PIN_3
|
||||
#define GPIO3_GPIO_Port GPIOB
|
||||
#define GPIO2_Pin GPIO_PIN_4
|
||||
#define GPIO2_GPIO_Port GPIOB
|
||||
#define GPIO1_Pin GPIO_PIN_5
|
||||
#define GPIO1_GPIO_Port GPIOB
|
||||
#define PTT_Pin GPIO_PIN_6
|
||||
#define PTT_GPIO_Port GPIOB
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#define RX_ADC_BUFFER_SIZE (1024)
|
||||
#define RX_ADC_SAMPLES_BUFFER_RATE (RX_ADC_SAMPLE_RATE/RX_ADC_BUFFER_SIZE)
|
||||
|
||||
|
||||
#define NCO2_INCREMENT (343597383L)
|
||||
#define NCO2_FREQUENCY (RX_DAC_SAMPLE_RATE/((0xFFFFFFFF)/NCO2_INCREMENT))
|
||||
// RX DAC
|
||||
#define RX_DAC_DIVISOR 7680
|
||||
#define RX_DAC_SAMPLE_RATE (CLOCK/RX_DAC_DIVISOR) // 21875
|
||||
|
||||
// 1° stadio
|
||||
// decimazione del singolo stadio
|
||||
@@ -38,20 +38,20 @@
|
||||
#define LF_BUFFER_SIZE (ST2_BUFFER_SIZE/ST2_DECIMATION_FACTOR)
|
||||
|
||||
// audio filter
|
||||
#define AUDIO_FILTER_TAP_NUM 128
|
||||
#define AUDIO_FILTER_FREQ_DEF (1250)
|
||||
#define AUDIO_FILTER_FREQ_MAX (RX_DAC_SAMPLE_RATE/2)
|
||||
#define AUDIO_FILTER_BW_DEF (2000)
|
||||
#define AUDIO_FILTER_BW_MAX (RX_DAC_SAMPLE_RATE/2)
|
||||
#define AUDIO_FILTER_BETA_DEF (16)
|
||||
#define AUDIO_FILTER_BLOCK_SIZE LF_BUFFER_SIZE
|
||||
#define RX_AUDIO_FILTER_TAP_NUM 128
|
||||
#define RX_AUDIO_FILTER_FREQ_DEF (1250)
|
||||
#define RX_AUDIO_FILTER_FREQ_MAX (RX_DAC_SAMPLE_RATE/2)
|
||||
#define RX_AUDIO_FILTER_BW_DEF (2000)
|
||||
#define RX_AUDIO_FILTER_BW_MAX (RX_DAC_SAMPLE_RATE/2)
|
||||
#define RX_AUDIO_FILTER_BETA_DEF (16)
|
||||
#define RX_AUDIO_FILTER_BLOCK_SIZE LF_BUFFER_SIZE
|
||||
|
||||
// demodulatore
|
||||
#define NCO2_INCREMENT (343597383L)
|
||||
#define NCO2_FREQUENCY (RX_DAC_SAMPLE_RATE/((0xFFFFFFFF)/NCO2_INCREMENT)) // 1750
|
||||
|
||||
#define RX_SMETER_SCALE 4
|
||||
|
||||
// === DAC ===
|
||||
#define RX_DAC_DIVISOR 7680
|
||||
#define RX_DAC_SAMPLE_RATE (CLOCK/RX_DAC_DIVISOR)
|
||||
|
||||
extern uint8_t rx_signal, rx_signal_last;
|
||||
extern q31_t rx_nco1_increment;
|
||||
|
||||
@@ -65,8 +65,8 @@ extern int32_t st2_wide_taps[ST2_FILTER_TAP_NUM];
|
||||
|
||||
// filtro audio
|
||||
extern arm_fir_instance_q31 audio_filter_struct;
|
||||
extern q31_t audio_filter_state[AUDIO_FILTER_BLOCK_SIZE + AUDIO_FILTER_TAP_NUM - 1];
|
||||
extern int32_t audio_filter_coeffs[AUDIO_FILTER_TAP_NUM];
|
||||
extern q31_t audio_filter_state[RX_AUDIO_FILTER_BLOCK_SIZE + RX_AUDIO_FILTER_TAP_NUM - 1];
|
||||
extern int32_t audio_filter_coeffs[RX_AUDIO_FILTER_TAP_NUM];
|
||||
|
||||
// mix
|
||||
void rx_mixer(uint16_t *in, uint16_t size, q31_t *I_out, q31_t *Q_out, int32_t nco_freq);
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
/*#define HAL_NAND_MODULE_ENABLED */
|
||||
/*#define HAL_NOR_MODULE_ENABLED */
|
||||
#define HAL_OPAMP_MODULE_ENABLED
|
||||
/*#define HAL_PCD_MODULE_ENABLED */
|
||||
#define HAL_PCD_MODULE_ENABLED
|
||||
/*#define HAL_QSPI_MODULE_ENABLED */
|
||||
/*#define HAL_RNG_MODULE_ENABLED */
|
||||
/*#define HAL_RTC_MODULE_ENABLED */
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
#define TX_DAC_BUFFER_SIZE (1024)
|
||||
#define TX_DAC_BUFFER_RATE (TX_DAC_SAMPLE_RATE/TX_DAC_BUFFER_SIZE)
|
||||
|
||||
// TX ADC
|
||||
#define TX_ADC_DIVISOR 7680
|
||||
#define TX_ADC_SAMPLE_RATE (CLOCK/TX_ADC_DIVISOR) // 21875
|
||||
|
||||
extern uint8_t tx_signal, tx_signal_last;
|
||||
extern q31_t tx_nco1_increment;
|
||||
|
||||
|
||||
@@ -142,7 +142,6 @@ void set_modulation(void){
|
||||
st2_filter_init();
|
||||
// cambia offset
|
||||
set_frequency();
|
||||
// nco1_increment = set_nco1_freq(frequency);
|
||||
}
|
||||
|
||||
void set_dummy(void){
|
||||
@@ -169,9 +168,9 @@ void state_set_default(void){
|
||||
set_frequency();
|
||||
gain = 2;
|
||||
volume = 8;
|
||||
audio_filter_freq = AUDIO_FILTER_FREQ_DEF;
|
||||
audio_filter_bw = AUDIO_FILTER_BW_DEF;
|
||||
audio_filter_beta = AUDIO_FILTER_BETA_DEF;
|
||||
audio_filter_freq = RX_AUDIO_FILTER_FREQ_DEF;
|
||||
audio_filter_bw = RX_AUDIO_FILTER_BW_DEF;
|
||||
audio_filter_beta = RX_AUDIO_FILTER_BETA_DEF;
|
||||
audio_filter_generate_coeffs(audio_filter_coeffs, audio_filter_freq, audio_filter_bw, audio_filter_beta);
|
||||
state_changed = 0xFFFF;
|
||||
// strcpy(tabstring, "TX AUD MEM NO");
|
||||
@@ -202,7 +201,6 @@ uint16_t get_pwm_period(uint32_t pwm_frequency){
|
||||
|
||||
uint8_t measure_log_abs_mean(q31_t *samples, uint16_t size){
|
||||
int32_t measured_signal = 0;
|
||||
// , old_rx_signal;
|
||||
uint16_t index = 0;
|
||||
uint8_t log_sig = 31;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ q31_t st2_filter_Q_state[ST2_FILTER_BLOCK_SIZE + ST2_FILTER_TAP_NUM - 1];
|
||||
|
||||
// filtro audio
|
||||
arm_fir_instance_q31 audio_filter_struct;
|
||||
q31_t audio_filter_state[AUDIO_FILTER_BLOCK_SIZE + AUDIO_FILTER_TAP_NUM - 1];
|
||||
int32_t audio_filter_coeffs[AUDIO_FILTER_TAP_NUM];
|
||||
q31_t audio_filter_state[RX_AUDIO_FILTER_BLOCK_SIZE + RX_AUDIO_FILTER_TAP_NUM - 1];
|
||||
int32_t audio_filter_coeffs[RX_AUDIO_FILTER_TAP_NUM];
|
||||
|
||||
int32_t ms_hbf_filter_taps[MS_HBF_TAP_NUM] = {
|
||||
-181552, 0, 3414100, 0,
|
||||
@@ -100,7 +100,7 @@ int32_t st2_wide_taps[ST2_FILTER_TAP_NUM] = {
|
||||
1221284, 778895, 335568, -97978,
|
||||
};
|
||||
|
||||
int32_t audio_filter_coeffs[AUDIO_FILTER_TAP_NUM];
|
||||
int32_t audio_filter_coeffs[RX_AUDIO_FILTER_TAP_NUM];
|
||||
|
||||
// mix
|
||||
|
||||
@@ -244,19 +244,19 @@ void st2_filter_init(void){
|
||||
}
|
||||
|
||||
void audio_filter_init(void){
|
||||
arm_fir_init_q31 (&audio_filter_struct, AUDIO_FILTER_TAP_NUM, audio_filter_coeffs, &audio_filter_state[0], AUDIO_FILTER_BLOCK_SIZE);
|
||||
arm_fir_init_q31 (&audio_filter_struct, RX_AUDIO_FILTER_TAP_NUM, audio_filter_coeffs, &audio_filter_state[0], RX_AUDIO_FILTER_BLOCK_SIZE);
|
||||
}
|
||||
|
||||
void audio_filter_generate_coeffs(int32_t *Coeffs, uint32_t freq, uint32_t bw, uint8_t beta){
|
||||
double FPCoeff[AUDIO_FILTER_TAP_NUM + 1];
|
||||
double FPCoeff[RX_AUDIO_FILTER_TAP_NUM + 1];
|
||||
double normalized_center_freq, normalized_bw, fp_beta;
|
||||
normalized_center_freq = (double)(freq*2)/RX_DAC_SAMPLE_RATE;
|
||||
normalized_bw = (double)(bw*2)/RX_DAC_SAMPLE_RATE;
|
||||
fp_beta = beta/4;
|
||||
RectWinFIR(FPCoeff, AUDIO_FILTER_TAP_NUM, firBPF, normalized_center_freq, normalized_bw);
|
||||
FIRFilterWindow(FPCoeff, AUDIO_FILTER_TAP_NUM, wtKAISER, fp_beta);
|
||||
RectWinFIR(FPCoeff, RX_AUDIO_FILTER_TAP_NUM, firBPF, normalized_center_freq, normalized_bw);
|
||||
FIRFilterWindow(FPCoeff, RX_AUDIO_FILTER_TAP_NUM, wtKAISER, fp_beta);
|
||||
|
||||
for( int index = 0; index < AUDIO_FILTER_TAP_NUM; index++){
|
||||
for( int index = 0; index < RX_AUDIO_FILTER_TAP_NUM; index++){
|
||||
Coeffs[index] = (int32_t) ( (double)(FPCoeff[index])*(double)0x7FFFFFFF );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,6 +767,60 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PCD MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param hpcd: PCD handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
|
||||
{
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
|
||||
if(hpcd->Instance==USB)
|
||||
{
|
||||
/* USER CODE BEGIN USB_MspInit 0 */
|
||||
|
||||
/* USER CODE END USB_MspInit 0 */
|
||||
/** Initializes the peripherals clocks
|
||||
*/
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
|
||||
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_USB_CLK_ENABLE();
|
||||
/* USER CODE BEGIN USB_MspInit 1 */
|
||||
|
||||
/* USER CODE END USB_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PCD MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param hpcd: PCD handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd)
|
||||
{
|
||||
if(hpcd->Instance==USB)
|
||||
{
|
||||
/* USER CODE BEGIN USB_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END USB_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_USB_CLK_DISABLE();
|
||||
/* USER CODE BEGIN USB_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END USB_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
Reference in New Issue
Block a user