1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Small updates and clean up.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@355 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
gussy 2010-03-21 00:49:48 +00:00 committed by gussy
parent 58e4dd4757
commit a03952fb5d
8 changed files with 79 additions and 72 deletions

View File

@ -139,6 +139,7 @@ SRC += $(PIOSSTM32F10X)/pios_usb.c
SRC += $(PIOSSTM32F10X)/pios_usb_hid.c
SRC += $(PIOSSTM32F10X)/pios_debug.c
SRC += $(PIOSSTM32F10X)/pios_gpio.c
SRC += $(PIOSSTM32F10X)/pios_exti.c
## PIOS Hardware (Common)
SRC += $(PIOSCOMMON)/pios_sdcard.c

View File

@ -56,7 +56,7 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8
/* Channel 5 - SPI2 TX */
/* Channel 6 - */
/* Channel 7 - */
/* Channel 8 - */
/* Channel 8 - */
/* Channel 9 - */
/* Channel 10 - */
/* Channel 11 - */
@ -222,59 +222,51 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8
//-------------------------
// Receiver PWM inputs
//-------------------------
#define RECEIVER1_GPIO_PORT GPIOA
#define RECEIVER1_PIN GPIO_Pin_9
#define RECEIVER1_TIM_PORT TIM1
#define RECEIVER1_CH TIM_Channel_2
#define RECEIVER1_CCR TIM_IT_CC2
#define RECEIVER2_GPIO_PORT GPIOA
#define RECEIVER2_PIN GPIO_Pin_10
#define RECEIVER2_TIM_PORT TIM1
#define RECEIVER2_CH TIM_Channel_3
#define RECEIVER2_CCR TIM_IT_CC3
#define RECEIVER3_GPIO_PORT GPIOA
#define RECEIVER3_PIN GPIO_Pin_0
#define RECEIVER3_TIM_PORT TIM5
#define RECEIVER3_CH TIM_Channel_1
#define RECEIVER3_CCR TIM_IT_CC1
#define RECEIVER4_GPIO_PORT GPIOA
#define RECEIVER4_PIN GPIO_Pin_8
#define RECEIVER4_TIM_PORT TIM1
#define RECEIVER4_CH TIM_Channel_1
#define RECEIVER4_CCR TIM_IT_CC1
#define RECEIVER5_GPIO_PORT GPIOB
#define RECEIVER5_PIN GPIO_Pin_1
#define RECEIVER5_TIM_PORT TIM3
#define RECEIVER5_CH TIM_Channel_4
#define RECEIVER5_CCR TIM_IT_CC4
#define RECEIVER6_GPIO_PORT GPIOB
#define RECEIVER6_PIN GPIO_Pin_0
#define RECEIVER6_TIM_PORT TIM3
#define RECEIVER6_CH TIM_Channel_3
#define RECEIVER6_CCR TIM_IT_CC3
#define RECEIVER7_GPIO_PORT GPIOB
#define RECEIVER7_PIN GPIO_Pin_4
#define RECEIVER7_TIM_PORT TIM3
#define RECEIVER7_CH TIM_Channel_1
#define RECEIVER7_CCR TIM_IT_CC1
#define RECEIVER8_GPIO_PORT GPIOB
#define RECEIVER8_PIN GPIO_Pin_5
#define RECEIVER8_TIM_PORT TIM3
#define RECEIVER8_CH TIM_Channel_2
#define RECEIVER8_CCR TIM_IT_CC2
#define PIOS_PWM_GPIO_PORTS { RECEIVER1_GPIO_PORT, RECEIVER2_GPIO_PORT, RECEIVER3_GPIO_PORT, RECEIVER4_GPIO_PORT, RECEIVER5_GPIO_PORT, RECEIVER6_GPIO_PORT, RECEIVER7_GPIO_PORT, RECEIVER8_GPIO_PORT }
#define PIOS_PWM_GPIO_PINS { RECEIVER1_PIN, RECEIVER2_PIN, RECEIVER3_PIN, RECEIVER4_PIN, RECEIVER5_PIN, RECEIVER6_PIN, RECEIVER7_PIN, RECEIVER8_PIN }
#define PIOS_PWM_TIM_PORTS { RECEIVER1_TIM_PORT, RECEIVER2_TIM_PORT, RECEIVER3_TIM_PORT, RECEIVER4_TIM_PORT, RECEIVER5_TIM_PORT, RECEIVER6_TIM_PORT, RECEIVER7_TIM_PORT, RECEIVER8_TIM_PORT }
#define PIOS_PWM_TIM_CHANNELS { RECEIVER1_CH, RECEIVER2_CH, RECEIVER3_CH, RECEIVER4_CH, RECEIVER5_CH, RECEIVER6_CH, RECEIVER7_CH, RECEIVER8_CH }
#define PIOS_PWM_TIM_CCRS { RECEIVER1_CCR, RECEIVER2_CCR, RECEIVER3_CCR, RECEIVER4_CCR, RECEIVER5_CCR, RECEIVER6_CCR, RECEIVER7_CCR, RECEIVER8_CCR }
#define PIOS_PWM_CH1_GPIO_PORT GPIOA
#define PIOS_PWM_CH1_PIN GPIO_Pin_9
#define PIOS_PWM_CH1_TIM_PORT TIM1
#define PIOS_PWM_CH1_CH TIM_Channel_2
#define PIOS_PWM_CH1_CCR TIM_IT_CC2
#define PIOS_PWM_CH2_GPIO_PORT GPIOA
#define PIOS_PWM_CH2_PIN GPIO_Pin_10
#define PIOS_PWM_CH2_TIM_PORT TIM1
#define PIOS_PWM_CH2_CH TIM_Channel_3
#define PIOS_PWM_CH2_CCR TIM_IT_CC3
#define PIOS_PWM_CH3_GPIO_PORT GPIOA
#define PIOS_PWM_CH3_PIN GPIO_Pin_0
#define PIOS_PWM_CH3_TIM_PORT TIM5
#define PIOS_PWM_CH3_CH TIM_Channel_1
#define PIOS_PWM_CH3_CCR TIM_IT_CC1
#define PIOS_PWM_CH4_GPIO_PORT GPIOA
#define PIOS_PWM_CH4_PIN GPIO_Pin_8
#define PIOS_PWM_CH4_TIM_PORT TIM1
#define PIOS_PWM_CH4_CH TIM_Channel_1
#define PIOS_PWM_CH4_CCR TIM_IT_CC1
#define PIOS_PWM_CH5_GPIO_PORT GPIOB
#define PIOS_PWM_CH5_PIN GPIO_Pin_1
#define PIOS_PWM_CH5_TIM_PORT TIM3
#define PIOS_PWM_CH5_CH TIM_Channel_4
#define PIOS_PWM_CH5_CCR TIM_IT_CC4
#define PIOS_PWM_CH6_GPIO_PORT GPIOB
#define PIOS_PWM_CH6_PIN GPIO_Pin_0
#define PIOS_PWM_CH6_TIM_PORT TIM3
#define PIOS_PWM_CH6_CH TIM_Channel_3
#define PIOS_PWM_CH6_CCR TIM_IT_CC3
#define PIOS_PWM_CH7_GPIO_PORT GPIOB
#define PIOS_PWM_CH7_PIN GPIO_Pin_4
#define PIOS_PWM_CH7_TIM_PORT TIM3
#define PIOS_PWM_CH7_CH TIM_Channel_1
#define PIOS_PWM_CH7_CCR TIM_IT_CC1
#define PIOS_PWM_CH8_GPIO_PORT GPIOB
#define PIOS_PWM_CH8_PIN GPIO_Pin_5
#define PIOS_PWM_CH8_TIM_PORT TIM3
#define PIOS_PWM_CH8_CH TIM_Channel_2
#define PIOS_PWM_CH8_CCR TIM_IT_CC2
#define PIOS_PWM_GPIO_PORTS { PIOS_PWM_CH1_GPIO_PORT, PIOS_PWM_CH2_GPIO_PORT, PIOS_PWM_CH3_GPIO_PORT, PIOS_PWM_CH4_GPIO_PORT, PIOS_PWM_CH5_GPIO_PORT, PIOS_PWM_CH6_GPIO_PORT, PIOS_PWM_CH7_GPIO_PORT, PIOS_PWM_CH8_GPIO_PORT }
#define PIOS_PWM_GPIO_PINS { PIOS_PWM_CH1_PIN, PIOS_PWM_CH2_PIN, PIOS_PWM_CH3_PIN, PIOS_PWM_CH4_PIN, PIOS_PWM_CH5_PIN, PIOS_PWM_CH6_PIN, PIOS_PWM_CH7_PIN, PIOS_PWM_CH8_PIN }
#define PIOS_PWM_TIM_PORTS { PIOS_PWM_CH1_TIM_PORT, PIOS_PWM_CH2_TIM_PORT, PIOS_PWM_CH3_TIM_PORT, PIOS_PWM_CH4_TIM_PORT, PIOS_PWM_CH5_TIM_PORT, PIOS_PWM_CH6_TIM_PORT, PIOS_PWM_CH7_TIM_PORT, PIOS_PWM_CH8_TIM_PORT }
#define PIOS_PWM_TIM_CHANNELS { PIOS_PWM_CH1_CH, PIOS_PWM_CH2_CH, PIOS_PWM_CH3_CH, PIOS_PWM_CH4_CH, PIOS_PWM_CH5_CH, PIOS_PWM_CH6_CH, PIOS_PWM_CH7_CH, PIOS_PWM_CH8_CH }
#define PIOS_PWM_TIM_CCRS { PIOS_PWM_CH1_CCR, PIOS_PWM_CH2_CCR, PIOS_PWM_CH3_CCR, PIOS_PWM_CH4_CCR, PIOS_PWM_CH5_CCR, PIOS_PWM_CH6_CCR, PIOS_PWM_CH7_CCR, PIOS_PWM_CH8_CCR }
#define PIOS_PWM_TIMS { TIM1, TIM3, TIM5 }
#define PIOS_PWM_TIM_IRQS { TIM1_CC_IRQn, TIM3_IRQn, TIM5_IRQn }
#define PIOS_PWM_NUM_INPUTS 8
@ -289,11 +281,11 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8
//-------------------------
// Receiver PPM input
//-------------------------
#define PIOS_PPM_GPIO_PORT RECEIVER1_GPIO_PORT
#define PIOS_PPM_GPIO_PIN RECEIVER1_PIN
#define PIOS_PPM_TIM_PORT RECEIVER1_TIM_PORT
#define PIOS_PPM_TIM_CHANNEL RECEIVER1_CH
#define PIOS_PPM_TIM_CCR RECEIVER1_CCR
#define PIOS_PPM_GPIO_PORT PIOS_PWM_CH1_GPIO_PORT
#define PIOS_PPM_GPIO_PIN PIOS_PWM_CH1_PIN
#define PIOS_PPM_TIM_PORT PIOS_PWM_CH1_TIM_PORT
#define PIOS_PPM_TIM_CHANNEL PIOS_PWM_CH1_CH
#define PIOS_PPM_TIM_CCR PIOS_PWM_CH1_CCR
#define PIOS_PPM_TIM TIM1
#define PIOS_PPM_TIM_IRQ TIM1_CC_IRQn
#define PIOS_PPM_NUM_INPUTS 8 //Could be more if needed
@ -377,9 +369,16 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8
#define PIOS_ADC_NUM_ADC_CHANNELS 2
#define PIOS_ADC_USE_ADC2 1
#define PIOS_ADC_CLOCK_FUNCTION RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2, ENABLE)
#define PIOS_ADC_SAMPLE_TIME ADC_SampleTime_239Cycles5 /* Sample time: */
/* With an ADCCLK = 14 MHz and a sampling time of 293.5 cycles: */
/* Tconv = 239.5 + 12.5 = 252 cycles = 18<31>s */
#define PIOS_ADC_ADCCLK RCC_PCLK2_Div8
/* RCC_PCLK2_Div2: ADC clock = PCLK2/2 */
/* RCC_PCLK2_Div4: ADC clock = PCLK2/4 */
/* RCC_PCLK2_Div6: ADC clock = PCLK2/6 */
/* RCC_PCLK2_Div8: ADC clock = PCLK2/8 */
#define PIOS_ADC_SAMPLE_TIME ADC_SampleTime_239Cycles5
/* Sample time: */
/* With an ADCCLK = 14 MHz and a sampling time of 293.5 cycles: */
/* Tconv = 239.5 + 12.5 = 252 cycles = 18µs */
/* (1 / (ADCCLK / CYCLES)) = Sample Time (µS) */
#define PIOS_ADC_IRQ_PRIO PIOS_IRQ_PRIO_HIGH
//-------------------------
@ -408,6 +407,7 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8
#define PIOS_USB_ENABLED 1
#define PIOS_USB_DETECT_GPIO_PORT GPIOC
#define PIOS_USB_DETECT_GPIO_PIN GPIO_Pin_4
#define PIOS_USB_DETECT_EXTI_LINE EXTI_Line4
#define PIOS_IRQ_USB_PRIORITY PIOS_IRQ_PRIO_MID
#endif /* PIOS_BOARD_H */

