John Alexander / VL53L3ExpansionBoard

Dependencies:   VL53L3_Lib

Dependents:  

Committer:
charlesmn
Date:
Fri Oct 16 15:04:28 2020 +0000
Revision:
0:293607457a02
Change typo in name

Who changed what in which revision?

UserRevisionLine numberNew contents of line
charlesmn 0:293607457a02 1 /**
charlesmn 0:293607457a02 2 ******************************************************************************
charlesmn 0:293607457a02 3 * @file DbgMCU.h
charlesmn 0:293607457a02 4 * @author AST / EST
charlesmn 0:293607457a02 5 * @version V0.0.1
charlesmn 0:293607457a02 6 * @date 30-March-2015
charlesmn 0:293607457a02 7 * @brief Header file for enabling debugging in sleep modes for STM32 MCUs
charlesmn 0:293607457a02 8 ******************************************************************************
charlesmn 0:293607457a02 9 * @attention
charlesmn 0:293607457a02 10 *
charlesmn 0:293607457a02 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
charlesmn 0:293607457a02 12 *
charlesmn 0:293607457a02 13 * Redistribution and use in source and binary forms, with or without modification,
charlesmn 0:293607457a02 14 * are permitted provided that the following conditions are met:
charlesmn 0:293607457a02 15 * 1. Redistributions of source code must retain the above copyright notice,
charlesmn 0:293607457a02 16 * this list of conditions and the following disclaimer.
charlesmn 0:293607457a02 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
charlesmn 0:293607457a02 18 * this list of conditions and the following disclaimer in the documentation
charlesmn 0:293607457a02 19 * and/or other materials provided with the distribution.
charlesmn 0:293607457a02 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
charlesmn 0:293607457a02 21 * may be used to endorse or promote products derived from this software
charlesmn 0:293607457a02 22 * without specific prior written permission.
charlesmn 0:293607457a02 23 *
charlesmn 0:293607457a02 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
charlesmn 0:293607457a02 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
charlesmn 0:293607457a02 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
charlesmn 0:293607457a02 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
charlesmn 0:293607457a02 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
charlesmn 0:293607457a02 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
charlesmn 0:293607457a02 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
charlesmn 0:293607457a02 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
charlesmn 0:293607457a02 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
charlesmn 0:293607457a02 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
charlesmn 0:293607457a02 34 *
charlesmn 0:293607457a02 35 ******************************************************************************
charlesmn 0:293607457a02 36 */
charlesmn 0:293607457a02 37
charlesmn 0:293607457a02 38 /* Define to prevent from recursive inclusion --------------------------------*/
charlesmn 0:293607457a02 39 #ifndef __DBG_MCU_H
charlesmn 0:293607457a02 40 #define __DBG_MCU_H
charlesmn 0:293607457a02 41
charlesmn 0:293607457a02 42 /* Includes ------------------------------------------------------------------*/
charlesmn 0:293607457a02 43
charlesmn 0:293607457a02 44 /* Classes -------------------------------------------------------------------*/
charlesmn 0:293607457a02 45 /** Helper class DbgMCU providing a default constructor which enables debugging
charlesmn 0:293607457a02 46 * on STM32 MCUs while using sleep modes.
charlesmn 0:293607457a02 47 */
charlesmn 0:293607457a02 48 class DbgMCU
charlesmn 0:293607457a02 49 {
charlesmn 0:293607457a02 50 public:
charlesmn 0:293607457a02 51 /** Create a DbgMCU dummy object */
charlesmn 0:293607457a02 52 DbgMCU(void) {
charlesmn 0:293607457a02 53 /* the following code is NOT portable */
charlesmn 0:293607457a02 54 volatile uint32_t *dbgmcu_creg = (uint32_t*)0xE0042004;
charlesmn 0:293607457a02 55 uint32_t tmp = *dbgmcu_creg;
charlesmn 0:293607457a02 56
charlesmn 0:293607457a02 57 tmp &= ~(0xE7);
charlesmn 0:293607457a02 58 tmp |= 0x27; // Set asynchronous communication via DBGMCU_CR (for ITM/printf)
charlesmn 0:293607457a02 59 // tmp |= 0xE7; // Set 4-pin tracing via DBGMCU_CR (for ETM)
charlesmn 0:293607457a02 60 *dbgmcu_creg = tmp;
charlesmn 0:293607457a02 61 }
charlesmn 0:293607457a02 62 };
charlesmn 0:293607457a02 63
charlesmn 0:293607457a02 64 #endif /* __DBG_MCU_H */