STM32半主机模式
来源:互联网 发布:怎么在淘宝论坛发帖子 编辑:程序博客网 时间:2024/05/19 02:42
半主机是这么一种机制,它使得在ARM目标上跑的代码,如果主机电脑运行了调试器,那么该代码可以使用该主机电脑的输入输出设备。 这点非常重要,因为开发初期,可能开发者根本不知道该 ARM 器件上有什么输入输出设备,而半主基机制使得你不用知道ARM器件的外设,利用主机电脑的外设就可以实现输入输出调试。 所以要利用目标 ARM器件的输入输出设备,首先要关掉半主机机制。然后再将输入输出重定向到 ARM 器件上,如 printf 和 scanf,你需要重写 fputc和 fgetc 函数。下面就是将 scanf 和 printf 重定向到 uart 的代码。
/**
* @brief Retargets the C library printf function to the USART.
* @param ch: the char to be send.
* @param *f:
* @retval the char that send out.
*/
int fputc(int ch, FILE *f)
{
/* lace your implementation of fputc here */
/* e.g. write a character to the USART */
/* Loop until the end of transmission */ while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) { } USART_SendData(USART1, (uint8_t) ch); return ch;
}
/**
* @brief Retargets the C library printf function to the USART.
* @param *f
* @retval the char that received.
*/
int fgetc(FILE *f)
{
int ch;
while (USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET)
{
}
ch = USART_ReceiveData(USART1);
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) { } USART_SendData(USART1, (uint8_t) ch); return ch;
}
阅读全文
0 0
- STM32半主机模式
- STM32半主机模式
- STM32半主机模式
- STM32 printf半主机模式
- STM32使用半主机调试
- STM32笔记---避免使用 C 库半主机
- KEIL工具之半主机模式
- stm32的modbus主机,读取电表等
- STM32-modbus rtu 之主机程序
- Android USB 主机模式
- Android USB 主机模式
- Android USB 主机模式
- Android USB 主机模式
- STM32--低功耗模式
- STM32启动模式 收藏
- STM32启动模式
- STM32待机模式测试
- stm32进入standby模式
- ubantu下的搜狗输入法安装
- CTS、CTS-V、GTS版本更新,及其注意事项
- YOLO v2 CPU 使用 openblas 加速
- 牛客网解题-2017网易雷火实习生笔试题
- 4-5 基础堆排序和Heapify(两个版本的基于堆的排序算法)
- STM32半主机模式
- apt-get update 失败
- 代理设计模式1(知识点总结)
- HashSet如何重写了hashcode()和equals()
- Android 手机卫士(6)消息处理机制
- 《算法与数据结构》学习笔记 4-6 优化的堆排序(原地堆排序)
- oracle中单引号和双引号的作用
- Linux下Tomcat重新启动
- 安全的终止正在运行的线程