Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Feature/175 can transmission #206

Merged
merged 50 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3994c20
added transmit :3
NicoOhR Apr 25, 2024
5f395c0
updating to submodules
NicoOhR May 3, 2024
4837825
update merge
NicoOhR May 15, 2024
815864e
changing submodule
NicoOhR May 16, 2024
32cae9c
update paths
NicoOhR May 16, 2024
7f76dc1
matched cproject with develop, updated libs
NicoOhR May 16, 2024
7a84d23
update libs
NicoOhR May 17, 2024
491bcae
Merge branch 'develop' into feature/175_CAN-transmission
NicoOhR May 17, 2024
c5ff122
changed app to match new data logger
NicoOhR May 17, 2024
e06930e
submodule update
NicoOhR May 22, 2024
7b35ec6
added relay to app
NicoOhR May 22, 2024
e35aa1a
update submodules
NicoOhR May 22, 2024
0a6d371
pulling remote
NicoOhR Jun 6, 2024
cdfc331
see submodule ;P
NicoOhR Jun 6, 2024
302d088
submodule things
NicoOhR Jun 6, 2024
2529154
added step to workflow
NicoOhR Jun 7, 2024
b2d0aa6
test submodule in CI build
NicoOhR Jun 7, 2024
a9e97e9
changed submodule branch
NicoOhR Jun 7, 2024
58ceeae
changed submodule branch now without qoutes
NicoOhR Jun 7, 2024
3f0a192
changed action from push to PR
NicoOhR Jun 7, 2024
9400715
changing priority
NicoOhR Jun 7, 2024
5221052
nart excplicitly disabled, debugging in app, relay thread
NicoOhR Jun 15, 2024
2311dfa
message transmits fine in main, confirming it's a circuit problem
NicoOhR Jun 15, 2024
b26807a
minor restructuring in app, transmission works
NicoOhR Jul 2, 2024
9702b4f
transmits and fails as expected
NicoOhR Jul 2, 2024
e54bc5e
updated transmission code
NicoOhR Jul 3, 2024
b46295f
changed thread prio, minor cleanup
NicoOhR Jul 3, 2024
5ec7aea
minor changes to app and lib update
NicoOhR Jul 6, 2024
1346d60
changed nomenclature and added write only can bus
NicoOhR Jul 7, 2024
edb185a
can2 baud rate set correctly
NicoOhR Jul 9, 2024
b1c7f12
testing transmission with linpot hooked up
NicoOhR Jul 12, 2024
98b7241
restoring code to deployable version
NicoOhR Jul 12, 2024
1869b04
missed some testing changes, TODO: move relay to own queue
NicoOhR Jul 31, 2024
c82518d
added relay queue, decoupling from datalogger
NicoOhR Jul 31, 2024
4e08548
signaling end of transmission
NicoOhR Aug 1, 2024
d68da6b
1Mhz CAN buad rate
NicoOhR Aug 5, 2024
8bcde0f
interrupts added back in, not sure why they were deleted
NicoOhR Aug 18, 2024
edabc65
rx pin pull up
NicoOhR Aug 21, 2024
962dc51
sneaking by 10hz sample rate
NicoOhR Aug 21, 2024
d7d0019
switched back to 0.5hz
NicoOhR Aug 26, 2024
ff317d3
debugging changes
NicoOhR Sep 6, 2024
8a2cf9a
linpot + ECU 10hz
NicoOhR Sep 17, 2024
2334bfe
arb ids
NicoOhR Sep 20, 2024
ed5bcdb
breaking changes to IOC b/c stuck pin on devboard
NicoOhR Sep 23, 2024
a35db8f
rx pullup enabled, 100hz
NicoOhR Sep 27, 2024
1759725
working setup for autocross
NicoOhR Oct 11, 2024
2071762
autocross, removed printf
NicoOhR Oct 12, 2024
87b3545
autocross, removed printf
NicoOhR Oct 12, 2024
5281e9e
fixed typo
NicoOhR Oct 12, 2024
a93ae5a
Merge branch 'develop' into feature/175_CAN-transmission
NicoOhR Oct 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci_build.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI Build

