update bsp for f7

This commit is contained in:
hathach 2024-11-06 21:46:18 +07:00
parent fe79a93594
commit e5c26924ed
No known key found for this signature in database
GPG Key ID: 26FAB84F615C3C52
21 changed files with 362 additions and 184 deletions

View File

@ -3,12 +3,18 @@ set(JLINK_DEVICE stm32f723xx)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/STM32F723xE_FLASH.ld)
set(RHPORT_SPEED OPT_MODE_FULL_SPEED OPT_MODE_HIGH_SPEED)
if (NOT DEFINED RHPORT_DEVICE)
set(RHPORT_DEVICE 1)
endif()
if (NOT DEFINED RHPORT_HOST)
set(RHPORT_HOST 1)
endif()
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC
STM32F723xx
HSE_VALUE=25000000
# default to PORT 1 High Speed
BOARD_TUD_RHPORT=1
BOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
)
endfunction()

View File

@ -31,29 +31,37 @@
extern "C" {
#endif
#define LED_PORT GPIOA
#define LED_PIN GPIO_PIN_10
#define LED_STATE_ON 1
// No physical button is populated
#define BUTTON_PORT GPIOA
#define BUTTON_PIN GPIO_PIN_0
#define BUTTON_STATE_ACTIVE 1
#define UART_DEV USART6
#define UART_CLK_EN __HAL_RCC_USART6_CLK_ENABLE
#define UART_GPIO_AF GPIO_AF8_USART6
#define UART_TX_PORT GPIOG
#define UART_TX_PIN GPIO_PIN_9
#define UART_RX_PORT GPIOG
#define UART_RX_PIN GPIO_PIN_14
// VBUS Sense detection
#define OTG_FS_VBUS_SENSE 1
#define OTG_HS_VBUS_SENSE 0
#define PINID_LED 0
#define PINID_UART_TX 1
#define PINID_UART_RX 2
//#define PINID_VBUS0_EN 4
//#define PINID_VBUS1_EN 5
static board_pindef_t board_pindef[] = {
{ // LED
.port = GPIOA,
.pin_init = { .Pin = GPIO_PIN_10, .Mode = GPIO_MODE_OUTPUT_PP, .Pull = GPIO_PULLDOWN, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 1
},
{ // UART TX
.port = GPIOG,
.pin_init = { .Pin = GPIO_PIN_9, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF8_USART6 },
.active_state = 0
},
{ // UART RX
.port = GPIOG,
.pin_init = { .Pin = GPIO_PIN_14, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF8_USART6 },
.active_state = 0
}
};
//--------------------------------------------------------------------+
// RCC Clock
//--------------------------------------------------------------------+
@ -92,8 +100,15 @@ static inline void board_clock_init(void)
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
UART_CLK_EN();
}
static inline void board_vbus_set(uint8_t rhport, bool state) {
(void) rhport; (void) state;
}
#ifdef __cplusplus
}
#endif

View File

@ -1,6 +1,10 @@
MCU_VARIANT = stm32f723xx
# Only OTG-HS has a connector on this board
RHPORT_SPEED = OPT_MODE_FULL_SPEED OPT_MODE_HIGH_SPEED
RHPORT_DEVICE ?= 1
RHPORT_HOST ?= 1
PORT ?= 1
SPEED ?= high

View File

@ -3,12 +3,19 @@ set(JLINK_DEVICE stm32f723ie)
#set(JLINK_OPTION "-USB 000776606156")
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/STM32F723xE_FLASH.ld)
set(RHPORT_SPEED OPT_MODE_FULL_SPEED OPT_MODE_HIGH_SPEED)
# device default to PORT 1 High Speed
if (NOT DEFINED RHPORT_DEVICE)
set(RHPORT_DEVICE 1)
endif()
if (NOT DEFINED RHPORT_HOST)
set(RHPORT_HOST 0)
endif()
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC
STM32F723xx
HSE_VALUE=25000000
# default to PORT 1 High Speed
BOARD_TUD_RHPORT=1
BOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
)
endfunction()

