From 894e8bafb5d5d0faf62c4f596644d3471752ac64 Mon Sep 17 00:00:00 2001
From: Karan Saxena <karan@ti.com>
Date: Thu, 4 Jun 2020 14:42:43 +0530
Subject: [PATCH] Remove enabling CAN transceivers on CP board

- Patch enables MCAN 11 in Tx only mode
- I2C conflicts with linux and hence remove that
- Currently CAN transceivers on GESI board can be use

Signed-off-by: Karan Saxena <karan@ti.com>
---
 .../output/generated/soc/j721e/mcu2_1/include/Can_Cfg.h      | 2 +-
 mcuss_demos/profiling/can/can_profile.c                      | 2 +-
 mcuss_demos/profiling/can/can_profile.h                      | 2 +-
 mcuss_demos/profiling/can/main_tirtos.c                      | 2 +-
 mcuss_demos/profiling/can/soc/j721e/mcu2_1/CanApp_Startup.c  | 5 +++++
 mcuss_demos/profiling/can/soc/j721e/mcu2_1/CanApp_Startup.h  | 2 ++
 6 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/mcuss_demos/mcal_config/Can_Demo_Cfg/output/generated/soc/j721e/mcu2_1/include/Can_Cfg.h b/mcuss_demos/mcal_config/Can_Demo_Cfg/output/generated/soc/j721e/mcu2_1/include/Can_Cfg.h
index c928241..88e4d75 100644
--- a/mcuss_demos/mcal_config/Can_Demo_Cfg/output/generated/soc/j721e/mcu2_1/include/Can_Cfg.h
+++ b/mcuss_demos/mcal_config/Can_Demo_Cfg/output/generated/soc/j721e/mcu2_1/include/Can_Cfg.h
@@ -113,7 +113,7 @@ extern "C" {
 /*!< Enable/Disable DEV error detection */
 #define CAN_DEINIT_API                      (STD_ON)
 /*!< Enable/Disable Can_DeInit() API */
-#define CAN_LOOPBACK_ENABLE                 (STD_ON)
+#define CAN_LOOPBACK_ENABLE                 (STD_OFF)
 /*!< Enable/Disable Can_TestLoopBackModeEnable() */
 #define CAN_REGISTER_READBACK_API           (STD_ON)
 /*!< Enable/Disable Can_ConfigRegReadBack() */
diff --git a/mcuss_demos/profiling/can/can_profile.c b/mcuss_demos/profiling/can/can_profile.c
index a2fd666..07afafb 100644
--- a/mcuss_demos/profiling/can/can_profile.c
+++ b/mcuss_demos/profiling/can/can_profile.c
@@ -242,7 +242,7 @@ sint32 CanApp_ProfileTest(canAppTaskObj_t *testParams)
     canMaxControllerCnt = Can_ConfigPtr->CanMaxControllerCount;
     for (ctlr_cnt = 0U; ctlr_cnt < canMaxControllerCnt; ctlr_cnt++)
 #else
-    ctlr_cnt = 0U;
+    ctlr_cnt = 3U;
 #endif
     {
         CanApp_ProfileStatus = E_OK;
diff --git a/mcuss_demos/profiling/can/can_profile.h b/mcuss_demos/profiling/can/can_profile.h
index bcd5fd7..ec4f0c2 100644
--- a/mcuss_demos/profiling/can/can_profile.h
+++ b/mcuss_demos/profiling/can/can_profile.h
@@ -110,7 +110,7 @@ extern "C"
 #define APP_NUM_ITERATION                   (5U)
 /**< Number of iteration, total can messages sent would be
     APP_NUM_MSG_PER_ITERATION * APP_NUM_ITERATION */
-#define APP_INSTANCE_1_INST_IN_CFG_ONLY     (STD_OFF)
+#define APP_INSTANCE_1_INST_IN_CFG_ONLY     (STD_ON)
 /**< Enables application to use 1st instance configured, useful when profiling
         has to be done for 1 instance only
         STD_OFF Configures to use all instances specified in the configuration
diff --git a/mcuss_demos/profiling/can/main_tirtos.c b/mcuss_demos/profiling/can/main_tirtos.c
index 69a86f5..58fce27 100644
--- a/mcuss_demos/profiling/can/main_tirtos.c
+++ b/mcuss_demos/profiling/can/main_tirtos.c
@@ -184,7 +184,7 @@ int32_t local_moduleClockEnable(uint32_t moduleId)
     return retVal;
 }
 
-volatile uint32_t qwerty = 0xDEADBEEF;
+volatile uint32_t qwerty = 0x0;
 
 int main(void)
 {
diff --git a/mcuss_demos/profiling/can/soc/j721e/mcu2_1/CanApp_Startup.c b/mcuss_demos/profiling/can/soc/j721e/mcu2_1/CanApp_Startup.c
index 382f06b..68a1eb8 100644
--- a/mcuss_demos/profiling/can/soc/j721e/mcu2_1/CanApp_Startup.c
+++ b/mcuss_demos/profiling/can/soc/j721e/mcu2_1/CanApp_Startup.c
@@ -261,11 +261,13 @@ void CanApp_EnableTransceivers(void)
     uint32 regVal = 0U;
     Dio_LevelType dioPinLevel[2U];
 
+#if (STD_ON == CAN_USE_I2C)
     /* Configure SOC_PADCONFIG_143 set it to '1' to take
        MCAN transceiver out of STB mode */
     I2C_Params      i2cParams;
     I2C_Handle      handle = NULL;
     uint8           dataToSlave[4];
+#endif
 
     /* Pin mux for CAN STB used in GESI board */
     regVal = 0x20007U;
@@ -358,6 +360,8 @@ void CanApp_EnableTransceivers(void)
         AppUtils_Printf(MSG_NORMAL, MSG_APP_NAME
         " Successfully Enabled CAN Transceiver MCU MCAN1!!!\n");
     }
+
+#if (STD_ON == CAN_USE_I2C)
     /*
      * Configuring TCA6424 IO Exp 2 with addr 0x22
      * This io expander is controlled by i2c0
@@ -397,6 +401,7 @@ void CanApp_EnableTransceivers(void)
     dataToSlave[1] |= 0xC0;
     dataToSlave[2] &= ~(0x18);
     SetupI2CTransfer(handle, 0x22, &dataToSlave[0], 1, &dataToSlave[1], 3);
+#endif
 
     return;
 }
diff --git a/mcuss_demos/profiling/can/soc/j721e/mcu2_1/CanApp_Startup.h b/mcuss_demos/profiling/can/soc/j721e/mcu2_1/CanApp_Startup.h
index 46f8653..2e31cc3 100644
--- a/mcuss_demos/profiling/can/soc/j721e/mcu2_1/CanApp_Startup.h
+++ b/mcuss_demos/profiling/can/soc/j721e/mcu2_1/CanApp_Startup.h
@@ -126,6 +126,8 @@
 #define APP_MCAN_9_INT0         (CSLR_R5FSS0_CORE1_INTR_MCAN9_MCANSS_MCAN_LVL_INT_0)
 #define APP_MCAN_11_INT0        (CSLR_R5FSS0_CORE1_INTR_MCAN11_MCANSS_MCAN_LVL_INT_0)
 
+#define CAN_USE_I2C             STD_OFF 
+
 /* Can App Isr to be registered */
 void CanApp_CanXIsr(uintptr_t CanPtr);
 typedef void (*CanApp_IsrType)(void);
-- 
2.26.2

