This commit is contained in:
Steven Dan
2026-05-12 11:17:20 +08:00
parent b5b095efd0
commit b43581c2ff
473 changed files with 55278 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
# 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 -DXASSERT_ENABLE_ASSERTIONS=1 -DXASSERT_ENABLE_DEBUG=1
XCC_FLAGS_input_basic = $(COMMON_FLAGS) -DEVENTS=0
XCC_FLAGS_input_events = $(COMMON_FLAGS) -DEVENTS=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

View File

@@ -0,0 +1,70 @@
// 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 "debug_print.h"
#define NUM_CLIENTS (4)
#define NUM_TEST_EVENTS (2)
port input_port = XS1_PORT_4D;
port trigger_port = XS1_PORT_4B;
void read_port_on_event(client input_gpio_if input_port, unsigned int client_num,
client output_gpio_if trigger_port) {
unsigned int completed_events = 0;
unsigned int expected_value = (client_num & 1);
/* Setup event that should trigger immediately */
input_port.event_when_pins_eq(expected_value);
debug_printf("xCORE client %d setup pins eq event\n", client_num);
while (1) {
select {
case input_port.event():
debug_printf("xCORE client %d got input port event\n", client_num);
completed_events++;
// Read value on pin to make sure it's correct
unsigned int 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);
}
if (completed_events < NUM_TEST_EVENTS) {
/* Setup event that should trigger later */
// Flip expected_value each iteration of test
expected_value = !expected_value;
input_port.event_when_pins_eq(expected_value);
debug_printf("xCORE client %d setup pins eq event\n", client_num);
// Trigger simulator to output new expected_value
debug_printf("xCORE client %d driving trigger port\n", client_num);
trigger_port.output(1);
} else {
// Allow other cores to complete
delay_microseconds(5);
_exit(0);
}
break;
}
}
}
int main(void) {
interface input_gpio_if i_input_port[NUM_CLIENTS];
interface output_gpio_if i_trigger_port[NUM_CLIENTS];
par {
#if EVENTS
input_gpio_with_events(i_input_port, NUM_CLIENTS, input_port, null);
#else
input_gpio(i_input_port, NUM_CLIENTS, input_port, null);
#endif
output_gpio(i_trigger_port, NUM_CLIENTS, trigger_port, null);
par (int i = 0; i < NUM_CLIENTS; i++) {
read_port_on_event(i_input_port[i], i, i_trigger_port[i]);
}
}
return 0;
}

View 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')