chore: Remove tracked build artifacts
This commit is contained in:
@ -1,197 +0,0 @@
|
||||
#include "app_config.h"
|
||||
#include "ir_sensor/ir_manage.h"
|
||||
|
||||
#if(TCFG_IRSENSOR_ENABLE == 1)
|
||||
|
||||
#define LOG_TAG "[IRSENSOR]"
|
||||
#define LOG_ERROR_ENABLE
|
||||
#define LOG_DEBUG_ENABLE
|
||||
#define LOG_INFO_ENABLE
|
||||
/* #define LOG_DUMP_ENABLE */
|
||||
#define LOG_CLI_ENABLE
|
||||
#include "debug.h"
|
||||
|
||||
#if TCFG_SENOR_USER_IIC_TYPE
|
||||
#define iic_init(iic) hw_iic_init(iic)
|
||||
#define iic_uninit(iic) hw_iic_uninit(iic)
|
||||
#define iic_start(iic) hw_iic_start(iic)
|
||||
#define iic_stop(iic) hw_iic_stop(iic)
|
||||
#define iic_tx_byte(iic, byte) hw_iic_tx_byte(iic, byte)
|
||||
#define iic_rx_byte(iic, ack) hw_iic_rx_byte(iic, ack)
|
||||
#define iic_read_buf(iic, buf, len) hw_iic_read_buf(iic, buf, len)
|
||||
#define iic_write_buf(iic, buf, len) hw_iic_write_buf(iic, buf, len)
|
||||
#define iic_suspend(iic) hw_iic_suspend(iic)
|
||||
#define iic_resume(iic) hw_iic_resume(iic)
|
||||
#else
|
||||
#define iic_init(iic) soft_iic_init(iic)
|
||||
#define iic_uninit(iic) soft_iic_uninit(iic)
|
||||
#define iic_start(iic) soft_iic_start(iic)
|
||||
#define iic_stop(iic) soft_iic_stop(iic)
|
||||
#define iic_tx_byte(iic, byte) soft_iic_tx_byte(iic, byte)
|
||||
#define iic_rx_byte(iic, ack) soft_iic_rx_byte(iic, ack)
|
||||
#define iic_read_buf(iic, buf, len) soft_iic_read_buf(iic, buf, len)
|
||||
#define iic_write_buf(iic, buf, len) soft_iic_write_buf(iic, buf, len)
|
||||
#define iic_suspend(iic) soft_iic_suspend(iic)
|
||||
#define iic_resume(iic) soft_iic_resume(iic)
|
||||
#endif
|
||||
|
||||
static const struct irSensor_platform_data *platform_data;
|
||||
IR_SENSOR_INTERFACE *irSensor_hdl = NULL;
|
||||
IR_SENSOR_INFO __irSensor_info = {.iic_delay = 30, .ir_event = IR_SENSOR_EVENT_NULL};
|
||||
#define irSensor_info (&__irSensor_info)
|
||||
|
||||
#define JSA_IIC_DELAY 50
|
||||
|
||||
|
||||
|
||||
u8 irSensor_write(u8 w_chip_id, u8 register_address, u8 function_command)
|
||||
{
|
||||
//spin_lock(&iic_lock);
|
||||
u8 ret = 1;
|
||||
iic_start(irSensor_info->iic_hdl);
|
||||
if (0 == iic_tx_byte(irSensor_info->iic_hdl, w_chip_id)) {
|
||||
ret = 0;
|
||||
log_e("\n JSA iic wr err 0\n");
|
||||
goto __gcend;
|
||||
}
|
||||
|
||||
delay(JSA_IIC_DELAY);
|
||||
|
||||
if (0 == iic_tx_byte(irSensor_info->iic_hdl, register_address)) {
|
||||
ret = 0;
|
||||
log_e("\n JSA iic wr err 1\n");
|
||||
goto __gcend;
|
||||
}
|
||||
|
||||
delay(JSA_IIC_DELAY);
|
||||
|
||||
if (0 == iic_tx_byte(irSensor_info->iic_hdl, function_command)) {
|
||||
ret = 0;
|
||||
log_e("\n JSA iic wr err 2\n");
|
||||
goto __gcend;
|
||||
}
|
||||
|
||||
g_printf("JSA iic wr succ\n");
|
||||
__gcend:
|
||||
iic_stop(irSensor_info->iic_hdl);
|
||||
|
||||
//spin_unlock(&iic_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
u8 irSensor_read(u8 r_chip_id, u8 register_address, u8 *buf, u8 data_len)
|
||||
{
|
||||
u8 read_len = 0;
|
||||
|
||||
//spin_lock(&iic_lock);
|
||||
|
||||
iic_start(irSensor_info->iic_hdl);
|
||||
if (0 == iic_tx_byte(irSensor_info->iic_hdl, r_chip_id - 1)) {
|
||||
log_e("\n JSA iic rd err 0\n");
|
||||
read_len = 0;
|
||||
goto __gdend;
|
||||
}
|
||||
|
||||
|
||||
delay(JSA_IIC_DELAY);
|
||||
if (0 == iic_tx_byte(irSensor_info->iic_hdl, register_address)) {
|
||||
log_e("\n JSA iic rd err 1\n");
|
||||
read_len = 0;
|
||||
goto __gdend;
|
||||
}
|
||||
|
||||
iic_start(irSensor_info->iic_hdl);
|
||||
if (0 == iic_tx_byte(irSensor_info->iic_hdl, r_chip_id)) {
|
||||
log_e("\n JSA iic rd err 2\n");
|
||||
read_len = 0;
|
||||
goto __gdend;
|
||||
}
|
||||
|
||||
delay(JSA_IIC_DELAY);
|
||||
|
||||
for (; data_len > 1; data_len--) {
|
||||
*buf++ = iic_rx_byte(irSensor_info->iic_hdl, 1);
|
||||
read_len ++;
|
||||
}
|
||||
|
||||
*buf = iic_rx_byte(irSensor_info->iic_hdl, 0);
|
||||
read_len ++;
|
||||
|
||||
__gdend:
|
||||
|
||||
iic_stop(irSensor_info->iic_hdl);
|
||||
delay(JSA_IIC_DELAY);
|
||||
|
||||
//spin_unlock(&iic_lock);
|
||||
return read_len;
|
||||
}
|
||||
|
||||
void irSensor_int_io_detect(void *priv)
|
||||
{
|
||||
struct sys_event e;
|
||||
if (gpio_read(irSensor_info->int_io) == 0) {
|
||||
irSensor_info->ir_event = irSensor_hdl->ir_sensor_check();
|
||||
if (irSensor_info->ir_event != IR_SENSOR_EVENT_NULL) {
|
||||
log_info("irSensor event trigger:%d", irSensor_info->ir_event);
|
||||
e.type = SYS_IR_EVENT;
|
||||
e.u.ir.event = irSensor_info->ir_event;
|
||||
sys_event_notify(&e);
|
||||
//Interface: initial state after reboot is near
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum irSensor_event get_irSensor_event(void)
|
||||
{
|
||||
return irSensor_info->ir_event;
|
||||
}
|
||||
|
||||
int ir_sensor_init(void *_data)
|
||||
{
|
||||
int retval = 0;
|
||||
platform_data = (const struct irSensor_platform_data *)_data;
|
||||
irSensor_info->iic_hdl = platform_data->iic;
|
||||
irSensor_info->int_io = platform_data->irSensor_int_io;
|
||||
|
||||
retval = iic_init(irSensor_info->iic_hdl);
|
||||
if (retval < 0) {
|
||||
log_e("\n open iic for gsensor err\n");
|
||||
return retval;
|
||||
} else {
|
||||
log_info("\n iic open succ\n");
|
||||
}
|
||||
|
||||
retval = -EINVAL;
|
||||
list_for_each_irSensor(irSensor_hdl) {
|
||||
if (!memcmp(irSensor_hdl->logo, platform_data->irSensor_name, strlen(platform_data->irSensor_name))) {
|
||||
retval = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (retval < 0) {
|
||||
log_e(">>>irSensor_hdl logo err\n");
|
||||
return retval;
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
g_printf("irSensor_init_io:%d", platform_data->irSensor_int_io);
|
||||
gpio_set_pull_up(platform_data->irSensor_int_io, 0);
|
||||
gpio_set_pull_down(platform_data->irSensor_int_io, 0);
|
||||
gpio_set_direction(platform_data->irSensor_int_io, 1);
|
||||
gpio_set_die(platform_data->irSensor_int_io, 1);
|
||||
|
||||
|
||||
if (irSensor_hdl->ir_sensor_init(platform_data->pxs_low_th, platform_data->pxs_high_th)) {
|
||||
log_info(">>>>irSensor_Int SUCC\n");
|
||||
sys_s_hi_timer_add(NULL, irSensor_int_io_detect, 10);
|
||||
} else {
|
||||
log_e(">>>>irSensor_Int ERROR\n");
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,74 +0,0 @@
|
||||
#ifndef _IR_SENSOR_MANAGE_H
|
||||
#define _IR_SENSOR_MANAGE_H
|
||||
|
||||
#include "printf.h"
|
||||
#include "cpu.h"
|
||||
//#include "iic.h"
|
||||
#include "asm/iic_hw.h"
|
||||
#include "asm/iic_soft.h"
|
||||
#include "timer.h"
|
||||
#include "app_config.h"
|
||||
#include "event.h"
|
||||
#include "system/includes.h"
|
||||
|
||||
enum {
|
||||
IR_SENSOR_RESET_INT = 0,
|
||||
IR_SENSOR_RESUME_INT,
|
||||
IR_SENSOR_INT_DET,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
u8 logo[20];
|
||||
u8(*ir_sensor_init)(u16 low_th, u16 high_th);
|
||||
char (*ir_sensor_check)(void);
|
||||
void (*ir_sensor_ctl)(u8 cmd, void *arg);
|
||||
} IR_SENSOR_INTERFACE;
|
||||
|
||||
|
||||
struct irSensor_platform_data {
|
||||
u8 iic;
|
||||
char irSensor_name[20];
|
||||
int irSensor_int_io;
|
||||
u16 pxs_low_th;
|
||||
u16 pxs_high_th;
|
||||
};
|
||||
|
||||
enum irSensor_event {
|
||||
IR_SENSOR_EVENT_NULL = 0,
|
||||
IR_SENSOR_EVENT_FAR,
|
||||
IR_SENSOR_EVENT_NEAR,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
u8 iic_hdl;
|
||||
u8 iic_delay; //这个延时并非影响iic的时钟频率,而是2Byte数据之间的延时
|
||||
int int_io;
|
||||
int check_timer_hdl;
|
||||
enum irSensor_event ir_event;
|
||||
} IR_SENSOR_INFO;
|
||||
|
||||
int ir_sensor_init(void *_data);
|
||||
u8 ir_sensor_command(u8 w_chip_id, u8 register_address, u8 function_command);
|
||||
|
||||
extern IR_SENSOR_INTERFACE irSensor_dev_begin[];
|
||||
extern IR_SENSOR_INTERFACE irSensor_dev_end[];
|
||||
|
||||
#define REGISTER_IR_SENSOR(gSensor) \
|
||||
static IR_SENSOR_INTERFACE irSensor SEC_USED(.irSensor_dev)
|
||||
|
||||
#define list_for_each_irSensor(c) \
|
||||
for (c=irSensor_dev_begin; c<irSensor_dev_end; c++)
|
||||
|
||||
#define IR_SENSOR_PLATFORM_DATA_BEGIN(data) \
|
||||
static const struct irSensor_platform_data data = {
|
||||
|
||||
#define IR_GSENSOR_PLATFORM_DATA_END() \
|
||||
};
|
||||
|
||||
|
||||
int ir_sensor_init(void *_data);
|
||||
u8 irSensor_write(u8 w_chip_id, u8 register_address, u8 function_command);
|
||||
u8 irSensor_read(u8 r_chip_id, u8 register_address, u8 *buf, u8 data_len);
|
||||
enum irSensor_event get_irSensor_event(void);
|
||||
|
||||
#endif
|
||||
@ -1,75 +0,0 @@
|
||||
#if(TCFG_JSA1221_ENABLE == 1)
|
||||
#include "asm/includes.h"
|
||||
#include "irSensor/jsa1221.h"
|
||||
#include "app_config.h"
|
||||
#include "asm/iic_soft.h"
|
||||
#include "asm/iic_hw.h"
|
||||
#include "system/timer.h"
|
||||
|
||||
#include "system/includes.h"
|
||||
#include "ir_manage.h"
|
||||
|
||||
static u32 jsa_high_th = 0; //红外穿戴中断的触发阈值
|
||||
static u32 jsa_low_th = 0;
|
||||
|
||||
u8 jsa1221_pxs_int_flag(void)
|
||||
{
|
||||
u8 int_flag = 0;
|
||||
irSensor_read(JSA_1221_READ_ADDR, JSA_INT_FLAG, &int_flag, 1);
|
||||
if (int_flag & BIT(1)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
u16 jsa1221_read_pxs_data(void)
|
||||
{
|
||||
u8 lower_data, upper_data = 0;
|
||||
irSensor_read(JSA_1221_READ_ADDR, JSA_PXS_DATA1, &lower_data, 1);
|
||||
irSensor_read(JSA_1221_READ_ADDR, JSA_PXS_DATA2, &upper_data, 1);
|
||||
return (upper_data * 256 + lower_data);
|
||||
}
|
||||
|
||||
enum irSensor_event jsa1221_check(void *_para)
|
||||
{
|
||||
if (jsa1221_pxs_int_flag()) {
|
||||
u16 pxs_data = jsa1221_read_pxs_data();
|
||||
g_printf("DATA:%d", pxs_data);
|
||||
if (pxs_data < jsa_low_th) {
|
||||
g_printf("FAR");
|
||||
return IR_SENSOR_EVENT_FAR;
|
||||
} else {
|
||||
g_printf("NEAR");
|
||||
return IR_SENSOR_EVENT_NEAR;
|
||||
}
|
||||
} else {
|
||||
return IR_SENSOR_EVENT_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
u8 jsa1221_init(u16 pxs_low_th, u16 pxs_high_th)
|
||||
{
|
||||
u32 ret = 1;
|
||||
jsa_low_th = pxs_low_th;
|
||||
jsa_high_th = pxs_high_th;
|
||||
ret &= irSensor_write(JSA_1221_WRITE_ADDR, JSA_CONFIGURE, PXS_ACTIVE_MODE);
|
||||
ret &= irSensor_write(JSA_1221_WRITE_ADDR, JSA_PXS_LOW_TH1, pxs_low_th & 0xff); // low 8 bit
|
||||
ret &= irSensor_write(JSA_1221_WRITE_ADDR, JSA_PXS_LOW_TH2, pxs_low_th >> 8); // upper 8 bit
|
||||
ret &= irSensor_write(JSA_1221_WRITE_ADDR, JSA_PXS_HIGH_TH1, pxs_high_th & 0xff); // low 8 bit
|
||||
ret &= irSensor_write(JSA_1221_WRITE_ADDR, JSA_PXS_HIGH_TH2, pxs_high_th >> 8); // upper 8 bit
|
||||
ret &= irSensor_write(JSA_1221_WRITE_ADDR, JSA_INT_CTRL, BIT(7)); //enable pxs int
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
REGISTER_IR_SENSOR(irSensor) = {
|
||||
.logo = "jsa1221",
|
||||
.ir_sensor_init = jsa1221_init,
|
||||
.ir_sensor_check = jsa1221_check,
|
||||
.ir_sensor_ctl = NULL,
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user