initial commit

This commit is contained in:
2025-08-05 15:53:44 +08:00
commit 09dc02ae52
553 changed files with 137665 additions and 0 deletions

7
hal/hal_lightsensor/config.mk Executable file
View File

@@ -0,0 +1,7 @@
SRC += $(wildcard $(HAL_DIR)/hal_lightsensor/*.c)
CFLAGS += -I$(HAL_DIR)/hal_lightsensor
ifdef MOD_IRCUT
SRC += $(wildcard $(HAL_DIR)/hal_lightsensor/$(MOD_IRCUT)/*.c)
else
$(warning warning you sure no audio?)
endif

View File

@@ -0,0 +1,53 @@
/*************************************************
File name : hal_interface_lightsensor.c
Module :
Author : amir
Version : 0.1
Created on : 2022-02-07
Description :
hal interface for lightsensor
Modify History:
1. Date: Author: Modification:
*************************************************/
#include "hal_interface_lightsensor.h"
#include "hal_interface_ircut.h"
#include "hlog.h"
#define TAG "TAG_HAL_LIGHTSESNOR"
#define PERIOD_TO_GET_ADC ((uint16_t)(500))//ms
#define IRLED_OPEN ((uint8_t)(1))
static void* hal_lightsensor_entry(void *param){
uint32_t adc;
if (hal_lightsensor_get_adc(&adc) == 0){
IRCUT_MODE cur_mode = hal_ircut_mode_get();
if (adc < NIGHT_ADC && cur_mode != IRCUT_NIGHT){//to night
kpacket *packet = kpacket_new(EVENT_HAL_DAYNIGHT, sizeof(uint32_t));
*packet->box->payload = IRCUT_NIGHT;
hal_pub(packet);
atomic_dec(packet);
}else if (adc > DAY_ADC && cur_mode != IRCUT_DAY){//to day
kpacket *packet = kpacket_new(EVENT_HAL_DAYNIGHT, sizeof(uint32_t));
*packet->box->payload = IRCUT_DAY;
hal_pub(packet);
atomic_dec(packet);
}
hlogd("%s adc %u cur_mode:%d",__func__, adc, cur_mode);
}else{
hlogd("%s hal_lightsensor_get_adc err",__func__);
}
return 0;
}
uint32_t hal_lightsensor_start(){
hal_timer_start(hal_lightsensor_entry, NULL, PERIOD_TO_GET_ADC);
}
uint32_t hal_lightsensor_stop(){
hal_timer_stop(hal_lightsensor_entry);
}

View File

@@ -0,0 +1,34 @@
#ifndef __HAL_LIGHTSENSOR_H__
#define __HAL_LIGHTSENSOR_H__
#include "hal.h"
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#define NIGHT_ADC ((uint16_t)(30))
#define DAY_ADC ((uint16_t)(60))
////////////////////////////////////////////////////////////
//
// 数据类型定义
//
////////////////////////////////////////////////////////////
uint32_t hal_lightsensor_init();
uint32_t hal_lightsensor_deinit();
uint32_t hal_lightsensor_start();
uint32_t hal_lightsensor_stop();
uint32_t hal_lightsensor_get_adc(uint32_t *p_adc);// <NIGHT_ADC to night, >=DAY_ADC to day
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __HAL_LIGHTSENSOR_H__ */

View File

@@ -0,0 +1,24 @@
#include "hal_interface_lightsensor.h"
#include "hlog.h"
#define TAG "TAG_HAL_LIGHTSESNOR"
uint32_t hal_lightsensor_init(){
hlogi("%s ok", __func__);
hal_lightsensor_start();
return 0;
}
uint32_t hal_lightsensor_deinit(){
hal_lightsensor_stop();
return 0;
}
uint32_t hal_lightsensor_get_adc(uint32_t *p_adc){
*p_adc = 70;
return 0;
}
DECLARE_INIT(PRI_AFTER_DRIVER, hal_lightsensor_init);