123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793 |
- /* USER CODE BEGIN Header */
- /**
- ******************************************************************************
- * @file : main.c
- * @brief : Main program body
- ******************************************************************************
- ** This notice applies to any and all portions of this file
- * that are not between comment pairs USER CODE BEGIN and
- * USER CODE END. Other portions of this file, whether
- * inserted by the user or by software development tools
- * are owned by their respective copyright owners.
- *
- * COPYRIGHT(c) 2019 STMicroelectronics
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
- /* USER CODE END Header */
- /* Includes ------------------------------------------------------------------*/
- #include "main.h"
- /* Private includes ----------------------------------------------------------*/
- /* USER CODE BEGIN Includes */
- /* USER CODE END Includes */
- /* Private typedef -----------------------------------------------------------*/
- /* USER CODE BEGIN PTD */
- /* USER CODE END PTD */
- /* Private define ------------------------------------------------------------*/
- /* USER CODE BEGIN PD */
- /* USER CODE END PD */
- /* Private macro -------------------------------------------------------------*/
- /* USER CODE BEGIN PM */
- /* USER CODE END PM */
- /* Private variables ---------------------------------------------------------*/
- I2C_HandleTypeDef hi2c3;
- TIM_HandleTypeDef htim6;
- UART_HandleTypeDef huart3;
- DMA_HandleTypeDef hdma_usart3_rx;
- DMA_HandleTypeDef hdma_usart3_tx;
- /* USER CODE BEGIN PV */
- /* 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_TIM6_Init(void);
- static void MX_I2C3_Init(void);
- static void MX_USART3_UART_Init(void);
- static void MX_NVIC_Init(void);
- /* USER CODE BEGIN PFP */
- void Atten_ButtonUnPressSet(bool set);
- bool Atten_ButtonUnPressGet(void);
- AttenButton_t Atten_ButtonPressGet(void);
- /* USER CODE END PFP */
- /* Private user code ---------------------------------------------------------*/
- /* USER CODE BEGIN 0 */
- uint8_t rx2_data[2];
- uint8_t ring_buf[buf_size];
- uint8_t count_in, count_out;
- uint32_t Timer10ms;
- uint8_t buf[buf_size] = {0,};
- volatile uint32_t UartTimerCnt = 0;
- volatile uint32_t LedTimerCnt = 0;
- volatile uint32_t ButtonLong_TimerCnt = 0;
- volatile uint32_t ButtonNext_TimerCnt = 0;
- volatile uint8_t chattering = 0,ButtonPressed = 0;
- uint8_t switchcnt[5] = {0,};
- uint8_t UartDataisReved;
- int _write (int file, uint8_t *ptr, uint16_t len)
- {
- HAL_UART_Transmit (&huart3, ptr, len, 10);
- return len;
- }
- uint8_t buttonChatteringset(uint8_t set){
- chattering = set;
- }
- uint8_t buttonChatteringget(uint8_t set){
- return chattering;
- }
- void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
- {
- uint8_t uartindex = 0;
- etError crccheck = 0;
- /* Prevent unused argument(s) compilation warning */
- if(htim->Instance == TIM6){
- UartTimerCnt++;
- LedTimerCnt++;
- if(Atten_ButtonUnPressGet() == true && Layer_Get() >= AChSetting_Change150M_Layer)
- ButtonLong_TimerCnt++;
- }
- /* NOTE : This function Should not be modified, when the callback is needed,
- the __HAL_TIM_PeriodElapsedCallback could be implemented in the user file
- */
- }
- void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
- {
- if(huart->Instance == USART3){
- ring_buf[count_in] = rx2_data[0];//(uint8_t)USART2->DR;
- if(ring_buf[count_in] == 0xEB)UartDataRecvSet(1);
- if(++count_in>=buf_size) count_in=0;
- HAL_UART_Receive_DMA(&huart3,&rx2_data,1);
- }
- #if 0 // PYJ.2019.08.30_BEGIN --
- if ((__HAL_UART_GET_FLAG(&huart3, UART_FLAG_RXNE) != RESET))
- {
- PutDataToUartQueue(&huart3, (uint8_t)(huart3.Instance->DR & (uint8_t)0x00FF));
- }
- __HAL_UART_CLEAR_PEFLAG(&huart3); /* clear event flag */
- return;
- #endif // PYJ.2019.08.30_END --
- }
- uint8_t button_press = 0;
- bool Unbutton_press = 0;
- void Atten_ButtonPressSet(AttenButton_t set){
- button_press = set;
- }
- AttenButton_t Atten_ButtonPressGet(void){
- return button_press;
- }
- void Atten_ButtonUnPressSet(bool set){
- Unbutton_press = set;
- }
- bool Atten_ButtonUnPressGet(void){
- return Unbutton_press;
- }
- __STATIC_INLINE void Pol_Delay_us(volatile uint32_t microseconds)
- {
- /* Go to number of cycles for system */
- microseconds *= (SystemCoreClock / 1000000);
- /* Delay till end */
- while (microseconds--);
- }
- void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
- {
- // HAL_Delay(100);
- // printf("%s : %d \r\n",__func__,__LINE__);
- if(GPIO_Pin == GPIO_PIN_8){
- if(Atten_ButtonUnPressGet() == false){
- // printf("Button_PRESS ESC \r\n",__func__,__LINE__);
- Atten_ButtonPressSet( Button_ESC);
- Atten_ButtonUnPressSet(true);
- }
- else{
- // printf("Button_UnPRESS ESC \r\n",__func__,__LINE__);
- ButtonLong_TimerCnt = 0;
- Atten_ButtonUnPressSet(false);
- return;
- }
- }
- if(GPIO_Pin == GPIO_PIN_12){
- if(Atten_ButtonUnPressGet() == false){
- // printf("Button_PRESS MENU \r\n",__func__,__LINE__);
- Atten_ButtonPressSet( Button_MENU);
- Atten_ButtonUnPressSet(true);
- }
- else{
- // printf("Button_UNPRESS MENU \r\n",__func__,__LINE__);
- ButtonLong_TimerCnt = 0;
- Atten_ButtonUnPressSet(false);
- return;
- }
- }
- if(GPIO_Pin == GPIO_PIN_13){
- if(Atten_ButtonUnPressGet() == false ){
- // printf("Button_UP UNPRESS \r\n",__func__,__LINE__);
- Atten_ButtonPressSet( Button_UP);
- Atten_ButtonUnPressSet(true);
- }
- else{
- if( HAL_GPIO_ReadPin(GPIOB, GPIO_Pin) == GPIO_PIN_SET){
- // printf("Button_UP PRESS \r\n",__func__,__LINE__);
- ButtonLong_TimerCnt = 0;
- Atten_ButtonUnPressSet(false);
- return;
- }
- }
- }
- if(GPIO_Pin == GPIO_PIN_14){
- if(Atten_ButtonUnPressGet() == false ){
- // printf("Button_DOWN UNPRESS \r\n",__func__,__LINE__);
- Atten_ButtonPressSet( Button_DOWN);
- Atten_ButtonUnPressSet(true);
- }
- else{
- if( HAL_GPIO_ReadPin(GPIOB, GPIO_Pin) == GPIO_PIN_SET){
- // printf("Button_DOWN PRESS \r\n",__func__,__LINE__);
- ButtonLong_TimerCnt = 0;
- Atten_ButtonUnPressSet(false);
- return;
- }
- }
- }
- if(GPIO_Pin == GPIO_PIN_15){
- if(Atten_ButtonUnPressGet() == false){
- // printf("Button_ENTER PRESS \r\n",__func__,__LINE__);
- Atten_ButtonPressSet( Button_ENTER);
- Atten_ButtonUnPressSet(true);
- }
- else{
- // printf("Button_ENTER UNPRESS \r\n",__func__,__LINE__);
- Atten_ButtonUnPressSet(false);
- ButtonLong_TimerCnt = 0;
- return;
- }
- }
- Pol_Delay_us(1000 *50);
- Character_Lcd_chMenu(Atten_ButtonPressGet());
- }
- void UartDataRecvSet(uint8_t val){
- UartDataisReved = val;
- }
- uint8_t UartDataRecvGet(void){
- return UartDataisReved;
- }
- volatile uint8_t uartindex = 0;
- /* USER CODE END 0 */
- /**
- * @brief The application entry point.
- * @retval int
- */
- int main(void)
- {
- /* USER CODE BEGIN 1 */
- //uint8_t writetemp[10] = {6,4,2,0,1,2,3,4,5,0xab};
- uint8_t tempdata[100] = {0,};
- Atten_Alarm_t Alarm_st;
- /* 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_TIM6_Init();
- MX_I2C3_Init();
- MX_USART3_UART_Init();
- /* Initialize interrupts */
- MX_NVIC_Init();
- /* USER CODE BEGIN 2 */
- HAL_TIM_Base_Start_IT(&htim6);
- HAL_UART_Receive_DMA(&huart3, &rx2_data,1);
- InitUartQueue(&TerminalQueue);
- setbuf(stdout, NULL); // \n ?��?��?��, printf �?????��?���???? ?��?��?��
- //
- // printf("PE43711_ATTEN_31_75DB_Trace : %02x \r\n",PE43711_ATTEN_31_75DB_Trace);
- // printf("PE43711_ATTEN_16DB_Trace : %02x \r\n",PE43711_ATTEN_16DB_Trace);
- // printf("PE43711_ATTEN_8DB_Trace : %02x \r\n",PE43711_ATTEN_8DB_Trace);
- // printf("PE43711_ATTEN_4DB_Trace : %02x \r\n",PE43711_ATTEN_4DB_Trace);
- // printf("PE43711_ATTEN_2DB_Trace : %02x \r\n",PE43711_ATTEN_2DB_Trace);
- // printf("PE43711_ATTEN_1DB_Trace : %02x \r\n",PE43711_ATTEN_1DB_Trace);
-
- /* USER CODE END 2 */
- /* Infinite loop */
- /* USER CODE BEGIN WHILE */
- #if 0 // PYJ.2019.03.04_BEGIN --
- printf("****************************************\r\n");
- printf("TEST Project\r\n");
- printf("Build at %s %s\r\n", __DATE__, __TIME__);
- printf("Copyright (c) 2019. BLUECELL\r\n");
- printf("****************************************\r\n");
- #endif // PYJ.2019.03.04_END --
- EEPROM_IM24CM01P_Init();
- LCD_M68_DataWrite_COMMAND_Init();
- Character_Lcd_chMenu(Power_On);
- memcpy(tempdata,&ATT_A_EN_30G1_28_28_5Ghz_Table.Atten_Table_31_5dB_Value,sizeof(Atten_Table_Value_t));
- Atten_Init();
- etError crccheck = 0;
- AttenButton_t Buttonpress = Button_NOP;
- while(1)
- {
- if(count_in != count_out){
- UartTimerCnt = 0;
- buf[uartindex++] = ring_buf[count_out];
- if(++count_out >= buf_size) count_out=0;
- }
- if((UartDataRecvGet() == 1 && UartTimerCnt > 100) || ButtonDataGet() == true){
- #if 0
- for(uint8_t i = 0; i < (uartindex); i++){
- // Uart_Data_Send(buf[i],1);
- printf("%02x ",buf[i]);
- }
- // printf("\r\n");
- #endif
- crccheck = STH30_CheckCrc(&buf[Bluecell_Type],buf[Bluecell_Length]+2,buf[3 + buf[Bluecell_Length]]);
- if(crccheck == CHECKSUM_ERROR){
- for(uint8_t i = 0; i < (uartindex); i++){
- printf("%02x ",buf[i]);
- }
- printf("\r\n");
- printf("CHECKSUM_ERROR RecvCRC : %02x , index %d\r\n",buf[3 + buf[Bluecell_Length]],5 + buf[Bluecell_Length]);
- }
- else if(crccheck == NO_ERROR){
- Atten_Operate_Mem_RW(&buf[Bluecell_STX]);
- LedTimerCnt = 0;
- }
- else{
- printf("What Happen?\r\n");
- /*NOP*/
- }
- memset(buf,0x00,buf_size);
- uartindex = 0;
- UartDataRecvSet(0);
- ButtonDataSet(false);
- }
- else{
- //Alarm Timer
- #if 0 // PYJ.2019.03.07_BEGIN --
- if(ButtonLong_TimerCnt > 500){
- Character_Lcd_chMenu(Atten_ButtonPressGet());
- ButtonLong_TimerCnt = 0;
- printf("ButtonLong_TimerCnt \r\n");
- }
- #endif // PYJ.2019.03.07_END --
- if(ButtonLong_TimerCnt > 500
- && (!HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_13)
- || !HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_14))){
- // printf("LONG KEY PRESS\r\n");
- Character_Lcd_chMenu(Atten_ButtonPressGet());
- ButtonLong_TimerCnt = 0;
- }
- if(LedTimerCnt > 500){
- Alarm_st = Atten_Alarm_Read();
- Alarm_Operate(Alarm_st);
- tempdata[Bluecell_STX] = 0xBE;
- tempdata[Bluecell_Type] = ATT_AB_ALARM_READ;
- tempdata[Bluecell_Length] = sizeof(Atten_Alarm_t) + 2;
- memcpy(&tempdata[Bluecell_DATA],&Alarm_st.Atten_Ach_Alarm_150M,sizeof(Atten_Alarm_t));
- tempdata[tempdata[Bluecell_Length] + 3] = STH30_CreateCrc(&tempdata[Bluecell_Type],tempdata[Bluecell_Length] + 2);
- tempdata[tempdata[Bluecell_Length] + 4] = 0xeb;
- Uart_Data_Send(&tempdata[Bluecell_STX],tempdata[Bluecell_Length]+5);
- HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_15);
- LedTimerCnt = 0;
- }
- }
- }
- // HAL_Delay(1);
- /* USER CODE END WHILE */
- /* USER CODE BEGIN 3 */
- /* USER CODE END 3 */
- }
- /**
- * @brief System Clock Configuration
- * @retval None
- */
- void SystemClock_Config(void)
- {
- RCC_OscInitTypeDef RCC_OscInitStruct = {0};
- RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
- /** Initializes the CPU, AHB and APB busses clocks
- */
- RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
- RCC_OscInitStruct.HSIState = RCC_HSI_ON;
- RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
- RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
- RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
- RCC_OscInitStruct.PLL.PLLM = 13;
- RCC_OscInitStruct.PLL.PLLN = 195;
- RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
- RCC_OscInitStruct.PLL.PLLQ = 4;
- if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
- {
- Error_Handler();
- }
- /** Initializes the CPU, AHB and APB busses 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_3) != HAL_OK)
- {
- Error_Handler();
- }
- }
- /**
- * @brief NVIC Configuration.
- * @retval None
- */
- static void MX_NVIC_Init(void)
- {
- /* DMA1_Stream1_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(DMA1_Stream1_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(DMA1_Stream1_IRQn);
- /* DMA1_Stream4_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(DMA1_Stream4_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(DMA1_Stream4_IRQn);
- /* USART3_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(USART3_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(USART3_IRQn);
- /* TIM6_DAC_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);
- /* EXTI15_10_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
- /* EXTI9_5_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
- }
- /**
- * @brief I2C3 Initialization Function
- * @param None
- * @retval None
- */
- static void MX_I2C3_Init(void)
- {
- /* USER CODE BEGIN I2C3_Init 0 */
- /* USER CODE END I2C3_Init 0 */
- /* USER CODE BEGIN I2C3_Init 1 */
- /* USER CODE END I2C3_Init 1 */
- hi2c3.Instance = I2C3;
- hi2c3.Init.ClockSpeed = 400000;
- hi2c3.Init.DutyCycle = I2C_DUTYCYCLE_2;
- hi2c3.Init.OwnAddress1 = 0;
- hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
- hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
- hi2c3.Init.OwnAddress2 = 0;
- hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
- hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
- if (HAL_I2C_Init(&hi2c3) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN I2C3_Init 2 */
- /* USER CODE END I2C3_Init 2 */
- }
- /**
- * @brief TIM6 Initialization Function
- * @param None
- * @retval None
- */
- static void MX_TIM6_Init(void)
- {
- /* USER CODE BEGIN TIM6_Init 0 */
- /* USER CODE END TIM6_Init 0 */
- TIM_MasterConfigTypeDef sMasterConfig = {0};
- /* USER CODE BEGIN TIM6_Init 1 */
- /* USER CODE END TIM6_Init 1 */
- htim6.Instance = TIM6;
- htim6.Init.Prescaler = 6000 -1;
- htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
- htim6.Init.Period = 10 - 1;
- htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
- if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
- {
- Error_Handler();
- }
- sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
- sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
- if (HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN TIM6_Init 2 */
- /* USER CODE END TIM6_Init 2 */
- }
- /**
- * @brief USART3 Initialization Function
- * @param None
- * @retval None
- */
- static void MX_USART3_UART_Init(void)
- {
- /* USER CODE BEGIN USART3_Init 0 */
- /* USER CODE END USART3_Init 0 */
- /* USER CODE BEGIN USART3_Init 1 */
- /* USER CODE END USART3_Init 1 */
- huart3.Instance = USART3;
- huart3.Init.BaudRate = 115200;
- huart3.Init.WordLength = UART_WORDLENGTH_8B;
- huart3.Init.StopBits = UART_STOPBITS_1;
- huart3.Init.Parity = UART_PARITY_NONE;
- huart3.Init.Mode = UART_MODE_TX_RX;
- huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
- huart3.Init.OverSampling = UART_OVERSAMPLING_16;
- if (HAL_UART_Init(&huart3) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN USART3_Init 2 */
- /* USER CODE END USART3_Init 2 */
- }
- /**
- * Enable DMA controller clock
- */
- static void MX_DMA_Init(void)
- {
- /* DMA controller clock enable */
- __HAL_RCC_DMA1_CLK_ENABLE();
- }
- /**
- * @brief GPIO Initialization Function
- * @param None
- * @retval None
- */
- static void MX_GPIO_Init(void)
- {
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- /* GPIO Ports Clock Enable */
- __HAL_RCC_GPIOE_CLK_ENABLE();
- __HAL_RCC_GPIOC_CLK_ENABLE();
- __HAL_RCC_GPIOF_CLK_ENABLE();
- __HAL_RCC_GPIOH_CLK_ENABLE();
- __HAL_RCC_GPIOA_CLK_ENABLE();
- __HAL_RCC_GPIOB_CLK_ENABLE();
- __HAL_RCC_GPIOD_CLK_ENABLE();
- __HAL_RCC_GPIOG_CLK_ENABLE();
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
- |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
- |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_0, GPIO_PIN_RESET);
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_5
- |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12, GPIO_PIN_RESET);
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOF, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_11
- |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET);
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
- |GPIO_PIN_11, GPIO_PIN_RESET);
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
- |GPIO_PIN_9, GPIO_PIN_RESET);
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
- |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2
- |GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7, GPIO_PIN_RESET);
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOG, GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
- |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_9|GPIO_PIN_11
- |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14, GPIO_PIN_RESET);
- /*Configure GPIO pins : PE2 PE3 PE4 PE5
- PE8 PE9 PE10 PE11
- PE12 PE13 PE14 PE0 */
- GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
- |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
- |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_0;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
- /*Configure GPIO pins : PC14 PC15 PC4 PC5
- PC10 PC11 PC12 */
- GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_5
- |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
- /*Configure GPIO pins : PF0 PF1 PF2 PF11
- PF13 PF14 PF15 */
- GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_11
- |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
- /*Configure GPIO pins : PF6 PF7 PF8 */
- GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
- /*Configure GPIO pins : PC1 PC2 PC3 */
- GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
- /*Configure GPIO pins : PA4 PA5 PA6 PA7
- PA11 */
- GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
- |GPIO_PIN_11;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
- /*Configure GPIO pins : PB0 PB5 PB6 PB7
- PB9 */
- GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
- |GPIO_PIN_9;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
- /*Configure GPIO pins : PB12 PB13 PB14 PB15 */
- GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
- GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
- /*Configure GPIO pin : PD8 */
- GPIO_InitStruct.Pin = GPIO_PIN_8;
- GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
- /*Configure GPIO pins : PD11 PD12 PD13 PD14
- PD15 PD0 PD1 PD2
- PD3 PD6 PD7 */
- GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
- |GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2
- |GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
- /*Configure GPIO pins : PG2 PG3 PG4 PG5
- PG6 PG7 PG9 PG11
- PG12 PG13 PG14 */
- GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
- |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_9|GPIO_PIN_11
- |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
- }
- /* USER CODE BEGIN 4 */
- /* 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 */
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|