From 8b7c4a82edebc9634dae7a8effbed25272e32000 Mon Sep 17 00:00:00 2001 From: Arnaud Cadot Date: Thu, 17 Mar 2016 12:00:56 +0100 Subject: [PATCH] Fixed a bug in PositionList constructor --- stm32/src/hardware/remote.cpp | 2 +- stm32/src/hardware/tourelle.cpp | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/stm32/src/hardware/remote.cpp b/stm32/src/hardware/remote.cpp index 81c43ea6..5eb3bdbf 100644 --- a/stm32/src/hardware/remote.cpp +++ b/stm32/src/hardware/remote.cpp @@ -79,7 +79,7 @@ void Remote::initClocksAndPortsGPIO() { #ifdef STM32F10X_CL //H107 - /* Bit configuration structure for GPIOA PIN9 and PIN10 */ + /* Bit configuration structure for GPIOB PIN6 and PIN7 */ GPIO_InitTypeDef gpioa_init_struct; /* Enalbe clock for USART1, AFIO and GPIOA */ diff --git a/stm32/src/hardware/tourelle.cpp b/stm32/src/hardware/tourelle.cpp index dccc1927..eba3b790 100644 --- a/stm32/src/hardware/tourelle.cpp +++ b/stm32/src/hardware/tourelle.cpp @@ -40,11 +40,13 @@ void PositionsList::reserve(unsigned int i) memset(ptr, 0, i*sizeof(PositionData)); m_usedSize = min(m_usedSize, i); - m_allocatedSize=i; - - memcpy(ptr, m_array, m_usedSize*sizeof(PositionData)); - - delete m_array; + m_allocatedSize=i; + + if(m_array != 0) + { + memcpy(ptr, m_array, m_usedSize*sizeof(PositionData)); + delete m_array; + } m_array = ptr; } @@ -114,7 +116,7 @@ PositionsList PositionsList::fromQList(const QList& list) //////////////////// #ifdef ROBOTHW void Tourelle::initClocksAndPortsGPIO(uint32_t usart_rcc_index, uint32_t usart_af, GPIO_TypeDef* GPIOx_RX, uint16_t GPIO_Pin_RX, GPIO_TypeDef* GPIOx_TX, uint16_t GPIO_Pin_TX) -{//processeur : pour faire les recherches, c'est en fait f10 pour h107, et f04 pour h405 +{//processeur : pour faire les recherches, c'est en fait f10 pour h107, et f4 pour h405 #ifdef STM32F40_41xxx // For stm32 h405 RCC_APB1PeriphClockCmd(usart_rcc_index, ENABLE); @@ -201,7 +203,7 @@ Tourelle::Tourelle() initUART(TURRET_USART_INDEX, USART_BAUDRATE); #endif #ifdef STM32F40_41xxx // For stm32 h405 - + // TODO #endif #endif -- GitLab