new lib adapted to folder structure
This commit is contained in:
84
source/test/src/include/BlinkLed.h
Normal file
84
source/test/src/include/BlinkLed.h
Normal file
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// 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 (3)
|
||||
#define BLINK_PIN_NUMBER (12)
|
||||
#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_
|
27
source/test/src/include/Timer.h
Normal file
27
source/test/src/include/Timer.h
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// This file is part of the GNU ARM Eclipse distribution.
|
||||
// Copyright (c) 2014 Liviu Ionescu.
|
||||
//
|
||||
|
||||
#ifndef TIMER_H_
|
||||
#define TIMER_H_
|
||||
|
||||
#include "cmsis_device.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define TIMER_FREQUENCY_HZ (1000u)
|
||||
|
||||
typedef uint32_t timer_ticks_t;
|
||||
|
||||
extern volatile timer_ticks_t timer_delayCount;
|
||||
|
||||
extern void
|
||||
timer_start (void);
|
||||
|
||||
extern void
|
||||
timer_sleep (timer_ticks_t ticks);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#endif // TIMER_H_
|
1
source/test/src/include/include.mk
Normal file
1
source/test/src/include/include.mk
Normal file
@@ -0,0 +1 @@
|
||||
INCLUDES += include
|
Reference in New Issue
Block a user