Skip to content

Commit

Permalink
autocross, removed printf
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoOhR committed Oct 12, 2024
1 parent 1759725 commit 2071762
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 17 deletions.
2 changes: 2 additions & 0 deletions Project/DAQ_System/Core/Inc/stm32f4xx_it.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ void EXTI15_10_IRQHandler(void);
void TIM6_DAC_IRQHandler(void);
void TIM7_IRQHandler(void);
void DMA2_Stream0_IRQHandler(void);
void CAN2_RX0_IRQHandler(void);
void CAN2_RX1_IRQHandler(void);
void OTG_FS_IRQHandler(void);
/* USER CODE BEGIN EFP */

Expand Down
10 changes: 9 additions & 1 deletion Project/DAQ_System/Core/Src/can.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void MX_CAN2_Init(void)

/* USER CODE END CAN2_Init 1 */
hcan2.Instance = CAN2;
hcan2.Init.Prescaler = 3;
hcan2.Init.Prescaler = 12;
hcan2.Init.Mode = CAN_MODE_NORMAL;
hcan2.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan2.Init.TimeSeg1 = CAN_BS1_11TQ;
Expand Down Expand Up @@ -168,6 +168,11 @@ void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle)
GPIO_InitStruct.Alternate = GPIO_AF9_CAN2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

/* CAN2 interrupt Init */
HAL_NVIC_SetPriority(CAN2_RX0_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(CAN2_RX0_IRQn);
HAL_NVIC_SetPriority(CAN2_RX1_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(CAN2_RX1_IRQn);
/* USER CODE BEGIN CAN2_MspInit 1 */

/* USER CODE END CAN2_MspInit 1 */
Expand Down Expand Up @@ -219,6 +224,9 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle)
*/
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6);

/* CAN2 interrupt Deinit */
HAL_NVIC_DisableIRQ(CAN2_RX0_IRQn);
HAL_NVIC_DisableIRQ(CAN2_RX1_IRQn);
/* USER CODE BEGIN CAN2_MspDeInit 1 */

/* USER CODE END CAN2_MspDeInit 1 */
Expand Down
29 changes: 29 additions & 0 deletions Project/DAQ_System/Core/Src/stm32f4xx_it.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
extern HCD_HandleTypeDef hhcd_USB_OTG_FS;
extern DMA_HandleTypeDef hdma_adc1;
extern CAN_HandleTypeDef hcan1;
extern CAN_HandleTypeDef hcan2;
extern TIM_HandleTypeDef htim7;
extern TIM_HandleTypeDef htim6;

Expand Down Expand Up @@ -247,6 +248,34 @@ void DMA2_Stream0_IRQHandler(void)
/* USER CODE END DMA2_Stream0_IRQn 1 */
}

/**
* @brief This function handles CAN2 RX0 interrupts.
*/
void CAN2_RX0_IRQHandler(void)
{
/* USER CODE BEGIN CAN2_RX0_IRQn 0 */

/* USER CODE END CAN2_RX0_IRQn 0 */
HAL_CAN_IRQHandler(&hcan2);
/* USER CODE BEGIN CAN2_RX0_IRQn 1 */

/* USER CODE END CAN2_RX0_IRQn 1 */
}

/**
* @brief This function handles CAN2 RX1 interrupt.
*/
void CAN2_RX1_IRQHandler(void)
{
/* USER CODE BEGIN CAN2_RX1_IRQn 0 */

/* USER CODE END CAN2_RX1_IRQn 0 */
HAL_CAN_IRQHandler(&hcan2);
/* USER CODE BEGIN CAN2_RX1_IRQn 1 */

/* USER CODE END CAN2_RX1_IRQn 1 */
}

/**
* @brief This function handles USB On The Go FS global interrupt.
*/
Expand Down
3 changes: 2 additions & 1 deletion Project/DAQ_System/Core/Startup/startup_stm32f429zitx.s
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ defined in linker script */
.section .text.Reset_Handler
.weak Reset_Handler
.type Reset_Handler, %function
Reset_Handler: ldr sp, =_estack /* set stack pointer */

\Reset_Handler: ldr sp, =_estack /* set stack pointer */

