/*********************************************************************************
|
* Copyright: (C) 2019 LingYun IoT System Studio
|
* All rights reserved.
|
*
|
* Filename: hal.h
|
* Description: This file is HAL(Hardware Abstract Layer) initial functions
|
*
|
* Version: 1.0.0(2019年06月24日)
|
* Author: Guo Wenxue <guowenxue@gmail.com>
|
* ChangeLog: 1, Release initial version on "2019年06月24日 23时46分47秒"
|
*
|
********************************************************************************/
|
|
#ifndef _HAL_H_
|
#define _HAL_H_
|
|
#include <gpiod.h>
|
|
#define OFF 0
|
#define ON 1
|
|
#define RELAY_ACTVLEVEL 0
|
#define RELAY_INACTVLEVEL 1
|
|
/* Three Lights code */
|
enum
|
{
|
LIGHT1 = 0,
|
LIGHT_HALLWAY = LIGHT1, /* Hallway light with infrared and lux support */
|
|
LIGHT2,
|
LIGHT_LVROOM_LEFT = LIGHT2, /* living room left light control by MQTT */
|
|
LIGHT3,
|
LIGHT_LVROOM_RIGHT= LIGHT3, /* living room right light control by MQTT */
|
|
LIGHT_MAX = 4,
|
};
|
|
|
typedef struct hal_ctx_s
|
{
|
|
int infrared_pin;
|
float lux_threshold;
|
|
int light_cnt;
|
int light_pins[LIGHT_MAX]; /* max support lights */
|
|
int light_intval; /* lights on interval */
|
} hal_ctx_t;
|
|
|
/* init hardware */
|
extern int hal_init(hal_ctx_t *ctx);
|
|
/* terminal hardware */
|
extern void hal_term(hal_ctx_t *ctx);
|
|
/* turn which light on/off */
|
extern void turn_light(int which, int cmd);
|
|
/* Return value: 1(HIGH): Sombody detected 0(LOW): Nobody detected */
|
extern int infrared_detect(void);
|
|
|
#endif /* ----- #ifndef _HAL_H_ ----- */
|