PN532 Updates
authorKevin Townsend <kevin@ktownsend.com>
Thu, 16 Feb 2012 11:57:36 +0000 (12:57 +0100)
committerKevin Townsend <kevin@ktownsend.com>
Thu, 16 Feb 2012 11:57:36 +0000 (12:57 +0100)
build/codelite/LPC1343 Workspace.workspace.session
build/crossworks/LPC1343_CodeBase.hzp
build/crossworks/LPC1343_CodeBase.hzs
drivers/sensors/pn532/pn532_bus.h
drivers/sensors/pn532/pn532_bus_i2c.c
tools/examples/sensors/pn532/ISO14443A_ID/main.c

index a989bd8..07cea37 100644 (file)
@@ -1,24 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Session Name="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\build\codelite\LPC1343 Workspace.workspace">
-  <int Value="1" Name="m_selectedTab"/>
+  <int Value="2" Name="m_selectedTab"/>
   <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\build\codelite\LPC1343 Workspace.workspace" Name="m_workspaceName"/>
   <TabInfoArray Name="TabInfoArray">
     <TabInfo>
       <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\Makefile" Name="FileName"/>
-      <int Value="55" Name="FirstVisibleLine"/>
+      <int Value="42" Name="FirstVisibleLine"/>
       <int Value="60" Name="CurrentLine"/>
       <wxArrayString Name="Bookmarks"/>
     </TabInfo>
     <TabInfo>
-      <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" Name="FileName"/>
-      <int Value="0" Name="FirstVisibleLine"/>
-      <int Value="14" Name="CurrentLine"/>
+      <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\projectconfig.h" Name="FileName"/>
+      <int Value="9" Name="FirstVisibleLine"/>
+      <int Value="27" Name="CurrentLine"/>
       <wxArrayString Name="Bookmarks"/>
     </TabInfo>
     <TabInfo>
-      <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\projectconfig.h" Name="FileName"/>
-      <int Value="0" Name="FirstVisibleLine"/>
-      <int Value="27" Name="CurrentLine"/>
+      <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" Name="FileName"/>
+      <int Value="1" Name="FirstVisibleLine"/>
+      <int Value="35" Name="CurrentLine"/>
       <wxArrayString Name="Bookmarks"/>
     </TabInfo>
   </TabInfoArray>
index d7f6d5d..c5861e1 100644 (file)
             <file file_name="../../drivers/sensors/pn532/pn532_bus_i2c.c">
               <configuration Name="THUMB Flash Debug" build_exclude_from_build="No"/>
             </file>
+            <file file_name="../../drivers/sensors/pn532/pn532_bus.h"/>
           </folder>
           <folder Name="tsl2561">
             <file file_name="../../drivers/sensors/tsl2561/tsl2561.c">
index e894c45..5b3c975 100644 (file)
@@ -36,8 +36,6 @@
   <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers" name="unnamed" />
   <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;sensors" name="unnamed" />
   <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;sensors;pn532" name="unnamed" />
-  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;sensors;pn532;helpers" name="unnamed" />
-  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;System Files" name="unnamed" />
  </Project>
  <Register1>
   <RegisterWindow openNodes="USB;USB/USBRxPLen;USB/USBTxPLen;USB/USBCtrl" binaryNodes="" hiddenNodes="" unsignedNodes="" visibleGroups="CPU;USB" decimalNodes="" octalNodes="" asciiNodes="" />
  </TraceWindow>
  <Watch1>
   <Watches active="1" update="Each Second" >
-   <Watchpoint linenumber="155" radix="16" name="Tick" expression="Tick" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/freertos/tasks.c" />
-   <Watchpoint linenumber="155" radix="-1" name="xTickCount" expression="xTickCount" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/freertos/tasks.c" />
-   <Watchpoint linenumber="138" radix="16" name="timer32_0_counter" expression="timer32_0_counter" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/core/timer32/timer32.c" />
    <Watchpoint linenumber="66" radix="10" name="msTicks" expression="msTicks" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/core/systick/systick.c" />
+   <Watchpoint linenumber="138" radix="16" name="timer32_0_counter" expression="timer32_0_counter" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/core/timer32/timer32.c" />
+   <Watchpoint linenumber="155" radix="-1" name="xTickCount" expression="xTickCount" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/freertos/tasks.c" />
+   <Watchpoint linenumber="155" radix="16" name="Tick" expression="Tick" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/freertos/tasks.c" />
   </Watches>
  </Watch1>
  <Watch2>
@@ -73,7 +71,7 @@
   <Watches active="0" update="Never" />
  </Watch4>
  <Files>
-  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" y="48" path="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" left="0" selected="1" name="unnamed" top="33" />
+  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="72" debugPath="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" y="16" path="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" left="0" selected="1" name="unnamed" top="0" />
  </Files>
- <ARMCrossStudioWindow activeProject="LPC1343_CodeBase" autoConnectTarget="Segger J-Link" debugSearchFileMap="" fileDialogInitialDirectory="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\drivers\sensors\pn532" fileDialogDefaultFilter="*.c" autoConnectCapabilities="388991" debugSearchPath="" buildConfiguration="THUMB Flash Debug" />
+ <ARMCrossStudioWindow activeProject="LPC1343_CodeBase" autoConnectTarget="Segger J-Link" debugSearchFileMap="" fileDialogInitialDirectory="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\drivers\sensors\pn532" fileDialogDefaultFilter="" autoConnectCapabilities="388991" debugSearchPath="" buildConfiguration="THUMB Flash Release" />
 </session>
