Skip to content

Commit

Permalink
regenerate project, update ADC, RGB LED names and add more info to re…
Browse files Browse the repository at this point in the history
…adme
  • Loading branch information
PonomarevDA committed Dec 26, 2023
1 parent 75561bd commit a6d8655
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 20 deletions.
Binary file added Assets/adc1_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/stm32cubemx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 13 additions & 5 deletions Core/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
35 changes: 30 additions & 5 deletions Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);

}

Expand Down
15 changes: 13 additions & 2 deletions Core/Src/stm32f1xx_hal_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 */

Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 |
| ---- | --- | ------ |
| <img src="https://docs.raccoonlab.co/assets/img/t-view.42a0bfba.png" alt="drawing" width="225"> | <img src="https://docs.raccoonlab.co/assets/img/t-view-top.39aeaa81.png" alt="drawing" width="225"> | <img src="https://docs.raccoonlab.co/assets/img/t-view-bottom.e9a28e7d.png" alt="drawing" width="225">|

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:

<img src="Assets/stm32cubemx.png" alt="drawing">
| | |
|-|-|
| <img src="Assets/stm32cubemx.png" alt="drawing"> | <img src="Assets/adc1_settings.png" alt="drawing"> |

Additionally, the reposity has a source code generated with STM32CubeMX v6.6.0 using STM32Cube FW_G0 V1.6.1 for STM32CubeIDE usage.

Expand Down
19 changes: 13 additions & 6 deletions lights.ioc
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -106,26 +112,26 @@ 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
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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a6d8655

Please sign in to comment.