-- This is an implementation of ieee.std_logic_1164 based only on the -- specifications. This file is part of GHDL. -- Copyright (C) 2015 Tristan Gingold -- -- GHDL is free software; you can redistribute it and/or modify it under -- the terms of the GNU General Public License as published by the Free -- Software Foundation; either version 2, or (at your option) any later -- version. -- -- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY -- WARRANTY; without even the implied warranty of MERCHANTABILITY or -- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- for more details. -- -- You should have received a copy of the GNU General Public License -- along with GCC; see the file COPYING2. If not see -- . -- This package is valid for VHDL version until but not including 2008. -- For VHDL87, the functions xnor should be removed. package std_logic_1164 is -- Unresolved logic state. type std_ulogic is ('U', -- Uninitialized, this is also the default value. 'X', -- Unknown / conflict value (forcing level). '0', -- 0 (forcing level). '1', -- 1 (forcing level). 'Z', -- High impedance. 'W', -- Unknown / conflict (weak level). 'L', -- 0 (weak level). 'H', -- 1 (weak level). '-' -- Don't care. ); -- Vector of logic state. type std_ulogic_vector is array (natural range <>) of std_ulogic; -- Resolution function. -- If S is empty, returns 'Z'. -- If S has one element, return the element. -- Otherwise, 'U' is the strongest. -- then 'X' -- then '0' and '1' -- then 'W' -- then 'H' and 'L' -- then 'Z'. function resolved (s : std_ulogic_vector) return std_ulogic; -- Resolved logic state. subtype std_logic is resolved std_ulogic; -- Vector of std_logic. type std_logic_vector is array (natural range <>) of std_logic; -- Subtypes of std_ulogic. The names give the values. subtype X01 is resolved std_ulogic range 'X' to '1'; subtype X01Z is resolved std_ulogic range 'X' to 'Z'; subtype UX01 is resolved std_ulogic range 'U' to '1'; subtype UX01Z is resolved std_ulogic range 'U' to 'Z'; -- Logical operators. -- For logical operations, the inputs are first normalized to UX01: -- 0 and L are normalized to 0, 1 and 1 are normalized to 1, U isnt changed, -- all other states are normalized to X. -- Then the classical electric rules are followed. function "and" (l : std_ulogic; r : std_ulogic) return UX01; function "nand" (l : std_ulogic; r : std_ulogic) return UX01; function "or" (l : std_ulogic; r : std_ulogic) return UX01; function "nor" (l : std_ulogic; r : std_ulogic) return UX01; function "xor" (l : std_ulogic; r : std_ulogic) return UX01; function "xnor" (l : std_ulogic; r : std_ulogic) return UX01; function "not" (l : std_ulogic) return UX01; -- Logical operators for vectors. -- An assertion of severity failure fails if the length of L and R aren't -- equal. The result range is 1 to L'Length. function "and" (l, r : std_logic_vector) return std_logic_vector; function "nand" (l, r : std_logic_vector) return std_logic_vector; function "or" (l, r : std_logic_vector) return std_logic_vector; function "nor" (l, r : std_logic_vector) return std_logic_vector; function "xor" (l, r : std_logic_vector) return std_logic_vector; function "xnor" (l, r : std_logic_vector) return std_logic_vector; function "not" (l : std_logic_vector) return std_logic_vector; function "and" (l, r : std_ulogic_vector) return std_ulogic_vector; function "nand" (l, r : std_ulogic_vector) return std_ulogic_vector; function "or" (l, r : std_ulogic_vector) return std_ulogic_vector; function "nor" (l, r : std_ulogic_vector) return std_ulogic_vector; function "xor" (l, r : std_ulogic_vector) return std_ulogic_vector; function "xnor" (l, r : std_ulogic_vector) return std_ulogic_vector; function "not" (l : std_ulogic_vector) return std_ulogic_vector; -- Conversion functions. -- The result range (for vectors) is S'Length - 1 downto 0. -- XMAP is return for values not in '0', '1', 'L', 'H'. function to_bit (s : std_ulogic; xmap : bit := '0') return bit; function to_bitvector (s : std_logic_vector; xmap : bit := '0') return bit_vector; function to_bitvector (s : std_ulogic_vector; xmap : bit := '0') return bit_vector; function to_stdulogic (b : bit) return std_ulogic; function to_stdlogicvector (b : bit_vector) return std_logic_vector; function to_stdlogicvector (s : std_ulogic_vector) return std_logic_vector; function to_stdulogicvector (b : bit_vector) return std_ulogic_vector; function to_stdulogicvector (s : std_logic_vector) return std_ulogic_vector; -- Normalization. -- The result range (for vectors) is 1 to S'Length. function to_X01 (s : std_logic_vector) return std_logic_vector; function to_X01 (s : std_ulogic_vector) return std_ulogic_vector; function to_X01 (s : std_ulogic) return X01; function to_X01 (b : bit_vector) return std_logic_vector; function to_X01 (b : bit_vector) return std_ulogic_vector; function to_X01 (b : bit) return X01; function to_X01Z (s : std_logic_vector) return std_logic_vector; function to_X01Z (s : std_ulogic_vector) return std_ulogic_vector; function to_X01Z (s : std_ulogic) return X01Z; function to_X01Z (b : bit_vector) return std_logic_vector; function to_X01Z (b : bit_vector) return std_ulogic_vector; function to_X01Z (b : bit) return X01Z; function to_UX01 (s : std_logic_vector) return std_logic_vector; function to_UX01 (s : std_ulogic_vector) return std_ulogic_vector; function to_UX01 (s : std_ulogic) return UX01; function to_UX01 (b : bit_vector) return std_logic_vector; function to_UX01 (b : bit_vector) return std_ulogic_vector; function to_UX01 (b : bit) return UX01; -- Edge detection. -- An edge is detected in case of event on s, and X01 normalized value -- rises from 0 to 1 or falls from 1 to 0. function rising_edge (signal s : std_ulogic) return boolean; function falling_edge (signal s : std_ulogic) return boolean; -- Test for unknown. Only 0, 1, L and H are known values. function is_X (s : std_ulogic_vector) return boolean; function is_X (s : std_logic_vector) return boolean; function is_X (s : std_ulogic) return boolean; end std_logic_1164; ' href='#n94'>94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
/*
             LUFA Library
     Copyright (C) Dean Camera, 2017.

  dean [at] fourwalledcubicle [dot] com
           www.lufa-lib.org
*/

/*
  Copyright 2017  Dean Camera (dean [at] fourwalledcubicle [dot] com)

  Permission to use, copy, modify, distribute, and sell this
  software and its documentation for any purpose is hereby granted
  without fee, provided that the above copyright notice appear in
  all copies and that both that the copyright notice and this
  permission notice and warranty disclaimer appear in supporting
  documentation, and that the name of the author not be used in
  advertising or publicity pertaining to distribution of the
  software without specific, written prior permission.

  The author disclaims all warranties with regard to this
  software, including all implied warranties of merchantability
  and fitness.  In no event shall the author be liable for any
  special, indirect or consequential damages or any damages
  whatsoever resulting from loss of use, data or profits, whether
  in an action of contract, negligence or other tortious action,
  arising out of or in connection with the use or performance of
  this software.
*/

/** \file
 *
 *  Header file for Descriptors.c.
 */

#ifndef _DESCRIPTORS_H_
#define _DESCRIPTORS_H_

	/* Includes: */
		#include <LUFA/Drivers/USB/USB.h>

		#include <avr/pgmspace.h>

		#include "Config/AppConfig.h"

	/* Macros: */
		/** Endpoint address of the MIDI streaming data IN endpoint, for device-to-host data transfers. */
		#define MIDI_STREAM_IN_EPADDR       (ENDPOINT_DIR_IN  | 2)

		/** Endpoint address of the MIDI streaming data OUT endpoint, for host-to-device data transfers. */
		#define MIDI_STREAM_OUT_EPADDR      (ENDPOINT_DIR_OUT | 1)

		/** Endpoint size in bytes of the Audio isochronous streaming data IN and OUT endpoints. */
		#define MIDI_STREAM_EPSIZE          64

	/* Type Defines: */
		/** Type define for the device configuration descriptor structure. This must be defined in the
		 *  application code, as the configuration descriptor contains several sub-descriptors which
		 *  vary between devices, and which describe the device's usage to the host.
		 */
		typedef struct
		{
			USB_Descriptor_Configuration_Header_t     Config;

			// MIDI Audio Control Interface
			USB_Descriptor_Interface_t                Audio_ControlInterface;
			USB_Audio_Descriptor_Interface_AC_t       Audio_ControlInterface_SPC;

			// MIDI Audio Streaming Interface
			USB_Descriptor_Interface_t                Audio_StreamInterface;
			USB_MIDI_Descriptor_AudioInterface_AS_t   Audio_StreamInterface_SPC;
			USB_MIDI_Descriptor_InputJack_t           MIDI_In_Jack_Emb;
			USB_MIDI_Descriptor_InputJack_t           MIDI_In_Jack_Ext;
			USB_MIDI_Descriptor_OutputJack_t          MIDI_Out_Jack_Emb;
			USB_MIDI_Descriptor_OutputJack_t          MIDI_Out_Jack_Ext;
			USB_Audio_Descriptor_StreamEndpoint_Std_t MIDI_In_Jack_Endpoint;
			USB_MIDI_Descriptor_Jack_Endpoint_t       MIDI_In_Jack_Endpoint_SPC;
			USB_Audio_Descriptor_StreamEndpoint_Std_t MIDI_Out_Jack_Endpoint;
			USB_MIDI_Descriptor_Jack_Endpoint_t       MIDI_Out_Jack_Endpoint_SPC;
		} USB_Descriptor_Configuration_t;

		/** Enum for the device interface descriptor IDs within the device. Each interface descriptor
		 *  should have a unique ID index associated with it, which can be used to refer to the
		 *  interface from other descriptors.
		 */
		enum InterfaceDescriptors_t
		{
			INTERFACE_ID_AudioControl = 0, /**< Audio control interface descriptor ID */
			INTERFACE_ID_AudioStream  = 1, /**< Audio stream interface descriptor ID */
		};

		/** Enum for the device string descriptor IDs within the device. Each string descriptor should
		 *  have a unique ID index associated with it, which can be used to refer to the string from
		 *  other descriptors.
		 */
		enum StringDescriptors_t
		{
			STRING_ID_Language     = 0, /**< Supported Languages string descriptor ID (must be zero) */
			STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
			STRING_ID_Product      = 2, /**< Product string ID */
		};

	/* Function Prototypes: */
		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
		                                    const uint16_t wIndex,
		                                    const void** const DescriptorAddress)
		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);

#endif