CCID: Add support for PC-to-Reader XfrBlock message
[pub/USBasp.git] / LUFA / Drivers / Board / XMEGA / B1_XPLAINED / Dataflash.h
index 7a9c03e..aefa0d6 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2013.
+     Copyright (C) Dean Camera, 2018.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2013  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2018  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
 */
 
 /** \file
- *  \brief Board specific Dataflash driver header for the Atmel XMEGA A3BU Xplained.
- *  \copydetails Group_Dataflash_A3BU_XPLAINED
+ *  \brief Board specific Dataflash driver header for the Atmel XMEGA B1 Xplained.
+ *  \copydetails Group_Dataflash_B1_XPLAINED
  *
  *  \note This file should not be included directly. It is automatically included as needed by the dataflash driver
  *        dispatch header located in LUFA/Drivers/Board/Dataflash.h.
  */
 
 /** \ingroup Group_Dataflash
- *  \defgroup Group_Dataflash_A3BU_XPLAINED A3BU_XPLAINED
- *  \brief Board specific Dataflash driver header for the Atmel XMEGA A3BU Xplained.
+ *  \defgroup Group_Dataflash_B1_XPLAINED B1_XPLAINED
+ *  \brief Board specific Dataflash driver header for the Atmel XMEGA B1 Xplained.
  *
- *  Board specific Dataflash driver header for the Atmel XMEGA A3BU Xplained board.
+ *  Board specific Dataflash driver header for the Atmel XMEGA B1 Xplained board.
  *
  *  <table>
  *    <tr><th>Name</th><th>Info</th><th>Select Pin</th><th>SPI Port</th></tr>
  *    <tr><td>DATAFLASH_CHIP1</td><td>AT45DB642D (8MB)</td><td>PORTD.2</td><td>USARTC0 (In SPI Mode, Remapped)</td></tr>
- *  </table> 
+ *  </table>
  *
  *  @{
  */
 
-#ifndef __DATAFLASH_A3BU_XPLAINED_H__
-#define __DATAFLASH_A3BU_XPLAINED_H__
+#ifndef __DATAFLASH_B1_XPLAINED_H__
+#define __DATAFLASH_B1_XPLAINED_H__
 
        /* Includes: */
                #include "../../../../Common/Common.h"
 
                /* Inline Functions: */
                        /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.
-                        *  The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used.
+                        *  The appropriate SPI interface will be automatically configured.
                         */
                        static inline void Dataflash_Init(void)
                        {
                                DATAFLASH_CHIPCS_PORT.DIRSET   = DATAFLASH_CHIPCS_MASK;
-                               
+
                                PORTCFG.MPCMASK                = DATAFLASH_CHIPCS_MASK;
-                               DATAFLASH_CHIPCS_PORT.PIN0CTRL = PORT_INVEN_bm; 
-                               
-                               PORTC.REMAP |= PORT_USART0_bm;
+                               DATAFLASH_CHIPCS_PORT.PIN0CTRL = PORT_INVEN_bm;
+
+                               SerialSPI_Init(&USARTC0, (USART_SPI_SCK_LEAD_RISING | USART_SPI_SAMPLE_LEADING | USART_SPI_ORDER_MSB_FIRST), (F_CPU / 2));
+
+                               PORTC.REMAP   |= PORT_USART0_bm;
+                               PORTC.DIRSET   = PIN7_bm | PIN5_bm;
+                               PORTC.DIRCLR   = PIN6_bm;
+                               PORTC.PIN6CTRL = PORT_OPC_PULLUP_gc;
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.