apps/xplain-bc/main.c File Reference

Main source file for Xplain series board controller. More...

#include <led.h>
#include <gpio.h>
#include <board.h>
#include <debug.h>
#include <dmapool.h>
#include <mainloop.h>
#include <clk/sys.h>
#include <usb/dev_mux.h>
#include <usb/request.h>
#include <usb/udc.h>
#include "xplain-bc.h"
#include <spi.h>
#include <workqueue.h>

Go to the source code of this file.

Functions

static void app_usb_mode_worker (struct workqueue_task *task)
 Check USB mode switch input line and enable or disable the USB interface.
static void app_dataflash_ready (struct workqueue_task *task)
 Set SPI lines as input (slave mode) and release XMEGA reset line.
int main (void)
 Xplain board controller application.

Detailed Description

Main source file for Xplain series board controller.

Copyright (C) 2009 - 2010 Atmel Corporation. All rights reserved.

Definition in file main.c.


Function Documentation

static void app_dataflash_ready ( struct workqueue_task task  )  [static]

Set SPI lines as input (slave mode) and release XMEGA reset line.

This worker function will set the SPI lines in input mode (slave mode) and release the XMEGA reset line. Further it will switch to the main worker function app_usb_mode_worker and add that worker function to the queue.

Definition at line 130 of file main.c.

References app_usb_mode_worker(), board_gpio_mcu_reset(), board_gpio_set_spi_master_mode(), main_workqueue, workqueue_add_task(), and workqueue_task_set_work_func().

Referenced by main().

static void app_usb_mode_worker ( struct workqueue_task task  )  [static]

Check USB mode switch input line and enable or disable the USB interface.

This function will read the USB mode switch input line and disable or enable the USB interface as needed. If MSC is enabled and input line is high, MSC will be disabled and SPI lines set as input (slave mode). In addition the red LED will be deactivated to indicate MSC is no longer available. Finally the XMEGA chip is released from reset.

When MSC is not enabled and the USB mode switch line is low the worker function will set the SPI lines in output mode (master mode) and enable the USB interface. In addition the red LED will be actived to indicate MSC is available. Finally the XMEGA chip is held in reset to get synchronized access to the flash memory.

Todo:
Rewrite to use GPIO level change interrupt to trigger USB mode switching task.

Definition at line 73 of file main.c.

References board_gpio_is_usb_msc_mode(), board_gpio_mcu_reset(), board_gpio_set_spi_master_mode(), main_workqueue, OPERATION_IN_PROGRESS, udc_attach(), udc_detach(), and workqueue_add_task().

Referenced by app_dataflash_ready(), and main().

int main ( void   ) 

Xplain board controller application.

This application will enable or disable the USB mass-storage class (MSC) interface given an input on the USB mode switch input line. The main microcontroller on the Xplain board is held in reset while the board controller has the MSC interface enabled to ensure synchronouse access.

Definition at line 148 of file main.c.

References app_dataflash_ready(), app_usb_mode_worker(), board_gpio_is_usb_msc_mode(), buffer_pool_init(), cpu_irq_enable, dataflash_init(), dbg_info, dbg_panic, main_workqueue, mainloop_run(), sysclk_init(), udc_init(), usb_init(), workqueue_init(), workqueue_task_init(), and workqueue_task_set_work_func().

Generated on Thu Apr 29 14:10:34 2010 for xplain-bc by  doxygen 1.6.3