2017090621PM-Key Helper

本文围绕Key Resolver展开,介绍了其使用场景,可用于解析主键、父属性等。阐述了编写Key Helper表达式的方法,包括所需输入和VO类型,还说明了添加表达式的步骤。最后讲解了Key Resolver的两种工作模式:正向和反向。

Where to use key Resolver

 

Key Helper is nothing but a java expression which can be added as a custom property on attribute level or VO def level. At runtime we invokes this expression to resolve attributes with the provided inputs in this expression.

It can be used to resolve -
 

  •   Primary key attribute
  •   Parent Attribute
  •   Foreign key attribute
    • Lookup attribute

How to write a Key Helper Expression

 

Once we finalized the attribute which need to be resolve, we have to find out the dependency and the resolving VO for them.

Input required to write a key helper expression :-
 

1. Resolver VO or Resolver Helper Class Name

2. Bind attributes(dependent attributes)

3. Return attributes
 

There could be two type of VO we will use in expression writing
 

1. ResolvingVO is the VO for which we are resolving attributes. Like if we are resolving EmployeeId for EmployeeVO then EmployeeVO is a ResolvingVO.

2. ResolverVO is the VO from the VO we are resolving attribute. Like DeptId for EmployeeVO we are resolving DeptId from DepartmentVO so DepartmentVO is ResolverVO.
 

Here is the format to write a key helper expression :-
  

keyContextHelper.resolve("Resolver_VO_Name", "Resolving_VO_Bind_Attribute1:Resolver_VO_Bind_Attribute1;Resolving_VO_Bind_Attribute2:Resolver_VO_Bind_Attribute2;........", "Resolving_VO_Return_Attribute:Resolver_VO_Return_Attribute");

  
If we have more than one Bind attributes then we can add them using semi colon separated ( ; ) , Resolving and resolver bind attribute names can be separated with colon ( : ) .
  

Lets take an example of parent key (DeptId) of EmployeeVO -
  
Resolving attribute - DeptId

ResolvingVO - EmployeeVO

ResolverVO - DepartmentVO ("oracle.apps.hcm.common.core.publicModel.view.DepartmentVO")

Bind attributes - DeptName, LocationId

Return attribute - DeptmentId from DepartmentVO --> DeptId of EmployeeVO

  

keyContextHelper.resolve("oracle.apps.hcm.common.core.publicModel.view.DepartmentVO", "DeptName:DepartmentName;LocationId:LocationId", "DeptId:DepartmentId" );

Where to add Key Helper Expression

  

Steps to add a key helper expression :-
  

1. Go to attribute Def 

2. click on add custom properties

3. Select non-transient property

4 write Property --> KeyHelper , value -> (Expression) 
  
  

  

Property name must be KeyHelper, otherwise it will not be considered as a key helper expression property.

How Key Resolver works

  
Key resolver basically works in to two modes -

1. Forward :- To resolve Id's from the user provided attributes or user key attributes. (Import Case)
  
  
        
  

  •   DepartmentName and LocationId from Employee, will be provided as a input for Department.
  •   Query to get DepartmentId will be execute with the provided input value.
  •   DepartmentId from the query result will be passed to the Employee's DeptId.

2. Backward (Reverse) :- To resolve user key attributes form the Id's. (Export Case)

Same key expression used to resolve attributes in backward case.
  
  
        
  

  • DeptId from Employee will be provided as a input to execute a query.
  • Query will return DepartmentName and LocationId from Department.
  • DepartmentName and LocationId will be returned to Employee.
