#include <cafe/ntag.h>

typedef void (*NTAGResultCheckCallback)(s32 chan, NTAGError error_code, void* userData); 

NTAGError NTAGFormat( s32 chan, u16 time_out, const u8* uid, 
                      u16 write_size, const u8* data,
                      NTAGResultCheckCallback callback, void* userData ); 


chan Controller number 0.
time_out Timeout intervals.
0: Infinite
1 through 65535 : ms
uid ID of the target tag (7 bytes).
When NULL is specified, it is handled as a UID of All0, and tag formatting fails.
write_size Size of the data to write after formatting.
data Pointer to the data to write.
callback Callback that is called when tag formatting has finished.
userData Data to pass to the callback function.

Return Values

NTAG_ERR_NONE The command was issued normally.
NTAG_ERR_NOT_INIT The initialization of the NFC module is not finished.

Callback Notification Details

When tags are detected, the following registered callbacks send notifications with the following details.

chan Controller number.
error_code Error code:
  • NTAG_ERR_NONE : The process finished normally.
  • NTAG_ERR_TIMEOUT : Timeout occurred.
  • NTAG_ERR_INVALID_UID : The configured UID did not match the UID of the detected tag.
  • NTAG_ERR_INVALID_TAG : An unsupported tag was detected.
  • NTAG_ERR_INVALID_FORMAT : A tag with an invalid format was detected.
  • NTAG_ERR_FORMAT : An error occurred during formatting.
  • NTAG_ERR_WRITE : An error occurred during the writing process after formatting.
  • NTAG_ERR_ABORT : The process was ended partway by the system.
    (When the HOME Menu is called or the TV control button is pressed.)
userData User data.


Formats tags. After the formatting is performed, it handles the writing of the data specified in the arguments. The result can be received with the set callback function. The write data specified in this function must be of a size equal to or less than the RAM region for the tag that handles the writing. If the size provided in the arguments does not fill the RAM region, the remaining data is filled in with random values on the system side when the tag is written. (Writing to tags is performed for the entire region, not just part of it.)

Do Not Call From

Background Do not call this function from the background.
Multiple threads This function is not thread-safe.
Multiple Cores Do not call this function from more than one Core.

Revision History

2013/05/08 Automated cleanup pass.
2012/12/26 Initial version.