/* @Created by VECMOCON Technology * @Date - 26 feb 2024 * TODO - To enable the not define function please go through the project properties --> under the arm complier --> predefine symbols * @ add (_N) at the end of definition to not define * @ Remove (_N) from the end of definition to define * @ Content added by AS - MCAL function for ADC, ADC with DMA, Periodic Timer, PWM, SysTick and Input Capture */ #include "../utils/utils.h" #include "../Core/Include/gpio.h" #include "../Core/Include/ivec_mcal_adc_dma.h" #include "../Core/Include/ivec_mcal_timer.h" #include "../Core/Include/ivec_mcal_mcan.h" #include "../Core/Include/ivec_mcal_spi.h" #include "../Core/Include/ivec_mcal_i2c.h" #include "../Core/Include/ivec_mcal_uart.h" #include "NOR_FLASH/nor_flash.h" #include "ti_msp_dl_config.h" #include "string.h" #include "ivec_cmplx_queue.h" #include "../ivec_ECU/ivec_ecu_uart/inc/ivec_ecu_uart.h" #include "../ivec_ECU/ivec_ecu_can/inc/ivec_ecu_can.h" #define DMA_CHANNEL 1 #define ADC_CHANNEL 2 #define SAMPLE_TIME 500 #ifdef ADC_DMA_CONFIG /*!< ADC with DMA _PA15 */ #endif //#ifdef ADC_CONFIG /*! -1) { if(ulId == 0x00) { vECU_InitiateUartToCanTransmit(&prvUartHandle, ulId, pucBuf, 0); } else{ xECU_WriteDataOverCAN(pucBuf, ulId, retCode, 0); } } } void CANDataProcess() { IVEC_EcuCommonErr_e retCode = commonECU_FAIL; can_buff_t xBuff = { 0x00 }; retCode = xECU_CANGetData(&xBuff); if(retCode == commonECU_SUCCESS) { vECU_InitiateUartToCanTransmit(&prvUartHandle, (uint32_t)xBuff.id, (uint8_t*)&xBuff.data[0], (uint8_t)xBuff.length); } //delay(3200000); } int main(void) { xMCAL_McuInit(); printf("hii\n"); xMCAL_SYSCTL_INIT(SYSOSC,STANDBY0); xMCAL_SYSTICK_INIT(Period_1ms); // Initialize the timer with the desired timeout value xMCAL_TimerInit(TIMG0); // Initialize your timer instance (e.g., TIMG0) xECU_UARTInit(&prvUartHandle); xECU_CANInit(CANFD0,BAUD_500); while(1) { UARTDataProcess(); CANDataProcess(); } // // //u8SPI_TxDum[]; // xMCAL_McuInit(); // xMCAL_SYSCTL_INIT(SYSOSC,STANDBY0); // xMCAL_SYSTICK_INIT(Period_1ms); // //// //SYSCFG_DL_init(); //// //// ////// xMCAL_SPI_init(SPI0,CS_1Mhz); ////// // SYSCFG_DL_MCAN0_init(); // xMCAL_MCANInit(CANFD0,BAUD_500); //////// xMCAL_I2C_init(I2C0, BAUD_100Khz); // xStatus1=xMCAL_uart_init(UART1,BAUD_115200); //////// DL_UART_Main_reset(UART0); //////// DL_UART_Main_enablePower(UART0); ////// // DL_MCAN_TxBufElement txMsg; // Added by Akshat // // txMsg.id = ((uint32_t)(0x9)) << 18U;//Added by Akshat // /* Transmit data frame. */ // txMsg.rtr = 0U; // /* 11-bit standard identifier. */ // txMsg.xtd = 0U; // /* ESI bit in CAN FD format depends only on error passive flag. */ // txMsg.esi = 0U; // /* Transmitting 4 bytes. */ // txMsg.dlc = 1U; // /* CAN FD frames transmitted with bit rate switching. */ // txMsg.brs = 0U; // /* Frame transmitted in CAN FD format. */ // txMsg.fdf = 0U; // /* Store Tx events. */ // txMsg.efc = 1U; // /* Message Marker. */ // txMsg.mm = 0xAAU; //// //#ifdef ADC_DMA_CONFIG // xMCAL_DmaInit(); // flag = xMCAL_AdcInit(ADC1); /*!< Configure ADC with DMA */ // // xMCAL_AdcStart(ADC1); //#endif // //#ifdef TIMER_CONFIG // xMCAL_TimerInit(TIMG0); // xMCAL_TimerstartCounter(); //#endif // // // //#ifdef TIMER_PWM_CONFIG // xMCAL_PwmInit(TIMG0); // xMCAL_PwmStart(); //#endif // // // // //#ifdef TIMER_INPUTCAPTURE_CONFIG // xMCAL_InputCaptureInit(TIMA0); // xMCAL_InputCaptureStart(); //#endif // // // //ret_UID=flash_getUID(u8SPI_TxDum); // //ret_MID=flash_getMID(u8SPI_MID,u8SPI_DID); //// xStatus1 = xMCU_i2cDevReadyMcal(I2C0,0x08); //// while(1) //// { //// //vMCAL_DelayTicks(500); //// //// //// //// if(STATUS_SUCCESS==xStatus1) //// { //// //vMCAL_DelayTicks(500); //// xMCU_i2cWriteMcal(I2C0 ,0x08 ,u8TxPacket, 1); //// //vMCAL_DelayTicks( 500); //// //// xMCU_i2cReadMcal(I2C0, 0x08, 4); //// xMcal_I2C_getData(I2C0,u8RxData,4); //// } //// } //// ret_UID=flash_getUID(u8SPI_TxDum); // //DL_GPIO_setPins(GPIOA,DL_GPIO_PIN_13); // //xMCAL_uart_transmit(UART1,u8txdata,u32data_size); //// while(1) //// { ////// //xStatus1=xMCAL_SPI_TxData(SPI0, u8SPI_TxDum, u8SPI_RxDum,21); ////// //ret_UID=flash_getUID(u8SPI_RxDum); //////// xMCU_i2cWriteMcal(I2C0 ,0x08 ,u8TxPacket, 1); //////// xMCU_i2cReadMcal(I2C0, 0x08, 4); //////// xMcal_I2C_getData(I2C0,u8RxData,4); ////// // vMCAL_DelayTicks(100); ////// //ret_MID=flash_getMID(u8SPI_MID,u8SPI_DID); ////// //DL_UART_Main_disableInterrupt(UART3,DL_UART_MAIN_INTERRUPT_RX); //// xMCAL_uart_transmit(UART1,u8txdata,u32data_size); ////// //DL_UART_Main_enableInterrupt(UART3,DL_UART_MAIN_INTERRUPT_RX); //// delay(10000000); ////// //// //xMCAL_uart_getdata(UART1,u8rxdata,u32rxbuffer_size); ////// //vMCAL_DelayTicks(1000); //// } // //} // //} // /*u8cfg_upd[2]=crc8fromTable(crc1,3); //LDO 5V Enable begins // u8REG12_CFG[2]=crc8fromTable(crc2,3); // u8REG12_CFG[4]=crc8fromTable(&r12crc[0],1); // u8REG12_CFG[6]=crc8fromTable(&r12crc[1],1); // u8cfg_exit[2]=crc8fromTable(crc3,3); // // xMCU_i2cWriteMcal(I2C0 ,0x08 ,u8cfg_upd, 5);//write set_CFG_UPD // // vMCAL_DelayTicks(2);//wait for CFG_UPD mode // // xMCU_i2cWriteMcal(I2C0,0x08,u8REG12_CFG,7);//write REG12_CFG // // vMCAL_DelayTicks(2); // // c_sum[1]=Checksum(u8REG12_CFG_CS, 3);//crc8fromTable(crc4,2); // crc4[2]=c_sum[1]; // c_sum[2]=crc8fromTable(crc4,3); // c_sum[4]=crc8fromTable(&c_sum[3],1); // // vMCAL_DelayTicks(1); // // xMCU_i2cWriteMcal(I2C0,0x08,c_sum,5); // // vMCAL_DelayTicks(1); // // xMCU_i2cWriteMcal(I2C0,0x08,u8cfg_exit,5);//write CFG_exit // // vMCAL_DelayTicks(1);//wait for CFG_exit*/ //LDO 5V Enable Ends //// // // while(1) // { //// xMCAL_getMCAN_ErrorStatus(ErrorStatus); //// xMCAL_getMCAN_InterruptLine1Status(&Interrupt_Status); // xMCAL_MCANTx(CANFD0, &txMsg ,&idx, 0, 1); // vMCAL_DelayTicks(500); // xMCAL_uart_transmit(UART1,u8txdata,u32data_size); // delay(1000000); // xMCAL_MCANRx(CANFD0,&RxMsg ,0, &RxData,1); //// // vMCAL_DelayTicks(500); //// //// ret_UID=flash_getUID(u8SPI_TxDum); //// ret_MID=flash_getMID(u8SPI_MID,u8SPI_DID); //// //// vMCAL_DelayTicks(500); //// //// xMCU_i2cWriteMcal(I2C0 ,0x08 ,u8TxPacket, 1); //// xMCU_i2cReadMcal(I2C0, 0x08, 4); //// xMcal_I2C_getData(I2C0,u8RxData,4); //// //// vMCAL_DelayTicks(500); //// vMCAL_DelayTicks(400); //// //// if(RxData[0]!=0) //// break; //// __asm("nop"); //// //// ////#ifdef TIMER_CONFIG //// xMCAL_TimergetCount(&timerCount); ////#endif //// ////#ifdef ADC_DMA_CONFIG //// xMCAL_DmaStart(DMA_CHANNEL,&gAdcResult); //// InputVoltage = (gAdcResult) * (3.3/4096); ////#endif // //} } //void vPacketRun(void) //{ // PacketRetCode_t retCode = PACKET_FAIL; // uint8_t pucBuf[MAX_PACKET_LENGTH] = {0}; // uint32_t ulId = 0xffffffff; // retCode = xGetPkt(&xHandle, pucBuf, &ulId); //}