# Define the trigger event(s)
on: push
on: pull_request

# Jobs run in parallel by default, each runs steps in sequence
jobs:
Expand All @@ -15,6 +15,9 @@ jobs:
with:
submodules: 'true'

- name : List files in this repo
run : ls -R

- name : Update the submodules
run: |
git submodule update --init --recursive
Expand All @@ -25,4 +28,4 @@ jobs:
with:
project-path: 'Project/DAQ_System'
project-target: 'DAQ_System/Debug'


2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "Project/DAQ_System/Program/DFR_Libraries"]
path = Project/DAQ_System/Program/DFR_Libraries
url = https://github.com/DallasFormulaRacing/DAQ-Firmware-Libraries.git
url = https://github.com/DallasFormulaRacing/DAQ-Firmware-Libraries.git
2 changes: 2 additions & 0 deletions .settings/com.st.stm32cube.ide.mcu.sfrview.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
sfrviewstate={"fFavorites"\:{"fLists"\:{}},"fProperties"\:{"fNodeProperties"\:{}}}
2 changes: 2 additions & 0 deletions Project/.settings/com.st.stm32cube.ide.mcu.sfrview.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
sfrviewstate={"fFavorites"\:{"fLists"\:{}},"fProperties"\:{"fNodeProperties"\:{}}}
32 changes: 3 additions & 29 deletions Project/DAQ_System/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -109,39 +109,13 @@
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.782968077" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/>
</toolChain>
</folderInfo>
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.879501129.634388624" name="/" resourcePath="Program/DFR_Libraries/Docs">
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.992419115" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug" unusedChildren="">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.541163000.864475970" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.541163000"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.219345738.1114000658" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.219345738"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.1391531893.432361009" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.1391531893"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.746269954.451726076" name="Floating-point unit" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.746269954"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.250882376.191507950" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.250882376"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.2030735942.7322469" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.2030735942"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.94125778.339007824" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.94125778"/>
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1963479036.318729088" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1963479036"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat.1591555373.584468954" name="Use float with printf from newlib-nano (-u _printf_float)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat.1591555373"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.217603449" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.96760002"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1680300913" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1473665233"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.330008397" name="MCU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.1575380401"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.142098822" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.1415815366"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.1809564165" name="MCU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.670361290"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.1975256477" name="MCU GCC Archiver" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.1060254670"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.803131498" name="MCU Size" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.468158338"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.434726503" name="MCU Output Converter list file" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.1459090181"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.413955231" name="MCU Output Converter Hex" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.1823277085"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.802002225" name="MCU Output Converter Binary" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.260991602"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.1862328522" name="MCU Output Converter Verilog" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.435127464"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.16968820" name="MCU Output Converter Motorola S-rec" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.259276545"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.1774672960" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.782968077"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="Src/syscalls.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="FATFS"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
<entry excluding="DFR_Libraries/Docs|DFR_Libraries/Tests" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Program"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="USB_HOST"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="FATFS"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
</sourceEntries>
</configuration>
</storageModule>
Expand Down
98 changes: 49 additions & 49 deletions Project/DAQ_System/.mxproject

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Project/DAQ_System/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1331966944000499888" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1034606765660890457" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1331966944000499888" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1034606765660890457" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
3 changes: 3 additions & 0 deletions Project/DAQ_System/Core/Inc/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ extern "C" {

extern CAN_HandleTypeDef hcan1;

extern CAN_HandleTypeDef hcan2;

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

void MX_CAN1_Init(void);
void MX_CAN2_Init(void);

/* USER CODE BEGIN Prototypes */

Expand Down
2 changes: 0 additions & 2 deletions Project/DAQ_System/Core/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ void Error_Handler(void);
#define STLK_RX_GPIO_Port GPIOD
#define STLK_TX_Pin GPIO_PIN_9
#define STLK_TX_GPIO_Port GPIOD
#define USB_PowerSwitchOn_Pin GPIO_PIN_6
#define USB_PowerSwitchOn_GPIO_Port GPIOG
Comment on lines -87 to -88
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the USB data logger still working properly?

It has happened to me once or twice that a pin is removed or no longer initialized after messing with CubeMX a bit. I may have accidentally toggled something that I did not mean to, but I did have to set the CubeMX settings again. In my case, the GPIO pin for the timestamp timer interrupt was not working properly

Copy link
Member Author

@NicoOhR NicoOhR Aug 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check on that next time im in the shop, I'm pretty sure it is. The same thing as what happened in Project/DAQ_System/Core/Inc/stm32f4xx_it.h might've happened here

#define USB_OverCurrent_Pin GPIO_PIN_7
#define USB_OverCurrent_GPIO_Port GPIOG
#define USB_SOF_Pin GPIO_PIN_8
Expand Down
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
125 changes: 119 additions & 6 deletions Project/DAQ_System/Core/Src/can.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
/* USER CODE END 0 */

CAN_HandleTypeDef hcan1;
CAN_HandleTypeDef hcan2;

/* CAN1 init function */
void MX_CAN1_Init(void)
Expand All @@ -38,11 +39,11 @@ void MX_CAN1_Init(void)

/* USER CODE END CAN1_Init 1 */
hcan1.Instance = CAN1;
hcan1.Init.Prescaler = 24;
hcan1.Init.Prescaler = 12;
hcan1.Init.Mode = CAN_MODE_NORMAL;
hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan1.Init.TimeSeg1 = CAN_BS1_3TQ;
hcan1.Init.TimeSeg2 = CAN_BS2_3TQ;
hcan1.Init.TimeSeg1 = CAN_BS1_11TQ;
hcan1.Init.TimeSeg2 = CAN_BS2_2TQ;
Comment on lines -41 to +46
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to document how you selected these parameters on the CubeMX settings

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

hcan1.Init.TimeTriggeredMode = DISABLE;
hcan1.Init.AutoBusOff = DISABLE;
hcan1.Init.AutoWakeUp = DISABLE;
Expand All @@ -57,8 +58,42 @@ void MX_CAN1_Init(void)

/* USER CODE END CAN1_Init 2 */

}
/* CAN2 init function */
void MX_CAN2_Init(void)
{

/* USER CODE BEGIN CAN2_Init 0 */

/* USER CODE END CAN2_Init 0 */

/* USER CODE BEGIN CAN2_Init 1 */

/* USER CODE END CAN2_Init 1 */
hcan2.Instance = CAN2;
hcan2.Init.Prescaler = 12;
hcan2.Init.Mode = CAN_MODE_NORMAL;
hcan2.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan2.Init.TimeSeg1 = CAN_BS1_11TQ;
hcan2.Init.TimeSeg2 = CAN_BS2_2TQ;
hcan2.Init.TimeTriggeredMode = DISABLE;
hcan2.Init.AutoBusOff = DISABLE;
hcan2.Init.AutoWakeUp = DISABLE;
hcan2.Init.AutoRetransmission = DISABLE;
hcan2.Init.ReceiveFifoLocked = DISABLE;
hcan2.Init.TransmitFifoPriority = DISABLE;
if (HAL_CAN_Init(&hcan2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN CAN2_Init 2 */

/* USER CODE END CAN2_Init 2 */

}

static uint32_t HAL_RCC_CAN1_CLK_ENABLED=0;

void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle)
{

Expand All @@ -69,14 +104,24 @@ void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle)

/* USER CODE END CAN1_MspInit 0 */
/* CAN1 clock enable */
__HAL_RCC_CAN1_CLK_ENABLE();
HAL_RCC_CAN1_CLK_ENABLED++;
if(HAL_RCC_CAN1_CLK_ENABLED==1){
__HAL_RCC_CAN1_CLK_ENABLE();
}

__HAL_RCC_GPIOD_CLK_ENABLE();
/**CAN1 GPIO Configuration
PD0 ------> CAN1_RX
PD1 ------> CAN1_TX
*/
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1;
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
Expand All @@ -92,6 +137,46 @@ void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle)

/* USER CODE END CAN1_MspInit 1 */
}
else if(canHandle->Instance==CAN2)
{
/* USER CODE BEGIN CAN2_MspInit 0 */

/* USER CODE END CAN2_MspInit 0 */
/* CAN2 clock enable */
__HAL_RCC_CAN2_CLK_ENABLE();
HAL_RCC_CAN1_CLK_ENABLED++;
if(HAL_RCC_CAN1_CLK_ENABLED==1){
__HAL_RCC_CAN1_CLK_ENABLE();
}

__HAL_RCC_GPIOB_CLK_ENABLE();
/**CAN2 GPIO Configuration
PB5 ------> CAN2_RX
PB6 ------> CAN2_TX
*/
GPIO_InitStruct.Pin = GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_CAN2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
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 */
}
}

void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle)
Expand All @@ -103,7 +188,10 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle)

/* USER CODE END CAN1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_CAN1_CLK_DISABLE();
HAL_RCC_CAN1_CLK_ENABLED--;
if(HAL_RCC_CAN1_CLK_ENABLED==0){
__HAL_RCC_CAN1_CLK_DISABLE();
}

/**CAN1 GPIO Configuration
PD0 ------> CAN1_RX
Expand All @@ -118,6 +206,31 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle)

/* USER CODE END CAN1_MspDeInit 1 */
}
else if(canHandle->Instance==CAN2)
{
/* USER CODE BEGIN CAN2_MspDeInit 0 */

/* USER CODE END CAN2_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_CAN2_CLK_DISABLE();
HAL_RCC_CAN1_CLK_ENABLED--;
if(HAL_RCC_CAN1_CLK_ENABLED==0){
__HAL_RCC_CAN1_CLK_DISABLE();
}

/**CAN2 GPIO Configuration
PB5 ------> CAN2_RX
PB6 ------> CAN2_TX
*/
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 */
}
}

