LELEC2811 - I&S / Mbed OS LELEC2811_IKS01A3_Multisensors

Dependencies:   X_NUCLEO_IKS01A3

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers gpio.cpp Source File

gpio.cpp

00001 /**
00002   ******************************************************************************
00003   * File Name          : gpio.c
00004   * Description        : This file provides code for the configuration
00005   *                      of all used GPIO pins.
00006   ******************************************************************************
00007   ** This notice applies to any and all portions of this file
00008   * that are not between comment pairs USER CODE BEGIN and
00009   * USER CODE END. Other portions of this file, whether 
00010   * inserted by the user or by software development tools
00011   * are owned by their respective copyright owners.
00012   *
00013   * COPYRIGHT(c) 2019 STMicroelectronics
00014   *
00015   * Redistribution and use in source and binary forms, with or without modification,
00016   * are permitted provided that the following conditions are met:
00017   *   1. Redistributions of source code must retain the above copyright notice,
00018   *      this list of conditions and the following disclaimer.
00019   *   2. Redistributions in binary form must reproduce the above copyright notice,
00020   *      this list of conditions and the following disclaimer in the documentation
00021   *      and/or other materials provided with the distribution.
00022   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00023   *      may be used to endorse or promote products derived from this software
00024   *      without specific prior written permission.
00025   *
00026   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00029   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00030   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00031   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00032   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00033   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00034   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00035   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036   *
00037   ******************************************************************************
00038   */
00039 
00040 /* Includes ------------------------------------------------------------------*/
00041 #include "gpio.h"
00042 
00043 /*----------------------------------------------------------------------------*/
00044 /* Configure GPIO                                                             */
00045 /*----------------------------------------------------------------------------*/
00046 
00047 /** Configure pins as 
00048         * Analog 
00049         * Input 
00050         * Output
00051         * EVENT_OUT
00052         * EXTI
00053 */
00054 void MX_GPIO_Init(void)
00055 {
00056     GPIO_InitTypeDef GPIO_InitStruct;
00057 
00058     /* GPIO Ports Clock Enable */
00059     __HAL_RCC_GPIOC_CLK_ENABLE();
00060     __HAL_RCC_GPIOH_CLK_ENABLE();
00061     __HAL_RCC_GPIOA_CLK_ENABLE();
00062 
00063     /*Configure GPIO pin Output Level */
00064     HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
00065 
00066     /* Configure GPIO pin : PtPin */
00067     GPIO_InitStruct.Pin = B1_Pin;
00068     GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
00069     GPIO_InitStruct.Pull = GPIO_NOPULL;
00070     HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
00071 
00072     /* Configure GPIO pin : PtPin */
00073     GPIO_InitStruct.Pin = LD2_Pin;
00074     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
00075     GPIO_InitStruct.Pull = GPIO_NOPULL;
00076     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
00077     HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);
00078 
00079     /* Configure GPIO pin : IR ctrl , RED ctrl */
00080     GPIO_InitStruct.Pin = GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7;
00081     GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
00082     GPIO_InitStruct.Pull = GPIO_NOPULL;
00083     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
00084     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
00085 }
00086 
00087 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/