This commit is contained in:
刘可亮
2024-06-04 19:00:30 +08:00
parent 990c72f5be
commit 0a13af6a1d
1668 changed files with 342810 additions and 37726 deletions

View File

@@ -14,30 +14,36 @@
#include "hal_tsen.h"
#include "hal_adcim.h"
#include "mpp_fb.h"
#include "test_tsen.h"
struct aic_tsen_ch aic_tsen_chs[] = {
{
.id = 0,
.available = 1,
.name = "tsen-cpu",
.mode = AIC_TSEN_MODE_SINGLE,
.hta_enable = 0,
.lta_enable = 0,
.otp_enable = 0,
#ifndef CONFIG_FPGA_BOARD_ARTINCHIP
.slope = -1134,
.offset = 2439001,
#endif
}
};
#define AIC_TSEN_CH_CHOSEN 0
static int test_tsen_init()
static void cmd_tsen_usage(void)
{
printf("Compile time: %s %s\n", __DATE__, __TIME__);
printf("Usage: test_tsen [options]\n");
printf("test_tsen read <sensor_id> : Select one channel in [0, %d], default is 0\n", AIC_TSEN_CH_NUM - 1);
printf("test_tsen help : Get this help\n");
printf("\n");
printf("Example: test_tsen read 1\n");
printf("Sensor ID:\n");
printf("\t[0] sensor_cpu\n");
printf("\t[1] sensor_gpai\n");
}
static int test_tsen_init(int argc, char **argv)
{
u32 ch;
static int inited = 0;
struct aic_tsen_ch *chan;
ch = strtod(argv[1], NULL);
hal_tsen_set_ch_num(ARRAY_SIZE(aic_tsen_chs));
chan = hal_tsen_get_valid_ch(ch);
if (chan == NULL) {
printf("Please enter the correct sensor id\n");
return -1;
}
if (!inited) {
hal_adcim_probe();
inited = 1;
@@ -45,7 +51,6 @@ static int test_tsen_init()
if (hal_tsen_clk_init())
return -1;
chan = &aic_tsen_chs[AIC_TSEN_CH_CHOSEN];
hal_tsen_enable(1);
hal_tsen_ch_enable(0, 1);
@@ -54,13 +59,15 @@ static int test_tsen_init()
return 0;
}
static void test_tsen_read(int ch)
static void test_tsen_read(int argc, char **argv)
{
u32 ch;
int num;
s32 value;
struct aic_tsen_ch *chan;
chan = &aic_tsen_chs[AIC_TSEN_CH_CHOSEN];
ch = strtod(argv[1], NULL);
chan = hal_tsen_get_valid_ch(ch);
#ifdef AIC_SID_DRV
hal_tsen_curve_fitting(chan);
@@ -68,6 +75,7 @@ static void test_tsen_read(int ch)
chan->complete = aicos_sem_create(0);
aicos_request_irq(TSEN_IRQn, hal_tsen_irq_handle, 0, NULL, NULL);
printf("Starting the %s sensor temperature reading\n", chan->name);
for (num = 0; num < 10; num++) {
if (hal_tsen_get_temp(chan, &value) >= 0)
printf("num:%3d, temp:%3d.%d C (%d)\n", num, value / 10,value % 10,
@@ -78,9 +86,19 @@ static void test_tsen_read(int ch)
static int cmd_test_tsen(int argc, char *argv[])
{
if (test_tsen_init())
return -1;
test_tsen_read(0);
if (argc < 3) {
cmd_tsen_usage();
return 0;
}
if (!strcmp(argv[1], "read")) {
if (!test_tsen_init(argc - 1, &argv[1])) {
test_tsen_read(argc - 1, &argv[1]);
return 0;
}
}
cmd_tsen_usage();
return 0;
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2024, Artinchip Technology Co., Ltd
*
* SPDX-License-Identifier: Apache-2.0
*
* Authors: Li Siyao <siyao.li@artinchip.com>
*/
struct aic_tsen_ch aic_tsen_chs[] = {
#ifdef AIC_USING_TSEN_CPU
{
.id = 0,
.available = 1,
.name = "tsen_cpu",
.mode = AIC_TSEN0_MODE,
.soft_mode = AIC_TSEN0_SOFT_MODE,
.hta_enable = 0,
.lta_enable = 0,
.otp_enable = 0,
#ifndef CONFIG_FPGA_BOARD_ARTINCHIP
.slope = -1134,
.offset = 2439001,
#endif
},
#endif
#ifdef AIC_USING_TSEN_GPAI
{
.id = 1,
.available = 1,
.name = "tsen_gpai",
.mode = AIC_TSEN1_MODE,
.soft_mode = AIC_TSEN1_SOFT_MODE,
.hta_enable = 0,
.lta_enable = 0,
.otp_enable = 0,
#ifndef CONFIG_FPGA_BOARD_ARTINCHIP
.slope = -1139,
.offset = 2450566,
#endif
}
#endif
};