2 Star 1 Fork 1

976717326 / Teacup_Firmware

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
serial.c 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
#include "serial.h"
/** \file
\brief Serial subsystem
Teacup's serial subsystem is a powerful, thoroughly tested and highly modular serial management system.
It uses ringbuffers for both transmit and receive, and intelligently decides whether to wait or drop transmitted characters if the buffer is full.
It also supports XON/XOFF flow control of the receive buffer, to help avoid overruns.
*/
#define TEACUP_C_INCLUDE
#include "serial-avr.c"
#include "serial-arm.c"
#undef TEACUP_C_INCLUDE
/// send a string- look for null byte instead of expecting a length
void serial_writestr(uint8_t *data)
{
uint8_t i = 0, r;
// yes, this is *supposed* to be assignment rather than comparison, so we break when r is assigned zero
while ((r = data[i++]))
serial_writechar(r);
}
/**
Write string from FLASH.
Extensions to output flash memory pointers. This prevents the data to
become part of the .data segment instead of the .code segment. That means
less memory is consumed for multi-character writes.
For single character writes (i.e. '\n' instead of "\n"), using
serial_writechar() directly is the better choice.
*/
void serial_writestr_P(PGM_P data_P)
{
uint8_t r, i = 0;
// yes, this is *supposed* to be assignment rather than comparison, so we break when r is assigned zero
while ((r = pgm_read_byte(&data_P[i++])))
serial_writechar(r);
}
C
1
https://gitee.com/rhh/Teacup_Firmware.git
git@gitee.com:rhh/Teacup_Firmware.git
rhh
Teacup_Firmware
Teacup_Firmware
master

搜索帮助