From f7b9ebea02cf2a48fd4b287f6a445090ea433d52 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Wed, 12 Jun 2013 19:51:57 +0200 Subject: Update board Dataflash_Init() functions to automatically configure the appropriate communication interface. --- LUFA/Drivers/Board/AVR8/EVK527/Dataflash.h | 6 ++++-- LUFA/Drivers/Board/AVR8/STK525/Dataflash.h | 4 +++- LUFA/Drivers/Board/AVR8/STK526/Dataflash.h | 4 +++- LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h | 6 ++++-- LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h | 6 ++++-- LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h | 8 +++++++- LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Dataflash.h | 9 +++++++-- 7 files changed, 32 insertions(+), 11 deletions(-) (limited to 'LUFA/Drivers/Board') diff --git a/LUFA/Drivers/Board/AVR8/EVK527/Dataflash.h b/LUFA/Drivers/Board/AVR8/EVK527/Dataflash.h index ef04ebad6..a58a06c85 100644 --- a/LUFA/Drivers/Board/AVR8/EVK527/Dataflash.h +++ b/LUFA/Drivers/Board/AVR8/EVK527/Dataflash.h @@ -45,7 +45,7 @@ * * * - *
NameInfoSelect PinSPI Port
DATAFLASH_CHIP1AT45DB321C (4MB)PORTE.6SPI0
+ * * * @{ */ @@ -90,12 +90,14 @@ /* 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; + + 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. diff --git a/LUFA/Drivers/Board/AVR8/STK525/Dataflash.h b/LUFA/Drivers/Board/AVR8/STK525/Dataflash.h index 608400c8d..b34907b03 100644 --- a/LUFA/Drivers/Board/AVR8/STK525/Dataflash.h +++ b/LUFA/Drivers/Board/AVR8/STK525/Dataflash.h @@ -90,12 +90,14 @@ /* 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; + + 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. diff --git a/LUFA/Drivers/Board/AVR8/STK526/Dataflash.h b/LUFA/Drivers/Board/AVR8/STK526/Dataflash.h index f6e112417..511479f55 100644 --- a/LUFA/Drivers/Board/AVR8/STK526/Dataflash.h +++ b/LUFA/Drivers/Board/AVR8/STK526/Dataflash.h @@ -90,12 +90,14 @@ /* 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; + + 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. diff --git a/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h b/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h index 14b94c506..648beb557 100644 --- a/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h +++ b/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h @@ -94,12 +94,14 @@ /* 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; + + 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. @@ -223,7 +225,7 @@ #if (DATAFLASH_TOTALCHIPS == 2) PageAddress >>= 1; #endif - + Dataflash_SendByte(PageAddress >> 5); Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); Dataflash_SendByte(BufferByte); diff --git a/LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h b/LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h index b02cce698..d8bb12bda 100644 --- a/LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h +++ b/LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h @@ -71,7 +71,7 @@ /* Includes: */ #include "../../../../Common/Common.h" - + #include "../../../Misc/AT45DB642D.h" #include "../../../Peripheral/SPI.h" @@ -113,12 +113,14 @@ /* 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; + + 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. diff --git a/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h b/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h index 143fbbffc..7ba478ca4 100644 --- a/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h +++ b/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h @@ -89,7 +89,7 @@ /* 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) { @@ -97,6 +97,12 @@ 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. diff --git a/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Dataflash.h b/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Dataflash.h index 28c79f197..3430e0cbf 100644 --- a/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Dataflash.h +++ b/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Dataflash.h @@ -89,7 +89,7 @@ /* 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) { @@ -98,7 +98,12 @@ 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. -- cgit v1.2.3