mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Remove old pin config and MSP code
This commit is contained in:
parent
fafd586b32
commit
021fa678c9
@ -15,16 +15,8 @@ typedef struct {
|
||||
uint16_t pin;
|
||||
} gpio_t;
|
||||
|
||||
extern const gpio_t led_pins[];
|
||||
extern const gpio_t gpio_pins[];
|
||||
#ifdef OPENMV1
|
||||
/* LEDs */
|
||||
#define LED_PORT (GPIOD)
|
||||
#define LED_RED_PIN (GPIO_PIN_4)
|
||||
#define LED_GREEN_PIN (GPIO_PIN_6)
|
||||
#define LED_BLUE_PIN (GPIO_PIN_5)
|
||||
#define LED_ON(gpio) (gpio.port->BSRRH = gpio.pin)
|
||||
#define LED_OFF(gpio) (gpio.port->BSRRL = gpio.pin)
|
||||
|
||||
/* GPIOs */
|
||||
typedef enum {
|
||||
@ -178,14 +170,6 @@ typedef enum {
|
||||
#define __WLAN_DISABLE() HAL_GPIO_WritePin(WLAN_EN_PORT, WLAN_EN_PIN, GPIO_PIN_RESET)
|
||||
|
||||
#else //OPENMV2
|
||||
/* LEDs */
|
||||
#define LED_PORT (GPIOB)
|
||||
#define LED_IR_PIN (GPIO_PIN_3)
|
||||
#define LED_RED_PIN (GPIO_PIN_4)
|
||||
#define LED_GREEN_PIN (GPIO_PIN_6)
|
||||
#define LED_BLUE_PIN (GPIO_PIN_5)
|
||||
#define LED_ON(gpio) (gpio.port->BSRRH = gpio.pin)
|
||||
#define LED_OFF(gpio) (gpio.port->BSRRL = gpio.pin)
|
||||
|
||||
/* GPIOs */
|
||||
typedef enum {
|
||||
|
||||
@ -9,16 +9,6 @@
|
||||
#include "pincfg.h"
|
||||
#include <stm32f4xx_hal.h>
|
||||
|
||||
/* LED GPIOs */
|
||||
const gpio_t led_pins[] = {
|
||||
{LED_PORT, LED_RED_PIN},
|
||||
{LED_PORT, LED_GREEN_PIN},
|
||||
{LED_PORT, LED_BLUE_PIN},
|
||||
#ifdef OPENMV2
|
||||
{LED_PORT, LED_IR_PIN},
|
||||
#endif
|
||||
};
|
||||
|
||||
/* GPIOs */
|
||||
#ifdef OPENMV1
|
||||
const gpio_t gpio_pins[] = {
|
||||
@ -63,7 +53,6 @@ static const gpio_t dcmi_pins[] = {
|
||||
{DCMI_PXCLK_PORT, DCMI_PXCLK_PIN},
|
||||
};
|
||||
|
||||
#define NUM_LED_PINS (sizeof(led_pins)/sizeof(led_pins[0]))
|
||||
#define NUM_DCMI_PINS (sizeof(dcmi_pins)/sizeof(dcmi_pins[0]))
|
||||
|
||||
void SystemClock_Config(void);
|
||||
@ -102,23 +91,6 @@ void HAL_MspInit(void)
|
||||
GPIO_InitStructure.Pin = DCMI_PWDN_PIN;
|
||||
HAL_GPIO_Init(DCMI_PWDN_PORT, &GPIO_InitStructure);
|
||||
|
||||
/* Configure LED GPIO */
|
||||
GPIO_InitStructure.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
for (int i=0; i<NUM_LED_PINS; i++) {
|
||||
HAL_GPIO_WritePin(led_pins[i].port,
|
||||
led_pins[i].pin, GPIO_PIN_SET);
|
||||
#ifdef OPENMV2
|
||||
if (led_pins[i].pin==LED_IR_PIN) { //IR LED is inverted
|
||||
HAL_GPIO_WritePin(led_pins[i].port,
|
||||
led_pins[i].pin, GPIO_PIN_RESET);
|
||||
}
|
||||
#endif
|
||||
GPIO_InitStructure.Pin = led_pins[i].pin;
|
||||
HAL_GPIO_Init(led_pins[i].port, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
/* Configure SD CD PIN */
|
||||
GPIO_InitStructure.Pin = SD_CD_PIN;
|
||||
GPIO_InitStructure.Pull = GPIO_NOPULL;
|
||||
@ -190,10 +162,10 @@ void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef OPENMV1
|
||||
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
#ifdef OPENMV1
|
||||
if (hspi->Instance == SD_SPI) {
|
||||
/* Enable clock */
|
||||
SD_SPI_CLK_ENABLE();
|
||||
@ -220,71 +192,11 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi)
|
||||
/* De-select the Card: Chip Select high */
|
||||
SD_DESELECT();
|
||||
|
||||
} else
|
||||
#endif
|
||||
if (hspi->Instance == WLAN_SPI) {
|
||||
/* Enable clock */
|
||||
WLAN_SPI_CLK_ENABLE();
|
||||
|
||||
/* Configure WLAN EN */
|
||||
GPIO_InitStructure.Pin = WLAN_EN_PIN;
|
||||
GPIO_InitStructure.Pull = GPIO_PULLDOWN;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
HAL_GPIO_Init(WLAN_EN_PORT, &GPIO_InitStructure);
|
||||
|
||||
/* Disable wlan */
|
||||
__WLAN_DISABLE();
|
||||
|
||||
/* Configure WLAN IRQ */
|
||||
GPIO_InitStructure.Pin = WLAN_IRQ_PIN;
|
||||
GPIO_InitStructure.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_IT_FALLING;
|
||||
HAL_GPIO_Init(WLAN_IRQ_PORT, &GPIO_InitStructure);
|
||||
|
||||
/* Configure WLAN SPI GPIOs */
|
||||
GPIO_InitStructure.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_MEDIUM;
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStructure.Alternate = WLAN_SPI_AF;
|
||||
|
||||
GPIO_InitStructure.Pin = WLAN_MOSI_PIN;
|
||||
HAL_GPIO_Init(WLAN_MOSI_PORT, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.Pin = WLAN_MISO_PIN;
|
||||
HAL_GPIO_Init(WLAN_MISO_PORT, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.Pin = WLAN_SCLK_PIN;
|
||||
HAL_GPIO_Init(WLAN_SCLK_PORT, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.Pin = WLAN_CS_PIN;
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
HAL_GPIO_Init(WLAN_CS_PORT, &GPIO_InitStructure);
|
||||
|
||||
/* Deselect the CC3K CS */
|
||||
WLAN_DESELECT();
|
||||
} else if (hspi->Instance == USR_SPI) {
|
||||
/* Enable clock */
|
||||
USR_SPI_CLK_ENABLE();
|
||||
|
||||
/* Configure SPI GPIOs */
|
||||
GPIO_InitStructure.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStructure.Alternate = USR_SPI_AF;
|
||||
|
||||
GPIO_InitStructure.Pin = USR_SCLK_PIN;
|
||||
HAL_GPIO_Init(USR_SCLK_PORT, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.Pin = USR_MOSI_PIN;
|
||||
HAL_GPIO_Init(USR_MOSI_PORT, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.Pin = USR_MISO_PIN;
|
||||
HAL_GPIO_Init(USR_MISO_PORT, &GPIO_InitStructure);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef OPENMV2
|
||||
void HAL_SD_MspInit(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
/* Enable SDIO clock */
|
||||
@ -308,99 +220,7 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
__SDIO_CLK_DISABLE();
|
||||
}
|
||||
|
||||
#ifdef OPENMV2
|
||||
void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram)
|
||||
{
|
||||
/* Enable FMC clock */
|
||||
__FMC_CLK_ENABLE();
|
||||
|
||||
/* Enable GPIO clocks */
|
||||
__GPIOC_CLK_ENABLE();
|
||||
__GPIOD_CLK_ENABLE();
|
||||
__GPIOE_CLK_ENABLE();
|
||||
__GPIOF_CLK_ENABLE();
|
||||
__GPIOG_CLK_ENABLE();
|
||||
|
||||
/* SDRAM pins assignment
|
||||
+-------------------+--------------------+--------------------+
|
||||
| FMC_D0 <-> PD14 | FMC_A0 <-> PF0 | FMC_CLK <-> PG8 |
|
||||
| FMC_D1 <-> PD15 | FMC_A1 <-> PF1 | FMC_CLKE <-> PC3 |
|
||||
| FMC_D2 <-> PD0 | FMC_A2 <-> PF2 | FMC_WE <-> PC0 |
|
||||
| FMC_D3 <-> PD1 | FMC_A3 <-> PF3 | FMC_CS <-> PC2 |
|
||||
| FMC_D4 <-> PE7 | FMC_A4 <-> PF4 | FMC_DQM <-> PE0 |
|
||||
| FMC_D5 <-> PE8 | FMC_A5 <-> PF5 | FMC_BA0 <-> PG4 |
|
||||
| FMC_D6 <-> PE9 | FMC_A6 <-> PF12 | FMC_BA1 <-> PG5 |
|
||||
| FMC_D7 <-> PE10 | FMC_A7 <-> PF13 | FMC_RAS <-> PF11 |
|
||||
| | FMC_A8 <-> PF14 | FMC_CAS <-> PG15 |
|
||||
| | FMC_A9 <-> PF15 | |
|
||||
| | FMC_A10 <-> PG0 | |
|
||||
| | FMC_A11 <-> PG1 | |
|
||||
+-------------------+--------------------+--------------------+ */
|
||||
/* SDRAM GPIO configuration */
|
||||
GPIO_InitTypeDef GPIO_Init_Structure;
|
||||
GPIO_Init_Structure.Pull = GPIO_NOPULL;
|
||||
GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_Init_Structure.Speed = GPIO_SPEED_FAST;
|
||||
GPIO_Init_Structure.Alternate = GPIO_AF12_FMC;
|
||||
|
||||
/* GPIOC configuration */
|
||||
GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_2 | GPIO_PIN_3;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_Init_Structure);
|
||||
|
||||
/* GPIOD configuration */
|
||||
GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_14 | GPIO_PIN_15;
|
||||
HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure);
|
||||
|
||||
/* GPIOE configuration */
|
||||
GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10;
|
||||
HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure);
|
||||
|
||||
/* GPIOF configuration */
|
||||
GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 |
|
||||
GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_11 | GPIO_PIN_12 |
|
||||
GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
|
||||
HAL_GPIO_Init(GPIOF, &GPIO_Init_Structure);
|
||||
|
||||
/* GPIOG configuration */
|
||||
GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 |
|
||||
GPIO_PIN_8 | GPIO_PIN_15;
|
||||
HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure);
|
||||
}
|
||||
#endif
|
||||
|
||||
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
|
||||
{
|
||||
// Enable UART clock
|
||||
UARTx_CLK_ENABLE();
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Alternate = UARTx_TX_AF;
|
||||
|
||||
/* UART TX GPIO pin configuration */
|
||||
GPIO_InitStruct.Pin = UARTx_TX_PIN;
|
||||
HAL_GPIO_Init(UARTx_TX_PORT, &GPIO_InitStruct);
|
||||
|
||||
/* UART RX GPIO pin configuration */
|
||||
GPIO_InitStruct.Pin = UARTx_RX_PIN;
|
||||
GPIO_InitStruct.Alternate = UARTx_RX_AF;
|
||||
HAL_GPIO_Init(UARTx_RX_PORT, &GPIO_InitStruct);
|
||||
}
|
||||
|
||||
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
|
||||
{
|
||||
// UARTx_FORCE_RESET();
|
||||
// UARTx_RELEASE_RESET();
|
||||
//
|
||||
// /* Disable peripherals and GPIO Clocks */
|
||||
// /* Configure UART Tx as alternate function */
|
||||
// HAL_GPIO_DeInit(UARTx_TX_GPIO_PORT, UARTx_TX_PIN);
|
||||
// /* Configure UART Rx as alternate function */
|
||||
// HAL_GPIO_DeInit(UARTx_RX_GPIO_PORT, UARTx_RX_PIN);
|
||||
}
|
||||
#endif //OPENMV2
|
||||
|
||||
void HAL_MspDeInit(void)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user