Make headers in extras more cpp friendly

This commit is contained in:
UncleRus 2016-10-24 18:09:17 +05:00 committed by rus
parent 2994a566a6
commit 57cb9b925c
12 changed files with 130 additions and 29 deletions

View file

@ -20,6 +20,10 @@
#define BMP180_TEMPERATURE (1<<0) #define BMP180_TEMPERATURE (1<<0)
#define BMP180_PRESSURE (1<<1) #define BMP180_PRESSURE (1<<1)
#ifdef __cplusplus
extern "C" {
#endif
// //
// Create bmp180_types // Create bmp180_types
// //
@ -79,4 +83,8 @@ bool bmp180_fillInternalConstants(bmp180_constants_t *c);
bool bmp180_measure(bmp180_constants_t *c, int32_t *temperature, bool bmp180_measure(bmp180_constants_t *c, int32_t *temperature,
uint32_t *pressure, uint8_t oss); uint32_t *pressure, uint8_t oss);
#ifdef __cplusplus
}
#endif
#endif /* DRIVER_BMP180_H_ */ #endif /* DRIVER_BMP180_H_ */

View file

@ -27,6 +27,10 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* Uncomment to enable debug output. * 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, bool bmp280_read_float(bmp280_t *dev, float *temperature,
float *pressure, float *humidity); float *pressure, float *humidity);
#ifdef __cplusplus
}
#endif
#endif // __BMP280_H__ #endif // __BMP280_H__

View file

@ -14,6 +14,10 @@
#define DHCPSERVER_LEASE_TIME 3600 #define DHCPSERVER_LEASE_TIME 3600
#endif #endif
#ifdef __cplusplus
extern "C" {
#endif
/* Start DHCP server. /* Start DHCP server.
Static IP of server should already be set and network interface enabled. 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); void dhcpserver_stop(void);
#ifdef __cplusplus
}
#endif
#endif #endif

View file

@ -17,6 +17,10 @@
// Type of sensor to use // Type of sensor to use
#define DHT_TYPE DHT22 #define DHT_TYPE DHT22
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* Read data from sensor on specified pin. * 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); bool dht_read_float_data(uint8_t pin, float *humidity, float *temperature);
#ifdef __cplusplus
}
#endif
#endif // __DHT_H__ #endif // __DHT_H__

View file

@ -3,6 +3,10 @@
#include "onewire/onewire.h" #include "onewire/onewire.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @file ds18b20.h /** @file ds18b20.h
* *
* Communicate with the DS18B20 family of one-wire temperature sensor ICs. * 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. // temperature from single dallas chip.
float ds18b20_read_single(uint8_t pin); float ds18b20_read_single(uint8_t pin);
#ifdef __cplusplus
}
#endif #endif
#endif /* DRIVER_DS18B20_H_ */

View file

@ -13,40 +13,44 @@
#include <stdbool.h> #include <stdbool.h>
#include <time.h> #include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
#define DS3231_ADDR 0x68 #define DS3231_ADDR 0x68
#define DS3231_STAT_OSCILLATOR 0x80 #define DS3231_STAT_OSCILLATOR 0x80
#define DS3231_STAT_32KHZ 0x08 #define DS3231_STAT_32KHZ 0x08
#define DS3231_STAT_BUSY 0x04 #define DS3231_STAT_BUSY 0x04
#define DS3231_STAT_ALARM_2 0x02 #define DS3231_STAT_ALARM_2 0x02
#define DS3231_STAT_ALARM_1 0x01 #define DS3231_STAT_ALARM_1 0x01
#define DS3231_CTRL_OSCILLATOR 0x80 #define DS3231_CTRL_OSCILLATOR 0x80
#define DS3231_CTRL_SQUAREWAVE_BB 0x40 #define DS3231_CTRL_SQUAREWAVE_BB 0x40
#define DS3231_CTRL_TEMPCONV 0x20 #define DS3231_CTRL_TEMPCONV 0x20
#define DS3231_CTRL_SQWAVE_4096HZ 0x10 #define DS3231_CTRL_SQWAVE_4096HZ 0x10
#define DS3231_CTRL_SQWAVE_1024HZ 0x08 #define DS3231_CTRL_SQWAVE_1024HZ 0x08
#define DS3231_CTRL_SQWAVE_8192HZ 0x18 #define DS3231_CTRL_SQWAVE_8192HZ 0x18
#define DS3231_CTRL_SQWAVE_1HZ 0x00 #define DS3231_CTRL_SQWAVE_1HZ 0x00
#define DS3231_CTRL_ALARM_INTS 0x04 #define DS3231_CTRL_ALARM_INTS 0x04
#define DS3231_CTRL_ALARM2_INT 0x02 #define DS3231_CTRL_ALARM2_INT 0x02
#define DS3231_CTRL_ALARM1_INT 0x01 #define DS3231_CTRL_ALARM1_INT 0x01
#define DS3231_ALARM_WDAY 0x40 #define DS3231_ALARM_WDAY 0x40
#define DS3231_ALARM_NOTSET 0x80 #define DS3231_ALARM_NOTSET 0x80
#define DS3231_ADDR_TIME 0x00 #define DS3231_ADDR_TIME 0x00
#define DS3231_ADDR_ALARM1 0x07 #define DS3231_ADDR_ALARM1 0x07
#define DS3231_ADDR_ALARM2 0x0b #define DS3231_ADDR_ALARM2 0x0b
#define DS3231_ADDR_CONTROL 0x0e #define DS3231_ADDR_CONTROL 0x0e
#define DS3231_ADDR_STATUS 0x0f #define DS3231_ADDR_STATUS 0x0f
#define DS3231_ADDR_AGING 0x10 #define DS3231_ADDR_AGING 0x10
#define DS3231_ADDR_TEMP 0x11 #define DS3231_ADDR_TEMP 0x11
#define DS3231_12HOUR_FLAG 0x40 #define DS3231_12HOUR_FLAG 0x40
#define DS3231_12HOUR_MASK 0x1f #define DS3231_12HOUR_MASK 0x1f
#define DS3231_PM_FLAG 0x20 #define DS3231_PM_FLAG 0x20
#define DS3231_MONTH_MASK 0x1f #define DS3231_MONTH_MASK 0x1f
enum { enum {
DS3231_SET = 0, DS3231_SET = 0,
@ -184,4 +188,8 @@ bool ds3231_getTempFloat(float *temp);
bool ds3231_getTime(struct tm *time); bool ds3231_getTime(struct tm *time);
void ds3231_Init(uint8_t scl, uint8_t sda); void ds3231_Init(uint8_t scl, uint8_t sda);
#ifdef __cplusplus
}
#endif #endif
#endif /* __DS3231_H__ */

View file

@ -24,11 +24,14 @@
#ifndef __I2C_H__ #ifndef __I2C_H__
#define __I2C_H__ #define __I2C_H__
#endif
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
// Init bitbanging I2C driver on given pins // Init bitbanging I2C driver on given pins
void i2c_init(uint8_t scl_pin, uint8_t sda_pin); 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. // devices where the i2c_slave_[read|write] functions above are of no use.
void i2c_start(void); void i2c_start(void);
void i2c_stop(void); void i2c_stop(void);
#ifdef __cplusplus
}
#endif
#endif /* __I2C_H__ */

View file

@ -28,6 +28,10 @@
#include <stdbool.h> #include <stdbool.h>
#include "esp/slc_regs.h" #include "esp/slc_regs.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*i2s_dma_isr_t)(void); typedef void (*i2s_dma_isr_t)(void);
typedef struct dma_descriptor { 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; return (dma_descriptor_t*)SLC.RX_EOF_DESCRIPTOR_ADDR;
} }
#ifdef __cplusplus
}
#endif
#endif // __I2S_DMA_H__ #endif // __I2S_DMA_H__

View file

@ -4,6 +4,10 @@
#include <espressif/esp_misc.h> // sdk_os_delay_us #include <espressif/esp_misc.h> // sdk_os_delay_us
#include "FreeRTOS.h" #include "FreeRTOS.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @file onewire.h /** @file onewire.h
* *
* Routines to access devices using the Dallas Semiconductor 1-Wire(tm) * 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); uint16_t onewire_crc16(const uint8_t* input, size_t len, uint16_t crc_iv);
#ifdef __cplusplus
}
#endif #endif
#endif /* __ONEWIRE_H__ */

View file

@ -5,10 +5,17 @@
* Copyright (C) 2015 Javier Cardona (https://github.com/jcard0na) * Copyright (C) 2015 Javier Cardona (https://github.com/jcard0na)
* BSD Licensed as described in the file LICENSE * BSD Licensed as described in the file LICENSE
*/ */
#ifndef EXTRAS_PWM_H_
#define EXTRAS_PWM_H_
#include <stdint.h> #include <stdint.h>
#define MAX_PWM_PINS 8 #define MAX_PWM_PINS 8
#ifdef __cplusplus
extern "C" {
#endif
void pwm_init(uint8_t npins, uint8_t* pins); void pwm_init(uint8_t npins, uint8_t* pins);
void pwm_set_freq(uint16_t freq); void pwm_set_freq(uint16_t freq);
void pwm_set_duty(uint16_t duty); void pwm_set_duty(uint16_t duty);
@ -16,3 +23,9 @@ void pwm_set_duty(uint16_t duty);
void pwm_restart(); void pwm_restart();
void pwm_start(); void pwm_start();
void pwm_stop(); void pwm_stop();
#ifdef __cplusplus
}
#endif
#endif /* EXTRAS_PWM_H_ */

View file

@ -35,6 +35,10 @@
#include "espressif/esp_common.h" // sdk_os_delay_us #include "espressif/esp_common.h" // sdk_os_delay_us
#include "esp/gpio.h" #include "esp/gpio.h"
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* @brief Struct for easy manipulation of RGB colors. * @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 sdk_os_delay_us(50); // display the loaded colors
} }
#ifdef __cplusplus
}
#endif
#endif /* WS2812_DRV_H */ #endif /* WS2812_DRV_H */

View file

@ -27,6 +27,10 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct { typedef struct {
uint8_t red; uint8_t red;
uint8_t green; uint8_t green;
@ -50,4 +54,8 @@ void ws2812_i2s_init(uint32_t pixels_number);
*/ */
void ws2812_i2s_update(ws2812_pixel_t *pixels); void ws2812_i2s_update(ws2812_pixel_t *pixels);
#ifdef __cplusplus
}
#endif
#endif // __WS2812_I2S_H__ #endif // __WS2812_I2S_H__