Add libcanardv1 for Cyphal, rename libcanard to libcanardv0

This commit is contained in:
Peter van der Perk 2022-08-01 15:44:33 +02:00 committed by Xiang Xiao
parent cfa5af51cd
commit 819c34e975
19 changed files with 1075 additions and 53 deletions

View file

@ -3,22 +3,22 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
config CANUTILS_LIBCANARD
bool "libcanard UAVCAN Library"
config CANUTILS_LIBCANARDV0
bool "libcanard UAVCAN v0 Library"
default n
depends on CAN && CAN_EXTID
---help---
Enable the libcanard UAVCAN library.
Enable the libcanard UAVCAN v0 library.
if CANUTILS_LIBCANARD
if CANUTILS_LIBCANARDV0
config LIBCANARD_URL
config LIBCANARDV0_URL
string "libcanard URL"
default "https://github.com/UAVCAN/libcanard/archive"
---help---
libcanard URL.
config LIBCANARD_VERSION
config LIBCANARDV0_VERSION
string "libcanard Version"
default "5ad65c6a4efda60cda7a8f0512da0f465822bbb8"
---help---

View file

@ -1,5 +1,5 @@
############################################################################
# apps/canutils/libcanard/Make.defs
# apps/canutils/libcanardv0/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@ -18,6 +18,6 @@
#
############################################################################
ifeq ($(CONFIG_CANUTILS_LIBCANARD),y)
CONFIGURED_APPS += $(APPDIR)/canutils/libcanard
ifeq ($(CONFIG_CANUTILS_LIBCANARDV0),y)
CONFIGURED_APPS += $(APPDIR)/canutils/libcanardv0
endif

View file

@ -1,5 +1,5 @@
############################################################################
# apps/canutils/libcanard/Makefile
# apps/canutils/libcanardv0/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@ -23,38 +23,38 @@ include $(APPDIR)/Make.defs
UNPACK = unzip
PACKEXT = .zip
LIBCANARD_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARD_URL)))
LIBCANARD_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARD_VERSION)))
LIBCANARD_UNPACKNAME = libcanard-$(LIBCANARD_VERSION)
LIBCANARD_PACKNAME = $(LIBCANARD_UNPACKNAME)$(PACKEXT)
LIBCANARD_SRCDIR = $(LIBCANARD_UNPACKNAME)
LIBCANARD_DRVDIR = $(LIBCANARD_SRCDIR)$(DELIM)drivers$(DELIM)nuttx
LIBCANARDV0_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARDV0_URL)))
LIBCANARDV0_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARDV0_VERSION)))
LIBCANARDV0_UNPACKNAME = libcanard-$(LIBCANARDV0_VERSION)
LIBCANARDV0_PACKNAME = $(LIBCANARDV0_UNPACKNAME)$(PACKEXT)
LIBCANARDV0_SRCDIR = $(LIBCANARDV0_UNPACKNAME)
LIBCANARDV0_DRVDIR = $(LIBCANARDV0_SRCDIR)$(DELIM)drivers$(DELIM)nuttx
APPS_INCDIR = $(APPDIR)$(DELIM)include$(DELIM)canutils
CFLAGS += -std=c99 -DCANARD_ASSERT=DEBUGASSERT
CFLAGS += ${shell $(INCDIR) "$(CC)" $(APPS_INCDIR)}
CSRCS = $(LIBCANARD_SRCDIR)$(DELIM)canard.c $(LIBCANARD_DRVDIR)$(DELIM)canard_nuttx.c
CSRCS = $(LIBCANARDV0_SRCDIR)$(DELIM)canard.c $(LIBCANARDV0_DRVDIR)$(DELIM)canard_nuttx.c
$(LIBCANARD_PACKNAME):
$(LIBCANARDV0_PACKNAME):
@echo "Downloading: $@"
$(Q) curl -o $@ -L $(LIBCANARD_URL)$(DELIM)$(LIBCANARD_VERSION)$(PACKEXT)
$(Q) curl -o $@ -L $(LIBCANARDV0_URL)$(DELIM)$(LIBCANARDV0_VERSION)$(PACKEXT)
$(LIBCANARD_UNPACKNAME): $(LIBCANARD_PACKNAME)
$(LIBCANARDV0_UNPACKNAME): $(LIBCANARDV0_PACKNAME)
@echo "Unpacking: $< -> $@"
$(call DELDIR, $@)
$(Q) $(UNPACK) $<
$(Q) touch $@
$(LIBCANARD_SRCDIR)$(DELIM)canard.h: $(LIBCANARD_UNPACKNAME)
$(LIBCANARDV0_SRCDIR)$(DELIM)canard.h: $(LIBCANARDV0_UNPACKNAME)
$(LIBCANARD_DRVDIR)$(DELIM)canard_nuttx.h: $(LIBCANARD_UNPACKNAME)
$(LIBCANARDV0_DRVDIR)$(DELIM)canard_nuttx.h: $(LIBCANARDV0_UNPACKNAME)
$(APPS_INCDIR)$(DELIM)canard.h: $(LIBCANARD_SRCDIR)$(DELIM)canard.h
$(APPS_INCDIR)$(DELIM)canard.h: $(LIBCANARDV0_SRCDIR)$(DELIM)canard.h
$(Q) cp $< $@
$(APPS_INCDIR)$(DELIM)canard_nuttx.h: $(LIBCANARD_DRVDIR)$(DELIM)canard_nuttx.h
$(APPS_INCDIR)$(DELIM)canard_nuttx.h: $(LIBCANARDV0_DRVDIR)$(DELIM)canard_nuttx.h
$(Q) cp $< $@
context:: $(APPS_INCDIR)$(DELIM)canard.h $(APPS_INCDIR)$(DELIM)canard_nuttx.h
@ -65,7 +65,7 @@ clean::
distclean::
$(call DELFILE, $(APPS_INCDIR)$(DELIM)canard.h)
$(call DELFILE, $(APPS_INCDIR)$(DELIM)canard_nuttx.h)
$(call DELDIR, $(LIBCANARD_UNPACKNAME))
$(call DELFILE, $(LIBCANARD_PACKNAME))
$(call DELDIR, $(LIBCANARDV0_UNPACKNAME))
$(call DELFILE, $(LIBCANARDV0_PACKNAME))
include $(APPDIR)/Application.mk

