Skip to content
This repository was archived by the owner on Nov 19, 2022. It is now read-only.

Commit bae8004

Browse files
committed
rename wiring_private.c to wiring_digital.c
1 parent 4b8fbc8 commit bae8004

File tree

6 files changed

+57
-79
lines changed

6 files changed

+57
-79
lines changed

cores/scirocco/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ zephyr_sources(Tone.cpp)
1414
zephyr_sources(UartDevice.cpp)
1515
zephyr_sources(wiring.c)
1616
zephyr_sources(wiring_analog.c)
17-
zephyr_sources(wiring_private.c)
17+
zephyr_sources(wiring_digital.c)
1818
zephyr_sources(wiring_shift.c)
1919
zephyr_sources(WMath.cpp)
2020
zephyr_sources(WString.cpp)

cores/scirocco/WInterrupts.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#define _WIRING_INTERRUPTS_
2121

2222
#include <stdint.h>
23-
#include "wiring_private.h"
2423

2524
#ifdef __cplusplus
2625
extern "C" {
@@ -41,21 +40,15 @@ typedef void (*voidFuncPtr)(void);
4140
* \brief Specifies a named Interrupt Service Routine (ISR) to call when an interrupt occurs.
4241
* Replaces any previous function that was attached to the interrupt.
4342
*/
44-
inline void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode) { w_attach_interrupt(pin, callback, mode); }
43+
void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
4544

4645
/*
4746
* \brief Turns off the given interrupt.
4847
*/
49-
inline void detachInterrupt(uint32_t pin) { w_detach_interrupt(pin); }
48+
void detachInterrupt(uint32_t pin);
5049

5150
#ifdef __cplusplus
5251
}
53-
54-
inline void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode, uint32_t pinmode, uint32_t extraflag=0)
55-
{
56-
w_configure_gpio_interrupt(pin, callback, mode, pinmode, extraflag);
57-
}
58-
5952
#endif
6053

6154
#endif

cores/scirocco/wiring_analog.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ extern "C" {
2727
#include <adc.h>
2828
#include <pwm.h>
2929

30+
#ifndef W_PWM_DEV_NAME
31+
#define W_PWM_DEV_NAME(x) NULL
32+
#endif
33+
3034
#ifdef CONFIG_ADC
3135

3236
void analogReference( eAnalogReference ulMode )

cores/scirocco/wiring_private.c renamed to cores/scirocco/wiring_digital.c

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,39 @@
55
#include "wiring_private.h"
66
#include "WInterrupts.h"
77

8-
int w_pin_mode[W_GPIO_PIN_NUM] = { 0 };
9-
struct w_gpio_callbacks w_callbacks[W_GPIO_PIN_NUM] = { 0 };
8+
#ifndef W_GPIO_PINS_PER_PORT
9+
#define W_GPIO_PINS_PER_PORT 32
10+
#endif
11+
12+
#ifndef W_GPIO_PORT_NUM
13+
#define W_GPIO_PORT_NUM (sizeof(gpio_port_names)/sizeof(const char*))
14+
#endif
15+
16+
#ifndef W_PIN2PORT
17+
#define W_PIN2PORT(x) (gpio_port_names[x / W_GPIO_PINS_PER_PORT])
18+
#endif
19+
20+
#ifndef W_PIN2PORTPIN
21+
#define W_PIN2PORTPIN(x) (x % W_GPIO_PINS_PER_PORT)
22+
#endif
23+
24+
#ifndef W_GPIO_PIN_NUM
25+
#define W_GPIO_PIN_NUM (W_GPIO_PINS_PER_PORT * W_GPIO_PORT_NUM)
26+
#endif
27+
28+
29+
struct w_gpio_callbacks {
30+
struct gpio_callback z_callback;
31+
voidFuncPtr callback;
32+
};
33+
34+
static const char* gpio_port_names[] = W_GPIO_PORT_NAMES;
35+
static int w_pin_mode[W_GPIO_PIN_NUM] = { 0 };
36+
static struct w_gpio_callbacks w_callbacks[W_GPIO_PIN_NUM] = { 0 };
1037

1138
static void gpio_handler(struct device *port, struct gpio_callback *cb, u32_t pins)
1239
{
13-
for(int i=0; i<W_GPIO_PIN_NUM; i++)
40+
for(uint32_t i=0; i<W_GPIO_PIN_NUM; i++)
1441
{
1542
if( (&w_callbacks[i].z_callback) == cb) {
1643
w_callbacks[i].callback();
@@ -71,29 +98,40 @@ void w_configure_gpio_interrupt(uint32_t pin, voidFuncPtr callback, uint32_t int
7198
gpio_pin_enable_callback(device_get_binding(W_PIN2PORT(pin)), pin);
7299
}
73100
else {
74-
w_detach_interrupt(pin);
101+
detachInterrupt(pin);
75102
}
76103

77104
}
78105

79-
void w_attach_interrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
106+
void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
80107
{
81108
uint32_t pinmode = w_pin_mode[pin];
82109
w_configure_gpio_interrupt(pin, callback, mode, pinmode, 0);
83110
}
84-
85-
void w_detach_interrupt(uint32_t pin)
111+
/*
112+
void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode, uint32_t pinmode, uint32_t extraflag)
113+
{
114+
w_configure_gpio_interrupt(pin, callback, mode, pinmode, extraflag);
115+
}
116+
*/
117+
void detachInterrupt(uint32_t pin)
86118
{
87119
gpio_pin_disable_callback(device_get_binding(W_PIN2PORT(pin)), pin);
88120
gpio_remove_callback(device_get_binding(W_PIN2PORT(pin)), &w_callbacks[pin].z_callback);
89121
}
90122

91-
void w_digital_write( uint32_t ulPin, uint32_t ulVal )
123+
void pinMode( uint32_t dwPin, uint32_t dwMode )
124+
{
125+
w_configure_gpio_interrupt(dwPin, NULL, -1, dwMode, 0);
126+
}
127+
128+
129+
void digitalWrite( uint32_t ulPin, uint32_t ulVal )
92130
{
93131
gpio_pin_write(device_get_binding(W_PIN2PORT(ulPin)), W_PIN2PORTPIN(ulPin), ulVal ? 1 : 0);
94132
}
95133

96-
int w_digital_read( uint32_t ulPin )
134+
int digitalRead( uint32_t ulPin )
97135
{
98136
u32_t value;
99137
gpio_pin_read(device_get_binding(W_PIN2PORT(ulPin)), W_PIN2PORTPIN(ulPin), &value);

cores/scirocco/wiring_digital.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#ifndef _WIRING_DIGITAL_
2020
#define _WIRING_DIGITAL_
2121

22-
#include "wiring_private.h"
23-
2422
#ifdef __cplusplus
2523
extern "C" {
2624
#endif
@@ -33,7 +31,7 @@
3331
* \param ulPin The number of the pin whose mode you wish to set
3432
* \param ulMode Can be INPUT, OUTPUT, INPUT_PULLUP or INPUT_PULLDOWN
3533
*/
36-
inline void pinMode( uint32_t dwPin, uint32_t dwMode ) { w_configure_gpio_interrupt(dwPin, NULL, -1, dwMode, 0); }
34+
extern void pinMode( uint32_t dwPin, uint32_t dwMode ) ;
3735

3836
/**
3937
* \brief Write a HIGH or a LOW value to a digital pin.
@@ -55,7 +53,7 @@ inline void pinMode( uint32_t dwPin, uint32_t dwMode ) { w_configure_gpio_interr
5553
* \param dwPin the pin number
5654
* \param dwVal HIGH or LOW
5755
*/
58-
inline void digitalWrite( uint32_t dwPin, uint32_t dwVal ) { w_digital_write(dwPin, dwVal); }
56+
extern void digitalWrite( uint32_t dwPin, uint32_t dwVal ) ;
5957

6058
/**
6159
* \brief Reads the value from a specified digital pin, either HIGH or LOW.
@@ -64,7 +62,7 @@ inline void digitalWrite( uint32_t dwPin, uint32_t dwVal ) { w_digital_write(dwP
6462
*
6563
* \return HIGH or LOW
6664
*/
67-
inline int digitalRead( uint32_t ulPin ) { return w_digital_read(ulPin); }
65+
extern int digitalRead( uint32_t ulPin ) ;
6866

6967
#ifdef __cplusplus
7068
}

cores/scirocco/wiring_private.h

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -32,61 +32,6 @@
3232
extern "C" {
3333
#endif
3434

35-
#ifndef W_GPIO_PINS_PER_PORT
36-
#define W_GPIO_PINS_PER_PORT 32
37-
#endif
38-
39-
#ifndef W_GPIO_PORT_NUM
40-
#define W_GPIO_PORT_NUM (sizeof(gpio_port_names)/sizeof(const char*))
41-
#endif
42-
43-
#ifndef W_PIN2PORT
44-
#define W_PIN2PORT(x) (gpio_port_names[x / W_GPIO_PINS_PER_PORT])
45-
#endif
46-
47-
#ifndef W_PIN2PORTPIN
48-
#define W_PIN2PORTPIN(x) (x % W_GPIO_PINS_PER_PORT)
49-
#endif
50-
51-
#ifndef W_GPIO_PIN_NUM
52-
#define W_GPIO_PIN_NUM (W_GPIO_PINS_PER_PORT * W_GPIO_PORT_NUM)
53-
#endif
54-
55-
#ifndef W_PWM_DEV_NAME
56-
#define W_PWM_DEV_NAME(x) NULL
57-
#endif
58-
59-
typedef void (*voidFuncPtr)(void);
60-
61-
struct w_gpio_callbacks {
62-
struct gpio_callback z_callback;
63-
voidFuncPtr callback;
64-
};
65-
66-
static const char* gpio_port_names[] = GPIO_PORT_NAMES;
67-
68-
extern int w_pin_mode[W_GPIO_PIN_NUM];
69-
extern struct w_gpio_callbacks w_callbacks[W_GPIO_PIN_NUM];
70-
71-
extern void w_digital_write( uint32_t ulPin, uint32_t ulVal );
72-
extern int w_digital_read( uint32_t ulPin );
73-
extern void w_attach_interrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
74-
extern void w_detach_interrupt(uint32_t pin);
75-
76-
extern void w_configure_gpio_interrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode, uint32_t pinmode, uint32_t extraflag);
77-
78-
79-
struct spi_device {
80-
int (*init)(void*);
81-
int (*configure)(void*, bool, bool, bool, uint32_t);
82-
int (*start)(void*);
83-
void (*stop)(void*);
84-
uint8_t (*transfer)(void*, uint8_t);
85-
int (*mask_interrupt_on_transaction)(void*, int);
86-
int (*deinit)(void*);
87-
void* devinfo;
88-
};
89-
9035
#ifdef __cplusplus
9136
} // extern "C"
9237
#endif

0 commit comments

Comments
 (0)