[X9D] SPORT driver draft, only feeds the frsky packed decoder for displaying good old telemetry for now
This commit is contained in:
+1
-1
@@ -485,7 +485,7 @@ ifeq ($(PCB), X9D)
|
||||
EEPROMSRC = eeprom_avr.cpp # TODO later eeprom_conversions.cpp
|
||||
PULSESSRC = pulses_arm.cpp
|
||||
CPPSRC += audio_arm.cpp
|
||||
CPPSRC += x9d/pwr_driver.cpp x9d/pulses_driver.cpp x9d/keys_driver.cpp x9d/adc_driver.cpp x9d/trainer_driver.cpp x9d/audio_driver.cpp x9d/delays.cpp x9d/uart_driver.cpp
|
||||
CPPSRC += x9d/pwr_driver.cpp x9d/pulses_driver.cpp x9d/keys_driver.cpp x9d/adc_driver.cpp x9d/trainer_driver.cpp x9d/audio_driver.cpp x9d/delays.cpp x9d/uart_driver.cpp x9d/sport_driver.cpp
|
||||
CPPSRC += bmp.cpp monitors_views.cpp
|
||||
SRC += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c
|
||||
SRC += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
|
||||
|
||||
@@ -205,6 +205,8 @@ void boardInit()
|
||||
__enable_irq() ;
|
||||
|
||||
eepromInit();
|
||||
|
||||
sportInit();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -81,10 +81,13 @@ extern uint16_t sessionTimer;
|
||||
void delaysInit();
|
||||
|
||||
#define DEBUG_UART_BAUDRATE 115200
|
||||
#define SPORT_BAUDRATE 9600
|
||||
|
||||
void uartInit(uint32_t baudrate);
|
||||
void uartPutc(const char c);
|
||||
|
||||
void sportInit(void);
|
||||
|
||||
void delaysInit(void);
|
||||
void delay_01us(uint16_t nb);
|
||||
|
||||
|
||||
+13
-5
@@ -78,11 +78,6 @@
|
||||
#define GPIOPWRLED GPIOC
|
||||
#define GPIOPWR GPIOD
|
||||
|
||||
// Smart-Port
|
||||
#define PIN_SPORT_ON GPIO_Pin_4 //PD.04
|
||||
#define PIN_SPORT_TX GPIO_Pin_5 //PD.05
|
||||
#define PIN_SPORT_RX GPIO_Pin_6 //PD.06
|
||||
|
||||
// Trainer Port
|
||||
#define PIN_TR_PPM_IN GPIO_Pin_5 //PC.08
|
||||
#define PIN_TR_PPM_OUT GPIO_Pin_9 //PC.09
|
||||
@@ -116,6 +111,19 @@
|
||||
#define GPIO_AF_UART3 GPIO_AF_USART3
|
||||
#define UART3 USART3
|
||||
|
||||
// Smart-Port
|
||||
#define RCC_AHB1Periph_GPIO_SPORT RCC_AHB1Periph_GPIOD
|
||||
#define RCC_APB1Periph_SPORT RCC_APB1Periph_USART2
|
||||
#define GPIO_PIN_SPORT_ON GPIOD
|
||||
#define PIN_SPORT_ON GPIO_Pin_4 //PD.04
|
||||
#define GPIO_PIN_SPORT_TXRX GPIOD
|
||||
#define PIN_SPORT_TX GPIO_Pin_5 //PD.05
|
||||
#define PIN_SPORT_RX GPIO_Pin_6 //PD.06
|
||||
#define GPIO_PinSource_SPORT_TX GPIO_PinSource5
|
||||
#define GPIO_PinSource_SPORT_RX GPIO_PinSource6
|
||||
#define GPIO_AF_SPORT GPIO_AF_USART2
|
||||
#define SPORT USART2
|
||||
|
||||
// USB_OTG
|
||||
#define PIN_FS_VBUS GPIO_Pin_9 //PA.09
|
||||
#define PIN_FS_ID GPIO_Pin_10 //PA.10
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
*
|
||||
* open9x is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../open9x.h"
|
||||
|
||||
void sportInit(void)
|
||||
{
|
||||
USART_InitTypeDef USART_InitStructure;
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_SPORT, ENABLE);
|
||||
|
||||
GPIO_PinAFConfig(GPIO_PIN_SPORT_TXRX, GPIO_PinSource_SPORT_RX, GPIO_AF_SPORT);
|
||||
GPIO_PinAFConfig(GPIO_PIN_SPORT_TXRX, GPIO_PinSource_SPORT_TX, GPIO_AF_SPORT);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_SPORT_TX | PIN_SPORT_RX;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIO_PIN_SPORT_TXRX, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_SPORT_ON;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIO_PIN_SPORT_ON, &GPIO_InitStructure);
|
||||
|
||||
GPIO_ResetBits(GPIO_PIN_SPORT_ON, PIN_SPORT_ON);
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPORT, ENABLE);
|
||||
|
||||
USART_InitStructure.USART_BaudRate = SPORT_BAUDRATE;
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||
USART_InitStructure.USART_Mode = USART_Mode_Tx|USART_Mode_Rx;
|
||||
|
||||
USART_Init(SPORT, &USART_InitStructure);
|
||||
USART_Cmd(SPORT, ENABLE);
|
||||
|
||||
USART_ITConfig(SPORT, USART_IT_RXNE, ENABLE);
|
||||
NVIC_EnableIRQ(USART2_IRQn);
|
||||
}
|
||||
|
||||
void sportPutc(const char c)
|
||||
{
|
||||
GPIO_SetBits(GPIO_PIN_SPORT_ON, PIN_SPORT_ON);
|
||||
USART_SendData(SPORT, c);
|
||||
GPIO_ResetBits(GPIO_PIN_SPORT_ON, PIN_SPORT_ON);
|
||||
}
|
||||
|
||||
extern "C" void USART2_IRQHandler()
|
||||
{
|
||||
uint16_t data;
|
||||
|
||||
while(USART_GetFlagStatus(SPORT, USART_FLAG_RXNE)){
|
||||
data = USART_ReceiveData(SPORT);
|
||||
// debugPutc(data);
|
||||
processSerialData((uint8_t) data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user