From d6216cf02b62eb005db0afd59aba07a4edba549f Mon Sep 17 00:00:00 2001 From: Sambas Date: Sat, 2 Jun 2012 12:46:09 +0300 Subject: [PATCH] Graphic features and cleanup osdinput module back to irq based usart --- flight/Modules/Osd/osdgen/osdgen.c | 94 +++++- flight/Modules/Osd/osdinput/osdinput.c | 45 +-- flight/OSD/System/inc/pios_config.h | 2 +- flight/OSD/System/pios_board.c | 373 ++++++----------------- flight/PiOS/Boards/STM32F4xx_OSD.h | 210 +------------ flight/board_hw_defs/osd/board_hw_defs.c | 52 +--- 6 files changed, 220 insertions(+), 556 deletions(-) diff --git a/flight/Modules/Osd/osdgen/osdgen.c b/flight/Modules/Osd/osdgen/osdgen.c index 70adc5882..69c40e191 100644 --- a/flight/Modules/Osd/osdgen/osdgen.c +++ b/flight/Modules/Osd/osdgen/osdgen.c @@ -1897,6 +1897,91 @@ void setGpsOsd(uint8_t status, int32_t lat, int32_t lon, float alt, float spd) m_gpsSpd=spd; } +void draw_artificial_horizon(float angle, float pitch, int16_t l_x, int16_t l_y, int16_t size ) +{ + float alpha; + + int16_t x1,x2,x3,x4; + int16_t y1,y2,y3,y4; + int16_t y_pitch; + // rotated corners + int16_t ax1,ax2,ax3,ax4,ay1,ay2,ay3,ay4; + int16_t refx,refy; + alpha=DEG2RAD(angle); + + // move up or down Size + y_pitch=(pitch/90.0f*(size/2))+size/2; + + // center rotate point + refx=l_x + size/2; + refy=l_y + size/2; + + x1=l_x - size/2; + y1=l_y + y_pitch; + x2=l_x + size + size/2; + y2=l_y + y_pitch; + x3=l_x + size + size/2; + y3=l_y + size + y_pitch; + x4=l_x - size/2; + y4=l_y + size + y_pitch; + + ax1=refy+(x1-refx)*cosf(alpha)-(y1-refy)*sinf(alpha); + ay1=refy+(x1-refx)*sinf(alpha)+(y1-refy)*cosf(alpha); + + ax2=refy+(x2-refx)*cosf(alpha)-(y2-refy)*sinf(alpha); + ay2=refy+(x2-refx)*sinf(alpha)+(y2-refy)*cosf(alpha); + + ax3=refy+(x3-refx)*cosf(alpha)-(y3-refy)*sinf(alpha); + ay3=refy+(x3-refx)*sinf(alpha)+(y3-refy)*cosf(alpha); + + ax4=refy+(x4-refx)*cosf(alpha)-(y4-refy)*sinf(alpha); + ay4=refy+(x4-refx)*sinf(alpha)+(y4-refy)*cosf(alpha); + + write_line_outlined(ax1,ay1,ax2,ay2,0,0,0,1); + //fill + for(int i=0;i<(size);i++) + { + x1=l_x - size/2; + y1=l_y + y_pitch + i; + x2=l_x + size + size/2; + y2=l_y + y_pitch + i; + ax1=refy+(x1-refx)*cosf(alpha)-(y1-refy)*sinf(alpha); + ay1=refy+(x1-refx)*sinf(alpha)+(y1-refy)*cosf(alpha); + ax2=refy+(x2-refx)*cosf(alpha)-(y2-refy)*sinf(alpha); + ay2=refy+(x2-refx)*sinf(alpha)+(y2-refy)*cosf(alpha); + + write_line_lm(ax1,ay1,ax2,ay2,1,1); + } + //fill2 + for(int i=0;i<(size*2);i++) + { + x1=l_x - size/2 + i; + y1=l_y + y_pitch; + x4=l_x - size/2 + i; + y4=l_y + size + y_pitch; + ax1=refy+(x1-refx)*cosf(alpha)-(y1-refy)*sinf(alpha); + ay1=refy+(x1-refx)*sinf(alpha)+(y1-refy)*cosf(alpha); + ax4=refy+(x4-refx)*cosf(alpha)-(y4-refy)*sinf(alpha); + ay4=refy+(x4-refx)*sinf(alpha)+(y4-refy)*cosf(alpha); + + write_line_lm(ax1,ay1,ax4,ay4,1,1); + } + + //sides + write_line_outlined(l_x,l_y,l_x,l_y+size,0,0,0,1); + write_line_outlined(l_x+size,l_y,l_x+size,l_y+size,0,0,0,1); + //plane + write_line_outlined(refx-5,refy,refx+6,refy,0,0,0,1); + write_line_outlined(refx,refy,refx,refy-3,0,0,0,1); + //needs better way to limit drawing outside the box + write_filled_rectangle_lm(l_x - size - size/2-1, l_y - size - size/2-1, size + size/2, size*4+2, 0,0); //left + write_filled_rectangle_lm(l_x + size + 1, l_y - size - size/2-1, size + size/2, size*4+2, 0,0); //right + write_filled_rectangle_lm(l_x-1, l_y + size + 1, size+2, size + size/2, 0,0); //bot + write_filled_rectangle_lm(l_x-1, l_y - size - size/2-1, size+1, size + size/2+1, 0,0); //top + +} + + void introText(){ write_string("ver 0.2", APPLY_HDEADBAND((GRAPHICS_RIGHT/2)),APPLY_VDEADBAND(GRAPHICS_BOTTOM-10), 0, 0, TEXT_VA_BOTTOM, TEXT_HA_CENTER, 0, 3); } @@ -2196,6 +2281,11 @@ void updateGraphics() { } } break; + case 2: + { + draw_artificial_horizon(-attitude.Roll,attitude.Pitch,100,100,30); + } + break; case 3: { lamas(); @@ -2273,7 +2363,7 @@ static void osdgenTask(void *parameters) lastSysTime = xTaskGetTickCount(); // intro - for(int i=0; i<125; i++) + for(int i=0; i<63; i++) { if( xSemaphoreTake( osdSemaphore, LONG_TIME ) == pdTRUE ) { @@ -2281,7 +2371,7 @@ static void osdgenTask(void *parameters) introGraphics(); } } - for(int i=0; i<125; i++) + for(int i=0; i<63; i++) { if( xSemaphoreTake( osdSemaphore, LONG_TIME ) == pdTRUE ) { diff --git a/flight/Modules/Osd/osdinput/osdinput.c b/flight/Modules/Osd/osdinput/osdinput.c index 169882e6f..456fd9a3f 100644 --- a/flight/Modules/Osd/osdinput/osdinput.c +++ b/flight/Modules/Osd/osdinput/osdinput.c @@ -61,7 +61,7 @@ static void OpOsdTask(void *parameters); // **************** // Private variables -//static uint32_t oposdPort; +static uint32_t oposdPort; static xTaskHandle OpOsdTaskHandle; @@ -111,7 +111,7 @@ int32_t OpOsdInitialize(void) // TODO: Get gps settings object -/* oposdPort = PIOS_COM_OSD;*/ + oposdPort = PIOS_COM_OSD; oposd_rx_buffer = pvPortMalloc(NMEA_MAX_PACKET_LENGTH); PIOS_Assert(oposd_rx_buffer); @@ -127,6 +127,7 @@ MODULE_INITCALL(OpOsdInitialize, OpOsdStart) static void OpOsdTask(void *parameters) { + portTickType xDelay = 100 / portTICK_RATE_MS; portTickType lastSysTime; // Loop forever lastSysTime = xTaskGetTickCount(); //portTickType xDelay = 100 / portTICK_RATE_MS; @@ -152,7 +153,7 @@ static void OpOsdTask(void *parameters) // Loop forever while (1) { - //DMA_Cmd(DMA1_Stream2, DISABLE); //prohibit channel3 for a little time + /*//DMA_Cmd(DMA1_Stream2, DISABLE); //prohibit channel3 for a little time uint16_t cnt = DMA_GetCurrDataCounter(DMA1_Stream2); rx.wr = rx.buf_size-cnt; if(rx.wr) @@ -199,9 +200,9 @@ static void OpOsdTask(void *parameters) attitude.Pitch = (int16_t)(oposd_rx_buffer[5] | oposd_rx_buffer[6]<<8); attitude.Yaw = (int16_t)(oposd_rx_buffer[7] | oposd_rx_buffer[8]<<8); AttitudeActualSet(&attitude); - /*setAttitudeOsd((int16_t)(oposd_rx_buffer[5] | oposd_rx_buffer[6]<<8), //pitch - (int16_t)(oposd_rx_buffer[3] | oposd_rx_buffer[4]<<8), //roll - (int16_t)(oposd_rx_buffer[7] | oposd_rx_buffer[8]<<8)); //yaw*/ + //setAttitudeOsd((int16_t)(oposd_rx_buffer[5] | oposd_rx_buffer[6]<<8), //pitch + // (int16_t)(oposd_rx_buffer[3] | oposd_rx_buffer[4]<<8), //roll + // (int16_t)(oposd_rx_buffer[7] | oposd_rx_buffer[8]<<8)); //yaw } //frame completed @@ -212,9 +213,8 @@ static void OpOsdTask(void *parameters) } //DMA_Cmd(DMA1_Stream2, ENABLE); + */ - - /*uint8_t c=0xAA; //PIOS_COM_SendBufferNonBlocking(oposdPort, &c, 1); // This blocks the task until there is something on the buffer @@ -246,18 +246,25 @@ static void OpOsdTask(void *parameters) } if (rx_count == 11) { - AttitudeActualData attitude; - AttitudeActualGet(&attitude); - attitude.q1 = 1; - attitude.q2 = 0; - attitude.q3 = 0; - attitude.q4 = 0; - attitude.Roll = (int16_t)(oposd_rx_buffer[3] | oposd_rx_buffer[4]<<8); - attitude.Pitch = (int16_t)(oposd_rx_buffer[5] | oposd_rx_buffer[6]<<8); - attitude.Yaw = 0; - AttitudeActualSet(&attitude); + if(oposd_rx_buffer[1]==3) + { + AttitudeActualData attitude; + AttitudeActualGet(&attitude); + attitude.q1 = 1; + attitude.q2 = 0; + attitude.q3 = 0; + attitude.q4 = 0; + attitude.Roll = (int16_t)(oposd_rx_buffer[3] | oposd_rx_buffer[4]<<8); + attitude.Pitch = (int16_t)(oposd_rx_buffer[5] | oposd_rx_buffer[6]<<8); + attitude.Yaw = (int16_t)(oposd_rx_buffer[7] | oposd_rx_buffer[8]<<8); + AttitudeActualSet(&attitude); + } + //frame completed + start_flag = false; + rx_count = 0; + } - }*/ + } vTaskDelayUntil(&lastSysTime, 50 / portTICK_RATE_MS); // Check for GPS timeout timeNowMs = xTaskGetTickCount() * portTICK_RATE_MS; diff --git a/flight/OSD/System/inc/pios_config.h b/flight/OSD/System/inc/pios_config.h index 8a7af6520..0d08f4a7a 100644 --- a/flight/OSD/System/inc/pios_config.h +++ b/flight/OSD/System/inc/pios_config.h @@ -54,7 +54,7 @@ /* Com systems to include */ #define PIOS_INCLUDE_COM #define PIOS_INCLUDE_COM_TELEM -//#define PIOS_INCLUDE_COM_AUX +#define PIOS_INCLUDE_COM_AUX #define PIOS_INCLUDE_GPS //#define PIOS_OVERO_SPI diff --git a/flight/OSD/System/pios_board.c b/flight/OSD/System/pios_board.c index d930b9861..2e550eebc 100644 --- a/flight/OSD/System/pios_board.c +++ b/flight/OSD/System/pios_board.c @@ -41,20 +41,10 @@ #include - -#define TxBufferSize3 33 - - /* Private macro -------------------------------------------------------------*/ #define countof(a) (sizeof(a) / sizeof(*(a))) /* Private variables ---------------------------------------------------------*/ -//uint8_t TxBuffer2[TxBufferSize2]; -uint8_t TxBuffer3[TxBufferSize3]; -//uint8_t RxBuffer2[TxBufferSize2]; -uint8_t RxBuffer3[TxBufferSize3]; -//uint8_t UART1_REVDATA[380]; - #if defined(PIOS_INCLUDE_ADC) #include "pios_adc_priv.h" @@ -118,23 +108,23 @@ const uint8_t Escalator8bit[6] = {0x0, 0x33, 0x66, 0x99, 0xCC, 0xFF}; */ void TIM6_Config(void) { - TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; - /* TIM6 Periph clock enable */ - RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE); + TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + /* TIM6 Periph clock enable */ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE); - /* Time base configuration */ - TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); - TIM_TimeBaseStructure.TIM_Period = 27; - TIM_TimeBaseStructure.TIM_Prescaler = 0; - TIM_TimeBaseStructure.TIM_ClockDivision = 0; - TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; - TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure); + /* Time base configuration */ + TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); + TIM_TimeBaseStructure.TIM_Period = 27; + TIM_TimeBaseStructure.TIM_Prescaler = 0; + TIM_TimeBaseStructure.TIM_ClockDivision = 0; + TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; + TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure); - /* TIM6 TRGO selection */ - TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update); + /* TIM6 TRGO selection */ + TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update); - /* TIM6 enable counter */ - TIM_Cmd(TIM6, ENABLE); + /* TIM6 enable counter */ + TIM_Cmd(TIM6, ENABLE); } @@ -145,192 +135,92 @@ void TIM6_Config(void) */ void DAC_Ch2_SineWaveConfig(void) { - DMA_InitTypeDef DMA_InitStructure; + DMA_InitTypeDef DMA_InitStructure; - /* DAC channel2 Configuration */ - DAC_InitStructure.DAC_Trigger = DAC_Trigger_T6_TRGO; - DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; - DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable; - DAC_Init(DAC_Channel_2, &DAC_InitStructure); + /* DAC channel2 Configuration */ + DAC_InitStructure.DAC_Trigger = DAC_Trigger_T6_TRGO; + DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; + DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable; + DAC_Init(DAC_Channel_2, &DAC_InitStructure); - /* DMA1_Stream5 channel7 configuration **************************************/ - DMA_DeInit(DMA1_Stream6); - DMA_InitStructure.DMA_Channel = DMA_Channel_7; - DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(uint32_t)&DAC->DHR12R2; - DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&Sine12bit; - DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; - DMA_InitStructure.DMA_BufferSize = 32; - DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; - DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; - DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; - DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; - DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; - DMA_InitStructure.DMA_Priority = DMA_Priority_High; - DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; - DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; - DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; - DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; - DMA_Init(DMA1_Stream6, &DMA_InitStructure); + /* DMA1_Stream5 channel7 configuration **************************************/ + DMA_DeInit(DMA1_Stream6); + DMA_InitStructure.DMA_Channel = DMA_Channel_7; + DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(uint32_t)&DAC->DHR12R2; + DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&Sine12bit; + DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; + DMA_InitStructure.DMA_BufferSize = 32; + DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; + DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; + DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; + DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; + DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; + DMA_InitStructure.DMA_Priority = DMA_Priority_High; + DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; + DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; + DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; + DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; + DMA_Init(DMA1_Stream6, &DMA_InitStructure); - /* Enable DMA1_Stream5 */ - DMA_Cmd(DMA1_Stream6, ENABLE); + /* Enable DMA1_Stream5 */ + DMA_Cmd(DMA1_Stream6, ENABLE); - /* Enable DAC Channel2 */ - DAC_Cmd(DAC_Channel_2, ENABLE); + /* Enable DAC Channel2 */ + DAC_Cmd(DAC_Channel_2, ENABLE); - /* Enable DMA for DAC Channel2 */ - DAC_DMACmd(DAC_Channel_2, ENABLE); + /* Enable DMA for DAC Channel2 */ + DAC_DMACmd(DAC_Channel_2, ENABLE); } void DAC_Ch1_SineWaveConfig(void) { - DMA_InitTypeDef DMA_InitStructure; + DMA_InitTypeDef DMA_InitStructure; - /* DAC channel2 Configuration */ - DAC_InitStructure.DAC_Trigger = DAC_Trigger_T6_TRGO; - DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; - DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable; - DAC_Init(DAC_Channel_1, &DAC_InitStructure); + /* DAC channel2 Configuration */ + DAC_InitStructure.DAC_Trigger = DAC_Trigger_T6_TRGO; + DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; + DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable; + DAC_Init(DAC_Channel_1, &DAC_InitStructure); - /* DMA1_Stream5 channel7 configuration **************************************/ - DMA_DeInit(DMA1_Stream5); - DMA_InitStructure.DMA_Channel = DMA_Channel_7; - DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(uint32_t)&DAC->DHR12R1; - DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&Sine12bit; - DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; - DMA_InitStructure.DMA_BufferSize = 32; - DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; - DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; - DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; - DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; - DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; - DMA_InitStructure.DMA_Priority = DMA_Priority_High; - DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; - DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; - DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; - DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; - DMA_Init(DMA1_Stream5, &DMA_InitStructure); + /* DMA1_Stream5 channel7 configuration **************************************/ + DMA_DeInit(DMA1_Stream5); + DMA_InitStructure.DMA_Channel = DMA_Channel_7; + DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(uint32_t)&DAC->DHR12R1; + DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&Sine12bit; + DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; + DMA_InitStructure.DMA_BufferSize = 32; + DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; + DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; + DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; + DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; + DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; + DMA_InitStructure.DMA_Priority = DMA_Priority_High; + DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; + DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; + DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; + DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; + DMA_Init(DMA1_Stream5, &DMA_InitStructure); - /* Enable DMA1_Stream5 */ - DMA_Cmd(DMA1_Stream5, ENABLE); + /* Enable DMA1_Stream5 */ + DMA_Cmd(DMA1_Stream5, ENABLE); - /* Enable DAC Channel2 */ - DAC_Cmd(DAC_Channel_1, ENABLE); + /* Enable DAC Channel2 */ + DAC_Cmd(DAC_Channel_1, ENABLE); - /* Enable DMA for DAC Channel2 */ - DAC_DMACmd(DAC_Channel_1, ENABLE); + /* Enable DMA for DAC Channel2 */ + DAC_DMACmd(DAC_Channel_1, ENABLE); } - - static void Clock(uint32_t spektrum_id); -void initUSARTs(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - USART_InitTypeDef USART_InitStructure; - - //RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); - //RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); - //RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); - - /* Configure USART Tx as alternate function push-pull */ - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_PinAFConfig(GPIOA,GPIO_PinSource0,GPIO_AF_UART4); - GPIO_Init(GPIOA, &GPIO_InitStructure); - - - /* Configure USART Rx as input floating */ - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; - GPIO_PinAFConfig(GPIOA,GPIO_PinSource1,GPIO_AF_UART4); - GPIO_Init(GPIOA, &GPIO_InitStructure); - - - USART_InitStructure.USART_BaudRate = 57600; - 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_Rx | USART_Mode_Tx; - - USART_Init(UART4, &USART_InitStructure); - USART_DMACmd(UART4, USART_DMAReq_Rx, ENABLE); - DMA_Cmd(DMA1_Stream2, ENABLE); - USART_Cmd(UART4, ENABLE); -} - -#define DMA_Channel_USART4_RX DMA1_Stream2 -#define DMA_Channel_USART4_TX DMA1_Stream4 -#define DMA_FLAG_USART3_TC_RX DMA1_FLAG_TC3 -#define DMA_FLAG_USART3_TC_TX DMA1_FLAG_TC2 -#define USART3_DR_Base 0x40004804 - -void init_USART_dma() -{ - DMA_InitTypeDef DMA_InitStructure; - - /*RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); - - DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(USART3->DR); - DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; - DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; - DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; - DMA_InitStructure.DMA_BufferSize = size; - DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; - DMA_InitStructure.DMA_Priority = DMA_Priority_Low; - DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; - DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)buff[0]; - DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; - DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; - - DMA_DeInit(DMA_Channel_USART3_RX); - DMA_Init(DMA_Channel_USART3_RX, &DMA_InitStructure); - //DMA_ITConfig(DMA1_Channel3, DMA_IT_TC, ENABLE); - - DMA_Cmd(DMA_Channel_USART3_RX, ENABLE); - USART_DMACmd(USART3, USART_DMAReq_Rx, ENABLE);*/ - - /*DMA Channel2 USART3 TX*/ - DMA_DeInit(DMA1_Stream4); - DMA_InitStructure.DMA_Channel = DMA_Channel_4; - DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&UART4->DR; - DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)TxBuffer3; - DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; /*read from ram*/ - DMA_InitStructure.DMA_BufferSize = TxBufferSize3; /*if content is 0,stop TX*/ - DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; - DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; - DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; - DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; - DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; - //DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; - DMA_InitStructure.DMA_Priority = DMA_Priority_Low; - //DMA_Init(DMA1_Channel2, &DMA_InitStructure); - DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; - DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; - DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; - DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; - - /*DMA Channel3 USART3 RX*/ - DMA_DeInit(DMA1_Stream2); - DMA_InitStructure.DMA_Channel = DMA_Channel_4; - DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&UART4->DR; - DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)RxBuffer3; - DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; - DMA_InitStructure.DMA_BufferSize = sizeof(RxBuffer3); - DMA_Init(DMA1_Stream2, &DMA_InitStructure); - -} #define PIOS_COM_TELEM_RF_RX_BUF_LEN 512 #define PIOS_COM_TELEM_RF_TX_BUF_LEN 512 +#define PIOS_COM_AUX_RX_BUF_LEN 512 +#define PIOS_COM_AUX_TX_BUF_LEN 512 + #define PIOS_COM_GPS_RX_BUF_LEN 32 #define PIOS_COM_TELEM_USB_RX_BUF_LEN 65 @@ -343,7 +233,7 @@ uint32_t pios_com_aux_id; uint32_t pios_com_gps_id; uint32_t pios_com_telem_usb_id; uint32_t pios_com_telem_rf_id; -uint32_t pios_com_cotelem_id; + void PIOS_Board_Init(void) { @@ -530,15 +420,14 @@ void PIOS_Board_Init(void) { PIOS_DEBUG_Assert(0); } - const uint32_t BUF_SIZE = 512; - uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(BUF_SIZE); - uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(BUF_SIZE); + uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_AUX_RX_BUF_LEN); + uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_AUX_TX_BUF_LEN); PIOS_Assert(rx_buffer); PIOS_Assert(tx_buffer); if (PIOS_COM_Init(&pios_com_aux_id, &pios_usart_com_driver, pios_usart_aux_id, - rx_buffer, BUF_SIZE, - tx_buffer, BUF_SIZE)) { + rx_buffer, PIOS_COM_AUX_RX_BUF_LEN, + tx_buffer, PIOS_COM_AUX_TX_BUF_LEN)) { PIOS_DEBUG_Assert(0); } } @@ -567,102 +456,38 @@ void PIOS_Board_Init(void) { pios_com_telem_rf_id = 0; #endif /* PIOS_INCLUDE_COM_TELEM */ -#if defined(PIOS_INCLUDE_COM_COTELEM) - { /* Eventually add switch for this port function */ - uint32_t pios_usart_cotelem_id; - if (PIOS_USART_Init(&pios_usart_cotelem_id, &pios_usart_cotelem_main_cfg)) { - PIOS_Assert(0); - } - - uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN); - uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN); - PIOS_Assert(rx_buffer); - PIOS_Assert(tx_buffer); - if (PIOS_COM_Init(&pios_com_cotelem_id, &pios_usart_com_driver, pios_usart_cotelem_id, - rx_buffer, PIOS_COM_TELEM_RF_RX_BUF_LEN, - tx_buffer, PIOS_COM_TELEM_RF_TX_BUF_LEN)) { - PIOS_Assert(0); - } - } -#else - pios_com_cotelem_id = 0; -#endif /* PIOS_INCLUDE_COM_TELEM */ #endif /* PIOS_INCLUDE_COM */ -/* - uint32_t pios_usart_hkosd_id; - if (PIOS_USART_Init(&pios_usart_hkosd_id, &pios_usart_serial_cfg)) { - PIOS_Assert(0); - } - uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_HKOSD_RX_BUF_LEN); - PIOS_Assert(rx_buffer); - - uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_HKOSD_TX_BUF_LEN); - PIOS_Assert(tx_buffer); - if (PIOS_COM_Init(&pios_com_hkosd_id, &pios_usart_com_driver, pios_usart_hkosd_id, - rx_buffer, PIOS_COM_HKOSD_RX_BUF_LEN, - tx_buffer, PIOS_COM_HKOSD_TX_BUF_LEN)) { - PIOS_Assert(0); - }*/ - -/* - uint32_t pios_usart_serial_id; - if (PIOS_USART_Init(&pios_usart_serial_id, &pios_usart_serial_cfg)) { - PIOS_DEBUG_Assert(0); - } - uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN); - uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN); - PIOS_Assert(rx_buffer); - PIOS_Assert(tx_buffer); - - if (PIOS_COM_Init(&pios_com_serial_id, &pios_usart_com_driver, pios_usart_serial_id, - rx_buffer, PIOS_COM_TELEM_RF_RX_BUF_LEN, - tx_buffer, PIOS_COM_TELEM_RF_TX_BUF_LEN)) { - PIOS_Assert(0); - }*/ #if 1 -/* Preconfiguration before using DAC----------------------------------------*/ -GPIO_InitTypeDef GPIO_InitStructure; + /* Preconfiguration before using DAC----------------------------------------*/ + GPIO_InitTypeDef GPIO_InitStructure; -/* DAC Periph clock enable */ - RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE); + /* DAC Periph clock enable */ + RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE); - /* DAC channel 1 & 2 (DAC_OUT1 = PA.4)(DAC_OUT2 = PA.5) configuration */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(GPIOA, &GPIO_InitStructure); + /* DAC channel 1 & 2 (DAC_OUT1 = PA.4)(DAC_OUT2 = PA.5) configuration */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOA, &GPIO_InitStructure); - /* TIM6 Configuration ------------------------------------------------------*/ - TIM6_Config(); + /* TIM6 Configuration ------------------------------------------------------*/ + TIM6_Config(); - DAC_DeInit(); - DAC_Ch1_SineWaveConfig(); - //DAC_Ch2_SineWaveConfig(); + DAC_DeInit(); + DAC_Ch1_SineWaveConfig(); + //DAC_Ch2_SineWaveConfig(); #endif + // ADC system #if defined(PIOS_INCLUDE_ADC) PIOS_ADC_Init(&pios_adc_cfg); #endif - // SPI link to master - /*if (PIOS_SPI_Init(&pios_spi_port_id, &pios_spi_port_cfg)) { - PIOS_DEBUG_Assert(0); - }*/ - - /*init_USART_dma(); - initUSARTs(); - extern t_fifo_buffer rx; - fifoBuf_init(&rx,RxBuffer3,sizeof(RxBuffer3));*/ - +#if defined(PIOS_INCLUDE_VIDEO) PIOS_Video_Init(&pios_video_cfg); - - //uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_HKOSD_RX_BUF_LEN); - - //uint8_t test[16]; - - +#endif } uint16_t supv_timer=0; diff --git a/flight/PiOS/Boards/STM32F4xx_OSD.h b/flight/PiOS/Boards/STM32F4xx_OSD.h index ca426c543..05e2d7ace 100644 --- a/flight/PiOS/Boards/STM32F4xx_OSD.h +++ b/flight/PiOS/Boards/STM32F4xx_OSD.h @@ -137,30 +137,6 @@ TIM4 | STOPWATCH | #define PIOS_LED_HEARTBEAT 0 #define PIOS_LED_ALARM 1 -#if 0 -#define PIOS_LED_LED1_GPIO_PORT GPIOD -#define PIOS_LED_LED1_GPIO_PIN GPIO_Pin_13 //LD3 -#define PIOS_LED_LED1_GPIO_CLK RCC_APB2Periph_GPIOD -#define PIOS_LED_LED2_GPIO_PORT GPIOD -#define PIOS_LED_LED2_GPIO_PIN GPIO_Pin_12 //LD4 -#define PIOS_LED_LED2_GPIO_CLK RCC_APB2Periph_GPIOD -#define PIOS_LED_LED3_GPIO_PORT GPIOD -#define PIOS_LED_LED3_GPIO_PIN GPIO_Pin_14 //LD5 -#define PIOS_LED_LED3_GPIO_CLK RCC_APB2Periph_GPIOD -#define PIOS_LED_LED4_GPIO_PORT GPIOD -#define PIOS_LED_LED4_GPIO_PIN GPIO_Pin_15 //LD6 -#define PIOS_LED_LED4_GPIO_CLK RCC_APB2Periph_GPIOD -#define PIOS_LED_NUM 4 -#define PIOS_LED_PORTS { PIOS_LED_LED1_GPIO_PORT, PIOS_LED_LED2_GPIO_PORT, PIOS_LED_LED3_GPIO_PORT, PIOS_LED_LED4_GPIO_PORT } -#define PIOS_LED_PINS { PIOS_LED_LED1_GPIO_PIN, PIOS_LED_LED2_GPIO_PIN, PIOS_LED_LED3_GPIO_PIN, PIOS_LED_LED4_GPIO_PIN } -#define PIOS_LED_CLKS { PIOS_LED_LED1_GPIO_CLK, PIOS_LED_LED2_GPIO_CLK, PIOS_LED_LED3_GPIO_CLK, PIOS_LED_LED4_GPIO_CLK } -#endif - -/*#define USB_LED_ON PIOS_LED_On(LED1) -#define USB_LED_OFF PIOS_LED_Off(LED1) -#define USB_LED_TOGGLE PIOS_LED_Toggle(LED1) -*/ - // ***************************************************************** // Delay Timer @@ -206,17 +182,12 @@ extern uint32_t pios_com_telem_rf_id; extern uint32_t pios_com_gps_id; extern uint32_t pios_com_aux_id; extern uint32_t pios_com_telem_usb_id; -extern uint32_t pios_com_cotelem_id; #define PIOS_COM_AUX (pios_com_aux_id) #define PIOS_COM_GPS (pios_com_gps_id) #define PIOS_COM_TELEM_USB (pios_com_telem_usb_id) #define PIOS_COM_TELEM_RF (pios_com_telem_rf_id) -#define PIOS_COM_COTELEM (pios_com_cotelem_id) #define PIOS_COM_DEBUG PIOS_COM_AUX - - -extern uint32_t pios_com_hkosd_id; -#define PIOS_COM_OSD (pios_com_hkosd_id) +#define PIOS_COM_OSD (pios_com_aux_id) //extern uint32_t pios_com_serial_id; //#define PIOS_COM_SERIAL (pios_com_serial_id) @@ -269,158 +240,6 @@ extern uint32_t pios_com_telem_usb_id; #define PIOS_ADC_MAX_OVERSAMPLING 10 #define PIOS_ADC_USE_ADC2 0 -#if 0 - -// ***************************************************************** -// GPIO output pins - -// GPIO_Mode_Out_OD Open Drain Output -// GPIO_Mode_Out_PP Push-Pull Output -// GPIO_Mode_AF_OD Open Drain Output Alternate-Function -// GPIO_Mode_AF_PP Push-Pull Output Alternate-Function - -// Serial port RTS line -#define PIOS_GPIO_OUT_0_PORT GPIOB -#define PIOS_GPIO_OUT_0_PIN GPIO_Pin_15 -#define PIOS_GPIO_OUT_0_GPIO_CLK RCC_APB2Periph_GPIOB - -// RF module chip-select line -#define PIOS_GPIO_OUT_1_PORT GPIOA -#define PIOS_GPIO_OUT_1_PIN GPIO_Pin_4 -#define PIOS_GPIO_OUT_1_GPIO_CLK RCC_APB2Periph_GPIOA - -// PPM OUT line -#define PIOS_GPIO_OUT_2_PORT GPIOB -#define PIOS_GPIO_OUT_2_PIN GPIO_Pin_10 -#define PIOS_GPIO_OUT_2_GPIO_CLK RCC_APB2Periph_GPIOB - -// spare pin -#define PIOS_GPIO_OUT_3_PORT GPIOA -#define PIOS_GPIO_OUT_3_PIN GPIO_Pin_0 -#define PIOS_GPIO_OUT_3_GPIO_CLK RCC_APB2Periph_GPIOA - -// spare pin -#define PIOS_GPIO_OUT_4_PORT GPIOA -#define PIOS_GPIO_OUT_4_PIN GPIO_Pin_1 -#define PIOS_GPIO_OUT_4_GPIO_CLK RCC_APB2Periph_GPIOA - -// spare pin -#define PIOS_GPIO_OUT_5_PORT GPIOC -#define PIOS_GPIO_OUT_5_PIN GPIO_Pin_13 -#define PIOS_GPIO_OUT_5_GPIO_CLK RCC_APB2Periph_GPIOC - -// spare pin -#define PIOS_GPIO_OUT_6_PORT GPIOC -#define PIOS_GPIO_OUT_6_PIN GPIO_Pin_14 -#define PIOS_GPIO_OUT_6_GPIO_CLK RCC_APB2Periph_GPIOC - -// spare pin -#define PIOS_GPIO_OUT_7_PORT GPIOC -#define PIOS_GPIO_OUT_7_PIN GPIO_Pin_15 -#define PIOS_GPIO_OUT_7_GPIO_CLK RCC_APB2Periph_GPIOC - -#define PIOS_GPIO_NUM 8 -#define PIOS_GPIO_PORTS {PIOS_GPIO_OUT_0_PORT, PIOS_GPIO_OUT_1_PORT, PIOS_GPIO_OUT_2_PORT, PIOS_GPIO_OUT_3_PORT, PIOS_GPIO_OUT_4_PORT, PIOS_GPIO_OUT_5_PORT, PIOS_GPIO_OUT_6_PORT, PIOS_GPIO_OUT_7_PORT} -#define PIOS_GPIO_PINS {PIOS_GPIO_OUT_0_PIN, PIOS_GPIO_OUT_1_PIN, PIOS_GPIO_OUT_2_PIN, PIOS_GPIO_OUT_3_PIN, PIOS_GPIO_OUT_4_PIN, PIOS_GPIO_OUT_5_PIN, PIOS_GPIO_OUT_6_PIN, PIOS_GPIO_OUT_7_PIN} -#define PIOS_GPIO_CLKS {PIOS_GPIO_OUT_0_GPIO_CLK, PIOS_GPIO_OUT_1_GPIO_CLK, PIOS_GPIO_OUT_2_GPIO_CLK, PIOS_GPIO_OUT_3_GPIO_CLK, PIOS_GPIO_OUT_4_GPIO_CLK, PIOS_GPIO_OUT_5_GPIO_CLK, PIOS_GPIO_OUT_6_GPIO_CLK, PIOS_GPIO_OUT_7_GPIO_CLK} - -#define SERIAL_RTS_ENABLE PIOS_GPIO_Enable(0) -#define SERIAL_RTS_SET PIOS_GPIO_Off(0) -#define SERIAL_RTS_CLEAR PIOS_GPIO_On(0) - -#define RF_CS_ENABLE PIOS_GPIO_Enable(1) -#define RF_CS_HIGH PIOS_GPIO_Off(1) -#define RF_CS_LOW PIOS_GPIO_On(1) - -#define PPM_OUT_PIN PIOS_GPIO_OUT_2_PIN -#define PPM_OUT_PORT PIOS_GPIO_OUT_2_PORT -#define PPM_OUT_ENABLE PIOS_GPIO_Enable(2) -#define PPM_OUT_HIGH PIOS_GPIO_Off(2) -#define PPM_OUT_LOW PIOS_GPIO_On(2) - -#define SPARE1_ENABLE PIOS_GPIO_Enable(3) -#define SPARE1_HIGH PIOS_GPIO_Off(3) -#define SPARE1_LOW PIOS_GPIO_On(3) - -#define SPARE2_ENABLE PIOS_GPIO_Enable(4) -#define SPARE2_HIGH PIOS_GPIO_Off(4) -#define SPARE2_LOW PIOS_GPIO_On(4) - -#define SPARE3_ENABLE PIOS_GPIO_Enable(5) -#define SPARE3_HIGH PIOS_GPIO_Off(5) -#define SPARE3_LOW PIOS_GPIO_On(5) - -#define SPARE4_ENABLE PIOS_GPIO_Enable(6) -#define SPARE4_HIGH PIOS_GPIO_Off(6) -#define SPARE4_LOW PIOS_GPIO_On(6) - -#define SPARE5_ENABLE PIOS_GPIO_Enable(7) -#define SPARE5_HIGH PIOS_GPIO_Off(7) -#define SPARE5_LOW PIOS_GPIO_On(7) - -// ***************************************************************** -// GPIO input pins - -// GPIO_Mode_AIN Analog Input -// GPIO_Mode_IN_FLOATING Input Floating -// GPIO_Mode_IPD Input Pull-Down -// GPIO_Mode_IPU Input Pull-up - -// API mode line -#define GPIO_IN_0_PORT GPIOB -#define GPIO_IN_0_PIN GPIO_Pin_13 -#define GPIO_IN_0_MODE GPIO_Mode_IPU - -// Serial port CTS line -#define GPIO_IN_1_PORT GPIOB -#define GPIO_IN_1_PIN GPIO_Pin_14 -#define GPIO_IN_1_MODE GPIO_Mode_IPU - -// VBUS sense line -#define GPIO_IN_2_PORT GPIOA -#define GPIO_IN_2_PIN GPIO_Pin_8 -#define GPIO_IN_2_MODE GPIO_Mode_IN_FLOATING - -// 868MHz jumper option -#define GPIO_IN_3_PORT GPIOB -#define GPIO_IN_3_PIN GPIO_Pin_8 -#define GPIO_IN_3_MODE GPIO_Mode_IPU - -// 915MHz jumper option -#define GPIO_IN_4_PORT GPIOB -#define GPIO_IN_4_PIN GPIO_Pin_9 -#define GPIO_IN_4_MODE GPIO_Mode_IPU - -// RF INT line -#define GPIO_IN_5_PORT GPIOA -#define GPIO_IN_5_PIN GPIO_Pin_2 -#define GPIO_IN_5_MODE GPIO_Mode_IN_FLOATING - -// RF misc line -#define GPIO_IN_6_PORT GPIOB -#define GPIO_IN_6_PIN GPIO_Pin_0 -#define GPIO_IN_6_MODE GPIO_Mode_IN_FLOATING - -// PPM IN line -#define PPM_IN_PORT GPIOB -#define PPM_IN_PIN GPIO_Pin_11 -#define PPM_IN_MODE GPIO_Mode_IPD - -#define GPIO_IN_NUM 8 -#define GPIO_IN_PORTS { GPIO_IN_0_PORT, GPIO_IN_1_PORT, GPIO_IN_2_PORT, GPIO_IN_3_PORT, GPIO_IN_4_PORT, GPIO_IN_5_PORT, GPIO_IN_6_PORT, PPM_IN_PORT } -#define GPIO_IN_PINS { GPIO_IN_0_PIN, GPIO_IN_1_PIN, GPIO_IN_2_PIN, GPIO_IN_3_PIN, GPIO_IN_4_PIN, GPIO_IN_5_PIN, GPIO_IN_6_PIN, PPM_IN_PIN } -#define GPIO_IN_MODES { GPIO_IN_0_MODE, GPIO_IN_1_MODE, GPIO_IN_2_MODE, GPIO_IN_3_MODE, GPIO_IN_4_MODE, GPIO_IN_5_MODE, GPIO_IN_6_MODE, PPM_IN_MODE } - -#define API_MODE_PIN 0 -#define SERIAL_CTS_PIN 1 -#define VBUS_SENSE_PIN 2 -#define _868MHz_PIN 3 -#define _915MHz_PIN 4 -#define RF_INT_PIN 5 -#define RF_MISC_PIN 6 - -#endif - // ***************************************************************** // USB @@ -435,33 +254,6 @@ extern uint32_t pios_com_telem_usb_id; #endif -#if 0 -// ***************************************************************** -// VIDEO -#define PIOS_VIDEO_HSYNC_GPIO_PORT GPIOD -#define PIOS_VIDEO_HSYNC_GPIO_PIN GPIO_Pin_0 -#define PIOS_VIDEO_HSYNC_PORT_SOURCE GPIO_PortSourceGPIOD -#define PIOS_VIDEO_HSYNC_PIN_SOURCE GPIO_PinSource0 -#define PIOS_VIDEO_HSYNC_CLK RCC_AHB1Periph_GPIOD -#define PIOS_VIDEO_HSYNC_EXTI_LINE EXTI_Line0 -#define PIOS_VIDEO_HSYNC_EXTI_PORT_SOURCE EXTI_PortSourceGPIOD -#define PIOS_VIDEO_HSYNC_EXTI_PIN_SOURCE EXTI_PinSource0 -#define PIOS_VIDEO_HSYNC_IRQn EXTI0_IRQn -#define PIOS_VIDEO_HSYNC_PRIO PIOS_IRQ_PRIO_HIGHEST -//#define PIOS_VIDEO_SYNC_PRIO 1 - -#define PIOS_VIDEO_VSYNC_GPIO_PORT GPIOC -#define PIOS_VIDEO_VSYNC_GPIO_PIN GPIO_Pin_11 -#define PIOS_VIDEO_VSYNC_PORT_SOURCE GPIO_PortSourceGPIOC -#define PIOS_VIDEO_VSYNC_PIN_SOURCE GPIO_PinSource11 -#define PIOS_VIDEO_VSYNC_CLK RCC_AHB1Periph_GPIOC -#define PIOS_VIDEO_VSYNC_EXTI_LINE EXTI_Line11 -#define PIOS_VIDEO_VSYNC_EXTI_PORT_SOURCE EXTI_PortSourceGPIOC -#define PIOS_VIDEO_VSYNC_EXTI_PIN_SOURCE EXTI_PinSource11 -#define PIOS_VIDEO_VSYNC_IRQn EXTI15_10_IRQn -#define PIOS_VIDEO_VSYNC_PRIO PIOS_IRQ_PRIO_HIGHEST -#endif - // ***************************************************************** //-------------------------- // Timer controller settings diff --git a/flight/board_hw_defs/osd/board_hw_defs.c b/flight/board_hw_defs/osd/board_hw_defs.c index e059142a1..4e96f3720 100644 --- a/flight/board_hw_defs/osd/board_hw_defs.c +++ b/flight/board_hw_defs/osd/board_hw_defs.c @@ -129,7 +129,7 @@ static const struct pios_usart_cfg pios_usart_aux_cfg = { .regs = USART2, .remap = GPIO_AF_USART2, .init = { - .USART_BaudRate = 230400, + .USART_BaudRate = 57600, .USART_WordLength = USART_WordLength_8b, .USART_Parity = USART_Parity_No, .USART_StopBits = USART_StopBits_1, @@ -217,56 +217,6 @@ static const struct pios_usart_cfg pios_usart_telem_main_cfg = { #endif /* PIOS_COM_TELEM */ - -#if 0 -/* - * COTelemetry on main USART - */ -static const struct pios_usart_cfg pios_usart_cotelem_main_cfg = { - .regs = UART4, - .remap = GPIO_AF_UART4, - .init = { - .USART_BaudRate = 57600, - .USART_WordLength = USART_WordLength_8b, - .USART_Parity = USART_Parity_No, - .USART_StopBits = USART_StopBits_1, - .USART_HardwareFlowControl = - USART_HardwareFlowControl_None, - .USART_Mode = USART_Mode_Rx | USART_Mode_Tx, - }, - .irq = { - .init = { - .NVIC_IRQChannel = UART4_IRQn, - .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_MID, - .NVIC_IRQChannelSubPriority = 0, - .NVIC_IRQChannelCmd = ENABLE, - }, - }, - .rx = { - .gpio = GPIOA, - .init = { - .GPIO_Pin = GPIO_Pin_1, - .GPIO_Speed = GPIO_Speed_2MHz, - .GPIO_Mode = GPIO_Mode_AF, - .GPIO_OType = GPIO_OType_PP, - .GPIO_PuPd = GPIO_PuPd_UP - }, - }, - .tx = { - .gpio = GPIOA, - .init = { - .GPIO_Pin = GPIO_Pin_0, - .GPIO_Speed = GPIO_Speed_2MHz, - .GPIO_Mode = GPIO_Mode_AF, - .GPIO_OType = GPIO_OType_PP, - .GPIO_PuPd = GPIO_PuPd_UP - }, - }, -}; - -#endif /* PIOS_COM_COTELEM */ - - #if defined(PIOS_INCLUDE_COM) #include