2023/01/02 ARM M4核串口中断实验

gpio.c

void HAL_GPIO_EXTI_Falling_Callback(uint16_t GPIO_Pin)
{
	switch( GPIO_Pin)
	{
		/*Key2*/
		case GPIO_PIN_7:
			HAL_GPIO_TogglePin(GPIOF, GPIO_PIN_10);
		printf("Key2...\n");
		break;
		/*Key3*/
		case GPIO_PIN_8:
			HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_10);
		printf("Key3...\n");
		break;
		/*Key1*/
		case GPIO_PIN_9:
			HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_8);
		printf("Key1...\n");
		break;
	}
}
void HAL_GPIO_EXTI_Rising_Callback(uint16_t GPIO_Pin)
{
	switch( GPIO_Pin)
	{
		/*fire*/
		case GPIO_PIN_5:
			HAL_GPIO_TogglePin(GPIOF, GPIO_PIN_10);
		printf("Fire...\n");
		break;
		/*people*/
		case GPIO_PIN_12:
			HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_10);
		printf("People...\n");
		break;
		/*light*/
		case GPIO_PIN_15:
			HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_8);
		printf("Light...\n");
		break;
	}
}

usart.cxianxiang

int fputc(int ch, FILE* stream)
{
	//判断发送寄存器是否为空
	while(!(huart4.Instance->ISR &(0x1 << 7)));
	//将要发送的数据,写入到发送寄存器中
	huart4.Instance->TDR = ch;
	//判断要发送的数据是否为'\n'
	if(ch == '\n')
	{
		while(!(huart4.Instance->ISR &(0x1 << 7)));
		huart4.Instance->TDR = '\r';
	}
	return ch;
}

现象:

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值