Fork to see if I can get working

Dependencies:   BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated

Fork of xDotBridge_update_test20180823 by Matt Briggs

Files at this revision

API Documentation at this revision

Comitter:
Matt Briggs
Date:
Tue Feb 21 11:07:22 2017 -0700
Parent:
50:e89647e77fd5
Child:
52:64a2c71c7c49
Commit message:
Moved PVD test files to seperate manual test. Add new PVD manual test. Updated bbio test and commited bin of test.

Changed in this revision

testBbio_v2_20170221.bin Show annotated file Show diff for this revision Revisions of this file
xDotBridge/TESTS/autoLibs/testDs2408/testAPI.cpp Show annotated file Show diff for this revision Revisions of this file
xDotBridge/config.h Show annotated file Show diff for this revision Revisions of this file
xDotBridge/manualTest/testBaseboardIO/testBaseboardIO.cpp Show annotated file Show diff for this revision Revisions of this file
xDotBridge/manualTest/testPVD/testPVD.cpp Show annotated file Show diff for this revision Revisions of this file
Binary file testBbio_v2_20170221.bin has changed
--- a/xDotBridge/TESTS/autoLibs/testDs2408/testAPI.cpp	Fri Feb 17 11:58:40 2017 -0700
+++ b/xDotBridge/TESTS/autoLibs/testDs2408/testAPI.cpp	Tue Feb 21 11:07:22 2017 -0700
@@ -28,7 +28,7 @@
  */
 void test_search() {
     uint8_t result;
-    for (int i=0; i<5; i++) {
+    for (int i=0; i<10; i++) {
         OWMaster.reset();
         OWMaster.reset_search(); // TODO Check if this is helpful
         wait(1.0);
--- a/xDotBridge/config.h	Fri Feb 17 11:58:40 2017 -0700
+++ b/xDotBridge/config.h	Tue Feb 21 11:07:22 2017 -0700
@@ -8,8 +8,9 @@
 #define __TEST__ 1 // Comment out for main application
 
 // Manual test
-//#define __TEST_BBIO__ // Comment out for main application
-//#define __TEST_LRR__ // Comment out for main application
+#define __TEST_BBIO__ // Comment out for main application
+//#define __TEST_PVD__  // Comment out for main application
+//#define __TEST_LRR__  // Comment out for main application
 // These define which wireless bridge you are generating code for
 #define BRIDGE_TX_BRUTE 0
 
--- a/xDotBridge/manualTest/testBaseboardIO/testBaseboardIO.cpp	Fri Feb 17 11:58:40 2017 -0700
+++ b/xDotBridge/manualTest/testBaseboardIO/testBaseboardIO.cpp	Tue Feb 21 11:07:22 2017 -0700
@@ -3,12 +3,12 @@
 #include "..\..\config.h"
 #include "BaseboardIO.h"
 #include "MTSLog.h"
-#include "critical.h"
 
 #ifdef __TEST_BBIO__
 Serial pc(USBTX, USBRX); // Externally defined
 
-const int VERSION = 1;
+const int VERSION = 2;
+extern void Error_Handler(void);
 
 char* bool2Str(bool in) {
     if (in) {
@@ -25,7 +25,6 @@
 volatile uint8_t pvdIntCnt;
 
 void ccInIntCallback () {
-//    core_util_atomic_incr_u8(&ccInIntCnt, 1); // Not needed since function is wrapped in critical section code.
     ccInIntCnt++;
 }
 void tamperIntCallback () {
@@ -34,9 +33,8 @@
 void pairBtnIntCallback () {
     pairBtnIntCnt++;
 }
-void HAL_PWR_PVDCallback () { // Override callback in lib
-    pvdIntCnt++;
-}
+
+// TODO Add in later after I figure out how
 
 class MenuManager
 {
@@ -117,7 +115,7 @@
                 tamperIntCnt);
         pc.printf("= CCIN. State: %s      IntCnt: %02d   =\r\n",
                 bool2Str(0), ccInIntCnt);
-        pc.printf("= PVD. State: N/A                IntCnt: %02d   =\r\n",
+        pc.printf("= PVD (BROKEN). State: N/A       IntCnt: %02d   =\r\n",
                 pvdIntCnt);
         pc.printf("= Is TX. State: %s                  =\r\n", bool2Str(mBbio->isTx()));
         pc.printf("= CC Normally Closed. State: %s     =\r\n", bool2Str(mBbio->isCCNC()));
@@ -145,34 +143,6 @@
     pc.baud(115200);
     mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL);
 
-    // Setup programmable voltage detector
-    // PVD_LEVEL0 Falling 1.85
-    // PVD_LEVEL1 Falling 2.04
-    // PVD_LEVEL2 Falling 2.24
-    // PVD_LEVEL3 Falling 2.44
-    // PVD_LEVEL4 Falling 2.64
-    // PVD_LEVEL5 Falling 2.84
-    // PVD_LEVEL6 Falling 3.05
-//    PWR_PVDTypeDef pvdConfig;
-////    pvdConfig.Mode = PWR_PVD_MODE_EVENT_RISING_FALLING; //PWR_PVD_MODE_NORMAL;
-//    pvdConfig.Mode = PWR_PVD_MODE_IT_RISING_FALLING | PWR_PVD_MODE_EVENT_RISING_FALLING;
-//    pvdConfig.PVDLevel = PWR_PVDLEVEL_5;
-//
-//    HAL_PWR_ConfigPVD(&pvdConfig);
-//    HAL_PWR_EnablePVD();
-//    logInfo("Programmable Voltage Detector set for level: %d", pvdConfig.PVDLevel);
-//
-////    HAL_PWR_PVDCallback();  // Does inc the value
-//
-////    __HAL_PWR_PVD_EXTI_CLEAR_FLAG();
-//    HAL_PWR_PVD_IRQHandler(); // This calls the callback and clears the IRQ
-//    __HAL_PWR_PVD_EXTI_GENERATE_SWIT();
-
-//    __HAL_PPP_EXTI_ENABLE_IT();
-
-//     __HAL_PWR_PVD_EXTI_ENABLE_EVENT()
-
-
     wait(1.0);
 
     pc.printf("===============================================\r\n");
@@ -221,4 +191,5 @@
     }
     return 0;
 }
+
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xDotBridge/manualTest/testPVD/testPVD.cpp	Tue Feb 21 11:07:22 2017 -0700
@@ -0,0 +1,74 @@
+#include "mbed.h"
+#include "stm32l1xx_hal_pwr.h"
+#include "..\..\config.h"
+
+#ifdef __TEST_PVD__
+
+Serial pc(USBTX, USBRX); // Externally defined
+
+extern void Error_Handler(void);
+
+volatile uint8_t pvdIntCnt;
+DigitalOut gpio0(GPIO0);
+
+void HAL_PWR_PVDCallback(void) {
+    gpio0 = 1;
+    pvdIntCnt++;
+    /* Clear PWR Exti pending bit */
+    __HAL_PWR_PVD_EXTI_CLEAR_FLAG();  // Just to be extra sure
+}
+int main ()
+{
+    HAL_MspInit();
+    pvdIntCnt = 0;
+
+    pc.baud(115200);
+
+    while (true) {
+        pc.printf("PVD_INT_CNT %d, EXTI_GET_FLAG %d\r\n", pvdIntCnt, __HAL_PWR_PVD_EXTI_GET_FLAG());
+        wait(0.1);
+    }
+    return 0;
+}
+void HAL_MspInit(void)
+{
+  /* USER CODE BEGIN MspInit 0 */
+  /* USER CODE END MspInit 0 */
+  PWR_PVDTypeDef sConfigPVD;
+  __HAL_RCC_COMP_CLK_ENABLE();
+  __HAL_RCC_SYSCFG_CLK_ENABLE();
+  __HAL_RCC_PWR_CLK_ENABLE();
+  HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
+  /* System interrupt init*/
+  /* MemoryManagement_IRQn interrupt configuration */
+  HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
+  /* BusFault_IRQn interrupt configuration */
+  HAL_NVIC_SetPriority(BusFault_IRQn, 0, 0);
+  /* UsageFault_IRQn interrupt configuration */
+  HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
+  /* SVC_IRQn interrupt configuration */
+  HAL_NVIC_SetPriority(SVC_IRQn, 0, 0);
+  /* DebugMonitor_IRQn interrupt configuration */
+  HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
+  /* PendSV_IRQn interrupt configuration */
+  HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0);
+  /* SysTick_IRQn interrupt configuration */
+  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
+  /* Peripheral interrupt init*/
+  /* PVD_IRQn interrupt configuration */
+  HAL_NVIC_SetPriority(PVD_IRQn, 1, 0);
+  HAL_NVIC_EnableIRQ(PVD_IRQn);  // If not commented out program will hard fault but does not interrupt
+    /**PVD Configuration
+    */
+  sConfigPVD.PVDLevel = PWR_PVDLEVEL_5;
+  sConfigPVD.Mode = PWR_PVD_MODE_IT_RISING_FALLING;
+//  sConfigPVD.Mode = PWR_PVD_MODE_EVENT_RISING;
+  HAL_PWR_ConfigPVD(&sConfigPVD);
+    /**Enable the PVD Output
+    */
+  HAL_PWR_EnablePVD();
+  /* USER CODE BEGIN MspInit 1 */
+  /* USER CODE END MspInit 1 */
+}
+
+#endif