1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/periph_dac/main.c
smlng e381317fbf make: fix sign-compare errors
cpu, nrf5x_common: fix sign-compare in periph/flashpage
    drivers, periph_common: fix sign-compare in flashpage
    cpu, sam0_common: fix sign-compare error in periph/gpio
    cpu, cc2538: fix sign-compare in periph/timer
    cpu, sam3: fix sign-compare in periph/gpio
    cpu, stm32_common: fix sign-compare in periph/pwm
    cpu, stm32_common: fix sign-compare in periph/timer
    cpu, stm32_common: fix sign-compare in periph/flashpage
    cpu, nrf5x_common: fix sign-compare in radio/nrfmin
    cpu, samd21: fix sign-compare in periph/pwm
    cpu, ezr32wg: fix sign-compare in periph/gpio
    cpu, ezr32wg: fix sign-compare in periph/timer
    drivers, ethos: fix sign-compare
    sys, net: fix sign-compare
    cpu, atmega_common: fix sign-compare error
    cpu, msp430fxyz: fix sign-compare in periph/gpio
    boards, msb-430-common: fix sign-compare in board_init
    driver, cc2420: fix sign-compared
    sys/net: fix sign-compare in gnrc_tftp
    driver, pcd8544: fix sign-compare
    driver, pn532: fix sign-compare
    driver, sdcard_spi: fix sign-compare
    tests: fix sign_compare
    sys/net, lwmac: fix sign_compare
    pkg, lwip: fix sign-compare
    boards, waspmote: make CORECLOCK unsigned long to fix sign_compare error
    tests, sock_ip: fix sign compare
    tests, msg_avail: fix sign compare
    tests, sock_udp: fix sign compare
    boards: fix sign-compare for calliope and microbit matrix
2017-11-28 11:55:48 +01:00

64 lines
1.5 KiB
C

/*
* Copyright (C) 2014-2016 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License v2.1. See the file LICENSE in the top level directory for more
* details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Test case for the low-level DAC driver
*
* @author Peter Kietzmann <peter.kietzmann@haw-hamburg.de>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include <stdio.h>
#include "xtimer.h"
#include "periph/dac.h"
#define DELAY (100U)
#define STEPS (1000U)
int main(void)
{
xtimer_ticks32_t last = xtimer_now();
uint16_t val = 0;
uint16_t step = 0xffff / STEPS;
puts("\nRIOT DAC peripheral driver test\n");
puts("This test application produces a saw tooth signal on each available\n"
"DAC line. The period of the signal should be around 100ms\n");
/* initialize all DAC lines */
for (unsigned i = 0; i < DAC_NUMOF; i++) {
if (dac_init(DAC_LINE(i)) < 0) {
printf("Error initializing DAC_LINE(%u)\n", i);
return 1;
}
else {
printf("Successfully initialized DAC_LINE(%u)\n", i);
}
}
puts("");
/* create saw tooth signal */
while (1) {
for (unsigned i = 0; i < DAC_NUMOF; i++) {
dac_set(DAC_LINE(i), val);
}
val += step;
xtimer_periodic_wakeup(&last, DELAY);
}
return 0;
}