]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/commitdiff
Fixed MOUT driver. Everything is working just niceee.
authorCarlos Jenkins <carlos@jenkins.co.cr>
Mon, 17 Jun 2013 15:55:02 +0000 (17:55 +0200)
committerCarlos Jenkins <carlos@jenkins.co.cr>
Mon, 17 Jun 2013 15:55:02 +0000 (17:55 +0200)
doc/reports/report/report.t2t
rpp/lib/apps/rpp-test-suite/src/mout.c
rpp/lib/rpp/include/hal/gpio_tms570_def.h
rpp/lib/rpp/include/rpp/mout.h
rpp/lib/rpp/src/drv/mout.c
rpp/lib/rpp/src/rpp/mout.c
rpp/lib/rpp/src/sys/ti_drv_dmm.c
rpp/lib/rpp/src/sys/ti_drv_gio.c
rpp/lib/rpp/src/sys/ti_drv_het.c

index ea9315b03e9398e003e9b7b23e868e5cbce31e1d..99b800971542c9bf2e5dddb28a72e7c7926d04b9 100644 (file)
@@ -368,6 +368,12 @@ Talk about motivation, work done and compare against origin.
 - Prefix based functions names.
 - To be careful about symbol export.
 
+=== Futher improvements ===[futher_improvements]
+
+- Change name of GPIO MOUT1_EN to MOUT1_DIAG
+- Change name of GPIO MOUT1_IN to MOUT1_EN
+This are misleading.
+
 == Repository branch description ==[repository_branch_description]
 
 
index 4e7214b6a5e296e93efb47980fe2642c16168618..603baf14d1cd94586622208ef28d161cc1220b06 100644 (file)
@@ -59,24 +59,45 @@ void mout_test_task(void* par)
     portTickType last_wake_time = xTaskGetTickCount();
 
     uint8_t i;
+    uint8_t tmp;
     uint8_t pin;
