]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/commitdiff
Fixed an error on main template file in case DEBUG is not defined. Implemented rpp_sc...
authorCarlos Jenkins <carlos@jenkins.co.cr>
Mon, 3 Jun 2013 11:00:13 +0000 (13:00 +0200)
committerCarlos Jenkins <carlos@jenkins.co.cr>
Mon, 3 Jun 2013 11:00:13 +0000 (13:00 +0200)
rpp/lib/rpp/include/rpp/sci.h
rpp/lib/rpp/src/drv/sci.c
rpp/lib/rpp/src/rpp/rpp.c
rpp/lib/rpp/src/rpp/sci.c
rpp/rpp/rpp_srmain.tlc

index 96d5e8d28ce1a2699b15ebbb7d86ffcdb269d07b..37766b181a307f25cbfd497f7ff33e9067fe39eb 100644 (file)
  * SCI module initialization.
  * Call this method before using this module.
  *
- * @param[in] baud      Baud rate for the SCI. Tested values are 9600 and FIXME
- *                      Use 0 or any value less than 9600 to set to default 9600.
  * @return SUCCESS if initialization successful.
- *         FAILURE is module already initialized.
+ *          FAILURE is module already initialized.
+ */
+int8_t rpp_sci_init();
+
+
+/**
+ * SCI module setup.
+ * Configure the SCI module.
+ *
+ * @param[in] baud      Baud rate for the SCI. Tested values are 9600 and FIXME
+ *                      Default is 9600.
+ *
+ * @return TRUE if baud rate is a known value.
+ *          FALSE otherwise.
  */
-int8_t rpp_sci_init(uint32_t baud);
+boolean_t rpp_sci_setup(uint32_t baud);
 
 
 /**
index 235e81c07960b0fa9278ff86de4d6a82b4af4367..a303387e9b9e30876f92e66887097cfbb4677b5d 100644 (file)
@@ -1,10 +1,13 @@
 #include "drv/drv.h"
 
-void drv_sci_init(uint32_t baud)
+void drv_sci_init()
 {
     // Low level init
     sciInit();
+}
 
+void drv_sci_set_baudrate(baud)
+{
     // Set baudrate
     sciSetBaudrate(sciREG, baud);
 }
index 80be657dc0a6fe0d649f249bb86c113af33d142d..9d336ef2310cd0acb334ac580adf00b135d1face 100644 (file)
@@ -82,7 +82,7 @@ int8_t rpp_init() {
 #endif
 
 #if rppCONFIG_INCLUDE_SCI == 1
-    rpp_sci_init(0);
+    rpp_sci_init();
 #endif
 
 #if rppCONFIG_INCLUDE_ETH == 1
index b37a5687ebe31bf934d408d1ddca872607f3b4c6..0438ac6c16d95248af0d93cf4866e665dff0969e 100644 (file)
 
 static boolean_t initialized = FALSE;
 
-int8_t rpp_sci_init(uint32_t baud)
+int8_t rpp_sci_init()
 {
     if(initialized) {
         return FAILURE;
     }
     initialized = TRUE;
 
-    if(baud < 9600) {
-        baud = 9600;
+    #if rppCONFIG_DRV == 1
+    drv_sci_init();
+    #endif
+
+   return SUCCESS;
+}
+
+
+boolean_t rpp_sci_setup(uint32_t baud)
+{
+    boolean_t known = FALSE;
+
+    // FIXME This is a standard list of baud rates. This should include only
+    // tested baud rates.
+    switch(baud) {
+        case 110:
+            known = TRUE;
+            break;
+        case 300:
+            known = TRUE;
+            break;
+        case 600:
+            known = TRUE;
+            break;
+        case 1200:
+            known = TRUE;
+            break;
+        case 2400:
+            known = TRUE;
+            break;
+        case 4800:
+            known = TRUE;
+            break;
+        case 9600:
+            known = TRUE;
+            break;
+        case 14400:
+            known = TRUE;
+            break;
+        case 19200:
+            known = TRUE;
+            break;
+        case 28800:
+            known = TRUE;
+            break;
+        case 38400:
+            known = TRUE;
+            break;
+        case 56000:
+            known = TRUE;
+            break;
+        case 57600:
+            known = TRUE;
+            break;
+        case 115200:
+            known = TRUE;
+            break;
     }
 
     #if rppCONFIG_DRV == 1
-    drv_sci_init(baud);
+    drv_sci_set_baudrate(baud);
     #endif
 
-   return SUCCESS;
+    return known;
 }
 
+
 int rpp_sci_printf(const char *format, ...)
 {
     char str[128];
index c2bba612e6eb97ca0a01ec3319a90d6f336ca517..4f6acb4d306cc9ff8c6fa33b4e4f4564a745a058 100644 (file)
     }
 
 
-    #ifdef DEBUG
     /**
      * FreeRTOS malloc() failed hook.
      */
     void vApplicationMallocFailedHook(void) {
+        #ifdef DEBUG
         rpp_sci_printf((const char*)"<malloc() failed>\r\n");
+        #endif
     }
 
     /**
      */
     void vApplicationStackOverflowHook(xTaskHandle xTask,
                                        signed portCHAR *pcTaskName) {
+        #ifdef DEBUG
         rpp_sci_printf((const char*)"<stack overflow : \"%s\">\r\n", pcTaskName);
+        #endif
     }
-    #endif
 
     %closefile tmpBuf
     %<LibSetSourceFileSection(cFile, "Functions", tmpBuf)>