Skip to content
Snippets Groups Projects
Commit 24779bc7 authored by Alexandre Abadie's avatar Alexandre Abadie
Browse files

tests/driver_dsp0401: add simple test application

parent a4e16cd7
No related branches found
No related tags found
No related merge requests found
APPLICATION = driver_dsp0401
include ../Makefile.tests_common
USEMODULE += dsp0401
LOOPS ?= 3
CFLAGS += -DLOOPS=${LOOPS}
include $(RIOTBASE)/Makefile.include
## About
This is a test application for the [DSP0401](https://www.embeddedadventures.com/datasheets/DSP-0401B_hw_v4.pdf),
a 4 digits with 16 segments alpha-numeric display.
## Connecting the device
The display can be controlled from the JP1 connection jumper as follows:
* Connect `SIN` to the board `DSP0401_PARAM_SDI_PIN` (see your board_params.h file)
* Connect `CLK` to the board `DSP0401_PARAM_CLK_PIN`
* Connect `LAT` to the board `DSP0401_PARAM_LAT_PIN`
* Connect `PWM` to the board `DSP0401_PARAM_PWM_DEV` pwm device. See the board periph_conf.h
to find a valid pin and configuration.
* Connect `VCC` to one of the board VCC pin (3.3V or 5V depending on your board.
Example: use 3.3V with ST Nucleo)
* Connect `GND` to one of the board GND.
Since there are potentially a lot of LEDs to poweron, it's preferable to use an
external power supply to power the DSP0401 module. This is what JP2 is meant for.
See the [datasheet](https://www.embeddedadventures.com/datasheets/DSP-0401B_hw_v4.pdf)
section `Power` for more information on power configuration.
## Chaining devices
Since DSP0401 contains a shift register, it's possible to chain devices by connecting
the JP4 and JP5 connection jumpers of the device N to respectively JP2 and JP1 of the
device N+1.
Attention: ensure your power supply is able to provide enough current for the number of devices
you plan to use.
/*
* Copyright (C) 2017 Inria
*
* 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 application for the DSP0401 4 digit display.
*
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
*
* @}
*/
#include <stdio.h>
#include <inttypes.h>
#include "dsp0401_params.h"
#include "dsp0401.h"
#include "xtimer.h"
#define TEST_DELAY (2U) /* 2 seconds delay between each test */
#define WORD_DELAY (750U) /* 750 milliseconds delay between each word */
#define SCROLL_DELAY (200U) /* 200 milliseconds delay between character shift */
#ifndef LOOPS
#define LOOPS (3U) /* Number of display loops before exit */
#endif
int main(void)
{
dsp0401_t dev;
puts("Starting DSP0401 test application\n");
puts("Initializing DSP4010 device.");
if (dsp0401_init(&dev, &dsp0401_params[0]) != DSP0401_OK) {
puts("[Error] Cannot initialize DSP0401 display.");
return 1;
}
puts("Initialization successful\n");
uint8_t loop = 0;
while (loop < LOOPS) {
puts("[INFO] Displaying 'THIS IS RIOT'");
dsp0401_display_text(&dev, (char*)"THIS");
xtimer_usleep(WORD_DELAY * US_PER_MS);
dsp0401_display_text(&dev, (char*)" IS ");
xtimer_usleep(WORD_DELAY * US_PER_MS);
dsp0401_display_text(&dev, (char*)"RIOT");
xtimer_sleep(TEST_DELAY);
puts("[INFO] Clearing text!");
dsp0401_clear_text(&dev);
xtimer_sleep(TEST_DELAY);
puts("[INFO] Scrolling 'THIS IS RIOT'");
dsp0401_scroll_text(&dev, (char*)("THIS IS RIOT"), SCROLL_DELAY);
xtimer_sleep(TEST_DELAY);
puts("[INFO] Done\n");
++loop;
}
puts("SUCCESS");
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment