Skip to content

Commit

Permalink
create infrastructure for NO_OS_USB_UART argument
Browse files Browse the repository at this point in the history
no-OS projects may now be built with the NO_OS_USB_UART=y
make argument which will enable the creation of a CDC ACM
device over USB to emulate a serial port.

If the implementation does not exist, building will error
out by not finding the maxim_usb_uart.c implementation file.

Signed-off-by: Darius Berghe <[email protected]>
  • Loading branch information
buha committed Apr 9, 2024
1 parent 0a07b2c commit f94d138
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions iio/iio_app/iio_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static inline uint32_t _calc_uart_xfer_time(uint32_t len, uint32_t baudrate)
return ms;
}

#if !defined(LINUX_PLATFORM) && !defined(NO_OS_NETWORKING)
#if !defined(LINUX_PLATFORM) && !defined(NO_OS_NETWORKING) && !defined(NO_OS_USB_UART)
static int32_t iio_print_uart_info_message(struct no_os_uart_desc **uart_desc,
struct no_os_uart_init_param *user_uart_params,
char *message, int32_t msglen)
Expand All @@ -116,7 +116,7 @@ static int32_t iio_print_uart_info_message(struct no_os_uart_desc **uart_desc,
static int32_t print_uart_hello_message(struct no_os_uart_desc **uart_desc,
struct no_os_uart_init_param *user_uart_params)
{
#if defined(LINUX_PLATFORM) || defined(NO_OS_NETWORKING) || defined(NO_OS_LWIP_NETWORKING)
#if defined(LINUX_PLATFORM) || defined(NO_OS_NETWORKING) || defined(NO_OS_LWIP_NETWORKING) || defined(NO_OS_USB_UART)
return 0;
#else
const char *uart_data_size[] = { "5", "6", "7", "8", "9" };
Expand Down Expand Up @@ -151,7 +151,7 @@ static int32_t print_uart_error_message(struct no_os_uart_desc **uart_desc,
uint32_t msglen = sprintf(message,
"IIOD server failed with code %d.\n",
(int)status);
#if defined(LINUX_PLATFORM) || defined(NO_OS_NETWORKING) || defined(NO_OS_LWIP_NETWORKING)
#if defined(LINUX_PLATFORM) || defined(NO_OS_NETWORKING) || defined(NO_OS_LWIP_NETWORKING) || defined(NO_OS_USB_UART)
(void)msglen;
printf("%s", message);
return 0;
Expand Down
4 changes: 4 additions & 0 deletions tools/scripts/generic_variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ GIT_VERSION := $(subst heads/,,$(GIT_VERSION))
GIT_VERSION := $(subst -0-g,-,$(GIT_VERSION))
CFLAGS += -DNO_OS_VERSION=$(GIT_VERSION) \
-DNO_OS_PROJECT=$(notdir $(PROJECT))

ifeq '$(NO_OS_USB_UART)' 'y'
CFLAGS += -DNO_OS_USB_UART
endif
#------------------------------------------------------------------------------
# EVALUATE PLATFORM
#------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions tools/scripts/maxim.mk
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ ifeq ($(TARGET_LCASE), max32650)
INCS := $(filter-out $(MAXIM_LIBRARIES)/CMSIS/Device/Maxim/$(TARGET_UCASE)/Include/mxc_device.h, $(INCS))
endif

ifeq ($(NO_OS_USB_UART),y)
SRCS += $(MAXIM_LIBRARIES)/MAXUSB/src/core/usb_event.c
INCS += $(MAXIM_LIBRARIES)/MAXUSB/include/core/usb.h \
$(MAXIM_LIBRARIES)/MAXUSB/include/core/usb_protocol.h \
$(MAXIM_LIBRARIES)/MAXUSB/include/core/usb_event.h \
$(PLATFORM_DRIVERS)/maxim_usb_uart_descriptors.h
SRC_DIRS += $(MAXIM_LIBRARIES)/MAXUSB/src/core/musbhsfc \
$(MAXIM_LIBRARIES)/MAXUSB/src/enumerate \
$(MAXIM_LIBRARIES)/MAXUSB/src/devclass \
$(MAXIM_LIBRARIES)/MAXUSB/include/core/musbhsfc \
$(MAXIM_LIBRARIES)/MAXUSB/include/enumerate \
$(MAXIM_LIBRARIES)/MAXUSB/include/devclass
endif

$(PLATFORM)_project:
$(call print, Building for target $(TARGET_LCASE))
$(call print,Creating IDE project)
Expand Down

0 comments on commit f94d138

Please sign in to comment.