diff --git a/packages/ti/drv/i2c/test/eeprom_read/src/main_test.c b/packages/ti/drv/i2c/test/eeprom_read/src/main_test.c
index e5a7f0d622886a3933564a617b83f1c16fa0d01a..c4c272aa8ca3f1aa2f91547ae7692bd03946219c 100755 (executable)
* \brief Example application main file. This application will read the data
* from eeprom and compares it with the known data.
*
+ * On J7200 - The EEPROM is connected to the i2c which is in wakeup
+ * domain. The I2C driver, by default supports all
+ * all instances in MCU and Main Domain only.
+ *
+ * This test demonstrates steps required to add support for
+ * an instance that's not natively supported by the driver.
+ *
*/
/*
- * Copyright (C) 2014 - 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Copyright (C) 2014 - 2020 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#include <ti/drv/sciclient/sciclient.h>
#endif
-#ifdef SOC_J721E
+#if defined (SOC_J721E) || defined(SOC_J7200) || defined(SOC_AM65XX) || defined(SOC_AM64X)
#include <ti/csl/soc.h>
#if defined (BUILD_DSP_1) || defined (BUILD_DSP_2)
#include <ti/csl/csl_chipAux.h>
#include <ti/drv/sciclient/sciclient.h>
#endif
+#if defined (BUILD_C7X_1)
#include <ti/csl/csl_clec.h>
+#endif
#include <ti/csl/arch/r5/csl_arm_r5.h>
#include <ti/csl/arch/csl_arch.h>
#endif
+#if defined(UNITY_INCLUDE_CONFIG_H) && (defined(SOC_J721E) || defined(SOC_J7200) || defined(SOC_AM65XX) || defined(SOC_AM64X))
+#include <ti/build/unit-test/Unity/src/unity.h>
+#include <ti/build/unit-test/config/unity_config.h>
+#endif
+
void I2c_appC7xPreInit(void);
/* Define the I2C test interface */
#define I2C_TRANSACTION_TIMEOUT (10000U)
+#if defined (SOC_J721E)
+/* By default for, first available output from IR */
+#define I2C_INST_WKUP_I2C0_INT_NUM_MAIN (CSLR_R5FSS0_CORE0_INTR_R5FSS0_INTROUTER0_OUTL_0)
+#endif
+#if defined (SOC_J7200)
+/* Applicable for MCU 20/21 only */
+#define I2C_INST_WKUP_I2C0_INT_NUM_MAIN (CSLR_R5FSS0_CORE0_INTR_WKUP_I2C0_POINTRPEND_0)
+#endif /* J7200 Specific */
/**********************************************************************
************************** Internal functions ************************
**********************************************************************/
@@ -136,7 +158,7 @@ char eepromData[I2C_EEPROM_TEST_LENGTH] = {0x55, 0x33, 0xEE, 0x41, 0x4d, 0x35, 0
#elif defined (evmK2H) || defined (evmK2K) || defined (evmK2E) || defined (evmK2L) || defined (evmK2G) || defined (iceK2G) || defined (EVM_OMAPL137)
char eepromData[I2C_EEPROM_TEST_LENGTH] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09, 0x10};
-#elif defined (evmC6678) || defined (evmC6657) || defined (am65xx_evm) || defined (am65xx_idk) || defined (j721e_sim) || defined (j721e_evm)
+#elif defined (evmC6678) || defined (evmC6657) || defined (am65xx_evm) || defined (am65xx_idk) || defined (j721e_sim) || defined (j721e_evm) || defined(j7200_evm) || defined (am64x_evm)
char eepromData[I2C_EEPROM_TEST_LENGTH] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00};
#else
#endif
#endif
-#if defined (SOC_J721E)
+#if defined (SOC_J721E) || defined(SOC_J7200)
/* No I2C instanced connected to eeprom in main domain, use i2c instance in wakeup domain */
i2c_cfg.baseAddr = CSL_WKUP_I2C0_CFG_BASE;
#if defined (BUILD_MPU)
* Pulsar R5 core is on the Main domain, use the Main Pulsar
* interrupt router
*/
- i2c_cfg.intNum = 256U; /* value 256 - 511 reserved for IR output */
+ if(info.cpuID == 0U)
+ {
+ i2c_cfg.intNum = I2C_INST_WKUP_I2C0_INT_NUM_MAIN;
+ }
+ else
+ {
+ i2c_cfg.intNum = I2C_INST_WKUP_I2C0_INT_NUM_MAIN + 128U;
+ }
}
else
{
}
#endif
+
+ I2C_log("\n I2C Test: Using Instance %d", I2C_EEPROM_INSTANCE);
return (true);
}
goto Err;
}
-#if defined (evmK2H) || defined (evmK2K) || defined (evmK2E) || defined (evmK2L) || defined (evmK2G) || defined (iceK2G) || defined (am65xx_evm) || defined (am65xx_idk) || defined (j721e_sim) || defined (j721e_evm)
+#if defined (evmK2H) || defined (evmK2K) || defined (evmK2E) || defined (evmK2L) || defined (evmK2G) || defined (iceK2G) || defined (am65xx_evm) || defined (am65xx_idk) || defined (j721e_sim) || defined (j721e_evm) || defined (j7200_evm) || defined (am64x_evm)
BOARD_delay(I2C_EEPROM_TEST_DELAY);
#endif
#else
-#if defined (evmK2H) || defined (evmK2K) || defined (evmK2E) || defined (evmK2L) || defined (evmK2G) || defined (iceK2G) || defined (EVM_OMAPL137) || defined (am65xx_evm) || defined (am65xx_idk) || defined (j721e_sim) || defined (j721e_evm)
+#if defined (evmK2H) || defined (evmK2K) || defined (evmK2E) || defined (evmK2L) || defined (evmK2G) || defined (iceK2G) || defined (EVM_OMAPL137) || defined (am65xx_evm) || defined (am65xx_idk) || defined (j721e_sim) || defined (j721e_evm) || defined(j7200) || defined (am64x_evm)
/* EEPROM write disabled on K2, need copy data */
copyData = TRUE;
#endif
}
else
{
-#if defined (evmC6678) || defined (evmC6657) || defined (am65xx_evm) || defined (am65xx_idk) || defined (j721e_sim) || defined (j721e_evm)
+#if defined (evmC6678) || defined (evmC6657) || defined (am65xx_evm) || defined (am65xx_idk) || defined (j721e_sim) || defined (j721e_evm) || defined (j7200_evm) || defined (am64x_evm)
copyData = TRUE;
#endif
}
-#if defined (SOC_AM335X) || defined (SOC_AM437x) || defined (SOC_AM571x) || defined (SOC_AM572x) || defined (SOC_AM574x) || defined (SOC_AM65XX) || defined (SOC_J721E)
+#if defined (SOC_AM335X) || defined (SOC_AM437x) || defined (SOC_AM571x) || defined (SOC_AM572x) || defined (SOC_AM574x) || defined (SOC_AM65XX) || defined (SOC_J721E) || defined (SOC_J7200) || defined (SOC_AM64X)
static bool I2C_Probe_BusFrequency_test(void *arg)
{
I2C_Handle handle;
{
/* testFunc testID dma intr cbMode timeout testDesc */
{I2C_bitrate_test, I2C_TEST_ID_BIT_RATE, false, true, false, SemaphoreP_WAIT_FOREVER, "\r\n I2C bit rate test in interrupt mode"},
-#if defined (SOC_AM335X) || defined (SOC_AM437x) || defined (SOC_AM571x) || defined (SOC_AM572x) || defined (SOC_AM574x) || defined (SOC_AM65XX) || defined (SOC_J721E)
+#if defined (SOC_AM335X) || defined (SOC_AM437x) || defined (SOC_AM571x) || defined (SOC_AM572x) || defined (SOC_AM574x) || defined (SOC_AM65XX) || defined (SOC_J721E) || defined (SOC_J7200) || defined (SOC_AM64X)
{I2C_Probe_BusFrequency_test, I2C_TEST_ID_PROBE_BUS_FREQ, false, true, false, SemaphoreP_WAIT_FOREVER, "\r\n I2C probe bus freq test in interrupt mode"},
{I2C_timeout_test, I2C_TEST_ID_TIMEOUT_INT, false, true, false, 1, "\r\n I2C timeout test in interrupt mode"},
- {I2C_timeout_test, I2C_TEST_ID_TIMEOUT_POLLING, false, false, false, 1, "\r\n I2C timeout test in polling mode"},
#endif
{NULL, },
};
+#if defined(UNITY_INCLUDE_CONFIG_H) && (defined(SOC_J721E) || defined(SOC_J7200) || defined (SOC_AM65XX) || defined (SOC_AM64X))
+/*
+ * ======== Unity set up and tear down ========
+ */
+void setUp(void)
+{
+ /* Do nothing */
+}
+
+void tearDown(void)
+{
+ /* Do nothing */
+}
+
+bool test_I2C_Eeprom_common(void)
+{
+ bool testResult = true;
+ uint32_t i;
+ I2C_Tests *test;
+
+ if (Board_initI2C() == false)
+ {
+ I2C_log("\r\n %s Board_initI2C failed\r\n");
+#ifdef UNITY_INCLUDE_CONFIG_H
+ TEST_FAIL();
+#endif
+ while(1);
+ }
+
+ for (i = 0; ; i++)
+ {
+ test = &I2c_tests[i];
+ if (test->testFunc == NULL)
+ {
+ break;
+ }
+ I2C_test_print_test_desc(test);
+ if (test->testFunc((void *)test) == true)
+ {
+ I2C_log("\r\n %s have passed\r\n", test->testDesc);
+ }
+ else
+ {
+ I2C_log("\r\n %s have failed\r\n", test->testDesc);
+ testResult = false;
+ break;
+ }
+ }
+ return testResult;
+}
+
+void test_I2C_Eeprom_TestApp(void)
+{
+ bool testResult = true;
+ testResult = test_I2C_Eeprom_common();
+
+ if(testResult == true)
+ {
+ I2C_log("\n All tests have passed. \n");
+#ifdef UNITY_INCLUDE_CONFIG_H
+ TEST_PASS();
+#endif
+ }
+ else
+ {
+ I2C_log("\n Some tests have failed. \n");
+#ifdef UNITY_INCLUDE_CONFIG_H
+ TEST_FAIL();
+#endif
+ }
+
+ while (true)
+ {
+ }
+}
+
+void test_I2C_Eeprom_BareMetal_TestApp(void)
+{
+ bool testResult = true;
+ testResult = test_I2C_Eeprom_common();
+
+ if(testResult == true)
+ {
+ I2C_log("\n All tests have passed. \n");
+#ifdef UNITY_INCLUDE_CONFIG_H
+ TEST_PASS();
+#endif
+ }
+ else
+ {
+ I2C_log("\n Some tests have failed. \n");
+#ifdef UNITY_INCLUDE_CONFIG_H
+ TEST_FAIL();
+#endif
+ }
+
+ while (true)
+ {
+ }
+}
+
+void test_I2C_Eeprom_TestApp_runner(void)
+{
+ /* @description: Test runner for I2C_Eeprom Test App
+ and I2C_Eeprom BareMetal Test App
+
+ @requirements:PRSDK-6918, PRSDK-6919, PRSDK-6922,
+ PRSDK-6924, PRSDK-6930
+
+ @cores: mpu1_0, mcu1_0 */
+
+ UNITY_BEGIN();
+#ifdef USE_BIOS
+ RUN_TEST(test_I2C_Eeprom_TestApp);
+#else
+ RUN_TEST(test_I2C_Eeprom_BareMetal_TestApp);
+#endif
+ UNITY_END();
+ /* Function to print results defined in our unity_config.h file */
+ print_unityOutputBuffer_usingUARTstdio();
+}
+#endif
+
#ifdef USE_BIOS
/*
* ======== test function ========
int main ()
#endif
{
+#if defined(UNITY_INCLUDE_CONFIG_H) && (defined(SOC_J721E) || defined(SOC_J7200) || defined (SOC_AM65XX) || defined (SOC_AM64X))
+ test_I2C_Eeprom_TestApp_runner();
+#else
bool testResult = true;
uint32_t i;
I2C_Tests *test;
-#ifndef USE_BIOS
if (Board_initI2C() == false)
{
+#ifdef USE_BIOS
+ return;
+#else
return(0);
+#endif
}
-#endif
for (i = 0; ; i++)
{
break;
}
}
-
if(testResult == true)
{
I2C_log("\n All tests have passed. \n");
{
I2C_log("\n Some tests have failed. \n");
}
-
while (true)
{
}
+#endif
}
#ifdef USE_BIOS
{
I2c_appC7xPreInit();
- if (Board_initI2C() == false)
- {
- return (0);
- }
-
#if defined (SOC_AM335X) || defined (SOC_AM437x) || defined (SOC_OMAPL137)
Task_Handle task;
Error_Block eb;
}
#endif
-#if defined (SOC_J721E)
+#if defined (SOC_J721E) || defined(SOC_J7200) || defined (SOC_AM65XX) || defined (SOC_AM64X)
Task_Handle task;
Error_Block eb;
Task_Params taskParams;