forked from PAWPAW-Mirror/lib_xua
Created xua_buffer.h.
Added dummy hw config calls to simple app. Tmp added gpio_access
This commit is contained in:
50
examples/app_xua_simple/src/gpio_access.c
Normal file
50
examples/app_xua_simple/src/gpio_access.c
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#include "gpio_access.h"
|
||||||
|
//#include "swlock.h"
|
||||||
|
#include <xs1.h>
|
||||||
|
|
||||||
|
//swlock_t gpo_swlock = SWLOCK_INITIAL_VALUE;
|
||||||
|
|
||||||
|
void p_gpio_lock()
|
||||||
|
{
|
||||||
|
//swlock_acquire(&gpo_swlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void p_gpio_unlock()
|
||||||
|
{
|
||||||
|
//swlock_release(&gpo_swlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned p_gpio_peek()
|
||||||
|
{
|
||||||
|
unsigned portId, x;
|
||||||
|
|
||||||
|
// Wrapped in lock to ensure it's safe from multiple logical cores
|
||||||
|
// swlock_acquire(&gpo_swlock);
|
||||||
|
|
||||||
|
asm("ldw %0, dp[p_gpio]":"=r"(portId));
|
||||||
|
asm volatile("peek %0, res[%1]":"=r"(x):"r"(portId));
|
||||||
|
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void p_gpio_out(unsigned x)
|
||||||
|
{
|
||||||
|
unsigned portId;
|
||||||
|
|
||||||
|
asm("ldw %0, dp[p_gpio]":"=r"(portId));
|
||||||
|
asm volatile("out res[%0], %1"::"r"(portId),"r"(x));
|
||||||
|
|
||||||
|
// Wrapped in lock to ensure it's safe from multiple logical cores
|
||||||
|
//swlock_release(&gpo_swlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_gpio(unsigned bit, unsigned value)
|
||||||
|
{
|
||||||
|
unsigned port_shadow;
|
||||||
|
port_shadow = p_gpio_peek(); // Read port pin value
|
||||||
|
if (value == 0) port_shadow &= ~bit; // If writing a 0, generate mask and AND with current val
|
||||||
|
else port_shadow |= bit; // Else use mask and OR to set bit
|
||||||
|
p_gpio_out(port_shadow); // Write back to port. Will make port an output if not already
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
51
examples/app_xua_simple/src/gpio_access.h
Normal file
51
examples/app_xua_simple/src/gpio_access.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#ifndef _GPIO_ACCESS_H_
|
||||||
|
#define _GPIO_ACCESS_H_
|
||||||
|
|
||||||
|
#include "customdefines.h"
|
||||||
|
|
||||||
|
#if XCORE_200_MC_AUDIO_HW_VERSION == 2
|
||||||
|
|
||||||
|
/* General output port bit definitions */
|
||||||
|
#define P_GPIO_DSD_MODE (1 << 0) /* DSD mode select 0 = 8i/8o I2S, 1 = 8o DSD*/
|
||||||
|
#define P_GPIO_DAC_RST_N (1 << 1)
|
||||||
|
#define P_GPIO_USB_SEL0 (1 << 2)
|
||||||
|
#define P_GPIO_USB_SEL1 (1 << 3)
|
||||||
|
#define P_GPIO_VBUS_EN (1 << 4)
|
||||||
|
#define P_GPIO_PLL_SEL (1 << 5) /* 1 = CS2100, 0 = Phaselink clock source */
|
||||||
|
#define P_GPIO_ADC_RST_N (1 << 6)
|
||||||
|
#define P_GPIO_MCLK_FSEL (1 << 7) /* Select frequency on Phaselink clock. 0 = 24.576MHz for 48k, 1 = 22.5792MHz for 44.1k.*/
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* General output port bit definitions */
|
||||||
|
#define P_GPIO_DSD_MODE (1 << 0) /* DSD mode select 0 = 8i/8o I2S, 1 = 8o DSD*/
|
||||||
|
#define P_GPIO_DAC_RST_N (1 << 1)
|
||||||
|
#define P_GPIO_ADC_RST_N (1 << 2)
|
||||||
|
#define P_GPIO_USB_SEL0 (1 << 3)
|
||||||
|
#define P_GPIO_USB_SEL1 (1 << 4)
|
||||||
|
#define P_GPIO_VBUS_EN (1 << 5)
|
||||||
|
#define P_GPIO_MCLK_FSEL (1 << 6) /* Select frequency on Phaselink clock. 0 = 24.576MHz for 48k, 1 = 22.5792MHz for 44.1k.*/
|
||||||
|
#define P_GPIO_PLL_SEL (1 << 7) /* 1 = CS2100, 0 = Phaselink clock source */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*LED array defines*/
|
||||||
|
#define LED_ALL_ON 0xf00f
|
||||||
|
#define LED_SQUARE_BIG 0x9009
|
||||||
|
#define LED_SQUARE_SML 0x6006
|
||||||
|
#define LED_ROW_1 0xf001
|
||||||
|
#define LED_ROW_2 0xf003
|
||||||
|
#define LED_ROW_3 0xf007
|
||||||
|
#define ALL_OFF 0x0000
|
||||||
|
// LED array masks
|
||||||
|
#define LED_MASK_COL_OFF 0x7fff
|
||||||
|
#define LED_MASK_DISABLE 0xffff
|
||||||
|
|
||||||
|
void set_gpio(unsigned bit, unsigned value);
|
||||||
|
void p_gpio_lock();
|
||||||
|
void p_gpio_unlock();
|
||||||
|
unsigned p_gpio_peek();
|
||||||
|
void p_gpio_out(unsigned x);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include "audiohw.h"
|
#include "audiohw.h"
|
||||||
#include "customdefines.h"
|
#include "customdefines.h"
|
||||||
|
#include "gpio_access.h"
|
||||||
|
|
||||||
|
|
||||||
void AudioHwConfig(unsigned samFreq, unsigned mClk, chanend ?c_codec, unsigned dsdMode,
|
void AudioHwConfig(unsigned samFreq, unsigned mClk, chanend ?c_codec, unsigned dsdMode,
|
||||||
unsigned sampRes_DAC, unsigned sampRes_ADC)
|
unsigned sampRes_DAC, unsigned sampRes_ADC)
|
||||||
@@ -12,6 +14,7 @@ void AudioHwConfig(unsigned samFreq, unsigned mClk, chanend ?c_codec, unsigned d
|
|||||||
|
|
||||||
void AudioHwInit(chanend ?c_codec)
|
void AudioHwInit(chanend ?c_codec)
|
||||||
{
|
{
|
||||||
// nothing
|
set_gpio(P_GPIO_USB_SEL0, 1);
|
||||||
|
set_gpio(P_GPIO_USB_SEL1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
117
lib_xua/api/xua_buffer.h
Normal file
117
lib_xua/api/xua_buffer.h
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
#ifndef __XUA_BUFFER_H__
|
||||||
|
#define __XUA_BUFFER_H__
|
||||||
|
/** USB Audio Buffering Thread.
|
||||||
|
*
|
||||||
|
* This function buffers USB audio data between the XUD layer and the decouple
|
||||||
|
* thread. Most of the chanend parameters to the function should be connected to
|
||||||
|
* XUD_Manager()
|
||||||
|
*
|
||||||
|
* \param c_aud_out Audio OUT endpoint channel connected to the XUD
|
||||||
|
* \param c_aud_in Audio IN endpoint channel connected to the XUD
|
||||||
|
* \param c_aud_fb Audio feedback endpoint channel connected to the XUD
|
||||||
|
* \param c_midi_from_host MIDI OUT endpoint channel connected to the XUD
|
||||||
|
* \param c_midi_to_host MIDI IN endpoint channel connected to the XUD
|
||||||
|
* \param c_int Audio clocking interrupt endpoint channel connected to the XUD
|
||||||
|
* \param c_clk_int Optional chanend connected to the clockGen() thread if present
|
||||||
|
* \param c_sof Start of frame channel connected to the XUD
|
||||||
|
* \param c_aud_ctl Audio control channel connected to Endpoint0()
|
||||||
|
* \param p_off_mclk A port that is clocked of the MCLK input (not the MCLK input itself)
|
||||||
|
*/
|
||||||
|
#include "devicedefines.h"
|
||||||
|
|
||||||
|
|
||||||
|
void XUA_Buffer(
|
||||||
|
chanend c_aud_out,
|
||||||
|
#if (NUM_USB_CHAN_IN > 0)
|
||||||
|
chanend c_aud_in,
|
||||||
|
#endif
|
||||||
|
#if (NUM_USB_CHAN_IN == 0) || defined (UAC_FORCE_FEEDBACK_EP)
|
||||||
|
chanend c_aud_fb,
|
||||||
|
#endif
|
||||||
|
#ifdef MIDI
|
||||||
|
chanend c_midi_from_host,
|
||||||
|
chanend c_midi_to_host,
|
||||||
|
chanend c_midi,
|
||||||
|
#endif
|
||||||
|
#ifdef IAP
|
||||||
|
chanend c_iap_from_host,
|
||||||
|
chanend c_iap_to_host,
|
||||||
|
#ifdef IAP_INT_EP
|
||||||
|
chanend c_iap_to_host_int,
|
||||||
|
#endif
|
||||||
|
chanend c_iap,
|
||||||
|
#ifdef IAP_EA_NATIVE_TRANS
|
||||||
|
chanend c_iap_ea_native_out,
|
||||||
|
chanend c_iap_ea_native_in,
|
||||||
|
chanend c_iap_ea_native_ctrl,
|
||||||
|
chanend c_iap_ea_native_data,
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if defined(SPDIF_RX) || defined(ADAT_RX)
|
||||||
|
chanend ?c_int,
|
||||||
|
chanend ?c_clk_int,
|
||||||
|
#endif
|
||||||
|
chanend c_sof,
|
||||||
|
chanend c_aud_ctl,
|
||||||
|
in port p_off_mclk
|
||||||
|
#ifdef HID_CONTROLS
|
||||||
|
, chanend c_hid
|
||||||
|
#endif
|
||||||
|
, chanend c_aud
|
||||||
|
);
|
||||||
|
|
||||||
|
void XUA_Buffer_Ep(chanend c_aud_out,
|
||||||
|
#if (NUM_USB_CHAN_IN > 0)
|
||||||
|
chanend c_aud_in,
|
||||||
|
#endif
|
||||||
|
#if (NUM_USB_CHAN_IN == 0) || defined (UAC_FORCE_FEEDBACK_EP)
|
||||||
|
chanend c_aud_fb,
|
||||||
|
#endif
|
||||||
|
#ifdef MIDI
|
||||||
|
chanend c_midi_from_host,
|
||||||
|
chanend c_midi_to_host,
|
||||||
|
chanend c_midi,
|
||||||
|
#endif
|
||||||
|
#ifdef IAP
|
||||||
|
chanend c_iap_from_host,
|
||||||
|
chanend c_iap_to_host,
|
||||||
|
#ifdef IAP_INT_EP
|
||||||
|
chanend c_iap_to_host_int,
|
||||||
|
#endif
|
||||||
|
chanend c_iap,
|
||||||
|
#ifdef IAP_EA_NATIVE_TRANS
|
||||||
|
chanend c_iap_ea_native_out,
|
||||||
|
chanend c_iap_ea_native_in,
|
||||||
|
chanend c_iap_ea_native_ctrl,
|
||||||
|
chanend c_iap_ea_native_data,
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if defined(SPDIF_RX) || defined(ADAT_RX)
|
||||||
|
chanend ?c_int,
|
||||||
|
chanend ?c_clk_int,
|
||||||
|
#endif
|
||||||
|
chanend c_sof,
|
||||||
|
chanend c_aud_ctl,
|
||||||
|
in port p_off_mclk
|
||||||
|
#ifdef HID_CONTROLS
|
||||||
|
, chanend c_hid
|
||||||
|
#endif
|
||||||
|
#ifdef CHAN_BUFF_CTRL
|
||||||
|
, chanend c_buff_ctrl
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
/** Manage the data transfer between the USB audio buffer and the
|
||||||
|
* Audio I/O driver.
|
||||||
|
*
|
||||||
|
* \param c_audio_out Channel connected to the audio() or mixer() threads
|
||||||
|
*/
|
||||||
|
void XUA_Buffer_Decouple(chanend c_audio_out
|
||||||
|
#ifdef CHAN_BUFF_CTRL
|
||||||
|
, chanend c_buff_ctrl
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#ifndef __DECOUPLE_H__
|
|
||||||
#define __DECOUPLE_H__
|
|
||||||
|
|
||||||
|
|
||||||
/** Manage the data transfer between the USB audio buffer and the
|
|
||||||
* Audio I/O driver.
|
|
||||||
*
|
|
||||||
* \param c_audio_out Channel connected to the audio() or mixer() threads
|
|
||||||
*/
|
|
||||||
void decouple(chanend c_audio_out
|
|
||||||
#ifdef CHAN_BUFF_CTRL
|
|
||||||
, chanend c_buff_ctrl
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif // __DECOUPLE_H__
|
|
||||||
Reference in New Issue
Block a user