Skip to content

Commit d6248de

Browse files
committed
organize core-api extensions
mbed extensions to the normal Arduino API are located in 'core-extend'
1 parent 9912f90 commit d6248de

File tree

7 files changed

+61
-28
lines changed

7 files changed

+61
-28
lines changed

bridge/pins.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,6 @@ pin_size_t pinNumberByIndex(pin_size_t index);
4545
#define pinDACByIndex(I) variantPinStates[I].dac
4646
#define pinGPIOByIndex(I) variantPinStates[I].gpio
4747

48-
// API extensions
49-
void indexPinMode(pin_size_t index, Arduino_PinMode pinMode);
50-
void pinMode(PinName pinName, Arduino_PinMode pinMode);
51-
void indexDigitalWrite(pin_size_t index, PinStatus val);
52-
void digitalWrite(PinName pinName, PinStatus val);
53-
PinStatus indexDigitalRead(pin_size_t index);
54-
PinStatus digitalRead(PinName pinName);
55-
void indexAnalogWriteDAC(pin_size_t index, int val);
56-
void analogWriteDAC(PinName pinName, int val);
57-
void analogWriteDAC(pin_size_t pinNumber, int val);
58-
void indexAnalogWrite(pin_size_t index, int val);
59-
void analogWrite(PinName pinName, int val);
60-
61-
#ifdef __cplusplus
62-
63-
unsigned long indexPulseIn(pin_size_t index, uint8_t state, unsigned long timeout = 1000000L);
64-
unsigned long pulseIn(PinName pinName, uint8_t state, unsigned long timeout = 1000000L);
65-
unsigned long indexPulseInLong(pin_size_t index, uint8_t state, unsigned long timeout = 1000000L);
66-
unsigned long pulseInLong(PinName pinName, uint8_t state, unsigned long timeout = 1000000L);
67-
68-
#endif // __cplusplus
69-
7048
extern const pin_size_t variantPinCount;
7149
extern PinState variantPinStates[];
7250

core-extend/Common.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
Copyright (c) 2020 SparkFun Electronics
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.
21+
*/
22+
23+
#ifndef _ARDUINO_MBED_BRIDGE_EXTEND_COMMON_H_
24+
#define _ARDUINO_MBED_BRIDGE_EXTEND_COMMON_H_
25+
26+
#include "Arduino.h"
27+
28+
#include "bridge/pins.h"
29+
30+
void indexPinMode(pin_size_t index, Arduino_PinMode pinMode);
31+
void pinMode(PinName pinName, Arduino_PinMode pinMode);
32+
33+
void indexDigitalWrite(pin_size_t index, PinStatus val);
34+
void digitalWrite(PinName pinName, PinStatus val);
35+
36+
PinStatus indexDigitalRead(pin_size_t index);
37+
PinStatus digitalRead(PinName pinName);
38+
39+
void indexAnalogWriteDAC(pin_size_t index, int val);
40+
void analogWriteDAC(PinName pinName, int val);
41+
void analogWriteDAC(pin_size_t pinNumber, int val);
42+
43+
void indexAnalogWrite(pin_size_t index, int val);
44+
void analogWrite(PinName pinName, int val);
45+
46+
#ifdef __cplusplus
47+
48+
unsigned long indexPulseIn(pin_size_t index, uint8_t state, unsigned long timeout = 1000000L);
49+
unsigned long pulseIn(PinName pinName, uint8_t state, unsigned long timeout = 1000000L);
50+
unsigned long indexPulseInLong(pin_size_t index, uint8_t state, unsigned long timeout = 1000000L);
51+
unsigned long pulseInLong(PinName pinName, uint8_t state, unsigned long timeout = 1000000L);
52+
53+
#endif // __cplusplus
54+
55+
#endif // _ARDUINO_MBED_BRIDGE_EXTEND_COMMON_H_

core-implement/CommonAnalog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ SOFTWARE.
2626
#include "core-api/api/Common.h"
2727
#undef PinMode
2828

29-
#include "bridge/pins.h"
29+
#include "core-extend/Common.h"
3030

3131
#define standInFunc() printf("Stand-In for '%s' [file: %s, line: %d]\n", __FUNCTION__, __FILE__, __LINE__)
3232

core-implement/CommonDigital.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ SOFTWARE.
2626
#include "core-api/api/Common.h"
2727
#undef PinMode
2828

29-
#include "bridge/pins.h"
29+
#include "core-extend/Common.h"
3030

3131
#define standInFunc() printf("Stand-In for '%s' [file: %s, line: %d]\n", __FUNCTION__, __FILE__, __LINE__)
3232

core-implement/CommonInit.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ SOFTWARE.
2424
#include "core-api/api/Common.h"
2525
#undef PinMode
2626

27+
#include "core-extend/Common.h"
28+
2729
extern void initTimer(void);
2830

2931
void init(void){

core-implement/CommonPulse.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ SOFTWARE.
2626
#include "core-api/api/Common.h"
2727
#undef PinMode
2828

29-
#include "bridge/pins.h"
30-
31-
#define standInFunc() printf("Stand-In for '%s' [file: %s, line: %d]\n", __FUNCTION__, __FILE__, __LINE__)
29+
#include "core-extend/Common.h"
3230

3331
// unsigned long indexPulseIn(pin_size_t index, uint8_t state, unsigned long timeout){
3432
// standInFunc();

core-implement/CommonTiming.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ SOFTWARE.
2626
#include "core-api/api/Common.h"
2727
#undef PinMode
2828

29-
#include "bridge/pins.h"
29+
#include "core-extend/Common.h"
3030

3131
#define standInFunc() printf("Stand-In for '%s' [file: %s, line: %d]\n", __FUNCTION__, __FILE__, __LINE__)
3232

0 commit comments

Comments
 (0)