打印
[文档下载]

N76E003资料

[复制链接]
383|11
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
DS_N76E003_SC_Rev1.08.pdf (3.88 MB)


使用特权

评论回复
沙发
dongnanxibei|  楼主 | 2020-4-15 22:36 | 只看该作者
N76E003_BSP_Keil_C51_V1.0.6.zip (6.32 MB)

使用特权

评论回复
板凳
dongnanxibei|  楼主 | 2020-4-15 22:36 | 只看该作者
EC_N76E003_UART_RS485_V1.00.zip (210.87 KB)

使用特权

评论回复
地板
dongnanxibei|  楼主 | 2020-4-15 22:37 | 只看该作者
EC_N76E003_Open_Loop_BLDC_Motor_V1.00.zip (1.8 MB)

使用特权

评论回复
5
dongnanxibei|  楼主 | 2020-4-15 22:38 | 只看该作者
EC_N76E003_Weigand_V1.00.zip (3.02 MB)

使用特权

评论回复
6
dongnanxibei|  楼主 | 2020-4-15 22:39 | 只看该作者
基于N76E003实现Wiegand协议封包
基于N76E003的定时器(Timer)与通用输入输出接口 (GPIO)实现收发Wiegand 协议封包
简介
Wiegand通讯协议由摩托罗拉公司制定,广泛应用于门禁系统的读卡器和电子卡片,为现今的 工业标准,最常见的格式为标准的26-bit封包。本范例代码基于N76E003的定时器(Timer)与通 用输入输出接口(GPIO)实现收发26-bit的Wiegand协议封包

使用特权

评论回复
7
dongnanxibei|  楼主 | 2020-4-15 22:40 | 只看该作者
Wiegand 协议
Wiegand界面是一种通讯协议,由3根线组成 Data0, Data1, Data return。Data0与Data1在没有 数据输出时保持+5V高电平。若输出为0,则D0拉低一段时间;若输出为1,则D1拉低一段时 间。

使用特权

评论回复
8
dongnanxibei|  楼主 | 2020-4-15 22:42 | 只看该作者




使用特权

评论回复
9
dongnanxibei|  楼主 | 2020-4-15 22:43 | 只看该作者

使用特权

评论回复
10
dongnanxibei|  楼主 | 2020-4-15 22:44 | 只看该作者
/**************************************************************************//**
* [url=home.php?mod=space&uid=288409]@file[/url]     main.c
* [url=home.php?mod=space&uid=247401]@brief[/url]     Use GPIO to send wiegand26 protocol
* @note
* Copyright (C) 2019 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/

#include "N76E003.h"
#include "SFR_Macro.h"
#include "Function_define.h"
#include "Common.h"
#include "Delay.h"
/*---------------------------------------------------------------------------*/
/* Define                                                                    */
/*---------------------------------------------------------------------------*/
#define delay_100us() Timer0_Delay100us(1)
#define WG_DATA1 P06
#define WG_DATA0 P05
/*---------------------------------------------------------------------------*/
/* Global variables                                                          */
/*---------------------------------------------------------------------------*/
unsigned char out[3] = {0x55, 0x55, 0x55};
unsigned char in[3] = {0, 0, 0};
unsigned char count = 0; //capture data count
unsigned char inputcapture[26] = {0}; //for reciver data buffeer

/*---------------------------------------------------------------------------*/
/* Functions                                                                 */
/*---------------------------------------------------------------------------*/

void  delay_1500us(void)
{
  Timer0_Delay100us(15);
}

void WG_send_bit_1(void)
{
  WG_DATA1 = 0;
  delay_100us();
  WG_DATA1 = 1;
  delay_1500us();
}
void WG_send_bit_0(void)
{
  WG_DATA0 = 0;
  delay_100us();
  WG_DATA0 = 1;
  delay_1500us();
}