index 74796f0..9a509b9 100644 (file)
@@ -34,7 +34,6 @@
 void          pn532_bus_HWInit(void);
 pn532_error_t pn532_bus_SendCommand(const byte_t * pbtData, const size_t szData);
 pn532_error_t pn532_bus_ReadResponse(byte_t * pbtResponse, size_t * pszRxLen);
-bool          pn532_bus_TransceiveBytes(const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx);
 pn532_error_t pn532_bus_Wakeup(void);
 
 #endif
index 1f73624..bbcff7c 100644 (file)
@@ -1,8 +1,36 @@
 /**************************************************************************/
 /*! 
-    @file      pn532_bus_i2c.c
-    @author    Kevin Townsend
-    @copyright Kevin Townsend 2012
+    @file     pn532_bus_i2c.c
+    @author   K. Townsend (microBuilder.eu)
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2012, microBuilder SARL
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 /**************************************************************************/
 #include <string.h>
@@ -20,6 +48,10 @@ extern volatile uint8_t   I2CMasterBuffer[I2C_BUFSIZE];
 extern volatile uint8_t   I2CSlaveBuffer[I2C_BUFSIZE];
 extern volatile uint32_t  I2CReadLength, I2CWriteLength;
 
+/* ======================================================================
+   PRIVATE FUNCTIONS                                                      
+   ====================================================================== */
+
 /**************************************************************************/
 /*! 
     @brief  Writes an 8 bit value over I2C
@@ -114,7 +146,7 @@ uint8_t pn532_bus_i2c_WaitForReady(void)
             - PN532_ERROR_EXTENDEDFRAME
 */
 /**************************************************************************/
-pn532_error_t pn532_bus_BuildFrame(byte_t * pbtFrame, size_t * pszFrame, const byte_t * pbtData, const size_t szData)
+pn532_error_t pn532_bus_i2c_BuildFrame(byte_t * pbtFrame, size_t * pszFrame, const byte_t * pbtData, const size_t szData)
 {
   if (szData > PN532_NORMAL_FRAME__DATA_MAX_LEN) 
   {
@@ -148,6 +180,10 @@ pn532_error_t pn532_bus_BuildFrame(byte_t * pbtFrame, size_t * pszFrame, const b
   return PN532_ERROR_NONE;
 }
 
+/* ======================================================================
+   PUBLIC FUNCTIONS                                                      
+   ====================================================================== */
+
 /**************************************************************************/
 /*! 
     @brief  Initialises I2C and configures the PN532 HW
@@ -214,7 +250,7 @@ pn532_error_t pn532_bus_SendCommand(const byte_t * pbtData, const size_t szData)
   size_t szFrame = 0;
 
   // Build the frame
-  pn532_bus_BuildFrame (abtFrame, &szFrame, pbtData, szData);
+  pn532_bus_i2c_BuildFrame (abtFrame, &szFrame, pbtData, szData);
 
   // Keep track of the last command that was sent
   pn532->lastCommand = pbtData[0];
@@ -268,7 +304,11 @@ pn532_error_t pn532_bus_SendCommand(const byte_t * pbtData, const size_t szData)
   // Make sure the received ACK matches the prototype
   const byte_t abtAck[6] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 };
   byte_t abtRxBuf[6];
-  memcpy(abtRxBuf, I2CSlaveBuffer+1, 6);
+  // memcpy(abtRxBuf, I2CSlaveBuffer+1, 6);
+  for ( i = 0; i < 6; i++ )
+  {
+    abtRxBuf[i] = I2CSlaveBuffer[i+1];
+  }
   if (0 != (memcmp (abtRxBuf, abtAck, 6))) 
   {
     #ifdef PN532_DEBUGMODE
@@ -346,7 +386,11 @@ pn532_error_t pn532_bus_ReadResponse(byte_t * pbtResponse, size_t * pszRxLen)
   *pszRxLen = I2C_BUFSIZE - 1;
 
   // Fill the response buffer from I2C (skipping the leading 'ready' bit when using I2C)
-  memcpy(pbtResponse, I2CSlaveBuffer+1, I2C_BUFSIZE-1);
+  // memcpy(pbtResponse, I2CSlaveBuffer+1, I2C_BUFSIZE-1);
+  for ( i = 0; i < I2C_BUFSIZE-1; i++ )
+  {
+    pbtResponse[i] = I2CSlaveBuffer[i+1];
+  }
 
   // Check the frame type
   if ((0x01 == pbtResponse[3]) && (0xff == pbtResponse[4])) 
index 511a554..551b3ab 100644 (file)
@@ -139,6 +139,9 @@ int main (void)
         case (PN532_ERROR_LENCHECKSUMMISMATCH):          
           printf("Frame length check/checksum mismatch%s", CFG_PRINTF_NEWLINE);
           break;
+        default:
+          // Other errors handled below
+          break;
       }
   
       // Print the card details if possible
This page took 0.039681 seconds and 4 git commands to generate.