103 lines
2.5 KiB
C
103 lines
2.5 KiB
C
//
|
|
// This file is part of the GNU ARM Eclipse distribution.
|
|
// Copyright (c) 2014 Liviu Ionescu.
|
|
//
|
|
|
|
#ifndef BLINKLED_H_
|
|
#define BLINKLED_H_
|
|
|
|
#include "stm32f7xx.h"
|
|
#include "stm32f7xx_hal.h"
|
|
|
|
// ----- LED definitions ------------------------------------------------------
|
|
|
|
// Adjust these definitions for your own board.
|
|
|
|
|
|
// Ports numbers are: PA=0, PB=1, PC=2, PD=3, PE=4, PF=5, PG=6, PH=7, PI=8.
|
|
|
|
#if defined(STM32F746xx)
|
|
|
|
#if defined(STM32F746_EVAL)
|
|
|
|
//#warning "Assume a STM32F746G-EVAL board, PF12 & PB7, active low."
|
|
|
|
#define BLINK_PORT_NUMBER (5)
|
|
#define BLINK_PIN_NUMBER (12)
|
|
|
|
#define BLINK_PORT_NUMBER_RED (1)
|
|
#define BLINK_PIN_NUMBER_RED (7)
|
|
|
|
#define BLINK_ACTIVE_LOW (1)
|
|
|
|
#else
|
|
|
|
#warning "Assume a STM32F746G-DISCO board, PI1, active high."
|
|
|
|
// STM32F746-DISCO definitions (the GREEN led, I1, active high)
|
|
|
|
#define BLINK_PORT_NUMBER (4)
|
|
#define BLINK_PIN_NUMBER (13)
|
|
#define BLINK_ACTIVE_LOW (0)
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#warning "Unknown board, assume PA5, active high."
|
|
|
|
#define BLINK_PORT_NUMBER (0)
|
|
#define BLINK_PIN_NUMBER (5)
|
|
#define BLINK_ACTIVE_LOW (0)
|
|
|
|
#endif
|
|
|
|
#define BLINK_GPIOx(_N) ((GPIO_TypeDef *)(GPIOA_BASE + (GPIOB_BASE-GPIOA_BASE)*(_N)))
|
|
#define BLINK_PIN_MASK(_N) (1 << (_N))
|
|
#define BLINK_RCC_MASKx(_N) (RCC_AHB1ENR_GPIOAEN << (_N))
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
extern
|
|
void
|
|
blink_led_init(void);
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
inline void
|
|
blink_led_on(void);
|
|
|
|
inline void
|
|
blink_led_off(void);
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
inline void
|
|
__attribute__((always_inline))
|
|
blink_led_on(void)
|
|
{
|
|
#if (BLINK_ACTIVE_LOW)
|
|
HAL_GPIO_WritePin(BLINK_GPIOx(BLINK_PORT_NUMBER),
|
|
BLINK_PIN_MASK(BLINK_PIN_NUMBER), GPIO_PIN_RESET);
|
|
#else
|
|
HAL_GPIO_WritePin(BLINK_GPIOx(BLINK_PORT_NUMBER),
|
|
BLINK_PIN_MASK(BLINK_PIN_NUMBER), GPIO_PIN_SET);
|
|
#endif
|
|
}
|
|
|
|
inline void
|
|
__attribute__((always_inline))
|
|
blink_led_off(void)
|
|
{
|
|
#if (BLINK_ACTIVE_LOW)
|
|
HAL_GPIO_WritePin(BLINK_GPIOx(BLINK_PORT_NUMBER),
|
|
BLINK_PIN_MASK(BLINK_PIN_NUMBER), GPIO_PIN_SET);
|
|
#else
|
|
HAL_GPIO_WritePin(BLINK_GPIOx(BLINK_PORT_NUMBER),
|
|
BLINK_PIN_MASK(BLINK_PIN_NUMBER), GPIO_PIN_RESET);
|
|
#endif
|
|
}
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
#endif // BLINKLED_H_
|