183 lines
3.5 KiB
C
Executable File
183 lines
3.5 KiB
C
Executable File
|
|
#include "os_types.h"
|
|
#include "os_task.h"
|
|
#include "os_mem.h"
|
|
|
|
#include "dbg_io.h"
|
|
#include "iot_diag.h"
|
|
#include "iot_io.h"
|
|
|
|
#include "iot_system_api.h"
|
|
#include "iot_config.h"
|
|
|
|
#include "iot_system.h"
|
|
|
|
|
|
#include "platform.h"
|
|
#include "encoding.h"
|
|
|
|
#include "bits.h"
|
|
|
|
#include "os_utils.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern void nfc_write_access_write(uint8_t cmd, uint8_t addr, uint8_t val);
|
|
|
|
extern uint8_t nfc_write_access_read();
|
|
|
|
static int32_t iot__platform_init()
|
|
{
|
|
/*platform intialization*/
|
|
platform_init();
|
|
|
|
//resource initializations;
|
|
dbg_uart_init();
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
void user_task_1(){
|
|
int i=0;
|
|
while(1)
|
|
{
|
|
nfc_write_access_write(2, 0x01, 0x0f);
|
|
|
|
i=0;
|
|
|
|
while(i<0x3f){
|
|
iot_printf("%02x 0x%02x, ",i, nfc_write_access_read(i));
|
|
i++;
|
|
if((i&0xf)==0)
|
|
iot_printf("\r\n");
|
|
}
|
|
////////////////////////////////////////////
|
|
nfc_write_access_write(2, 0x11, 0xff);
|
|
nfc_write_access_write(2, 0x14, 0xff);
|
|
nfc_write_access_write(2, 0x17, 0xff);
|
|
nfc_write_access_write(2, 0x19, 0xff);
|
|
nfc_write_access_write(2, 0x27, 0xff);
|
|
nfc_write_access_write(2, 0x2c, 0xff);
|
|
nfc_write_access_write(2, 0x32, 0xff);
|
|
nfc_write_access_write(2, 0x34, 0xff);
|
|
//////////////////////////////////////////////////
|
|
i=0;
|
|
iot_printf("\r\nREAD aft wr:\r\n");
|
|
while(i<0x3f){
|
|
iot_printf("%02x 0x%02x, ",i, nfc_write_access_read(i));
|
|
i++;
|
|
if((i&0xf)==0)
|
|
iot_printf("\r\n");
|
|
}
|
|
iot_printf("\r\n");
|
|
nfc_write_access_write(2, 0x01, 0x0f);
|
|
os_delay(10);
|
|
i=25;
|
|
while(i)
|
|
{
|
|
nfc_write_access_write(2, 0x09, 0x00);
|
|
i--;
|
|
}
|
|
os_delay(10);
|
|
nfc_write_access_write(2, 0x01, 0x01);
|
|
os_delay(10);
|
|
nfc_write_access_write(2, 0x36, 0x09);
|
|
os_delay(10);
|
|
nfc_write_access_write(2, 0x09, 0x00);
|
|
os_delay(10);
|
|
nfc_write_access_write(2, 0x01, 0x03);
|
|
|
|
os_delay(10);
|
|
|
|
i=64;
|
|
while(i)
|
|
{
|
|
iot_printf("0x%x ",nfc_write_access_read(0x09));
|
|
i--;
|
|
}
|
|
iot_printf("\r\n+++++++++++++++++++++++++\r\n");
|
|
|
|
////////////////////////////////////////////
|
|
iot_printf("NFC TX:\r\n");
|
|
nfc_write_access_write(2, 0x01, 0x0f);
|
|
os_delay(10);
|
|
/*data*/
|
|
nfc_write_access_write(2, 0x09, 0x00);
|
|
nfc_write_access_write(2, 0x09, 0xd3);
|
|
nfc_write_access_write(2, 0x09, 0x0f);
|
|
nfc_write_access_write(2, 0x09, 0xaa);
|
|
nfc_write_access_write(2, 0x09, 0x33);
|
|
/*analog*/
|
|
nfc_write_access_write(2, 0x12, 0x00);
|
|
nfc_write_access_write(2, 0x14, 0x83);
|
|
nfc_write_access_write(2, 0x16, 0x10);
|
|
nfc_write_access_write(2, 0x27, 0xf0);
|
|
nfc_write_access_write(2, 0x28, 0x3f);
|
|
nfc_write_access_write(2, 0x29, 0x00);
|
|
nfc_write_access_write(2, 0x01, 0x04);
|
|
}
|
|
}
|
|
|
|
int32_t iot__task_init()
|
|
{
|
|
os_task_h handle;
|
|
|
|
handle = os_create_task(user_task_1, NULL, 9);
|
|
|
|
//create the tasks;
|
|
if(handle != NULL) {
|
|
iot_printf("task 1 init successfully...\n");
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
int32_t iot__module_init(void)
|
|
{
|
|
//platform intialization;
|
|
iot__platform_init();
|
|
|
|
//create all the tasks;
|
|
iot__task_init();
|
|
|
|
iot_printf("starting...\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
int32_t iot__task_start()
|
|
{
|
|
//start the tasks;
|
|
os_start_kernel();
|
|
|
|
return 0;
|
|
}
|
|
|
|
int32_t iot__module_start(void)
|
|
{
|
|
int32_t res = 0;
|
|
|
|
res = iot__task_start();
|
|
|
|
return res;
|
|
}
|
|
|
|
|
|
int main(void)
|
|
{
|
|
//module init;
|
|
iot__module_init();
|
|
|
|
//module start;
|
|
iot__module_start();
|
|
|
|
return 0;
|
|
}
|
|
|
|
|