Skip to content

Commit

Permalink
Merge pull request #250 from UncleRus/extras/cpp_fix
Browse files Browse the repository at this point in the history
Make headers in extras more cpp friendly
  • Loading branch information
sheinz committed Oct 24, 2016
2 parents f1d44f5 + 57cb9b9 commit 8840eb0
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 33 deletions.
8 changes: 8 additions & 0 deletions extras/bmp180/bmp180.h
Expand Up @@ -20,6 +20,10 @@
#define BMP180_TEMPERATURE (1<<0)
#define BMP180_PRESSURE (1<<1)

#ifdef __cplusplus
extern "C" {
#endif

//
// Create bmp180_types
//
Expand Down Expand Up @@ -79,4 +83,8 @@ bool bmp180_fillInternalConstants(bmp180_constants_t *c);
bool bmp180_measure(bmp180_constants_t *c, int32_t *temperature,
uint32_t *pressure, uint8_t oss);

#ifdef __cplusplus
}
#endif

#endif /* DRIVER_BMP180_H_ */
8 changes: 8 additions & 0 deletions extras/bmp280/bmp280.h
Expand Up @@ -27,6 +27,10 @@
#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
* Uncomment to enable debug output.
*/
Expand Down Expand Up @@ -184,4 +188,8 @@ bool bmp280_read_fixed(bmp280_t *dev, int32_t *temperature,
bool bmp280_read_float(bmp280_t *dev, float *temperature,
float *pressure, float *humidity);

#ifdef __cplusplus
}
#endif

#endif // __BMP280_H__
8 changes: 8 additions & 0 deletions extras/dhcpserver/include/dhcpserver.h
Expand Up @@ -14,6 +14,10 @@
#define DHCPSERVER_LEASE_TIME 3600
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* Start DHCP server.
Static IP of server should already be set and network interface enabled.
Expand All @@ -30,4 +34,8 @@ void dhcpserver_get_lease(const ip_addr_t *first_client_addr, uint8_t max_leases
*/
void dhcpserver_stop(void);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions extras/dht/dht.h
Expand Up @@ -17,6 +17,10 @@
// Type of sensor to use
#define DHT_TYPE DHT22

#ifdef __cplusplus
extern "C" {
#endif

/**
* Read data from sensor on specified pin.
*
Expand All @@ -35,4 +39,8 @@ bool dht_read_data(uint8_t pin, int16_t *humidity, int16_t *temperature);
*/
bool dht_read_float_data(uint8_t pin, float *humidity, float *temperature);

#ifdef __cplusplus
}
#endif

#endif // __DHT_H__
8 changes: 8 additions & 0 deletions extras/ds18b20/ds18b20.h
Expand Up @@ -3,6 +3,10 @@

#include "onewire/onewire.h"

#ifdef __cplusplus
extern "C" {
#endif

/** @file ds18b20.h
*
* Communicate with the DS18B20 family of one-wire temperature sensor ICs.
Expand Down Expand Up @@ -147,4 +151,8 @@ uint8_t ds18b20_read_all(uint8_t pin, ds_sensor_t *result);
// temperature from single dallas chip.
float ds18b20_read_single(uint8_t pin);

#ifdef __cplusplus
}
#endif

#endif /* DRIVER_DS18B20_H_ */
72 changes: 40 additions & 32 deletions extras/ds3231/ds3231.h
Expand Up @@ -13,40 +13,44 @@
#include <stdbool.h>
#include <time.h>

#ifdef __cplusplus
extern "C" {
#endif

#define DS3231_ADDR 0x68

#define DS3231_STAT_OSCILLATOR 0x80
#define DS3231_STAT_32KHZ 0x08
#define DS3231_STAT_BUSY 0x04
#define DS3231_STAT_ALARM_2 0x02
#define DS3231_STAT_ALARM_1 0x01

#define DS3231_CTRL_OSCILLATOR 0x80
#define DS3231_CTRL_SQUAREWAVE_BB 0x40
#define DS3231_CTRL_TEMPCONV 0x20
#define DS3231_CTRL_SQWAVE_4096HZ 0x10
#define DS3231_CTRL_SQWAVE_1024HZ 0x08
#define DS3231_CTRL_SQWAVE_8192HZ 0x18
#define DS3231_CTRL_SQWAVE_1HZ 0x00
#define DS3231_CTRL_ALARM_INTS 0x04
#define DS3231_CTRL_ALARM2_INT 0x02
#define DS3231_CTRL_ALARM1_INT 0x01

#define DS3231_ALARM_WDAY 0x40
#define DS3231_ALARM_NOTSET 0x80

#define DS3231_ADDR_TIME 0x00
#define DS3231_ADDR_ALARM1 0x07
#define DS3231_ADDR_ALARM2 0x0b
#define DS3231_ADDR_CONTROL 0x0e
#define DS3231_ADDR_STATUS 0x0f
#define DS3231_ADDR_AGING 0x10
#define DS3231_ADDR_TEMP 0x11

#define DS3231_12HOUR_FLAG 0x40
#define DS3231_12HOUR_MASK 0x1f
#define DS3231_PM_FLAG 0x20
#define DS3231_MONTH_MASK 0x1f
#define DS3231_STAT_OSCILLATOR 0x80
#define DS3231_STAT_32KHZ 0x08
#define DS3231_STAT_BUSY 0x04
#define DS3231_STAT_ALARM_2 0x02
#define DS3231_STAT_ALARM_1 0x01

#define DS3231_CTRL_OSCILLATOR 0x80
#define DS3231_CTRL_SQUAREWAVE_BB 0x40
#define DS3231_CTRL_TEMPCONV 0x20
#define DS3231_CTRL_SQWAVE_4096HZ 0x10
#define DS3231_CTRL_SQWAVE_1024HZ 0x08
#define DS3231_CTRL_SQWAVE_8192HZ 0x18
#define DS3231_CTRL_SQWAVE_1HZ 0x00
#define DS3231_CTRL_ALARM_INTS 0x04
#define DS3231_CTRL_ALARM2_INT 0x02
#define DS3231_CTRL_ALARM1_INT 0x01

#define DS3231_ALARM_WDAY 0x40
#define DS3231_ALARM_NOTSET 0x80

#define DS3231_ADDR_TIME 0x00
#define DS3231_ADDR_ALARM1 0x07
#define DS3231_ADDR_ALARM2 0x0b
#define DS3231_ADDR_CONTROL 0x0e
#define DS3231_ADDR_STATUS 0x0f
#define DS3231_ADDR_AGING 0x10
#define DS3231_ADDR_TEMP 0x11

#define DS3231_12HOUR_FLAG 0x40
#define DS3231_12HOUR_MASK 0x1f
#define DS3231_PM_FLAG 0x20
#define DS3231_MONTH_MASK 0x1f

enum {
DS3231_SET = 0,
Expand Down Expand Up @@ -184,4 +188,8 @@ bool ds3231_getTempFloat(float *temp);
bool ds3231_getTime(struct tm *time);
void ds3231_Init(uint8_t scl, uint8_t sda);

#ifdef __cplusplus
}
#endif

#endif /* __DS3231_H__ */
11 changes: 10 additions & 1 deletion extras/i2c/i2c.h
Expand Up @@ -24,11 +24,14 @@

#ifndef __I2C_H__
#define __I2C_H__
#endif

#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

// Init bitbanging I2C driver on given pins
void i2c_init(uint8_t scl_pin, uint8_t sda_pin);

Expand All @@ -49,3 +52,9 @@ bool i2c_slave_read(uint8_t slave_addr, uint8_t data, uint8_t *buf, uint32_t len
// devices where the i2c_slave_[read|write] functions above are of no use.
void i2c_start(void);
void i2c_stop(void);

#ifdef __cplusplus
}
#endif

#endif /* __I2C_H__ */
8 changes: 8 additions & 0 deletions extras/i2s_dma/i2s_dma.h
Expand Up @@ -28,6 +28,10 @@
#include <stdbool.h>
#include "esp/slc_regs.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef void (*i2s_dma_isr_t)(void);

typedef struct dma_descriptor {
Expand Down Expand Up @@ -113,4 +117,8 @@ inline dma_descriptor_t *i2s_dma_get_eof_descriptor()
return (dma_descriptor_t*)SLC.RX_EOF_DESCRIPTOR_ADDR;
}

#ifdef __cplusplus
}
#endif

#endif // __I2S_DMA_H__
8 changes: 8 additions & 0 deletions extras/onewire/onewire.h
Expand Up @@ -4,6 +4,10 @@
#include <espressif/esp_misc.h> // sdk_os_delay_us
#include "FreeRTOS.h"

#ifdef __cplusplus
extern "C" {
#endif

/** @file onewire.h
*
* Routines to access devices using the Dallas Semiconductor 1-Wire(tm)
Expand Down Expand Up @@ -232,4 +236,8 @@ bool onewire_check_crc16(const uint8_t* input, size_t len, const uint8_t* invert
*/
uint16_t onewire_crc16(const uint8_t* input, size_t len, uint16_t crc_iv);

#ifdef __cplusplus
}
#endif

#endif /* __ONEWIRE_H__ */
13 changes: 13 additions & 0 deletions extras/pwm/pwm.h
Expand Up @@ -5,14 +5,27 @@
* Copyright (C) 2015 Javier Cardona (https://github.com/jcard0na)
* BSD Licensed as described in the file LICENSE
*/
#ifndef EXTRAS_PWM_H_
#define EXTRAS_PWM_H_

#include <stdint.h>

#define MAX_PWM_PINS 8

#ifdef __cplusplus
extern "C" {
#endif

void pwm_init(uint8_t npins, uint8_t* pins);
void pwm_set_freq(uint16_t freq);
void pwm_set_duty(uint16_t duty);

void pwm_restart();
void pwm_start();
void pwm_stop();

#ifdef __cplusplus
}
#endif

#endif /* EXTRAS_PWM_H_ */
7 changes: 7 additions & 0 deletions extras/ws2812/ws2812.h
Expand Up @@ -35,6 +35,10 @@
#include "espressif/esp_common.h" // sdk_os_delay_us
#include "esp/gpio.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Struct for easy manipulation of RGB colors.
*
Expand Down Expand Up @@ -204,5 +208,8 @@ void ws2812_seq_end(void)
sdk_os_delay_us(50); // display the loaded colors
}

#ifdef __cplusplus
}
#endif

#endif /* WS2812_DRV_H */
8 changes: 8 additions & 0 deletions extras/ws2812_i2s/ws2812_i2s.h
Expand Up @@ -27,6 +27,10 @@
#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
uint8_t red;
uint8_t green;
Expand All @@ -50,4 +54,8 @@ void ws2812_i2s_init(uint32_t pixels_number);
*/
void ws2812_i2s_update(ws2812_pixel_t *pixels);

#ifdef __cplusplus
}
#endif

#endif // __WS2812_I2S_H__

0 comments on commit 8840eb0

Please sign in to comment.