2
canutils/libcanardv1/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/libcanard-*
/o1heap-*

View file

@ -0,0 +1,39 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config CANUTILS_LIBCANARDV1
bool "libcanard UAVCAN v1 Library"
default n
depends on NET_CAN && ALLOW_MIT_COMPONENTS
---help---
Enable the libcanard UAVCAN v1 library.
if CANUTILS_LIBCANARDV1
config LIBCANARDV1_URL
string "libcanard URL"
default "https://github.com/UAVCAN/libcanard/archive"
---help---
libcanard URL.
config LIBCANARDV1_VERSION
string "libcanard Version"
default "cde670347425023480a1417fcd603b27c8eb06c1"
---help---
libcanard version.
config O1HEAP_URL
string "O(1) heap URL"
default "https://github.com/pavel-kirienko/o1heap/archive"
---help---
libcanard URL.
config O1HEAP_VERSION
string "O(1) heap Version"
default "b21b069e4b971d3016dd232784faca6f7d9fd724"
---help---
libcanard version.
endif

View file

@ -0,0 +1,23 @@
############################################################################
# apps/canutils/libcanardv1/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifeq ($(CONFIG_CANUTILS_LIBCANARDV1),y)
CONFIGURED_APPS += $(APPDIR)/canutils/libcanardv1
endif

View file

