本文整理汇总了C++中Error_Handler函数的典型用法代码示例。如果您正苦于以下问题:C++ Error_Handler函数的具体用法?C++ Error_Handler怎么用?C++ Error_Handler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Error_Handler函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ADC_Config
/**
* @brief ADC configuration
* @note This function Configure the ADC peripheral
1) Enable peripheral clocks
2) Configure ADC Channel 12 pin as analog input
3) DMA2_Stream0 channel2 configuration
4) Configure ADC1 Channel 12
5) Configure ADC2 Channel 12
* @param None
* @retval None
*/
static void ADC_Config(void)
{
ADC_ChannelConfTypeDef sConfig;
ADC_MultiModeTypeDef mode;
/*##-1- Configure the ADC2 peripheral ######################################*/
AdcHandle2.Instance = ADCy;
AdcHandle2.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2;
AdcHandle2.Init.Resolution = ADC_RESOLUTION_8B;
AdcHandle2.Init.ScanConvMode = ENABLE;
AdcHandle2.Init.ContinuousConvMode = ENABLE;
AdcHandle2.Init.DiscontinuousConvMode = DISABLE;
AdcHandle2.Init.NbrOfDiscConversion = 0;
AdcHandle2.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
AdcHandle2.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T1_CC1;
AdcHandle2.Init.DataAlign = ADC_DATAALIGN_RIGHT;
AdcHandle2.Init.NbrOfConversion = 1;
AdcHandle2.Init.DMAContinuousRequests = ENABLE;
AdcHandle2.Init.EOCSelection = ENABLE;
if(HAL_ADC_Init(&AdcHandle2) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-2- Configure ADC2 regular channel #####################################*/
sConfig.Channel = ADCxy_CHANNEL;
sConfig.Rank = 1;
sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
sConfig.Offset = 0;
if(HAL_ADC_ConfigChannel(&AdcHandle2, &sConfig) != HAL_OK)
{
/* Channel Configuration Error */
Error_Handler();
}
/*##-3- Configure the ADC1 peripheral ######################################*/
AdcHandle1.Instance = ADCx;
AdcHandle1.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2;
AdcHandle1.Init.Resolution = ADC_RESOLUTION_8B;
AdcHandle1.Init.ScanConvMode = DISABLE;
AdcHandle1.Init.ContinuousConvMode = ENABLE;
AdcHandle1.Init.DiscontinuousConvMode = DISABLE;
AdcHandle1.Init.NbrOfDiscConversion = 0;
AdcHandle1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
AdcHandle1.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T1_CC1;
AdcHandle1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
AdcHandle1.Init.NbrOfConversion = 1;
AdcHandle1.Init.DMAContinuousRequests = ENABLE;
AdcHandle1.Init.EOCSelection = ENABLE;
if(HAL_ADC_Init(&AdcHandle1) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-4- Configure ADC1 regular channel #####################################*/
if(HAL_ADC_ConfigChannel(&AdcHandle1, &sConfig) != HAL_OK)
{
/* Channel Configuration Error */
Error_Handler();
}
/*##-5- Configure Multimode ################################################*/
mode.Mode = ADC_DUALMODE_INTERL;
mode.DMAAccessMode = ADC_DMAACCESSMODE_3;
mode.TwoSamplingDelay = ADC_TWOSAMPLINGDELAY_6CYCLES;
if(HAL_ADCEx_MultiModeConfigChannel(&AdcHandle1, &mode) != HAL_OK)
{
/* Channel Configuration Error */
Error_Handler();
}
}
开发者ID:eemei,项目名称:library-stm32f4,代码行数:89,代码来源:main.c
示例2: Syringe_Size
uint32_t Syringe_Size(void)
{
uint32_t adc_value;
uint32_t adc_valuetest=0;
ADC_Config();
if (HAL_ADCEx_Calibration_Start(&AdcHandle) != HAL_OK)
{
/* Calibration Error */
Error_Handler();
}
#if defined(ADC_TRIGGER_FROM_TIMER)
/* Configure the TIM peripheral */
TIM_Config();
#endif /* ADC_TRIGGER_FROM_TIMER */
/*## Enable peripherals ####################################################*/
#if defined(ADC_TRIGGER_FROM_TIMER)
/* Timer enable */
if (HAL_TIM_Base_Start(&TimHandle) != HAL_OK)
{
/* Counter Enable Error */
Error_Handler();
}
#endif /* ADC_TRIGGER_FROM_TIMER */
/* Note: This example, on some other STM32 boards, is performing */
/* DAC signal generation here. */
/* On STM32F103RB-Nucleo, the device has no DAC available, */
/* therefore analog signal must be supplied externally. */
/*## Start ADC conversions #################################################*/
/* Start ADC conversion on regular group with transfer by DMA */
// if (HAL_ADC_Start_DMA(&AdcHandle,
// (uint32_t *)aADCxConvertedValues,
// ADCCONVERTEDVALUES_BUFFER_SIZE
// ) != HAL_OK)
// {
// /* Start Error */
// Error_Handler();
// }
if (HAL_ADC_Start(&AdcHandle) != HAL_OK)
{
/* Start Error */
Error_Handler();
}
if (HAL_ADC_PollForConversion(&AdcHandle,10) != HAL_OK)
{
/* Start Error */
Error_Handler();
}
adc_value= HAL_ADC_GetValue(&AdcHandle);
if(adc_value<=0x400) return(10);
else if(adc_value>0x400 && adc_value<=0x800) return(20);
else if(adc_value>0x800 && adc_value<=0xc00) return(30);
else if(adc_value>0xc00)
return(50);
}
开发者ID:salinraj,项目名称:amigo,代码行数:63,代码来源:Syringe_Size.c
示例3: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* Configure the MPU attributes as Write Back */
MPU_Config();
/* Enable the CPU Cache */
CPU_CACHE_Enable();
/* STM32F7xx HAL library initialization:
- Configure the Flash ART accelerator on ITCM interface
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Set NVIC Group Priority to 4
- Low Level Initialization
*/
HAL_Init();
/* Configure the system clock to 200 MHz */
SystemClock_Config();
/* Configure LED1 and LED3 */
BSP_LED_Init(LED1);
BSP_LED_Init(LED3);
/*##-1- Configure the SDRAM device #########################################*/
/* SDRAM device configuration */
hsdram.Instance = FMC_SDRAM_DEVICE;
SDRAM_Timing.LoadToActiveDelay = 2;
SDRAM_Timing.ExitSelfRefreshDelay = 6;
SDRAM_Timing.SelfRefreshTime = 4;
SDRAM_Timing.RowCycleDelay = 6;
SDRAM_Timing.WriteRecoveryTime = 2;
SDRAM_Timing.RPDelay = 2;
SDRAM_Timing.RCDDelay = 2;
hsdram.Init.SDBank = FMC_SDRAM_BANK1;
hsdram.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9;
hsdram.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12;
hsdram.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH;
hsdram.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
hsdram.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3;
hsdram.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
hsdram.Init.SDClockPeriod = SDCLOCK_PERIOD;
hsdram.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE;
hsdram.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0;
/* Initialize the SDRAM controller */
if(HAL_SDRAM_Init(&hsdram, &SDRAM_Timing) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/* Program the SDRAM external device */
BSP_SDRAM_Initialization_Sequence(&hsdram, &command);
/*##-2- SDRAM memory read/write access #####################################*/
/* Fill the buffer to write */
Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xA244250F);
/* Write data to the SDRAM memory */
for (uwIndex = 0; uwIndex < BUFFER_SIZE; uwIndex++)
{
*(__IO uint32_t*) (SDRAM_BANK_ADDR + WRITE_READ_ADDR + 4*uwIndex) = aTxBuffer[uwIndex];
}
/* Read back data from the SDRAM memory */
for (uwIndex = 0; uwIndex < BUFFER_SIZE; uwIndex++)
{
aRxBuffer[uwIndex] = *(__IO uint32_t*) (SDRAM_BANK_ADDR + WRITE_READ_ADDR + 4*uwIndex);
}
/*##-3- Checking data integrity ############################################*/
for (uwIndex = 0; (uwIndex < BUFFER_SIZE) && (uwWriteReadStatus == 0); uwIndex++)
{
if (aRxBuffer[uwIndex] != aTxBuffer[uwIndex])
{
uwWriteReadStatus++;
}
}
if (uwWriteReadStatus != PASSED)
{
/* KO */
/* Toggle LED3 */
while(1)
{
BSP_LED_Toggle(LED3);
}
//.........这里部分代码省略.........
开发者ID:acrepina,项目名称:STM32F7_serverWEB,代码行数:101,代码来源:main.c
示例4: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* STM32F0xx HAL library initialization:
- Configure the Flash prefetch
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Low Level Initialization
*/
HAL_Init();
/* Configure LED3, LED4 and LED5 */
BSP_LED_Init(LED3);
BSP_LED_Init(LED4);
BSP_LED_Init(LED5);
/* Configure the system clock to 48 MHz */
SystemClock_Config();
/*##-1- Configure the SPI peripheral #######################################*/
/* Set the SPI parameters */
SpiHandle.Instance = SPIx;
SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
SpiHandle.Init.Direction = SPI_DIRECTION_2LINES;
SpiHandle.Init.CLKPhase = SPI_PHASE_1EDGE;
SpiHandle.Init.CLKPolarity = SPI_POLARITY_LOW;
SpiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
SpiHandle.Init.CRCPolynomial = 7;
SpiHandle.Init.DataSize = SPI_DATASIZE_8BIT;
SpiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB;
SpiHandle.Init.NSS = SPI_NSS_SOFT;
SpiHandle.Init.TIMode = SPI_TIMODE_DISABLE;
SpiHandle.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
SpiHandle.Init.CRCLength = SPI_CRC_LENGTH_8BIT;
#ifdef MASTER_BOARD
SpiHandle.Init.Mode = SPI_MODE_MASTER;
#else
SpiHandle.Init.Mode = SPI_MODE_SLAVE;
#endif /* MASTER_BOARD */
if (HAL_SPI_Init(&SpiHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
#ifdef MASTER_BOARD
/* Configure the push button */
BSP_PB_Init(BUTTON_USER, BUTTON_MODE_GPIO);
/* Wait for Button press before starting the Communication */
while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_SET)
{
BSP_LED_Toggle(LED3);
HAL_Delay(100);
}
BSP_LED_Off(LED3);
#endif /* MASTER_BOARD */
/*##-2- Start the Full Duplex Communication process ########################*/
/* While the SPI in TransmitReceive process, user can transmit data through
"aTxBuffer" buffer & receive data through "aRxBuffer" */
if(HAL_SPI_TransmitReceive_DMA(&SpiHandle, (uint8_t*)aTxBuffer, (uint8_t *)aRxBuffer, BUFFERSIZE) != HAL_OK)
{
/* Transfer error in transmission process */
Error_Handler();
}
/*##-3- Wait for the end of the transfer ###################################*/
/* Before starting a new communication transfer, you need to check the current
state of the peripheral; if it’s busy you need to wait for the end of current
transfer before starting a new one.
For simplicity reasons, this example is just waiting till the end of the
transfer, but application may perform other tasks while transfer operation
is ongoing. */
while (HAL_SPI_GetState(&SpiHandle) != HAL_SPI_STATE_READY)
{
}
/*##-4- Compare the sent and received buffers ##############################*/
if(Buffercmp((uint8_t*)aTxBuffer, (uint8_t*)aRxBuffer, BUFFERSIZE))
{
/* Processing Error */
Error_Handler();
}
/* Infinite loop */
while (1)
{
}
}
开发者ID:jmoyerman,项目名称:stm32f0_cube,代码行数:98,代码来源:main.c
示例5: ADC_Config
static void ADC_Config(void)
{
ADC_ChannelConfTypeDef sConfig;
// ADC_AnalogWDGConfTypeDef AnalogWDGConfig;
/* Configuration of ADCx init structure: ADC parameters and regular group */
AdcHandle.Instance = ADCx;
AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT;
AdcHandle.Init.ScanConvMode = ADC_SCAN_DISABLE; /* Sequencer disabled (ADC conversion on only 1 channel: channel set on rank 1) */
//#if defined ADC_TRIGGER_FROM_TIMER
AdcHandle.Init.ContinuousConvMode = DISABLE; /* Continuous mode disabled to have only 1 conversion at each conversion trig */
//#else
// AdcHandle.Init.ContinuousConvMode = ENABLE; /* Continuous mode to have maximum conversion speed (no delay between conversions) */
//#endif
AdcHandle.Init.NbrOfConversion = 1; /* Parameter discarded because sequencer is disabled */
AdcHandle.Init.DiscontinuousConvMode = DISABLE; /* Parameter discarded because sequencer is disabled */
AdcHandle.Init.NbrOfDiscConversion = 1; /* Parameter discarded because sequencer is disabled */
#if defined ADC_TRIGGER_FROM_TIMER
AdcHandle.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_Tx_TRGO; /* Trig of conversion start done by external event */
#else
AdcHandle.Init.ExternalTrigConv = ADC_SOFTWARE_START; /* Software start to trig the 1st conversion manually, without external event */
#endif
if (HAL_ADC_Init(&AdcHandle) != HAL_OK)
{
/* ADC initialization error */
Error_Handler();
}
/* Configuration of channel on ADCx regular group on sequencer rank 1 */
/* Note: Considering IT occurring after each ADC conversion if ADC */
/* conversion is out of the analog watchdog window selected (ADC IT */
/* enabled), select sampling time and ADC clock with sufficient */
/* duration to not create an overhead situation in IRQHandler. */
sConfig.Channel = ADCx_CHANNELa;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_41CYCLES_5;
//sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
if (HAL_ADC_ConfigChannel(&AdcHandle, &sConfig) != HAL_OK)
{
/* Channel Configuration Error */
Error_Handler();
}
/* Set analog watchdog thresholds in order to be between steps of DAC */
/* voltage. */
/* - High threshold: between DAC steps 1/2 and 3/4 of full range: */
/* 5/8 of full range (4095 <=> Vdda=3.3V): 2559<=> 2.06V */
/* - Low threshold: between DAC steps 0 and 1/4 of full range: */
/* 1/8 of full range (4095 <=> Vdda=3.3V): 512 <=> 0.41V */
/* Analog watchdog 1 configuration */
// AnalogWDGConfig.WatchdogMode = ADC_ANALOGWATCHDOG_ALL_REG;
// AnalogWDGConfig.Channel = ADCx_CHANNELa;
// AnalogWDGConfig.ITMode = ENABLE;
// AnalogWDGConfig.HighThreshold = (RANGE_12BITS * 5/8);
// AnalogWDGConfig.LowThreshold = (RANGE_12BITS * 1/8);
// if (HAL_ADC_AnalogWDGConfig(&AdcHandle, &AnalogWDGConfig) != HAL_OK)
// {
// /* Channel Configuration Error */
// Error_Handler();
// }
//
}
开发者ID:salinraj,项目名称:amigo,代码行数:66,代码来源:Syringe_Size.c
示例6: WaveRecorderProcess
/**
* @brief Update the recorded data.
* @param None
* @retval None
*/
void WaveRecorderProcess(void)
{
/* Current size of the recorded buffer */
uint32_t byteswritten = 0;
WaveCounter = 0;
LEDsState = LEDS_OFF;
/* Remove Wave file if it exists on USB Flash Disk */
f_unlink(REC_WAVE_NAME);
/* Open the file to write on it */
if((AppliState == APPLICATION_IDLE) || (f_open(&WavFile, REC_WAVE_NAME, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK))
{
while(1)
{
/* Toggle LED5 in infinite loop to signal that: USB Flash Disk is not connected/removed
or an issue has occurred when creating/opening Wave file */
BSP_LED_Toggle(LED5);
}
}
else
{
WaveRecStatus = 1;
}
/* Initialize header file */
WavProcess_EncInit(DEFAULT_AUDIO_IN_FREQ, pHeaderBuff);
/* Write the header Wave */
f_write(&WavFile, pHeaderBuff, 44, (void *)&byteswritten);
/* Increment the Wave counter */
BufferCtl.fptr = byteswritten;
BufferCtl.offset = BUFFER_OFFSET_NONE;
BSP_AUDIO_IN_Init(DEFAULT_AUDIO_IN_FREQ, DEFAULT_AUDIO_IN_BIT_RESOLUTION, DEFAULT_AUDIO_IN_CHANNEL_NBR);
BSP_AUDIO_IN_Record((uint16_t*)&InternalBuffer[0], INTERNAL_BUFF_SIZE);
/* Reset the time recording base variable */
TimeRecBase = 0;
ITCounter = 0;
LEDsState = LED3_TOGGLE;
while(AppliState != APPLICATION_IDLE)
{
/* Wait for the recording time */
if(TimeRecBase <= DEFAULT_TIME_REC)
{
/* Check if there are Data to write in Usb Key */
if(AUDIODataReady == 1)
{
/* write buffer in file */
res = f_write(&WavFile, (uint8_t*)(WrBuffer+AUDIOBuffOffset), WR_BUFFER_SIZE, (void*)&byteswritten);
if(res != FR_OK)
{
Error_Handler();
}
BufferCtl.fptr += byteswritten;
AUDIODataReady = 0;
}
/* User button pressed */
if(CmdIndex != CMD_RECORD)
{
/* Stop Audio Recording */
WaveRecorderStop();
/* Switch Command Index to Play */
CmdIndex = CMD_PLAY;
/* Toggoling LED6 to signal Play */
LEDsState = LED6_TOGGLE;
break;
}
}
else /* End of recording time DEFAULT_TIME_REC */
{
/* Stop Audio Recording */
WaveRecorderStop();
/* Change Command Index to Stop */
CmdIndex = CMD_STOP;
/* Toggoling LED4 to signal Stop */
LEDsState = LED4_TOGGLE;
AUDIODataReady = 0;
break;
}
}
/* Update the data length in the header of the recorded Wave */
f_lseek(&WavFile, 0);
/* Parse the wav file header and extract required information */
WavProcess_HeaderUpdate(pHeaderBuff, &WaveFormat);
f_write(&WavFile, pHeaderBuff, 44, (void*)&byteswritten);
/* Close file and unmount MyFilesystem */
f_close (&WavFile);
//.........这里部分代码省略.........
开发者ID:EarnestHein89,项目名称:STM32Cube_FW_F4,代码行数:101,代码来源:waverecorder.c
示例7: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* STM32F4xx HAL library initialization:
- Configure the Flash prefetch, instruction and Data caches
- Configure the Systick to generate an interrupt each 1 msec
- Set NVIC Group Priority to 4
- Global MSP (MCU Support Package) initialization
*/
if(HAL_Init()!= HAL_OK)
{
/* Start Conversation Error */
Error_Handler();
}
/* Configure the system clock to 84 MHz */
SystemClock_Config();
/* Configure LED3 and LED4 */
BSP_LED_Init(LED3);
BSP_LED_Init(LED4);
/*##-1- Configure the TIM peripheral #######################################*/
/* -----------------------------------------------------------------------
In this example TIM3 input clock (TIM3CLK) is set to 2 * APB1 clock (PCLK1),
since APB1 prescaler is different from 1.
TIM3CLK = 2 * PCLK1
PCLK1 = HCLK / 2
=> TIM3CLK = HCLK = SystemCoreClock
To get TIM3 counter clock at 10 KHz, the Prescaler is computed as following:
Prescaler = (TIM3CLK / TIM3 counter clock) - 1
Prescaler = (SystemCoreClock /10 KHz) - 1
Note:
SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f4xx.c file.
Each time the core clock (HCLK) changes, user had to update SystemCoreClock
variable value. Otherwise, any configuration based on this variable will be incorrect.
This variable is updated in three ways:
1) by calling CMSIS function SystemCoreClockUpdate()
2) by calling HAL API function HAL_RCC_GetSysClockFreq()
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
----------------------------------------------------------------------- */
/* Compute the prescaler value to have TIM3 counter clock equal to 10 KHz */
uwPrescalerValue = (uint32_t) ((SystemCoreClock / 10000) - 1);
/* Set TIMx instance */
TimHandle.Instance = TIMx;
/* Initialize TIM3 peripheral as follow:
+ Period = 10000 - 1
+ Prescaler = ((SystemCoreClock/2)/10000) - 1
+ ClockDivision = 0
+ Counter direction = Up
*/
TimHandle.Init.Period = 10000 - 1;
TimHandle.Init.Prescaler = uwPrescalerValue;
TimHandle.Init.ClockDivision = 0;
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
if(HAL_TIM_Base_Init(&TimHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-2- Start the TIM Base generation in interrupt mode ####################*/
/* Start Channel1 */
if(HAL_TIM_Base_Start_IT(&TimHandle) != HAL_OK)
{
/* Starting Error */
Error_Handler();
}
/* Infinite loop */
while (1)
{
}
}
开发者ID:PaxInstruments,项目名称:STM32CubeF4,代码行数:84,代码来源:main.c
示例8: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
/* STM32F0xx HAL library initialization:
- Configure the Flash prefetch
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Low Level Initialization
*/
HAL_Init();
/* Configure LED4 */
BSP_LED_Init(LED4);
/* Configure the system clock to 48 MHz */
SystemClock_Config();
/*##-1- Configure the TIM peripheral #######################################*/
/* ---------------------------------------------------------------------------
TIM3 configuration: PWM Input mode
In this example TIM3 input clock (TIM3CLK) is set to APB1 clock (PCLK1),
since APB1 prescaler is 1.
TIM3CLK = PCLK1
PCLK1 = HCLK
=> TIM3CLK = HCLK = SystemCoreClock
External Signal Frequency = TIM3 counter clock / TIM3_CCR2 in Hz.
External Signal DutyCycle = (TIM3_CCR1*100)/(TIM3_CCR2) in %.
--------------------------------------------------------------------------- */
/* Set TIMx instance */
TimHandle.Instance = TIMx;
/* Initialize TIMx peripheral as follows:
+ Period = 0xFFFF
+ Prescaler = 0
+ ClockDivision = 0
+ Counter direction = Up
*/
TimHandle.Init.Period = 0xFFFF;
TimHandle.Init.Prescaler = 0;
TimHandle.Init.ClockDivision = 0;
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
TimHandle.Init.RepetitionCounter = 0;
if (HAL_TIM_IC_Init(&TimHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-2- Configure the Input Capture channels ###############################*/
/* Common configuration */
sConfig.ICPrescaler = TIM_ICPSC_DIV1;
sConfig.ICFilter = 0;
/* Configure the Input Capture of channel 1 */
sConfig.ICPolarity = TIM_ICPOLARITY_FALLING;
sConfig.ICSelection = TIM_ICSELECTION_INDIRECTTI;
if (HAL_TIM_IC_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_1) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
/* Configure the Input Capture of channel 2 */
sConfig.ICPolarity = TIM_ICPOLARITY_RISING;
sConfig.ICSelection = TIM_ICSELECTION_DIRECTTI;
if (HAL_TIM_IC_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_2) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
/*##-3- Configure the slave mode ###########################################*/
/* Select the slave Mode: Reset Mode */
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_RESET;
sSlaveConfig.InputTrigger = TIM_TS_TI2FP2;
sSlaveConfig.TriggerPolarity = TIM_TRIGGERPOLARITY_NONINVERTED;
sSlaveConfig.TriggerPrescaler = TIM_TRIGGERPRESCALER_DIV1;
sSlaveConfig.TriggerFilter = 0;
if (HAL_TIM_SlaveConfigSynchronization(&TimHandle, &sSlaveConfig) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
/*##-4- Start the Input Capture in interrupt mode ##########################*/
if (HAL_TIM_IC_Start_IT(&TimHandle, TIM_CHANNEL_2) != HAL_OK)
{
/* Starting Error */
Error_Handler();
//.........这里部分代码省略.........
开发者ID:GreyCardinalRus,项目名称:stm32-cube,代码行数:101,代码来源:main.c
示例9: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
FRESULT res; /* FatFs function common result code */
uint32_t byteswritten, bytesread; /* File write/read counts */
uint8_t wtext[] = "This is STM32 working with FatFs"; /* File write buffer */
uint8_t rtext[100]; /* File read buffer */
/* STM32F107xC HAL library initialization:
- Configure the Flash prefetch
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Set NVIC Group Priority to 4
- Low Level Initialization
*/
HAL_Init();
/* Configure the system clock to 72 MHz */
SystemClock_Config();
/* Configure LED_GREEN and LED_RED */
BSP_LED_Init(LED_GREEN);
BSP_LED_Init(LED_RED);
/*##-1- Link the micro SD disk I/O driver ##################################*/
if(FATFS_LinkDriver(&SD_Driver, SDPath) == 0)
{
/*##-2- Register the file system object to the FatFs module ##############*/
if(f_mount(&SDFatFs, (TCHAR const*)SDPath, 0) != FR_OK)
{
/* FatFs Initialization Error */
Error_Handler();
}
else
{
/*##-3- Create a FAT file system (format) on the logical drive #########*/
/* WARNING: Formatting the uSD card will delete all content on the device */
if(f_mkfs((TCHAR const*)SDPath, 0, 0) != FR_OK)
{
/* FatFs Format Error */
Error_Handler();
}
else
{
/*##-4- Create and Open a new text file object with write access #####*/
if(f_open(&MyFile, "STM32.TXT", FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
{
/* 'STM32.TXT' file Open for write Error */
Error_Handler();
}
else
{
/*##-5- Write data to the text file ################################*/
res = f_write(&MyFile, wtext, sizeof(wtext), (void *)&byteswritten);
/*##-6- Close the open text file #################################*/
if (f_close(&MyFile) != FR_OK )
{
Error_Handler();
}
if((byteswritten == 0) || (res != FR_OK))
{
/* 'STM32.TXT' file Write or EOF Error */
Error_Handler();
}
else
{
/*##-7- Open the text file object with read access ###############*/
if(f_open(&MyFile, "STM32.TXT", FA_READ) != FR_OK)
{
/* 'STM32.TXT' file Open for read Error */
Error_Handler();
}
else
{
/*##-8- Read data from the text file ###########################*/
res = f_read(&MyFile, rtext, sizeof(rtext), (UINT*)&bytesread);
if((bytesread == 0) || (res != FR_OK))
{
/* 'STM32.TXT' file Read or EOF Error */
Error_Handler();
}
else
{
/*##-9- Close the open text file #############################*/
f_close(&MyFile);
/*##-10- Compare read data with the expected data ############*/
if((bytesread != byteswritten))
{
/* Read data is different from the expected data */
//.........这里部分代码省略.........
开发者ID:Lembed,项目名称:STM32CubeF1-mirrors,代码行数:101,代码来源:main.c
示例10: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* STM32F2xx HAL library initialization:
- Configure the Flash prefetch, instruction and Data caches
- Configure the Systick to generate an interrupt each 1 msec
- Set NVIC Group Priority to 4
- Global MSP (MCU Support Package) initialization
*/
HAL_Init();
/* Configure the system clock to 120 MHz */
SystemClock_Config();
/* Configure LED1 and LED3 */
BSP_LED_Init(LED1);
BSP_LED_Init(LED3);
/* Compute the prescaler value to have TIMx counter clock equal to 2 KHz */
uwPrescalerValue = ((SystemCoreClock /2) / 2000) - 1;
/*##-1- Configure the TIM peripheral #######################################*/
/* ---------------------------------------------------------------------------
TIM3 Configuration: Output Compare Active Mode:
In this example TIM3 input clock (TIM3CLK) is set to 2 * APB1 clock (PCLK1),
since APB1 prescaler is different from 1.
TIM3CLK = 2 * PCLK1
PCLK1 = HCLK / 4
=> TIM3CLK = HCLK / 2 = SystemCoreClock /2
To get TIM3 counter clock at 2 KHz, the prescaler is computed as follows:
Prescaler = (TIM3CLK / TIM3 counter clock) - 1
Prescaler = ((SystemCoreClock /2) /2 KHz) - 1
Generate 4 signals with 4 different delays:
TIM3_CH1 delay = uhCCR1_Val/TIM3 counter clock = 500 ms
TIM3_CH2 delay = uhCCR2_Val/TIM3 counter clock = 250 ms
TIM3_CH3 delay = uhCCR3_Val/TIM3 counter clock = 125 ms
TIM3_CH4 delay = uhCCR4_Val/TIM3 counter clock = 62.5 ms
Note:
SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f2xx.c file.
Each time the core clock (HCLK) changes, user had to update SystemCoreClock
variable value. Otherwise, any configuration based on this variable will be incorrect.
This variable is updated in three ways:
1) by calling CMSIS function SystemCoreClockUpdate()
2) by calling HAL API function HAL_RCC_GetSysClockFreq()
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
--------------------------------------------------------------------------- */
/* Initialize TIMx peripheral as follow:
+ Prescaler = (SystemCoreClock/2)/2000
+ Period = 65535
+ ClockDivision = 0
+ Counter direction = Up
*/
TimHandle.Instance = TIMx;
TimHandle.Init.Period = 65535;
TimHandle.Init.Prescaler = uwPrescalerValue;
TimHandle.Init.ClockDivision = 0;
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
if(HAL_TIM_OC_Init(&TimHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-2- Configure the Output Compare channels ##############################*/
/* Common configuration for all channels */
sConfig.OCMode = TIM_OCMODE_ACTIVE;
sConfig.OCPolarity = TIM_OCPOLARITY_HIGH;
/* Set the pulse (delay1) value for channel 1 */
sConfig.Pulse = PULSE1_VALUE;
if(HAL_TIM_OC_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_1) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
/* Set the pulse (delay2) value for channel 2 */
sConfig.Pulse = PULSE2_VALUE;
if(HAL_TIM_OC_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_2) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
/* Set the pulse (delay3) value for channel 3 */
sConfig.Pulse = PULSE3_VALUE;
if(HAL_TIM_OC_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_3) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
//.........这里部分代码省略.........
开发者ID:PaxInstruments,项目名称:STM32CubeF2,代码行数:101,代码来源:main.c
示例11: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
/* STM32F4xx HAL library initialization:
- Configure the Flash prefetch
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Set NVIC Group Priority to 4
- Low Level Initialization
*/
HAL_Init();
/* Configure LED3 */
BSP_LED_Init(LED3);
/* Configure the system clock to 180 MHz */
SystemClock_Config();
/* Compute the prescaler value to have TIM3 counter clock equal to 36000000 Hz */
uhPrescalerValue = (uint32_t)(SystemCoreClock / 36000000) - 1;
/*##-1- Configure the TIM peripheral #######################################*/
/* -----------------------------------------------------------------------
TIM3 Configuration: generate 1 PWM signal with clock prescaler selection feature activated using __HAL_RCC_TIMCLKPRESCALER()
which allow to double the output frequency.
In this example TIM3 input clock (TIM3CLK) is set to 4 * APB1 clock (PCLK1), since
Timer clock prescalers selection activated (TIMPRE bit from RCC_DCKCFGR register is set).
TIM3CLK = 4 * PCLK1
PCLK1 = HCLK / 4
=> TIM3CLK = HCLK = SystemCoreClock
For TIM3CLK equal to SystemCoreClock and prescaler equal to (5 - 1), TIM3 counter clock
is computed as follows:
TIM3 counter clock = TIM3CLK / (Prescaler + 1)
= SystemCoreClock / (Prescaler + 1)
= 36MHz
For ARR equal to (1800 - 1), the TIM3 output clock is computed as follows:
TIM3 output clock = TIM3 counter clock / (ARR + 1)
= 20KHZ
The TIM3 CCR1 register value is equal to 900, so the TIM3 Channel 1 generates a
PWM signal with a frequency equal to 20 KHz and a duty cycle equal to 50%:
TIM3 Channel1 duty cycle = (TIM3_CCR1/ TIM3_ARR + 1)* 100 = 50%
Note:
SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f4xx.c file.
Each time the core clock (HCLK) changes, user had to update SystemCoreClock
variable value. Otherwise, any configuration based on this variable will be incorrect.
This variable is updated in three ways:
1) by calling CMSIS function SystemCoreClockUpdate()
2) by calling HAL API function HAL_RCC_GetSysClockFreq()
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
----------------------------------------------------------------------- */
/* Timer clock prescalers selection activation */
__HAL_RCC_TIMCLKPRESCALER(RCC_TIMPRES_ACTIVATED);
/* Initialize TIMx peripheral as follows:
+ Prescaler = (SystemCoreClock / 36000000) - 1
+ Period = (1800 - 1)
+ ClockDivision = 0
+ Counter direction = Up
*/
TimHandle.Instance = TIMx;
TimHandle.Init.Prescaler = uhPrescalerValue;
TimHandle.Init.Period = PERIOD_VALUE;
TimHandle.Init.ClockDivision = 0;
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
TimHandle.Init.RepetitionCounter = 0;
if (HAL_TIM_PWM_Init(&TimHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-2- Configure the PWM channels #########################################*/
/* Common configuration for all channels */
sConfig.OCMode = TIM_OCMODE_PWM1;
sConfig.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfig.OCFastMode = TIM_OCFAST_DISABLE;
sConfig.OCNPolarity = TIM_OCNPOLARITY_HIGH;
sConfig.OCNIdleState = TIM_OCNIDLESTATE_RESET;
sConfig.OCIdleState = TIM_OCIDLESTATE_RESET;
/* Set the pulse value for channel 1 */
sConfig.Pulse = PULSE1_VALUE;
if (HAL_TIM_PWM_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_1) != HAL_OK)
{
//.........这里部分代码省略.........
开发者ID:Joe-Merten,项目名称:Stm32-Tools-Evaluation,代码行数:101,代码来源:main.c
示例12: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* STM32F4xx HAL library initialization:
- Configure the Flash prefetch, instruction and Data caches
- Configure the Systick to generate an interrupt each 1 msec
- Set NVIC Group Priority to 4
- Global MSP (MCU Support Package) initialization
*/
HAL_Init();
/* Configure LED1, LED2, LED3 and LED4 */
BSP_LED_Init(LED1);
BSP_LED_Init(LED2);
BSP_LED_Init(LED3);
BSP_LED_Init(LED4);
/* Initialize Key button, will be used to trigger an interrupt each time it's pressed.
In the ISR the PLL source will be changed from HSE to HSI, and vice versa. */
BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);
/* Enable Power Control clock */
__PWR_CLK_ENABLE();
/* The voltage scaling allows optimizing the power consumption when the device is
clocked below the maximum system frequency, to update the voltage scaling value
regarding system frequency refer to product datasheet. */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/* Enable HSE oscillator and configure the PLL to reach the max system frequency (168MHz)
when using HSE oscillator as PLL clock source. */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 25;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 7;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers.
The SysTick 1 msec interrupt is required for the HAL process (Timeout management); by default
the configuration is done using the HAL_Init() API, and when the system clock configuration
is updated the SysTick configuration will be adjusted by the HAL_RCC_ClockConfig() API. */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/* Output SYSCLK divided by 2 on MCO2 pin(PC9) */
HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_2);
/* Toggle some LEDs in an infinite loop */
while (1)
{
/* Toggle LED1 */
BSP_LED_Toggle(LED1);
HAL_Delay(100);
/* Toggle LED2 */
BSP_LED_Toggle(LED2);
HAL_Delay(100);
/* Toggle LED4 */
BSP_LED_Toggle(LED4);
HAL_Delay(100);
}
}
开发者ID:EarnestHein89,项目名称:STM32Cube_FW_F4,代码行数:81,代码来源:main.c
示例13: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* STM32F4xx HAL library initialization:
- Configure the Flash prefetch, instruction and Data caches
- Configure the Systick to generate an interrupt each 1 msec
- Set NVIC Group Priority to 4
- Global MSP (MCU Support Package) initialization
*/
HAL_Init();
/* Configure the system clock to 180 MHz */
SystemClock_Config();
/* Configure LED2 */
BSP_LED_Init(LED2);
/*##-1- Configure the TIM peripheral #######################################*/
/* Set TIMx instance */
TimHandle.Instance = TIMx;
/* Initialize TIMx peripheral as follows:
+ Period = 0xFFFF
+ Prescaler = 0
+ ClockDivision = 0
+ Counter direction = Up
*/
TimHandle.Init.Period = 0xFFFF;
TimHandle.Init.Prescaler = 0;
TimHandle.Init.ClockDivision = 0;
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
if(HAL_TIM_IC_Init(&TimHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/*##-2- Configure the Input Capture channels ###############################*/
/* Common configuration */
sConfig.ICPrescaler = TIM_ICPSC_DIV1;
sConfig.ICFilter = 0;
/* Configure the Input Capture of channel 1 */
sConfig.ICPolarity = TIM_ICPOLARITY_FALLING;
sConfig.ICSelection = TIM_ICSELECTION_INDIRECTTI;
if(HAL_TIM_IC_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_1) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
/* Configure the Input Capture of channel 2 */
sConfig.ICPolarity = TIM_ICPOLARITY_RISING;
sConfig.ICSelection = TIM_ICSELECTION_DIRECTTI;
if(HAL_TIM_IC_ConfigChannel(&TimHandle, &sConfig, TIM_CHANNEL_2) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
/*##-3- Configure the slave mode ###########################################*/
/* Select the slave Mode: Reset Mode */
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_RESET;
sSlaveConfig.InputTrigger = TIM_TS_TI2FP2;
if(HAL_TIM_SlaveConfigSynchronization(&TimHandle, &sSlaveConfig) != HAL_OK)
{
/* Configuration Error */
Error_Handler();
}
/*##-4- Start the Input Capture in interrupt mode ##########################*/
if(HAL_TIM_IC_Start_IT(&TimHandle, TIM_CHANNEL_2) != HAL_OK)
{
/* Starting Error */
Error_Handler();
}
/*##-5- Start the Input Capture in interrupt mode ##########################*/
if(HAL_TIM_IC_Start_IT(&TimHandle, TIM_CHANNEL_1) != HAL_OK)
{
/* Starting Error */
Error_Handler();
}
/* Infinite loop */
while (1)
{
}
}
开发者ID:451506709,项目名称:automated_machine,代码行数:93,代码来源:main.c
示例14: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* STM32F0xx HAL library initialization:
- Configure the Flash prefetch
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Low Level Initialization
*/
HAL_Init();
/* Configure the system clock to 48 MHz */
SystemClock_Config();
/* Configure LED1, LED2 and LED3 */
BSP_LED_Init(LED1);
BSP_LED_Init(LED2);
BSP_LED_Init(LED3);
/*##-1- Configure the I2C peripheral #######################################*/
I2cHandle.Instance = I2Cx;
I2cHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
I2cHandle.Init.Timing = I2Cx_TIMING;
I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
I2cHandle.Init.OwnAddress1 = 0;
I2cHandle.Init.OwnAddress2 = 0;
I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
I2cHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED;
if (HAL_I2C_Init(&I2cHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
/* The board sends the message to EEPROM then reads it back */
/*##-2- Start writing process ##############################################*/
/* Initialize Remaining Bytes Value to TX Buffer Size */
Remaining_Bytes = TXBUFFERSIZE;
/* Initialize Memory address to 0 since EEPROM write will start from address 0 */
Memory_Address = 0;
/* Since page size is 4 bytes, the write procedure will be done in a loop */
while (Remaining_Bytes > 0)
{
/* Write 4 bytes */
if (HAL_I2C_Mem_Write_DMA(&I2cHandle, (uint16_t)I2C_ADDRESS, Memory_Address, I2C_MEMADD_SIZE_16BIT, (uint8_t *)(aTxBuffer + Memory_Address), 4) != HAL_OK)
{
/* Writing process Error */
Error_Handler();
}
/* Wait for the end of the transfer */
while (HAL_I2C_GetState(&I2cHandle) != HAL_I2C_STATE_READY)
{
}
/* Check if the EEPROM is ready for a new operation */
while (HAL_I2C_IsDeviceReady(&I2cHandle, I2C_ADDRESS, 20, 300) == HAL_TIMEOUT);
/* Wait for the end of the transfer */
while (HAL_I2C_GetState(&I2cHandle) != HAL_I2C_STATE_READY)
{
}
/* Update Remaining bytes and Memory Address values */
Remaining_Bytes -= 4;
Memory_Address += 4;
}
/*##-3- Start reading process ##############################################*/
if (HAL_I2C_Mem_Read_DMA(&I2cHandle, (uint16_t)I2C_ADDRESS, 0, I2C_MEMADD_SIZE_16BIT, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)
{
/* Reading process Error */
Error_Handler();
}
/* Wait for the end of the transfer */
while (HAL_I2C_GetState(&I2cHandle) != HAL_I2C_STATE_READY)
{
}
/*##-4- Compare the sent and received buffers ##############################*/
if (Buffercmp((uint8_t *)aTxBuffer, (uint8_t *)aRxBuffer, RXBUFFERSIZE))
{
/* Processing Error */
Error_Handler();
}
/* Infinite loop */
while (1)
{
//.........这里部分代码省略.........
开发者ID:GreyCardinalRus,项目名称:stm32-cube,代码行数:101,代码来源:main.c
|
请发表评论