Exemple #1
0
void DBG_Configuration()
{
	//Enable debug in powersafe modes
	HAL_DBGMCU_EnableDBGSleepMode();
	HAL_DBGMCU_EnableDBGStopMode();
	HAL_DBGMCU_EnableDBGStandbyMode();

	//hard fault on div by zero
	SCB->CCR |= SCB_CCR_DIV_0_TRP_Msk;
}
Exemple #2
0
/**
 * @brief  Main function to show how to use BlueNRG Bluetooth Low Energy
 *         stack.
 *         To test this application you need:
 *         - an STM32 Nucleo board with its BlueNRG STM32 expansion board
 *         - a Smartphone with Bluetooth Low Energy (BLE) chip and Android
 *           OS >= v4.3.
 *         On the Android smartphone the STM32_BLE_Toolbox App must be installed
 *         and running.
 *         The STM32_BLE_Toolbox App can be found in this package at:
 *         $PATH_TO_THIS_PACKAGE$\Utilities\Android_Software\Profiles_Central
 *         This sample application configures the board as Server-Peripheral,
 *         while the smartphone plays the Client-Central role.
 *         To set/change the BLE Profile to test, change the value of the macro
 *         BLE_CURRENT_PROFILE_ROLES (in the "active profile" section) in file:
 *         $PATH_TO_THIS_PACKAGE$\Middlewares\ST\STM32_BlueNRG\Profile_Framework
 *         \includes\host_config.h
 *         For example, if the HEART_RATE profile is set, after the connection
 *         between the board and the smartphone has been established, the
 *         STM32_BLE_Toolbox App will show the Heart Rate values in bpm (beats
 *         per minute) coming from the STM32 Nucleo board.
 *         The communication is done using a vendor specific profile.
 *
 * @param  None
 * @retval None
 */
int main(void)
{
#if (JTAG_SUPPORTED == 1) 
  /*
  * Keep debugger enabled while in any low power mode
  */
#ifdef STM32L053xx
  __DBGMCU_CLK_ENABLE();
  HAL_DBG_LowPowerConfig(DBGMCU_SLEEP | DBGMCU_STOP | DBGMCU_STANDBY, ENABLE);
#endif /* STM32L053xx */
  
#ifdef STM32L476xx
  HAL_DBGMCU_EnableDBGSleepMode();
  HAL_DBGMCU_EnableDBGStopMode();
  HAL_DBGMCU_EnableDBGStandbyMode();
#endif /* STM32L476xx */

#ifdef STM32F401xE 
  HAL_EnableDBGSleepMode();
  HAL_EnableDBGStopMode();
  HAL_EnableDBGStandbyMode();
#endif /* STM32F401xE */

#endif /* (JTAG_SUPPORTED == 1) */
 
  /* STM32Cube HAL library initialization:
   *  - Configure the Flash prefetch, Flash preread and Buffer caches
   *  - Systick timer is configured by default as source of time base, but user 
   *    can eventually implement his proper time base source (a general purpose 
   *    timer for example or other time source), keeping in mind that Time base 
   *    duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
   *    handled in milliseconds basis.
   *  - Low Level Initialization
   */
  HAL_Init();
  
  /* Configure the system clock */
  SystemClock_Config();
  
  /* Configure the system Power */
  SystemPower_Config();
    
  /* Initialize the Profile Application Context's Data Structures */
  Osal_MemSet(&profileApplContext,0,sizeof(tProfileApplContext));
  
  /* Configure the RTC */
  Init_RTC();
  TIMER_Init(&hrtc);
  TIMER_Create(eTimerModuleID_BlueNRG_Profile_App, &(profileApplContext.profileTimer_Id), eTimerMode_Repeated, 0);
  
  LPM_Mode_Request(eLPM_MAIN_LOOP_PROCESSES, eLPM_Mode_LP_Stop);  
  
  /* Initialize the BlueNRG SPI driver */
  BNRG_SPI_Init();
  
  /* Set current BlueNRG profile (HRM, HTM, GS, ...) */
  BNRG_Set_Current_profile();
  
  /* Initialize the BlueNRG Profile */
  /* set tx power and security parameters (common to all profiles) */
  BNRG_Profiles_Init();  
  /* low level profile initialization (profile specific) */
  profileApplContext.initProfileFunc();
  
  /* Start the main processes */
  while(1)
  {
    Background();
    
  } /* end while(1) */  
}