/* Copy the data segment initializers from flash to SRAM */
ldr r0, =_sdata
Expand Down
10 changes: 6 additions & 4 deletions Project/DAQ_System/DAQ_System.ioc
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ CAN1.Mode=CAN_MODE_NORMAL
CAN1.Prescaler=12
CAN2.BS1=CAN_BS1_11TQ
CAN2.BS2=CAN_BS2_2TQ
CAN2.CalculateBaudRate=1000000
CAN2.CalculateTimeBit=1000
CAN2.CalculateTimeQuantum=71.42857142857143
CAN2.CalculateBaudRate=250000
CAN2.CalculateTimeBit=4000
CAN2.CalculateTimeQuantum=285.7142857142857
CAN2.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,Prescaler,BS1,BS2
CAN2.Prescaler=3
CAN2.Prescaler=12
Dma.ADC1.0.Direction=DMA_PERIPH_TO_MEMORY
Dma.ADC1.0.FIFOMode=DMA_FIFOMODE_DISABLE
Dma.ADC1.0.Instance=DMA2_Stream0
Expand Down Expand Up @@ -136,6 +136,8 @@ MxDb.Version=DB.6.0.120
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false\:false
NVIC.CAN1_RX0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.CAN1_RX1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.CAN2_RX0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.CAN2_RX1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.DMA2_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false\:false
NVIC.EXTI15_10_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true\:true
Expand Down
12 changes: 1 addition & 11 deletions Project/DAQ_System/Program/Src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ void DataLoggingThread(void *argument) {
application::DataLogger data_logger(file_system, toggle_switch, queue, usb_connected_observer, is_logging_flag);

for (;;) {
printf("running datalogger \n");
//data_logger.Run();
data_logger.Run();
osDelay(100);
}
}
Expand Down Expand Up @@ -278,7 +277,6 @@ void EcuThread(void *argument) {
}

bx_can_peripheral_data->Start();
//printf("CAN Data Peripheral started \n");

// Configure and enable CAN message arrival interrupts
bx_can_callback_ptr = bx_can_peripheral_data;
Expand All @@ -294,8 +292,6 @@ void EcuThread(void *argument) {
uint32_t can_id = pe3_ecu.LatestCanId();

data_payload.Lock();
//printf(" ecu locked ");


switch(can_id) {
case FramePe1Id:
Expand All @@ -307,23 +303,19 @@ void EcuThread(void *argument) {
break;

case FramePe2Id:
printf("[ECU] PE2 arrived\n");
data_payload.barometer_ = pe3_ecu.BarometerPressure();
data_payload.map_ = pe3_ecu.Map();
data_payload.lambda_ = pe3_ecu.Lambda();
break;

case FramePe3Id:
printf("[ECU] PE3 arrived\n");
//printf(" %f ", pe3_ecu.AnalogInputVoltage(3));
data_payload.analog_inputs_.at(0) = pe3_ecu.AnalogInputVoltage(0);
data_payload.analog_inputs_.at(1) = pe3_ecu.AnalogInputVoltage(1);
data_payload.analog_inputs_.at(2) = pe3_ecu.AnalogInputVoltage(2);
data_payload.analog_inputs_.at(3) = pe3_ecu.AnalogInputVoltage(3);
break;

case FramePe4Id:
printf("[ECU] PE4 arrived\n");
data_payload.analog_inputs_.at(4) = pe3_ecu.AnalogInputVoltage(4);
data_payload.analog_inputs_.at(5) = pe3_ecu.AnalogInputVoltage(5);
data_payload.analog_inputs_.at(6) = pe3_ecu.AnalogInputVoltage(6);
Expand All @@ -332,14 +324,12 @@ void EcuThread(void *argument) {


case FramePe6Id:
printf("[ECU] PE6 arrived\n");
data_payload.battery_voltage_ = pe3_ecu.BatteryVoltage();
data_payload.air_temp_ = pe3_ecu.AirTemperature();
data_payload.coolant_temp_ = pe3_ecu.CoolantTemperature();
break;

default:
//printf("[ECU] Un-handled CAN ID:%" PRIu32 "\n", can_id);
printf("");
}

Expand Down

0 comments on commit 2071762

Please sign in to comment.