582 lines
15 KiB
C
582 lines
15 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file : main.c
|
|
* @brief : Main program body
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
|
* All rights reserved.</center></h2>
|
|
*
|
|
* This software component is licensed by ST under Ultimate Liberty license
|
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
|
* the License. You may obtain a copy of the License at:
|
|
* www.st.com/SLA0044
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
/* USER CODE END Header */
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "main.h"
|
|
#include "fatfs.h"
|
|
#include "usb_device.h"
|
|
|
|
/* Private includes ----------------------------------------------------------*/
|
|
/* USER CODE BEGIN Includes */
|
|
#include <errno.h>
|
|
#include <sys/stat.h>
|
|
#include <stdio.h>
|
|
#include "restart.h"
|
|
#include "control.h"
|
|
#include "firmware.h"
|
|
/* USER CODE END Includes */
|
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
/* USER CODE BEGIN PTD */
|
|
/* USER CODE END PTD */
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
/* USER CODE BEGIN PD */
|
|
#define STDIN_FILENO 0
|
|
#define STDOUT_FILENO 1
|
|
#define STDERR_FILENO 2
|
|
/* USER CODE END PD */
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
/* USER CODE BEGIN PM */
|
|
|
|
/* USER CODE END PM */
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
I2C_HandleTypeDef hi2c1;
|
|
|
|
SD_HandleTypeDef hsd;
|
|
|
|
UART_HandleTypeDef huart2;
|
|
|
|
/* USER CODE BEGIN PV */
|
|
extern Control control;
|
|
|
|
/* USER CODE END PV */
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
void SystemClock_Config(void);
|
|
static void MX_GPIO_Init(void);
|
|
static void MX_USART2_UART_Init(void);
|
|
static void MX_I2C1_Init(void);
|
|
static void MX_SDIO_SD_Init(void);
|
|
/* USER CODE BEGIN PFP */
|
|
|
|
/* USER CODE END PFP */
|
|
|
|
/* Private user code ---------------------------------------------------------*/
|
|
/* USER CODE BEGIN 0 */
|
|
uint8_t byte;
|
|
uint8_t ack[] = {0x01};
|
|
uint8_t nack[] = {0xFE};
|
|
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
|
|
if (huart->Instance == USART2) {
|
|
static uint8_t command_mode = 0;
|
|
|
|
if (command_mode) {
|
|
switch (byte) {
|
|
// Reboot to bootloader
|
|
case 'b':
|
|
HAL_UART_Transmit(&huart2, ack, sizeof(ack), HAL_MAX_DELAY);
|
|
request_restart_to_bootloader();
|
|
break;
|
|
|
|
// Upload firmware
|
|
case 'u':
|
|
HAL_UART_Transmit(&huart2, ack, sizeof(ack), HAL_MAX_DELAY);
|
|
firmware_update();
|
|
break;
|
|
|
|
// Send over for bload
|
|
case 'l':
|
|
// @todo Implement this
|
|
break;
|
|
|
|
default:
|
|
HAL_UART_Transmit(&huart2, nack, sizeof(nack), HAL_MAX_DELAY);
|
|
break;
|
|
}
|
|
command_mode = 0;
|
|
} else if (byte == 0xFF) {
|
|
command_mode = 1;
|
|
HAL_UART_Transmit(&huart2, ack, sizeof(ack), HAL_MAX_DELAY);
|
|
} else {
|
|
HAL_I2C_Master_Transmit(&hi2c1, 0x29 << 1, &byte, 1, 1000);
|
|
}
|
|
|
|
HAL_UART_Receive_IT(&huart2, &byte, 1);
|
|
}
|
|
}
|
|
|
|
int _isatty(int fd) {
|
|
if (fd >= STDIN_FILENO && fd <= STDERR_FILENO) {
|
|
return 1;
|
|
}
|
|
|
|
errno = EBADF;
|
|
return 0;
|
|
}
|
|
|
|
int _write(int fd, char* ptr, int len) {
|
|
HAL_StatusTypeDef hstatus;
|
|
|
|
if (fd >= STDIN_FILENO && fd <= STDERR_FILENO) {
|
|
hstatus = HAL_UART_Transmit(&huart2, (uint8_t*)ptr, len, HAL_MAX_DELAY);
|
|
if (hstatus == HAL_OK) {
|
|
return len;
|
|
} else {
|
|
return EIO;
|
|
}
|
|
}
|
|
errno = EBADF;
|
|
return -1;
|
|
}
|
|
|
|
int _close(int fd) {
|
|
if (fd >= STDIN_FILENO && fd <= STDERR_FILENO) {
|
|
return 0;
|
|
}
|
|
|
|
errno = EBADF;
|
|
return -1;
|
|
}
|
|
|
|
int _lseek(int fd, int ptr, int dir) {
|
|
(void) fd;
|
|
(void) ptr;
|
|
(void) dir;
|
|
|
|
errno = EBADF;
|
|
return -1;
|
|
}
|
|
|
|
int _read(int fd, char* ptr, int len) {
|
|
HAL_StatusTypeDef hstatus;
|
|
|
|
if (fd == STDIN_FILENO) {
|
|
hstatus = HAL_UART_Receive(&huart2, (uint8_t*)ptr, 1, HAL_MAX_DELAY);
|
|
if (hstatus == HAL_OK) {
|
|
return 1;
|
|
} else {
|
|
return EIO;
|
|
}
|
|
}
|
|
errno = EBADF;
|
|
return -1;
|
|
}
|
|
|
|
int _fstat(int fd, struct stat* st) {
|
|
if (fd >= STDIN_FILENO && fd <= STDERR_FILENO) {
|
|
st->st_mode = S_IFCHR;
|
|
return 0;
|
|
}
|
|
|
|
errno = EBADF;
|
|
return 0;
|
|
}
|
|
|
|
uint8_t zrst = 0;
|
|
uint8_t dfu = 0;
|
|
uint8_t rst = 0;
|
|
/* USER CODE END 0 */
|
|
|
|
/**
|
|
* @brief The application entry point.
|
|
* @retval int
|
|
*/
|
|
int main(void)
|
|
{
|
|
/* USER CODE BEGIN 1 */
|
|
|
|
/* USER CODE END 1 */
|
|
|
|
/* MCU Configuration--------------------------------------------------------*/
|
|
|
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
|
HAL_Init();
|
|
|
|
/* USER CODE BEGIN Init */
|
|
|
|
/* USER CODE END Init */
|
|
|
|
/* Configure the system clock */
|
|
SystemClock_Config();
|
|
|
|
/* USER CODE BEGIN SysInit */
|
|
|
|
/* USER CODE END SysInit */
|
|
|
|
/* Initialize all configured peripherals */
|
|
MX_GPIO_Init();
|
|
MX_USART2_UART_Init();
|
|
MX_I2C1_Init();
|
|
MX_SDIO_SD_Init();
|
|
MX_FATFS_Init();
|
|
MX_USB_DEVICE_Init();
|
|
/* USER CODE BEGIN 2 */
|
|
setvbuf(stdout, NULL, _IONBF, 0);
|
|
|
|
printf("Z80 Computer is booting!\n\r");
|
|
|
|
BSP_SD_Init();
|
|
|
|
control_reset();
|
|
|
|
HAL_UART_Receive_IT(&huart2, &byte, 1);
|
|
|
|
/* USER CODE END 2 */
|
|
|
|
/* Infinite loop */
|
|
/* USER CODE BEGIN WHILE */
|
|
while (1)
|
|
{
|
|
/* USER CODE END WHILE */
|
|
|
|
/* USER CODE BEGIN 3 */
|
|
// @todo Speed up the main loop
|
|
uint8_t temp = HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_4);
|
|
if (!temp && zrst) {
|
|
printf("Restarting Z80\n\r");
|
|
control_reset();
|
|
}
|
|
zrst = temp;
|
|
|
|
temp = HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_5);
|
|
if (!temp && dfu) {
|
|
printf("Soft restart to bootloader\n\r");
|
|
request_restart_to_bootloader();
|
|
}
|
|
dfu = temp;
|
|
|
|
temp = HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_6);
|
|
if (!temp && rst) {
|
|
printf("Soft restart\n\r");
|
|
request_restart_to_default();
|
|
}
|
|
rst = temp;
|
|
|
|
restart_check();
|
|
|
|
control_execute_state();
|
|
}
|
|
/* USER CODE END 3 */
|
|
}
|
|
|
|
/**
|
|
* @brief System Clock Configuration
|
|
* @retval None
|
|
*/
|
|
void SystemClock_Config(void)
|
|
{
|
|
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
|
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
|
|
|
/** Configure the main internal regulator output voltage
|
|
*/
|
|
__HAL_RCC_PWR_CLK_ENABLE();
|
|
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
|
/** Initializes the CPU, AHB and APB busses clocks
|
|
*/
|
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
|
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
|
RCC_OscInitStruct.PLL.PLLM = 25;
|
|
RCC_OscInitStruct.PLL.PLLN = 336;
|
|
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
|
RCC_OscInitStruct.PLL.PLLQ = 7;
|
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
/** Initializes the CPU, AHB and APB busses clocks
|
|
*/
|
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
|
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
|
|
|
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief I2C1 Initialization Function
|
|
* @param None
|
|
* @retval None
|
|
*/
|
|
static void MX_I2C1_Init(void)
|
|
{
|
|
|
|
/* USER CODE BEGIN I2C1_Init 0 */
|
|
|
|
/* USER CODE END I2C1_Init 0 */
|
|
|
|
/* USER CODE BEGIN I2C1_Init 1 */
|
|
|
|
/* USER CODE END I2C1_Init 1 */
|
|
hi2c1.Instance = I2C1;
|
|
hi2c1.Init.ClockSpeed = 100000;
|
|
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
|
|
hi2c1.Init.OwnAddress1 = 0;
|
|
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
|
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
|
hi2c1.Init.OwnAddress2 = 0;
|
|
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
|
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
|
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
/* USER CODE BEGIN I2C1_Init 2 */
|
|
|
|
/* USER CODE END I2C1_Init 2 */
|
|
|
|
}
|
|
|
|
/**
|
|
* @brief SDIO Initialization Function
|
|
* @param None
|
|
* @retval None
|
|
*/
|
|
static void MX_SDIO_SD_Init(void)
|
|
{
|
|
|
|
/* USER CODE BEGIN SDIO_Init 0 */
|
|
|
|
/* USER CODE END SDIO_Init 0 */
|
|
|
|
/* USER CODE BEGIN SDIO_Init 1 */
|
|
|
|
/* USER CODE END SDIO_Init 1 */
|
|
hsd.Instance = SDIO;
|
|
hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
|
|
hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
|
|
hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
|
|
hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
|
|
hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
|
|
hsd.Init.ClockDiv = 0;
|
|
/* USER CODE BEGIN SDIO_Init 2 */
|
|
|
|
/* USER CODE END SDIO_Init 2 */
|
|
|
|
}
|
|
|
|
/**
|
|
* @brief USART2 Initialization Function
|
|
* @param None
|
|
* @retval None
|
|
*/
|
|
static void MX_USART2_UART_Init(void)
|
|
{
|
|
|
|
/* USER CODE BEGIN USART2_Init 0 */
|
|
|
|
/* USER CODE END USART2_Init 0 */
|
|
|
|
/* USER CODE BEGIN USART2_Init 1 */
|
|
|
|
/* USER CODE END USART2_Init 1 */
|
|
huart2.Instance = USART2;
|
|
huart2.Init.BaudRate = 115200;
|
|
huart2.Init.WordLength = UART_WORDLENGTH_8B;
|
|
huart2.Init.StopBits = UART_STOPBITS_1;
|
|
huart2.Init.Parity = UART_PARITY_NONE;
|
|
huart2.Init.Mode = UART_MODE_TX_RX;
|
|
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
|
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
|
|
if (HAL_UART_Init(&huart2) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
/* USER CODE BEGIN USART2_Init 2 */
|
|
|
|
/* USER CODE END USART2_Init 2 */
|
|
|
|
}
|
|
|
|
/**
|
|
* @brief GPIO Initialization Function
|
|
* @param None
|
|
* @retval None
|
|
*/
|
|
static void MX_GPIO_Init(void)
|
|
{
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
|
|
/* GPIO Ports Clock Enable */
|
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
|
__HAL_RCC_GPIOH_CLK_ENABLE();
|
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_1|GPIO_PIN_2, GPIO_PIN_SET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4|GPIO_PIN_5, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
|
|GPIO_PIN_15, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pins : PE2 PE6 PE0 PE1 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_6|GPIO_PIN_0|GPIO_PIN_1;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PE3 PE4 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : PE5 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_5;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PC13 PC0 PC3 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_0|GPIO_PIN_3;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PC1 PC2 PC4 PC5 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_4|GPIO_PIN_5;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PA0 PA1 PA8 PA14
|
|
PA15 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_8|GPIO_PIN_14
|
|
|GPIO_PIN_15;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PA4 PA5 PA6 PA9
|
|
PA10 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_9
|
|
|GPIO_PIN_10;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : PA7 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_7;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PB11 PB12 PB13 PB14
|
|
PB15 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
|
|GPIO_PIN_15;
|
|
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);
|
|
|
|
/*Configure GPIO pins : PD8 PD9 PD10 PD11 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11;
|
|
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);
|
|
|
|
/*Configure GPIO pins : PD12 PD13 PD14 PD15 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PC6 PC7 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PD0 PD1 PD3 PD4
|
|
PD5 PD6 PD7 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_3|GPIO_PIN_4
|
|
|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PB3 PB4 PB5 PB8
|
|
PB9 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8
|
|
|GPIO_PIN_9;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
}
|
|
|
|
/* USER CODE BEGIN 4 */
|
|
/* USER CODE END 4 */
|
|
|
|
/**
|
|
* @brief This function is executed in case of error occurrence.
|
|
* @retval None
|
|
*/
|
|
void Error_Handler(void)
|
|
{
|
|
/* USER CODE BEGIN Error_Handler_Debug */
|
|
/* User can add his own implementation to report the HAL error return state */
|
|
|
|
/* USER CODE END Error_Handler_Debug */
|
|
}
|
|
|
|
#ifdef USE_FULL_ASSERT
|
|
/**
|
|
* @brief Reports the name of the source file and the source line number
|
|
* where the assert_param error has occurred.
|
|
* @param file: pointer to the source file name
|
|
* @param line: assert_param error line source number
|
|
* @retval None
|
|
*/
|
|
void assert_failed(uint8_t *file, uint32_t line)
|
|
{
|
|
/* USER CODE BEGIN 6 */
|
|
/* User can add his own implementation to report the file name and line number,
|
|
tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
|
/* USER CODE END 6 */
|
|
}
|
|
#endif /* USE_FULL_ASSERT */
|
|
|
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|