-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55adfb3
commit a8a5d83
Showing
3 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
/* | ||
The MIT License (MIT) | ||
Copyright (c) 2023 Pengutronix, | ||
Marc Kleine-Budde <[email protected]> | ||
Copyright (c) 2024 intive GmbH, | ||
Hubert Denkmair <[email protected]> | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
|
||
#include "board.h" | ||
#include "config.h" | ||
#include "device.h" | ||
#include "gpio.h" | ||
#include "usbd_gs_can.h" | ||
|
||
/* | ||
LED_RX PB14 | ||
LEX_TX PB13 | ||
UART_TX PB6 | ||
UART_RX PB7 | ||
USB_P PA12 | ||
USB_N PA11 | ||
CAN1_RX PD0 | ||
CAN1_TX PD1 | ||
CAN1_S PD2 | ||
CAN2_RX PB0 | ||
CAN2_TX PB1 | ||
CAN2_S PB9 | ||
*/ | ||
|
||
#define LEDRX_GPIO_Port GPIOB | ||
#define LEDRX_Pin GPIO_PIN_14 | ||
#define LEDRX_Mode GPIO_MODE_OUTPUT_PP | ||
#define LEDRX_Active_High 1 | ||
|
||
#define LEDTX_GPIO_Port GPIOB | ||
#define LEDTX_Pin GPIO_PIN_13 | ||
#define LEDTX_Mode GPIO_MODE_OUTPUT_PP | ||
#define LEDTX_Active_High 1 | ||
|
||
static void intive2c2lusb_setup(USBD_GS_CAN_HandleTypeDef *hcan) | ||
{ | ||
GPIO_InitTypeDef GPIO_InitStruct; | ||
|
||
UNUSED(hcan); | ||
|
||
__HAL_RCC_GPIOB_CLK_ENABLE(); | ||
__HAL_RCC_GPIOD_CLK_ENABLE(); | ||
|
||
/* LEDs */ | ||
HAL_GPIO_WritePin(LEDRX_GPIO_Port, LEDRX_Pin, GPIO_INIT_STATE(LEDRX_Active_High)); | ||
GPIO_InitStruct.Pin = LEDRX_Pin; | ||
GPIO_InitStruct.Mode = LEDRX_Mode; | ||
GPIO_InitStruct.Pull = GPIO_NOPULL; | ||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||
HAL_GPIO_Init(LEDRX_GPIO_Port, &GPIO_InitStruct); | ||
|
||
HAL_GPIO_WritePin(LEDTX_GPIO_Port, LEDTX_Pin, GPIO_INIT_STATE(LEDTX_Active_High)); | ||
GPIO_InitStruct.Pin = LEDTX_Pin; | ||
GPIO_InitStruct.Mode = LEDTX_Mode; | ||
GPIO_InitStruct.Pull = GPIO_NOPULL; | ||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||
HAL_GPIO_Init(LEDTX_GPIO_Port, &GPIO_InitStruct); | ||
|
||
/* Setup transceiver silent pin */ | ||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_2, GPIO_PIN_RESET); | ||
GPIO_InitStruct.Pin = GPIO_PIN_2; | ||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||
GPIO_InitStruct.Pull = GPIO_NOPULL; | ||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); | ||
|
||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9, GPIO_PIN_RESET); | ||
GPIO_InitStruct.Pin = GPIO_PIN_9; | ||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||
GPIO_InitStruct.Pull = GPIO_NOPULL; | ||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||
|
||
/* FDCAN */ | ||
|
||
RCC_PeriphCLKInitTypeDef PeriphClkInit = { | ||
.PeriphClockSelection = RCC_PERIPHCLK_FDCAN, | ||
.FdcanClockSelection = RCC_FDCANCLKSOURCE_PLL, | ||
}; | ||
|
||
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit); | ||
__HAL_RCC_FDCAN_CLK_ENABLE(); | ||
|
||
/* FDCAN1_RX, FDCAN1_TX */ | ||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1; | ||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||
GPIO_InitStruct.Pull = GPIO_NOPULL; | ||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||
GPIO_InitStruct.Alternate = GPIO_AF3_FDCAN1; | ||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); | ||
|
||
/* FDCAN2_RX, FDCAN2_TX */ | ||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1; | ||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||
GPIO_InitStruct.Pull = GPIO_NOPULL; | ||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||
GPIO_InitStruct.Alternate = GPIO_AF3_FDCAN2; | ||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||
} | ||
|
||
static void intive2c2lusb_phy_power_set(can_data_t *channel, bool enable) | ||
{ | ||
UNUSED(channel); | ||
UNUSED(enable); | ||
} | ||
|
||
static void intive2c2lusb_termination_set(can_data_t *channel, enum gs_can_termination_state enable) | ||
{ | ||
UNUSED(channel); | ||
UNUSED(enable); | ||
} | ||
|
||
const struct BoardConfig config = { | ||
.setup = intive2c2lusb_setup, | ||
.phy_power_set = intive2c2lusb_phy_power_set, | ||
.termination_set = intive2c2lusb_termination_set, | ||
.channels[0] = { | ||
.interface = FDCAN1, | ||
.leds = { | ||
[LED_RX] = { | ||
.port = LEDRX_GPIO_Port, | ||
.pin = LEDRX_Pin, | ||
.active_high = LEDRX_Active_High, | ||
}, | ||
[LED_TX] = { | ||
.port = LEDTX_GPIO_Port, | ||
.pin = LEDTX_Pin, | ||
.active_high = LEDTX_Active_High, | ||
}, | ||
}, | ||
}, | ||
.channels[1] = { | ||
.interface = FDCAN2, | ||
.leds = { | ||
[LED_RX] = { | ||
.port = LEDRX_GPIO_Port, | ||
.pin = LEDRX_Pin, | ||
.active_high = LEDRX_Active_High, | ||
}, | ||
[LED_TX] = { | ||
.port = LEDTX_GPIO_Port, | ||
.pin = LEDTX_Pin, | ||
.active_high = LEDTX_Active_High, | ||
}, | ||
}, | ||
}, | ||
}; |