Skip to content

Commit 04786ca

Browse files
committed
Add Wire
Signed-off-by: Bigbits <[email protected]>
1 parent d8b2123 commit 04786ca

File tree

8 files changed

+677
-6
lines changed

8 files changed

+677
-6
lines changed

cores/arduino/HardwareI2C.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
class HardwareI2C : public Stream
25+
{
26+
public:
27+
virtual void begin() = 0;
28+
virtual void begin(uint8_t address) = 0;
29+
virtual void end() = 0;
30+
31+
virtual void setClock(uint32_t freq) = 0;
32+
33+
virtual void beginTransmission(uint8_t address) = 0;
34+
virtual uint8_t endTransmission(bool stopBit) = 0;
35+
virtual uint8_t endTransmission(void) = 0;
36+
37+
virtual uint8_t requestFrom(uint8_t address, size_t len, bool stopBit) = 0;
38+
virtual uint8_t requestFrom(uint8_t address, size_t len) = 0;
39+
40+
virtual void onReceive(void(*)(int)) = 0;
41+
virtual void onRequest(void(*)(void)) = 0;
42+
};
43+

cores/arduino/RingBuffer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
// using a ring buffer (I think), in which head is the index of the location
2828
// to which to write the next incoming character and tail is the index of the
2929
// location from which to read.
30-
#define SERIAL_BUFFER_SIZE 64
30+
#define RING_BUFFER_SIZE 64
3131

3232
template <int N>
3333
class RingBufferN
@@ -51,7 +51,7 @@ class RingBufferN
5151
int nextIndex(int index);
5252
};
5353

54-
typedef RingBufferN<SERIAL_BUFFER_SIZE> RingBuffer;
54+
typedef RingBufferN<RING_BUFFER_SIZE> RingBuffer;
5555

5656

5757
template <int N>

libraries/Wire/keywords.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#######################################
2+
# Syntax Coloring Map For Wire
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
#######################################
10+
# Methods and Functions (KEYWORD2)
11+
#######################################
12+
13+
begin KEYWORD2
14+
setClock KEYWORD2
15+
setClockStretchLimit KEYWORD2
16+
beginTransmission KEYWORD2
17+
endTransmission KEYWORD2
18+
requestFrom KEYWORD2
19+
send KEYWORD2
20+
receive KEYWORD2
21+
onReceive KEYWORD2
22+
onRequest KEYWORD2
23+
24+
#######################################
25+
# Instances (KEYWORD2)
26+
#######################################
27+
28+
Wire KEYWORD2
29+
Wire1 KEYWORD2
30+
Wire2 KEYWORD2
31+
32+
#######################################
33+
# Constants (LITERAL1)
34+
#######################################
35+

libraries/Wire/library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=Wire
2+
version=1.0.0
3+
author=Bigbits
4+
maintainer=
5+
sentence=Allows the communication between devices or sensors connected via Two Wire Interface Bus. For k210 boards.
6+
paragraph=
7+
category=Signal Input/Output
8+
url=http://arduino.cc/en/Reference/Wire
9+
architectures=riscv

0 commit comments

Comments
 (0)