Throw error if configured device not found in Watchdog deviceTable
authorRobert Tivy <rtivy@ti.com>
Thu, 7 May 2015 23:23:14 +0000 (16:23 -0700)
committerRobert Tivy <rtivy@ti.com>
Fri, 8 May 2015 00:13:06 +0000 (17:13 -0700)
Previously Watchdog.xs would cryptically error out if an unsupported
device tried to use Deh.  This change produces a clean error statement.

packages/ti/deh/Watchdog.xs

index bf7c69d80d3584c5e7fe3ce8f4a6bbd83361a608..baa7aef440ad0e3aba1c03ede40a1e176992cd6f 100644 (file)
@@ -362,6 +362,7 @@ if (xdc.om.$name == "cfg" || typeof(genCdoc) != "undefined") {
 function module$use()
 {
     var device;
 function module$use()
 {
     var device;
+    var found = false;
 
     /* Only process during "cfg" phase */
     if (xdc.om.$name != "cfg") {
 
     /* Only process during "cfg" phase */
     if (xdc.om.$name != "cfg") {
@@ -391,11 +392,13 @@ function module$use()
                     Watchdog.timerSettings[i].clkCtrl = null;
                     Watchdog.timerSettings[i].intNum = device.intNum;
                     Watchdog.timerSettings[i].eventId = device.eventId;
                     Watchdog.timerSettings[i].clkCtrl = null;
                     Watchdog.timerSettings[i].intNum = device.intNum;
                     Watchdog.timerSettings[i].eventId = device.eventId;
+
+                    found = true;
                 }
                 else {
                     print("Watchdog Timer configuration is not found for " +
                       "timer " + timerIds[id] + " for the specified device (" +
                 }
                 else {
                     print("Watchdog Timer configuration is not found for " +
                       "timer " + timerIds[id] + " for the specified device (" +
-                      Program.cpu.deviceName + ").");
+                      Program.cpu.deviceName + ").  Supported devices:");
 
                     for (device in deviceTable[catalogName]) {
                         print("\t" + device);
 
                     for (device in deviceTable[catalogName]) {
                         print("\t" + device);
@@ -409,6 +412,17 @@ function module$use()
         }
     }
 
         }
     }
 
+    if (!found) {
+        print("Watchdog Timer configuration is not found for the specified " +
+          "device (" + Program.cpu.deviceName + ").  Supported devices:");
+
+        for (device in deviceTable[catalogName]) {
+            print("\t" + device);
+        }
+
+        throw new Error ("Watchdog Timer unsupported on device!");
+    }
+
     var Settings = xdc.module("ti.sysbios.family.Settings");
     var Hwi = xdc.useModule(Settings.getDefaultHwiDelegate());
 
     var Settings = xdc.module("ti.sysbios.family.Settings");
     var Hwi = xdc.useModule(Settings.getDefaultHwiDelegate());