Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Open Source > Industrial > Hardware &&
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
9 Star 166 Fork 18

GVP RTduino/RTduino

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (2)
Tags (3)
master
spi-fix
v1.0.0
v0.1.1
v0.1.0
master
Branches (2)
Tags (3)
master
spi-fix
v1.0.0
v0.1.1
v0.1.0
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (2)
Tags (3)
master
spi-fix
v1.0.0
v0.1.1
v0.1.0
RTduino
/
core
/
HardwareSerial.cpp
RTduino
/
core
/
HardwareSerial.cpp
HardwareSerial.cpp 7.99 KB
Copy Edit Raw Blame History
满鉴霆 authored 2025年01月19日 02:44 +08:00 . [core][LLT] add Serial LLT test cases
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
/*
* Copyright (c) 2021-2022, RTduino Development Team
*
* SPDX-License-Identifier: LGPL-v2.1
*
* https://github.com/RTduino/RTduino
* https://gitee.com/rtduino/RTduino
*
* Change Logs:
* Date Author Notes
* 2022年03月24日 Meco Man first version
*/
#include <rtdevice.h>
#include "HardwareSerial.h"
#define DBG_TAG "RTduino.HardwareSerial"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
static void ard2rtt_serial_bound(uint32_t baud, uint8_t config, struct serial_configure &rt_config)
{
switch(baud)
{
case 2400:
rt_config.baud_rate = BAUD_RATE_2400;
break;
case 4800:
rt_config.baud_rate = BAUD_RATE_4800;
break;
case 9600:
rt_config.baud_rate = BAUD_RATE_9600;
break;
case 19200:
rt_config.baud_rate = BAUD_RATE_19200;
break;
case 38400:
rt_config.baud_rate = BAUD_RATE_38400;
break;
case 57600:
rt_config.baud_rate = BAUD_RATE_57600;
break;
case 230400:
rt_config.baud_rate = BAUD_RATE_230400;
break;
case 460800:
rt_config.baud_rate = BAUD_RATE_460800;
break;
case 921600:
rt_config.baud_rate = BAUD_RATE_921600;
break;
case 2000000:
rt_config.baud_rate = BAUD_RATE_2000000;
break;
case 3000000:
rt_config.baud_rate = BAUD_RATE_3000000;
break;
case 115200:
default:
rt_config.baud_rate = BAUD_RATE_115200;
break;
}
switch(config)
{
case SERIAL_5N1:
rt_config.data_bits = DATA_BITS_5;
rt_config.stop_bits = STOP_BITS_1;
rt_config.parity = PARITY_NONE;
break;
case SERIAL_6N1:
rt_config.data_bits = DATA_BITS_6;
rt_config.stop_bits = STOP_BITS_1;
rt_config.parity = PARITY_NONE;
break;
case SERIAL_7N1:
rt_config.data_bits = DATA_BITS_7;
rt_config.stop_bits = STOP_BITS_1;
rt_config.parity = PARITY_NONE;
break;
case SERIAL_5N2:
rt_config.data_bits = DATA_BITS_5;
rt_config.stop_bits = STOP_BITS_2;
rt_config.parity = PARITY_NONE;
break;
case SERIAL_6N2:
rt_config.data_bits = DATA_BITS_6;
rt_config.stop_bits = STOP_BITS_2;
rt_config.parity = PARITY_NONE;
break;
case SERIAL_7N2:
rt_config.data_bits = DATA_BITS_7;
rt_config.stop_bits = STOP_BITS_2;
rt_config.parity = PARITY_NONE;
break;
case SERIAL_8N2:
rt_config.data_bits = DATA_BITS_8;
rt_config.stop_bits = STOP_BITS_2;
rt_config.parity = PARITY_NONE;
break;
case SERIAL_5E1:
rt_config.data_bits = DATA_BITS_5;
rt_config.stop_bits = STOP_BITS_1;
rt_config.parity = PARITY_EVEN;
break;
case SERIAL_6E1:
rt_config.data_bits = DATA_BITS_6;
rt_config.stop_bits = STOP_BITS_1;
rt_config.parity = PARITY_EVEN;
break;
case SERIAL_7E1:
rt_config.data_bits = DATA_BITS_7;
rt_config.stop_bits = STOP_BITS_1;
rt_config.parity = PARITY_EVEN;
break;
case SERIAL_8E1:
rt_config.data_bits = DATA_BITS_8;
rt_config.stop_bits = STOP_BITS_1;
rt_config.parity = PARITY_EVEN;
break;
case SERIAL_5E2:
rt_config.data_bits = DATA_BITS_5;
rt_config.stop_bits = STOP_BITS_2;
rt_config.parity = PARITY_EVEN;
break;
case SERIAL_6E2:
rt_config.data_bits = DATA_BITS_6;
rt_config.stop_bits = STOP_BITS_2;
rt_config.parity = PARITY_EVEN;
break;
case SERIAL_7E2:
rt_config.data_bits = DATA_BITS_7;
rt_config.stop_bits = STOP_BITS_2;
rt_config.parity = PARITY_EVEN;
break;
case SERIAL_8E2:
rt_config.data_bits = DATA_BITS_8;
rt_config.stop_bits = STOP_BITS_2;
rt_config.parity = PARITY_EVEN;
break;
case SERIAL_5O1:
rt_config.data_bits = DATA_BITS_5;
rt_config.stop_bits = STOP_BITS_1;
rt_config.parity = PARITY_ODD;
break;
case SERIAL_6O1:
rt_config.data_bits = DATA_BITS_6;
rt_config.stop_bits = STOP_BITS_1;
rt_config.parity = PARITY_ODD;
break;
case SERIAL_7O1:
rt_config.data_bits = DATA_BITS_7;
rt_config.stop_bits = STOP_BITS_1;
rt_config.parity = PARITY_ODD;
break;
case SERIAL_8O1:
rt_config.data_bits = DATA_BITS_8;
rt_config.stop_bits = STOP_BITS_1;
rt_config.parity = PARITY_ODD;
break;
case SERIAL_5O2:
rt_config.data_bits = DATA_BITS_5;
rt_config.stop_bits = STOP_BITS_2;
rt_config.parity = PARITY_ODD;
break;
case SERIAL_6O2:
rt_config.data_bits = DATA_BITS_6;
rt_config.stop_bits = STOP_BITS_2;
rt_config.parity = PARITY_ODD;
break;
case SERIAL_7O2:
rt_config.data_bits = DATA_BITS_7;
rt_config.stop_bits = STOP_BITS_2;
rt_config.parity = PARITY_ODD;
break;
case SERIAL_8O2:
rt_config.data_bits = DATA_BITS_8;
rt_config.stop_bits = STOP_BITS_2;
rt_config.parity = PARITY_ODD;
break;
case SERIAL_8N1:
default:
rt_config.data_bits = DATA_BITS_8;
rt_config.stop_bits = STOP_BITS_1;
rt_config.parity = PARITY_NONE;
break;
}
}
HardwareSerial::HardwareSerial(rt_device_t device)
{
this->uart_dev = device;
if (this->uart_dev != RT_NULL)
{
LOG_D("HardwareSerial %s (console) initiate successfully", RT_CONSOLE_DEVICE_NAME);
}
else
{
LOG_E("HardwareSerial %s (console) initiate failure", RT_CONSOLE_DEVICE_NAME);
}
}
HardwareSerial::HardwareSerial(const char* dev_name)
{
rt_err_t err = -RT_ERROR;
this->uart_dev = rt_device_find(dev_name);
if (this->uart_dev != RT_NULL)
{
err = rt_device_open(this->uart_dev, RT_DEVICE_FLAG_INT_RX);
}
if (err == RT_EOK)
{
LOG_D("HardwareSerial %s initiate successfully", dev_name);
}
else
{
LOG_E("HardwareSerial %s initiate failure", dev_name);
}
}
/*Code to display letter when given the ASCII code for it*/
size_t HardwareSerial::write(uint8_t c)
{
return write(&c, 1);
}
/*Code to display array of chars when given a pointer to the beginning of the array and a size
-- this will not end with the null character*/
size_t HardwareSerial::write(const uint8_t *buffer, size_t size)
{
return rt_device_write(this->uart_dev, 0, buffer, size);
}
void HardwareSerial::begin(void)
{
/* Do nothing. Use RT-Thread default configurations: typically 115200, 8N1 */
}
void HardwareSerial::begin(uint32_t baud)
{
begin(baud, SERIAL_8N1);
}
void HardwareSerial::begin(uint32_t baud, uint8_t config)
{
struct serial_configure rt_config = RT_SERIAL_CONFIG_DEFAULT;
ard2rtt_serial_bound(baud, config, rt_config);
rt_device_control(this->uart_dev, RT_DEVICE_CTRL_CONFIG, &rt_config);
}
void HardwareSerial::end(void)
{
// Nothing to do.
// RTduino has not right to close RT-Thread devices.
// This could cause other threads make errors.
}
int HardwareSerial::availableForWrite(void)
{
return 0; //TODO
}
void HardwareSerial::flush(void)
{
//TODO
}
int HardwareSerial::available(void)
{
return 0; //TODO
}
int HardwareSerial::peek(void)
{
return 0; //TODO
}
int HardwareSerial::read(void)
{
return 0; //TODO
}
#ifdef RT_USING_CONSOLE
ConsoleSerial Serial;
#endif /* RT_USING_CONSOLE */
#ifdef RTDUINO_SERIAL2_DEVICE_NAME
HardwareSerial Serial2(RTDUINO_SERIAL2_DEVICE_NAME);
#endif /* RTDUINO_SERIAL2_DEVICE_NAME */
#ifdef RTDUINO_SERIAL3_DEVICE_NAME
HardwareSerial Serial3(RTDUINO_SERIAL3_DEVICE_NAME);
#endif /* RTDUINO_SERIAL3_DEVICE_NAME */
#if defined(RTDUINO_USING_UTEST) || defined(RT_UTEST_USING_ALL_CASES)
void LLT__ard2rtt_serial_bound(uint32_t baud, uint8_t config, struct serial_configure &rt_config)
{
ard2rtt_serial_bound(baud, config, rt_config);
}
#endif /* RTDUINO_USING_UTEST || RT_UTEST_USING_ALL_CASES */
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