View File

@ -50,6 +50,7 @@
#define PIOS_INCLUDE_SETTINGS
#define PIOS_INCLUDE_FREERTOS
#define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_EXTI
/* Defaults for Logging */

View File

@ -281,7 +281,7 @@ int32_t PIOS_SDCARD_CheckAvailable(uint8_t was_available)
PIOS_SPI_RC_PinSet(PIOS_SDCARD_SPI, 1); /* spi, pin_value */
/* send 80 clock cycles to start up */
uint8_t i;
for(i=0; i<10; ++i) {
for(i = 0; i < 10; ++i) {
PIOS_SPI_TransferByte(PIOS_SDCARD_SPI, 0xff);
}
@ -293,11 +293,11 @@ int32_t PIOS_SDCARD_CheckAvailable(uint8_t was_available)
goto not_available;
}
//* Deactivate chip select */
/* Deactivate chip select */
PIOS_SPI_RC_PinSet(PIOS_SDCARD_SPI, 1); /* spi, pin_value */
SDCARD_MUTEX_GIVE;
/* run power-on sequence (negative return = not available) */
/* Run power-on sequence (negative return = not available) */
ret = PIOS_SDCARD_PowerOn();
}

View File

@ -106,6 +106,8 @@ void PIOS_ADC_Init(void)
ADC_ExternalTrigConvCmd(ADC2, ENABLE);
#endif
//RCC_ADCCLKConfig(PIOS_ADC_ADCCLK);
/* Enable ADC1->DMA request */
ADC_DMACmd(ADC1, ENABLE);