//send wiegnad 26 byte.
//input data array 3 char
void send_wiegand26(unsigned char *str)
{
  unsigned char data i;
  unsigned  char check_temp;
  unsigned char data check;
  bit  even;
  bit  odd;
  unsigned char data wiegand[3];

  wiegand[0] = *str;
  wiegand[1] = *(str + 1);
  wiegand[2] = *(str + 2);
  check = 0;
  check_temp = wiegand[0];
  //even data check for data 2-9
  for(i = 0; i < 8; i++)
  {
    if((check_temp & 0x80) == 0X80)
    {
      check++;
    }
    check_temp = check_temp << 1;
  }
  if(check % 2 == 0)
    even = 0;
  else
    even = 1;
  check = 0;
  //odd data check for data 10-25
  check_temp = wiegand[1];
  for(i = 0; i < 8; i++)
  {
    if(check_temp & 0x80 == 0X80)
    {
      check++;
    }
    check_temp = check_temp << 1;
  }
  check_temp = wiegand[2];
  for(i = 0; i < 8; i++)
  {
    if(check_temp & 0x80 == 0X80)
    {
      check++;
    }
    check_temp = check_temp << 1;
  }
  if(check % 2 == 0)
    odd = 1;
  else
    odd = 0;
  //send header ep
  if(even)
  {
    WG_send_bit_1();
  }
  else
  {
    WG_send_bit_0();
  }
  //send data
  for(i = 0; i < 24; i++)
  {

    if((wiegand[0]) & 0x80)
    {
      WG_send_bit_1();
    }
    else
    {
      WG_send_bit_0();
    }
    (*(long*)&wiegand[0]) <<= 1;
  }
  //send op
  if(odd)
  {
    WG_send_bit_1();
  }
  else
  {
    WG_send_bit_0();
  }
}
//interrupt data input
void PinInterrupt_ISR(void) interrupt 7
{
  if(WG_DATA1 == 0)
    inputcapture[count] = 1;
  count++;
  PIF = 0x00;                             //clear interrupt flag
}
//get wiegand
//return 0 false, 1 pass.
//input data array for reciver data
unsigned char GET_wiegand26(unsigned char *str)
{

  unsigned char data i;
  unsigned  char check_temp;
  unsigned char data check;
  bit  even;
  bit  odd;
  //enable interrupt
  PICON = 0xFC; //PORT 0 INT, edge interrupt
  PINEN = 0X60; //FALL edge
  count = 0;
  set_EPI;              // Enable pin interrupt
  set_EX0;
  set_EA;                // global enable bit
  while(count < 26);    //POLL DATA INPUT
  clr_EA;                // clear ea
  clr_EPI;              // clr pin interrupt
  clr_EX0;
  check = 0;
  check_temp = 0;
  //data 1-9
  for(i = 1; i < 9; i++)
  {
    if((inputcapture[i]) == 1)
    {
      check++;
      check_temp = check_temp | 0x01;
    }
    check_temp = check_temp << 1;
  }
  if(check % 2 == 0)
    even = 0;
  else
    even = 1;
  //compare even
  if(even != inputcapture[0])
    return 0;
  str[0] = check_temp;
  check = 0;
  check_temp = 0;
  //data 10-25
  for(i = 9; i < 17; i++)
  {
    if((inputcapture[i]) == 1)
    {
      check++;
      check_temp = check_temp | 0x01;
    }
    check_temp = check_temp << 1;
  }
  str[1] = check_temp;
  check_temp = 0;
  for(i = 17; i < 25; i++)
  {
    if((inputcapture[i]) == 1)
    {
      check++;
      check_temp = check_temp | 0x01;
    }
    check_temp = check_temp << 1;
  }
  str[2] = check_temp;
  if(check % 2 == 0)
    odd = 1;
  else
    odd = 0;
  //compare odd
  if(odd != inputcapture[25])
    return 0;
  return 1;
}
void main(void)
{
    //for wiegand in high state.
  P05 = 1;
  P06 = 1;
    //initial all gpio for quasi mode
  Set_All_GPIO_Quasi_Mode;
  delay_1500us();
    //send wiegand package
  send_wiegand26(out);
  while(1);
}

使用特权

评论回复
11
dongnanxibei|  楼主 | 2020-4-15 22:44 | 只看该作者
/**************************************************************************//**
* @file     main.c
* @brief     Use GPIO to reciver wiegand26 protocol
* @note
* Copyright (C) 2019 Nuvoton Technology Corp. All rights reserved.
*****************************************************************************/

//***********************************************************************************************************
//  File Function: N76E003 GPIO demo code
//***********************************************************************************************************
#include "N76E003.h"
#include "SFR_Macro.h"
#include "Function_define.h"
#include "Common.h"
#include "Delay.h"
/*---------------------------------------------------------------------------*/
/* Define                                                                    */
/*---------------------------------------------------------------------------*/
#define delay_100us() Timer0_Delay100us(1)
#define WG_DATA1 P06
#define WG_DATA0 P05

/*---------------------------------------------------------------------------*/
/* Global variables                                                          */
/*---------------------------------------------------------------------------*/
unsigned char out[3] = {0x55, 0x55, 0x55};
unsigned char in[3] = {0, 0, 0};
unsigned char count = 0; //capture data count
unsigned char inputcapture[26] = {0}; //for reciver data buffeer

void  delay_1500us(void)
{
  Timer0_Delay100us(15);
}

void WG_send_bit_1(void)
{
  WG_DATA1 = 0;
  delay_100us();
  WG_DATA1 = 1;
  delay_1500us();
}
void WG_send_bit_0(void)
{
  WG_DATA0 = 0;
  delay_100us();
  WG_DATA0 = 1;
  delay_1500us();
}

