Review feedback

This commit is contained in:
Ed
2024-04-24 12:01:52 +01:00
parent 8a90660f7c
commit e83bbf51cf
5 changed files with 49 additions and 39 deletions

View File

@@ -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;

View File

@@ -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] */