-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbc5eb5
commit d9b91ed
Showing
5 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (C) 2017 Freie Universität Berlin | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @ingroup cpu_stm32_common | ||
* | ||
* @{ | ||
* @file | ||
* @brief CPU specific handlers for direct control of debug pins | ||
* | ||
* @author Hauke Petersen <[email protected]> | ||
*/ | ||
|
||
#ifndef PINDBG_CPU_H | ||
#define PINDBG_CPU_H | ||
|
||
#include "cpu.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifdef PINDBG0 | ||
#define PINDBG0_PORT ((GPIO_TypeDef *)(PINDBG0 & ~(0x0f))) | ||
#define PINDBG0_MASK (1 << (PINDBG0 & 0xf)) | ||
#define PINDBG0_SET (PINDBG0_PORT->BSRR = PINDBG0_MASK) | ||
#define PINDBG0_CLR (PINDBG0_PORT->BSRR = (PINDBG0_MASK << 16)) | ||
#define PINDBG0_TGL (PINDBG0_PORT->ODR ^= PINDBG0_MASK) | ||
#endif | ||
|
||
#ifdef PINDBG1 | ||
#define PINDBG1_PORT ((GPIO_TypeDef *)(PINDBG1 & ~(0x0f))) | ||
#define PINDBG1_MASK (1 << (PINDBG1 & 0xf)) | ||
#define PINDBG1_SET (PINDBG1_PORT->BSRR = PINDBG1_MASK) | ||
#define PINDBG1_CLR (PINDBG1_PORT->BSRR = (PINDBG1_MASK << 16)) | ||
#define PINDBG1_TGL (PINDBG1_PORT->ODR ^= PINDBG1_MASK) | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* PINDBG_CPU_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2017 Freie Universität Berlin | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @defgroup sys_pindbg Direct pin control for debugging/profiling | ||
* @ingroup sys | ||
* | ||
* This module gives the possibility to directly control a number of GPIO pins | ||
* without the least possible overhead for debugging and profiling purposes. For | ||
* this, the module provides a number of macros for setting, clearing, and | ||
* toggling some defined pins: `PINDBG[\d]_[SET|CLR|TGL]`, for example | ||
* `PINDBG0_SET` or `PINDBG1_TGL`. | ||
* | ||
* To use this module, you have to do two things: | ||
* 1. the module has to be selected in your project: `USEMODULE += pindbg` | ||
* 2. you have to define the pins you want to use for debugging, e.g.: | ||
* `CFLAGS += -DPINDBG0=GPIO_PIN\(0,15\) -DPINDBG1=GPIO_PIN\(1,24\)` | ||
* | ||
* It is of course up to you to add these settings to your application Makefile | ||
* for the duration of debugging/profiling or to set them through environment | ||
* variables in your host systems shell. | ||
* | ||
* The initialization function is automatically called as early as possible | ||
* during the system initialization so the debug pins can be used already during | ||
* e.g. auto_init and so on. | ||
* | ||
* @{ | ||
* @file | ||
* @brief Module for direct pin control for debugging/profiling purposes | ||
* | ||
* @author Hauke Petersen <[email protected]> | ||
*/ | ||
|
||
#ifndef PINDBG_H | ||
#define PINDBG_H | ||
|
||
#include "pindbg_cpu.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Initialize all configured debug pins | ||
*/ | ||
void pindbg_init(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* PINDBG_H */ | ||
/** @} */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) 2017 Freie Universität Berlin | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @ingroup sys_pindbg | ||
* @{ | ||
* | ||
* @file | ||
* @brief Initialization of configured direct controlled debug pins | ||
* | ||
* @author Hauke Petersen <[email protected]> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include "pindbg.h" | ||
#include "periph/gpio.h" | ||
|
||
void pindbg_init(void) | ||
{ | ||
#ifdef PINDBG0 | ||
gpio_init(PINDBG0, GPIO_OUT); | ||
#endif | ||
#ifdef PINDBG1 | ||
gpio_init(PINDBG1, GPIO_OUT); | ||
#endif | ||
} |