Skip to content

Commit

Permalink
Support STM32F405/407
Browse files Browse the repository at this point in the history
  • Loading branch information
nopnop2002 committed Mar 1, 2020
1 parent 004b74e commit 3c6db2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions canard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
I forked from [here](https://github.com/geosmall/UAVCAN-for-STM32-Arduino).

# Changes from the original

- Communicate with other libraries
The original supports transmission of 8 bytes or more, but is not compatible with other libraries.
This example can only transfer up to 8 bytes of data, but can communicate with other libraries.

- Support STM32F405/407

# API
- Initialize Hardware
transfer_id = CAN_HW_Init(uint8_t serial);
Expand Down
11 changes: 11 additions & 0 deletions canard/example/can.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ uint32_t CAN_HW_Init(uint8_t serial) {
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
return 0x303 << 8 + serial; // 0x303XX

#elif defined (STM32F405xx) || defined (STM32F415xx) || defined (STM32F407xx) || defined (STM32F417xx)
printstr("Board is STM32F405xx/F415xx/F407xx/417xx");
println();
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
return 0x405 << 8 + serial; // 0x303XX

#else
#error "Warning untested processor variant"
#endif
Expand Down

0 comments on commit 3c6db2e

Please sign in to comment.