1.adc2
//adc修正函数
HAL_ADCEx_Calibration_Start(&hadc1,ADC_SINGLE_ENDED);
HAL_ADCEx_Calibration_Start(&hadc2,ADC_SINGLE_ENDED);
//串口接收中断
HAL_UARTEx_ReceiveToIdle_IT(&huart1,(uint8_t *)uart_rx,40);//开启中断
//接受空闲中断回调
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size);
2.iic
unsigned char I2CWaitAck(void)
{
unsigned short cErrTime = 5;
SDA_Input_Mode();
delay1(DELAY_TIME);
SCL_Output(1);
delay1(DELAY_TIME);
while(SDA_Input())
{
cErrTime--;
delay1(DELAY_TIME);
if (0 == cErrTime)
{
SDA_Output_Mode();
I2CStop();
return ERROR;
}
}
SCL_Output(0);
SDA_Output_Mode();
delay1(DELAY_TIME);
return SUCCESS;
}
//先scl延时在SDL