The foxBMS secondary mcu API documentation
io.c File Reference

Driver for the I/O ports (pins). More...

#include "io.h"
#include "driver_assert.h"
Include dependency graph for io.c:

Macros

#define IO_GET_GPIOx(_N)   ((GPIO_TypeDef *)(GPIOA_BASE + (GPIOB_BASE-GPIOA_BASE)*(_N)))
 
#define GPIO_MODE   ((uint32_t)0x00000003U)
 
#define EXTI_MODE   ((uint32_t)0x10000000U)
 
#define GPIO_MODE_IT   ((uint32_t)0x00010000U)
 
#define GPIO_MODE_EVT   ((uint32_t)0x00020000U)
 
#define RISING_EDGE   ((uint32_t)0x00100000U)
 
#define FALLING_EDGE   ((uint32_t)0x00200000U)
 
#define GPIO_OUTPUT_TYPE   ((uint32_t)0x00000010U)
 
#define GPIO_NUMBER   ((uint32_t)16U)
 

Functions

static STD_RETURN_TYPE_e IO_ClkInit (void)
 IO_ClkInit() activates the port clocks of the used package. More...
 
static STD_RETURN_TYPE_e GPIO_Check (GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
 Checks the GPIOx peripheral according to the specified parameters in the GPIO_Init. More...
 
STD_RETURN_TYPE_e IO_Init (const IO_PIN_CFG_s *io_config)
 Initializes all ports and pins of the microcontroller. More...
 
IO_PIN_STATE_e IO_ReadPin (IO_PORTS_e pin)
 Returns the state of a pin. More...
 
void IO_WritePin (IO_PORTS_e pin, IO_PIN_STATE_e requestedPinState)
 Sets the state of a pin. More...
 
void IO_TogglePin (IO_PORTS_e pin)
 Toggles the state of a pin. More...
 
void IO_EXTI_IRQHandler (IO_PORTS_e pin)
 Calls the EXTI_IRQHandler of the given pin. More...
 
void IO_EXTI_Callback (IO_PORTS_e pin)
 Calls the EXTI_Callback of the given pin. More...
 

Detailed Description

Driver for the I/O ports (pins).

BSD 3-Clause License 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 the copyright holder 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.

We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:

″This product uses parts of foxBMS®″

″This product includes parts of foxBMS®″

″This product is derived from foxBMS®″

Author
foxBMS Team
Date
26.08.2015 (date of creation)
Module-prefix IO

Macro Definition Documentation

◆ EXTI_MODE

#define EXTI_MODE   ((uint32_t)0x10000000U)

◆ FALLING_EDGE

#define FALLING_EDGE   ((uint32_t)0x00200000U)

◆ GPIO_MODE

#define GPIO_MODE   ((uint32_t)0x00000003U)

◆ GPIO_MODE_EVT

#define GPIO_MODE_EVT   ((uint32_t)0x00020000U)

◆ GPIO_MODE_IT

#define GPIO_MODE_IT   ((uint32_t)0x00010000U)

◆ GPIO_NUMBER

#define GPIO_NUMBER   ((uint32_t)16U)

◆ GPIO_OUTPUT_TYPE

#define GPIO_OUTPUT_TYPE   ((uint32_t)0x00000010U)

◆ IO_GET_GPIOx

#define IO_GET_GPIOx (   _N)    ((GPIO_TypeDef *)(GPIOA_BASE + (GPIOB_BASE-GPIOA_BASE)*(_N)))

◆ RISING_EDGE

#define RISING_EDGE   ((uint32_t)0x00100000U)

Function Documentation

◆ GPIO_Check()

STD_RETURN_TYPE_e GPIO_Check ( GPIO_TypeDef *  GPIOx,
GPIO_InitTypeDef *  GPIO_Init 
)
static

Checks the GPIOx peripheral according to the specified parameters in the GPIO_Init.


Attention
This function is based on the function 'HAL_GPIO_Init' from stm32f4xx_hal_gpio.c. The license of stm32f4xx_hal_gpio.c is as follows:

© COPYRIGHT(c) 2016 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.


Parameters
GPIOxwhere x can be (A..K) to select the GPIO peripheral for STM32F429X device or x can be (A..I) to select the GPIO peripheral for STM32F40XX and STM32F427X devices.
GPIO_Initpointer to a GPIO_InitTypeDef structure that contains the configuration information for the specified GPIO peripheral.
Return values
E_OKon success, E_NOT_OK on failure

◆ IO_ClkInit()

static STD_RETURN_TYPE_e IO_ClkInit ( void  )
static

IO_ClkInit() activates the port clocks of the used package.

IO_ClkInit is automatically called in IO_Init(). The clocks of each port available at the used package is enabled.

Returns
retVal (type: STD_RETURN_TYPE_e) returns E_OK when finished

◆ IO_EXTI_Callback()

void IO_EXTI_Callback ( IO_PORTS_e  pin)

Calls the EXTI_Callback of the given pin.

Parameters
pin(type: IO_PORTS_e)

◆ IO_EXTI_IRQHandler()

void IO_EXTI_IRQHandler ( IO_PORTS_e  pin)

Calls the EXTI_IRQHandler of the given pin.

Parameters
pin(type: IO_PORTS_e)

◆ IO_Init()

STD_RETURN_TYPE_e IO_Init ( const IO_PIN_CFG_s io_cfg)

Initializes all ports and pins of the microcontroller.

The pins of the microcontroller package are initialized by calling IO_Init(). The pins are identified by a signal name given in io_cfg_foxbms_mcu0_generated.h. The function gets the configuration of the pins by the array *io_cfg, which is defined is done in io_cfg.c. The io_cfg array allows you to set the functionality of the pin in the following order of the IO_PIN_CFG_s struct:

  • pin
    • signal name
  • mode -input
    • output
    • push-pull
    • open drain
    • analog
    • interrupt
      • rising edge
      • falling edge
      • rising falling edge
    • event
      • rising edge
      • falling edge
      • rising falling edge
  • logic level
    • no pull
    • pull up
    • pull down
  • speed
    • low
    • medium
    • fast
    • high
  • alternate functions
    • RTC_50Hz
    • MCO
    • TAMPER
    • SWJ (SWD and JTAG)
    • TRACE
    • TIM
    • I2C
    • SPI
    • I2S
    • SAI
    • USART
    • UART
    • CAN
    • LCD-TFT
    • OTG
  • pin configuration locking
    • disable
    • enable
  • default value of the pin
    • reset/low
    • set/high

If the define IO_PIN_LOCKING is set in file io_cfg.h the pin configuration locking is performed as defined in file io_cfg.c at the array IO_PIN_CFG_s io_cfg.

The default value of the pin/signal is optional. If the not given the signal is set low.

Parameters
*io_cfg(type: IO_PIN_CFG_s)
Returns
retVal (type: STD_RETURN_TYPE_e)
Here is the call graph for this function:

◆ IO_ReadPin()

IO_PIN_STATE_e IO_ReadPin ( IO_PORTS_e  pin)

Returns the state of a pin.

Reads the state/output of the given pin, which is given by its symbolic name.

Parameters
pin(type: IO_PORTS_e)
Returns
currentPinState (type: IO_PIN_STATE_e) returns
currentPinState physical pin out
GPIO_PIN_SET high
GPIO_PIN_RESET low

◆ IO_TogglePin()

void IO_TogglePin ( IO_PORTS_e  pin)

Toggles the state of a pin.

Parameters
pin(type: IO_PORTS_e)

◆ IO_WritePin()

void IO_WritePin ( IO_PORTS_e  pin,
IO_PIN_STATE_e  requestedPinState 
)

Sets the state of a pin.

Sets the state/output of the given pin, which is given by its symbolic name.

Parameters
pin(type: IO_PORTS_e) requested pin to be set
requestedPinState(type: IO_PIN_STATE_e) requests
requestedPinState physical pin out
GPIO_PIN_SET high
GPIO_PIN_RESET low