projects
/
pub
/
USBasp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Mark build test makefiles as being incompatible with parallel make builds, as they...
[pub/USBasp.git]
/
LUFA
/
Drivers
/
Board
/
XMEGA
/
A3BU_XPLAINED
/
Dataflash.h
diff --git
a/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h
b/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h
index
e43dce7
..
672d4eb
100644
(file)
--- a/
LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h
+++ b/
LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h
@@
-7,7
+7,7
@@
*/
/*
*/
/*
- Copyright 201
1
Dean Camera (dean [at] fourwalledcubicle [dot] com)
+ Copyright 201
2
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
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
@@
-29,28
+29,34
@@
*/
/** \file
*/
/** \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
*
* \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>PORTF.4</td><td>USARTD0 (In SPI Mode)</td></tr>
+ * </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"
#include "../../../Misc/AT45DB642D.h"
/* Includes: */
#include "../../../../Common/Common.h"
#include "../../../Misc/AT45DB642D.h"
+ #include "../../../Peripheral/SerialSPI.h"
/* Preprocessor Checks: */
#if !defined(__INCLUDE_FROM_DATAFLASH_H)
/* Preprocessor Checks: */
#if !defined(__INCLUDE_FROM_DATAFLASH_H)
@@
-70,10
+76,10
@@
#define DATAFLASH_TOTALCHIPS 1
/** Mask for no dataflash chip selected. */
#define DATAFLASH_TOTALCHIPS 1
/** Mask for no dataflash chip selected. */
- #define DATAFLASH_NO_CHIP
DATAFLASH_CHIPCS_MASK
+ #define DATAFLASH_NO_CHIP
0
/** Mask for the first dataflash chip selected. */
/** Mask for the first dataflash chip selected. */
- #define DATAFLASH_CHIP1
0
+ #define DATAFLASH_CHIP1
(1 << 4)
/** Internal main memory page size for the board's dataflash ICs. */
#define DATAFLASH_PAGE_SIZE 1024
/** Internal main memory page size for the board's dataflash ICs. */
#define DATAFLASH_PAGE_SIZE 1024
@@
-87,31
+93,32
@@
*/
static inline void Dataflash_Init(void)
{
*/
static inline void Dataflash_Init(void)
{
- DATAFLASH_CHIPCS_PORT.DIRSET = DATAFLASH_CHIPCS_MASK;
- DATAFLASH_CHIPCS_PORT.OUTSET = DATAFLASH_CHIPCS_MASK;
+ DATAFLASH_CHIPCS_PORT.DIRSET = DATAFLASH_CHIPCS_MASK;
+
+ PORTCFG.MPCMASK = DATAFLASH_CHIPCS_MASK;
+ DATAFLASH_CHIPCS_PORT.PIN0CTRL = PORT_INVEN_bm;
}
/** 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.
*
- * \param[in] Byte of data to send to the dataflash
+ * \param[in] Byte
Byte
of data to send to the dataflash
*
* \return Last response byte from the dataflash
*/
static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)
{
*
* \return Last response byte from the dataflash
*/
static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)
{
- // TODO
- return 0;
+ return SerialSPI_TransferByte(&USARTD0, Byte);
}
/** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.
*
}
/** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.
*
- * \param[in] Byte of data to send to the dataflash
+ * \param[in] Byte
Byte
of data to send to the dataflash
*/
static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
static inline void Dataflash_SendByte(const uint8_t Byte)
{
*/
static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
static inline void Dataflash_SendByte(const uint8_t Byte)
{
- // TODO
+ SerialSPI_SendByte(&USARTD0, Byte);
}
/** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.
}
/** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.
@@
-121,8
+128,7
@@
static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Dataflash_ReceiveByte(void)
{
static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Dataflash_ReceiveByte(void)
{
- // TODO
- return 0;
+ return SerialSPI_ReceiveByte(&USARTD0);
}
/** Determines the currently selected dataflash chip.
}
/** Determines the currently selected dataflash chip.
@@
-144,7
+150,8
@@
static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;
static inline void Dataflash_SelectChip(const uint8_t ChipMask)
{
static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;
static inline void Dataflash_SelectChip(const uint8_t ChipMask)
{
- DATAFLASH_CHIPCS_PORT.OUT = ((DATAFLASH_CHIPCS_PORT.OUT & ~DATAFLASH_CHIPCS_MASK) | ChipMask);
+ DATAFLASH_CHIPCS_PORT.OUTCLR = DATAFLASH_CHIPCS_MASK;
+ DATAFLASH_CHIPCS_PORT.OUTSET = ChipMask;
}
/** Deselects the current dataflash chip, so that no dataflash is selected. */
}
/** Deselects the current dataflash chip, so that no dataflash is selected. */
@@
-170,10
+177,7
@@
if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS))
return;
if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS))
return;
- if (PageAddress & 0x01)
- Dataflash_SelectChip(DATAFLASH_CHIP2);
- else
- Dataflash_SelectChip(DATAFLASH_CHIP1);
+ Dataflash_SelectChip(DATAFLASH_CHIP1);
}
/** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive
}
/** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive
@@
-207,8
+211,6
@@
static inline void Dataflash_SendAddressBytes(uint16_t PageAddress,
const uint16_t BufferByte)
{
static inline void Dataflash_SendAddressBytes(uint16_t PageAddress,
const uint16_t BufferByte)
{
- PageAddress >>= 1;
-
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);