forked from PAWPAW-Mirror/lib_xua
Review feedback
This commit is contained in:
@@ -4,11 +4,8 @@
|
||||
|
||||
ifeq ($(CONFIG), xs2)
|
||||
TARGET = XCORE-200-EXPLORER
|
||||
endif
|
||||
ifeq ($(CONFIG), xs3)
|
||||
TARGET = XCORE-AI-EXPLORER
|
||||
else
|
||||
TARGET = XCORE-AI-EXPLORER
|
||||
TARGET = XCORE-AI-EXPLORER #for xs3 and also loopback test
|
||||
endif
|
||||
|
||||
# The APP_NAME variable determines the name of the final .xe file. It should
|
||||
|
||||
@@ -45,12 +45,12 @@ on tile[MIDI_TILE] : clock clk_midi = CLKBLK_MIDI;
|
||||
#endif
|
||||
|
||||
/* See hwsupport.xc */
|
||||
void ctrlPort();
|
||||
void board_setup();
|
||||
|
||||
#define CABLE_NUM 0
|
||||
|
||||
|
||||
unsigned mini_in_parse_helper(unsigned midi[3]){
|
||||
unsigned midi_in_parse_helper(unsigned midi[3]){
|
||||
struct midi_in_parse_state m_state;
|
||||
reset_midi_state(m_state);
|
||||
|
||||
@@ -151,7 +151,7 @@ void test(chanend c_midi){
|
||||
|
||||
case tx_cmd_count < num_to_tx => tmr when timerafter(t_tx) :> int _:
|
||||
unsigned midi[] = {commands[tx_cmd_count][0], commands[tx_cmd_count][1], commands[tx_cmd_count][2]};
|
||||
unsigned tx_packet = mini_in_parse_helper(midi);
|
||||
unsigned tx_packet = midi_in_parse_helper(midi);
|
||||
outuint(c_midi, byterev(tx_packet));
|
||||
dprintf("Sent packet to midi: %u %u %u\n", commands[tx_cmd_count][0], commands[tx_cmd_count][1], commands[tx_cmd_count][2]);
|
||||
t_tx += tx_interval;
|
||||
@@ -177,7 +177,7 @@ int main(void)
|
||||
on tile[1]: usb_midi(p_midi_rx, p_midi_tx, clk_midi, c_midi, 0);
|
||||
|
||||
// Setup HW so we can run this on the MC board
|
||||
on tile[0]: ctrlPort();
|
||||
on tile[0]: board_setup();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -5,30 +5,44 @@
|
||||
#include "xua.h"
|
||||
|
||||
|
||||
on tile[0]: out port p_ctrl = XS1_PORT_8D;
|
||||
out port p_ctrl = PORT_CTRL; /* p_ctrl:
|
||||
* [0:3] - Unused
|
||||
* [4] - EN_3v3_N (1v0 hardware only)
|
||||
* [5] - EN_3v3A
|
||||
* [6] - EXT_PLL_SEL (CS2100:0, SI: 1)
|
||||
* [7] - MCLK_DIR (Out:0, In: 1)
|
||||
*/
|
||||
|
||||
/* p_ctrl:
|
||||
* [0:3] - Unused
|
||||
* [4] - EN_3v3_N
|
||||
* [5] - EN_3v3A
|
||||
* [6] - EXT_PLL_SEL (CS2100:0, SI: 1)
|
||||
* [7] - MCLK_DIR (Out:0, In: 1)
|
||||
*/
|
||||
on tile[0]: in port p_margin = XS1_PORT_1G; /* CORE_POWER_MARGIN: Driven 0: 0.925v
|
||||
* Pull down: 0.922v
|
||||
* High-z: 0.9v
|
||||
* Pull-up: 0.854v
|
||||
* Driven 1: 0.85v
|
||||
*/
|
||||
|
||||
#define USE_FRACTIONAL_N (0)
|
||||
|
||||
#if (USE_FRACTIONAL_N)
|
||||
#define EXT_PLL_SEL__MCLK_DIR (0x00)
|
||||
#else
|
||||
#define EXT_PLL_SEL__MCLK_DIR (0x80)
|
||||
#endif
|
||||
|
||||
/* Note, this runs on Tile[0] */
|
||||
void ctrlPort()
|
||||
/* Board setup for XU316 MC Audio (1v1) */
|
||||
void board_setup()
|
||||
{
|
||||
// Drive control port to turn on 3V3 and set MCLK_DIR
|
||||
// Note, "soft-start" to reduce current spike
|
||||
// Note, 3v3_EN is inverted
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
p_ctrl <: EXT_PLL_SEL__MCLK_DIR | 0x30; /* 3v3: off, 3v3A: on */
|
||||
delay_microseconds(5);
|
||||
p_ctrl <: EXT_PLL_SEL__MCLK_DIR | 0x20; /* 3v3: on, 3v3A: on */
|
||||
delay_microseconds(5);
|
||||
}
|
||||
/* "Drive high mode" - drive high for 1, non-driving for 0 */
|
||||
set_port_drive_high(p_ctrl);
|
||||
|
||||
/* Ensure high-z for 0.9v */
|
||||
p_margin :> void;
|
||||
|
||||
/* Drive control port to turn on 3V3 and mclk direction appropriately.
|
||||
* Bits set to low will be high-z, pulled down */
|
||||
p_ctrl <: EXT_PLL_SEL__MCLK_DIR | 0x20;
|
||||
|
||||
/* Wait for power supplies to be up and stable */
|
||||
delay_milliseconds(10);
|
||||
}
|
||||
|
||||
/* Configures the external audio hardware at startup. Note this runs on Tile[1] */
|
||||
|
||||
@@ -55,7 +55,8 @@ foreach(TESTFILE ${TEST_SOURCES})
|
||||
## Do xcommon cmake build
|
||||
##########################
|
||||
set(APP_HW_TARGET XK-EVK-XU316)
|
||||
set(APP_DEPENDENT_MODULES "lib_xua")
|
||||
set(APP_DEPENDENT_MODULES "lib_xua"
|
||||
"lib_unity(2.5.2)")
|
||||
# set(APP_PCA_ENABLE ON)
|
||||
set(APP_COMPILER_FLAGS ${EXTRA_BUILD_FLAGS} -fcomment-asm
|
||||
-Wall
|
||||
@@ -82,14 +83,12 @@ foreach(TESTFILE ${TEST_SOURCES})
|
||||
|
||||
set(APP_C_SRCS ${RUNNER_FILE_RELATIVE}
|
||||
${UNIT_TEST_SOURCE_RELATIVE}
|
||||
../../../Unity/src/unity.c
|
||||
)
|
||||
|
||||
|
||||
get_filename_component(TEST_FILE_DIR ${TESTFILE} DIRECTORY)
|
||||
set(APP_INCLUDES ${CMAKE_CURRENT_LIST_DIR}/src
|
||||
${TEST_FILE_DIR}
|
||||
${XMOS_SANDBOX_DIR}/Unity/src
|
||||
${XMOS_SANDBOX_DIR}/lib_xud/lib_xud/src/user/class)
|
||||
|
||||
XMOS_REGISTER_APP()
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#define CABLE_NUM 2
|
||||
#define RANDOM_SEED 6031769
|
||||
|
||||
unsigned mini_in_parse_ut(unsigned midi[3]){
|
||||
unsigned midi_in_parse_ut(unsigned midi[3]){
|
||||
// printf("Composing data: 0x%x 0x%x 0x%x\n", midi[0], midi[1], midi[2]);
|
||||
|
||||
struct midi_in_parse_state m_state;
|
||||
@@ -60,7 +60,7 @@ void test_midi_note(void) {
|
||||
for(int cmd = NOTE_OFF; cmd < NOTE_ON + NUM_CHANS; cmd++){
|
||||
for(int test = 0; test < NUM_TESTS_PER_TEST; test++){
|
||||
unsigned midi_ref[3] = {cmd, random(&rndm) & DATA_MASK, random(&rndm) & DATA_MASK};
|
||||
unsigned packed = mini_in_parse_ut(midi_ref);
|
||||
unsigned packed = midi_in_parse_ut(midi_ref);
|
||||
unsigned midi_dut[3] = {0};
|
||||
unsigned size = 0;
|
||||
midi_out_parse_c_wrapper(packed, midi_dut, &size);
|
||||
@@ -78,7 +78,7 @@ void test_midi_pressure(void) {
|
||||
for(int cmd = PRESSURE; cmd < PRESSURE + NUM_CHANS; cmd++){
|
||||
for(int test = 0; test < NUM_TESTS_PER_TEST; test++){
|
||||
unsigned midi_ref[3] = {cmd, random(&rndm) & DATA_MASK, random(&rndm) & DATA_MASK};
|
||||
unsigned packed = mini_in_parse_ut(midi_ref);
|
||||
unsigned packed = midi_in_parse_ut(midi_ref);
|
||||
unsigned midi_dut[3] = {0};
|
||||
unsigned size = 0;
|
||||
midi_out_parse_c_wrapper(packed, midi_dut, &size);
|
||||
@@ -96,7 +96,7 @@ void test_midi_control(void) {
|
||||
for(int cmd = CONTROL; cmd < CONTROL + NUM_CHANS; cmd++){
|
||||
for(int test = 0; test < NUM_TESTS_PER_TEST; test++){
|
||||
unsigned midi_ref[3] = {cmd, random(&rndm) & DATA_MASK, random(&rndm) & DATA_MASK};
|
||||
unsigned packed = mini_in_parse_ut(midi_ref);
|
||||
unsigned packed = midi_in_parse_ut(midi_ref);
|
||||
unsigned midi_dut[3] = {0};
|
||||
unsigned size = 0;
|
||||
midi_out_parse_c_wrapper(packed, midi_dut, &size);
|
||||
@@ -114,7 +114,7 @@ void test_midi_program(void) {
|
||||
for(int cmd = PROGRAM; cmd < PROGRAM + NUM_CHANS; cmd++){
|
||||
for(int test = 0; test < NUM_TESTS_PER_TEST; test++){
|
||||
unsigned midi_ref[3] = {cmd, random(&rndm) & DATA_MASK, random(&rndm) & DATA_MASK};
|
||||
unsigned packed = mini_in_parse_ut(midi_ref);
|
||||
unsigned packed = midi_in_parse_ut(midi_ref);
|
||||
unsigned midi_dut[3] = {0};
|
||||
unsigned size = 0;
|
||||
midi_out_parse_c_wrapper(packed, midi_dut, &size);
|
||||
@@ -132,7 +132,7 @@ void test_midi_pressure_val(void) {
|
||||
for(int cmd = PRESSURE_VAL; cmd < PRESSURE_VAL + NUM_CHANS; cmd++){
|
||||
for(int test = 0; test < NUM_TESTS_PER_TEST; test++){
|
||||
unsigned midi_ref[3] = {cmd, random(&rndm) & DATA_MASK, random(&rndm) & DATA_MASK};
|
||||
unsigned packed = mini_in_parse_ut(midi_ref);
|
||||
unsigned packed = midi_in_parse_ut(midi_ref);
|
||||
unsigned midi_dut[3] = {0};
|
||||
unsigned size = 0;
|
||||
midi_out_parse_c_wrapper(packed, midi_dut, &size);
|
||||
@@ -150,7 +150,7 @@ void test_midi_range(void) {
|
||||
for(int cmd = RANGE; cmd < RANGE + NUM_CHANS; cmd++){
|
||||
for(int test = 0; test < NUM_TESTS_PER_TEST; test++){
|
||||
unsigned midi_ref[3] = {cmd, random(&rndm) & DATA_MASK, random(&rndm) & DATA_MASK};
|
||||
unsigned packed = mini_in_parse_ut(midi_ref);
|
||||
unsigned packed = midi_in_parse_ut(midi_ref);
|
||||
unsigned midi_dut[3] = {0};
|
||||
unsigned size = 0;
|
||||
midi_out_parse_c_wrapper(packed, midi_dut, &size);
|
||||
@@ -168,7 +168,7 @@ void test_midi_manufacturer_id(void) {
|
||||
for(int cmd = MANUFACTURE_ID; cmd < MANUFACTURE_ID + NUM_CHANS; cmd++){
|
||||
for(int test = 0; test < NUM_TESTS_PER_TEST; test++){
|
||||
unsigned midi_ref[3] = {cmd, random(&rndm) & DATA_MASK, random(&rndm) & DATA_MASK};
|
||||
unsigned packed = mini_in_parse_ut(midi_ref);
|
||||
unsigned packed = midi_in_parse_ut(midi_ref);
|
||||
unsigned midi_dut[3] = {0};
|
||||
unsigned size = 0;
|
||||
midi_out_parse_c_wrapper(packed, midi_dut, &size);
|
||||
|
||||
Reference in New Issue
Block a user