Skip to content

Commit

Permalink
bloodlight_based.c: Create test for led.c
Browse files Browse the repository at this point in the history
* Bloodlight_based.c: Test leds with led.c APIs.
* Build bloodlight_based.c by default.

Keep both tests zephyr_based (previous main) and bloodlight_based.c so
the user can select in CMakeFie which test wants to run. zephyr_based to
test leds using zephyrs APIs or bloodlight_based to test them using
bloodlight's APIs.

Signed-off-by: Iker Perez del Palomar Sustatxa <iker.perez@codethink.co.uk>
  • Loading branch information
Iker Perez del Palomar Sustatxa committed Jun 1, 2021
1 parent 7d8e799 commit 8afe0b7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
7 changes: 6 additions & 1 deletion boards/arm/bloodlight_rev2/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ config USB_DEVICE_VID
depends on USB
help
USB device vendor ID. MUST be configured by vendor.

config USB_DEVICE_PID
hex "USB Product ID"
default 0x0100
depends on USB
help
USB device product ID. MUST be configured by vendor.
USB device product ID. MUST be configured by vendor.

config PRINTK
bool "Send printk() to console"
default y
2 changes: 1 addition & 1 deletion tests/led/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ zephyr_include_directories(${CMAKE_SOURCE_DIR}/../..)
project(led_test)

target_sources(app PRIVATE
main.c
bloodlight_based.c
../../src/led.c
)
41 changes: 41 additions & 0 deletions tests/led/bloodlight_based.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <stddef.h>
#include <stdint.h>
#include <sys/printk.h>
#include <sys/util.h>
#include <string.h>
#include <usb/usb_device.h>
#include <drivers/uart.h>

#include "../../src/led.h"
#include "../../src/led.c"

void main (void) {
const struct device *dev = device_get_binding(
CONFIG_UART_CONSOLE_ON_DEV_NAME);
uint32_t dtr = 0;

if (usb_enable(NULL)) {
return;
}

/* Poll if the DTR flag was set, optional */
while (!dtr) {
uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr);
}

if (strlen(CONFIG_UART_CONSOLE_ON_DEV_NAME) !=
strlen("CDC_ACM_0") ||
strncmp(CONFIG_UART_CONSOLE_ON_DEV_NAME, "CDC_ACM_0",
strlen(CONFIG_UART_CONSOLE_ON_DEV_NAME))) {
printk("Error: Console device name is not USB ACM\n");

return;
}

printk("Before led init\n");
bl_led_init();
printk("After led init\n");
bl_led_status_set(true);
bl_led_set(0xffff);

};
File renamed without changes.

0 comments on commit 8afe0b7

Please sign in to comment.