add libs
This commit is contained in:
40
lib_gpio/tests/gpio_input_basic_test/Makefile
Normal file
40
lib_gpio/tests/gpio_input_basic_test/Makefile
Normal file
@@ -0,0 +1,40 @@
|
||||
# The TARGET variable determines what target system the application is
|
||||
# compiled for. It either refers to an XN file in the source directories
|
||||
# or a valid argument for the --target option when compiling.
|
||||
|
||||
TARGET = SLICEKIT-L16
|
||||
|
||||
# The APP_NAME variable determines the name of the final .xe file. It should
|
||||
# not include the .xe postfix. If left blank the name will default to
|
||||
# the project name
|
||||
|
||||
APP_NAME =
|
||||
|
||||
# The flags passed to xcc when building the application
|
||||
# You can also set the following to override flags for a particular language:
|
||||
#
|
||||
# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
|
||||
#
|
||||
# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
|
||||
# xcc for the final link (mapping) stage.
|
||||
|
||||
COMMON_FLAGS = -O2 -g -save-temps -DDEBUG_PRINT_ENABLE=1 -report
|
||||
|
||||
XCC_FLAGS_input_basic = $(COMMON_FLAGS) -DEVENTS=0 -DTIMESTAMPS=0 -DSUPPLY_PIN_MAP=0 -DCROSSTILE=0
|
||||
XCC_FLAGS_input_events = $(COMMON_FLAGS) -DEVENTS=1 -DTIMESTAMPS=0 -DSUPPLY_PIN_MAP=0 -DCROSSTILE=0
|
||||
XCC_FLAGS_input_timestamps = $(COMMON_FLAGS) -DEVENTS=0 -DTIMESTAMPS=1 -DSUPPLY_PIN_MAP=0 -DCROSSTILE=0
|
||||
XCC_FLAGS_input_events_timestamps = $(COMMON_FLAGS) -DEVENTS=1 -DTIMESTAMPS=1 -DSUPPLY_PIN_MAP=0 -DCROSSTILE=0
|
||||
XCC_FLAGS_input_supply_pin_map = $(COMMON_FLAGS) -DEVENTS=0 -DTIMESTAMPS=0 -DSUPPLY_PIN_MAP=1 -DCROSSTILE=0
|
||||
XCC_FLAGS_input_crosstile = $(COMMON_FLAGS) -DEVENTS=0 -DTIMESTAMPS=0 -DSUPPLY_PIN_MAP=0 -DCROSSTILE=1
|
||||
XCC_FLAGS_input_events_timestamps_supply_pin_map_crosstile = $(COMMON_FLAGS) -DEVENTS=1 -DTIMESTAMPS=1 -DSUPPLY_PIN_MAP=1 -DCROSSTILE=1
|
||||
|
||||
# The USED_MODULES variable lists other module used by the application.
|
||||
|
||||
USED_MODULES = lib_gpio lib_logging
|
||||
|
||||
#=============================================================================
|
||||
# The following part of the Makefile includes the common build infrastructure
|
||||
# for compiling XMOS applications. You should not need to edit below here.
|
||||
|
||||
XMOS_MAKE_PATH ?= ../..
|
||||
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common
|
||||
85
lib_gpio/tests/gpio_input_basic_test/src/main.xc
Normal file
85
lib_gpio/tests/gpio_input_basic_test/src/main.xc
Normal file
@@ -0,0 +1,85 @@
|
||||
// Copyright 2015-2021 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <gpio.h>
|
||||
#include <xs1.h>
|
||||
#include <timer.h>
|
||||
#include <syscall.h>
|
||||
#include <platform.h>
|
||||
#include "debug_print.h"
|
||||
|
||||
#ifndef CROSSTILE
|
||||
#define CROSSTILE 0
|
||||
#endif
|
||||
|
||||
#define NUM_CLIENTS (4)
|
||||
#define TIMESTAMP_TEST_DELAY_MICROSECONDS (5)
|
||||
#define TIMESTAMP_TEST_DELAY_CLOCKS (TIMESTAMP_TEST_DELAY_MICROSECONDS * XS1_TIMER_MHZ)
|
||||
#define TIMESTAMP_TEST_DELAY_SLACK_CLOCKS (100 + CROSSTILE?100:0)
|
||||
|
||||
on tile[0] : port input_port = XS1_PORT_4D;
|
||||
|
||||
void read_port(client input_gpio_if input_port, unsigned int client_num) {
|
||||
unsigned int pin_data;
|
||||
unsigned int expected_value = (client_num & 1);
|
||||
if (SUPPLY_PIN_MAP) {
|
||||
expected_value = !expected_value;
|
||||
}
|
||||
|
||||
if (TIMESTAMPS) {
|
||||
gpio_time_t ts1, ts2;
|
||||
pin_data = input_port.input_and_timestamp(ts1);
|
||||
// Wait known time before second input with timestamp
|
||||
delay_microseconds(TIMESTAMP_TEST_DELAY_MICROSECONDS);
|
||||
input_port.input_and_timestamp(ts2);
|
||||
// Check that the second ts is a later time than the first
|
||||
if (porttimeafter(ts1, ts2)) {
|
||||
debug_printf("ERROR: Second timestamp (%d) read by client %d appears to be earlier than first (%d)\n",
|
||||
ts2, client_num, ts1);
|
||||
}
|
||||
// Sanity check difference between timestamps
|
||||
if ((ts2 - ts1) <
|
||||
(TIMESTAMP_TEST_DELAY_CLOCKS - TIMESTAMP_TEST_DELAY_SLACK_CLOCKS)) {
|
||||
debug_printf("ERROR: Difference between timestamps (%d, %d) read by client %d smaller than expected\n",
|
||||
ts1, ts2, client_num);
|
||||
}
|
||||
if ((ts2 - ts1) >
|
||||
(TIMESTAMP_TEST_DELAY_CLOCKS + TIMESTAMP_TEST_DELAY_SLACK_CLOCKS)) {
|
||||
debug_printf("ERROR: Difference between timestamps (%d, %d) read by client %d larger than expected\n",
|
||||
ts1, ts2, client_num);
|
||||
}
|
||||
} else {
|
||||
pin_data = input_port.input();
|
||||
}
|
||||
|
||||
if (pin_data != expected_value) {
|
||||
debug_printf("ERROR: Data 0x%x read by client %d does not match expected data 0x%x\n",
|
||||
pin_data, client_num, expected_value);
|
||||
} else {
|
||||
debug_printf("xCORE client %d input data correctly\n", client_num);
|
||||
}
|
||||
|
||||
// Allow other cores to complete
|
||||
delay_microseconds(5);
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
#if SUPPLY_PIN_MAP
|
||||
static char pin_map[NUM_CLIENTS] = {1, 0, 3, 2};
|
||||
#else
|
||||
#define pin_map null
|
||||
#endif
|
||||
|
||||
int main(void) {
|
||||
interface input_gpio_if i_input_port[NUM_CLIENTS];
|
||||
par {
|
||||
#if EVENTS
|
||||
on tile[0] : input_gpio_with_events(i_input_port, NUM_CLIENTS, input_port, pin_map);
|
||||
#else
|
||||
on tile[0] : input_gpio(i_input_port, NUM_CLIENTS, input_port, pin_map);
|
||||
#endif
|
||||
par (int i = 0; i < NUM_CLIENTS; i++) {
|
||||
on tile[CROSSTILE?i%2:0] : read_port(i_input_port[i], i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
14
lib_gpio/tests/gpio_input_basic_test/wscript
Normal file
14
lib_gpio/tests/gpio_input_basic_test/wscript
Normal file
@@ -0,0 +1,14 @@
|
||||
def options(opt):
|
||||
opt.load('xwaf.xcommon')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('xwaf.xcommon')
|
||||
|
||||
def build(bld):
|
||||
bld.do_xcommon()
|
||||
|
||||
def dist(ctx):
|
||||
ctx.load('xwaf.xcommon')
|
||||
|
||||
def distcheck(ctx):
|
||||
ctx.load('xwaf.xcommon')
|
||||
Reference in New Issue
Block a user