/* USER CODE BEGIN 1 */
Expand Down
10 changes: 5 additions & 5 deletions Project/DAQ_System/Core/Src/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void MX_GPIO_Init(void)
HAL_GPIO_WritePin(GPIOB, LD1_Pin|LD3_Pin|LD2_Pin, GPIO_PIN_RESET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(USB_PowerSwitchOn_GPIO_Port, USB_PowerSwitchOn_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_6, GPIO_PIN_RESET);

/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = USER_Btn_Pin;
Expand All @@ -75,15 +75,15 @@ void MX_GPIO_Init(void)
/*Configure GPIO pin : PF15 */
GPIO_InitStruct.Pin = GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);

/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = USB_PowerSwitchOn_Pin;
/*Configure GPIO pin : PG6 */
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(USB_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = USB_OverCurrent_Pin;
Expand Down
8 changes: 4 additions & 4 deletions Project/DAQ_System/Core/Src/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)

__HAL_RCC_GPIOB_CLK_ENABLE();
/**I2C1 GPIO Configuration
PB6 ------> I2C1_SCL
PB8 ------> I2C1_SCL
PB9 ------> I2C1_SDA
*/
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_9;
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
Expand All @@ -112,10 +112,10 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* i2cHandle)
__HAL_RCC_I2C1_CLK_DISABLE();

/**I2C1 GPIO Configuration
PB6 ------> I2C1_SCL
PB8 ------> I2C1_SCL
PB9 ------> I2C1_SDA
*/
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8);

HAL_GPIO_DeInit(GPIOB, GPIO_PIN_9);

Expand Down
1 change: 1 addition & 0 deletions Project/DAQ_System/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ int main(void)
MX_I2C1_Init();
MX_FATFS_Init();
MX_TIM7_Init();
MX_CAN2_Init();
/* USER CODE BEGIN 2 */


Expand Down
1 change: 1 addition & 0 deletions Project/DAQ_System/Core/Src/stm32f4xx_hal_msp.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/* USER CODE BEGIN Header */
/**
******************************************************************************
Expand Down
2 changes: 0 additions & 2 deletions Project/DAQ_System/Core/Src/stm32f4xx_hal_timebase_tim.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)

/* Enable TIM6 clock */
__HAL_RCC_TIM6_CLK_ENABLE();

/* Get clock configuration */
HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);

/* Get APB1 prescaler */
uwAPB1Prescaler = clkconfig.APB1CLKDivider;
/* Compute TIM6 clock */
Expand Down
Loading
Loading