forked from PAWPAW-Mirror/lib_xua
Updates to get L2 working on latest iOS codebase
This commit is contained in:
@@ -528,7 +528,7 @@ void audio(chanend c_mix_out, chanend ?c_dig_rx, chanend ?c_config)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initialise master clock generation */
|
/* Initialise master clock generation */
|
||||||
ClockingInit();
|
ClockingInit(c_config);
|
||||||
|
|
||||||
/* Perform required CODEC/ADC/DAC initialisation */
|
/* Perform required CODEC/ADC/DAC initialisation */
|
||||||
CodecInit(c_config);
|
CodecInit(c_config);
|
||||||
@@ -550,7 +550,7 @@ void audio(chanend c_mix_out, chanend ?c_dig_rx, chanend ?c_config)
|
|||||||
divide = mClk / ( curSamFreq * 64 );
|
divide = mClk / ( curSamFreq * 64 );
|
||||||
|
|
||||||
/* Configure clocking for required master clock */
|
/* Configure clocking for required master clock */
|
||||||
ClockingConfig(mClk);
|
ClockingConfig(mClk, c_config);
|
||||||
|
|
||||||
if(!firstRun)
|
if(!firstRun)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
/* Functions that handle master clock generation. These need modifying for an existing design */
|
/* Functions that handle master clock generation. These need modifying for an existing design */
|
||||||
|
|
||||||
/* Any initialisation required for master clock generation - run once at start up */
|
/* Any initialisation required for master clock generation - run once at start up */
|
||||||
void ClockingInit(void);
|
void ClockingInit(chanend ?c);
|
||||||
|
|
||||||
/* Configuration for a specific master clock frequency - run every sample frequency change */
|
/* Configuration for a specific master clock frequency - run every sample frequency change */
|
||||||
void ClockingConfig(unsigned mClkFreq);
|
void ClockingConfig(unsigned mClkFreq, chanend ?c);
|
||||||
|
|
||||||
|
|
||||||
/** Clock generation and digital audio I/O handling.
|
/** Clock generation and digital audio I/O handling.
|
||||||
|
|||||||
@@ -1,4 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* Module: module_usb_aud_shared
|
||||||
|
* Version: 2v3_iosrc0
|
||||||
|
* Build: 5247dfd8ec69594e0670e3b8073efd3c453ad07d
|
||||||
|
* File: i2c.h
|
||||||
|
*
|
||||||
|
* The copyrights, all other intellectual and industrial
|
||||||
|
* property rights are retained by XMOS and/or its licensors.
|
||||||
|
* Terms and conditions covering the use of this code can
|
||||||
|
* be found in the Xmos End User License Agreement.
|
||||||
|
*
|
||||||
|
* Copyright XMOS Ltd 2010
|
||||||
|
*
|
||||||
|
* In the case where this code is a modification of existing code
|
||||||
|
* under a separate license, the separate license terms are shown
|
||||||
|
* below. The modifications to the code are still covered by the
|
||||||
|
* copyright notice above.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
// Channel interface
|
||||||
|
void I2cRegWriteC(int deviceAdrs, int Adrs, int WrData, chanend c);
|
||||||
|
|
||||||
|
int I2cRegReadC(int deviceAdrs, int Adrs, chanend c);
|
||||||
|
|
||||||
|
// Function interface
|
||||||
void I2cRegWrite(int deviceAdrs, int Adrs, int WrData, port AUD_SCLK, port AUD_SDIN);
|
void I2cRegWrite(int deviceAdrs, int Adrs, int WrData, port AUD_SCLK, port AUD_SDIN);
|
||||||
|
|
||||||
int I2cRegRead(int deviceAdrs, int Adrs, port AUD_SCLK, port AUD_SDIN);
|
int I2cRegRead(int deviceAdrs, int Adrs, port AUD_SCLK, port AUD_SDIN);
|
||||||
|
|||||||
@@ -1,6 +1,47 @@
|
|||||||
|
/**
|
||||||
|
* Module: module_usb_aud_shared
|
||||||
|
* Version: 2v3_iosrc0
|
||||||
|
* Build: c1785ffa61c5d34613093518d78adcebd79ae1cc
|
||||||
|
* File: i2c.xc
|
||||||
|
*
|
||||||
|
* The copyrights, all other intellectual and industrial
|
||||||
|
* property rights are retained by XMOS and/or its licensors.
|
||||||
|
* Terms and conditions covering the use of this code can
|
||||||
|
* be found in the Xmos End User License Agreement.
|
||||||
|
*
|
||||||
|
* Copyright XMOS Ltd 2010
|
||||||
|
*
|
||||||
|
* In the case where this code is a modification of existing code
|
||||||
|
* under a separate license, the separate license terms are shown
|
||||||
|
* below. The modifications to the code are still covered by the
|
||||||
|
* copyright notice above.
|
||||||
|
*
|
||||||
|
**/
|
||||||
#include <xs1.h>
|
#include <xs1.h>
|
||||||
#include <print.h>
|
#include <print.h>
|
||||||
|
|
||||||
|
int I2cRegReadC(int device, int addr, chanend c) {
|
||||||
|
int read;
|
||||||
|
int retVal;
|
||||||
|
c <: 0; // isWrite
|
||||||
|
c <: device;
|
||||||
|
c <: addr;
|
||||||
|
c <: 1; // only ever one byte
|
||||||
|
c :> read;
|
||||||
|
c :> retVal;
|
||||||
|
return read;
|
||||||
|
}
|
||||||
|
|
||||||
|
void I2cRegWriteC(int device, int addr, int data, chanend c) {
|
||||||
|
int retVal;
|
||||||
|
c <: 1; // isWrite
|
||||||
|
c <: device;
|
||||||
|
c <: addr;
|
||||||
|
c <: 1; // only ever one byte
|
||||||
|
c <: data;
|
||||||
|
c :> retVal;
|
||||||
|
}
|
||||||
|
|
||||||
int I2cRegRead(int device, int addr, port scl, port sda)
|
int I2cRegRead(int device, int addr, port scl, port sda)
|
||||||
{
|
{
|
||||||
//int Result;
|
//int Result;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
void PllInit(void);
|
void PllInit(chanend ?c);
|
||||||
|
|
||||||
|
|
||||||
void PllMult(unsigned mult);
|
void PllMult(unsigned mult, chanend ?c);
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
* \param c_clk_int Optional chanend connected to the clockGen() thread if present
|
* \param c_clk_int Optional chanend connected to the clockGen() thread if present
|
||||||
*/
|
*/
|
||||||
void decouple(chanend c_audio_out,
|
void decouple(chanend c_audio_out,
|
||||||
chanend ?c_led,
|
chanend ?c_midi,
|
||||||
chanend ?c_midi, chanend ?c_clk_int
|
chanend ?c_clk_int
|
||||||
#ifdef IAP
|
#ifdef IAP
|
||||||
, chanend ?c_iap
|
, chanend ?c_iap
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "midiinparse.h"
|
#include "midiinparse.h"
|
||||||
#include "midioutparse.h"
|
#include "midioutparse.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "port32A.h"
|
//#include "port32A.h"
|
||||||
#ifdef IAP
|
#ifdef IAP
|
||||||
#include "iAP.h"
|
#include "iAP.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -64,77 +64,93 @@ extern unsigned authenticating;
|
|||||||
// state for auto-selecting dock or USB B
|
// state for auto-selecting dock or USB B
|
||||||
extern unsigned polltime;
|
extern unsigned polltime;
|
||||||
|
|
||||||
|
#ifdef IO_EXPANSION
|
||||||
extern port p_i2c_scl;
|
extern port p_i2c_scl;
|
||||||
extern port p_i2c_sda;
|
extern port p_i2c_sda;
|
||||||
#define p_midi_out p_i2c_scl
|
#define p_midi_out p_i2c_scl
|
||||||
#define p_midi_in p_i2c_sda
|
#define p_midi_in p_i2c_sda
|
||||||
|
#else
|
||||||
|
//extern out port p_midi_tx;
|
||||||
|
//extern port p_midi_rx;
|
||||||
|
#define p_midi_out p_midi_tx
|
||||||
|
#define p_midi_in p_midi_rx
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#ifdef IO_EXPANSION
|
||||||
|
#if 0
|
||||||
extern timer i2ctimer;
|
extern timer i2ctimer;
|
||||||
#define iAPTimer i2ctimer
|
#define iAPTimer i2ctimer
|
||||||
|
#else
|
||||||
|
timer iAPTimer;
|
||||||
|
#endif
|
||||||
|
|
||||||
void usb_midi(in port ?p_midi_inj, out port ?p_midi_outj,
|
void usb_midi(in port ?p_midi_in, out port ?p_midi_out,
|
||||||
clock ?clk_midi,
|
clock ?clk_midi,
|
||||||
chanend c_midi,
|
chanend c_midi,
|
||||||
unsigned cable_number,
|
unsigned cable_number,
|
||||||
chanend c_iap, chanend ?c_i2c // iOS stuff
|
chanend c_iap, chanend ?c_i2c // iOS stuff
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
unsigned symbol = 0x0; // Symbol in progress of being sent out
|
unsigned symbol = 0x0; // Symbol in progress of being sent out
|
||||||
unsigned isTX = 0; // Guard when outputting data
|
unsigned isTX = 0; // Guard when outputting data
|
||||||
unsigned txT; // Timer value used for outputting
|
unsigned txT; // Timer value used for outputting
|
||||||
//unsigned inputPortState, newInputPortState;
|
//unsigned inputPortState, newInputPortState;
|
||||||
int waiting_for_ack = 0;
|
int waiting_for_ack = 0;
|
||||||
// Receiver
|
// Receiver
|
||||||
unsigned rxByte;
|
unsigned rxByte;
|
||||||
int rxI;
|
int rxI;
|
||||||
int rxT;
|
int rxT;
|
||||||
int isRX = 0; // Guard when receiving data
|
int isRX = 0; // Guard when receiving data
|
||||||
timer t;
|
timer t;
|
||||||
timer t2;
|
timer t2;
|
||||||
|
|
||||||
// One place buffer for data going out to host
|
// One place buffer for data going out to host
|
||||||
queue midi_to_host_fifo;
|
queue midi_to_host_fifo;
|
||||||
unsigned char midi_to_host_fifo_arr[4]; // Used for 32bit USB MIDI events
|
unsigned char midi_to_host_fifo_arr[4]; // Used for 32bit USB MIDI events
|
||||||
|
|
||||||
unsigned outputting_symbol, outputted_symbol;
|
unsigned outputting_symbol, outputted_symbol;
|
||||||
|
|
||||||
struct midi_in_parse_state mips;
|
struct midi_in_parse_state mips;
|
||||||
|
|
||||||
// the symbol fifo (to go out of uart)
|
// the symbol fifo (to go out of uart)
|
||||||
queue symbol_fifo;
|
queue symbol_fifo;
|
||||||
unsigned char symbol_fifo_arr[USB_MIDI_DEVICE_OUT_FIFO_SIZE * 4]; // Used for 32bit USB MIDI events
|
unsigned char symbol_fifo_arr[USB_MIDI_DEVICE_OUT_FIFO_SIZE * 4]; // Used for 32bit USB MIDI events
|
||||||
|
|
||||||
unsigned rxPT, txPT;
|
unsigned rxPT, txPT;
|
||||||
int midi_from_host_overflow = 0;
|
int midi_from_host_overflow = 0;
|
||||||
|
|
||||||
//configure_clock_rate(clk_midi, 100, 1);
|
//configure_clock_rate(clk_midi, 100, 1);
|
||||||
init_queue(symbol_fifo, symbol_fifo_arr, USB_MIDI_DEVICE_OUT_FIFO_SIZE, 4);
|
init_queue(symbol_fifo, symbol_fifo_arr, USB_MIDI_DEVICE_OUT_FIFO_SIZE, 4);
|
||||||
init_queue(midi_to_host_fifo, midi_to_host_fifo_arr, 1, 4);
|
init_queue(midi_to_host_fifo, midi_to_host_fifo_arr, 1, 4);
|
||||||
|
|
||||||
configure_out_port_no_ready(p_midi_out, clk_midi, 1);
|
configure_out_port_no_ready(p_midi_out, clk_midi, 1);
|
||||||
configure_in_port(p_midi_in, clk_midi);
|
configure_in_port(p_midi_in, clk_midi);
|
||||||
|
|
||||||
start_clock(clk_midi);
|
start_clock(clk_midi);
|
||||||
start_port(p_midi_out);
|
start_port(p_midi_out);
|
||||||
start_port(p_midi_in);
|
start_port(p_midi_in);
|
||||||
|
|
||||||
reset_midi_state(mips);
|
reset_midi_state(mips);
|
||||||
|
|
||||||
t :> txT;
|
t :> txT;
|
||||||
t2 :> rxT;
|
t2 :> rxT;
|
||||||
|
|
||||||
#ifndef MIDI_LOOPBACK
|
#ifndef MIDI_LOOPBACK
|
||||||
#ifdef IAP
|
#ifdef IAP
|
||||||
port32A_unset(P32A_I2C_NOTMIDI);
|
#ifdef IO_EXPANSION
|
||||||
|
port32A_unset(P32A_I2C_NOTMIDI);
|
||||||
#endif
|
#endif
|
||||||
p_midi_out <: 1; // Start with high bit.
|
#endif
|
||||||
|
p_midi_out <: 1; // Start with high bit.
|
||||||
#ifdef IAP
|
#ifdef IAP
|
||||||
port32A_set(P32A_I2C_NOTMIDI);
|
#ifdef IO_EXPANSION
|
||||||
|
port32A_set(P32A_I2C_NOTMIDI);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IAP
|
#ifdef IAP
|
||||||
init_iAP(c_i2c); // uses timer for i2c initialisation pause..
|
init_iAP(c_i2c); // uses timer for i2c initialisation pause..
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user