mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-27 23:41:18 +01:00
Merge pull request #8447 from haukepetersen/opt_test_periphuartpower
tests/periph_uart: included power_on/off() in test
This commit is contained in:
commit
47a500d0b1
@ -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);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user