# Copyright (c) 2015, XMOS Ltd, All rights reserved

########################################
# xCORE-AUDIO default configuration file
########################################

# USB Identification 

VENDOR_ID = 0x20B1

PRODUCT_ID = 0x3066

# Format of the given USB strings
#   ASCII = 0
#   UNICODE = 1
# If format is mentioned as 1 (UNICODE), then the following
# USB strings are interpreted as unicode instead of ascii.
STRING_FORMAT = 0

VENDOR_STRING = "XMOS"

PRODUCT_STRING = "xCORE-AUDIO Hi-Res 2"

SERIAL_STRING = ''

LANGUAGE_ID = 0x0409

# Power options
MAX_POWER = 0xFA

SELF_POWER_ENABLE = 0

# USB Audio class 1.0 enable/disable
UAC_1_ENABLE = 0

# USB HID inputs enable/disable
HID_INPUTS_ENABLE = 0

# I2S data formats
#   I2S_DEFAULT = 0
#   I2S_LEFT_ALIGNED = 1
#   I2S_RIGHT_ALIGNED = 2
#
I2S_DATA_FORMAT = 0

# Audio sample rates enable/disable
# Bitmap to enable/disable each supported sample rate.
#     |  Bit7  |  Bit6  |  Bit5  |  Bit4  |  Bit3  |  Bit2  |  Bit1  |  Bit0  |
#     | 352.8K | 176.4K | 88.2K  | 44.1K  |  384K  |  192K  |  96K   |  48K   |

SAMPLE_RATE_BITMAP = 0b01110111

# Any variables required for writing event actions can be declared here
# Example: I2C address of the DAC can be set as a variable called
# DAC_I2C_ADDR = 0x48; For ease of writing I2C_WRITE command, the register
# addresses can also be set to variables.

# Default GPIO pins
GPIO_S_AUD_STRM = 0 # GPIO_0 is S_AUD_STRM
GPIO_S_USB_HOST = 1 # GPIO_1 is S_USB_HOST
GPIO_S_DSD_MODE = 2 # GPIO_2 is S_DSD_MODE
GPIO_MCLK_SEL   = 3 # GPIO_3 is MCLK_SEL
GPIO_S_SP_0     = 4 # GPIO_4 is S_SP_0
GPIO_S_DSD_128  = 4 # GPIO_4 is also acts as S_DSD_128
GPIO_S_SP_1     = 5 # GPIO_5 is S_SP_1


# Events and their actions

# System intialize event
EVT_SYS_INIT = []

# USB connected event
EVT_USB_CONNECT = [
    GPIO(GPIO_S_USB_HOST, HIGH),
    ]

# USB disconnected event 
EVT_USB_DISCONNECT = [
    GPIO(GPIO_S_USB_HOST, LOW),
    ]

# Audio streaming started event
EVT_STRM_START = [
    GPIO(GPIO_S_AUD_STRM, HIGH),
    ]

# Audio streaming stopped event
EVT_STRM_STOP = [
    GPIO(GPIO_S_AUD_STRM, LOW),
    ]

# Event on host selecting 48KHz sample rate
EVT_SEL_48K = [
    GPIO(GPIO_MCLK_SEL, HIGH),
    GPIO(GPIO_S_SP_1, LOW),
    GPIO(GPIO_S_SP_0, LOW),
    ]

# Event on host selecting 96KHz sample rate
EVT_SEL_96K = [
    GPIO(GPIO_MCLK_SEL, HIGH),
    GPIO(GPIO_S_SP_1, LOW),
    GPIO(GPIO_S_SP_0, HIGH),
    ]

# Event on host selecting 192KHz sample rate   
EVT_SEL_192K = [
    GPIO(GPIO_MCLK_SEL, HIGH),
    GPIO(GPIO_S_SP_1, HIGH),
    GPIO(GPIO_S_SP_0, LOW),
    ]

# Event on host selecting 384KHz sample rate
EVT_SEL_384K = [
    GPIO(GPIO_MCLK_SEL, HIGH),
    GPIO(GPIO_S_SP_1, HIGH),
    GPIO(GPIO_S_SP_0, HIGH),
    ]

# Event on host selecting 44.1KHz sample rate
EVT_SEL_44_1K = [
    GPIO(GPIO_MCLK_SEL, LOW),
    GPIO(GPIO_S_SP_1, LOW),
    GPIO(GPIO_S_SP_0, LOW),
    ]

# Event on host selecting 88.2KHz sample rate
EVT_SEL_88_2K = [
    GPIO(GPIO_MCLK_SEL, LOW),
    GPIO(GPIO_S_SP_1, LOW),
    GPIO(GPIO_S_SP_0, HIGH),
    ]

# Event on host selecting 176.4KHz sample rate
EVT_SEL_176_4K = [
    GPIO(GPIO_MCLK_SEL, LOW),
    GPIO(GPIO_S_SP_1, HIGH),
    GPIO(GPIO_S_SP_0, LOW),
    ]

# Event on host selecting 352.8KHz sample rate
EVT_SEL_352_8K = [
    GPIO(GPIO_MCLK_SEL, LOW),
    GPIO(GPIO_S_SP_1, HIGH),
    GPIO(GPIO_S_SP_0, HIGH),
    ]

# DSD active event
EVT_DSD_ACTIVE = [
    GPIO(GPIO_S_DSD_MODE, HIGH),
    ]

# PCM active event
EVT_PCM_ACTIVE = [
    GPIO(GPIO_S_DSD_MODE, LOW),
    ]

# Event on host selecting DSD128 format
EVT_SEL_DSD128 = [
    GPIO(GPIO_S_DSD_128, HIGH),
    ]

# Event on host selecting DSD64 format
EVT_SEL_DSD64 = [
    GPIO(GPIO_S_DSD_128, LOW),
    ]