Skip to content

Commit 8840eb0

Browse files
authored
Merge pull request #250 from UncleRus/extras/cpp_fix
Make headers in extras more cpp friendly
2 parents f1d44f5 + 57cb9b9 commit 8840eb0

File tree

12 files changed

+134
-33
lines changed

12 files changed

+134
-33
lines changed

extras/bmp180/bmp180.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#define BMP180_TEMPERATURE (1<<0)
2121
#define BMP180_PRESSURE (1<<1)
2222

23+
#ifdef __cplusplus
24+
extern "C" {
25+
#endif
26+
2327
//
2428
// Create bmp180_types
2529
//
@@ -79,4 +83,8 @@ bool bmp180_fillInternalConstants(bmp180_constants_t *c);
7983
bool bmp180_measure(bmp180_constants_t *c, int32_t *temperature,
8084
uint32_t *pressure, uint8_t oss);
8185

86+
#ifdef __cplusplus
87+
}
88+
#endif
89+
8290
#endif /* DRIVER_BMP180_H_ */

extras/bmp280/bmp280.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
#include <stdint.h>
2828
#include <stdbool.h>
2929

30+
#ifdef __cplusplus
31+
extern "C" {
32+
#endif
33+
3034
/**
3135
* Uncomment to enable debug output.
3236
*/
@@ -184,4 +188,8 @@ bool bmp280_read_fixed(bmp280_t *dev, int32_t *temperature,
184188
bool bmp280_read_float(bmp280_t *dev, float *temperature,
185189
float *pressure, float *humidity);
186190

191+
#ifdef __cplusplus
192+
}
193+
#endif
194+
187195
#endif // __BMP280_H__

extras/dhcpserver/include/dhcpserver.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#define DHCPSERVER_LEASE_TIME 3600
1515
#endif
1616

17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
1721
/* Start DHCP server.
1822
1923
Static IP of server should already be set and network interface enabled.
@@ -30,4 +34,8 @@ void dhcpserver_get_lease(const ip_addr_t *first_client_addr, uint8_t max_leases
3034
*/
3135
void dhcpserver_stop(void);
3236

37+
#ifdef __cplusplus
38+
}
39+
#endif
40+
3341
#endif

extras/dht/dht.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
// Type of sensor to use
1818
#define DHT_TYPE DHT22
1919

20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
2024
/**
2125
* Read data from sensor on specified pin.
2226
*
@@ -35,4 +39,8 @@ bool dht_read_data(uint8_t pin, int16_t *humidity, int16_t *temperature);
3539
*/
3640
bool dht_read_float_data(uint8_t pin, float *humidity, float *temperature);
3741

42+
#ifdef __cplusplus
43+
}
44+
#endif
45+
3846
#endif // __DHT_H__

extras/ds18b20/ds18b20.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#include "onewire/onewire.h"
55

6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
610
/** @file ds18b20.h
711
*
812
* Communicate with the DS18B20 family of one-wire temperature sensor ICs.
@@ -147,4 +151,8 @@ uint8_t ds18b20_read_all(uint8_t pin, ds_sensor_t *result);
147151
// temperature from single dallas chip.
148152
float ds18b20_read_single(uint8_t pin);
149153

154+
#ifdef __cplusplus
155+
}
150156
#endif
157+
158+
#endif /* DRIVER_DS18B20_H_ */

extras/ds3231/ds3231.h

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,44 @@
1313
#include <stdbool.h>
1414
#include <time.h>
1515

16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif
19+
1620
#define DS3231_ADDR 0x68
1721

18-
#define DS3231_STAT_OSCILLATOR 0x80
19-
#define DS3231_STAT_32KHZ 0x08
20-
#define DS3231_STAT_BUSY 0x04
21-
#define DS3231_STAT_ALARM_2 0x02
22-
#define DS3231_STAT_ALARM_1 0x01
23-
24-
#define DS3231_CTRL_OSCILLATOR 0x80
25-
#define DS3231_CTRL_SQUAREWAVE_BB 0x40
26-
#define DS3231_CTRL_TEMPCONV 0x20
27-
#define DS3231_CTRL_SQWAVE_4096HZ 0x10
28-
#define DS3231_CTRL_SQWAVE_1024HZ 0x08
29-
#define DS3231_CTRL_SQWAVE_8192HZ 0x18
30-
#define DS3231_CTRL_SQWAVE_1HZ 0x00
31-
#define DS3231_CTRL_ALARM_INTS 0x04
32-
#define DS3231_CTRL_ALARM2_INT 0x02
33-
#define DS3231_CTRL_ALARM1_INT 0x01
34-
35-
#define DS3231_ALARM_WDAY 0x40
36-
#define DS3231_ALARM_NOTSET 0x80
37-
38-
#define DS3231_ADDR_TIME 0x00
39-
#define DS3231_ADDR_ALARM1 0x07
40-
#define DS3231_ADDR_ALARM2 0x0b
41-
#define DS3231_ADDR_CONTROL 0x0e
42-
#define DS3231_ADDR_STATUS 0x0f
43-
#define DS3231_ADDR_AGING 0x10
44-
#define DS3231_ADDR_TEMP 0x11
45-
46-
#define DS3231_12HOUR_FLAG 0x40
47-
#define DS3231_12HOUR_MASK 0x1f
48-
#define DS3231_PM_FLAG 0x20
49-
#define DS3231_MONTH_MASK 0x1f
22+
#define DS3231_STAT_OSCILLATOR 0x80
23+
#define DS3231_STAT_32KHZ 0x08
24+
#define DS3231_STAT_BUSY 0x04
25+
#define DS3231_STAT_ALARM_2 0x02
26+
#define DS3231_STAT_ALARM_1 0x01
27+
28+
#define DS3231_CTRL_OSCILLATOR 0x80
29+
#define DS3231_CTRL_SQUAREWAVE_BB 0x40
30+
#define DS3231_CTRL_TEMPCONV 0x20
31+
#define DS3231_CTRL_SQWAVE_4096HZ 0x10
32+
#define DS3231_CTRL_SQWAVE_1024HZ 0x08
33+
#define DS3231_CTRL_SQWAVE_8192HZ 0x18
34+
#define DS3231_CTRL_SQWAVE_1HZ 0x00
35+
#define DS3231_CTRL_ALARM_INTS 0x04
36+
#define DS3231_CTRL_ALARM2_INT 0x02
37+
#define DS3231_CTRL_ALARM1_INT 0x01
38+
39+
#define DS3231_ALARM_WDAY 0x40
40+
#define DS3231_ALARM_NOTSET 0x80
41+
42+
#define DS3231_ADDR_TIME 0x00
43+
#define DS3231_ADDR_ALARM1 0x07
44+
#define DS3231_ADDR_ALARM2 0x0b
45+
#define DS3231_ADDR_CONTROL 0x0e
46+
#define DS3231_ADDR_STATUS 0x0f
47+
#define DS3231_ADDR_AGING 0x10
48+
#define DS3231_ADDR_TEMP 0x11
49+
50+
#define DS3231_12HOUR_FLAG 0x40
51+
#define DS3231_12HOUR_MASK 0x1f
52+
#define DS3231_PM_FLAG 0x20
53+
#define DS3231_MONTH_MASK 0x1f
5054

5155
enum {
5256
DS3231_SET = 0,
@@ -184,4 +188,8 @@ bool ds3231_getTempFloat(float *temp);
184188
bool ds3231_getTime(struct tm *time);
185189
void ds3231_Init(uint8_t scl, uint8_t sda);
186190

191+
#ifdef __cplusplus
192+
}
187193
#endif
194+
195+
#endif /* __DS3231_H__ */

extras/i2c/i2c.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@
2424

2525
#ifndef __I2C_H__
2626
#define __I2C_H__
27-
#endif
2827

2928
#include <stdint.h>
3029
#include <stdbool.h>
3130

31+
#ifdef __cplusplus
32+
extern "C" {
33+
#endif
34+
3235
// Init bitbanging I2C driver on given pins
3336
void i2c_init(uint8_t scl_pin, uint8_t sda_pin);
3437

@@ -49,3 +52,9 @@ bool i2c_slave_read(uint8_t slave_addr, uint8_t data, uint8_t *buf, uint32_t len
4952
// devices where the i2c_slave_[read|write] functions above are of no use.
5053
void i2c_start(void);
5154
void i2c_stop(void);
55+
56+
#ifdef __cplusplus
57+
}
58+
#endif
59+
60+
#endif /* __I2C_H__ */

extras/i2s_dma/i2s_dma.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#include <stdbool.h>
2929
#include "esp/slc_regs.h"
3030

31+
#ifdef __cplusplus
32+
extern "C" {
33+
#endif
34+
3135
typedef void (*i2s_dma_isr_t)(void);
3236

3337
typedef struct dma_descriptor {
@@ -113,4 +117,8 @@ inline dma_descriptor_t *i2s_dma_get_eof_descriptor()
113117
return (dma_descriptor_t*)SLC.RX_EOF_DESCRIPTOR_ADDR;
114118
}
115119

120+
#ifdef __cplusplus
121+
}
122+
#endif
123+
116124
#endif // __I2S_DMA_H__

extras/onewire/onewire.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include <espressif/esp_misc.h> // sdk_os_delay_us
55
#include "FreeRTOS.h"
66

7+
#ifdef __cplusplus
8+
extern "C" {
9+
#endif
10+
711
/** @file onewire.h
812
*
913
* Routines to access devices using the Dallas Semiconductor 1-Wire(tm)
@@ -232,4 +236,8 @@ bool onewire_check_crc16(const uint8_t* input, size_t len, const uint8_t* invert
232236
*/
233237
uint16_t onewire_crc16(const uint8_t* input, size_t len, uint16_t crc_iv);
234238

239+
#ifdef __cplusplus
240+
}
235241
#endif
242+
243+
#endif /* __ONEWIRE_H__ */

extras/pwm/pwm.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,27 @@
55
* Copyright (C) 2015 Javier Cardona (https://github.com/jcard0na)
66
* BSD Licensed as described in the file LICENSE
77
*/
8+
#ifndef EXTRAS_PWM_H_
9+
#define EXTRAS_PWM_H_
10+
811
#include <stdint.h>
912

1013
#define MAX_PWM_PINS 8
1114

15+
#ifdef __cplusplus
16+
extern "C" {
17+
#endif
18+
1219
void pwm_init(uint8_t npins, uint8_t* pins);
1320
void pwm_set_freq(uint16_t freq);
1421
void pwm_set_duty(uint16_t duty);
1522

1623
void pwm_restart();
1724
void pwm_start();
1825
void pwm_stop();
26+
27+
#ifdef __cplusplus
28+
}
29+
#endif
30+
31+
#endif /* EXTRAS_PWM_H_ */

0 commit comments

Comments
 (0)