RT-Thread的Arduino生态兼容层
Cancel

Releases (1)

All

The Open Source Evaluation Index is derived from the OSS Compass evaluation system, which evaluates projects around the following three dimensions

1. Open source ecosystem

  • Productivity: To evaluate the ability of open-source projects to output software artifacts and open-source value.
  • Innovation: Used to evaluate the degree of diversity of open source software and its ecosystem.
  • Robustness: Used to evaluate the ability of open-source projects to resist internal and external interference and self recover in the face of changing development environments.

2. Collaboration, People, Software

  • Collaboration: represents the degree and depth of collaboration in open source development behavior.
  • Observe the influence of core personnel in open source projects, and examine the evaluations of users and developers on open source projects from a third-party perspective.
  • Software: Evaluate the value of products exported from open-source projects and their ultimate destination. It is also a concrete manifestation of "open source software", one of the oldest mainstream directions in open source evaluation.

3. Evaluation model

    Based on the dimensions of "open source ecosystem" and "collaboration, people, and software", identify quantifiable indicators directly or indirectly related to this goal, quantitatively evaluate the health and ecology of open source projects, and ultimately form an open source evaluation index.

Contributors

All

Language(Optional)

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/rtduino/RTduino.git
git@gitee.com:rtduino/RTduino.git
rtduino
RTduino
RTduino
master
Going to Help Center

Search

Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /