Update board Dataflash_Init() functions to automatically configure the appropriate communication interface.
This commit is contained in:
		
							parent
							
								
									6d58628e85
								
							
						
					
					
						commit
						f7b9ebea02
					
				
					 16 changed files with 37 additions and 20 deletions
				
			
		| 
						 | 
				
			
			@ -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> 
 | 
			
		||||
 *  </table>
 | 
			
		||||
 *
 | 
			
		||||
 *  @{
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue