AppNearMe µNFC stack for the NXP PN532 chip License: You can use the stack free of charge to prototype with mbed; if you want to use the stack with your commercial product, get in touch!

Dependents:   IOT_sensor_nfc AppNearMe_MuNFC_PN532_Test p2p_nfc_test NFCMoodLamp ... more

License

You can use the stack free of charge to prototype with mbed; if you want to use the stack with your commercial product, get in touch!

PN532/munfc/ndef/appnearme_ndef_util.h

Committer:
AppNearMe
Date:
2012-11-07
Revision:
10:2af578c635cd

File content as of revision 10:2af578c635cd:

/*
    appnearme_ndef_util.h 
  Copyright (c) Donatien Garnier 2012
  donatien.garnier@appnearme.com
  http://www.appnearme.com/
*/

#ifndef APPNEARME_NDEF_UTIL_H_
#define APPNEARME_NDEF_UTIL_H_

#include "core/fwk.h"

//MSB first
#define WRITE_UINT32_NDEF( addr, val ) do{ *(((uint8_t*)(addr)) + 0) = (val >> 24 ) & 0xFF; \
                                           *(((uint8_t*)(addr)) + 1) = (val >> 16 ) & 0xFF; \
                                           *(((uint8_t*)(addr)) + 2) = (val >> 8 ) & 0xFF; \
                                           *(((uint8_t*)(addr)) + 3) = (val >> 0 ) & 0xFF; } while(0)
#define WRITE_UINT16_NDEF( addr, val ) do{ *(((uint8_t*)(addr)) + 0) = (val >> 8 ) & 0xFF; \
                                           *(((uint8_t*)(addr)) + 1) = (val >> 0 ) & 0xFF; } while(0)

//MSB first
#define READ_UINT32_NDEF( addr, val ) do{ val = (*(((uint8_t*)(addr)) + 0) << 24 ) \
                                              | (*(((uint8_t*)(addr)) + 1) << 16 ) \
                                              | (*(((uint8_t*)(addr)) + 2) << 8 ) \
                                              | (*(((uint8_t*)(addr)) + 3) << 0 ); } while(0)
#define READ_UINT16_NDEF( addr, val ) do{ val = (*(((uint8_t*)(addr)) + 0) << 8 ) \
                                              | (*(((uint8_t*)(addr)) + 1) << 0 ); } while(0)

#endif /* APPNEARME_NDEF_UTIL_H_ */