Project changes
1/ Added Spi that used to read data from AS5045b position sensor 2/ Added Base FOC code to project 3/ Added Standart DSP lib with optimazes sincos cals Need for FOC
This commit is contained in:
parent
ee1319b10e
commit
526b689693
43 changed files with 10985 additions and 410 deletions
107
Src/adc.c
107
Src/adc.c
|
@ -110,113 +110,6 @@ void MX_ADC1_Init(void)
|
|||
|
||||
/* USER CODE END ADC1_Init 2 */
|
||||
|
||||
}
|
||||
/* ADC2 init function */
|
||||
void MX_ADC2_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN ADC2_Init 0 */
|
||||
|
||||
/* USER CODE END ADC2_Init 0 */
|
||||
|
||||
LL_ADC_InitTypeDef ADC_InitStruct = {0};
|
||||
LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0};
|
||||
|
||||
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
/* Peripheral clock enable */
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC2);
|
||||
|
||||
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOC);
|
||||
/**ADC2 GPIO Configuration
|
||||
PC3 ------> ADC2_IN13
|
||||
PC4 ------> ADC2_IN14
|
||||
PC5 ------> ADC2_IN15
|
||||
*/
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_3|LL_GPIO_PIN_4|LL_GPIO_PIN_5;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN ADC2_Init 1 */
|
||||
|
||||
/* USER CODE END ADC2_Init 1 */
|
||||
|
||||
/** Common config
|
||||
*/
|
||||
ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B;
|
||||
ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT;
|
||||
ADC_InitStruct.SequencersScanMode = LL_ADC_SEQ_SCAN_DISABLE;
|
||||
LL_ADC_Init(ADC2, &ADC_InitStruct);
|
||||
ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE;
|
||||
ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_DISABLE;
|
||||
ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
|
||||
ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_SINGLE;
|
||||
ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_NONE;
|
||||
LL_ADC_REG_Init(ADC2, &ADC_REG_InitStruct);
|
||||
LL_ADC_REG_SetFlagEndOfConversion(ADC2, LL_ADC_REG_FLAG_EOC_UNITARY_CONV);
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
LL_ADC_REG_SetSequencerRanks(ADC2, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_15);
|
||||
LL_ADC_SetChannelSamplingTime(ADC2, LL_ADC_CHANNEL_15, LL_ADC_SAMPLINGTIME_3CYCLES);
|
||||
/* USER CODE BEGIN ADC2_Init 2 */
|
||||
|
||||
/* USER CODE END ADC2_Init 2 */
|
||||
|
||||
}
|
||||
/* ADC3 init function */
|
||||
void MX_ADC3_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN ADC3_Init 0 */
|
||||
|
||||
/* USER CODE END ADC3_Init 0 */
|
||||
|
||||
LL_ADC_InitTypeDef ADC_InitStruct = {0};
|
||||
LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0};
|
||||
|
||||
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
/* Peripheral clock enable */
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC3);
|
||||
|
||||
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOC);
|
||||
/**ADC3 GPIO Configuration
|
||||
PC0 ------> ADC3_IN10
|
||||
PC1 ------> ADC3_IN11
|
||||
*/
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_1;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN ADC3_Init 1 */
|
||||
|
||||
/* USER CODE END ADC3_Init 1 */
|
||||
|
||||
/** Common config
|
||||
*/
|
||||
ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B;
|
||||
ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT;
|
||||
ADC_InitStruct.SequencersScanMode = LL_ADC_SEQ_SCAN_DISABLE;
|
||||
LL_ADC_Init(ADC3, &ADC_InitStruct);
|
||||
ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE;
|
||||
ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_DISABLE;
|
||||
ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
|
||||
ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_SINGLE;
|
||||
ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_NONE;
|
||||
LL_ADC_REG_Init(ADC3, &ADC_REG_InitStruct);
|
||||
LL_ADC_REG_SetFlagEndOfConversion(ADC3, LL_ADC_REG_FLAG_EOC_UNITARY_CONV);
|
||||
|
||||
/** Configure Regular Channel
|
||||
*/
|
||||
LL_ADC_REG_SetSequencerRanks(ADC3, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_10);
|
||||
LL_ADC_SetChannelSamplingTime(ADC3, LL_ADC_CHANNEL_10, LL_ADC_SAMPLINGTIME_3CYCLES);
|
||||
/* USER CODE BEGIN ADC3_Init 2 */
|
||||
|
||||
/* USER CODE END ADC3_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue