summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
Diffstat (limited to 'bsp')
-rw-r--r--bsp/radio-controller-1/Inc/main.h4
-rw-r--r--bsp/radio-controller-1/Inc/stm32f1xx_hal_conf.h2
-rw-r--r--bsp/radio-controller-1/Inc/stm32f1xx_it.h1
-rw-r--r--bsp/radio-controller-1/Src/main.c73
-rw-r--r--bsp/radio-controller-1/Src/stm32f1xx_hal_msp.c51
-rw-r--r--bsp/radio-controller-1/Src/stm32f1xx_it.c15
-rw-r--r--bsp/radio-controller-1/Src/usbd_conf.c4
-rw-r--r--bsp/radio-controller-1/radio-controller-1.gpdsc4
-rw-r--r--bsp/radio-controller-1/radio-controller-1.ioc67
9 files changed, 189 insertions, 32 deletions
diff --git a/bsp/radio-controller-1/Inc/main.h b/bsp/radio-controller-1/Inc/main.h
index 89bca50..49efff9 100644
--- a/bsp/radio-controller-1/Inc/main.h
+++ b/bsp/radio-controller-1/Inc/main.h
@@ -51,8 +51,12 @@
/* Private define ------------------------------------------------------------*/
#define RADIO_RX_TIMER_PRESCALER (72000000/200000 - 1)
+#define IR_RX_Pin GPIO_PIN_0
+#define IR_RX_GPIO_Port GPIOA
#define RADIO_RX_Pin GPIO_PIN_8
#define RADIO_RX_GPIO_Port GPIOA
+#define DEBUG_PIN_Pin GPIO_PIN_10
+#define DEBUG_PIN_GPIO_Port GPIOA
/* USER CODE BEGIN Private defines */
#ifdef __cplusplus
diff --git a/bsp/radio-controller-1/Inc/stm32f1xx_hal_conf.h b/bsp/radio-controller-1/Inc/stm32f1xx_hal_conf.h
index eb2b5ca..917c203 100644
--- a/bsp/radio-controller-1/Inc/stm32f1xx_hal_conf.h
+++ b/bsp/radio-controller-1/Inc/stm32f1xx_hal_conf.h
@@ -133,7 +133,7 @@
* @brief This is the HAL system configuration section
*/
#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */
-#define TICK_INT_PRIORITY ((uint32_t)0) /*!< tick interrupt priority (lowest by default) */
+#define TICK_INT_PRIORITY ((uint32_t)1) /*!< tick interrupt priority (lowest by default) */
#define USE_RTOS 0
#define PREFETCH_ENABLE 1
diff --git a/bsp/radio-controller-1/Inc/stm32f1xx_it.h b/bsp/radio-controller-1/Inc/stm32f1xx_it.h
index f56b635..1d63a91 100644
--- a/bsp/radio-controller-1/Inc/stm32f1xx_it.h
+++ b/bsp/radio-controller-1/Inc/stm32f1xx_it.h
@@ -58,6 +58,7 @@ void USB_HP_CAN1_TX_IRQHandler(void);
void USB_LP_CAN1_RX0_IRQHandler(void);
void TIM1_TRG_COM_IRQHandler(void);
void TIM1_CC_IRQHandler(void);
+void TIM2_IRQHandler(void);
#ifdef __cplusplus
}
diff --git a/bsp/radio-controller-1/Src/main.c b/bsp/radio-controller-1/Src/main.c
index d7e4c04..dbcf975 100644
--- a/bsp/radio-controller-1/Src/main.c
+++ b/bsp/radio-controller-1/Src/main.c
@@ -54,6 +54,7 @@
IWDG_HandleTypeDef hiwdg;
TIM_HandleTypeDef htim1;
+TIM_HandleTypeDef htim2;
UART_HandleTypeDef huart2;
@@ -68,6 +69,7 @@ void Error_Handler(void);
static void MX_GPIO_Init(void);
static void MX_IWDG_Init(void);
static void MX_TIM1_Init(void);
+static void MX_TIM2_Init(void);
static void MX_USART2_UART_Init(void);
/* USER CODE BEGIN PFP */
@@ -98,6 +100,7 @@ int main(void)
MX_GPIO_Init();
MX_IWDG_Init();
MX_TIM1_Init();
+ MX_TIM2_Init();
MX_USART2_UART_Init();
MX_USB_DEVICE_Init();
@@ -172,7 +175,7 @@ void SystemClock_Config(void)
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
/* SysTick_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
+ HAL_NVIC_SetPriority(SysTick_IRQn, 1, 0);
}
/* IWDG init function */
@@ -240,6 +243,63 @@ static void MX_TIM1_Init(void)
}
+/* TIM2 init function */
+static void MX_TIM2_Init(void)
+{
+
+ TIM_SlaveConfigTypeDef sSlaveConfig;
+ TIM_MasterConfigTypeDef sMasterConfig;
+ TIM_IC_InitTypeDef sConfigIC;
+
+ htim2.Instance = TIM2;
+ htim2.Init.Prescaler = RADIO_RX_TIMER_PRESCALER;
+ htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
+ htim2.Init.Period = 0xffff;
+ htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
+ if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
+ {
+ Error_Handler();
+ }
+
+ if (HAL_TIM_IC_Init(&htim2) != HAL_OK)
+ {
+ Error_Handler();
+ }
+
+ sSlaveConfig.SlaveMode = TIM_SLAVEMODE_RESET;
+ sSlaveConfig.InputTrigger = TIM_TS_TI1FP1;
+ sSlaveConfig.TriggerPolarity = TIM_INPUTCHANNELPOLARITY_FALLING;
+ sSlaveConfig.TriggerFilter = 0;
+ if (HAL_TIM_SlaveConfigSynchronization(&htim2, &sSlaveConfig) != HAL_OK)
+ {
+ Error_Handler();
+ }
+
+ sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
+ sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
+ if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
+ {
+ Error_Handler();
+ }
+
+ sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_FALLING;
+ sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI;
+ sConfigIC.ICPrescaler = TIM_ICPSC_DIV1;
+ sConfigIC.ICFilter = 0;
+ if (HAL_TIM_IC_ConfigChannel(&htim2, &sConfigIC, TIM_CHANNEL_1) != HAL_OK)
+ {
+ Error_Handler();
+ }
+
+ sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_RISING;
+ sConfigIC.ICSelection = TIM_ICSELECTION_INDIRECTTI;
+ if (HAL_TIM_IC_ConfigChannel(&htim2, &sConfigIC, TIM_CHANNEL_2) != HAL_OK)
+ {
+ Error_Handler();
+ }
+
+}
+
/* USART2 init function */
static void MX_USART2_UART_Init(void)
{
@@ -269,11 +329,22 @@ static void MX_USART2_UART_Init(void)
static void MX_GPIO_Init(void)
{
+ GPIO_InitTypeDef GPIO_InitStruct;
+
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
+ /*Configure GPIO pin Output Level */
+ HAL_GPIO_WritePin(DEBUG_PIN_GPIO_Port, DEBUG_PIN_Pin, GPIO_PIN_RESET);
+
+ /*Configure GPIO pin : DEBUG_PIN_Pin */
+ GPIO_InitStruct.Pin = DEBUG_PIN_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(DEBUG_PIN_GPIO_Port, &GPIO_InitStruct);
+
}
/* USER CODE BEGIN 4 */
diff --git a/bsp/radio-controller-1/Src/stm32f1xx_hal_msp.c b/bsp/radio-controller-1/Src/stm32f1xx_hal_msp.c
index 5ee7f9a..49e9623 100644
--- a/bsp/radio-controller-1/Src/stm32f1xx_hal_msp.c
+++ b/bsp/radio-controller-1/Src/stm32f1xx_hal_msp.c
@@ -75,7 +75,7 @@ void HAL_MspInit(void)
/* PendSV_IRQn interrupt configuration */
HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0);
/* SysTick_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
+ HAL_NVIC_SetPriority(SysTick_IRQn, 1, 0);
/**NOJTAG: JTAG-DP Disabled and SW-DP Enabled
*/
@@ -107,14 +107,37 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
HAL_GPIO_Init(RADIO_RX_GPIO_Port, &GPIO_InitStruct);
/* Peripheral interrupt init */
- HAL_NVIC_SetPriority(TIM1_TRG_COM_IRQn, 1, 0);
+ HAL_NVIC_SetPriority(TIM1_TRG_COM_IRQn, 10, 0);
HAL_NVIC_EnableIRQ(TIM1_TRG_COM_IRQn);
- HAL_NVIC_SetPriority(TIM1_CC_IRQn, 1, 0);
+ HAL_NVIC_SetPriority(TIM1_CC_IRQn, 10, 0);
HAL_NVIC_EnableIRQ(TIM1_CC_IRQn);
/* USER CODE BEGIN TIM1_MspInit 1 */
/* USER CODE END TIM1_MspInit 1 */
}
+ else if(htim_base->Instance==TIM2)
+ {
+ /* USER CODE BEGIN TIM2_MspInit 0 */
+
+ /* USER CODE END TIM2_MspInit 0 */
+ /* Peripheral clock enable */
+ __HAL_RCC_TIM2_CLK_ENABLE();
+
+ /**TIM2 GPIO Configuration
+ PA0-WKUP ------> TIM2_CH1
+ */
+ GPIO_InitStruct.Pin = IR_RX_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(IR_RX_GPIO_Port, &GPIO_InitStruct);
+
+ /* Peripheral interrupt init */
+ HAL_NVIC_SetPriority(TIM2_IRQn, 10, 0);
+ HAL_NVIC_EnableIRQ(TIM2_IRQn);
+ /* USER CODE BEGIN TIM2_MspInit 1 */
+
+ /* USER CODE END TIM2_MspInit 1 */
+ }
}
@@ -139,10 +162,30 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
HAL_NVIC_DisableIRQ(TIM1_CC_IRQn);
- }
/* USER CODE BEGIN TIM1_MspDeInit 1 */
/* USER CODE END TIM1_MspDeInit 1 */
+ }
+ else if(htim_base->Instance==TIM2)
+ {
+ /* USER CODE BEGIN TIM2_MspDeInit 0 */
+
+ /* USER CODE END TIM2_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_TIM2_CLK_DISABLE();
+
+ /**TIM2 GPIO Configuration
+ PA0-WKUP ------> TIM2_CH1
+ */
+ HAL_GPIO_DeInit(IR_RX_GPIO_Port, IR_RX_Pin);
+
+ /* Peripheral interrupt DeInit*/
+ HAL_NVIC_DisableIRQ(TIM2_IRQn);
+
+ /* USER CODE BEGIN TIM2_MspDeInit 1 */
+
+ /* USER CODE END TIM2_MspDeInit 1 */
+ }
}
diff --git a/bsp/radio-controller-1/Src/stm32f1xx_it.c b/bsp/radio-controller-1/Src/stm32f1xx_it.c
index 67cbc69..2edc0a7 100644
--- a/bsp/radio-controller-1/Src/stm32f1xx_it.c
+++ b/bsp/radio-controller-1/Src/stm32f1xx_it.c
@@ -42,6 +42,7 @@
/* External variables --------------------------------------------------------*/
extern PCD_HandleTypeDef hpcd_USB_FS;
extern TIM_HandleTypeDef htim1;
+extern TIM_HandleTypeDef htim2;
/******************************************************************************/
/* Cortex-M3 Processor Interruption and Exception Handlers */
@@ -241,6 +242,20 @@ void TIM1_CC_IRQHandler(void)
/* USER CODE END TIM1_CC_IRQn 1 */
}
+/**
+* @brief This function handles TIM2 global interrupt.
+*/
+void TIM2_IRQHandler(void)
+{
+ /* USER CODE BEGIN TIM2_IRQn 0 */
+
+ /* USER CODE END TIM2_IRQn 0 */
+ HAL_TIM_IRQHandler(&htim2);
+ /* USER CODE BEGIN TIM2_IRQn 1 */
+
+ /* USER CODE END TIM2_IRQn 1 */
+}
+
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
diff --git a/bsp/radio-controller-1/Src/usbd_conf.c b/bsp/radio-controller-1/Src/usbd_conf.c
index 858fb0c..ea64758 100644
--- a/bsp/radio-controller-1/Src/usbd_conf.c
+++ b/bsp/radio-controller-1/Src/usbd_conf.c
@@ -79,9 +79,9 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
__HAL_RCC_USB_CLK_ENABLE();
/* Peripheral interrupt init */
- HAL_NVIC_SetPriority(USB_HP_CAN1_TX_IRQn, 0, 0);
+ HAL_NVIC_SetPriority(USB_HP_CAN1_TX_IRQn, 2, 0);
HAL_NVIC_EnableIRQ(USB_HP_CAN1_TX_IRQn);
- HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 0, 0);
+ HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 2, 0);
HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
/* USER CODE BEGIN USB_MspInit 1 */
diff --git a/bsp/radio-controller-1/radio-controller-1.gpdsc b/bsp/radio-controller-1/radio-controller-1.gpdsc
index 8d085bb..5ebbb9d 100644
--- a/bsp/radio-controller-1/radio-controller-1.gpdsc
+++ b/bsp/radio-controller-1/radio-controller-1.gpdsc
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- ******************************************************************************
* File Name : radio-controller-1.gpdsc
- * Date : 30/05/2017 22:50:29
+ * Date : 03/06/2017 13:16:33
* Description : Generator PDSC File generated by STM32CubeMX (DO NOT EDIT!)
****************************************************************************** -->
@@ -11,7 +11,7 @@
<description>STM32CubeMX generated pack description</description>
<releases>
<release version="1.0.0">
- - Generated: 30/05/2017 22:50:29
+ - Generated: 03/06/2017 13:16:33
</release>
</releases>
<requirements>
diff --git a/bsp/radio-controller-1/radio-controller-1.ioc b/bsp/radio-controller-1/radio-controller-1.ioc
index 11a988f..33865c7 100644
--- a/bsp/radio-controller-1/radio-controller-1.ioc
+++ b/bsp/radio-controller-1/radio-controller-1.ioc
@@ -7,28 +7,32 @@ Mcu.IP1=NVIC
Mcu.IP2=RCC
Mcu.IP3=SYS
Mcu.IP4=TIM1
-Mcu.IP5=USART2
-Mcu.IP6=USB
-Mcu.IP7=USB_DEVICE
-Mcu.IPNb=8
+Mcu.IP5=TIM2
+Mcu.IP6=USART2
+Mcu.IP7=USB
+Mcu.IP8=USB_DEVICE
+Mcu.IPNb=9
Mcu.Name=STM32F103C(4-6)Tx
Mcu.Package=LQFP48
Mcu.Pin0=PC14-OSC32_IN
Mcu.Pin1=PC15-OSC32_OUT
-Mcu.Pin10=PA14
-Mcu.Pin11=VP_IWDG_VS_IWDG
-Mcu.Pin12=VP_SYS_VS_Systick
-Mcu.Pin13=VP_TIM1_VS_ControllerModeReset
-Mcu.Pin14=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS
+Mcu.Pin10=PA12
+Mcu.Pin11=PA13
+Mcu.Pin12=PA14
+Mcu.Pin13=VP_IWDG_VS_IWDG
+Mcu.Pin14=VP_SYS_VS_Systick
+Mcu.Pin15=VP_TIM1_VS_ControllerModeReset
+Mcu.Pin16=VP_TIM2_VS_ControllerModeReset
+Mcu.Pin17=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS
Mcu.Pin2=PD0-OSC_IN
Mcu.Pin3=PD1-OSC_OUT
-Mcu.Pin4=PA2
-Mcu.Pin5=PA3
-Mcu.Pin6=PA8
-Mcu.Pin7=PA11
-Mcu.Pin8=PA12
-Mcu.Pin9=PA13
-Mcu.PinsNb=15
+Mcu.Pin4=PA0-WKUP
+Mcu.Pin5=PA2
+Mcu.Pin6=PA3
+Mcu.Pin7=PA8
+Mcu.Pin8=PA10
+Mcu.Pin9=PA11
+Mcu.PinsNb=18
Mcu.UserConstants=RADIO_RX_TIMER_PRESCALER,(72000000/200000 - 1)
Mcu.UserName=STM32F103C6Tx
MxCube.Version=4.20.1
@@ -41,12 +45,19 @@ NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true
-NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true
-NVIC.TIM1_CC_IRQn=true\:1\:0\:true\:false\:true
-NVIC.TIM1_TRG_COM_IRQn=true\:1\:0\:true\:false\:true
-NVIC.USB_HP_CAN1_TX_IRQn=true\:0\:0\:false\:false\:true
-NVIC.USB_LP_CAN1_RX0_IRQn=true\:0\:0\:false\:false\:true
+NVIC.SysTick_IRQn=true\:1\:0\:true\:false\:true
+NVIC.TIM1_CC_IRQn=true\:10\:0\:true\:false\:true
+NVIC.TIM1_TRG_COM_IRQn=true\:10\:0\:true\:false\:true
+NVIC.TIM2_IRQn=true\:10\:0\:true\:false\:true
+NVIC.USB_HP_CAN1_TX_IRQn=true\:2\:0\:true\:false\:true
+NVIC.USB_LP_CAN1_RX0_IRQn=true\:2\:0\:true\:false\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true
+PA0-WKUP.GPIOParameters=GPIO_Label
+PA0-WKUP.GPIO_Label=IR_RX
+PA0-WKUP.Signal=S_TIM2_CH1_ETR
+PA10.GPIOParameters=GPIO_Label
+PA10.GPIO_Label=DEBUG_PIN
+PA10.Signal=GPIO_Output
PA11.Mode=Device
PA11.Signal=USB_DM
PA12.Mode=Device
@@ -102,7 +113,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=Other Toolchains (GPDSC)
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false
-ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL,2-SystemClock_Config-RCC-false-HAL,3-MX_IWDG_Init-IWDG-false-HAL,4-MX_TIM1_Init-TIM1-false-HAL,5-MX_USART2_UART_Init-USART2-false-HAL,6-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL
+ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL,2-SystemClock_Config-RCC-false-HAL,3-MX_IWDG_Init-IWDG-false-HAL,4-MX_TIM1_Init-TIM1-false-HAL,5-MX_TIM2_Init-TIM2-false-HAL,6-MX_USART2_UART_Init-USART2-false-HAL,7-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL
RCC.ADCFreqValue=36000000
RCC.AHBFreq_Value=72000000
RCC.APB1CLKDivider=RCC_HCLK_DIV2
@@ -128,12 +139,22 @@ RCC.VCOOutput2Freq_Value=8000000
SH.S_TIM1_CH1.0=TIM1_CH1,Input_Capture1_from_TI1
SH.S_TIM1_CH1.1=TIM1_CH1,TriggerSource_TI1FP1
SH.S_TIM1_CH1.ConfNb=2
+SH.S_TIM2_CH1_ETR.0=TIM2_CH1,TriggerSource_TI1FP1
+SH.S_TIM2_CH1_ETR.1=TIM2_CH1,Input_Capture1_from_TI1
+SH.S_TIM2_CH1_ETR.2=TIM2_CH1,Input_Capture2_from_TI1
+SH.S_TIM2_CH1_ETR.ConfNb=3
TIM1.Channel-Input_Capture1_from_TI1=TIM_CHANNEL_1
TIM1.ICFilter_CH1=0
TIM1.ICPolarity_CH1=TIM_INPUTCHANNELPOLARITY_RISING
TIM1.IPParameters=Prescaler,Period,Channel-Input_Capture1_from_TI1,ICFilter_CH1,ICPolarity_CH1
TIM1.Period=0xffff
TIM1.Prescaler=RADIO_RX_TIMER_PRESCALER
+TIM2.Channel-Input_Capture1_from_TI1=TIM_CHANNEL_1
+TIM2.Channel-Input_Capture2_from_TI1=TIM_CHANNEL_2
+TIM2.ICPolarity_CH1=TIM_INPUTCHANNELPOLARITY_FALLING
+TIM2.IPParameters=Channel-Input_Capture1_from_TI1,ICPolarity_CH1,Channel-Input_Capture2_from_TI1,Prescaler,Period
+TIM2.Period=0xffff
+TIM2.Prescaler=RADIO_RX_TIMER_PRESCALER
USART2.IPParameters=VirtualMode
USART2.VirtualMode=VM_ASYNC
USB_DEVICE.CLASS_NAME_FS=CDC
@@ -146,6 +167,8 @@ VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
VP_TIM1_VS_ControllerModeReset.Mode=Reset Mode
VP_TIM1_VS_ControllerModeReset.Signal=TIM1_VS_ControllerModeReset
+VP_TIM2_VS_ControllerModeReset.Mode=Reset Mode
+VP_TIM2_VS_ControllerModeReset.Signal=TIM2_VS_ControllerModeReset
VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Mode=CDC_FS
VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Signal=USB_DEVICE_VS_USB_DEVICE_CDC_FS
board=radio-controller-1