Skip to content

Commit

Permalink
Add chipid command
Browse files Browse the repository at this point in the history
  • Loading branch information
carbonfix committed Dec 25, 2023
1 parent 9e4162f commit a33685b
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions middleware/v2/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ sample/audio/sample_audio_nr
sample/audio/sample_audio_resample
sample/audio/sample_audio_transcode
sample/audio/sample_audio_rtos
sample/chipid/chipid
sample/cipher/sample_cipher
sample/cvg/sample_cvg
sample/mipi_tx/sample_dsi
Expand Down
44 changes: 44 additions & 0 deletions middleware/v2/sample/chipid/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
SHELL = /bin/bash
ifeq ($(PARAM_FILE), )
PARAM_FILE:=../../Makefile.param
include $(PARAM_FILE)
endif
include ../sample.mk

SDIR = $(PWD)
SRCS = $(wildcard $(SDIR)/*.c)
INCS = -I$(MW_INC) -I$(ISP_INC) -I../common/ -I$(KERNEL_INC) -I./inc
OBJS = $(SRCS:.c=.o)
DEPS = $(SRCS:.c=.d)

TARGET = chipid

PKG_CONFIG_PATH = $(MW_PATH)/pkgconfig
REQUIRES = cvi_common

MW_LIBS = $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs --define-variable=mw_dir=$(MW_PATH) $(REQUIRES))

LIBS = $(MW_LIBS)

EXTRA_CFLAGS = $(INCS) $(DEFS)
EXTRA_LDFLAGS = $(LIBS)

.PHONY : clean all
all: $(TARGET)

$(COMMON_DIR)/%.o: $(COMMON_DIR)/%.c
@$(CC) $(DEPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
@echo [$(notdir $(CC))] $(notdir $@)

$(SDIR)/%.o: $(SDIR)/%.c
@$(CC) $(DEPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
@echo [$(notdir $(CC))] $(notdir $@)

$(TARGET): $(COMM_OBJ) $(OBJS) $(ISP_OBJ) $(MW_LIB)/libsys.a
@$(CXX) -o $@ -Wl,--start-group $(OBJS) $(COMM_OBJS) -lsys $(MW_LIB)/libsys.a -Wl,--end-group $(ELFFLAGS) $(EXTRA_LDFLAGS)
@echo -e $(BLUE)[LINK]$(END)[$(notdir $(CXX))] $(notdir $@)

clean:
@rm -f $(OBJS) $(DEPS) $(COMM_OBJ) $(COMM_DEPS) $(TARGET)

-include $(DEPS)
36 changes: 36 additions & 0 deletions middleware/v2/sample/chipid/chipid.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#include "cvi_buffer.h"

#include "cvi_sys.h"

int main(int argc, char **argv)
{
CVI_U32 id = 0;
CVI_S32 ret = CVI_SUCCESS;

UNUSED(argc);
UNUSED(argv);

ret = CVI_SYS_GetChipId(&id);

switch (id) {
case E_CHIPID_CV1800B:
printf("cv1800b\n");
break;
case E_CHIPID_CV1812C:
printf("cv1812c\n");
break;
case E_CHIPID_CV1813H:
printf("cv1813h\n");
break;
default:
printf("unsupported chip id\n");
break;
}

return ret;
}

0 comments on commit a33685b

Please sign in to comment.