PN532 updates
authorKevin Townsend <kevin@ktownsend.com>
Thu, 16 Feb 2012 10:22:43 +0000 (11:22 +0100)
committerKevin Townsend <kevin@ktownsend.com>
Thu, 16 Feb 2012 10:22:43 +0000 (11:22 +0100)
13 files changed:
ChangeLog.txt
Makefile
build/codelite/LPC1343 Workspace.workspace.session
build/codelite/LPC1343_CodeBase.project
build/crossworks/LPC1343_CodeBase.hzp
build/crossworks/LPC1343_CodeBase.hzs
core/i2c/i2c.c
core/i2c/i2c.h
drivers/sensors/pn532/helpers/pn532_mifare.h
drivers/sensors/pn532/helpers/pn532_mifare_classic.c
drivers/sensors/pn532/helpers/pn532_mifare_ultralight.c
drivers/sensors/pn532/pn532_bus_i2c.c
projectconfig.h

index 52bd28a..ecf050d 100644 (file)
@@ -1,5 +1,8 @@
 v0.9.8 - Ongoing
 ================
+- Added I2C driver for PN532
+- Updated and added PN532 examples at
+  /tools/examples/sensors/PN532
 - updated touchscreen.h to be a bit clearer during
   calibration, though it can still be much better
   organised
index 12f36ce..14e1c26 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -100,8 +100,9 @@ VPATH += drivers/dac/mcp4725
 OBJS += mcp4725.o
 
 # RFID/NFC
-VPATH += drivers/sensors/pn532
-OBJS += pn532.o 
+VPATH += drivers/sensors/pn532 drivers/sensors/pn532/helpers
+OBJS += pn532.o pn532_bus_i2c.o pn532_bus_uart.o
+OBJS += pn532_mifare_classic.o pn532_mifare_ultralight.o
 
 # TAOS Light Sensors
 VPATH += drivers/sensors/tcs3414 drivers/sensors/tsl2561
index 89b677c..a989bd8 100644 (file)
@@ -3,16 +3,22 @@
   <int Value="1" 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="60" Name="CurrentLine"/>
+      <wxArrayString Name="Bookmarks"/>
+    </TabInfo>
     <TabInfo>
       <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" Name="FileName"/>
-      <int Value="46" Name="FirstVisibleLine"/>
-      <int Value="19" Name="CurrentLine"/>
+      <int Value="0" Name="FirstVisibleLine"/>
+      <int Value="14" Name="CurrentLine"/>
       <wxArrayString Name="Bookmarks"/>
     </TabInfo>
     <TabInfo>
       <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\projectconfig.h" Name="FileName"/>
-      <int Value="18" Name="FirstVisibleLine"/>
-      <int Value="36" Name="CurrentLine"/>
+      <int Value="0" Name="FirstVisibleLine"/>
+      <int Value="27" Name="CurrentLine"/>
       <wxArrayString Name="Bookmarks"/>
     </TabInfo>
   </TabInfoArray>
index 54c13ef..1b12a41 100644 (file)
       <VirtualDirectory Name="pn532">
         <File Name="../../drivers/sensors/pn532/pn532.c"/>
         <File Name="../../drivers/sensors/pn532/pn532.h"/>
-        <File Name="../../drivers/sensors/pn532/pn532_drvr.h"/>
-        <File Name="../../drivers/sensors/pn532/pn532_drvr_uart.c"/>
+        <VirtualDirectory Name="helpers">
+          <File Name="../../drivers/sensors/pn532/helpers/pn532_mifare.h"/>
+          <File Name="../../drivers/sensors/pn532/helpers/pn532_mifare_classic.c"/>
+          <File Name="../../drivers/sensors/pn532/helpers/pn532_mifare_classic.h"/>
+          <File Name="../../drivers/sensors/pn532/helpers/pn532_mifare_ultralight.c"/>
+          <File Name="../../drivers/sensors/pn532/helpers/pn532_mifare_ultralight.h"/>
+        </VirtualDirectory>
+        <File Name="../../drivers/sensors/pn532/pn532_bus.h"/>
+        <File Name="../../drivers/sensors/pn532/pn532_bus_i2c.c"/>
+        <File Name="../../drivers/sensors/pn532/pn532_bus_uart.c"/>
       </VirtualDirectory>
       <VirtualDirectory Name="tcs3414">
         <File Name="../../drivers/sensors/tcs3414/tcs3414.c"/>
index b5c6b47..d7f6d5d 100644 (file)
             <file file_name="../../drivers/sensors/pn532/pn532.c">
               <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
             </file>