View File

@ -49,7 +49,7 @@ void PIOS_GPIO_Init(void)
}
/**
* Turn on Pin
* Enable a GPIO Pin
* \param[in] Pin Pin Number
*/
void PIOS_GPIO_Enable(uint8_t Pin)

View File

@ -172,16 +172,16 @@ int32_t PIOS_PPM_Get(int8_t Channel)
void TIM1_CC_IRQHandler(void)
{
/* Do this as it's more efficient */
if(TIM_GetITStatus(RECEIVER1_TIM_PORT, RECEIVER1_CCR) == SET) {
if(TIM_GetITStatus(PIOS_PWM_CH1_TIM_PORT, RECEIVER1_CCR) == SET) {
if(CaptureState == 0) {
RiseValue = TIM_GetCapture2(RECEIVER1_TIM_PORT);
RiseValue = TIM_GetCapture2(PIOS_PWM_CH1_TIM_PORT);
} else {
FallValue = TIM_GetCapture2(RECEIVER1_TIM_PORT);
FallValue = TIM_GetCapture2(PIOS_PWM_CH1_TIM_PORT);
}
}
/* Clear TIM3 Capture compare interrupt pending bit */
TIM_ClearITPendingBit(RECEIVER1_TIM_PORT, RECEIVER1_CCR);
TIM_ClearITPendingBit(PIOS_PWM_CH1_TIM_PORT, RECEIVER1_CCR);
/* Simple rise or fall state machine */
if(CaptureState == 0) {
@ -191,7 +191,7 @@ void TIM1_CC_IRQHandler(void)
/* Switch polarity of input capture */
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Falling;
TIM_ICInitStructure.TIM_Channel = RECEIVER1_CH;
TIM_ICInit(RECEIVER1_TIM_PORT, &TIM_ICInitStructure);
TIM_ICInit(PIOS_PWM_CH1_TIM_PORT, &TIM_ICInitStructure);
} else {
/* Capture computation */
@ -212,7 +212,7 @@ void TIM1_CC_IRQHandler(void)
/* Switch polarity of input capture */
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_Channel = RECEIVER1_CH;
TIM_ICInit(RECEIVER1_TIM_PORT, &TIM_ICInitStructure);
TIM_ICInit(PIOS_PWM_CH1_TIM_PORT, &TIM_ICInitStructure);
}
}

View File

@ -78,6 +78,9 @@
#include <pios_usb_hid.h>
#include <pios_debug.h>
#include <pios_gpio.h>
#if defined(PIOS_INCLUDE_EXTI)
#include <pios_exti.h>
#endif
/* PIOS Hardware Includes (Common) */
#include <pios_settings.h>