Commit da7d7dba authored by Mark Stevens's avatar Mark Stevens
Browse files

populate repo from existing folder :...

populate repo from existing folder : /home/mstevens/platforms/duco/scorpio_src/3128-6003-6.0/external/pn547_i2c_test_app
parent 47c730f0
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= pn547_i2c_test_app.c
LOCAL_MODULE:= pn547_i2c_test
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
/*
* Copyright (C) 2010 Trusted Logic S.A.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define PN544_MAGIC 0xE9
/*
* PN544 power control via ioctl
* PN544_SET_PWR(0): power off
* PN544_SET_PWR(1): power on
* PN544_SET_PWR(2): reset and power on with firmware download enabled
*/
#define PN544_SET_PWR _IOW(PN544_MAGIC, 0x01, unsigned int)
struct pn544_i2c_platform_data{
unsigned int irq_gpio;
unsigned int ven_gpio;
unsigned int firm_gpio;
};
pn547_i2c_test工具使用说明
pn547_i2c_test为测试程序
测试程序的使用方法如下:
1.将 pn547_i2c_test_app.rar 解压到 external 目录下 mm 编译
2.将生成的 pn547_i2c_test push 到 system/bin
adb shell
cd system/bin
chmod 777 pn547_i2c_test
./pn547_i2c_test
务必利用本工具确认 KERNEL 部分正常通信后,再移植 Middleware 部分。
驱动正常反馈的数据交互: 你只要看有类似这样的数据反馈就好了,不需要管里面的内容是什么。
>> root@Alto4NA:/ # pn547_test
>> pn544 iic driver testing...
>> DH->NFCC: 20 00 01 01
>> NFCC->DH: 40 00 03 00 10 01
>> write<->read successful!
>>
>> DH->NFCC: 20 01 00
>> NFCC->DH: 40 01 15 00 03 06 03 00 04 00 01 02 03 02 C8 00 FF 02 00 04 05
>> 08 01 08
>> write<->read successful!
>>
>> DH->NFCC: 20 02 2B 0D 28 01 01 21 01 00 30 01 08 31 01 03 33 04 01 02 03
>> 04 54 01 06 50 01 02 5B 01 02 60 01 07 80 01 01 81 01 01 82 01 0E 18 01 80
>> NFCC->DH: 40 02 02 00 00
>> write<->read successful!
>>
>> DH->NFCC: 2F 02 00
>> NFCC->DH: 4F 02 05 00 00 00 4F E9
>> write<->read successful!
驱动移植成功后,再移植Android 部分。
请仔细阅读AN11762-Android_NXP_NFC_Setup_Guideline说明文档。
I2C测试成功后,再移植Android 部分,当添加上层后,如果有问题需要提供完整的log:
adb reboot
adb logcat -v time>D:\logcatreboot.log
\ No newline at end of file
/*
* Android.mk //TODO:Here is makefile reference
* LOCAL_PATH:= $(call my-dir)
* include $(CLEAR_VARS)
* LOCAL_SRC_FILES:= pn547_iic_test_app.c
* LOCAL_MODULE:= pn547_app
* include $(BUILD_EXECUTABLE)
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include "pn544.h"
#define SEND_CMD_NUM 4
int main(int argc, char *argv[]) {
int ret = 0;
int i = 0;
int num;
int fp = 0;
//NCI cmd
unsigned char send_test_cmd[SEND_CMD_NUM][60] = {
{0x20, 0x00, 0x01, 0x01},/*CORE_RESET_CMD*/
{0x20, 0x01, 0x00}, /*CORE_INIT_CMD*/
{0x20, 0x02, 0x2B, 0x0D, 0x28, 0x01, 0x01, 0x21, 0x01, 0x00, 0x30, 0x01, 0x08, 0x31, 0x01, /*CORE_SET_CONFIG_CMD */
0x03, 0x33, 0x04, 0x01, 0x02, 0x03, 0x04, 0x54, 0x01, 0x06, 0x50, 0x01, 0x02, 0x5B, 0x01,
0x02, 0x60, 0x01, 0x07, 0x80, 0x01, 0x01, 0x81, 0x01, 0x01, 0x82, 0x01, 0x0E, 0x18, 0x01, 0x80},
{0x2F, 0x02, 0x00}/*,NXP_ACT_PROP_EXTN*/
/*{0x2F, 0x00, 0x01, 0x00 }NXP_CORE_STANDBY*/
};
unsigned char recv_resp[50] = {0};
printf("pn544 iic driver testing...");
if ((ret = (fp = open("/dev/pn544", O_RDWR))) < 0) {
printf("pn547 open error retcode = %d, errno = %d\n", ret, errno);
exit(0);
}
//hardware reset
ioctl(fp, PN544_SET_PWR, 1);
ioctl(fp, PN544_SET_PWR, 0);
ioctl(fp, PN544_SET_PWR, 1);
for (num=0; num<SEND_CMD_NUM; num++)
{
printf("\nDH->NFCC: ");
for (i=0; i<(send_test_cmd[num][2]+3); i++){
printf("%.2X ", send_test_cmd[num][i]);
}
//Send cmd
ret = write(fp, send_test_cmd[num], send_test_cmd[num][2]+3);
if (ret < 0){
printf("\npn547 write error, maybe in standby mode, retcode = %d, errno = %d, retry...", ret, errno);
//wait 50ms
usleep(50000);
ret = write(fp, send_test_cmd[num], send_test_cmd[num][2]+3);
if (ret < 0){
printf("\npn547 write error retcode = %d, errno = %d", ret, errno);
close(fp);
return errno;
}
}
//Read pn547 responses, Read XX XX XX 00 ..., if 4th byte is 00, it means STATUS_OK.
memset(recv_resp, 0, sizeof(recv_resp));
ret = read(fp, &recv_resp[0], 3);
if (ret < 0) {
printf("\npn547 read error! retcode = %d, errno = %d", ret, errno);
close(fp);
return errno;
}
else if (recv_resp[0] == 0x51) {
printf("\nRead 0x51, IRQ may do not work, abort! ");
break;
}
ret = read(fp, &recv_resp[3], recv_resp[2]);
if (ret < 0) {
printf("\npn544 read error! retcode = %d, errno = %d", ret, errno);
}
else{
printf("\nNFCC->DH: ");
for (i=0;i<(recv_resp[2]+3);i++){
printf("%.2X ", recv_resp[i]);}
}
if (((recv_resp[0]&0xF0)==0x40) && (recv_resp[1]==send_test_cmd[num][1]) && (recv_resp[3]==0))
printf("\nwrite<->read successful!\n");
else
printf("\nwrite<->read error!\n");
}
printf("\n");
close(fp);
return 0;
}
Markdown is supported
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