Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
USBB OTG Driver

USBB low-level driver for OTG features.

Warning
Bit-masks are used instead of bit-fields because PB registers require 32-bit write accesses while AVR32-GCC 4.0.2 builds 8-bit accesses even when volatile unsigned int bit-fields are specified.

Functions

void otg_dual_disable (void)
 Uninitialize the dual role This function is implemented in usbb_host.c file. More...
 
bool otg_dual_enable (void)
 Initialize the dual role This function is implemented in usbb_host.c file. More...
 

USBB IP properties

These macros give access to IP properties

#define otg_get_ip_name()   (((uint64_t)AVR32_USBB.uname2<<32)|(uint64_t)AVR32_USBB.uname1)
 Get IP name part 1 or 2. More...
 
#define otg_data_memory_barrier()   (AVR32_USBB.uvers)
 Instruction to access at a peripheral register after interrupt clear, see AVR32002 - AVR32UC Technical reference $6.6 Memory barriers. More...
 
#define otg_get_ip_version()   USBB_RD_BITFIELD(UVERS,VERSION_NUM)
 Get IP version. More...
 
#define otg_get_dpram_size()   (128 << USBB_RD_BITFIELD(UFEATURES,FIFO_MAX_SIZE))
 Get DPRAM size (FIFO maximal size) in bytes. More...
 
#define otg_get_ip_paddress_size()   (AVR32_USBB.uaddrsize)
 Get size of USBB PB address space. More...
 

USBB OTG ID pin management

The ID pin come from the USB OTG connector (A and B receptable) and allows to select the USB mode host or device.

The USBB hardware can manage it automatically. This feature is optional. When otg_ID_PIN equals true in conf_usb_host.h, the USB_ID must be defined in board.h.

#define OTG_ID_PIN   ATPASTE2(USB_ID, _PIN)
 Pin and function for OTG_ID according to configuration from USB_ID. More...
 
#define OTG_ID_FUNCTION   ATPASTE2(USB_ID, _FUNCTION)
 
#define otg_input_id_pin()
 Input USB_ID from its pin. More...
 
#define otg_enable_id_pin()   USBB_SET_BITS(USBCON,UIDE)
 
#define otg_disable_id_pin()   USBB_CLR_BITS(USBCON,UIDE)
 
#define otg_force_device_mode()   USBB_SET_BITS(USBCON,UIMOD)
 
#define Is_otg_device_mode_forced()   USBB_TST_BITS(USBCON,UIMOD)
 
#define otg_force_host_mode()   USBB_CLR_BITS(USBCON,UIMOD)
 
#define Is_otg_host_mode_forced()   (!Is_otg_device_mode_forced())
 

USBB OTG ID pin interrupt management

These macros manage the ID pin interrupt

#define otg_enable_id_interrupt()   USBB_SET_BITS(USBCON,IDTE)
 
#define otg_disable_id_interrupt()   USBB_CLR_BITS(USBCON,IDTE)
 
#define Is_otg_id_interrupt_enabled()   USBB_TST_BITS(USBCON,IDTE)
 
#define Is_otg_id_device()   USBB_TST_BITS(USBSTA,ID)
 
#define Is_otg_id_host()   (!Is_otg_id_device())
 
#define otg_ack_id_transition()   USBB_REG_CLR(USBSTA,IDTI)
 
#define Is_otg_id_transition()   USBB_TST_BITS(USBSTA,IDTI)
 

#define Is_otg_device_mode_forced ( )    USBB_TST_BITS(USBCON,UIMOD)

Referenced by ISR().

#define Is_otg_host_mode_forced ( )    (!Is_otg_device_mode_forced())
#define Is_otg_id_device ( )    USBB_TST_BITS(USBSTA,ID)

Referenced by ISR(), and otg_dual_enable().

#define Is_otg_id_host ( )    (!Is_otg_id_device())

Referenced by uhd_enable().

#define Is_otg_id_interrupt_enabled ( )    USBB_TST_BITS(USBCON,IDTE)
#define Is_otg_id_transition ( )    USBB_TST_BITS(USBSTA,IDTI)

Referenced by ISR().

#define otg_ack_id_transition ( )    USBB_REG_CLR(USBSTA,IDTI)

Referenced by ISR(), and otg_dual_enable().

#define otg_data_memory_barrier ( )    (AVR32_USBB.uvers)

Instruction to access at a peripheral register after interrupt clear, see AVR32002 - AVR32UC Technical reference $6.6 Memory barriers.

Referenced by ISR().

#define otg_disable_id_interrupt ( )    USBB_CLR_BITS(USBCON,IDTE)

Referenced by otg_dual_disable().

#define otg_disable_id_pin ( )    USBB_CLR_BITS(USBCON,UIDE)

Referenced by uhd_enable().

#define otg_enable_id_interrupt ( )    USBB_SET_BITS(USBCON,IDTE)

Referenced by otg_dual_enable().

#define otg_enable_id_pin ( )    USBB_SET_BITS(USBCON,UIDE)
#define otg_force_device_mode ( )    USBB_SET_BITS(USBCON,UIMOD)
#define otg_force_host_mode ( )    USBB_CLR_BITS(USBCON,UIMOD)

Referenced by uhd_enable().

#define otg_get_dpram_size ( )    (128 << USBB_RD_BITFIELD(UFEATURES,FIFO_MAX_SIZE))

Get DPRAM size (FIFO maximal size) in bytes.

#define otg_get_ip_name ( )    (((uint64_t)AVR32_USBB.uname2<<32)|(uint64_t)AVR32_USBB.uname1)

Get IP name part 1 or 2.

#define otg_get_ip_paddress_size ( )    (AVR32_USBB.uaddrsize)

Get size of USBB PB address space.

#define otg_get_ip_version ( )    USBB_RD_BITFIELD(UVERS,VERSION_NUM)

Get IP version.

#define OTG_ID_FUNCTION   ATPASTE2(USB_ID, _FUNCTION)
#define OTG_ID_PIN   ATPASTE2(USB_ID, _PIN)

Pin and function for OTG_ID according to configuration from USB_ID.

#define otg_input_id_pin ( )
Value:
{\
(AVR32_GPIO.port[OTG_ID_PIN >> 5].pmr0s = 1 << (OTG_ID_PIN & 0x1F)) :\
(AVR32_GPIO.port[OTG_ID_PIN >> 5].pmr0c = 1 << (OTG_ID_PIN & 0x1F)); \
(AVR32_GPIO.port[OTG_ID_PIN >> 5].pmr1s = 1 << (OTG_ID_PIN & 0x1F)) :\
(AVR32_GPIO.port[OTG_ID_PIN >> 5].pmr1c = 1 << (OTG_ID_PIN & 0x1F)); \
AVR32_GPIO.port[OTG_ID_PIN >> 5].gperc = 1 << (OTG_ID_PIN & 0x1F);\
AVR32_GPIO.port[OTG_ID_PIN >> 5].puers = 1 << (OTG_ID_PIN & 0x1F); }
#define OTG_ID_PIN
Pin and function for OTG_ID according to configuration from USB_ID.
Definition: usbb_otg.h:113
#define OTG_ID_FUNCTION
Definition: usbb_otg.h:114
#define Tst_bits(value, mask)
Tests the bits of a value specified by a given bit-mask.
Definition: compiler.h:471

Input USB_ID from its pin.

Referenced by otg_dual_enable().

void otg_dual_disable ( void  )

Uninitialize the dual role This function is implemented in usbb_host.c file.

References otg_disable, otg_disable_id_interrupt, otg_disable_pad, otg_initialized, otg_unfreeze_clock, sysclk_disable_usb(), uhd_sleep_mode(), and UHD_STATE_OFF.

Referenced by uhd_disable().

bool otg_dual_enable ( void  )