View File

@ -31,28 +31,53 @@
extern "C" {
#endif
#define LED_PORT GPIOB
#define LED_PIN GPIO_PIN_1
#define LED_STATE_ON 1
#define BUTTON_PORT GPIOA
#define BUTTON_PIN GPIO_PIN_0
#define BUTTON_STATE_ACTIVE 1
#define UART_DEV USART6
#define UART_CLK_EN __HAL_RCC_USART6_CLK_ENABLE
#define UART_GPIO_AF GPIO_AF8_USART6
#define UART_TX_PORT GPIOC
#define UART_TX_PIN GPIO_PIN_6
#define UART_RX_PORT GPIOC
#define UART_RX_PIN GPIO_PIN_7
// VBUS Sense detection
#define OTG_FS_VBUS_SENSE 1
#define OTG_HS_VBUS_SENSE 0
#define PINID_LED 0
#define PINID_BUTTON 1
#define PINID_UART_TX 2
#define PINID_UART_RX 3
#define PINID_VBUS0_EN 4
#define PINID_VBUS1_EN 5
static board_pindef_t board_pindef[] = {
{ // LED
.port = GPIOB,
.pin_init = { .Pin = GPIO_PIN_1, .Mode = GPIO_MODE_OUTPUT_PP, .Pull = GPIO_PULLDOWN, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 1
},
{ // Button
.port = GPIOA,
.pin_init = { .Pin = GPIO_PIN_0, .Mode = GPIO_MODE_INPUT, .Pull = GPIO_PULLDOWN, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 1
},
{ // UART TX
.port = GPIOC,
.pin_init = { .Pin = GPIO_PIN_6, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF8_USART6 },
.active_state = 0
},
{ // UART RX
.port = GPIOC,
.pin_init = { .Pin = GPIO_PIN_7, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF8_USART6 },
.active_state = 0
},
{ // VBUS0 EN
.port = GPIOG,
.pin_init = { .Pin = GPIO_PIN_8, .Mode = GPIO_MODE_OUTPUT_OD, .Pull = GPIO_NOPULL, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 0
},
{ // VBUS1 EN
.port = GPIOH,
.pin_init = { .Pin = GPIO_PIN_12, .Mode = GPIO_MODE_OUTPUT_PP, .Pull = GPIO_NOPULL, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 1
},
};
//--------------------------------------------------------------------+
// RCC Clock
//--------------------------------------------------------------------+
@ -90,46 +115,12 @@ static inline void board_clock_init(void) {
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
UART_CLK_EN();
}
//static inline void board_vbus_sense_init(void)
//{
//
//}
typedef struct {
GPIO_TypeDef* port;
GPIO_InitTypeDef pin_init;
bool active_state;
} board_pindef_t;
static board_pindef_t vbus_pindef[] = {
{
.port = GPIOG,
.pin_init = {
.Pin = GPIO_PIN_8, .Mode = GPIO_MODE_OUTPUT_OD, .Pull = GPIO_NOPULL,
.Speed = GPIO_SPEED_HIGH, .Alternate = 0
},
.active_state = false
},
{
.port = GPIOH,
.pin_init = {
.Pin = GPIO_PIN_12, .Mode = GPIO_MODE_OUTPUT_PP, .Pull = GPIO_NOPULL,
.Speed = GPIO_SPEED_HIGH, .Alternate = 0
},
.active_state = true
},
};
void board_vbus_set(uint8_t rhport, bool state) {
static bool pin_inited[2] = { false, false };
board_pindef_t* pindef = &vbus_pindef[rhport];
if (!pin_inited[rhport]) {
HAL_GPIO_Init(pindef->port, &pindef->pin_init);
pin_inited[rhport] = true;
}
static inline void board_vbus_set(uint8_t rhport, bool state) {
board_pindef_t* pindef = &board_pindef[rhport ? PINID_VBUS1_EN : PINID_VBUS0_EN];
HAL_GPIO_WritePin(pindef->port, pindef->pin_init.Pin, state == pindef->active_state ? GPIO_PIN_SET : GPIO_PIN_RESET);
}

View File

@ -1,5 +1,9 @@
MCU_VARIANT = stm32f723xx
RHPORT_SPEED = OPT_MODE_FULL_SPEED OPT_MODE_HIGH_SPEED
RHPORT_DEVICE ?= 1
RHPORT_HOST ?= 0
PORT ?= 1
SPEED ?= high

View File

@ -3,12 +3,19 @@ set(JLINK_DEVICE stm32f746xx)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/STM32F746ZGTx_FLASH.ld)
set(RHPORT_SPEED OPT_MODE_FULL_SPEED OPT_MODE_HIGH_SPEED)
if (NOT DEFINED RHPORT_DEVICE)
set(RHPORT_DEVICE 1)
endif()
if (NOT DEFINED RHPORT_HOST)
set(RHPORT_HOST 0)
endif()
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC
STM32F746xx
HSE_VALUE=25000000
# default to PORT 1 High Speed
BOARD_TUD_RHPORT=1
BOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
)
endfunction()

View File

@ -31,28 +31,43 @@
extern "C" {
#endif
#define LED_PORT GPIOI
#define LED_PIN GPIO_PIN_1
#define LED_STATE_ON 1
#define BUTTON_PORT GPIOI
#define BUTTON_PIN GPIO_PIN_11
#define BUTTON_STATE_ACTIVE 1
#define UART_DEV USART1
#define UART_CLK_EN __HAL_RCC_USART1_CLK_ENABLE
#define UART_GPIO_AF GPIO_AF7_USART1
#define UART_TX_PORT GPIOA
#define UART_TX_PIN GPIO_PIN_9
#define UART_RX_PORT GPIOB
#define UART_RX_PIN GPIO_PIN_7
// VBUS Sense detection
#define OTG_FS_VBUS_SENSE 0
#define OTG_HS_VBUS_SENSE 0
#define PINID_LED 0
#define PINID_BUTTON 1
#define PINID_UART_TX 2
#define PINID_UART_RX 3
//#define PINID_VBUS0_EN 4
//#define PINID_VBUS1_EN 5
static board_pindef_t board_pindef[] = {
{ // LED
.port = GPIOI,
.pin_init = { .Pin = GPIO_PIN_1, .Mode = GPIO_MODE_OUTPUT_PP, .Pull = GPIO_PULLDOWN, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 1
},
{ // Button
.port = GPIOI,
.pin_init = { .Pin = GPIO_PIN_11, .Mode = GPIO_MODE_INPUT, .Pull = GPIO_PULLDOWN, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 1
},
{ // UART TX
.port = GPIOA,
.pin_init = { .Pin = GPIO_PIN_9, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF7_USART1 },
.active_state = 0
},
{ // UART RX
.port = GPIOB,
.pin_init = { .Pin = GPIO_PIN_7, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF7_USART1 },
.active_state = 0
},
};
//--------------------------------------------------------------------+
// RCC Clock
//--------------------------------------------------------------------+
@ -91,8 +106,15 @@ static inline void board_clock_init(void)
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
UART_CLK_EN();
}
static inline void board_vbus_set(uint8_t rhport, bool state) {
(void) rhport; (void) state;
}
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,9 @@
MCU_VARIANT = stm32f746xx
RHPORT_SPEED = OPT_MODE_FULL_SPEED OPT_MODE_HIGH_SPEED
RHPORT_DEVICE ?= 1
RHPORT_HOST ?= 0
PORT ?= 1
SPEED ?= high

View File

@ -3,11 +3,16 @@ set(JLINK_DEVICE stm32f746xx)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/STM32F746ZGTx_FLASH.ld)
if (NOT DEFINED RHPORT_DEVICE)
set(RHPORT_DEVICE 0)
endif()
if (NOT DEFINED RHPORT_HOST)
set(RHPORT_HOST 0)
endif()
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC
STM32F746xx
HSE_VALUE=8000000
BOARD_TUD_RHPORT=0
BOARD_TUD_MAX_SPEED=OPT_MODE_FULL_SPEED
)
endfunction()

View File

@ -31,27 +31,43 @@
extern "C" {
#endif
#define LED_PORT GPIOB
#define LED_PIN GPIO_PIN_14
#define LED_STATE_ON 1
#define BUTTON_PORT GPIOC
#define BUTTON_PIN GPIO_PIN_13
#define BUTTON_STATE_ACTIVE 1
#define UART_DEV USART3
#define UART_CLK_EN __HAL_RCC_USART3_CLK_ENABLE
#define UART_GPIO_AF GPIO_AF7_USART3
#define UART_TX_PORT GPIOD
#define UART_TX_PIN GPIO_PIN_8
#define UART_RX_PORT GPIOD
#define UART_RX_PIN GPIO_PIN_9
// VBUS Sense detection
#define OTG_FS_VBUS_SENSE 1
#define OTG_HS_VBUS_SENSE 0
#define PINID_LED 0
#define PINID_BUTTON 1
#define PINID_UART_TX 2
#define PINID_UART_RX 3
//#define PINID_VBUS0_EN 4
//#define PINID_VBUS1_EN 5
static board_pindef_t board_pindef[] = {
{ // LED
.port = GPIOB,
.pin_init = { .Pin = GPIO_PIN_14, .Mode = GPIO_MODE_OUTPUT_PP, .Pull = GPIO_PULLDOWN, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 1
},
{ // Button
.port = GPIOC,
.pin_init = { .Pin = GPIO_PIN_13, .Mode = GPIO_MODE_INPUT, .Pull = GPIO_PULLDOWN, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 1
},
{ // UART TX
.port = GPIOD,
.pin_init = { .Pin = GPIO_PIN_8, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF7_USART3 },
.active_state = 0
},
{ // UART RX
.port = GPIOD,
.pin_init = { .Pin = GPIO_PIN_9, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF7_USART3 },
.active_state = 0
},
};
static inline void board_clock_init(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
@ -89,6 +105,12 @@ static inline void board_clock_init(void)
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
UART_CLK_EN();
}
static inline void board_vbus_set(uint8_t rhport, bool state) {
(void) rhport; (void) state;
}
#ifdef __cplusplus

View File

@ -1,5 +1,8 @@
MCU_VARIANT = stm32f746xx
RHPORT_DEVICE ?= 0
RHPORT_HOST ?= 0
PORT ?= 0
SPEED ?= full

View File

@ -3,11 +3,16 @@ set(JLINK_DEVICE stm32f767zi)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/STM32F767ZITx_FLASH.ld)
if (NOT DEFINED RHPORT_DEVICE)
set(RHPORT_DEVICE 0)
endif()
if (NOT DEFINED RHPORT_HOST)
set(RHPORT_HOST 0)
endif()
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC
STM32F767xx
HSE_VALUE=8000000
BOARD_TUD_RHPORT=0
BOARD_TUD_MAX_SPEED=OPT_MODE_FULL_SPEED
)
endfunction()

View File

@ -31,28 +31,43 @@
extern "C" {
#endif
#define LED_PORT GPIOB
#define LED_PIN GPIO_PIN_14
#define LED_STATE_ON 1
#define BUTTON_PORT GPIOC
#define BUTTON_PIN GPIO_PIN_13
#define BUTTON_STATE_ACTIVE 1
#define UART_DEV USART3
#define UART_CLK_EN __HAL_RCC_USART3_CLK_ENABLE
#define UART_GPIO_AF GPIO_AF7_USART3
#define UART_TX_PORT GPIOD
#define UART_TX_PIN GPIO_PIN_8
#define UART_RX_PORT GPIOD
#define UART_RX_PIN GPIO_PIN_9
// VBUS Sense detection
#define OTG_FS_VBUS_SENSE 1
#define OTG_HS_VBUS_SENSE 0
#define PINID_LED 0
#define PINID_BUTTON 1
#define PINID_UART_TX 2
#define PINID_UART_RX 3
//#define PINID_VBUS0_EN 4
//#define PINID_VBUS1_EN 5
static board_pindef_t board_pindef[] = {
{ // LED
.port = GPIOB,
.pin_init = { .Pin = GPIO_PIN_14, .Mode = GPIO_MODE_OUTPUT_PP, .Pull = GPIO_PULLDOWN, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 1
},
{ // Button
.port = GPIOC,
.pin_init = { .Pin = GPIO_PIN_13, .Mode = GPIO_MODE_INPUT, .Pull = GPIO_PULLDOWN, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 1
},
{ // UART TX
.port = GPIOD,
.pin_init = { .Pin = GPIO_PIN_8, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF7_USART3 },
.active_state = 0
},
{ // UART RX
.port = GPIOD,
.pin_init = { .Pin = GPIO_PIN_9, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF7_USART3 },
.active_state = 0
},
};
//--------------------------------------------------------------------+
// RCC Clock
//--------------------------------------------------------------------+
@ -92,8 +107,13 @@ static inline void board_clock_init(void)
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
UART_CLK_EN();
}
static inline void board_vbus_set(uint8_t rhport, bool state) {
(void) rhport; (void) state;
}
#ifdef __cplusplus
}

View File

@ -1,5 +1,8 @@
MCU_VARIANT = stm32f767xx
RHPORT_DEVICE ?= 0
RHPORT_HOST ?= 0
PORT ?= 0
SPEED ?= full

View File

@ -3,12 +3,18 @@ set(JLINK_DEVICE stm32f769ni)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/STM32F769ZITx_FLASH.ld)
set(RHPORT_SPEED OPT_MODE_FULL_SPEED OPT_MODE_HIGH_SPEED)
if (NOT DEFINED RHPORT_DEVICE)
set(RHPORT_DEVICE 1)
endif()
if (NOT DEFINED RHPORT_HOST)
set(RHPORT_HOST 1)
endif()
function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC
STM32F769xx
HSE_VALUE=25000000
# default to PORT 1 High Speed
BOARD_TUD_RHPORT=1
BOARD_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED
)
endfunction()

View File

@ -31,28 +31,43 @@
extern "C" {
#endif
#define LED_PORT GPIOJ
#define LED_PIN GPIO_PIN_12
#define LED_STATE_ON 5
#define BUTTON_PORT GPIOA
#define BUTTON_PIN GPIO_PIN_0
#define BUTTON_STATE_ACTIVE 1
#define UART_DEV USART1
#define UART_CLK_EN __HAL_RCC_USART1_CLK_ENABLE
#define UART_GPIO_AF GPIO_AF7_USART1
#define UART_TX_PORT GPIOA
#define UART_TX_PIN GPIO_PIN_9
#define UART_RX_PORT GPIOA
#define UART_RX_PIN GPIO_PIN_10
// VBUS Sense detection
#define OTG_FS_VBUS_SENSE 1
#define OTG_HS_VBUS_SENSE 0
#define PINID_LED 0
#define PINID_BUTTON 1
#define PINID_UART_TX 2
#define PINID_UART_RX 3
//#define PINID_VBUS0_EN 4
//#define PINID_VBUS1_EN 5
static board_pindef_t board_pindef[] = {
{ // LED
.port = GPIOJ,
.pin_init = { .Pin = GPIO_PIN_12, .Mode = GPIO_MODE_OUTPUT_PP, .Pull = GPIO_PULLDOWN, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 1
},
{ // Button
.port = GPIOA,
.pin_init = { .Pin = GPIO_PIN_0, .Mode = GPIO_MODE_INPUT, .Pull = GPIO_PULLDOWN, .Speed = GPIO_SPEED_HIGH, .Alternate = 0 },
.active_state = 1
},
{ // UART TX
.port = GPIOA,
.pin_init = { .Pin = GPIO_PIN_9, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF7_USART1 },
.active_state = 0
},
{ // UART RX
.port = GPIOA,
.pin_init = { .Pin = GPIO_PIN_10, .Mode = GPIO_MODE_AF_PP, .Pull = GPIO_PULLUP, .Speed = GPIO_SPEED_HIGH, .Alternate = GPIO_AF7_USART1 },
.active_state = 0
},
};
//--------------------------------------------------------------------+
// RCC Clock
//--------------------------------------------------------------------+
@ -92,6 +107,12 @@ static inline void board_clock_init(void)
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
UART_CLK_EN();
}
static inline void board_vbus_set(uint8_t rhport, bool state) {
(void) rhport; (void) state;
}
#ifdef __cplusplus

View File

@ -1,6 +1,10 @@
MCU_VARIANT = stm32f769xx
# Only OTG-HS has a connector on this board
RHPORT_SPEED = OPT_MODE_FULL_SPEED OPT_MODE_HIGH_SPEED
RHPORT_DEVICE ?= 1
RHPORT_HOST ?= 1
PORT ?= 1
SPEED ?= high

View File

@ -29,7 +29,11 @@
#include "stm32f7xx_hal.h"
#include "bsp/board_api.h"
void board_vbus_set(uint8_t rhport, bool state) TU_ATTR_WEAK;
typedef struct {
GPIO_TypeDef* port;
GPIO_InitTypeDef pin_init;
uint8_t active_state;
} board_pindef_t;
#include "board.h"
@ -63,12 +67,13 @@ void board_init(void) {
__HAL_RCC_GPIOG_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE(); // ULPI NXT
__HAL_RCC_GPIOI_CLK_ENABLE(); // ULPI NXT
#ifdef __HAL_RCC_GPIOJ_CLK_ENABLE
__HAL_RCC_GPIOJ_CLK_ENABLE();
#endif
UART_CLK_EN();
for (uint8_t i = 0; i < TU_ARRAY_SIZE(board_pindef); i++) {
HAL_GPIO_Init(board_pindef[i].port, &board_pindef[i].pin_init);
}
#if CFG_TUSB_OS == OPT_OS_NONE
// 1ms tick timer
@ -83,38 +88,7 @@ void board_init(void) {
NVIC_SetPriority(OTG_HS_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
#endif
GPIO_InitTypeDef GPIO_InitStruct;
// LED
GPIO_InitStruct.Pin = LED_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
// Button
GPIO_InitStruct.Pin = BUTTON_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
// Uart TX
GPIO_InitStruct.Pin = UART_TX_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = UART_GPIO_AF;
HAL_GPIO_Init(UART_TX_PORT, &GPIO_InitStruct);
// Uart RX
GPIO_InitStruct.Pin = UART_RX_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = UART_GPIO_AF;
HAL_GPIO_Init(UART_RX_PORT, &GPIO_InitStruct);
#ifdef UART_DEV
UartHandle.Instance = UART_DEV;
UartHandle.Init.BaudRate = CFG_BOARD_UART_BAUDRATE;
UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
@ -124,6 +98,9 @@ void board_init(void) {
UartHandle.Init.Mode = UART_MODE_TX_RX;
UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
HAL_UART_Init(&UartHandle);
#endif
GPIO_InitTypeDef GPIO_InitStruct;
//------------- rhport0: OTG_FS -------------//
/* Configure DM DP Pins */
@ -271,12 +248,22 @@ void board_init(void) {
//--------------------------------------------------------------------+
void board_led_write(bool state) {
GPIO_PinState pin_state = (GPIO_PinState) (state ? LED_STATE_ON : (1 - LED_STATE_ON));
HAL_GPIO_WritePin(LED_PORT, LED_PIN, pin_state);
#ifdef PINID_LED
board_pindef_t* pindef = &board_pindef[PINID_LED];
GPIO_PinState pin_state = state == pindef->active_state ? GPIO_PIN_SET : GPIO_PIN_RESET;
HAL_GPIO_WritePin(pindef->port, pindef->pin_init.Pin, pin_state);
#else
(void) state;
#endif
}
uint32_t board_button_read(void) {
return HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
#ifdef PINID_BUTTON
board_pindef_t* pindef = &board_pindef[PINID_BUTTON];
return pindef->active_state == HAL_GPIO_ReadPin(pindef->port, pindef->pin_init.Pin);
#else
return 0;
#endif
}
size_t board_get_unique_id(uint8_t id[], size_t max_len) {
@ -299,8 +286,13 @@ int board_uart_read(uint8_t *buf, int len) {
}
int board_uart_write(void const *buf, int len) {
#ifdef UART_DEV
HAL_UART_Transmit(&UartHandle, (uint8_t *) (uintptr_t) buf, len, 0xffff);
return len;
#else
(void) buf; (void) len;
return -1;
#endif
}
#if CFG_TUSB_OS == OPT_OS_NONE

View File

@ -16,6 +16,18 @@ set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOL
set(FAMILY_MCUS STM32F7 CACHE INTERNAL "")
if (NOT DEFINED RHPORT_SPEED)
# Most F7 does not has built-in HS PHY
set(RHPORT_SPEED OPT_MODE_FULL_SPEED OPT_MODE_FULL_SPEED)
endif ()
if (NOT DEFINED RHPORT_DEVICE_SPEED)
list(GET RHPORT_SPEED ${RHPORT_DEVICE} RHPORT_DEVICE_SPEED)
endif ()
if (NOT DEFINED RHPORT_HOST_SPEED)
list(GET RHPORT_SPEED ${RHPORT_HOST} RHPORT_HOST_SPEED)
endif ()
cmake_print_variables(RHPORT_DEVICE RHPORT_DEVICE_SPEED RHPORT_HOST RHPORT_HOST_SPEED)
#------------------------------------
# BOARD_TARGET
@ -54,8 +66,12 @@ function(add_board_target BOARD_TARGET)
${ST_CMSIS}/Include
${ST_HAL_DRIVER}/Inc
)
#target_compile_options(${BOARD_TARGET} PUBLIC)
#target_compile_definitions(${BOARD_TARGET} PUBLIC)
target_compile_definitions(${BOARD_TARGET} PUBLIC
BOARD_TUD_RHPORT=${RHPORT_DEVICE}
BOARD_TUD_MAX_SPEED=${RHPORT_DEVICE_SPEED}
BOARD_TUH_RHPORT=${RHPORT_HOST}
BOARD_TUH_MAX_SPEED=${RHPORT_HOST_SPEED}
)
update_board(${BOARD_TARGET})

View File

@ -8,6 +8,27 @@ ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
include $(TOP)/$(BOARD_PATH)/board.mk
CPU_CORE ?= cortex-m7-fpsp
# Default RHPORT_SPEED if not defined
RHPORT_SPEED ?= OPT_MODE_FULL_SPEED OPT_MODE_FULL_SPEED
# Determine RHPORT_DEVICE_SPEED if not defined
ifndef RHPORT_DEVICE_SPEED
ifeq ($(RHPORT_DEVICE), 0)
RHPORT_DEVICE_SPEED = $(firstword $(RHPORT_SPEED))
else
RHPORT_DEVICE_SPEED = $(lastword $(RHPORT_SPEED))
endif
endif
# Determine RHPORT_HOST_SPEED if not defined
ifndef RHPORT_HOST_SPEED
ifeq ($(RHPORT_HOST), 0)
RHPORT_HOST_SPEED = $(firstword $(RHPORT_SPEED))
else
RHPORT_HOST_SPEED = $(lastword $(RHPORT_SPEED))
endif
endif
# --------------
# Compiler Flags
# --------------