//send wiegnad 26 byte.
//input data array 3 char
void send_wiegand26(unsigned char *str)
{
  unsigned char data i;
  unsigned  char check_temp;
  unsigned char data check;
  bit  even;
  bit  odd;
  unsigned char data wiegand[3];

  wiegand[0] = *str;
  wiegand[1] = *(str + 1);
  wiegand[2] = *(str + 2);
  check = 0;
  check_temp = wiegand[0];
  //even data check for data 2-9
  for(i = 0; i < 8; i++)
  {
    if((check_temp & 0x80) == 0X80)
    {
      check++;
    }
    check_temp = check_temp << 1;
  }
  if(check % 2 == 0)
    even = 0;
  else
    even = 1;
  check = 0;
  //odd data check for data 10-25
  check_temp = wiegand[1];
  for(i = 0; i < 8; i++)
  {
    if(check_temp & 0x80 == 0X80)
    {
      check++;
    }
    check_temp = check_temp << 1;
  }
  check_temp = wiegand[2];
  for(i = 0; i < 8; i++)
  {
    if(check_temp & 0x80 == 0X80)
    {
      check++;
    }
    check_temp = check_temp << 1;
  }
  if(check % 2 == 0)
    odd = 1;
  else
    odd = 0;
  //send header ep
  if(even)
  {
    WG_send_bit_1();
  }
  else
  {
    WG_send_bit_0();
  }
  //send data
  for(i = 0; i < 24; i++)
  {

    if((wiegand[0]) & 0x80)
    {
      WG_send_bit_1();
    }
    else
    {
      WG_send_bit_0();
    }
    (*(long*)&wiegand[0]) <<= 1;
  }
  //send op
  if(odd)
  {
    WG_send_bit_1();
  }
  else
  {
    WG_send_bit_0();
  }
}
//interrupt data input
void PinInterrupt_ISR(void) interrupt 7
{
  if(WG_DATA1 == 0)
    inputcapture[count] = 1;
  count++;
  PIF = 0x00;                             //clear interrupt flag
}
//get wiegand
//return 0 false, 1 pass.
//input data array for reciver data
unsigned char GET_wiegand26(unsigned char *str)
{

  unsigned char data i;
  unsigned  char check_temp;
  unsigned char data check;
  bit  even;
  bit  odd;
  //enable interrupt
  PICON = 0xFC; //PORT 0 INT, edge interrupt
  PINEN = 0X60; //FALL edge
  count = 0;
  set_EPI;              // Enable pin interrupt
  set_EX0;
  set_EA;                // global enable bit
  while(count < 26);    //POLL DATA INPUT
  clr_EA;                // clear ea
  clr_EPI;              // clr pin interrupt
  clr_EX0;
  check = 0;
  check_temp = 0;
  //data 1-9
  for(i = 1; i < 9; i++)
  {
    if((inputcapture[i]) == 1)
    {
      check++;
      check_temp = check_temp | 0x01;
    }
    check_temp = check_temp << 1;
  }
  if(check % 2 == 0)
    even = 0;
  else
    even = 1;
  //compare even
  if(even != inputcapture[0])
    return 0;
  str[0] = check_temp;
  check = 0;
  check_temp = 0;
  //data 10-25
  for(i = 9; i < 17; i++)
  {
    if((inputcapture[i]) == 1)
    {
      check++;
      check_temp = check_temp | 0x01;
    }
    check_temp = check_temp << 1;
  }
  str[1] = check_temp;
  check_temp = 0;
  for(i = 17; i < 25; i++)
  {
    if((inputcapture[i]) == 1)
    {
      check++;
      check_temp = check_temp | 0x01;
    }
    check_temp = check_temp << 1;
  }
  str[2] = check_temp;
  if(check % 2 == 0)
    odd = 1;
  else
    odd = 0;
  //compare odd
  if(odd != inputcapture[25])
    return 0;
  return 1;
}
void main(void)
{
  P05 = 1;
  P06 = 1;
  Set_All_GPIO_Quasi_Mode;
  //reciver wiegand protocol data
  if(GET_wiegand26(in) == 0)
  {
    while(1);
  }
  while(1);
}

使用特权

评论回复
12
dongnanxibei|  楼主 | 2020-4-15 22:54 | 只看该作者
如何执行范例程序
1. 本项目支持Keil uVersion 4.6及以上版本 2. 根据目录信息进入Sample_Code\ExampleCode文件夹,双击Wiegand_Master与 Wiegand_Slave文件夹中的Wiegand_Master.uvproj与Wiegand_Slave.uvproj 3. 进入编译模式接口 a. 编译 b. 下载代码至内存 c. 进入 / 离开除错模式 4. 进入除错模式接口 a. 可别进入除错模式进行调试 b. 执行代码  

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

187

主题

3481

帖子

16

粉丝