Improvements:
- HAL re-organized - FreeRTOS running stable - UART finished - SPI1 & SPI3 finished and functional - Display driver added (functional) git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@172 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
CROSS_COMPILE = arm-none-eabi-
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
LD = $(CROSS_COMPILE)gcc
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
OBJDUMP = $(CROSS_COMPILE)objdump
|
||||
|
||||
OBJDIR = obj
|
||||
SRCDIR = src/
|
||||
ROOTDIR = ../../
|
||||
|
||||
LIBRARY_NAME = ../libPlatform.a
|
||||
|
||||
CCFLAGS = -c -O2 -Wall -g -fno-common -mcpu=cortex-m3 -mthumb -DOLI_STM32_H107 \
|
||||
-Iinc \
|
||||
-I../Misc/inc \
|
||||
-I$(ROOTDIR)/hsb-mrts/inc \
|
||||
-I$(ROOTDIR)/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc \
|
||||
-I$(ROOTDIR)/FreeRTOS/Source/include \
|
||||
-I$(ROOTDIR)/FreeRTOS/Source/portable/GCC/ARM_CM3 \
|
||||
-I$(ROOTDIR)/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x \
|
||||
-I$(ROOTDIR)/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/CoreSupport
|
||||
ARFLAGS = rs
|
||||
|
||||
OBJECTS = \
|
||||
oli_stm32_h107.o \
|
||||
|
||||
|
||||
vpath %.o $(OBJDIR)
|
||||
vpath %.c \
|
||||
$(SRCDIR)
|
||||
|
||||
all: $(LIBRARY_NAME)
|
||||
|
||||
$(LIBRARY_NAME): $(OBJDIR) $(OBJECTS)
|
||||
$(AR) $(ARFLAGS) $@ $(addprefix $(OBJDIR)/, $(OBJECTS))
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CCFLAGS) $< -o $(OBJDIR)/$@
|
||||
|
||||
$(OBJDIR):
|
||||
mkdir -p $@
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJDIR) $(LIBRARY_NAME)
|
||||
|
||||
.PHONY: all clean
|
||||
@@ -0,0 +1,106 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file platform.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {HAL} {group_description}
|
||||
/// This file defines the properties for the Olimex STM32 H107 dev-kit
|
||||
/// platform.
|
||||
///
|
||||
|
||||
/// @file olx_stm32_h107.h
|
||||
/// @ingroup {HAL}
|
||||
|
||||
|
||||
#ifndef PLATFORM_INC_PLATFORM_H_
|
||||
#define PLATFORM_INC_PLATFORM_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "FreeRTOSConfig.h"
|
||||
|
||||
#include "stm32f10x.h"
|
||||
#include "stm32f10x_gpio.h"
|
||||
#include "stm32f10x_rcc.h"
|
||||
#include "stm32f10x_spi.h"
|
||||
#include "stm32f10x_usart.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GPIO_TypeDef* GPIO_Typedef;
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
} T_PL_GPIO;
|
||||
|
||||
|
||||
// Export of LEDs
|
||||
extern struct Led* const ledGreen;
|
||||
extern struct Led* const ledOrange;
|
||||
// Export of UARTs
|
||||
extern struct Uart* const uart1;
|
||||
// Export of SPIs
|
||||
extern struct Spi* const spi1;
|
||||
extern struct Spi* const spi3;
|
||||
extern struct SpiDevice* const spiDAC;
|
||||
extern struct SpiDevice* const spiDisplay;
|
||||
extern struct SpiDevice* const spiEEPROM;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* initPlatform
|
||||
* Initialises the platform-specific properties like GPIO, peripheral systems
|
||||
* and the like
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if init was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus initPlatform(void);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* destructPlatform
|
||||
* Function de de-initialise (destruct) the platform-specific properties and
|
||||
* safely remove all settings that have been set-up with the initPlatform
|
||||
* function
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if init was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus destructPlatform(void);
|
||||
|
||||
#endif /* PLATFORM_INC_PLATFORM_H_ */
|
||||
@@ -0,0 +1,289 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file oli_stm32_h107.c
|
||||
/// @brief Description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @file oli_stm32_h107.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "stm32f10x_gpio.h"
|
||||
#include "stm32f10x_it.h"
|
||||
|
||||
#include "platform.h"
|
||||
#include "led.h"
|
||||
#include "spi.h"
|
||||
#include "uart.h"
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// UART1 Settings (Logger/Console)
|
||||
#define UART_LOG_TYPEDEF (USART1)
|
||||
#define UART_LOG_BAUDRATE (57600)
|
||||
#define UART_LOG_WORDLENGTH (USART_WordLength_8b)
|
||||
#define UART_LOG_STOPBITS (USART_StopBits_1)
|
||||
#define UART_LOG_PARITY (USART_Parity_No)
|
||||
#define UART_LOG_MODE (USART_Mode_Tx | USART_Mode_Rx)
|
||||
#define UART_LOG_HW_FLOW_CONTROL (USART_HardwareFlowControl_None)
|
||||
#define UART_LOG_RX_QUEUE (256)
|
||||
#define UART_LOG_TX_QUEUE (256)
|
||||
|
||||
// SPI1 settings
|
||||
#define SPI_DAC_TYPEDEF (SPI1)
|
||||
#define SPI_DAC_Direction (SPI_Direction_2Lines_FullDuplex)
|
||||
#define SPI_DAC_Mode (SPI_Mode_Master)
|
||||
#define SPI_DAC_DataSize (SPI_DataSize_8b)
|
||||
#define SPI_DAC_CPOL (SPI_CPOL_High)
|
||||
#define SPI_DAC_CPHA (SPI_CPHA_2Edge)
|
||||
#define SPI_DAC_NSS (SPI_NSS_Hard)
|
||||
#define SPI_DAC_BaudRatePrescaler (SPI_BaudRatePrescaler_128)
|
||||
#define SPI_DAC_FirstBit (SPI_FirstBit_MSB)
|
||||
#define SPI_DAC_CRCPolynomial (7)
|
||||
#define SPI_DAC_RX_QUEUE (32)
|
||||
#define SPI_DAC_TX_QUEUE (32)
|
||||
|
||||
// SPI3 settings
|
||||
#define SPI_LCD_TYPEDEF (SPI3)
|
||||
#define SPI_LCD_Direction (SPI_Direction_2Lines_FullDuplex)
|
||||
#define SPI_LCD_Mode (SPI_Mode_Master)
|
||||
#define SPI_LCD_DataSize (SPI_DataSize_8b)
|
||||
#define SPI_LCD_CPOL (SPI_CPOL_High)
|
||||
#define SPI_LCD_CPHA (SPI_CPHA_2Edge)
|
||||
#define SPI_LCD_NSS (SPI_NSS_Soft)
|
||||
// Display has max SPI CLK of 100 kHz
|
||||
#define SPI_LCD_BaudRatePrescaler (SPI_BaudRatePrescaler_128)
|
||||
#define SPI_LCD_FirstBit (SPI_FirstBit_MSB)
|
||||
#define SPI_LCD_CRCPolynomial (7)
|
||||
#define SPI_LCD_RX_QUEUE (32)
|
||||
#define SPI_LCD_TX_QUEUE (32)
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// The following static file-scope variables represent the actual storage of
|
||||
// the IO/Peripheral object
|
||||
|
||||
// LEDs
|
||||
static struct Led _ledGreen;
|
||||
static struct Led _ledOrange;
|
||||
|
||||
// USART
|
||||
static struct Uart _uart1;
|
||||
|
||||
// SPI
|
||||
static struct Spi _spi1;
|
||||
static struct SpiDevice _spiDAC;
|
||||
static struct Spi _spi3;
|
||||
static struct SpiDevice _spiDisplay;
|
||||
static struct SpiDevice _spiEEPROM;
|
||||
|
||||
// The following pointers are for export (see platform.h) and external use.
|
||||
// Note that the pointer content is marked "const"
|
||||
struct Led* const ledGreen = &_ledGreen;
|
||||
struct Led* const ledOrange = &_ledOrange;
|
||||
struct Uart* const uart1 = &_uart1;
|
||||
struct Spi* const spi1 = &_spi1;
|
||||
struct Spi* const spi3 = &_spi3;
|
||||
struct SpiDevice* const spiDAC = &_spiDAC;
|
||||
struct SpiDevice* const spiDisplay = &_spiDisplay;
|
||||
struct SpiDevice* const spiEEPROM = &_spiEEPROM;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static ErrorStatus initIO (void);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
//#ifdef OLI_STM32_H107
|
||||
|
||||
ErrorStatus initPlatform(void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (returnValue == SUCCESS)
|
||||
{
|
||||
returnValue = initIO();
|
||||
|
||||
// Initialize the Console UART
|
||||
IRQ_setInterruptProperties(USART1_IRQn, 15, 15, ENABLE);
|
||||
uart1->USART_TypeDef = UART_LOG_TYPEDEF;
|
||||
returnValue = Uart_Init(uart1, UART_LOG_BAUDRATE, UART_LOG_WORDLENGTH, UART_LOG_STOPBITS, UART_LOG_PARITY, UART_LOG_MODE, UART_LOG_HW_FLOW_CONTROL, UART_LOG_TX_QUEUE, UART_LOG_RX_QUEUE);
|
||||
|
||||
IRQ_setInterruptProperties(SPI1_IRQn, 11, 11, ENABLE);
|
||||
spi1->initialized = false;
|
||||
spi1->SPI_TypeDef = SPI_DAC_TYPEDEF;
|
||||
SPI_construct(spi1, SPI_DAC_Direction, SPI_DAC_Mode, SPI_DAC_DataSize, SPI_DAC_CPOL, SPI_DAC_CPHA, SPI_DAC_NSS, SPI_DAC_BaudRatePrescaler, SPI_DAC_FirstBit, SPI_DAC_CRCPolynomial, SPI_DAC_TX_QUEUE, SPI_DAC_RX_QUEUE);
|
||||
|
||||
IRQ_setInterruptProperties(SPI3_IRQn, 12, 12, ENABLE);
|
||||
spi3->initialized = false;
|
||||
spi3->SPI_TypeDef = SPI_LCD_TYPEDEF;
|
||||
SPI_construct(spi3, SPI_LCD_Direction, SPI_LCD_Mode, SPI_LCD_DataSize, SPI_LCD_CPOL, SPI_LCD_CPHA, SPI_LCD_NSS, SPI_LCD_BaudRatePrescaler, SPI_LCD_FirstBit, SPI_LCD_CRCPolynomial, SPI_LCD_TX_QUEUE, SPI_LCD_RX_QUEUE);
|
||||
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
//#endif
|
||||
|
||||
|
||||
static ErrorStatus initIO (void)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, DISABLE);
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);
|
||||
|
||||
RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART1, DISABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
|
||||
|
||||
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
|
||||
|
||||
RCC_APB2PeriphResetCmd(RCC_APB2Periph_AFIO, DISABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
|
||||
//! Enable USART clock
|
||||
|
||||
/* Peripheral bus power --------------------------------------------------*/
|
||||
RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOB, DISABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||||
RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOC, DISABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
||||
RCC_APB2PeriphResetCmd(RCC_APB2Periph_GPIOE, DISABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);
|
||||
|
||||
/*LED IO initialisation --------------------------------------------------*/
|
||||
// Init LED Green
|
||||
_ledGreen.ledGpio.GPIO_Typedef = GPIOC;
|
||||
_ledGreen.ledGpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
_ledGreen.ledGpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6;
|
||||
_ledGreen.ledGpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(_ledGreen.ledGpio.GPIO_Typedef, &_ledGreen.ledGpio.GPIO_InitStruct);
|
||||
|
||||
// Init LED Orange
|
||||
_ledOrange.ledGpio.GPIO_Typedef = GPIOC;
|
||||
_ledOrange.ledGpio.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
_ledOrange.ledGpio.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7;
|
||||
_ledOrange.ledGpio.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(_ledOrange.ledGpio.GPIO_Typedef, &_ledOrange.ledGpio.GPIO_InitStruct);
|
||||
|
||||
/* USART1 initialisation -------------------------------------------------*/
|
||||
// Init TX line
|
||||
_uart1.USART_TX.GPIO_Typedef = GPIOB;
|
||||
_uart1.USART_TX.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
_uart1.USART_TX.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6;
|
||||
_uart1.USART_TX.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(_uart1.USART_TX.GPIO_Typedef, &_uart1.USART_TX.GPIO_InitStruct);
|
||||
|
||||
// Init RX line
|
||||
_uart1.USART_RX.GPIO_Typedef = GPIOB;
|
||||
_uart1.USART_RX.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
_uart1.USART_RX.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7;
|
||||
_uart1.USART_RX.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(_uart1.USART_RX.GPIO_Typedef, &_uart1.USART_RX.GPIO_InitStruct);
|
||||
// Apply pin-remapping for UART1 I/Os (alternative I/Os usage)
|
||||
GPIO_PinRemapConfig(GPIO_Remap_USART1, ENABLE);
|
||||
|
||||
/* SPI initialisation ----------------------------------------------------*/
|
||||
// SPI1 CLK
|
||||
_spi1.SPI_CLK.GPIO_Typedef = GPIOA;
|
||||
_spi1.SPI_CLK.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
_spi1.SPI_CLK.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_5;
|
||||
_spi1.SPI_CLK.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(_spi1.SPI_CLK.GPIO_Typedef, &_spi1.SPI_CLK.GPIO_InitStruct);
|
||||
// SPI1 MISO
|
||||
_spi1.SPI_MISO.GPIO_Typedef = GPIOA;
|
||||
_spi1.SPI_MISO.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
_spi1.SPI_MISO.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6;
|
||||
_spi1.SPI_MISO.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(_spi1.SPI_MISO.GPIO_Typedef, &_spi1.SPI_MISO.GPIO_InitStruct);
|
||||
// SPI1 MOSI
|
||||
_spi1.SPI_MOSI.GPIO_Typedef = GPIOA;
|
||||
_spi1.SPI_MOSI.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
_spi1.SPI_MOSI.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7;
|
||||
_spi1.SPI_MOSI.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(_spi1.SPI_MOSI.GPIO_Typedef, &_spi1.SPI_MOSI.GPIO_InitStruct);
|
||||
// SPI1 CE
|
||||
_spiDAC.SPI_CE.GPIO_Typedef = GPIOA;
|
||||
_spiDAC.SPI_CE.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
_spiDAC.SPI_CE.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
|
||||
_spiDAC.SPI_CE.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(_spiDAC.SPI_CE.GPIO_Typedef, &_spiDAC.SPI_CE.GPIO_InitStruct);
|
||||
|
||||
spiDAC->spi = &_spi1;
|
||||
|
||||
|
||||
// SPI3 CLK
|
||||
_spi3.SPI_CLK.GPIO_Typedef = GPIOC;
|
||||
_spi3.SPI_CLK.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
_spi3.SPI_CLK.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10;
|
||||
_spi3.SPI_CLK.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(_spi3.SPI_CLK.GPIO_Typedef, &_spi3.SPI_CLK.GPIO_InitStruct);
|
||||
// SPI3 MISO
|
||||
_spi3.SPI_MISO.GPIO_Typedef = GPIOC;
|
||||
_spi3.SPI_MISO.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
_spi3.SPI_MISO.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11;
|
||||
_spi3.SPI_MISO.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(_spi3.SPI_MISO.GPIO_Typedef, &_spi3.SPI_MISO.GPIO_InitStruct);
|
||||
// SPI3 MOSI
|
||||
_spi3.SPI_MOSI.GPIO_Typedef = GPIOC;
|
||||
_spi3.SPI_MOSI.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
_spi3.SPI_MOSI.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12;
|
||||
_spi3.SPI_MOSI.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(_spi3.SPI_MOSI.GPIO_Typedef, &_spi3.SPI_MOSI.GPIO_InitStruct);
|
||||
|
||||
// Apply pin-remapping for SPI3 I/Os (alternative I/Os usage)
|
||||
GPIO_PinRemapConfig(GPIO_Remap_SPI3, ENABLE);
|
||||
|
||||
// SPI3 Display shares all parameters with SPI3 but the ChipEnable, which is different
|
||||
_spiDisplay.spi = &_spi3;
|
||||
// SPI3 CE EEPROM
|
||||
_spiDisplay.SPI_CE.GPIO_Typedef = GPIOE;
|
||||
_spiDisplay.SPI_CE.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
_spiDisplay.SPI_CE.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
|
||||
_spiDisplay.SPI_CE.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(_spiDisplay.SPI_CE.GPIO_Typedef, &_spiDisplay.SPI_CE.GPIO_InitStruct);
|
||||
|
||||
// SPI3 EEPROM shares all parameters with SPI3 but the ChipEnable, which is different
|
||||
_spiEEPROM.spi = &_spi3;
|
||||
// SPI3 CE EEPROM
|
||||
_spiEEPROM.SPI_CE.GPIO_Typedef = GPIOE;
|
||||
_spiEEPROM.SPI_CE.GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
_spiEEPROM.SPI_CE.GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2;
|
||||
_spiEEPROM.SPI_CE.GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(_spiEEPROM.SPI_CE.GPIO_Typedef, &_spiEEPROM.SPI_CE.GPIO_InitStruct);
|
||||
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
Reference in New Issue
Block a user