#include "main.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "arm_math.h" #include "stdio.h" #include <stdlib.h> #include "math_helper.h" //#include "systemclk.h" #include "delay.h" //#include "led.h" #include "key.h" //#include "usart.h" //#include "lcd.h" #include "ad9833.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ uint16_t BL = 24; float32_t TB[24] = { 0.0013 , 0.0056 , -0.0086 , -0.0048 , 0.0218 , -0.0093 , -0.0332 , 0.0456 , 0.0245 , -0.1186 , 0.0638 , 0.5119 , 0.5119 , 0.0638 , -0.1186 , 0.0245 , 0.0456 , -0.0332 , -0.0093 , 0.0218 , -0.0048 , -0.0086 , 0.0056 , 0.0013 }; /* USER CODE END PTD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ //#define FFT_LENGTH 1024 // //#define ADC1_DMA_Size 1024 //ADC???? //#define SAM_FRE 100000 //??? // // float fft_outputbuf_win[FFT_LENGTH]; // float fir_inputbuf[FFT_LENGTH]={0}; // float fir_outputbuf[FFT_LENGTH]={0}; // uint32_t ADC1_ConvertedValue[ ADC1_DMA_Size ]; // unsigned char flag; // unsigned int i; /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ #define TEST_LENGTH_SAMPLES 320 /* This SNR is a bit small. Need to understand why this example is not giving better SNR ... */ #define SNR_THRESHOLD_F32 75.0f #define BLOCK_SIZE 320 #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) /* Must be a multiple of 16 */ #define NUM_TAPS_ARRAY_SIZE 32 #else #define NUM_TAPS_ARRAY_SIZE 29 #endif #define NUM_TAPS 29 /* ------------------------------------------------------------------- * The input signal and reference output (computed with MATLAB) * are defined externally in arm_fir_lpf_data.c. * ------------------------------------------------------------------- */ extern float32_t testInput_f32_1kHz_15kHz[TEST_LENGTH_SAMPLES]; extern float32_t refOutput[TEST_LENGTH_SAMPLES]; /* ------------------------------------------------------------------- * Declare Test output buffer * ------------------------------------------------------------------- */ static float32_t testOutput[TEST_LENGTH_SAMPLES]; /* ------------------------------------------------------------------- * Declare State buffer of size (numTaps + blockSize - 1) * ------------------------------------------------------------------- */ #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) static float32_t firStateF32[2 * BLOCK_SIZE + NUM_TAPS - 1]; #else static float32_t firStateF32[BLOCK_SIZE + NUM_TAPS - 1]; #endif /* ---------------------------------------------------------------------- ** FIR Coefficients buffer generated using fir1() MATLAB function. ** fir1(28, 6/24) ** ------------------------------------------------------------------- */ #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) const float32_t firCoeffs32[NUM_TAPS_ARRAY_SIZE] = { -0.0018225230f, -0.0015879294f, +0.0000000000f, +0.0036977508f, +0.0080754303f, +0.0085302217f, -0.0000000000f, -0.0173976984f, -0.0341458607f, -0.0333591565f, +0.0000000000f, +0.0676308395f, +0.1522061835f, +0.2229246956f, +0.2504960933f, +0.2229246956f, +0.1522061835f, +0.0676308395f, +0.0000000000f, -0.0333591565f, -0.0341458607f, -0.0173976984f, -0.0000000000f, +0.0085302217f, +0.0080754303f, +0.0036977508f, +0.0000000000f, -0.0015879294f, -0.0018225230f, 0.0f,0.0f,0.0f }; #else const float32_t firCoeffs32[NUM_TAPS_ARRAY_SIZE] = { -0.0018225230f, -0.0015879294f, +0.0000000000f, +0.0036977508f, +0.0080754303f, +0.0085302217f, -0.0000000000f, -0.0173976984f, -0.0341458607f, -0.0333591565f, +0.0000000000f, +0.0676308395f, +0.1522061835f, +0.2229246956f, +0.2504960933f, +0.2229246956f, +0.1522061835f, +0.0676308395f, +0.0000000000f, -0.0333591565f, -0.0341458607f, -0.0173976984f, -0.0000000000f, +0.0085302217f, +0.0080754303f, +0.0036977508f, +0.0000000000f, -0.0015879294f, -0.0018225230f }; #endif /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ ADC_HandleTypeDef hadc1; DMA_HandleTypeDef hdma_adc1; SPI_HandleTypeDef hspi1; TIM_HandleTypeDef htim3; UART_HandleTypeDef huart1; /* USER CODE BEGIN PV */ uint32_t blockSize = BLOCK_SIZE; uint32_t numBlocks = TEST_LENGTH_SAMPLES/BLOCK_SIZE; float32_t snr; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_DMA_Init(void); static void MX_ADC1_Init(void); static void MX_TIM3_Init(void); static void MX_USART1_UART_Init(void); static void MX_SPI1_Init(void); /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ //float32_t snr; //uint32_t blockSize = 1024; //?????,?ADC??????? // //float32_t pState[1047]={0.0f}; //FIR?????????:?????=BL+blockSize-1 = 1024 + 24 -1 = 1047 /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */ int main(void) { uint8_t buf[16]; uint16_t key; uint8_t cnt = 0; uint8_t Wave_Type = AD9833_Out_Sinus; uint32_t Wave_Fre = 100; float CH1_Phase = 0; // ???0~360 float CH2_Phase = 0; // ???0~360 HAL_Init(); // ??'??HAL?? SystemClock_Config(); // ?????????72MHz Delay_Init(180); // ??'????????? //LED_Init(); // ??'??LED KEY_Init(); // ??'?????? //Usart_Init(115200); // ??'?????? // LCD_Init(); // ??'??LCD AD9833_Init(); // AD9833???u?'?? // Point_Color = RED; //LCD_Clear(WHITE); //LCD_Show_String(10, 40 , 240, 24, 24, "AD9833_2CH Test", RED); //LCD_Show_String(10, 160 , 240, 16, 16, "K1: + Frequency", MAGENTA); //LCD_Show_String(10, 180 , 240, 16, 16, "K2: + Phase", MAGENTA); //LCD_Show_String(10, 200 , 240, 16, 16, "K3: Set Wave Type", MAGENTA); //if(Wave_Type == AD9833_Out_Sinus) //{ //LCD_Show_String(10, 80 , 240, 16, 16, "Wave Type: Sine ", BLUE); //printf("Wave Type: Sine\r\n"); // } //else if(Wave_Type == AD9833_Out_Triangle) // { // LCD_Show_String(10, 80 , 240, 16, 16, "Wave Type: Triangle", BLUE); // } // else if(Wave_Type == AD9833_Out_Msb) //{ // LCD_Show_String(10, 80 , 240, 16, 16, "Wave Type: square ", BLUE); // printf("Wave Type: square\r\n"); // } //else if(Wave_Type == AD9833_Out_Msb2) //{ // LCD_Show_String(10, 80 , 240, 16, 16, "Wave Type: square ", BLUE); //} //sprintf((char *)buf,"Wave Fre : %9dHz ",Wave_Fre); //LCD_Show_String(10, 100, 240, 16, 16, (char *)buf, BLUE); //printf("%s\r\n",buf); //sprintf((char *)buf,"Wave Phase: %5.1f ",CH2_Phase); //LCD_Show_String(10, 120, 240, 16, 16, (char *)buf, BLUE); // printf("%s\r\n",buf); /* 10.73742 = 2^28/25000000, ????25000000??g????l???25MHz */ AD9833_Set_Phase(Wave_Type, (uint32_t)(Wave_Fre * 10.73742), CH1_Phase, CH2_Phase); while (1) { key=KEY_Scan(); if(key == K1_PRES) // ?i???? { if(Wave_Fre <10000) Wave_Fre += 1000; else if(Wave_Fre <100000) Wave_Fre += 10000; else if(Wave_Fre <1000000) Wave_Fre += 100000; else if(Wave_Fre <10000000) Wave_Fre += 1000000; else Wave_Fre = 1000; sprintf((char *)buf,"Wave Fre %9dHz ",Wave_Fre); //LCD_Show_String(10, 100, 240, 16, 16, (char *)buf, BLUE); printf("%s\r\n",buf); /* 10.73742 = 2^28/25000000, ????25000000??g????l???25MHz */ AD9833_Set_Frequency(AD9833_ALL, Wave_Type, (uint32_t)(Wave_Fre * 10.73742)); // ???????????? } else if(key == K2_PRES) // ?i???? { if(CH2_Phase >= 360) CH2_Phase = 0; else CH2_Phase += 10; sprintf((char *)buf,"Wave Phase: %5.1f ",CH2_Phase); // LCD_Show_String(10, 120, 240, 16, 16, (char *)buf, BLUE); printf("%s\r\n",buf); AD9833_Set_Phase(Wave_Type, (uint32_t)(Wave_Fre * 10.73742), CH1_Phase, CH2_Phase); } else if(key == K3_PRES) // ?i??????? { if(Wave_Type == AD9833_Out_Sinus) { Wave_Type = AD9833_Out_Triangle; // LCD_Show_String(10, 80 , 240, 16, 16, "Wave Type: Triangle", BLUE); printf("Wave Type: Triangle\r\n"); } else if(Wave_Type == AD9833_Out_Triangle) { Wave_Type = AD9833_Out_Msb; // LCD_Show_String(10, 80 , 240, 16, 16, "Wave Type: square ", BLUE); printf("Wave Type: square\r\n"); } else if(Wave_Type == AD9833_Out_Msb) { Wave_Type = AD9833_Out_Msb2; // LCD_Show_String(10, 80 , 240, 16, 16, "Wave Type: square2 ", BLUE); printf("Wave Type: square2\r\n"); } else if(Wave_Type == AD9833_Out_Msb2) { Wave_Type = AD9833_Out_Sinus; // LCD_Show_String(10, 80 , 240, 16, 16, "Wave Type: Sine ", BLUE); printf("Wave Type: Sine\r\n"); } /* 10.73742 = 2^28/25000000, ????25000000??g????l???25MHz */ AD9833_Set_Phase(Wave_Type, (uint32_t)(Wave_Fre * 10.73742), CH1_Phase, CH2_Phase); } cnt++; if(cnt > 100) { //LED1_TOGGLE; cnt = 0; } Delay_ms(10); } /* USER CODE BEGIN 1 */ float32_t data=0; /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ //SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_ADC1_Init(); MX_TIM3_Init(); MX_USART1_UART_Init(); MX_SPI1_Init(); /* USER CODE BEGIN 2 */ uint32_t i; arm_fir_instance_f32 S; arm_status status; float32_t *inputF32, *outputF32; /* Initialize input and output buffer pointers */ inputF32 = &testInput_f32_1kHz_15kHz[0]; outputF32 = &testOutput[0]; /* Call FIR init function to initialize the instance structure. */ arm_fir_init_f32(&S, NUM_TAPS, (float32_t *)&firCoeffs32[0], &firStateF32[0], blockSize); /* ---------------------------------------------------------------------- ** Call the FIR process function for every blockSize samples ** ------------------------------------------------------------------- */ for(i=0; i < numBlocks; i++) { arm_fir_f32(&S, inputF32 + (i * blockSize), outputF32 + (i * blockSize), blockSize); } /* ---------------------------------------------------------------------- ** Compare the generated output against the reference output computed ** in MATLAB. ** ------------------------------------------------------------------- */ snr = arm_snr_f32(&refOutput[0], &testOutput[0], TEST_LENGTH_SAMPLES); printf("SNR :%f\n",snr); status = (snr < SNR_THRESHOLD_F32) ? ARM_MATH_TEST_FAILURE : ARM_MATH_SUCCESS; // if (status != ARM_MATH_SUCCESS) // { //#if defined (SEMIHOSTING) // printf("FAILURE\n"); //#else // while (1); /* main function does not return */ //#endif // } // else // { //#if defined (SEMIHOSTING) // printf("SUCCESS\n"); //#else // while (1); /* main function does not return */ //#endif // } // data=arm_sin_f32(3.1415926/6);//sin(30) // arm_fir_instance_f32 *S;//FIR?????? // HAL_TIM_Base_Start(&htim3); // HAL_ADC_Start_DMA(&hadc1,(uint32_t*)ADC1_ConvertedValue,ADC1_DMA_Size); // printf("init_ok\r\n"); // // S = (arm_fir_instance_f32 *)malloc(sizeof(arm_fir_instance_f32)); //??????S // arm_fir_init_f32(S,BL,TB,pState,blockSize); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_GPIO_TogglePin(LED_R_GPIO_Port, LED_R_Pin); HAL_Delay(1000); //// if(flag==1) // { // // flag=0; // HAL_Delay(1000); // printf("/**************************************/\r\n"); // //S = (arm_fir_instance_f32 *)malloc(sizeof(arm_fir_instance_f32)); //??????S // if (S == NULL) //????????? // { // printf("error\r\n"); // } // // // for(i=0;i<FFT_LENGTH;i++) // { // fir_inputbuf[i]=(float)ADC1_ConvertedValue[ i ]*3.3/4096; //?ADC???????????fir_inputbuf????? // } // arm_fir_f32(S,fir_inputbuf,fir_outputbuf,blockSize); // // //free(S); // ???? // //S = NULL; // ?????? NULL,??????? // for(i=0;i<FFT_LENGTH;i++) // { // printf("%f,%f\r\n",(float)ADC1_ConvertedValue[i]*3.3/4096,fir_outputbuf[ i ]); // } // } } /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Configure the main internal regulator output voltage */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 15; RCC_OscInitStruct.PLL.PLLN = 216; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 4; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Activate the Over-Drive mode */ if (HAL_PWREx_EnableOverDrive() != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { Error_Handler(); } } /** * @brief ADC1 Initialization Function * @param None * @retval None */ static void MX_ADC1_Init(void) { /* USER CODE BEGIN ADC1_Init 0 */ /* USER CODE END ADC1_Init 0 */ ADC_ChannelConfTypeDef sConfig = {0}; /* USER CODE BEGIN ADC1_Init 1 */ /* USER CODE END ADC1_Init 1 */ /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) */ hadc1.Instance = ADC1; hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4; hadc1.Init.Resolution = ADC_RESOLUTION_12B; hadc1.Init.ScanConvMode = DISABLE; hadc1.Init.ContinuousConvMode = DISABLE; hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING; hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T3_TRGO; hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; hadc1.Init.NbrOfConversion = 1; hadc1.Init.DMAContinuousRequests = ENABLE; hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; if (HAL_ADC_Init(&hadc1) != HAL_OK) { Error_Handler(); } /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. */ sConfig.Channel = ADC_CHANNEL_0; sConfig.Rank = 1; sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN ADC1_Init 2 */ /* USER CODE END ADC1_Init 2 */ } /** * @brief SPI1 Initialization Function * @param None * @retval None */ static void MX_SPI1_Init(void) { /* USER CODE BEGIN SPI1_Init 0 */ /* USER CODE END SPI1_Init 0 */ /* USER CODE BEGIN SPI1_Init 1 */ /* USER CODE END SPI1_Init 1 */ /* SPI1 parameter configuration*/ hspi1.Instance = SPI1; hspi1.Init.Mode = SPI_MODE_MASTER; hspi1.Init.Direction = SPI_DIRECTION_2LINES; hspi1.Init.DataSize = SPI_DATASIZE_16BIT; hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH; hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; hspi1.Init.NSS = SPI_NSS_SOFT; hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32; hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi1.Init.TIMode = SPI_TIMODE_DISABLE; hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi1.Init.CRCPolynomial = 10; if (HAL_SPI_Init(&hspi1) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN SPI1_Init 2 */ /* USER CODE END SPI1_Init 2 */ } /** * @brief TIM3 Initialization Function * @param None * @retval None */ static void MX_TIM3_Init(void) { /* USER CODE BEGIN TIM3_Init 0 */ /* USER CODE END TIM3_Init 0 */ TIM_ClockConfigTypeDef sClockSourceConfig = {0}; TIM_MasterConfigTypeDef sMasterConfig = {0}; /* USER CODE BEGIN TIM3_Init 1 */ /* USER CODE END TIM3_Init 1 */ htim3.Instance = TIM3; htim3.Init.Prescaler = 29; htim3.Init.CounterMode = TIM_COUNTERMODE_UP; htim3.Init.Period = 300; htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE; if (HAL_TIM_Base_Init(&htim3) != HAL_OK) { Error_Handler(); } sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK) { Error_Handler(); } sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN TIM3_Init 2 */ /* USER CODE END TIM3_Init 2 */ } /** * @brief USART1 Initialization Function * @param None * @retval None */ static void MX_USART1_UART_Init(void) { /* USER CODE BEGIN USART1_Init 0 */ /* USER CODE END USART1_Init 0 */ /* USER CODE BEGIN USART1_Init 1 */ /* USER CODE END USART1_Init 1 */ huart1.Instance = USART1; huart1.Init.BaudRate = 115200; huart1.Init.WordLength = UART_WORDLENGTH_8B; huart1.Init.StopBits = UART_STOPBITS_1; huart1.Init.Parity = UART_PARITY_NONE; huart1.Init.Mode = UART_MODE_TX_RX; huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart1.Init.OverSampling = UART_OVERSAMPLING_16; if (HAL_UART_Init(&huart1) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN USART1_Init 2 */ /* USER CODE END USART1_Init 2 */ } /** * Enable DMA controller clock */ static void MX_DMA_Init(void) { /* DMA controller clock enable */ __HAL_RCC_DMA2_CLK_ENABLE(); /* DMA interrupt init */ /* DMA2_Stream0_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 0, 0); HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn); } /** * @brief GPIO Initialization Function * @param None * @retval None */ static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct = {0}; /* USER CODE BEGIN MX_GPIO_Init_1 */ /* USER CODE END MX_GPIO_Init_1 */ /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, GPIO_PIN_SET); /*Configure GPIO pin : LED_R_Pin */ GPIO_InitStruct.Pin = LED_R_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(LED_R_GPIO_Port, &GPIO_InitStruct); /* USER CODE BEGIN MX_GPIO_Init_2 */ /* USER CODE END MX_GPIO_Init_2 */ } /* USER CODE BEGIN 4 */ int fputc(int ch, FILE *fp) { HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xffff); return ch; } int fgetc(FILE *fp) { uint8_t ch = 0; HAL_UART_Receive(&huart1, &ch, 1, 0xffff); return ch; } /* USER CODE END 4 */ /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */ 这是main.c代码,如何根据以上问题修改?
07-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值