/* * Copyright (C) 2018-2022 Texas Instruments Incorporated * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include "ti_drivers_config.h" #include "ti_board_config.h" #include #include #include #include "ti_drivers_open_close.h" #include #include #include #include #define I2C_TIMEOUT (5000U) #define I2C_INTERRUPT_PRIORITY (4U) I2CLLD_Handle I2C3,I2C1; uint8_t tx_byte = 0x0A,rx_byte=0x00,count=1; I2C_ExtendedParams I2C3_RX_Params,I2C3_TX_Params,I2C1_RX_Params,I2C1_TX_Params; I2CLLD_Handle gI2cLldHandle3; uint32_t gI2cVimStsAddr, intrNum, gI2cVimStsClrMask, intcBaseAddr; HwiP_Params hwiPrms; HwiP_Object gGpioHwiObject; HwiP_Config gHwiConfig3 = { .intcBaseAddr = 0x50F00000u, }; void gpio_led_blink_main(void *args); static void i2c_isr(void *args,const I2CLLD_Transaction * targetTxn,int32_t transferStatus); static __attribute__((__section__(".text.hwi"), noinline, naked, target("arm"), aligned(4))) void App_I2C_ISR(void); void print_dat(void) { DebugP_log("Tx_Byte = 0x%02X, Rx_Byte = 0x%02X,\n\r",tx_byte,rx_byte); // DebugP_log("BRD Send = {"); // for(int i=0; iintrNum; intcBaseAddr = gHwiConfig3.intcBaseAddr; gI2cVimStsAddr = intcBaseAddr + (0x404u + (((intrNum)>> 5) & 0xFu) * 0x20u); gI2cVimStsClrMask = 0x1u << ((intrNum) & 0x1Fu); gI2cLldHandle3->targetTransferCompleteCallback = i2c_isr; HwiP_setVecAddr(intrNum, (uintptr_t)&App_I2C_ISR); HwiP_setPri(intrNum, I2C_INTERRUPT_PRIORITY); HwiP_enableInt(intrNum); } int main(void) { System_init(); Board_init(); Drivers_open(); I2C3 = (I2CLLD_Handle)(gI2cLldHandle[CONFIG_I2C3]); I2C1 = (I2CLLD_Handle)(gI2cLldHandle[CONFIG_I2C1]); I2C1->i2cMsg.controllerMode = true; I2C1_TX_Params.deviceAddress = 0x53; I2C1_TX_Params.buffer = &tx_byte; I2C1_TX_Params.size = 1U; I2C1_TX_Params.expandSA = false; I2C3->i2cMsg.targetAddress = 0x40; I2C3_RX_Params.buffer = &rx_byte; I2C3_RX_Params.size = 1U; I2C3_RX_Params.expandSA = false; GPIO_pinWriteHigh(CSL_GPIO0_U_BASE, GPIO_LED_PIN); printRegisterRange(); print_dat(); init_i2c_int(); while(1) { printRegisterRange(); I2C_lld_write(I2C1, &I2C1_TX_Params, 100); I2C_lld_target_read(I2C3, &I2C3_RX_Params, 100); ClockP_sleep(1); DebugP_log("GPIO LED Blinking...%d\r\n",count); print_dat(); // tx_byte++; if(tx_byte > 0xF0) { tx_byte = 0x0A; } } Board_deinit(); System_deinit(); return 0; }