@ -0,0 +1,100 @@
############################################################################
# apps/canutils/libcanardv1/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(APPDIR)/Make.defs
UNPACK = unzip
PACKEXT = .zip
LIBCANARDV1_URL = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARDV1_URL)))
LIBCANARDV1_VERSION = $(patsubst "%",%,$(strip $(CONFIG_LIBCANARDV1_VERSION)))
LIBCANARDV1_UNPACKNAME = libcanard-$(LIBCANARDV1_VERSION)
LIBCANARDV1_PACKNAME = $(LIBCANARDV1_UNPACKNAME)$(PACKEXT)
LIBCANARDV1_SRCDIR = $(LIBCANARDV1_UNPACKNAME)
LIBCANARDV1_DRVDIR = $(LIBCANARDV1_SRCDIR)$(DELIM)libcanard
O1HEAP_URL = $(patsubst "%",%,$(strip $(CONFIG_O1HEAP_URL)))
O1HEAP_VERSION = $(patsubst "%",%,$(strip $(CONFIG_O1HEAP_VERSION)))
O1HEAP_UNPACKNAME = o1heap-$(O1HEAP_VERSION)
O1HEAP_PACKNAME = $(O1HEAP_UNPACKNAME)$(PACKEXT)
O1HEAP_SRCDIR = $(O1HEAP_UNPACKNAME)
O1HEAP_DRVDIR = $(O1HEAP_SRCDIR)$(DELIM)o1heap
APPS_INCDIR = $(APPDIR)$(DELIM)include$(DELIM)canutils
CFLAGS += -std=c11 -DCANARD_ASSERT=DEBUGASSERT -DCANARD_DSDL_CONFIG_LITTLE_ENDIAN=1
CFLAGS += ${shell $(INCDIR) "$(CC)" $(APPS_INCDIR)}
CSRCS = $(LIBCANARDV1_DRVDIR)$(DELIM)canard.c $(LIBCANARDV1_DRVDIR)$(DELIM)canard_dsdl.c
CSRCS += $(O1HEAP_DRVDIR)$(DELIM)o1heap.c
$(LIBCANARDV1_PACKNAME):
@echo "Downloading: $@"
$(Q) curl -o $@ -L $(LIBCANARDV1_URL)$(DELIM)$(LIBCANARDV1_VERSION)$(PACKEXT)
$(LIBCANARDV1_UNPACKNAME): $(LIBCANARDV1_PACKNAME)
@echo "Unpacking: $< -> $@"
$(call DELDIR, $@)
$(Q) $(UNPACK) $<
$(Q) touch $@
$(O1HEAP_PACKNAME):
@echo "Downloading: $@"
$(Q) curl -o $@ -L $(O1HEAP_URL)$(DELIM)$(O1HEAP_VERSION)$(PACKEXT)
$(O1HEAP_UNPACKNAME): $(O1HEAP_PACKNAME)
@echo "Unpacking: $< -> $@"
$(call DELDIR, $@)
$(Q) $(UNPACK) $<
$(Q) touch $@
$(LIBCANARDV1_DRVDIR)$(DELIM)canard.h: $(LIBCANARDV1_UNPACKNAME)
$(LIBCANARDV1_DRVDIR)$(DELIM)canard_dsdl.h: $(LIBCANARDV1_UNPACKNAME)
$(O1HEAP_DRVDIR)$(DELIM)o1heap.h: $(O1HEAP_UNPACKNAME)
$(APPS_INCDIR)$(DELIM)canard.h: $(LIBCANARDV1_DRVDIR)$(DELIM)canard.h
$(Q) cp $< $@
$(APPS_INCDIR)$(DELIM)canard_dsdl.h: $(LIBCANARDV1_DRVDIR)$(DELIM)canard_dsdl.h
$(Q) cp $< $@
$(APPS_INCDIR)$(DELIM)o1heap.h: $(O1HEAP_DRVDIR)$(DELIM)o1heap.h
$(Q) cp $< $@
context:: $(APPS_INCDIR)$(DELIM)canard.h $(APPS_INCDIR)$(DELIM)canard_dsdl.h $(APPS_INCDIR)$(DELIM)o1heap.h
clean::
$(foreach OBJ, $(OBJS), $(call DELFILE, $(OBJ)))
distclean::
$(call DELFILE, $(APPS_INCDIR)$(DELIM)canard.h)
$(call DELFILE, $(APPS_INCDIR)$(DELIM)canard_dsdl.h)
$(call DELDIR, $(LIBCANARDV1_UNPACKNAME))
$(call DELFILE, $(LIBCANARDV1_PACKNAME))
$(call DELDIR, $(O1HEAP_UNPACKNAME))
$(call DELFILE, $(O1HEAP_PACKNAME))
$(call DELFILE, $(APPS_INCDIR)$(DELIM)o1heap.h)
$(call DELDIR, $(O1HEAP_UNPACKNAME))
$(call DELFILE, $(O1HEAP_PACKNAME))
include $(APPDIR)/Application.mk