diff --git a/.cproject b/.cproject
index d56f418..7c7f38c 100644
--- a/.cproject
+++ b/.cproject
@@ -362,7 +362,6 @@
-
@@ -372,8 +371,8 @@
-
-
diff --git a/Core/Source/ivec_mcal_uart.c b/Core/Source/ivec_mcal_uart.c
index f7e388f..6453b9d 100644
--- a/Core/Source/ivec_mcal_uart.c
+++ b/Core/Source/ivec_mcal_uart.c
@@ -305,11 +305,22 @@ exit:
/////////////////////////////////////////////////////////////////////////////////////
static xCoreStatus_t uart_init(McalUartHandle_s* pxUartHandle, McalUartBaudRate_e xBaud)
{
-// DL_GPIO_initPeripheralOutputFunction(IOMUX_PINCM32, IOMUX_PINCM32_PF_UART2_TX);
-// DL_GPIO_initPeripheralInputFunction(IOMUX_PINCM33, IOMUX_PINCM33_PF_UART2_RX);
- DL_GPIO_initPeripheralOutputFunction(IOMUX_PINCM19, IOMUX_PINCM19_PF_UART1_TX);
- DL_GPIO_initPeripheralInputFunction(IOMUX_PINCM20, IOMUX_PINCM20_PF_UART1_RX);
+ #if UART_PIN_SELECTION == 1
+ DL_GPIO_initPeripheralOutputFunction(IOMUX_PINCM32, IOMUX_PINCM32_PF_UART2_TX);
+ DL_GPIO_initPeripheralInputFunction(IOMUX_PINCM33, IOMUX_PINCM33_PF_UART2_RX);
+
+ #elif UART_PIN_SELECTION == 2
+ DL_GPIO_initPeripheralOutputFunction(IOMUX_PINCM19, IOMUX_PINCM19_PF_UART1_TX);
+ DL_GPIO_initPeripheralInputFunction(IOMUX_PINCM20, IOMUX_PINCM20_PF_UART1_RX);
+
+ #elif UART_PIN_SELECTION == 3
+ DL_GPIO_initPeripheralOutputFunction(IOMUX_PINCM19, IOMUX_PINCM19_PF_UART1_TX);
+ DL_GPIO_initPeripheralInputFunction(IOMUX_PINCM20, IOMUX_PINCM20_PF_UART1_RX);
+ DL_GPIO_initPeripheralOutputFunction(IOMUX_PINCM32, IOMUX_PINCM32_PF_UART2_TX);
+ DL_GPIO_initPeripheralInputFunction(IOMUX_PINCM33, IOMUX_PINCM33_PF_UART2_RX);
+
+ #endif
// Get the UART instance based on the port number in the handle
UART_Regs* uart_inst = GetUartInstance(pxUartHandle->eUartPortNumber);
@@ -380,60 +391,62 @@ static xCoreStatus_t uart_init(McalUartHandle_s* pxUartHandle, McalUartBaudRate_
* Target baud rate: 115200
* Actual baud rate: 115211.52
*/
- DL_UART_Main_setBaudRateDivisor(uart_inst, 13, 1);
+// DL_UART_Main_setBaudRateDivisor(uart_inst, 13, 1);
+ //DL_UART_Main_setBaudRateDivisor(uart_inst, 19, 20);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 19, 34);
}
else if(xBaud==9600)
{
- DL_UART_Main_setBaudRateDivisor(uart_inst, 156, 16);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 234, 24);
}
else if(xBaud==2400)
{
- DL_UART_Main_setBaudRateDivisor(uart_inst, 625, 0);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 937, 32);
}
else if(xBaud==4800)
{
- DL_UART_Main_setBaudRateDivisor(uart_inst, 312, 32);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 468, 48);
}
else if(xBaud==14400)
{
- DL_UART_Main_setBaudRateDivisor(uart_inst, 104, 11);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 156, 16);
}
else if(xBaud==19200)
{
- DL_UART_Main_setBaudRateDivisor(uart_inst, 78, 8);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 117, 12);
}
else if(xBaud==28800)
{
- DL_UART_Main_setBaudRateDivisor(uart_inst, 52, 5);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 78, 8);
}
else if(xBaud==33600)
{
- DL_UART_Main_setBaudRateDivisor(uart_inst, 44, 41);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 66, 62);
}
else if(xBaud==38400)
{
- DL_UART_Main_setBaudRateDivisor(uart_inst, 39, 4);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 58, 38);
}
else if(xBaud==57600)
{
- DL_UART_Main_setBaudRateDivisor(uart_inst, 26, 3);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 39, 4);
}
else if(xBaud==230400)
{
- DL_UART_Main_setBaudRateDivisor(uart_inst, 6, 33);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 9, 49);
}
else if(xBaud==460800)
{
- DL_UART_Main_setBaudRateDivisor(uart_inst, 3, 16);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 4, 57);
}
else if(xBaud==921600)
{
- DL_UART_Main_setBaudRateDivisor(uart_inst, 1, 40);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 2, 28);
}
else if(xBaud==1000000)
{
- DL_UART_Main_setBaudRateDivisor(uart_inst, 1, 32);
+ DL_UART_Main_setBaudRateDivisor(uart_inst, 2, 16);
}
else{
/*
diff --git a/Generated Codes/ti_msp_dl_config.c b/Generated Codes/ti_msp_dl_config.c
index 5144700..6b69834 100644
--- a/Generated Codes/ti_msp_dl_config.c
+++ b/Generated Codes/ti_msp_dl_config.c
@@ -37,8 +37,14 @@
* DO NOT EDIT - This file is generated for the MSPM0G350X
* by the SysConfig tool.
*/
+///* Port definition for Pin Group GPIO_tick */
+//#define GPIO_tick_PORT (GPIOA)
+//
+///* Defines for PIN_0: GPIOA.2 with pinCMx 7 on package pin 8 */
+//#define tick_PIN_0_PIN (0x00004000)
#include "ti_msp_dl_config.h"
+#include "../../utils/utils.h"
DL_TimerA_backupConfig gCAPTURE_0Backup;
DL_TimerA_backupConfig gTIMER_1Backup;
@@ -101,15 +107,33 @@ SYSCONFIG_WEAK void SYSCFG_DL_initPower(void)
DL_TimerA_reset(CAPTURE_0_INST);
DL_TimerG_reset(TIMER_0_INST);
DL_TimerA_reset(TIMER_1_INST);
- DL_UART_Main_reset(UART_0_INST);
+
DL_MCAN_reset(MCAN0_INST);
+ #if UART_PIN_SELECTION == 1
+ DL_UART_Main_reset(UART2);
+ DL_UART_Main_enablePower(UART2);
+
+ #elif UART_PIN_SELECTION == 2
+ DL_UART_Main_reset(UART1);
+ DL_UART_Main_enablePower(UART1);
+
+ #elif UART_PIN_SELECTION == 3
+ // UART1 pins
+ DL_UART_Main_reset(UART1);
+ DL_UART_Main_enablePower(UART1);
+ DL_UART_Main_reset(UART2);
+ DL_UART_Main_enablePower(UART2);
+
+
+ #endif
+
DL_GPIO_enablePower(GPIOA);
DL_GPIO_enablePower(GPIOB);
DL_TimerA_enablePower(CAPTURE_0_INST);
DL_TimerG_enablePower(TIMER_0_INST);
DL_TimerA_enablePower(TIMER_1_INST);
- DL_UART_Main_enablePower(UART_0_INST);
+
DL_MCAN_enablePower(MCAN0_INST);
delay_cycles(POWER_STARTUP_DELAY);
}
@@ -137,6 +161,11 @@ SYSCONFIG_WEAK void SYSCFG_DL_GPIO_init(void)
DL_GPIO_initPeripheralInputFunction(
GPIO_MCAN0_IOMUX_CAN_RX, GPIO_MCAN0_IOMUX_CAN_RX_FUNC);
+// DL_GPIO_initDigitalOutput(IOMUX_PINCM31);
+//
+// DL_GPIO_clearPins(GPIOB, tick_PIN_0_PIN);
+// DL_GPIO_enableOutput(GPIOB, tick_PIN_0_PIN);
+
}
diff --git a/ivec_ECU/ivec_ecu_uart/src/ivec_ecu_uart.c b/ivec_ECU/ivec_ecu_uart/src/ivec_ecu_uart.c
index c68c6f0..7ac100d 100644
--- a/ivec_ECU/ivec_ecu_uart/src/ivec_ecu_uart.c
+++ b/ivec_ECU/ivec_ecu_uart/src/ivec_ecu_uart.c
@@ -13,6 +13,8 @@ CmplxFifoQueueHandle_s __gprv_MyEcuUARTResponseQueue = { 0 };
static uint8_t __gprv_u8CANUartDataBuffer[CAN_UART_BUFFER_MAX_SIZE];
static uint32_t __gprv_u32CanUartDataAvailable = 0;
+int uartCount = 1;
+
// Get the UART instance based on the enum
@@ -72,15 +74,25 @@ IVEC_EcuCommonErr_e xECU_UARTInit(McalUartHandle_s* prvUartHandle, uint32_t spee
}
IVEC_ECU_LOG(LOG_STRING, "Initilising UART");
- prvUartHandle->eUartPortNumber = mcalUART_PORT2;
+ #if (UART_PIN_SELECTION == 1 || ((uartCount == 1) && (UART_PIN_SELECTION == 3)))
+ prvUartHandle->eUartPortNumber = mcalUART_PORT3;
+ uartCount = 2;
+
+ #elif (UART_PIN_SELECTION == 2 || ((uartCount == 2) && (UART_PIN_SELECTION == 3)))
+ prvUartHandle->eUartPortNumber = mcalUART_PORT2;
+ uartCount = 1;
+
+ #endif
+
prvUartHandle->pvUartRecvCallback = __prv_vEcu_CANOverUartMsgCallback;
prvUartHandle->xUartConfig.eUartBaudrate = speed;
prvUartHandle->xUartConfig.eUartFlowCtrl = mcalUART_FC_NONE;
prvUartHandle->xUartConfig.eUartDataBit = mcalUART_DATABIT_8;
prvUartHandle->xUartConfig.eUartStopBit = mcalUART_STOP_1;
prvUartHandle->xUartConfig.eUartParityBit = mcalUART_PARITY_NONE;
-
l_i32Ret = xMCAL_UartInit(prvUartHandle);
+
+
if (l_i32Ret != 0)
{
l_xFuncStatus = commonECU_INIT_FAIL;
diff --git a/ivec_RTE/src/ivec_rte.c b/ivec_RTE/src/ivec_rte.c
index 4b7068a..ac786dc 100644
--- a/ivec_RTE/src/ivec_rte.c
+++ b/ivec_RTE/src/ivec_rte.c
@@ -15,6 +15,7 @@
McalUartHandle_s g_xUartHandle;
+McalUartHandle_s g_xUart2Handle;
uint32_t g_u32UartSpeed = 0;
xCAN_baud_t g_u16CanSpeed = 0;
uint8_t g_pu8Buf[MAX_PACKET_LENGTH] = {0};
@@ -31,6 +32,7 @@ uint32_t filterCount = 0;
uint16_t extendedFilter = 0;
uint16_t standardFilter = 0;
+
static uint8_t __gprv_u8Idx = 0;
static uint8_t __gprv_u8Buf = 0;
@@ -230,6 +232,11 @@ void vRTE_InitUARTCANEcho(void)
g_u32UartSpeed = mcalUART_BAUD_115200;
g_u16CanSpeed = BAUD_500;
xECU_UARTInit(&g_xUartHandle, g_u32UartSpeed);
+
+ #if UART_PIN_SELECTION == 3
+ xECU_UARTInit(&g_xUart2Handle, g_u32UartSpeed);
+ #endif
+
xECU_CANInit(CANFD0,g_u16CanSpeed);
}
@@ -237,15 +244,6 @@ void vCanFilterMaskSaveVal(uint8_t ucIdx, uint32_t mask, bool isExtended)
{
maskCount = ucIdx;
maskValues[maskCount] = mask;
-// isExtendedID[maskCount++] = isExtended;
-// if(isExtended)
-// {
-// extendedFilter++;
-// }
-// else
-// {
-// standardFilter++;
-// }
}
@@ -254,16 +252,6 @@ void vCanFilterSaveVal(uint8_t ucIdx, uint32_t Filter, bool isExtended)
filterCount = ucIdx;
// Store filter value
filterValues[filterCount] = Filter;
-// isExtendedID[filterCount] = isExtended;
-// if(isExtended)
-// {
-// extendedFilter++;
-// }
-// else
-// {
-// standardFilter++;
-// }
-
}
diff --git a/main.c b/main.c
index d28f58f..6f3a8c0 100644
--- a/main.c
+++ b/main.c
@@ -19,7 +19,10 @@
void vMCAL_TimerCallback(void)
{
- //vRTE_MatlabRun();
+ #if UART_PIN_SELECTION == 1
+ vRTE_MatlabRun();
+ #endif
+
DL_TimerA_clearInterruptStatus(TIMER_1_INST, GPTIMER_CPU_INT_IMASK_Z_SET);
}
@@ -41,7 +44,10 @@ int main(void)
xMCAL_SYSTICK_INIT(Period_1ms);
__prv_TimerConfig();
- //vRTE_MatlabInit();
+ #if UART_PIN_SELECTION == 1
+ vRTE_MatlabInit();
+ #endif
+
vRTE_InitUARTCANEcho();
while(1)
{
diff --git a/targetConfigs/MSPM0G3507.ccxml b/targetConfigs/MSPM0G3507.ccxml
index e78eaa0..9e48a29 100644
--- a/targetConfigs/MSPM0G3507.ccxml
+++ b/targetConfigs/MSPM0G3507.ccxml
@@ -1,43 +1,23 @@
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/utils/utils.c b/utils/utils.c
index 6cec2d9..1893583 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -6,9 +6,13 @@
#include
#include "../Generated Codes/ti_msp_config.h"
+
+
volatile uint32_t systic_Count;
volatile uint32_t systic_init_flag =0;
static volatile uint32_t g_u32VrefInitFalg = 0;
+//#define tick_PIN_0_PIN (0x00004000)
+//uint8_t tickmeasurement = 1;
static const DL_VREF_Config gVREFConfig = {
.vrefEnable = DL_VREF_ENABLE_DISABLE,
@@ -90,11 +94,11 @@ static const DL_SYSCTL_SYSPLLConfig gSYSPLLConfig = {
.rDivClk1 = 0,
.rDivClk0 = 0,
.enableCLK2x = DL_SYSCTL_SYSPLL_CLK2X_DISABLE,
- .enableCLK1 = DL_SYSCTL_SYSPLL_CLK1_ENABLE,
+ .enableCLK1 = DL_SYSCTL_SYSPLL_CLK1_DISABLE,
.enableCLK0 = DL_SYSCTL_SYSPLL_CLK0_ENABLE,
.sysPLLMCLK = DL_SYSCTL_SYSPLL_MCLK_CLK0,
.sysPLLRef = DL_SYSCTL_SYSPLL_REF_HFCLK,
- .qDiv = 3,
+ .qDiv = 5,
.pDiv = DL_SYSCTL_SYSPLL_PDIV_1
};
@@ -213,6 +217,17 @@ xCoreStatus_t xMCAL_SYSCTL_INIT(uint8_t u8CLK_SRC,uint8_t u8LP_MODE)
void SysTick_Handler(void)
{
i32TickCnt++;
+// if(tickmeasurement)
+// {
+// DL_GPIO_clearPins(GPIOB, tick_PIN_0_PIN);
+// tickmeasurement = 0;
+// }
+// else
+// {
+// DL_GPIO_setPins(GPIOB, tick_PIN_0_PIN);
+// tickmeasurement = 1;
+// }
+
}
@@ -235,8 +250,7 @@ void vMCAL_DelayTicks(int i32Delay_ms)
void xMCAL_McuInit()
{
SYSCFG_DL_initPower();
- DL_UART_Main_reset(UART1);
- DL_UART_Main_enablePower(UART1);
+
SYSCFG_DL_GPIO_init();
}
diff --git a/utils/utils.h b/utils/utils.h
index d5a818d..3b77902 100644
--- a/utils/utils.h
+++ b/utils/utils.h
@@ -34,6 +34,13 @@ typedef enum
#define SYSOSC 4
#define SLEEP0 6
+// UART_PIN_SELECTION values:
+// 1 - Basil Battery Smart
+// 2 - Basil
+// 3 - Battery Swapping Station
+#define UART_PIN_SELECTION 2 // Set the desired UART configuration here
+
+
volatile int i32TickCnt;
@@ -75,7 +82,7 @@ typedef enum
typedef enum
{
/*SysTick Period Options*/
- Period_1ms = 48000, /*!< sets period of SysTick to 1ms @48Mhz*/
+ Period_1ms = 72000, /*!< sets period of SysTick to 1ms @48Mhz*/
}xTicks_t;
typedef enum