Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite30a03e

Browse files
committed
Added HardwareSerial API
1 parenta9f4f1c commite30a03e

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

‎api/ArduinoAPI.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#ifdef__cplusplus
2929
#include"Client.h"
30+
#include"HardwareSerial.h"
3031
#include"IPAddress.h"
3132
#include"Print.h"
3233
#include"Printable.h"

‎api/HardwareSerial.h‎

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
Copyright (c) 2016 Arduino LLC. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#pragma once
20+
21+
#include<inttypes.h>
22+
#include"Stream.h"
23+
24+
// XXX: Those constants should be defined as const int / enums?
25+
// XXX: shall we use namespaces too?
26+
#defineSERIAL_PARITY_EVEN (0x1ul)
27+
#defineSERIAL_PARITY_ODD (0x2ul)
28+
#defineSERIAL_PARITY_NONE (0x3ul)
29+
#defineSERIAL_PARITY_MARK (0x4ul)
30+
#defineSERIAL_PARITY_SPACE (0x5ul)
31+
#defineSERIAL_PARITY_MASK (0xFul)
32+
33+
#defineSERIAL_STOP_BIT_1 (0x10ul)
34+
#defineSERIAL_STOP_BIT_1_5 (0x20ul)
35+
#defineSERIAL_STOP_BIT_2 (0x30ul)
36+
#defineSERIAL_STOP_BIT_MASK (0xF0ul)
37+
38+
#defineSERIAL_DATA_5 (0x100ul)
39+
#defineSERIAL_DATA_6 (0x200ul)
40+
#defineSERIAL_DATA_7 (0x300ul)
41+
#defineSERIAL_DATA_8 (0x400ul)
42+
#defineSERIAL_DATA_MASK (0xF00ul)
43+
44+
#defineSERIAL_5N1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_NONE | SERIAL_DATA_5)
45+
#defineSERIAL_6N1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_NONE | SERIAL_DATA_6)
46+
#defineSERIAL_7N1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_NONE | SERIAL_DATA_7)
47+
#defineSERIAL_8N1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_NONE | SERIAL_DATA_8)
48+
#defineSERIAL_5N2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_NONE | SERIAL_DATA_5)
49+
#defineSERIAL_6N2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_NONE | SERIAL_DATA_6)
50+
#defineSERIAL_7N2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_NONE | SERIAL_DATA_7)
51+
#defineSERIAL_8N2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_NONE | SERIAL_DATA_8)
52+
#defineSERIAL_5E1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_EVEN | SERIAL_DATA_5)
53+
#defineSERIAL_6E1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_EVEN | SERIAL_DATA_6)
54+
#defineSERIAL_7E1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_EVEN | SERIAL_DATA_7)
55+
#defineSERIAL_8E1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_EVEN | SERIAL_DATA_8)
56+
#defineSERIAL_5E2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_EVEN | SERIAL_DATA_5)
57+
#defineSERIAL_6E2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_EVEN | SERIAL_DATA_6)
58+
#defineSERIAL_7E2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_EVEN | SERIAL_DATA_7)
59+
#defineSERIAL_8E2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_EVEN | SERIAL_DATA_8)
60+
#defineSERIAL_5O1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_ODD | SERIAL_DATA_5)
61+
#defineSERIAL_6O1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_ODD | SERIAL_DATA_6)
62+
#defineSERIAL_7O1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_ODD | SERIAL_DATA_7)
63+
#defineSERIAL_8O1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_ODD | SERIAL_DATA_8)
64+
#defineSERIAL_5O2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_ODD | SERIAL_DATA_5)
65+
#defineSERIAL_6O2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_ODD | SERIAL_DATA_6)
66+
#defineSERIAL_7O2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_ODD | SERIAL_DATA_7)
67+
#defineSERIAL_8O2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_ODD | SERIAL_DATA_8)
68+
#defineSERIAL_5M1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_MARK | SERIAL_DATA_5)
69+
#defineSERIAL_6M1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_MARK | SERIAL_DATA_6)
70+
#defineSERIAL_7M1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_MARK | SERIAL_DATA_7)
71+
#defineSERIAL_8M1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_MARK | SERIAL_DATA_8)
72+
#defineSERIAL_5M2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_MARK | SERIAL_DATA_5)
73+
#defineSERIAL_6M2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_MARK | SERIAL_DATA_6)
74+
#defineSERIAL_7M2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_MARK | SERIAL_DATA_7)
75+
#defineSERIAL_8M2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_MARK | SERIAL_DATA_8)
76+
#defineSERIAL_5S1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_SPACE | SERIAL_DATA_5)
77+
#defineSERIAL_6S1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_SPACE | SERIAL_DATA_6)
78+
#defineSERIAL_7S1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_SPACE | SERIAL_DATA_7)
79+
#defineSERIAL_8S1 (SERIAL_STOP_BIT_1 | SERIAL_PARITY_SPACE | SERIAL_DATA_8)
80+
#defineSERIAL_5S2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_SPACE | SERIAL_DATA_5)
81+
#defineSERIAL_6S2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_SPACE | SERIAL_DATA_6)
82+
#defineSERIAL_7S2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_SPACE | SERIAL_DATA_7)
83+
#defineSERIAL_8S2 (SERIAL_STOP_BIT_2 | SERIAL_PARITY_SPACE | SERIAL_DATA_8)
84+
85+
classHardwareSerial :publicStream
86+
{
87+
public:
88+
virtualvoidbegin(unsignedlong) = 0;
89+
virtualvoidbegin(unsignedlong baudrate,uint16_t config) = 0;
90+
virtualvoidend() = 0;
91+
virtualintavailable(void) = 0;
92+
virtualintpeek(void) = 0;
93+
virtualintread(void) = 0;
94+
virtualvoidflush(void) = 0;
95+
virtualsize_twrite(uint8_t) = 0;
96+
using Print::write;// pull in write(str) and write(buf, size) from Print
97+
virtualoperatorbool() = 0;
98+
};
99+
100+
// XXX: Are we keeping the serialEvent API?
101+
externvoidserialEventRun(void) __attribute__((weak));
102+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp