Merge pull request #250 from UncleRus/extras/cpp_fix
Make headers in extras more cpp friendly
This commit is contained in:
commit
8840eb0411
12 changed files with 130 additions and 29 deletions
|
@ -20,6 +20,10 @@
|
|||
#define BMP180_TEMPERATURE (1<<0)
|
||||
#define BMP180_PRESSURE (1<<1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//
|
||||
// Create bmp180_types
|
||||
//
|
||||
|
@ -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_ */
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Uncomment to enable debug output.
|
||||
*/
|
||||
|
@ -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__
|
||||
|
|
|
@ -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.
|
||||
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -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__
|
||||
|
|
|
@ -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.
|
||||
|
@ -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_ */
|
||||
|
|
|
@ -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_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_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_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_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_12HOUR_FLAG 0x40
|
||||
#define DS3231_12HOUR_MASK 0x1f
|
||||
#define DS3231_PM_FLAG 0x20
|
||||
#define DS3231_MONTH_MASK 0x1f
|
||||
|
||||
enum {
|
||||
DS3231_SET = 0,
|
||||
|
@ -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__ */
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -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__ */
|
||||
|
|
|
@ -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 {
|
||||
|
@ -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__
|
||||
|
|
|
@ -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)
|
||||
|
@ -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__ */
|
||||
|
|
|
@ -5,10 +5,17 @@
|
|||
* 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);
|
||||
|
@ -16,3 +23,9 @@ void pwm_set_duty(uint16_t duty);
|
|||
void pwm_restart();
|
||||
void pwm_start();
|
||||
void pwm_stop();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EXTRAS_PWM_H_ */
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -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 */
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
|
@ -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__
|
||||
|
|
Loading…
Reference in a new issue