Commit b462f2d4 authored by Dean Camera's avatar Dean Camera
Browse files

Minor correction to MagStripe demo to fix build problems.

parent 86e6ed7f
...@@ -53,16 +53,17 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, co ...@@ -53,16 +53,17 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, co
uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4); uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4);
bool UsingSecondBuffer = false; bool UsingSecondBuffer = false;
/* Copy selected dataflash's current page contents to the dataflash buffer */ /* Select the correct starting Dataflash IC for the block requested */
Dataflash_SelectChipFromPage(CurrDFPage); Dataflash_SelectChipFromPage(CurrDFPage);
#if (DATAFLASH_PAGE_SIZE > VIRTUAL_MEMORY_BLOCK_SIZE) #if (DATAFLASH_PAGE_SIZE > VIRTUAL_MEMORY_BLOCK_SIZE)
/* Copy selected dataflash's current page contents to the dataflash buffer */
Dataflash_SendByte(DF_CMD_MAINMEMTOBUFF1); Dataflash_SendByte(DF_CMD_MAINMEMTOBUFF1);
Dataflash_SendAddressBytes(CurrDFPage, 0); Dataflash_SendAddressBytes(CurrDFPage, 0);
#endif
Dataflash_WaitWhileBusy(); Dataflash_WaitWhileBusy();
#endif
/* Send the dataflash buffer write command */ /* Send the dataflash buffer write command */
Dataflash_ToggleSelectedChipCS();
Dataflash_SendByte(DF_CMD_BUFF1WRITE); Dataflash_SendByte(DF_CMD_BUFF1WRITE);
Dataflash_SendAddressBytes(0, CurrDFPageByte); Dataflash_SendAddressBytes(0, CurrDFPageByte);
...@@ -182,8 +183,10 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, con ...@@ -182,8 +183,10 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, con
uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE); uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE);
uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4); uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4);
/* Send the dataflash main memory page read command */ /* Select the correct starting Dataflash IC for the block requested */
Dataflash_SelectChipFromPage(CurrDFPage); Dataflash_SelectChipFromPage(CurrDFPage);
/* Send the dataflash main memory page read command */
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD); Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
Dataflash_SendAddressBytes(CurrDFPage, CurrDFPageByte); Dataflash_SendAddressBytes(CurrDFPage, CurrDFPageByte);
Dataflash_SendByte(0x00); Dataflash_SendByte(0x00);
...@@ -287,19 +290,20 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress, uint16_t Tota ...@@ -287,19 +290,20 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress, uint16_t Tota
uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4); uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4);
bool UsingSecondBuffer = false; bool UsingSecondBuffer = false;
/* Copy selected dataflash's current page contents to the dataflash buffer */ /* Select the correct starting Dataflash IC for the block requested */
Dataflash_SelectChipFromPage(CurrDFPage); Dataflash_SelectChipFromPage(CurrDFPage);
#if (DATAFLASH_PAGE_SIZE > VIRTUAL_MEMORY_BLOCK_SIZE) #if (DATAFLASH_PAGE_SIZE > VIRTUAL_MEMORY_BLOCK_SIZE)
/* Copy selected dataflash's current page contents to the dataflash buffer */
Dataflash_SendByte(DF_CMD_MAINMEMTOBUFF1); Dataflash_SendByte(DF_CMD_MAINMEMTOBUFF1);
Dataflash_SendAddressBytes(CurrDFPage, 0); Dataflash_SendAddressBytes(CurrDFPage, 0);
#endif
Dataflash_WaitWhileBusy(); Dataflash_WaitWhileBusy();
#endif
/* Send the dataflash buffer write command */ /* Send the dataflash buffer write command */
Dataflash_ToggleSelectedChipCS();
Dataflash_SendByte(DF_CMD_BUFF1WRITE); Dataflash_SendByte(DF_CMD_BUFF1WRITE);
Dataflash_SendAddressBytes(0, CurrDFPageByte); Dataflash_SendAddressBytes(0, CurrDFPageByte);
while (TotalBlocks) while (TotalBlocks)
{ {
uint8_t BytesInBlockDiv16 = 0; uint8_t BytesInBlockDiv16 = 0;
...@@ -384,8 +388,10 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress, uint16_t Total ...@@ -384,8 +388,10 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress, uint16_t Total
uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE); uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE);
uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4); uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4);
/* Send the dataflash main memory page read command */ /* Select the correct starting Dataflash IC for the block requested */
Dataflash_SelectChipFromPage(CurrDFPage); Dataflash_SelectChipFromPage(CurrDFPage);
/* Send the dataflash main memory page read command */
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD); Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
Dataflash_SendAddressBytes(CurrDFPage, CurrDFPageByte); Dataflash_SendAddressBytes(CurrDFPage, CurrDFPageByte);
Dataflash_SendByte(0x00); Dataflash_SendByte(0x00);
......
...@@ -53,16 +53,17 @@ void DataflashManager_WriteBlocks(const uint32_t BlockAddress, uint16_t TotalBlo ...@@ -53,16 +53,17 @@ void DataflashManager_WriteBlocks(const uint32_t BlockAddress, uint16_t TotalBlo
uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4); uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4);
bool UsingSecondBuffer = false; bool UsingSecondBuffer = false;
/* Copy selected dataflash's current page contents to the dataflash buffer */ /* Select the correct starting Dataflash IC for the block requested */
Dataflash_SelectChipFromPage(CurrDFPage); Dataflash_SelectChipFromPage(CurrDFPage);
#if (DATAFLASH_PAGE_SIZE > VIRTUAL_MEMORY_BLOCK_SIZE) #if (DATAFLASH_PAGE_SIZE > VIRTUAL_MEMORY_BLOCK_SIZE)
/* Copy selected dataflash's current page contents to the dataflash buffer */
Dataflash_SendByte(DF_CMD_MAINMEMTOBUFF1); Dataflash_SendByte(DF_CMD_MAINMEMTOBUFF1);
Dataflash_SendAddressBytes(CurrDFPage, 0); Dataflash_SendAddressBytes(CurrDFPage, 0);
#endif
Dataflash_WaitWhileBusy(); Dataflash_WaitWhileBusy();
#endif
/* Send the dataflash buffer write command */ /* Send the dataflash buffer write command */
Dataflash_ToggleSelectedChipCS();
Dataflash_SendByte(DF_CMD_BUFF1WRITE); Dataflash_SendByte(DF_CMD_BUFF1WRITE);
Dataflash_SendAddressBytes(0, CurrDFPageByte); Dataflash_SendAddressBytes(0, CurrDFPageByte);
...@@ -182,8 +183,10 @@ void DataflashManager_ReadBlocks(const uint32_t BlockAddress, uint16_t TotalBloc ...@@ -182,8 +183,10 @@ void DataflashManager_ReadBlocks(const uint32_t BlockAddress, uint16_t TotalBloc
uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE); uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE);
uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4); uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4);
/* Send the dataflash main memory page read command */ /* Select the correct starting Dataflash IC for the block requested */
Dataflash_SelectChipFromPage(CurrDFPage); Dataflash_SelectChipFromPage(CurrDFPage);
/* Send the dataflash main memory page read command */
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD); Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
Dataflash_SendAddressBytes(CurrDFPage, CurrDFPageByte); Dataflash_SendAddressBytes(CurrDFPage, CurrDFPageByte);
Dataflash_SendByte(0x00); Dataflash_SendByte(0x00);
...@@ -287,16 +290,17 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress, uint16_t Tota ...@@ -287,16 +290,17 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress, uint16_t Tota
uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4); uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4);
bool UsingSecondBuffer = false; bool UsingSecondBuffer = false;
/* Copy selected dataflash's current page contents to the dataflash buffer */ /* Select the correct starting Dataflash IC for the block requested */
Dataflash_SelectChipFromPage(CurrDFPage); Dataflash_SelectChipFromPage(CurrDFPage);
#if (DATAFLASH_PAGE_SIZE > VIRTUAL_MEMORY_BLOCK_SIZE) #if (DATAFLASH_PAGE_SIZE > VIRTUAL_MEMORY_BLOCK_SIZE)
/* Copy selected dataflash's current page contents to the dataflash buffer */
Dataflash_SendByte(DF_CMD_MAINMEMTOBUFF1); Dataflash_SendByte(DF_CMD_MAINMEMTOBUFF1);
Dataflash_SendAddressBytes(CurrDFPage, 0); Dataflash_SendAddressBytes(CurrDFPage, 0);
#endif
Dataflash_WaitWhileBusy(); Dataflash_WaitWhileBusy();
#endif
/* Send the dataflash buffer write command */ /* Send the dataflash buffer write command */
Dataflash_ToggleSelectedChipCS();
Dataflash_SendByte(DF_CMD_BUFF1WRITE); Dataflash_SendByte(DF_CMD_BUFF1WRITE);
Dataflash_SendAddressBytes(0, CurrDFPageByte); Dataflash_SendAddressBytes(0, CurrDFPageByte);
...@@ -384,8 +388,10 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress, uint16_t Total ...@@ -384,8 +388,10 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress, uint16_t Total
uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE); uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE);
uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4); uint8_t CurrDFPageByteDiv16 = (CurrDFPageByte >> 4);
/* Send the dataflash main memory page read command */ /* Select the correct starting Dataflash IC for the block requested */
Dataflash_SelectChipFromPage(CurrDFPage); Dataflash_SelectChipFromPage(CurrDFPage);
/* Send the dataflash main memory page read command */
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD); Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
Dataflash_SendAddressBytes(CurrDFPage, CurrDFPageByte); Dataflash_SendAddressBytes(CurrDFPage, CurrDFPageByte);
Dataflash_SendByte(0x00); Dataflash_SendByte(0x00);
......
...@@ -166,14 +166,14 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) ...@@ -166,14 +166,14 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
* *
* \return Number of bytes in the created report * \return Number of bytes in the created report
*/ */
uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData) uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID, void* ReportData)
{ {
static bool IsKeyReleaseReport; static bool IsKeyReleaseReport;
static bool IsNewlineReport; static bool IsNewlineReport;
BitBuffer_t* Buffer = NULL; BitBuffer_t* Buffer = NULL;
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData; USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;
/* Key reports must be interleaved with 0 Key Code reports to release the keys, or repeated keys will be ignored */ /* Key reports must be interleaved with 0 Key Code reports to release the keys, or repeated keys will be ignored */
IsKeyReleaseReport = !IsKeyReleaseReport; IsKeyReleaseReport = !IsKeyReleaseReport;
...@@ -214,8 +214,8 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInte ...@@ -214,8 +214,8 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInte
* \param[in] ReportData Pointer to the report buffer where the received report is stored * \param[in] ReportData Pointer to the report buffer where the received report is stored
* \param[in] ReportSize Size in bytes of the report received from the host * \param[in] ReportSize Size in bytes of the report received from the host
*/ */
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t ReportID, void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID,
void* ReportData, uint16_t ReportSize) const void* ReportData, const uint16_t ReportSize)
{ {
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports // Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
} }
...@@ -79,9 +79,9 @@ ...@@ -79,9 +79,9 @@
void EVENT_USB_ConfigurationChanged(void); void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void); void EVENT_USB_UnhandledControlPacket(void);
uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID, uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,
void* ReportData); void* ReportData);
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t ReportID, void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID,
void* ReportData, uint16_t ReportSize); const void* ReportData, const uint16_t ReportSize);
#endif #endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment