Update board Dataflash_Init() functions to automatically configure the appropriate...
authorDean Camera <dean@fourwalledcubicle.com>
Wed, 12 Jun 2013 17:51:57 +0000 (19:51 +0200)
committerDean Camera <dean@fourwalledcubicle.com>
Wed, 12 Jun 2013 17:51:57 +0000 (19:51 +0200)
16 files changed:
Demos/Device/ClassDriver/MassStorage/MassStorage.c
Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.c
Demos/Device/ClassDriver/VirtualSerialMassStorage/VirtualSerialMassStorage.c
Demos/Device/LowLevel/MassStorage/MassStorage.c
LUFA/DoxygenPages/ChangeLog.txt
LUFA/DoxygenPages/MigrationInformation.txt
LUFA/Drivers/Board/AVR8/EVK527/Dataflash.h
LUFA/Drivers/Board/AVR8/STK525/Dataflash.h
LUFA/Drivers/Board/AVR8/STK526/Dataflash.h
LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h
LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h
LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h
LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Dataflash.h
LUFA/Drivers/Peripheral/XMEGA/SerialSPI_XMEGA.h
Projects/TempDataLogger/TempDataLogger.c
Projects/Webserver/Webserver.c

index a0fa7a2..82f02b9 100644 (file)
@@ -103,7 +103,6 @@ void SetupHardware(void)
 
        /* Hardware Initialization */
        LEDs_Init();
 
        /* Hardware Initialization */
        LEDs_Init();
-       SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
        Dataflash_Init();
        USB_Init();
 
        Dataflash_Init();
        USB_Init();
 
index 05fdfbe..2ed3f41 100644 (file)
@@ -129,7 +129,6 @@ void SetupHardware(void)
        LEDs_Init();
        Joystick_Init();
        Buttons_Init();
        LEDs_Init();
        Joystick_Init();
        Buttons_Init();
-       SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
        Dataflash_Init();
        USB_Init();
 
        Dataflash_Init();
        USB_Init();
 
index f1dc049..03f422b 100644 (file)
@@ -148,7 +148,6 @@ void SetupHardware(void)
        /* Hardware Initialization */
        LEDs_Init();
        Joystick_Init();
        /* Hardware Initialization */
        LEDs_Init();
        Joystick_Init();
-       SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
        Dataflash_Init();
        USB_Init();
 
        Dataflash_Init();
        USB_Init();
 
index cfb1686..fc66433 100644 (file)
@@ -88,7 +88,6 @@ void SetupHardware(void)
 
        /* Hardware Initialization */
        LEDs_Init();
 
        /* Hardware Initialization */
        LEDs_Init();
-       SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
        Dataflash_Init();
        USB_Init();
 
        Dataflash_Init();
        USB_Init();
 
index b5c8fe1..e218fe3 100644 (file)
@@ -24,6 +24,7 @@
   *   - Updated the Android Accessory Class to accept version 2 protocol devices (with version 1 functionality)
   *   - All board drivers now implement dummy functions and constants when BOARD is set to NONE
   *   - Added missing LEDs to the XMEGA A3BU Xplained board LED driver (thanks to Michael Janssen)
   *   - Updated the Android Accessory Class to accept version 2 protocol devices (with version 1 functionality)
   *   - All board drivers now implement dummy functions and constants when BOARD is set to NONE
   *   - Added missing LEDs to the XMEGA A3BU Xplained board LED driver (thanks to Michael Janssen)
+  *   - Changed board Dataflash drivers to automatically configure the appropriate SPI interface for the selected board
   *
   *  <b>Fixed:</b>
   *  - Core:
   *
   *  <b>Fixed:</b>
   *  - Core:
index 8643eb3..cbacbf0 100644 (file)
@@ -11,7 +11,8 @@
  *  areas relevant to making older projects compatible with the API changes of each new release.
  *
  *  \section Sec_MigrationXXXXXX Migrating from 130303 to XXXXXX
  *  areas relevant to making older projects compatible with the API changes of each new release.
  *
  *  \section Sec_MigrationXXXXXX Migrating from 130303 to XXXXXX
- *  There is no migration information for this version.
+ *  <b>Non-USB Library Components</b>
+ *    - The Board Dataflash \c Dataflash_Init() function now automatically configures the appropriate communication interface.
  *
  *  \section Sec_Migration130303 Migrating from 120730 to 130303
  *  <b>Device Mode</b>
  *
  *  \section Sec_Migration130303 Migrating from 120730 to 130303
  *  <b>Device Mode</b>
index ef04eba..a58a06c 100644 (file)
@@ -45,7 +45,7 @@
  *  <table>
  *    <tr><th>Name</th><th>Info</th><th>Select Pin</th><th>SPI Port</th></tr>
  *    <tr><td>DATAFLASH_CHIP1</td><td>AT45DB321C (4MB)</td><td>PORTE.6</td><td>SPI0</td></tr>
  *  <table>
  *    <tr><th>Name</th><th>Info</th><th>Select Pin</th><th>SPI Port</th></tr>
  *    <tr><td>DATAFLASH_CHIP1</td><td>AT45DB321C (4MB)</td><td>PORTE.6</td><td>SPI0</td></tr>
- *  </table> 
+ *  </table>
  *
  *  @{
  */
  *
  *  @{
  */
 
                /* Inline Functions: */
                        /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.
 
                /* 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_DDR  |= DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;
                         */
                        static inline void Dataflash_Init(void)
                        {
                                DATAFLASH_CHIPCS_DDR  |= DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;
+
+                               SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
index 608400c..b34907b 100644 (file)
 
                /* Inline Functions: */
                        /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.
 
                /* 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_DDR  |= DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;
                         */
                        static inline void Dataflash_Init(void)
                        {
                                DATAFLASH_CHIPCS_DDR  |= DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;
+
+                               SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
index f6e1124..511479f 100644 (file)
 
                /* Inline Functions: */
                        /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.
 
                /* 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_DDR  |= DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;
                         */
                        static inline void Dataflash_Init(void)
                        {
                                DATAFLASH_CHIPCS_DDR  |= DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;
+
+                               SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
index 14b94c5..648beb5 100644 (file)
 
                /* Inline Functions: */
                        /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.
 
                /* 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_DDR  |= DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;
                         */
                        static inline void Dataflash_Init(void)
                        {
                                DATAFLASH_CHIPCS_DDR  |= DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;
+
+                               SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
                                #if (DATAFLASH_TOTALCHIPS == 2)
                                        PageAddress >>= 1;
                                #endif
                                #if (DATAFLASH_TOTALCHIPS == 2)
                                        PageAddress >>= 1;
                                #endif
-                               
+
                                Dataflash_SendByte(PageAddress >> 5);
                                Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8));
                                Dataflash_SendByte(BufferByte);
                                Dataflash_SendByte(PageAddress >> 5);
                                Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8));
                                Dataflash_SendByte(BufferByte);
index b02cce6..d8bb12b 100644 (file)
@@ -71,7 +71,7 @@
 
        /* Includes: */
                #include "../../../../Common/Common.h"
 
        /* Includes: */
                #include "../../../../Common/Common.h"
-               
+
                #include "../../../Misc/AT45DB642D.h"
                #include "../../../Peripheral/SPI.h"
 
                #include "../../../Misc/AT45DB642D.h"
                #include "../../../Peripheral/SPI.h"
 
 
                /* Inline Functions: */
                        /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.
 
                /* 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_DDR  |= DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;
                         */
                        static inline void Dataflash_Init(void)
                        {
                                DATAFLASH_CHIPCS_DDR  |= DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;
+
+                               SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
index 143fbbf..7ba478c 100644 (file)
@@ -89,7 +89,7 @@
 
                /* Inline Functions: */
                        /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.
 
                /* 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)
                        {
                         */
                        static inline void Dataflash_Init(void)
                        {
 
                                PORTCFG.MPCMASK                = DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT.PIN0CTRL = PORT_INVEN_bm;
 
                                PORTCFG.MPCMASK                = DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT.PIN0CTRL = PORT_INVEN_bm;
+
+                               SerialSPI_Init(&USARTD0, (USART_SPI_SCK_LEAD_RISING | USART_SPI_SAMPLE_LEADING | USART_SPI_ORDER_MSB_FIRST), (F_CPU / 2));
+
+                               PORTD.DIRSET   = PIN3_bm | PIN1_bm;
+                               PORTD.DIRCLR   = PIN2_bm;
+                               PORTC.PIN2CTRL = PORT_OPC_PULLUP_gc;
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
index 28c79f1..3430e0c 100644 (file)
@@ -89,7 +89,7 @@
 
                /* Inline Functions: */
                        /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.
 
                /* 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)
                        {
                         */
                        static inline void Dataflash_Init(void)
                        {
                                PORTCFG.MPCMASK                = DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT.PIN0CTRL = PORT_INVEN_bm;
 
                                PORTCFG.MPCMASK                = DATAFLASH_CHIPCS_MASK;
                                DATAFLASH_CHIPCS_PORT.PIN0CTRL = PORT_INVEN_bm;
 
-                               PORTC.REMAP |= PORT_USART0_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.
                        }
 
                        /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
index 7f5226b..caae55a 100644 (file)
                        #define USART_SPI_SAMPLE_LEADING       0
 
                        /** SPI data sample mode mask for \ref SerialSPI_Init(). Indicates that the data should be sampled on the trailing edge. */
                        #define USART_SPI_SAMPLE_LEADING       0
 
                        /** SPI data sample mode mask for \ref SerialSPI_Init(). Indicates that the data should be sampled on the trailing edge. */
-                       #define USART_SPI_SAMPLE_TRAILING      USART_UPCHA_bm
+                       #define USART_SPI_SAMPLE_TRAILING      (1 << 1)
                        //@}
 
                        /** \name SPI Data Ordering Configuration Masks */
                        //@}
 
                        /** \name SPI Data Ordering Configuration Masks */
                        #define USART_SPI_ORDER_MSB_FIRST      0
 
                        /** SPI data order mask for \ref SerialSPI_Init(). Indicates that data should be shifted out LSB first. */
                        #define USART_SPI_ORDER_MSB_FIRST      0
 
                        /** SPI data order mask for \ref SerialSPI_Init(). Indicates that data should be shifted out LSB first. */
-                       #define USART_SPI_ORDER_LSB_FIRST      USART_UDORD_bm
+                       #define USART_SPI_ORDER_LSB_FIRST      (1 << 2)
                        //@}
 
                /* Inline Functions: */
                        //@}
 
                /* Inline Functions: */
index 7590aee..0c59bc8 100644 (file)
@@ -201,7 +201,6 @@ void SetupHardware(void)
 
        /* Hardware Initialization */
        LEDs_Init();
 
        /* Hardware Initialization */
        LEDs_Init();
-       SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
        ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128);
        Temperature_Init();
        Dataflash_Init();
        ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128);
        Temperature_Init();
        Dataflash_Init();
index 173b52e..b866d37 100644 (file)
@@ -70,7 +70,6 @@ void SetupHardware(void)
 #endif
 
        /* Hardware Initialization */
 #endif
 
        /* Hardware Initialization */
-       SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
        Dataflash_Init();
        LEDs_Init();
        USB_Init(USB_MODE_UID);
        Dataflash_Init();
        LEDs_Init();
        USB_Init(USB_MODE_UID);