Permalink
Browse files

Merge pull request #126 from juribeparada/devel

Adding support for MMDVM-Pi with STM32F722
  • Loading branch information...
2 parents a8eae44 + a921df7 commit 628665175c2fa7931b8bb4e0fd3cafaf3f5be8d9 @g4klx committed Nov 6, 2017
Showing with 247 additions and 16 deletions.
  1. +75 −5 IOSTM.cpp
  2. +27 −3 Makefile
  3. +8 −8 SerialSTM.cpp
  4. +137 −0 stm32f722_link.ld
  5. 0 stm32f7xx_link.ld → stm32f767_link.ld
View
@@ -164,6 +164,76 @@ EXT_CLK PA15 input
#define PIN_TX GPIO_Pin_4
#define PIN_TX_CH DAC_Channel_1
+#elif defined(STM32F722_PI)
+/*
+Pin definitions for STM32F722 Pi Board:
+
+PTT PB13 output
+COSLED PB14 output
+LED PB15 output
+COS PC0 input
+
+DSTAR PC7 output
+DMR PC8 output
+YSF PA8 output
+P25 PC9 output
+
+RX PA0 analog input
+RSSI PA7 analog input
+TX PA4 analog output
+
+EXT_CLK PA15 input
+*/
+
+#define PIN_COS GPIO_Pin_0
+#define PORT_COS GPIOC
+#define RCC_Per_COS RCC_AHB1Periph_GPIOC
+
+#define PIN_PTT GPIO_Pin_13
+#define PORT_PTT GPIOB
+#define RCC_Per_PTT RCC_AHB1Periph_GPIOB
+
+#define PIN_COSLED GPIO_Pin_14
+#define PORT_COSLED GPIOB
+#define RCC_Per_COSLED RCC_AHB1Periph_GPIOB
+
+#define PIN_LED GPIO_Pin_15
+#define PORT_LED GPIOB
+#define RCC_Per_LED RCC_AHB1Periph_GPIOB
+
+#define PIN_P25 GPIO_Pin_9
+#define PORT_P25 GPIOC
+#define RCC_Per_P25 RCC_AHB1Periph_GPIOC
+
+#define PIN_DSTAR GPIO_Pin_7
+#define PORT_DSTAR GPIOC
+#define RCC_Per_DSTAR RCC_AHB1Periph_GPIOC
+
+#define PIN_DMR GPIO_Pin_8
+#define PORT_DMR GPIOC
+#define RCC_Per_DMR RCC_AHB1Periph_GPIOC
+
+#define PIN_YSF GPIO_Pin_8
+#define PORT_YSF GPIOA
+#define RCC_Per_YSF RCC_AHB1Periph_GPIOA
+
+#define PIN_EXT_CLK GPIO_Pin_15
+#define SRC_EXT_CLK GPIO_PinSource15
+#define PORT_EXT_CLK GPIOA
+
+#define PIN_RX GPIO_Pin_0
+#define PIN_RX_CH ADC_Channel_0
+#define PORT_RX GPIOA
+#define RCC_Per_RX RCC_AHB1Periph_GPIOA
+
+#define PIN_RSSI GPIO_Pin_7
+#define PIN_RSSI_CH ADC_Channel_7
+#define PORT_RSSI GPIOA
+#define RCC_Per_RSSI RCC_AHB1Periph_GPIOA
+
+#define PIN_TX GPIO_Pin_4
+#define PIN_TX_CH DAC_Channel_1
+
#elif defined(STM32F4_F4M)
/*
Pin definitions for MMDVM-F4M Pi-Hat F0DEI board:
@@ -497,7 +567,7 @@ EXT_CLK PA15 input CN11 Pin17
#define PIN_TX_CH DAC_Channel_1
#else
-#error "Either STM32F4_DISCOVERY, STM32F4_PI, STM32F4_F4M, STM32F4_NUCLEO or STM32F7_NUCLEO need to be defined"
+#error "Either STM32F4_DISCOVERY, STM32F4_PI, STM32F722_PI, STM32F4_F4M, STM32F4_NUCLEO or STM32F7_NUCLEO need to be defined"
#endif
const uint16_t DC_OFFSET = 2048U;
@@ -698,7 +768,7 @@ void CIO::startInt()
// Init the timer
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
-#if defined(EXTERNAL_OSC) && !defined(STM32F4_PI)
+#if defined(EXTERNAL_OSC) && !(defined(STM32F4_PI) || defined(STM32F722_PI))
// Configure a GPIO as external TIM2 clock source
GPIO_PinAFConfig(PORT_EXT_CLK, SRC_EXT_CLK, GPIO_AF_TIM2);
GPIO_InitStruct.GPIO_Pin = PIN_EXT_CLK;
@@ -710,7 +780,7 @@ void CIO::startInt()
TIM_TimeBaseStructInit (&timerInitStructure);
// TIM2 output frequency
-#if defined(EXTERNAL_OSC) && !defined(STM32F4_PI)
+#if defined(EXTERNAL_OSC) && !(defined(STM32F4_PI) || defined(STM32F722_PI))
timerInitStructure.TIM_Prescaler = (uint16_t) ((EXTERNAL_OSC/(2*SAMP_FREQ)) - 1);
timerInitStructure.TIM_Period = 1;
#else
@@ -723,7 +793,7 @@ void CIO::startInt()
timerInitStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM2, &timerInitStructure);
-#if defined(EXTERNAL_OSC) && !defined(STM32F4_PI)
+#if defined(EXTERNAL_OSC) && !(defined(STM32F4_PI) || defined(STM32F722_PI))
// Enable external clock
TIM_ETRClockMode2Config(TIM2, TIM_ExtTRGPSC_OFF, TIM_ExtTRGPolarity_NonInverted, 0x00);
#else
@@ -839,7 +909,7 @@ void CIO::setP25Int(bool on)
// Example from: http://thehackerworkshop.com/?p=1209
void CIO::delayInt(unsigned int dly)
{
-#if defined(STM32F7_NUCLEO)
+#if defined(STM32F7XX)
unsigned int loopsPerMillisecond = (SystemCoreClock/1000);
#else
unsigned int loopsPerMillisecond = (SystemCoreClock/1000) / 3;
View
@@ -91,6 +91,8 @@ endif
ifndef $(OSC)
ifeq ($(MAKECMDGOALS),pi)
OSC=$(CLK_MMDVM_PI)
+ else ifeq ($(MAKECMDGOALS),pi-f722)
+ OSC=$(CLK_MMDVM_PI)
else
OSC=$(CLK_NUCLEO)
endif
@@ -122,6 +124,8 @@ DEFS_F4M=-DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F446xx -DSTM32F4_F4M -DHSE_VA
DEFS_NUCLEO=-DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F446xx -DSTM32F4_NUCLEO -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
# STM32F7 Nucleo-144 F767ZI board:
DEFS_NUCLEO_F767=-DUSE_HAL_DRIVER -DSTM32F767xx -DSTM32F7XX -DSTM32F7_NUCLEO -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
+# MMDVM-Pi F722 board:
+DEFS_PI_F722=-DUSE_HAL_DRIVER -DSTM32F722xx -DSTM32F7XX -DSTM32F722_PI -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
# Build compiler flags
CFLAGS_F4=-c $(MCFLAGS_F4) $(INCLUDES_F4)
@@ -131,15 +135,16 @@ CXXFLAGS_F7=-c $(MCFLAGS_F7) $(INCLUDES_F7)
# Linker flags
LDFLAGS_F4 =-T stm32f4xx_link.ld $(MCFLAGS_F4) --specs=nosys.specs $(INCLUDES_LIBS_F4)
-LDFLAGS_F7 =-T stm32f7xx_link.ld $(MCFLAGS_F7) --specs=nosys.specs $(INCLUDES_LIBS_F7)
+LDFLAGS_F767 =-T stm32f767_link.ld $(MCFLAGS_F7) --specs=nosys.specs $(INCLUDES_LIBS_F7)
+LDFLAGS_F722 =-T stm32f722_link.ld $(MCFLAGS_F7) --specs=nosys.specs $(INCLUDES_LIBS_F7)
# Common flags
CFLAGS=-Os -ffunction-sections -fdata-sections -fno-builtin -Wno-implicit -DCUSTOM_NEW -DNO_EXCEPTIONS
CXXFLAGS=-Os -fno-exceptions -ffunction-sections -fdata-sections -fno-builtin -fno-rtti -DCUSTOM_NEW -DNO_EXCEPTIONS
LDFLAGS=-Os --specs=nano.specs
# Build Rules
-.PHONY: all release dis pi f4m nucleo f767 clean
+.PHONY: all release dis pi pi_f722 f4m nucleo f767 clean
# Default target: Nucleo-64 F446RE board
all: nucleo
@@ -150,6 +155,12 @@ pi: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_PI)
pi: LDFLAGS+=$(LDFLAGS_F4)
pi: release_f4
+pi-f722: GitVersion.h
+pi-f722: CFLAGS+=$(CFLAGS_F7) $(DEFS_PI_F722)
+pi-f722: CXXFLAGS+=$(CXXFLAGS_F7) $(DEFS_PI_F722)
+pi-f722: LDFLAGS+=$(LDFLAGS_F722)
+pi-f722: release_f7
+
f4m: GitVersion.h
f4m: CFLAGS+=$(CFLAGS_F4) $(DEFS_F4M)
f4m: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_F4M)
@@ -171,7 +182,7 @@ dis: release_f4
f767: GitVersion.h
f767: CFLAGS+=$(CFLAGS_F7) $(DEFS_NUCLEO_F767)
f767: CXXFLAGS+=$(CXXFLAGS_F7) $(DEFS_NUCLEO_F767)
-f767: LDFLAGS+=$(LDFLAGS_F7)
+f767: LDFLAGS+=$(LDFLAGS_F767)
f767: release_f7
release_f4: $(BINDIR)
@@ -295,6 +306,19 @@ endif
deploy-f4m: deploy-pi
+deploy-pi-f7:
+ifneq ($(wildcard /usr/local/bin/stm32flash),)
+ -/usr/local/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
+ -/usr/local/bin/stm32ld /dev/ttyAMA0 57600 bin/$(BINBIN_F7)
+ /usr/local/bin/stm32flash -v -w bin/$(BINBIN_F7) -g 0x0 -R -c /dev/ttyAMA0
+endif
+
+ifneq ($(wildcard /usr/bin/stm32flash),)
+ -/usr/bin/stm32flash -i 20,-21,21:-20,21 /dev/ttyAMA0
+ -/usr/bin/stm32ld /dev/ttyAMA0 57600 bin/$(BINBIN_F7)
+ /usr/bin/stm32flash -v -w bin/$(BINBIN_F7) -g 0x0 -R -c /dev/ttyAMA0
+endif
+
# Export the current git version if the index file exists, else 000...
GitVersion.h:
ifdef SYSTEMROOT
View
@@ -27,14 +27,14 @@
Pin definitions:
- Host communication:
-USART1 - TXD PA9 - RXD PA10 (MMDVM-Pi board, MMDVM-F4M board)
+USART1 - TXD PA9 - RXD PA10 (MMDVM-Pi board, MMDVM-Pi F722 board, MMDVM-F4M board)
USART2 - TXD PA2 - RXD PA3 (Nucleo64 F446RE board, Morpho or Arduino header)
USART3 - TXD PC10 - RXD PC11 (Discovery board)
USART3 - TXD PD8 - RXD PD9 (Nucleo144 F767ZI board)
- Serial repeater:
USART1 - TXD PA9 - RXD PA10 (Nucleo with Arduino header)
-UART5 - TXD PC12 - RXD PD2 (Discovery, MMDVM-Pi, MMDVM-F4M board, Nucleo64 with Morpho header and Nucleo144 F767ZI)
+UART5 - TXD PC12 - RXD PD2 (Discovery, MMDVM-Pi, MMDVM-Pi F722 board, MMDVM-F4M board, Nucleo64 with Morpho header and Nucleo144 F767ZI)
*/
#if defined(STM32F4XX) || defined(STM32F7XX)
@@ -50,7 +50,7 @@ extern "C" {
}
/* ************* USART1 ***************** */
-#if defined(STM32F4_PI) || defined(STM32F4_F4M) || (defined(STM32F4_NUCLEO) && defined(STM32F4_NUCLEO_ARDUINO_HEADER))
+#if defined(STM32F4_PI) || defined(STM32F4_F4M) || defined(STM32F722_PI) || (defined(STM32F4_NUCLEO) && defined(STM32F4_NUCLEO_ARDUINO_HEADER))
volatile uint8_t TXSerialfifo1[TX_SERIAL_FIFO_SIZE];
volatile uint8_t RXSerialfifo1[RX_SERIAL_FIFO_SIZE];
@@ -841,7 +841,7 @@ void CSerialPort::beginInt(uint8_t n, int speed)
case 1U:
#if defined(STM32F4_DISCOVERY) || defined(STM32F7_NUCLEO)
InitUSART3(speed);
- #elif defined(STM32F4_PI) || defined(STM32F4_F4M)
+ #elif defined(STM32F4_PI) || defined(STM32F4_F4M) || defined(STM32F722_PI)
InitUSART1(speed);
#elif defined(STM32F4_NUCLEO)
InitUSART2(speed);
@@ -865,7 +865,7 @@ int CSerialPort::availableInt(uint8_t n)
case 1U:
#if defined(STM32F4_DISCOVERY) || defined(STM32F7_NUCLEO)
return AvailUSART3();
- #elif defined(STM32F4_PI) || defined(STM32F4_F4M)
+ #elif defined(STM32F4_PI) || defined(STM32F4_F4M) || defined(STM32F722_PI)
return AvailUSART1();
#elif defined(STM32F4_NUCLEO)
return AvailUSART2();
@@ -887,7 +887,7 @@ int CSerialPort::availableForWriteInt(uint8_t n)
case 1U:
#if defined(STM32F4_DISCOVERY) || defined(STM32F7_NUCLEO)
return AvailForWriteUSART3();
- #elif defined(STM32F4_PI) || defined(STM32F4_F4M)
+ #elif defined(STM32F4_PI) || defined(STM32F4_F4M) || defined(STM32F722_PI)
return AvailForWriteUSART1();
#elif defined(STM32F4_NUCLEO)
return AvailForWriteUSART2();
@@ -909,7 +909,7 @@ uint8_t CSerialPort::readInt(uint8_t n)
case 1U:
#if defined(STM32F4_DISCOVERY) || defined(STM32F7_NUCLEO)
return ReadUSART3();
- #elif defined(STM32F4_PI) || defined(STM32F4_F4M)
+ #elif defined(STM32F4_PI) || defined(STM32F4_F4M) || defined(STM32F722_PI)
return ReadUSART1();
#elif defined(STM32F4_NUCLEO)
return ReadUSART2();
@@ -933,7 +933,7 @@ void CSerialPort::writeInt(uint8_t n, const uint8_t* data, uint16_t length, bool
WriteUSART3(data, length);
if (flush)
TXSerialFlush3();
- #elif defined(STM32F4_PI) || defined(STM32F4_F4M)
+ #elif defined(STM32F4_PI) || defined(STM32F4_F4M) || defined(STM32F722_PI)
WriteUSART1(data, length);
if (flush)
TXSerialFlush1();
Oops, something went wrong.

0 comments on commit 6286651

Please sign in to comment.