PSDR/Source/include/BlinkLed.h
Michael Colton ffcb904b66 Initial commit to GitHub.
Includes the Source (as an Eclipse project) and the Hardware files (including schematic, layout, gerbers, and bill of materials.)

The firmware is extremely incomplete. At this point the DDS chips work (with controlled phase relationship), the LCD (with fast-ish SPI, scrolling, and GFX, modified from Adafruit's library), the encoder knob, and LED work.

The ADC is capturing, but not in a usable way, but it's enough to feed the DSP code and see a nice pretty waterfall. Timers, interrupts, and DACs are not working yet.
2014-06-22 17:49:43 -06:00

84 lines
2.1 KiB
C

//
// This file is part of the GNU ARM Eclipse distribution.
// Copyright (c) 2014 Liviu Ionescu.
//
#ifndef BLINKLED_H_
#define BLINKLED_H_
#include "stm32f4xx.h"
#include "stm32f4xx_hal.h"
// ----- LED definitions ------------------------------------------------------
// Adjust these definitions for your own board.
#if defined(BOARD_OLIMEX_STM32_E407)
// STM32-E407 definitions (the GREEN led, C13, active low)
// Port numbers: 0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, ...
#define BLINK_PORT_NUMBER (2)
#define BLINK_PIN_NUMBER (13)
#define BLINK_ACTIVE_LOW (1)
#else
// STM32F4DISCOVERY definitions (the GREEN led, D12, active high)
// (SEGGER J-Link device name: STM32F407VG).
#define BLINK_PORT_NUMBER (2)
#define BLINK_PIN_NUMBER (13)
#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_