| | |
| | | // GPIO_InitStruct.Alternate = LL_GPIO_AF_0; |
| | | // LL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
| | | |
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_15; |
| | | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; |
| | | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; |
| | | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; |
| | | GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; |
| | | GPIO_InitStruct.Alternate = LL_GPIO_AF_0; |
| | | LL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
| | | |
| | | LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB); |
| | | /**SPI1 GPIO Configuration |
| | | PB3 ------> SPI1_SCK |
| | | PB4 ------> SPI1_MISO |
| | | PB5 ------> SPI1_MOSI |
| | | */ |
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_3; |
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_3 | LL_GPIO_PIN_4 | LL_GPIO_PIN_5; |
| | | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; |
| | | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; |
| | | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; |
| | | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; |
| | | GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; |
| | | GPIO_InitStruct.Alternate = LL_GPIO_AF_0; |
| | | LL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| | | |
| | | /* |
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_4; |
| | | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; |
| | | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; |
| | |
| | | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; |
| | | GPIO_InitStruct.Alternate = LL_GPIO_AF_0; |
| | | LL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| | | |
| | | */ |
| | | /* SPI1 interrupt Init */ |
| | | NVIC_SetPriority(SPI1_IRQn, 0); |
| | | // NVIC_EnableIRQ(SPI1_IRQn); |
| | |
| | | /* USER CODE END SPI2_Init 2 */ |
| | | } |
| | | |
| | | void Soft_I2C1_Init(void) |
| | | { |
| | | LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; |
| | | LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB); |
| | | /**I2C1 GPIO Configuration |
| | | PB6 ------> I2C1_SCL |
| | | PB7 ------> I2C1_SDA |
| | | */ |
| | | LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_6|LL_GPIO_PIN_7); |
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_6 | LL_GPIO_PIN_7; |
| | | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; |
| | | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; |
| | | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; |
| | | GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; |
| | | LL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| | | LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_6 | LL_GPIO_PIN_7); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @brief I2C1 Initialization Function |
| | | * @param None |
| | | * @retval None |
| | | */ |
| | | void MX_I2C1_Init(void) |
| | | { |
| | | |
| | | /* USER CODE BEGIN I2C1_Init 0 */ |
| | | |
| | | /* USER CODE END I2C1_Init 0 */ |
| | | |
| | | LL_I2C_InitTypeDef I2C_InitStruct = {0}; |
| | | |
| | | LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; |
| | | |
| | | LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB); |
| | | /**I2C1 GPIO Configuration |
| | | PB8 ------> I2C1_SCL |
| | | PB9 ------> I2C1_SDA |
| | | */ |
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_8; |
| | | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; |
| | | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; |
| | | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; |
| | | GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; |
| | | GPIO_InitStruct.Alternate = LL_GPIO_AF_1; |
| | | LL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| | | |
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_9; |
| | | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; |
| | | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; |
| | | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; |
| | | GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; |
| | | GPIO_InitStruct.Alternate = LL_GPIO_AF_1; |
| | | LL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| | | |
| | | /* Peripheral clock enable */ |
| | | LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_I2C1); |
| | | |
| | | /* USER CODE BEGIN I2C1_Init 1 */ |
| | | |
| | | /* USER CODE END I2C1_Init 1 */ |
| | | /** I2C Initialization |
| | | */ |
| | | LL_I2C_DisableOwnAddress2(I2C1); |
| | | LL_I2C_DisableGeneralCall(I2C1); |
| | | LL_I2C_EnableClockStretching(I2C1); |
| | | I2C_InitStruct.PeripheralMode = LL_I2C_MODE_I2C; |
| | | I2C_InitStruct.Timing = 0x20303E5D; |
| | | I2C_InitStruct.AnalogFilter = LL_I2C_ANALOGFILTER_ENABLE; |
| | | I2C_InitStruct.DigitalFilter = 0; |
| | | I2C_InitStruct.OwnAddress1 = 0; |
| | | I2C_InitStruct.TypeAcknowledge = LL_I2C_ACK; |
| | | I2C_InitStruct.OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT; |
| | | LL_I2C_Init(I2C1, &I2C_InitStruct); |
| | | LL_I2C_EnableAutoEndMode(I2C1); |
| | | LL_I2C_SetOwnAddress2(I2C1, 0, LL_I2C_OWNADDRESS2_NOMASK); |
| | | /* USER CODE BEGIN I2C1_Init 2 */ |
| | | |
| | | /* USER CODE END I2C1_Init 2 */ |
| | | |
| | | } |
| | | |
| | | /* USART1 init function */ |
| | | void MX_USART1_UART_Init(void) |
| | |
| | | LL_GPIO_PIN_12|LL_GPIO_PIN_13|LL_GPIO_PIN_15; |
| | | |
| | | |
| | | #elif (BOARD_TYPE==9 || BOARD_TYPE==10 || BOARD_TYPE==15 || BOARD_TYPE == 16 ) |
| | | #elif (BOARD_TYPE==9 || BOARD_TYPE==10) |
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_11|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_10| |
| | | LL_GPIO_PIN_12|LL_GPIO_PIN_13|LL_GPIO_PIN_15; |
| | | |
| | | #elif (BOARD_TYPE==15 || BOARD_TYPE == 16 ) |
| | | |
| | | GPIO_InitStruct.Pin = LL_GPIO_PIN_3|LL_GPIO_PIN_5|LL_GPIO_PIN_6|LL_GPIO_PIN_7| |
| | | LL_GPIO_PIN_11|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_10| |