Fork to see if I can get working
Dependencies: BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated
Fork of xDotBridge_update_test20180823 by
testPVD.cpp
00001 #include "mbed.h" 00002 #include "stm32l1xx_hal_pwr.h" 00003 #include "../../config.h" 00004 00005 #ifdef __TEST_PVD__ 00006 00007 Serial pc(USBTX, USBRX); // Externally defined 00008 00009 extern void Error_Handler(void); 00010 00011 volatile uint8_t pvdIntCnt; 00012 DigitalOut gpio0(GPIO0); 00013 00014 void HAL_PWR_PVDCallback(void) { 00015 gpio0 = 1; 00016 pvdIntCnt++; 00017 /* Clear PWR Exti pending bit */ 00018 __HAL_PWR_PVD_EXTI_CLEAR_FLAG(); // Just to be extra sure 00019 } 00020 int main () 00021 { 00022 HAL_MspInit(); 00023 pvdIntCnt = 0; 00024 00025 pc.baud(115200); 00026 00027 while (true) { 00028 pc.printf("PVD_INT_CNT %d, EXTI_GET_FLAG %d\r\n", pvdIntCnt, __HAL_PWR_PVD_EXTI_GET_FLAG()); 00029 wait(0.1); 00030 } 00031 return 0; 00032 } 00033 void HAL_MspInit(void) 00034 { 00035 /* USER CODE BEGIN MspInit 0 */ 00036 /* USER CODE END MspInit 0 */ 00037 PWR_PVDTypeDef sConfigPVD; 00038 __HAL_RCC_COMP_CLK_ENABLE(); 00039 __HAL_RCC_SYSCFG_CLK_ENABLE(); 00040 __HAL_RCC_PWR_CLK_ENABLE(); 00041 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); 00042 /* System interrupt init*/ 00043 /* MemoryManagement_IRQn interrupt configuration */ 00044 HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0); 00045 /* BusFault_IRQn interrupt configuration */ 00046 HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0); 00047 /* UsageFault_IRQn interrupt configuration */ 00048 HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0); 00049 /* SVC_IRQn interrupt configuration */ 00050 HAL_NVIC_SetPriority(SVC_IRQn, 0, 0); 00051 /* DebugMonitor_IRQn interrupt configuration */ 00052 HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0); 00053 /* PendSV_IRQn interrupt configuration */ 00054 HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0); 00055 /* SysTick_IRQn interrupt configuration */ 00056 HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); 00057 /* Peripheral interrupt init*/ 00058 /* PVD_IRQn interrupt configuration */ 00059 HAL_NVIC_SetPriority(PVD_IRQn, 1, 0); 00060 HAL_NVIC_EnableIRQ(PVD_IRQn); // If not commented out program will hard fault but does not interrupt 00061 /**PVD Configuration 00062 */ 00063 sConfigPVD.PVDLevel = PWR_PVDLEVEL_5; 00064 sConfigPVD.Mode = PWR_PVD_MODE_IT_RISING_FALLING; 00065 // sConfigPVD.Mode = PWR_PVD_MODE_EVENT_RISING; 00066 HAL_PWR_ConfigPVD(&sConfigPVD); 00067 /**Enable the PVD Output 00068 */ 00069 HAL_PWR_EnablePVD(); 00070 /* USER CODE BEGIN MspInit 1 */ 00071 /* USER CODE END MspInit 1 */ 00072 } 00073 00074 #endif
Generated on Fri Jul 15 2022 14:36:45 by 1.7.2