KETCube
Macros | Functions | Variables
ketCube_gpio.c File Reference

This file contains the ketCube GPIO driver. More...

#include "stm32l0xx_hal.h"
#include "timeServer.h"
#include "ketCube_cfg.h"
#include "ketCube_gpio.h"
#include "ketCube_terminal.h"

Macros

#define RCC_GPIO_CLK_ENABLE(__GPIO_PORT__)
 
#define RCC_GPIO_CLK_DISABLE(__GPIO_PORT__)
 

Functions

static void ketCube_gpio_LEDHandler (void *context)
 LED Periodic Handler. More...
 
IRQn_Type MSP_GetIRQn (uint16_t GPIO_Pin)
 Gets IRQ number as a function of the GPIO_Pin. More...
 
static ketCube_gpio_pin_t getPin (uint8_t index)
 Get the PIN from index. More...
 
static uint8_t getPinIndex (uint16_t pin)
 Get the position of the bit. More...
 
static ketCube_gpio_port_t getPort (uint8_t index)
 Get the PORT from index. More...
 
static uint8_t getPortIndex (ketCube_gpio_port_t port)
 Get the PORT index. More...
 
static char getPortName (ketCube_gpio_port_t port)
 Get the PORT index. More...
 
void ketCube_GPIO_noneIrqHandler ()
 Dummy irq handler. More...
 
void ketCube_GPIO_InitDriver (void)
 Initializes the GPIO driver. More...
 
ketCube_cfg_DrvError_t ketCube_GPIO_SleepEnter (void)
 Set-UP GPIO befere sleep enter. More...
 
ketCube_cfg_DrvError_t ketCube_GPIO_Init (ketCube_gpio_port_t port, uint16_t pin, GPIO_InitTypeDef *initStruct)
 Initializes the GPIO PIN(s) More...
 
ketCube_cfg_DrvError_t ketCube_GPIO_InitLED (ketCube_gpio_port_t port, uint16_t pin, ketCube_gpio_polarity_t polarity)
 Initializes the GPIO PIN(s) as LEDs. More...
 
ketCube_cfg_DrvError_t ketCube_GPIO_ReInit (ketCube_gpio_port_t port, uint16_t pin, GPIO_InitTypeDef *initStruct)
 Initializes the GPIO PIN(s) without usage checking. More...
 
ketCube_cfg_DrvError_t ketCube_GPIO_Release (ketCube_gpio_port_t port, ketCube_gpio_pin_t pin)
 Release KETCube PIN - setup as input pin. More...
 
ketCube_cfg_DrvError_t ketCube_GPIO_SetIrq (ketCube_gpio_port_t port, ketCube_gpio_pin_t pin, uint32_t prio, ketCube_GPIO_VoidFn_t irqHandler)
 Records the interrupt handler for the GPIO object. More...
 
ketCube_cfg_DrvError_t ketCube_GPIO_ClearIrq (ketCube_gpio_port_t port, ketCube_gpio_pin_t pin)
 Clear IRQ for the GPIO object. More...
 
void ketCube_GPIO_Write (ketCube_gpio_port_t port, ketCube_gpio_pin_t pin, bool bit)
 Writes the bit value to the GPIO PIN. More...
 
bool ketCube_GPIO_Read (ketCube_gpio_port_t port, ketCube_gpio_pin_t pin)
 Reads the current PIN value. More...
 
void ketCube_GPIO_SetLED (ketCube_gpio_port_t port, ketCube_gpio_pin_t pin, ketCube_gpio_LEDState_t state)
 Sets the LED state. More...
 
void HAL_GPIO_EXTI_Callback (ketCube_gpio_pin_t pin)
 Execute the irqHandler This function redefines a weak deffinition from stm32l0xx_hal_gpio.c. More...
 
void EXTI0_1_IRQHandler (void)
 
void EXTI2_3_IRQHandler (void)
 
void EXTI4_15_IRQHandler (void)
 

Variables

static volatile ketCube_gpio_descriptor_t pinDescr [3][16] = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }
 PIN descriptor for ports A, B and C. More...
 
static TimerEvent_t ketCube_gpio_LEDTimer = { 0 }
 
static ketCube_GPIO_VoidFn_t ketCube_GPIO_IrqHandlers [16] = { NULL }
 

Detailed Description