-    boolean_t state = FALSE;
+    boolean_t state = TRUE;
     while(!stop_tasks) {
 
-        // Toggle state
+        // Toggle state one by one slowly
         for(pin = 1; pin <= 6; pin++) {
+
+            // Change pin
             rpp_mout_set(pin, state);
+
+            // Reprint values
+            rpp_sci_printf((const char*)
+                    "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
+                    "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
+                );
+
+            tmp = pin;
+            for(pin = 1; pin <= 6; pin++) {
+                rpp_sci_printf((const char*)
+                        "%d:    ", rpp_mout_get(pin)
+                    );
+            }
+            pin = tmp;
+
+            // Wait for next change
+            if(!stop_tasks) {
+                vTaskDelayUntil(&last_wake_time, freq_ticks);
+            } else {
+                break;
+            }
+
         }
         state = !state;
 
-        rpp_sci_printf((const char*)
-                "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
-                "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
-            );
-
-        for(pin = 1; pin <= 6; pin++) {
+        if(!stop_tasks) {
             rpp_sci_printf((const char*)
-                    "%d:    ", rpp_mout_get(pin)
+                    "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
+                    "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
                 );
         }
 
@@ -97,7 +118,7 @@ void mout_test_task(void* par)
             for(pin = 1; pin <= 6; pin++) {
                 rpp_sci_printf((const char*)
                     "%d:%s ", rpp_mout_get(pin),
-                    (rpp_mout_get(pin) == rpp_mout_diag(pin)) ? " OK" : "BAD"
+                    (rpp_mout_diag(pin) == SUCCESS) ? " OK" : "BAD"
                 );
             }
 
index 55fa5419d42c2f27c8c03fefb917c17fda959def..0e6b5d199febae912da4fe35d00768975814e6e9 100644 (file)
@@ -40,8 +40,8 @@
 #define PORT_CONF_MODE_MASK 0x30000000
 #define PORT_CONF_MODE_PTYPE_MASK   0x10000000
 #define PORT_CONF_MODE_PEN_MASK     0x20000000
-#define PORT_CONF_MODE_PU   0x00000000
-#define PORT_CONF_MODE_PD   0x10000000
+#define PORT_CONF_MODE_PU   0x00000000      // Pull-up
+#define PORT_CONF_MODE_PD   0x10000000      // Pull-down
 #define PORT_CONF_MODE_PEN  0x20000000      // Pull resistor enable
 #define PORT_CONF_MODE_PDIS 0x00000000      // Pull resistor disable
 
 #define PORT_CONF_FNC_2     0x80000000
 #define PORT_CONF_FNC_3     0xc0000000
 
-#define PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF      PORT_CONF_FNC_GPIO|PORT_CONF_INIT_LOW|PORT_CONF_DIR_OUT|PORT_CONF_MODE_PD|PORT_CONF_MODE_PEN|PORT_CONF_OD_OFF
 #define PORT_CONF_GPIO_OUT_HI_PD_PEN_ODOFF      PORT_CONF_FNC_GPIO|PORT_CONF_INIT_HIGH|PORT_CONF_DIR_OUT|PORT_CONF_MODE_PD|PORT_CONF_MODE_PEN|PORT_CONF_OD_OFF
+#define PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF      PORT_CONF_FNC_GPIO|PORT_CONF_INIT_LOW|PORT_CONF_DIR_OUT|PORT_CONF_MODE_PD|PORT_CONF_MODE_PEN|PORT_CONF_OD_OFF
+#define PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON       PORT_CONF_FNC_GPIO|PORT_CONF_INIT_LOW|PORT_CONF_DIR_OUT|PORT_CONF_MODE_PD|PORT_CONF_MODE_PEN|PORT_CONF_OD_ON
 #define PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODON      PORT_CONF_FNC_GPIO|PORT_CONF_INIT_LOW|PORT_CONF_DIR_OUT|PORT_CONF_MODE_PD|PORT_CONF_MODE_PDIS|PORT_CONF_OD_ON
 #define PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODOFF     PORT_CONF_FNC_GPIO|PORT_CONF_INIT_LOW|PORT_CONF_DIR_OUT|PORT_CONF_MODE_PD|PORT_CONF_MODE_PDIS|PORT_CONF_OD_OFF
+#define PORT_CONF_GPIO_OUT_LO_PU_PDIS_ODOFF     PORT_CONF_FNC_GPIO|PORT_CONF_INIT_LOW|PORT_CONF_DIR_OUT|PORT_CONF_MODE_PU|PORT_CONF_MODE_PDIS|PORT_CONF_OD_OFF
+#define PORT_CONF_GPIO_IN_HI_PU_PEN_ODON        PORT_CONF_FNC_GPIO|PORT_CONF_INIT_HIGH|PORT_CONF_DIR_IN|PORT_CONF_MODE_PU|PORT_CONF_MODE_PEN|PORT_CONF_OD_ON
+#define PORT_CONF_GPIO_IN_HI_PU_PDIS_ODON       PORT_CONF_FNC_GPIO|PORT_CONF_INIT_HIGH|PORT_CONF_DIR_IN|PORT_CONF_MODE_PU|PORT_CONF_MODE_PDIS|PORT_CONF_OD_ON
 #define PORT_CONF_GPIO_IN_LO_PD_PDIS_ODOFF      PORT_CONF_FNC_GPIO|PORT_CONF_INIT_LOW|PORT_CONF_DIR_IN|PORT_CONF_MODE_PD|PORT_CONF_MODE_PDIS|PORT_CONF_OD_OFF
-#define PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON       PORT_CONF_FNC_GPIO|PORT_CONF_INIT_LOW|PORT_CONF_DIR_OUT|PORT_CONF_MODE_PD|PORT_CONF_MODE_PEN|PORT_CONF_OD_ON
 #define PORT_CONF_GPIO_IN_LO_PU_PDIS_ODOFF      PORT_CONF_FNC_GPIO|PORT_CONF_INIT_LOW|PORT_CONF_DIR_IN|PORT_CONF_MODE_PD|PORT_CONF_MODE_PDIS|PORT_CONF_OD_OFF
-#define PORT_CONF_GPIO_OUT_LO_PU_PDIS_ODOFF     PORT_CONF_FNC_GPIO|PORT_CONF_INIT_LOW|PORT_CONF_DIR_OUT|PORT_CONF_MODE_PU|PORT_CONF_MODE_PDIS|PORT_CONF_OD_OFF
 
 typedef struct pin_map_element {
-    const char*     pin_name;       // Pin name
+    const char*    pin_name;       // Pin name
     uint32_t        pin_desc;       // Pin descriptor assigned to the pin name
 } pin_map_element_t;
 
@@ -144,8 +146,8 @@ typedef struct pin_map_element {
 #define PIN_DSC_VBATEN      PORT_PIN(PORT_ID_DMM, 5, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
 #define PIN_DSC_SPICSA      PORT_PIN(PORT_ID_DMM, 7, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
 #define PIN_DSC_SPICSB      PORT_PIN(PORT_ID_DMM, 8, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
-#define PIN_DSC_MOUT1EN     PORT_PIN(PORT_ID_DMM, 11, PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODON)
-#define PIN_DSC_MOUT2EN     PORT_PIN(PORT_ID_DMM, 12, PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODON)
+#define PIN_DSC_MOUT1EN     PORT_PIN(PORT_ID_DMM, 11, PORT_CONF_GPIO_IN_HI_PU_PDIS_ODON)
+#define PIN_DSC_MOUT2EN     PORT_PIN(PORT_ID_DMM, 12, PORT_CONF_GPIO_IN_HI_PU_PDIS_ODON)
 #define PIN_DSC_CANNSTB     PORT_PIN(PORT_ID_DMM, 13, PORT_CONF_GPIO_OUT_HI_PD_PEN_ODOFF)
 #define PIN_DSC_CANEN       PORT_PIN(PORT_ID_DMM, 15, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
 #define PIN_DSC_LIN2NSLP    PORT_PIN(PORT_ID_DMM, 16, PORT_CONF_GPIO_OUT_HI_PD_PEN_ODOFF)
@@ -159,19 +161,19 @@ typedef struct pin_map_element {
 #define PIN_DSC_DIN13       PORT_PIN(PORT_ID_GIOA, 5, PORT_CONF_GPIO_IN_LO_PD_PDIS_ODOFF)
 #define PIN_DSC_DIN14       PORT_PIN(PORT_ID_GIOA, 6, PORT_CONF_GPIO_IN_LO_PD_PDIS_ODOFF)
 #define PIN_DSC_DIN15       PORT_PIN(PORT_ID_GIOA, 7, PORT_CONF_GPIO_IN_LO_PD_PDIS_ODOFF)
-#define PIN_DSC_MOUT6EN     PORT_PIN(PORT_ID_GIOB, 0, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
-#define PIN_DSC_MOUT5EN     PORT_PIN(PORT_ID_GIOB, 1, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
-#define PIN_DSC_MOUT6IN     PORT_PIN(PORT_ID_GIOB, 2, PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODOFF)
-#define PIN_DSC_MOUT5IN     PORT_PIN(PORT_ID_GIOB, 3, PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODOFF)
-#define PIN_DSC_MOUT4EN     PORT_PIN(PORT_ID_GIOB, 4, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
-#define PIN_DSC_MOUT3EN     PORT_PIN(PORT_ID_GIOB, 5, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
-#define PIN_DSC_MOUT4IN     PORT_PIN(PORT_ID_GIOB, 6, PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODOFF)
-#define PIN_DSC_MOUT3IN     PORT_PIN(PORT_ID_GIOB, 7, PORT_CONF_GPIO_OUT_LO_PD_PDIS_ODOFF)
+#define PIN_DSC_MOUT6EN     PORT_PIN(PORT_ID_GIOB, 0, PORT_CONF_GPIO_IN_HI_PU_PDIS_ODON)
+#define PIN_DSC_MOUT5EN     PORT_PIN(PORT_ID_GIOB, 1, PORT_CONF_GPIO_IN_HI_PU_PDIS_ODON)
+#define PIN_DSC_MOUT6IN     PORT_PIN(PORT_ID_GIOB, 2, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_MOUT5IN     PORT_PIN(PORT_ID_GIOB, 3, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_MOUT4EN     PORT_PIN(PORT_ID_GIOB, 4, PORT_CONF_GPIO_IN_HI_PU_PDIS_ODON)
+#define PIN_DSC_MOUT3EN     PORT_PIN(PORT_ID_GIOB, 5, PORT_CONF_GPIO_IN_HI_PU_PDIS_ODON)
+#define PIN_DSC_MOUT4IN     PORT_PIN(PORT_ID_GIOB, 6, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_MOUT3IN     PORT_PIN(PORT_ID_GIOB, 7, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
 #define PIN_DSC_HBREN       PORT_PIN(PORT_ID_HET1, 1, PORT_CONF_GPIO_OUT_LO_PU_PDIS_ODOFF)
 #define PIN_DSC_HBRDIR      PORT_PIN(PORT_ID_HET1, 4, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
 #define PIN_DSC_HBRPWM      PORT_PIN(PORT_ID_HET1, 7, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
-#define PIN_DSC_MOUT1IN     PORT_PIN(PORT_ID_HET1, 9, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
-#define PIN_DSC_MOUT2IN     PORT_PIN(PORT_ID_HET1, 14, PORT_CONF_GPIO_IN_LO_PU_PDIS_ODOFF)
+#define PIN_DSC_MOUT1IN     PORT_PIN(PORT_ID_HET1, 9, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
+#define PIN_DSC_MOUT2IN     PORT_PIN(PORT_ID_HET1, 14, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODOFF)
 #define PIN_DSC_HOUT1IN     PORT_PIN(PORT_ID_HET1, 16, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
 #define PIN_DSC_HOUT1DIAG   PORT_PIN(PORT_ID_HET1, 17, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
 #define PIN_DSC_HOUT2IN     PORT_PIN(PORT_ID_HET1, 18, PORT_CONF_GPIO_OUT_LO_PD_PEN_ODON)
index 02f22cec5dd735549bcf887f466de099c1d8a846..e3c153d394ee8df8577d568f4ea1cf9d7e2240ed 100644 (file)
@@ -26,7 +26,7 @@ int8_t rpp_mout_init();
 /**
  * Set the output of given pin to given value.
  *
- * This function will also verify that the output is set. See return
+ * This function will also verify if a faulty condition is detected. See return
  * documentation below for details.
  *
  * @param[in] pin       The pin number to set [1-6].
@@ -37,10 +37,9 @@ int8_t rpp_mout_init();
  *         -2 if val is not HIGH or LOW.\n
  *         -3 if pin could not be set. With current implementation this should
  *            never happen.\n
- *         -4 if pin is confirmed to be in trouble (write / read mismatch).
- *            This normally indicates that the drive connected to the pin pulled
- *            the pin HIGH or LOW, by mistake or to avoid damage, among other
- *            possible hardware failure situations.
+ *         -4 if pin is confirmed to be in trouble.
+ *            This normally indicates a hardware failure and that the driver
+ *            chip pulled the diagnostic pin.
  */
 int8_t rpp_mout_set(uint8_t pin, uint8_t val);
 
@@ -48,9 +47,8 @@ int8_t rpp_mout_set(uint8_t pin, uint8_t val);
 /**
  * Get the cached value of the given pin set by rpp_mout_set().
  *
- * This will not read the value on the pin, for that use rpp_mout_diag().
- * You can use this function to implement your own routine for value set / value
- * read mismatch.
+ * This will not read the value on the pin. To confirm if the output is
+ * correctly set call rpp_mout_diag() and confirm SUCCESS.
  *
  * @param[in] pin       The pin number to get cached value [1-6].
  *
@@ -61,13 +59,14 @@ int8_t rpp_mout_get(uint8_t pin);
 
 
 /**
- * Reads the value on the given pin for diagnostic.
+ * Reads the value on the given diagnostic pin.
  *
  * Note that rpp_mout_set() calls this routine already before returning.
  *
  * @param[in] pin       The pin number to read [1-6].
  *
- * @return HIGH or LOW value in given pin.
+ * @return SUCCESS is output is operating normally.
+ *         FAILURE if a faulty condition was detected.
  */
 int8_t rpp_mout_diag(uint8_t pin);
 
index 22f53760960e72e94c17b457eb8a1b260df88ab9..5738b8af66b1bfa1b30006e03e46130f637458da 100644 (file)
 #include "drv/mout.h"
 
 const static uint32_t dsc_pin_map[6U][2U] = {
-    {PIN_DSC_MOUT1EN, PIN_DSC_MOUT1IN},
-    {PIN_DSC_MOUT2EN, PIN_DSC_MOUT2IN},
-    {PIN_DSC_MOUT3EN, PIN_DSC_MOUT3IN},
-    {PIN_DSC_MOUT4EN, PIN_DSC_MOUT4IN},
-    {PIN_DSC_MOUT5EN, PIN_DSC_MOUT5IN},
-    {PIN_DSC_MOUT6EN, PIN_DSC_MOUT6IN}
+    {PIN_DSC_MOUT1IN, PIN_DSC_MOUT1EN},
+    {PIN_DSC_MOUT2IN, PIN_DSC_MOUT2EN},
+    {PIN_DSC_MOUT3IN, PIN_DSC_MOUT3EN},
+    {PIN_DSC_MOUT4IN, PIN_DSC_MOUT4EN},
+    {PIN_DSC_MOUT5IN, PIN_DSC_MOUT5EN},
+    {PIN_DSC_MOUT6IN, PIN_DSC_MOUT6EN}
 };
 
 
index 950091477c4606c16853361a2616de3209cdad77..5f79514fd75a3aad3504377263d2a1a5761c8fd7 100644 (file)
@@ -82,7 +82,7 @@ int8_t rpp_mout_set(uint8_t pin, uint8_t val)
     }
 
     // Get value back and compare
-    if(drv_mout_diag(idx) != val) {
+    if(drv_mout_diag(idx) == FAILURE) {
         return -4;
     }
     #else
@@ -112,10 +112,11 @@ int8_t rpp_mout_diag(uint8_t pin)
     }
 
     #if rppCONFIG_DRV == 1
-    return drv_mout_diag(pin - 1);
-    #else
-    return LOW;
+    if(drv_mout_diag(pin - 1) == 0) {
+        return FAILURE;
+    }
     #endif
+    return SUCCESS;
 }
 
 
index fa6a0c91aad8e77e67cd03df8b858a0f1e85c9e4..81baed3271f4347a7831e3e529b4bf281f33d91c 100644 (file)
@@ -26,7 +26,9 @@
 /* ***************************************************** */
 void dmmInit(void)
 {
-    /** - DMM Port default output value */
+    /** - DMM pins default output value
+     *    1 - High, 0 - Low
+     */
     dmmREG->PC3 =  0           /* DMM SYNC     - FAN_CONTROL*/
                 | (0 << 1)     /* DMM CLK      - ETH_RESET */
                 | (0 << 2)     /* DMM DATA[0]  - VBAT_1_EN */
@@ -38,8 +40,8 @@ void dmmInit(void)
                 | (0 << 8)     /* DMM DATA[6]  - SPICSB    */
                 | (0 << 9)     /* DMM DATA[7]  - NOT USED  */
                 | (0 << 10)    /* DMM DATA[8]  - NOT USED  */
-                | (0 << 11)    /* DMM DATA[9]  - MOUT1_EN  */
-                | (0 << 12)    /* DMM DATA[10] - MOUT2_EN  */
+                | (1 << 11)    /* DMM DATA[9]  - MOUT1_EN  */
+                | (1 << 12)    /* DMM DATA[10] - MOUT2_EN  */
                 | (1 << 13)    /* DMM DATA[11] - CAN_NSTB  */
                 | (0 << 14)    /* DMM DATA[12] - NOT USED  */
                 | (0 << 15)    /* DMM DATA[13] - CAN_EN    */
@@ -47,7 +49,9 @@ void dmmInit(void)
                 | (1 << 17)    /* DMM DATA[15] - LIN1_NSLP */
                 | (0 << 18);   /* DMM ENA      - DIN_INT   */
 
-    /** - DMM Port direction 1 - output, 0 - input */
+    /** - DMM pins direction
+     *    1 - Output, 0 - Input
+     */
     dmmREG->PC1 =  1          /* DMM SYNC     - FAN_CONTROL*/
                 | (1 << 1)    /* DMM CLK      - ETH_RESET */
                 | (1 << 2)    /* DMM DATA[0]  - VBAT_1_EN */
@@ -59,8 +63,8 @@ void dmmInit(void)
                 | (1 << 8)    /* DMM DATA[6]  - SPICSB    */
                 | (1 << 9)    /* DMM DATA[7]  - NOT USED  */
                 | (1 << 10)   /* DMM DATA[8]  - NOT USED  */
-                | (1 << 11)   /* DMM DATA[9]  - MOUT1_EN  */
-                | (1 << 12)   /* DMM DATA[10] - MOUT2_EN  */
+                | (0 << 11)   /* DMM DATA[9]  - MOUT1_EN  */
+                | (0 << 12)   /* DMM DATA[10] - MOUT2_EN  */
                 | (1 << 13)   /* DMM DATA[11] - CAN_NSTB  */
                 | (1 << 14)   /* DMM DATA[12] - NOT USED  */
                 | (1 << 15)   /* DMM DATA[13] - CAN_EN    */
@@ -68,7 +72,9 @@ void dmmInit(void)
                 | (1 << 17)   /* DMM DATA[15] - LIN1_NSLP */
                 | (1 << 18);  /* DMM ENA      - DIN_INT   */
 
-    /** - DMM Port open drain enable */
+    /** - DMM pins open drain enable
+     *    1 - Enabled, 0 - Disabled
+     */
     dmmREG->PC6 =  0         /* DMM SYNC     - FAN_CONTROL*/
                 | (0 << 1)   /* DMM CLK      - ETH_RESET */
                 | (0 << 2)   /* DMM DATA[0]  - VBAT_1_EN */
@@ -90,7 +96,9 @@ void dmmInit(void)
                 | (0 << 18); /* DMM ENA      - DIN_INT   */
 
 
-    /** - DMM Port pullup(1) / pulldown(0) selection */
+    /** - DMM pins pull type selection
+     *    1 - Pull-up, 0 - Pull-down
+     */
     dmmREG->PC8 =  0         /* DMM SYNC     - FAN_CONTROL*/
                 | (0 << 1)   /* DMM CLK      - ETH_RESET */
                 | (0 << 2)   /* DMM DATA[0]  - VBAT_1_EN */
@@ -102,8 +110,8 @@ void dmmInit(void)
                 | (0 << 8)   /* DMM DATA[6]  - SPICSB    */
                 | (0 << 9)   /* DMM DATA[7]  - NOT USED  */
                 | (0 << 10)  /* DMM DATA[8]  - NOT USED  */
-                | (0 << 11)  /* DMM DATA[9]  - MOUT1_EN  */
-                | (0 << 12)  /* DMM DATA[10] - MOUT2_EN  */
+                | (1 << 11)  /* DMM DATA[9]  - MOUT1_EN  */
+                | (1 << 12)  /* DMM DATA[10] - MOUT2_EN  */
                 | (0 << 13)  /* DMM DATA[11] - CAN_NSTB  */
                 | (0 << 14)  /* DMM DATA[12] - NOT USED  */
                 | (0 << 15)  /* DMM DATA[13] - CAN_EN    */
@@ -112,7 +120,9 @@ void dmmInit(void)
                 | (0 << 18); /* DMM ENA      - DIN_INT   */
 
 
-    /** - DMM Port pullup / pulldown enable*/
+    /** - DMM pins pull resistor enable
+     *    1 - Enabled, 0 - Disabled
+     */
     dmmREG->PC7 =  1          /* DMM SYNC     - FAN_CONTROL*/
                 | (1 << 1)    /* DMM CLK      - ETH_RESET */
                 | (1 << 2)    /* DMM DATA[0]  - VBAT_1_EN */
@@ -133,7 +143,9 @@ void dmmInit(void)
                 | (1 << 17)   /* DMM DATA[15] - LIN1_NSLP */
                 | (1 << 18);  /* DMM ENA      - DIN_INT   */
 
-    /* 1 = pin is functional / 0 = pin is in GIO  */
+    /** - DMM pins type selection
+     *    1 - Pin is functional, 0 - Pin is GPIO
+     */
     dmmREG->PC0 =  0         /* DMM SYNC     - FAN_CONTROL*/
                 | (0 << 1)   /* DMM CLK      - ETH_RESET */
                 | (0 << 2)   /* DMM DATA[0]  - VBAT_1_EN */
index a179a92108f6482f6b884f99a95152a7172f4818..c25552a02f906548c4761f5531a6c7396e8ad7ca 100644 (file)
@@ -85,55 +85,75 @@ void gioInit(void)
 
     /** @b initalise @b Port @b B */
 
-    /** - Port B output values */
-    gioPORTB->DOUT =  0        /* Bit 0 */
-                   | (0 << 1)  /* Bit 1 */
-                   | (0 << 2)  /* Bit 2 */
-                   | (0 << 3)  /* Bit 3 */
-                   | (0 << 4)  /* Bit 4 */
-                   | (0 << 5)  /* Bit 5 */
-                   | (0 << 6)  /* Bit 6 */
-                   | (0 << 7); /* Bit 7 */
-
-    /** - Port B direction */
-    gioPORTB->DIR  =  1        /* Bit 0 */
-                   | (1 << 1)  /* Bit 1 */
-                   | (1 << 2)  /* Bit 2 */
-                   | (1 << 3)  /* Bit 3 */
-                   | (1 << 4)  /* Bit 4 */
-                   | (1 << 5)  /* Bit 5 */
-                   | (1 << 6)  /* Bit 6 */
-                   | (1 << 7); /* Bit 7 */
-
-    /** - Port B open drain enable */
-    gioPORTB->PDR  =  1        /* Bit 0 */
-                   | (1 << 1)  /* Bit 1 */
-                   | (0 << 2)  /* Bit 2 */
-                   | (0 << 3)  /* Bit 3 */
-                   | (1 << 4)  /* Bit 4 */
-                   | (1 << 5)  /* Bit 5 */
-                   | (0 << 6)  /* Bit 6 */
-                   | (0 << 7); /* Bit 7 */
-
-    /** - Port B pullup / pulldown selection */
-    gioPORTB->PSL  =  0        /* Bit 0 */
-                   | (0 << 1)  /* Bit 1 */
-                   | (0 << 2)  /* Bit 2 */
-                   | (0 << 3)  /* Bit 3 */
-                   | (0 << 4)  /* Bit 4 */
-                   | (0 << 5)  /* Bit 5 */
-                   | (0 << 6)  /* Bit 6 */
-                   | (0 << 7); /* Bit 7 */
-
-    /** - Port B pullup / pulldown enable*/
-    gioPORTB->PULDIS  =  1        /* Bit 0 */
-                      | (1 << 1)  /* Bit 1 */
-                      | (0 << 2)  /* Bit 2 */
-                      | (0 << 3)  /* Bit 3 */
-                      | (1 << 4)  /* Bit 4 */
-                      | (1 << 5)  /* Bit 5 */
-                      | (0 << 6)  /* Bit 6 */
-                      | (0 << 7); /* Bit 7 */
+    /** - Port B default output value
+     *    1 - High, 0 - Low
+     */
+    gioPORTB->DOUT = 0x0
+                 //| _BV(7)  /* MOUT3IN */
+                 //| _BV(6)  /* MOUT4IN */
+                   | _BV(5)  /* MOUT3EN */
+                   | _BV(4)  /* MOUT4EN */
+                 //| _BV(3)  /* MOUT5IN */
+                 //| _BV(2)  /* MOUT6IN */
+                   | _BV(1)  /* MOUT5EN */
+                   | _BV(0)  /* MOUT6EN */
+                   | 0x0;
+
+    /** - Port B direction
+     *    1 - Output, 0 - Input
+     */
+    gioPORTB->DIR  = 0x0
+                   | _BV(7)  /* MOUT3IN */
+                   | _BV(6)  /* MOUT4IN */
+                 //| _BV(5)  /* MOUT3EN */
+                 //| _BV(4)  /* MOUT4EN */
+                   | _BV(3)  /* MOUT5IN */
+                   | _BV(2)  /* MOUT6IN */
+                 //| _BV(1)  /* MOUT5EN */
+                 //| _BV(0)  /* MOUT6EN */
+                   | 0x0;
+
+    /** - Port B open drain enable
+     *    1 - Enabled, 0 - Disabled
+     */
+    gioPORTB->PDR  = 0x0
+                 //| _BV(7)  /* MOUT3IN */
+                 //| _BV(6)  /* MOUT4IN */
+                   | _BV(5)  /* MOUT3EN */
+                   | _BV(4)  /* MOUT4EN */
+                 //| _BV(3)  /* MOUT5IN */
+                 //| _BV(2)  /* MOUT6IN */
+                   | _BV(1)  /* MOUT5EN */
+                   | _BV(0)  /* MOUT6EN */
+                   | 0x0;
+
+    /** - Port B pull type selection
+     *    1 - Pull-up, 0 - Pull-down
+     */
+    gioPORTB->PSL  = 0x0
+                 //| _BV(7)  /* MOUT3IN */
+                 //| _BV(6)  /* MOUT4IN */
+                   | _BV(5)  /* MOUT3EN */
+                   | _BV(4)  /* MOUT4EN */
+                 //| _BV(3)  /* MOUT5IN */
+                 //| _BV(2)  /* MOUT6IN */
+                   | _BV(1)  /* MOUT5EN */
+                   | _BV(0)  /* MOUT6EN */
+                   | 0x0;
+
+    /** - Port B pull resistor enable
+     *    1 - Disabled, 0 - Enabled
+     */
+    gioPORTB->PULDIS  = 0x0
+                 //| _BV(7)  /* MOUT3IN */
+                 //| _BV(6)  /* MOUT4IN */
+                   | _BV(5)  /* MOUT3EN */
+                   | _BV(4)  /* MOUT4EN */
+                 //| _BV(3)  /* MOUT5IN */
+                 //| _BV(2)  /* MOUT6IN */
+                   | _BV(1)  /* MOUT5EN */
+                   | _BV(0)  /* MOUT6EN */
+                   | 0x0;
 
 /* USER CODE BEGIN (3) */
 /* USER CODE END */
index 966198e54911d09452524d2384291b299aceb4cf..bd023214e76a7be539e87f5925990af6e90a1724 100644 (file)
@@ -1038,175 +1038,195 @@ void hetInit(void)
 {
     /** @b intalise @b HET */
 
-    /** - Set HET pins default output value */
-    hetREG1->DOUT = (0U << 31U)
-                 | (0U << 30U)
-                 | (0U << 29U)
-                 | (0U << 28U)
-                 | (0U << 27U)
-                 | (0U << 26U)
-                 | (0U << 25U)
-                 | (0U << 24U)
-                 | (0U << 23U)
-                 | (0U << 22U)
-                 | (0U << 21U)
-                 | (0U << 20U)
-                 | (0U << 19U)
-                 | (0U << 18U)
-                 | (0U << 17U)
-                 | (0U << 16U)
-                 | (0U << 15U)
-                 | (0U << 14U)
-                 | (0U << 13U)
-                 | (0U << 12U)
-                 | (0U << 11U)
-                 | (0U << 10U)
-                 | (0U << 9U)
-                 | (0U << 8U)
-                 | (0U << 7U)
-                 | (0U << 6U)
-                 | (0U << 5U)
-                 | (0U << 4U)
-                 | (0U << 3U)
-                 | (0U << 2U)
-                 | (0U << 1U)
-                 | (0U);
-
-    /** - Set HET pins direction */
-    hetREG1->DIR = 0x00000000U
-                | 0x00000000U
-                | 0x20000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x02000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00400000U
-                | 0x00000000U
-                | 0x00100000U
-                | 0x00000000U
-                | 0x00040000U
-                | 0x00000000U
-                | 0x00010000U
-                | 0x00000000U
-                | 0x00004000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000200U
-                | 0x00000000U
-                | 0x00000080U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000010U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000002U
-                | 0x00000000U;
-
-    /** - Set HET pins open drain enable */
-    hetREG1->PDR = 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U
-                | 0x00000000U;
-
-    /** - Set HET pins pullup/down enable */
-    hetREG1->PULDIS = 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000080U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000010U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U
-                   | 0x00000000U;
-
-    /** - Set HET pins pullup/down select */
-    hetREG1->PSL = 0x80000000U
-                | 0x40000000U
-                | 0x20000000U
-                | 0x10000000U
-                | 0x08000000U
-                | 0x04000000U
-                | 0x02000000U
-                | 0x01000000U
-                | 0x00800000U
-                | 0x00400000U
-                | 0x00200000U
-                | 0x00100000U
-                | 0x00080000U
-                | 0x00040000U
-                | 0x00020000U
-                | 0x00010000U
-                | 0x00008000U
-                | 0x00004000U
-                | 0x00002000U
-                | 0x00001000U
-                | 0x00000800U
-                | 0x00000400U
-                | 0x00000200U
-                | 0x00000100U
-                | 0x00000000U
-                | 0x00000040U
-                | 0x00000020U
-                | 0x00000000U
-                | 0x00000008U
-                | 0x00000004U
-                | 0x00000002U
-                | 0x00000001U;
+    /** - HET pins default output value
+     *    1 - High, 0 - Low
+     */
+    hetREG1->DOUT = 0x0
+                //| _BV(31)
+                //| _BV(30)
+                //| _BV(29)
+                //| _BV(28)
+                //| _BV(27)
+                //| _BV(26)
+                //| _BV(25)
+                //| _BV(24)
+                //| _BV(23)
+                //| _BV(22)
+                //| _BV(21)
+                //| _BV(20)
+                //| _BV(19)
+                //| _BV(18)
+                //| _BV(17)
+                //| _BV(16)
+                //| _BV(15)
+                //| _BV(14) /* MOUT2IN */
+                //| _BV(13)
+                //| _BV(12)
+                //| _BV(11)
+                //| _BV(10)
+                //| _BV( 9) /* MOUT1IN */
+                //| _BV( 8)
+                //| _BV( 7)
+                //| _BV( 6)
+                //| _BV( 5)
+                //| _BV( 4)
+                //| _BV( 3)
+                //| _BV( 2)
+                //| _BV( 1)
+                //| _BV( 0)
+                  | 0x0;
+
+    /** - HET pins direction
+     *    1 - Output, 0 - Input
+     */
+    hetREG1->DIR = 0x0
+                //| _BV(31)
+                  | _BV(30)
+                //| _BV(29)
+                  | _BV(28)
+                //| _BV(27)
+                  | _BV(26)
+                //| _BV(25)
+                  | _BV(24)
+                //| _BV(23)
+                  | _BV(22)
+                //| _BV(21)
+                //| _BV(20)
+                //| _BV(19)
+                //| _BV(18)
+                  | _BV(17)
+                //| _BV(16)
+                //| _BV(15)
+                  | _BV(14) /* MOUT2IN */
+                //| _BV(13)
+                //| _BV(12)
+                //| _BV(11)
+                //| _BV(10)
+                  | _BV( 9) /* MOUT1IN */
+                //| _BV( 8)
+                  | _BV( 7)
+                //| _BV( 6)
+                //| _BV( 5)
+                  | _BV( 4)
+                //| _BV( 3)
+                //| _BV( 2)
+                  | _BV( 1)
+                //| _BV( 0)
+                  | 0x0;
+
+    /** - HET pins open drain enable
+     *    1 - Enabled, 0 - Disabled
+     */
+    hetREG1->PDR = 0x0
+                //| _BV(31)
+                //| _BV(30)
+                //| _BV(29)
+                //| _BV(28)
+                //| _BV(27)
+                //| _BV(26)
+                //| _BV(25)
+                //| _BV(24)
+                //| _BV(23)
+                //| _BV(22)
+                //| _BV(21)
+                //| _BV(20)
+                //| _BV(19)
+                //| _BV(18)
+                //| _BV(17)
+                //| _BV(16)
+                //| _BV(15)
+                //| _BV(14) /* MOUT2IN */
+                //| _BV(13)
+                //| _BV(12)
+                //| _BV(11)
+                //| _BV(10)
+                //| _BV( 9) /* MOUT1IN */
+                //| _BV( 8)
+                //| _BV( 7)
+                //| _BV( 6)
+                //| _BV( 5)
+                //| _BV( 4)
+                //| _BV( 3)
+                //| _BV( 2)
+                //| _BV( 1)
+                //| _BV( 0)
+                  | 0x0;
+
+    /** - HET pins pull resistor enable
+     *    1 - Disabled, 0 - Enabled
+     */
+    hetREG1->PULDIS = 0x0
+                //| _BV(31)
+                //| _BV(30)
+                //| _BV(29)
+                //| _BV(28)
+                //| _BV(27)
+                //| _BV(26)
+                //| _BV(25)
+                //| _BV(24)
+                //| _BV(23)
+                //| _BV(22)
+                //| _BV(21)
+                //| _BV(20)
+                //| _BV(19)
+                //| _BV(18)
+                //| _BV(17)
+                //| _BV(16)
+                //| _BV(15)
+                //| _BV(14) /* MOUT2IN */
+                //| _BV(13)
+                //| _BV(12)
+                //| _BV(11)
+                //| _BV(10)
+                //| _BV( 9) /* MOUT1IN */
+                //| _BV( 8)
+                  | _BV( 7)
+                //| _BV( 6)
+                //| _BV( 5)
+                  | _BV( 4)
+                //| _BV( 3)
+                //| _BV( 2)
+                //| _BV( 1)
+                //| _BV( 0)
+                  | 0x0;
+
+    /** - HET pins pull type selection
+     *    1 - Pull-up, 0 - Pull-down
+     */
+    hetREG1->PSL = 0x0
+                  | _BV(31)
+                  | _BV(30)
+                  | _BV(29)
+                  | _BV(28)
+                  | _BV(27)
+                  | _BV(26)
+                  | _BV(25)
+                  | _BV(24)
+                  | _BV(23)
+                  | _BV(22)
+                  | _BV(21)
+                  | _BV(20)
+                  | _BV(19)
+                  | _BV(18)
+                  | _BV(17)
+                  | _BV(16)
+                  | _BV(15)
+                //| _BV(14) /* MOUT2IN */
+                  | _BV(13)
+                  | _BV(12)
+                  | _BV(11)
+                  | _BV(10)
+                //| _BV( 9) /* MOUT1IN */
+                  | _BV( 8)
+                //| _BV( 7)
+                  | _BV( 6)
+                  | _BV( 5)
+                //| _BV( 4)
+                  | _BV( 3)
+                  | _BV( 2)
+                  | _BV( 1)
+                  | _BV( 0)
+                  | 0x0;
 
     /** - Set HET pins high resolution share */
     hetREG1->HRSH = 0x00000000U