diff --git a/Assets/adc1_settings.png b/Assets/adc1_settings.png
new file mode 100644
index 0000000..af15a55
Binary files /dev/null and b/Assets/adc1_settings.png differ
diff --git a/Assets/stm32cubemx.png b/Assets/stm32cubemx.png
index fd4af02..81a76da 100644
Binary files a/Assets/stm32cubemx.png and b/Assets/stm32cubemx.png differ
diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index daae1d7..df4a0bd 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -60,14 +60,22 @@ void Error_Handler(void);
/* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/
-#define ADC_VIN_Pin GPIO_PIN_1
+#define ADC_VIN_Pin GPIO_PIN_0
#define ADC_VIN_GPIO_Port GPIOA
+#define ADC_5V_Pin GPIO_PIN_1
+#define ADC_5V_GPIO_Port GPIOA
#define WS2812B_RGB_LED_Pin GPIO_PIN_2
#define WS2812B_RGB_LED_GPIO_Port GPIOA
-#define ADC_5V_Pin GPIO_PIN_5
-#define ADC_5V_GPIO_Port GPIOA
-#define INTERNAL_LED_Pin GPIO_PIN_8
-#define INTERNAL_LED_GPIO_Port GPIOA
+#define INT_RGB_LED_BLUE_Pin GPIO_PIN_4
+#define INT_RGB_LED_BLUE_GPIO_Port GPIOA
+#define ADC_5VA5_Pin GPIO_PIN_5
+#define ADC_5VA5_GPIO_Port GPIOA
+#define ADC_VERSION_Pin GPIO_PIN_1
+#define ADC_VERSION_GPIO_Port GPIOB
+#define INT_RGB_LED_GREEN_Pin GPIO_PIN_8
+#define INT_RGB_LED_GREEN_GPIO_Port GPIOA
+#define INT_RGB_LED_RED_Pin GPIO_PIN_15
+#define INT_RGB_LED_RED_GPIO_Port GPIOA
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
diff --git a/Core/Src/main.c b/Core/Src/main.c
index 6179d21..3ad299c 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -185,7 +185,7 @@ static void MX_ADC1_Init(void)
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
- hadc1.Init.NbrOfConversion = 3;
+ hadc1.Init.NbrOfConversion = 5;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
@@ -218,6 +218,24 @@ static void MX_ADC1_Init(void)
{
Error_Handler();
}
+
+ /** Configure Regular Channel
+ */
+ sConfig.Channel = ADC_CHANNEL_0;
+ sConfig.Rank = ADC_REGULAR_RANK_4;
+ if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
+ {
+ Error_Handler();
+ }
+
+ /** Configure Regular Channel
+ */
+ sConfig.Channel = ADC_CHANNEL_9;
+ sConfig.Rank = ADC_REGULAR_RANK_5;
+ if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
+ {
+ Error_Handler();
+ }
/* USER CODE BEGIN ADC1_Init 2 */
/* USER CODE END ADC1_Init 2 */
@@ -348,16 +366,23 @@ static void MX_GPIO_Init(void)
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(INTERNAL_LED_GPIO_Port, INTERNAL_LED_Pin, GPIO_PIN_RESET);
+ HAL_GPIO_WritePin(GPIOA, INT_RGB_LED_BLUE_Pin|INT_RGB_LED_GREEN_Pin|INT_RGB_LED_RED_Pin, GPIO_PIN_RESET);
- /*Configure GPIO pin : INTERNAL_LED_Pin */
- GPIO_InitStruct.Pin = INTERNAL_LED_Pin;
+ /*Configure GPIO pins : INT_RGB_LED_BLUE_Pin INT_RGB_LED_GREEN_Pin INT_RGB_LED_RED_Pin */
+ GPIO_InitStruct.Pin = INT_RGB_LED_BLUE_Pin|INT_RGB_LED_GREEN_Pin|INT_RGB_LED_RED_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(INTERNAL_LED_GPIO_Port, &GPIO_InitStruct);
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /*Configure GPIO pins : PB6 PB7 */
+ GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
diff --git a/Core/Src/stm32f1xx_hal_msp.c b/Core/Src/stm32f1xx_hal_msp.c
index e69ae7d..c7a2ca8 100644
--- a/Core/Src/stm32f1xx_hal_msp.c
+++ b/Core/Src/stm32f1xx_hal_msp.c
@@ -102,14 +102,21 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
__HAL_RCC_ADC1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
/**ADC1 GPIO Configuration
+ PA0-WKUP ------> ADC1_IN0
PA1 ------> ADC1_IN1
PA5 ------> ADC1_IN5
+ PB1 ------> ADC1_IN9
*/
- GPIO_InitStruct.Pin = ADC_VIN_Pin|ADC_5V_Pin;
+ GPIO_InitStruct.Pin = ADC_VIN_Pin|ADC_5V_Pin|ADC_5VA5_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+ GPIO_InitStruct.Pin = ADC_VERSION_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
+ HAL_GPIO_Init(ADC_VERSION_GPIO_Port, &GPIO_InitStruct);
+
/* USER CODE BEGIN ADC1_MspInit 1 */
/* USER CODE END ADC1_MspInit 1 */
@@ -134,10 +141,14 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
__HAL_RCC_ADC1_CLK_DISABLE();
/**ADC1 GPIO Configuration
+ PA0-WKUP ------> ADC1_IN0
PA1 ------> ADC1_IN1
PA5 ------> ADC1_IN5
+ PB1 ------> ADC1_IN9
*/
- HAL_GPIO_DeInit(GPIOA, ADC_VIN_Pin|ADC_5V_Pin);
+ HAL_GPIO_DeInit(GPIOA, ADC_VIN_Pin|ADC_5V_Pin|ADC_5VA5_Pin);
+
+ HAL_GPIO_DeInit(ADC_VERSION_GPIO_Port, ADC_VERSION_Pin);
/* USER CODE BEGIN ADC1_MspDeInit 1 */
diff --git a/README.md b/README.md
index 4f8bb22..34d8834 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,18 @@
# RaccoonLab UAV LIGHTS v2 node
-This is a repository for RaccoonLab lights v2 node.
+This is a repository for [RaccoonLab UAV Lights v2](https://docs.raccoonlab.co/guide/ui_leds/) node.
+
+| View | Top view | Bot view |
+| ---- | --- | ------ |
+| | | |
The core of this repository is the .ioc file that defines the stm32 peripherals with respect to what a real device has.
The peripheral configuration is shown below:
-
+| | |
+|-|-|
+| | |
Additionally, the reposity has a source code generated with STM32CubeMX v6.6.0 using STM32Cube FW_G0 V1.6.1 for STM32CubeIDE usage.
diff --git a/lights.ioc b/lights.ioc
index 9ec1b30..8bf51b5 100644
--- a/lights.ioc
+++ b/lights.ioc
@@ -2,17 +2,23 @@
ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_1
ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_5
ADC1.Channel-4\#ChannelRegularConversion=ADC_CHANNEL_TEMPSENSOR
+ADC1.Channel-5\#ChannelRegularConversion=ADC_CHANNEL_0
+ADC1.Channel-6\#ChannelRegularConversion=ADC_CHANNEL_9
ADC1.EnableInjectedConversion=DISABLE
-ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,EnableInjectedConversion,InjNumberOfConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,NbrOfConversion,Rank-4\#ChannelRegularConversion,Channel-4\#ChannelRegularConversion,SamplingTime-4\#ChannelRegularConversion,master
+ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,EnableInjectedConversion,InjNumberOfConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,NbrOfConversion,Rank-4\#ChannelRegularConversion,Channel-4\#ChannelRegularConversion,SamplingTime-4\#ChannelRegularConversion,master,Rank-5\#ChannelRegularConversion,Channel-5\#ChannelRegularConversion,SamplingTime-5\#ChannelRegularConversion,Rank-6\#ChannelRegularConversion,Channel-6\#ChannelRegularConversion,SamplingTime-6\#ChannelRegularConversion
ADC1.InjNumberOfConversion=2
-ADC1.NbrOfConversion=3
+ADC1.NbrOfConversion=5
ADC1.NbrOfConversionFlag=1
ADC1.Rank-0\#ChannelRegularConversion=1
ADC1.Rank-3\#ChannelRegularConversion=2
ADC1.Rank-4\#ChannelRegularConversion=3
+ADC1.Rank-5\#ChannelRegularConversion=4
+ADC1.Rank-6\#ChannelRegularConversion=5
ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_55CYCLES_5
ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_55CYCLES_5
ADC1.SamplingTime-4\#ChannelRegularConversion=ADC_SAMPLETIME_55CYCLES_5
+ADC1.SamplingTime-5\#ChannelRegularConversion=ADC_SAMPLETIME_55CYCLES_5
+ADC1.SamplingTime-6\#ChannelRegularConversion=ADC_SAMPLETIME_55CYCLES_5
ADC1.master=1
CAD.formats=
CAD.pinconfig=
@@ -106,7 +112,7 @@ PA13.Signal=SYS_JTMS-SWDIO
PA14.Mode=Serial_Wire
PA14.Signal=SYS_JTCK-SWCLK
PA15.GPIOParameters=GPIO_Label
-PA15.GPIO_Label=INTERNAL_LED_RED
+PA15.GPIO_Label=INT_RGB_LED_RED
PA15.Locked=true
PA15.Signal=GPIO_Output
PA2.GPIOParameters=GPIO_Label
@@ -114,18 +120,18 @@ PA2.GPIO_Label=WS2812B_RGB_LED
PA2.Locked=true
PA2.Signal=S_TIM2_CH3
PA4.GPIOParameters=GPIO_Label
-PA4.GPIO_Label=INTERNAL_LED_BLUE
+PA4.GPIO_Label=INT_RGB_LED_BLUE
PA4.Locked=true
PA4.Signal=GPIO_Output
PA5.GPIOParameters=GPIO_Label
PA5.GPIO_Label=ADC_5V
PA5.Signal=ADCx_IN5
PA8.GPIOParameters=GPIO_Label
-PA8.GPIO_Label=INTERNAL_LED_GREEN
+PA8.GPIO_Label=INT_RGB_LED_GREEN
PA8.Locked=true
PA8.Signal=GPIO_Output
PB1.GPIOParameters=GPIO_Label
-PB1.GPIO_Label=VERSION
+PB1.GPIO_Label=ADC_VERSION
PB1.Locked=true
PB1.Signal=ADCx_IN9
PB6.Locked=true
@@ -159,6 +165,7 @@ ProjectManager.PreviousToolchain=STM32CubeIDE
ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=lights.ioc
ProjectManager.ProjectName=lights
+ProjectManager.ProjectStructure=
ProjectManager.RegisterCallBack=
ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=STM32CubeIDE