-            <file file_name="../../drivers/sensors/pn532/pn532_bus_uart.c"/>
+            <file file_name="../../drivers/sensors/pn532/pn532_bus_uart.c">
+              <configuration Name="THUMB Flash Debug" build_exclude_from_build="No"/>
+            </file>
             <folder Name="helpers">
               <file file_name="../../drivers/sensors/pn532/helpers/pn532_mifare_classic.c"/>
               <file file_name="../../drivers/sensors/pn532/helpers/pn532_mifare_ultralight.c"/>
index f56c47e..e894c45 100644 (file)
@@ -18,7 +18,7 @@
  </ETMWindow>
  <ExecutionCountWindow/>
  <Memory1>
-  <MemoryWindow autoEvaluate="0" addressText="0x100003d0" numColumns="8" sizeText="12" dataSize="1" radix="16" addressSpace="" />
+  <MemoryWindow autoEvaluate="0" addressText="&amp;pbtResponse" numColumns="8" sizeText="64" dataSize="1" radix="16" addressSpace="" />
  </Memory1>
  <Memory2>
   <MemoryWindow autoEvaluate="0" addressText="" numColumns="8" sizeText="" dataSize="1" radix="16" addressSpace="" />
   <ProjectSessionItem path="LPC1343_CodeBase" name="unnamed" />
   <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase" name="unnamed" />
   <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files" name="unnamed" />
-  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;project" name="unnamed" />
-  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;project;commands" name="unnamed" />
-  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;project;commands;drawing" name="unnamed" />
+  <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="" />
@@ -71,7 +73,7 @@
   <Watches active="0" update="Never" />
  </Watch4>
  <Files>
-  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="43" debugPath="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" y="32" path="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" left="0" selected="1" name="unnamed" top="31" />
+  <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" />
  </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 Release" />
+ <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" />
 </session>
index 2db915e..05bd4e2 100644 (file)
@@ -216,8 +216,8 @@ void I2C_IRQHandler(void)
 ** Function name:      I2CStart
 **
 ** Descriptions:       Create I2C start condition, a timeout
-**                                     value is set if the I2C never gets started,
-**                                     and timed out. It's a fatal error.
+**                     value is set if the I2C never gets started,
+**                     and timed out. It's a fatal error.
 **
 ** parameters:         None
 ** Returned value:     true or false, return false if timed out
@@ -269,7 +269,7 @@ static uint32_t I2CStop( void )
 **
 ** parameters:         I2c mode is either MASTER or SLAVE
 ** Returned value:     true or false, return false if the I2C
-**                                     interrupt handler was not installed correctly
+**                     interrupt handler was not installed correctly
 ** 
 *****************************************************************************/
 uint32_t i2cInit( uint32_t I2cMode ) 
@@ -320,11 +320,11 @@ uint32_t i2cInit( uint32_t I2cMode )
 ** Function name:      I2CEngine
 **
 ** Descriptions:       The routine to complete a I2C transaction
-**                                     from start to stop. All the intermitten
-**                                     steps are handled in the interrupt handler.
-**                                     Before this routine is called, the read
-**                                     length, write length and I2C master buffer
-**                                     need to be filled.
+**                     from start to stop. All the intermitten
+**                     steps are handled in the interrupt handler.
+**                     Before this routine is called, the read
+**                     length, write length and I2C master buffer
+**                     need to be filled.
 **
 ** parameters:         None
 ** Returned value:     Any of the I2CSTATE_... values. See i2c.h
index ff1e224..63b01e8 100644 (file)
@@ -75,8 +75,8 @@
    Fast Mode       (400KHz) = CFG_CPU_CCLK / 800000
    Fast- Mode Plus (1MHz)   = CFG_CPU_CCLK / 2000000       */
 
-#define I2SCLH_SCLH       CFG_CPU_CCLK / 800000  /* Standard Mode I2C SCL Duty Cycle High (400KHz) */
-#define I2SCLL_SCLL       CFG_CPU_CCLK / 800000  /* Fast Mode I2C SCL Duty Cycle Low (400KHz) */
+#define I2SCLH_SCLH       CFG_CPU_CCLK / 200000  /* Standard Mode I2C SCL Duty Cycle High (400KHz) */
+#define I2SCLL_SCLL       CFG_CPU_CCLK / 200000  /* Fast Mode I2C SCL Duty Cycle Low (400KHz) */
 #define I2SCLH_HS_SCLH    CFG_CPU_CCLK / 2000000  /* Fast Plus I2C SCL Duty Cycle High Reg */
 #define I2SCLL_HS_SCLL    CFG_CPU_CCLK / 2000000  /* Fast Plus I2C SCL Duty Cycle Low Reg */
 
index fedebeb..94d2c2e 100644 (file)
@@ -10,8 +10,8 @@
 #include "projectconfig.h"
 
 // These may need to be enlarged for multi card support
-#define PN532_RESPONSELEN_INLISTPASSIVETARGET (32)
-#define PN532_RESPONSELEN_INDATAEXCHANGE      (32)  
+#define PN532_RESPONSELEN_INLISTPASSIVETARGET (64)
+#define PN532_RESPONSELEN_INDATAEXCHANGE      (64)  
 
 typedef enum pn532_mifare_cmd_e
 {
index ece672e..debf834 100644 (file)
@@ -253,7 +253,8 @@ pn532_error_t pn532_mifareclassic_WaitForPassiveTarget (byte_t * pbtCUID, size_t
   {
     /* Card appears to be Mifare Classic */
     *szCUIDLen = abtResponse[12];
-    for (uint8_t i=0; i < *szCUIDLen; i++) 
+    uint8_t i;
+    for (i=0; i < *szCUIDLen; i++) 
     {
       pbtCUID[i] = abtResponse[13+i];
     }
index 1b4007a..0876101 100644 (file)
@@ -153,7 +153,8 @@ pn532_error_t pn532_mifareultralight_WaitForPassiveTarget (byte_t * pbtCUID, siz
   {
     /* Card appears to be Mifare Ultralight */
     *szCUIDLen = abtResponse[12];
-    for (uint8_t i=0; i < *szCUIDLen; i++) 
+    uint8_t i;
+    for (i=0; i < *szCUIDLen; i++) 
     {
       pbtCUID[i] = abtResponse[13+i];
     }
@@ -283,32 +284,3 @@ pn532_error_t pn532_mifareultralight_ReadPage (uint8_t page, byte_t * pbtBuffer)
   return PN532_ERROR_NONE;
 }
 
-//static  bool
-//read_card (void)
-//{
-//  uint32_t page;
-//  bool    bFailure = false;
-//  uint32_t uiReadedPages = 0;
-//
-//  printf ("Reading %d pages |", uiBlocks + 1);
-//
-//  for (page = 0; page <= uiBlocks; page += 4) {
-//    // Try to read out the data block
-//    if (nfc_initiator_mifare_cmd (pnd, MC_READ, page, &mp)) {
-//      memcpy (mtDump.amb[page / 4].mbd.abtData, mp.mpd.abtData, 16);
-//    } else {
-//      bFailure = true;
-//      break;
-//    }
-//
-//    print_success_or_failure (bFailure, &uiReadedPages);
-//    print_success_or_failure (bFailure, &uiReadedPages);
-//    print_success_or_failure (bFailure, &uiReadedPages);
-//    print_success_or_failure (bFailure, &uiReadedPages);
-//  }
-//  printf ("|\n");
-//  printf ("Done, %d of %d pages readed.\n", uiReadedPages, uiBlocks + 1);
-//  fflush (stdout);
-//
-//  return (!bFailure);
-//}
index 024fdfd..1f73624 100644 (file)
@@ -197,7 +197,6 @@ pn532_error_t pn532_bus_SendCommand(const byte_t * pbtData, const size_t szData)
 {
   pn532_error_t error = PN532_ERROR_NONE;
   pn532_pcb_t *pn532 = pn532GetPCB();
-  uint32_t ready_timeout = 0;
     
   // Check if we're busy
   if (pn532->state == PN532_STATE_BUSY)
@@ -405,7 +404,6 @@ pn532_error_t pn532_bus_ReadResponse(byte_t * pbtResponse, size_t * pszRxLen)
 /**************************************************************************/
 pn532_error_t pn532_bus_Wakeup(void)
 {
-  size_t szLen;
   pn532_error_t error = PN532_ERROR_NONE;
   byte_t abtWakeUp[] = { 0x55,0x55,0x00,0x00,0x00,0x00,0x00,0xff,0x03,0xfd,0xd4,0x14,0x01,0x17,0x00,0x00,0xff,0x03,0xfd,0xd4,0x14,0x01,0x17,0x00 };
   uint32_t i;
index e677c80..2eb55c0 100644 (file)
     SSD1306     . .  .  .     X X X . X X . . .     . . . .
     SSD1351     . .  .  .     X X X X X . . . .     . . . .
     MCP121      . .  .  .     . . . . . . . . .     . X . .
+    PN532 [3]   . .  .  .     . . . . . . . . .     . X X . 
 
                 TIMERS                    SSP     ADC         UART
                 ======================    ===     =======     ====
          can safely be used by other peripherals, but may need to be
          reconfigured when you wakeup from deep-sleep.
     [2]  INTERFACE can be configured to use either USBCDC or UART
+    [3]  3.2 only used when with the I2C bus (for IRQ)
 
  **************************************************************************/
 
This page took 0.044758 seconds and 4 git commands to generate.