add include guards, update readme
This commit is contained in:
parent
7de8bbdc3b
commit
1b79e5cbea
@ -24,6 +24,8 @@ When using the FDCAN peripheral (H7 series), you also need to define
|
|||||||
`FTCAN_NUM_FILTERS` (and set it to the value of "Std Filters Nbr" you configured
|
`FTCAN_NUM_FILTERS` (and set it to the value of "Std Filters Nbr" you configured
|
||||||
in your `.ioc`).
|
in your `.ioc`).
|
||||||
|
|
||||||
|
If you want to use the dedicated buffers of the FDCAN, you must additionally define `FTCAN_NUM_TX_BUFFERS` (set to value of "Tx Buffers Nbr" in CubeMX).
|
||||||
|
|
||||||
If you use
|
If you use
|
||||||
[VSCode with the stm-32-for-vscode extension](https://podio.com/fasttubede/modulubergreifend/apps/tech-tutorials/items/57),
|
[VSCode with the stm-32-for-vscode extension](https://podio.com/fasttubede/modulubergreifend/apps/tech-tutorials/items/57),
|
||||||
you can add these definitions in the `STM32-for-VSCode-config.yaml` file, e.g.:
|
you can add these definitions in the `STM32-for-VSCode-config.yaml` file, e.g.:
|
||||||
@ -33,6 +35,7 @@ you can add these definitions in the `STM32-for-VSCode-config.yaml` file, e.g.:
|
|||||||
cDefinitions:
|
cDefinitions:
|
||||||
- STM32H7
|
- STM32H7
|
||||||
- FTCAN_NUM_FILTERS=32
|
- FTCAN_NUM_FILTERS=32
|
||||||
|
- FTCAN_NUM_TX_BUFFERS=10 # optional, only if using dedicated tx buffers
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
@ -229,10 +229,15 @@ HAL_StatusTypeDef ftcan_get_tx_queue_length(uint32_t *length) {
|
|||||||
return HAL_OK;
|
return HAL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if FTCAN_NUM_TX_BUFFERS
|
||||||
HAL_StatusTypeDef ftcan_transmit_buffer(uint16_t id, const uint8_t *data, size_t datalen, uint32_t buffer_index) {
|
HAL_StatusTypeDef ftcan_transmit_buffer(uint16_t id, const uint8_t *data, size_t datalen, uint32_t buffer_index) {
|
||||||
static FDCAN_TxHeaderTypeDef header;
|
static FDCAN_TxHeaderTypeDef header;
|
||||||
|
if (buffer_index >= FTCAN_NUM_TX_BUFFERS) {
|
||||||
|
return HAL_ERROR;
|
||||||
|
}
|
||||||
return HAL_FDCAN_AddMessageToTxBuffer(hcan, fdcan_initialize_tx_header(&header, id, datalen), data, buffer_index);
|
return HAL_FDCAN_AddMessageToTxBuffer(hcan, fdcan_initialize_tx_header(&header, id, datalen), data, buffer_index);
|
||||||
}
|
}
|
||||||
|
#endif // FTCAN_NUM_TX_BUFFERS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__weak void ftcan_msg_received_cb(uint16_t id, size_t datalen,
|
__weak void ftcan_msg_received_cb(uint16_t id, size_t datalen,
|
||||||
|
@ -41,6 +41,13 @@ HAL_StatusTypeDef ftcan_init(FDCAN_HandleTypeDef *handle);
|
|||||||
#error "Unknown CAN peripheral"
|
#error "Unknown CAN peripheral"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(FTCAN_IS_FDCAN) && defined(FTCAN_NUM_TX_BUFFERS)
|
||||||
|
static_assert(FTCAN_NUM_TX_BUFFERS > 0,
|
||||||
|
"If you want to use the dedicated transmit buffers, you must define FTCAN_NUM_TX_BUFFERS as configured in CubeMX (at least 1).");
|
||||||
|
|
||||||
|
HAL_StatusTypeDef ftcan_transmit_buffer(uint16_t id, const uint8_t *data, size_t datalen, uint32_t buffer_index);
|
||||||
|
#endif // FTCAN_IS_FDCAN && FTCAN_NUM_TX_BUFFERS
|
||||||
|
|
||||||
HAL_StatusTypeDef ftcan_transmit(uint16_t id, const uint8_t *data,
|
HAL_StatusTypeDef ftcan_transmit(uint16_t id, const uint8_t *data,
|
||||||
size_t datalen);
|
size_t datalen);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user