├── Makefile
├── README
├── adc_demo
└── adc_demo.sh
├── blink
├── Makefile
├── blink.c
├── ignore_handler_s.c
├── safe_str_constraint.c
└── snprintf_support.c
├── doc
└── README
├── hello
├── Makefile
└── hello.c
├── include
├── safe_lib.h
├── safe_lib_errno.h
├── safe_lib_errno.h.in
├── safe_mem_lib.h
├── safe_str_lib.h
├── safe_types.h
├── safe_types.h.in
└── snprintf_s.h
├── led_control
├── Makefile
├── led_control.c
└── led_control.h
├── pio-interrupt
├── Makefile
└── gpio_interrupt.c
├── pio_ilc_demo
├── Makefile
├── README
└── intel_pio_ilc.c
├── safeclib
├── abort_handler_s.c
├── ignore_handler_s.c
├── mem_primitives_lib.c
├── mem_primitives_lib.h
├── memcmp16_s.c
├── memcmp32_s.c
├── memcmp_s.c
├── memcpy16_s.c
├── memcpy32_s.c
├── memcpy_s.c
├── memmove16_s.c
├── memmove32_s.c
├── memmove_s.c
├── memset16_s.c
├── memset32_s.c
├── memset_s.c
├── memzero16_s.c
├── memzero32_s.c
├── memzero_s.c
├── safe_mem_constraint.c
├── safe_mem_constraint.h
├── safe_str_constraint.c
├── safe_str_constraint.h
├── safeclib_private.h
├── snprintf_support.c
├── stpcpy_s.c
├── stpncpy_s.c
├── strcasecmp_s.c
├── strcasestr_s.c
├── strcat_s.c
├── strcmp_s.c
├── strcmpfld_s.c
├── strcpy_s.c
├── strcpyfld_s.c
├── strcpyfldin_s.c
├── strcpyfldout_s.c
├── strcspn_s.c
├── strfirstchar_s.c
├── strfirstdiff_s.c
├── strfirstsame_s.c
├── strisalphanumeric_s.c
├── strisascii_s.c
├── strisdigit_s.c
├── strishex_s.c
├── strislowercase_s.c
├── strismixedcase_s.c
├── strispassword_s.c
├── strisuppercase_s.c
├── strlastchar_s.c
├── strlastdiff_s.c
├── strlastsame_s.c
├── strljustify_s.c
├── strncat_s.c
├── strncpy_s.c
├── strnlen_s.c
├── strnterminate_s.c
├── strpbrk_s.c
├── strprefix_s.c
├── strremovews_s.c
├── strspn_s.c
├── strstr_s.c
├── strtok_s.c
├── strtolowercase_s.c
├── strtouppercase_s.c
├── strzero_s.c
├── wcpcpy_s.c
├── wcscat_s.c
├── wcscpy_s.c
├── wcsncat_s.c
├── wcsncpy_s.c
├── wcsnlen_s.c
├── wmemcmp_s.c
├── wmemcpy_s.c
├── wmemmove_s.c
└── wmemset_s.c
├── scroll_client
├── Makefile
└── scroll_client.c
├── scroll_server
├── Makefile
├── ignore_handler_s.c
├── safe_str_constraint.c
├── scroll_server.c
└── snprintf_support.c
├── syschk
├── Makefile
├── ignore_handler_s.c
├── safe_str_constraint.c
├── strcat_s.c
├── strcpy_s.c
├── strnlen_s.c
└── syschk.c
└── toggle
├── Makefile
└── toggle.c
/Makefile:
--------------------------------------------------------------------------------
1 | DIRS=led_control hello blink toggle scroll_server scroll_client syschk
2 |
3 | all:
4 | @for subd in $(DIRS); do \
5 | $(MAKE) -C $$subd; \
6 | done
7 |
8 | clean:
9 | @for subd in $(DIRS); do \
10 | $(MAKE) -C $$subd clean; \
11 | done
12 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | This is the repository for the source code necessary to run reference designs.
2 |
3 | Each reference design is on its own branch.
4 |
5 | This repository includes software from several sources under a collection of compatible open source licenses; refer to the specific copyright/license embedded in each source file.
6 |
--------------------------------------------------------------------------------
/adc_demo/adc_demo.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright (C) 2015 Altera Corporation. All rights reserved.
4 | #
5 | # This program is free software; you can redistribute it and/or modify
6 | # it under the terms and conditions of the GNU General Public License,
7 | # version 2, as published by the Free Software Foundation.
8 | #
9 | # This program is distributed in the hope it will be useful, but WITHOUT
10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 | # more details.
13 | #
14 | # You should have received a copy of the GNU General Public License along with
15 | # this program. If not, see .
16 |
17 | # Internals
18 | SELF="$(basename $0)"
19 |
20 | # Constants
21 | readonly BAR_COUNT=24 # Total count of display bars
22 | readonly QUANTUM_LEVEL=4096 # Quantum levels for 12bits ADC
23 | readonly ADC_DEFAULT_SYSFS="/sys/bus/iio/devices/iio:device0/in_voltage0_adc1-ch7_raw"
24 |
25 | # Variables
26 | RAW= # Raw Value read from ADC
27 | VAR= # Nominalize ADC value to Bar Count
28 | BAR= # Number of bars to be displayed
29 | ADC_SYSFS= # ADC sysfs to read
30 |
31 | # Display help
32 | help() {
33 | echo "ADC Demonstration to display ADC reading"
34 | echo "usage: ${SELF} -t "
35 | echo "-t file: specifies ADC sysfs. Default points to,"
36 | echo " ${ADC_DEFAULT_SYSFS}"
37 | echo "-h : this message."
38 | return 0
39 | }
40 |
41 | # Display function
42 | display() {
43 | RAW="$(cat ${ADC_SYSFS})"
44 | VAR="$(expr ${RAW} \* ${BAR_COUNT} / ${QUANTUM_LEVEL})"
45 | BAR="$(printf '%0.s#' $(seq 0 ${VAR}))"
46 | printf "\r\033[2JADC Demo: Press CTRL-C to quit.\n"
47 | printf "Raw Value: %-4s [%-24s] \033[1;44f" ${RAW} ${BAR}
48 | return 0
49 | }
50 |
51 | # Script starts here
52 | # Option parsing
53 | while [ $# -gt 0 ]; do
54 | case $1 in
55 | -h) help; exit 0 ;;
56 | -t) ADC_SYSFS=$2 ; shift ;;
57 | *) echo "${SELF}: error: unknown option ${1}" ; help ; exit 1 ;;
58 | esac
59 | shift
60 | done
61 |
62 | # Error checks
63 | if [ -z "${ADC_SYSFS}" ]; then
64 | ADC_SYSFS=${ADC_DEFAULT_SYSFS}
65 | fi
66 |
67 | if [ ! -f "${ADC_SYSFS}" ]; then
68 | echo "${SELF}: error: ${ADC_SYSFS}: no such file."
69 | exit 1
70 | fi
71 |
72 | # Start display
73 | while [ true ]; do
74 | display
75 | done
76 |
--------------------------------------------------------------------------------
/blink/Makefile:
--------------------------------------------------------------------------------
1 | C_SRC := blink.c snprintf_support.c safe_str_constraint.c ignore_handler_s.c
2 | CFLAGS := -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -Werror -Wall -fstack-protector-all -O -I../led_control -I../include -I../safeclib
3 |
4 | ifeq ($(or $(COMSPEC),$(ComSpec)),)
5 | RM := rm -rf
6 | else
7 | RM := cs-rm -rf
8 | endif
9 |
10 | ELF ?= $(basename $(firstword $(C_SRC)))
11 | OBJ := $(patsubst %.c,%.o,$(C_SRC))
12 |
13 | .PHONY: all
14 | all: $(ELF) $(OBJ)
15 |
16 | .PHONY:
17 | clean:
18 | $(RM) $(ELF) *.o
19 |
20 | $(OBJ): %.o: %.c
21 | $(CC) $(CFLAGS) -c $< -o $@
22 |
23 | $(ELF): $(OBJ)
24 | $(CC) $(CFLAGS) $(OBJ) ../led_control/led_control.a -o $@ -lpthread
25 |
26 |
--------------------------------------------------------------------------------
/blink/blink.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013-2014, Altera Corporation
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions are met:
7 | * - Redistributions of source code must retain the above copyright
8 | * notice, this list of conditions and the following disclaimer.
9 | * - Redistributions in binary form must reproduce the above copyright
10 | * notice, this list of conditions and the following disclaimer in the
11 | * documentation and/or other materials provided with the distribution.
12 | * - Neither the name of the Altera Corporation nor the
13 | * names of its contributors may be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | * DISCLAIMED. IN NO EVENT SHALL ALTERA CORPORATION BE LIABLE FOR ANY
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 |
35 | #include "led_control.h"
36 |
37 | #define STRSIZE 256
38 |
39 | int main(int argc, char** argv)
40 | {
41 | FILE *fp;
42 | int led, delay_ms, i;
43 | char trigger[] = "timer";
44 | char dir[STRSIZE];
45 | char delay[STRSIZE];
46 | int blink_interval_ms;
47 |
48 | for (i = 1; i < argc; i++) {
49 | if (strcmp("--help", argv[i]) == 0) {
50 | printf("Usage %s: