-
Notifications
You must be signed in to change notification settings - Fork 16
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
9dbb2da
commit bb62c88
Showing
13 changed files
with
1,141 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
****************************************************************************** | ||
* @file bsp_io.c | ||
* @author Benedek Kupper | ||
* @version 0.1 | ||
* @date 2018-12-16 | ||
* @brief IPoverUSB BSP for I/O pins | ||
* | ||
* Copyright (c) 2018 Benedek Kupper | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include <bsp_io.h> | ||
|
||
const GPIO_InitType BSP_IOCfg[] = | ||
{ | ||
/* USB pins */ | ||
{ | ||
.Mode = GPIO_MODE_ALTERNATE, | ||
.Pull = GPIO_PULL_FLOAT, | ||
.Output.Type = GPIO_OUTPUT_PUSHPULL, | ||
.Output.Speed = VERY_HIGH, | ||
.AlternateMap = GPIO_OTG_FS_AF10 | ||
}, | ||
/* PushButton */ | ||
{ | ||
.Mode = GPIO_MODE_INPUT, | ||
.Pull = GPIO_PULL_FLOAT, | ||
}, | ||
/* LED */ | ||
{ | ||
.Mode = GPIO_MODE_OUTPUT, | ||
.Pull = GPIO_PULL_FLOAT, | ||
.Output.Type = GPIO_OUTPUT_PUSHPULL, | ||
.Output.Speed = HIGH, | ||
}, | ||
}; |
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,54 @@ | ||
/** | ||
****************************************************************************** | ||
* @file bsp_io.h | ||
* @author Benedek Kupper | ||
* @version 0.1 | ||
* @date 2018-12-16 | ||
* @brief IPoverUSB BSP for I/O pins | ||
* | ||
* Copyright (c) 2018 Benedek Kupper | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef __BSP_IO_H_ | ||
#define __BSP_IO_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
#include <xpd_gpio.h> | ||
|
||
#define USB_DP_PIN PA12 | ||
#define USB_DM_PIN PA11 | ||
#define USB_VBUS_PIN PA9 | ||
#define USB_DP_CFG (&BSP_IOCfg[0]) | ||
#define USB_DM_CFG (&BSP_IOCfg[0]) | ||
#define USB_VBUS_CFG (&BSP_IOCfg[0]) | ||
|
||
#define BUTTON_PIN PA0 | ||
#define BUTTON_CFG (&BSP_IOCfg[1]) | ||
|
||
#define LED_GREEN_PIN PE8 | ||
#define LED_RED_PIN PB2 | ||
#define LED_GREEN_CFG (&BSP_IOCfg[2]) | ||
#define LED_RED_CFG (&BSP_IOCfg[2]) | ||
|
||
extern const GPIO_InitType BSP_IOCfg[]; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __BSP_IO_H_ */ |
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,59 @@ | ||
/** | ||
****************************************************************************** | ||
* @file bsp_system.c | ||
* @author Benedek Kupper | ||
* @version 0.1 | ||
* @date 2018-12-16 | ||
* @brief IPoverUSB BSP for system clocking | ||
* | ||
* Copyright (c) 2018 Benedek Kupper | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include <bsp_system.h> | ||
#include <xpd_rcc.h> | ||
|
||
static const RCC_MSI_InitType msiconf = { | ||
.ClockFreq = MSI_48MHz, | ||
.State = ENABLE | ||
}; | ||
|
||
static const RCC_PLL_InitType pllconf = { | ||
.State = ENABLE, | ||
.Source = MSI, | ||
.M = 6, | ||
.N = 20, | ||
.R = 2, /* MSI / 6 * 20 / 2 = PLLR = 80000000 -> SYSCLK */ | ||
|
||
.Q = 2, | ||
.P = 7 | ||
}; | ||
|
||
/* System clocks configuration */ | ||
void SystemClock_Config(void) | ||
{ | ||
RCC_eMSI_Config(&msiconf); | ||
|
||
#ifdef LSE_VALUE_Hz | ||
/* Use LSE to synchronize MSI */ | ||
RCC_eLSE_Config(OSC_ON); | ||
#endif | ||
|
||
RCC_ePLL_Config(&pllconf); | ||
|
||
/* System clocks configuration */ | ||
RCC_eHCLK_Config(PLL, CLK_DIV1, 4); | ||
|
||
RCC_vPCLK1_Config(CLK_DIV1); | ||
RCC_vPCLK2_Config(CLK_DIV1); | ||
} |
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,37 @@ | ||
/** | ||
****************************************************************************** | ||
* @file bsp_system.h | ||
* @author Benedek Kupper | ||
* @version 0.1 | ||
* @date 2018-12-16 | ||
* @brief IPoverUSB BSP for system clocking | ||
* | ||
* Copyright (c) 2018 Benedek Kupper | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef __BSP_SYSTEM_H_ | ||
#define __BSP_SYSTEM_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
extern void SystemClock_Config(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __BSP_SYSTEM_H_ */ |
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,70 @@ | ||
/** | ||
****************************************************************************** | ||
* @file bsp_usb.c | ||
* @author Benedek Kupper | ||
* @version 0.1 | ||
* @date 2018-12-16 | ||
* @brief IPoverUSB BSP for USB communication | ||
* | ||
* Copyright (c) 2018 Benedek Kupper | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include <bsp_io.h> | ||
#include <bsp_usb.h> | ||
#include <xpd_nvic.h> | ||
#include <xpd_pwr.h> | ||
|
||
void OTG_FS_IRQHandler(void); | ||
|
||
/* USB dependencies initialization */ | ||
static void BSP_USB_Init(void * handle) | ||
{ | ||
/* GPIO settings */ | ||
GPIO_vInitPin(USB_DM_PIN, USB_DM_CFG); | ||
GPIO_vInitPin(USB_DP_PIN, USB_DP_CFG); | ||
|
||
NVIC_SetPriorityConfig(OTG_FS_IRQn, 0x6, 0); | ||
NVIC_EnableIRQ(OTG_FS_IRQn); | ||
|
||
USB_vClockConfig(USB_CLOCKSOURCE_MSI); | ||
|
||
PWR_vVddUSB(ENABLE); | ||
} | ||
|
||
/* USB dependencies deinitialization */ | ||
static void BSP_USB_Deinit(void * handle) | ||
{ | ||
GPIO_vDeinitPin(USB_DM_PIN); | ||
GPIO_vDeinitPin(USB_DP_PIN); | ||
NVIC_DisableIRQ(OTG_FS_IRQn); | ||
PWR_vVddUSB(DISABLE); | ||
} | ||
|
||
extern USB_HandleType *const UsbDevice; | ||
|
||
void BSP_USB_Bind(void) | ||
{ | ||
USB_INST2HANDLE(UsbDevice, USB_OTG_FS); | ||
UsbDevice->Callbacks.DepInit = BSP_USB_Init; | ||
UsbDevice->Callbacks.DepDeinit = BSP_USB_Deinit; | ||
} | ||
|
||
/* Common interrupt handler for USB core and WKUP line */ | ||
void OTG_FS_IRQHandler(void) | ||
{ | ||
EXTI_vClearFlag(USB_OTG_FS_WAKEUP_EXTI_LINE); | ||
|
||
/* Handle USB interrupts */ | ||
USB_vIRQHandler(UsbDevice); | ||
} |
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,39 @@ | ||
/** | ||
****************************************************************************** | ||
* @file bsp_usb.h | ||
* @author Benedek Kupper | ||
* @version 0.1 | ||
* @date 2018-12-16 | ||
* @brief IPoverUSB BSP for USB communication | ||
* | ||
* Copyright (c) 2018 Benedek Kupper | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef __BSP_USB_H_ | ||
#define __BSP_USB_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
#include <xpd_usb.h> | ||
|
||
void BSP_USB_Bind(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __BSP_USB_H_ */ |
Oops, something went wrong.