Skip to content

Commit 6fdb60a

Browse files
committed
prepare wiring_digital.c for splitting
1 parent c38409c commit 6fdb60a

2 files changed

Lines changed: 55 additions & 3 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
wiring_digital.c - digital input and output functions
3+
Part of Arduino - http://www.arduino.cc/
4+
5+
Copyright (c) 2005-2006 David A. Mellis
6+
7+
This library is free software; you can redistribute it and/or
8+
modify it under the terms of the GNU Lesser General Public
9+
License as published by the Free Software Foundation; either
10+
version 2.1 of the License, or (at your option) any later version.
11+
12+
This library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General
18+
Public License along with this library; if not, write to the
19+
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20+
Boston, MA 02111-1307 USA
21+
22+
Modified 28 September 2010 by Mark Sproul
23+
*/
24+
25+
26+
/*
27+
* compile the tables from pins_arduino.h
28+
*
29+
*/
30+
#define ARDUINO_MAIN
31+
#include "wiring_private.h"
32+
#include "pins_arduino.h"

sduino/hardware/sduino/stm8/cores/sduino/wiring_digital.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
Modified 28 September 2010 by Mark Sproul
2323
*/
2424

25-
#define ARDUINO_MAIN
2625
#include "wiring_private.h"
2726
#include "pins_arduino.h"
2827

@@ -35,7 +34,15 @@
3534
*/
3635
typedef unsigned char *uc_p;
3736

38-
/* timer capture/compare mode register to control PWM mode */
37+
extern const uc_p ccmrx[NUM_TIMERS];
38+
extern const uc_p ccerx[NUM_TIMERS];
39+
extern const unsigned char DISABLE_TIMER_OUTP_MASK[NUM_TIMERS];
40+
void turnOffPWM(uint8_t timer);
41+
42+
43+
/**
44+
* timer capture/compare mode register to control PWM mode
45+
*/
3946
const uc_p ccmrx[NUM_TIMERS]={
4047
#ifdef NEED_TIMER_11_12
4148
TIM1->CCMR1, /* for TIMER11 */
@@ -110,6 +117,9 @@ const unsigned char DISABLE_TIMER_OUTP_MASK[NUM_TIMERS]={
110117
};
111118

112119

120+
/**
121+
* set the input or output mode of a pin
122+
*/
113123
/* arduino-style pinMode
114124
void pinMode(uint8_t pin, uint8_t mode)
115125
{
@@ -225,7 +235,11 @@ void pinMode(uint8_t pin, uint8_t mode)
225235
*
226236
* SDCC is really, really not good in optimizing its code.
227237
*/
228-
static void turnOffPWM(uint8_t timer)
238+
239+
/**
240+
* handle the PWM pins
241+
*/
242+
void turnOffPWM(uint8_t timer)
229243
{
230244
// Output compare mode = 000: Frozen - The comparison between the output
231245
// compare register TIM1_CCR1 and the counter register TIM1_CNT has no
@@ -237,6 +251,9 @@ static void turnOffPWM(uint8_t timer)
237251
}
238252

239253

254+
/**
255+
* set an output value for a pin
256+
*/
240257
void digitalWrite(uint8_t pin, uint8_t val)
241258
{
242259
uint8_t timer = digitalPinToTimer(pin);
@@ -263,6 +280,9 @@ void digitalWrite(uint8_t pin, uint8_t val)
263280
END_CRITICAL
264281
}
265282

283+
/**
284+
* read a pin value
285+
*/
266286
int digitalRead(uint8_t pin)
267287
{
268288
uint8_t timer = digitalPinToTimer(pin);

0 commit comments

Comments
 (0)