This file contains the ketCube GPIO driver.

Author
Jan Belohoubek
Version
0.2
Date
2018-10-30
Attention

© Copyright (c) 2018 University of West Bohemia in Pilsen All rights reserved.

Developed by: The SmartCampus Team Department of Technologies and Measurement www.smartcampus.cz | www.zcu.cz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.

Macro Definition Documentation

◆ RCC_GPIO_CLK_DISABLE

#define RCC_GPIO_CLK_DISABLE (   __GPIO_PORT__)
Value:
do { \
switch( __GPIO_PORT__) \
{ \
case GPIOA_BASE: __HAL_RCC_GPIOA_CLK_DISABLE(); break; \
case GPIOB_BASE: __HAL_RCC_GPIOB_CLK_DISABLE(); break; \
case GPIOC_BASE: __HAL_RCC_GPIOC_CLK_DISABLE(); break; \
case GPIOD_BASE: __HAL_RCC_GPIOD_CLK_DISABLE(); break; \
case GPIOH_BASE: default: __HAL_RCC_GPIOH_CLK_ENABLE(); \
} \
} while(0)

◆ RCC_GPIO_CLK_ENABLE

#define RCC_GPIO_CLK_ENABLE (   __GPIO_PORT__)
Value:
do { \
switch( __GPIO_PORT__) \
{ \
case GPIOA_BASE: __HAL_RCC_GPIOA_CLK_ENABLE(); break; \
case GPIOB_BASE: __HAL_RCC_GPIOB_CLK_ENABLE(); break; \
case GPIOC_BASE: __HAL_RCC_GPIOC_CLK_ENABLE(); break; \
case GPIOD_BASE: __HAL_RCC_GPIOD_CLK_ENABLE(); break; \
case GPIOH_BASE: default: __HAL_RCC_GPIOH_CLK_ENABLE(); \
} \
} while(0)

Function Documentation

◆ getPin()

static ketCube_gpio_pin_t getPin ( uint8_t  index)
inlinestatic

Get the PIN from index.

Parameters
indexindex
Return values
pinPIN

◆ getPinIndex()

static uint8_t getPinIndex ( uint16_t  pin)
inlinestatic

Get the position of the bit.

Parameters
pinpin (0 .. 15)
Return values
posthe position of the bit

◆ getPort()

static ketCube_gpio_port_t getPort ( uint8_t  index)
inlinestatic

Get the PORT from index.

Parameters
indexindex
Return values
portport

◆ getPortIndex()

static uint8_t getPortIndex ( ketCube_gpio_port_t  port)
inlinestatic

Get the PORT index.

Parameters
port
See also
ketCube_gpio_port_t
Return values
indexport index; 0xFF in case of invalid port

◆ getPortName()

static char getPortName ( ketCube_gpio_port_t  port)
inlinestatic

Get the PORT index.

Parameters
port
See also
ketCube_gpio_port_t
Return values
nameport name (A, B or C; 0xFF in case of invalid port

◆ HAL_GPIO_EXTI_Callback()

void HAL_GPIO_EXTI_Callback ( ketCube_gpio_pin_t  pin)

Execute the irqHandler This function redefines a weak deffinition from stm32l0xx_hal_gpio.c.

Parameters
pinGPIO PIN

◆ ketCube_gpio_LEDHandler()

void ketCube_gpio_LEDHandler ( void *  context)
static

LED Periodic Handler.

Note
this function is executed out of the IRQ context

◆ ketCube_GPIO_noneIrqHandler()

void ketCube_GPIO_noneIrqHandler ( )

Dummy irq handler.

◆ MSP_GetIRQn()

IRQn_Type MSP_GetIRQn ( uint16_t  GPIO_Pin)

Gets IRQ number as a function of the GPIO_Pin.

Parameters
GPIO_PinSpecifies the pins connected to the EXTI line.
Return values
IRQnumber

Variable Documentation

◆ ketCube_GPIO_IrqHandlers

ketCube_GPIO_VoidFn_t ketCube_GPIO_IrqHandlers[16] = { NULL }
static

◆ ketCube_gpio_LEDTimer

TimerEvent_t ketCube_gpio_LEDTimer = { 0 }
static

◆ pinDescr

volatile ketCube_gpio_descriptor_t pinDescr[3][16] = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }
static

PIN descriptor for ports A, B and C.