Skip to content
Snippets Groups Projects
Unverified Commit 47a500d0 authored by Hauke Petersen's avatar Hauke Petersen Committed by GitHub
Browse files

Merge pull request #8447 from haukepetersen/opt_test_periphuartpower

tests/periph_uart: included power_on/off() in test
parents 3d3166e7 4fd16b0b
No related branches found
No related tags found
No related merge requests found
......@@ -152,6 +152,18 @@ void uart_write(uart_t uart, const uint8_t *data, size_t len)
}
}
void uart_poweron(uart_t uart)
{
(void)uart;
/* not implemented (yet) */
}
void uart_poweroff(uart_t uart)
{
(void)uart;
/* not implemented (yet) */
}
static inline void isr_handler(int num)
{
isr_ctx[num].rx_cb(isr_ctx[num].arg, dev[num]->DR);
......
......@@ -131,6 +131,18 @@ int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
return UART_OK;
}
void uart_poweron(uart_t uart)
{
(void)uart;
/* not implemented (yet) */
}
void uart_poweroff(uart_t uart)
{
(void)uart;
/* not implemented (yet) */
}
#if KINETIS_HAVE_UART && KINETIS_HAVE_LPUART
/* Dispatch function to pass to the proper write function depending on UART type
* This function is only used when the CPU supports both UART and LPUART. */
......
......@@ -98,3 +98,15 @@ void UART0_IRQHandler(void)
VICVectAddr = 0; /* Acknowledge Interrupt */
}
void uart_poweron(uart_t uart)
{
(void)uart;
/* not implemented (yet) */
}
void uart_poweroff(uart_t uart)
{
(void)uart;
/* not implemented (yet) */
}
......@@ -177,3 +177,15 @@ void uart_write(uart_t uart, const uint8_t *data, size_t len)
_native_write(tty_fds[uart], data, len);
}
void uart_poweron(uart_t uart)
{
(void)uart;
/* not implemented (yet) */
}
void uart_poweroff(uart_t uart)
{
(void)uart;
/* not implemented (yet) */
}
......@@ -5,5 +5,6 @@ BOARD_INSUFFICIENT_MEMORY := nucleo32-f031
FEATURES_REQUIRED = periph_uart
USEMODULE += shell
USEMODULE += xtimer
include $(RIOTBASE)/Makefile.include
......@@ -29,6 +29,7 @@
#include "ringbuffer.h"
#include "periph/uart.h"
#include "uart_stdio.h"
#include "xtimer.h"
#define SHELL_BUFSIZE (128U)
#define UART_BUFSIZE (128U)
......@@ -36,6 +37,8 @@
#define PRINTER_PRIO (THREAD_PRIORITY_MAIN - 1)
#define PRINTER_TYPE (0xabcd)
#define POWEROFF_DELAY (250U * US_PER_MS) /* quarter of a second */
#ifndef UART_STDIO_DEV
#define UART_STDIO_DEV (UART_UNDEF)
#endif
......@@ -107,6 +110,15 @@ static void *printer(void *arg)
return NULL;
}
static void sleep_test(int num, uart_t uart)
{
printf("UARD_DEV(%i): test uart_poweron() and uart_poweroff() -> ", num);
uart_poweroff(uart);
xtimer_usleep(POWEROFF_DELAY);
uart_poweron(uart);
puts("[OK]");
}
static int cmd_init(int argc, char **argv)
{
int dev, res;
......@@ -134,6 +146,11 @@ static int cmd_init(int argc, char **argv)
return 1;
}
printf("Successfully initialized UART_DEV(%i)\n", dev);
/* also test if poweron() and poweroff() work (or at least don't break
* anything) */
sleep_test(dev, UART_DEV(dev));
return 0;
}
......@@ -178,7 +195,13 @@ int main(void)
"being printed to STDOUT\n\n"
"NOTE: all strings need to be '\\n' terminated!\n");
puts("UART INFO:");
/* do sleep test for UART used as STDIO. There is a possibility that the
* value given in UART_STDIO_DEV is not a numeral (depends on the CPU
* implementation), so we rather break the output by printing a
* non-numerical value instead of breaking the UART device descriptor */
sleep_test(UART_STDIO_DEV, UART_STDIO_DEV);
puts("\nUART INFO:");
printf("Available devices: %i\n", UART_NUMOF);
printf("UART used for STDIO (the shell): UART_DEV(%i)\n\n", UART_STDIO_DEV);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment