how to use X-NUCLEO-NFC04A1 tag ? Please share its base code .
Hello,
I already used x-cube-nfc4 as a basic code for application use of RFID tag but it didn't work only it indicates the nfc tap while using near to tag and even this code doesn't support uart. So, i want to know why UART is not supporting in it. I am attaching the code which I used.
#include "main.h"
UART_HandleTypeDef huart;
sURI_Info URI;
extern sCCFileInfo CCFileStruct;
/* Private function prototypes -----------------------------------------------*/
void UARTConsoleConfig( void );
HAL_StatusTypeDef UARTConsolePrint( char *puartmsg );
extern void SystemClock_Config( void );
int main( void )
{
char uartmsg[6]="hello";
HAL_Init( );
/* Configure the System clock */
SystemClock_Config( );
/* Init of the Nucleo Board led */
// BSP_LED_Init(LED2);
/* Init of the Leds on X-NUCLEO-NFC04A1 board */
NFC04A1_LED_Init( );
NFC04A1_LED_ON( GREEN_LED );
HAL_Delay( 300 );
NFC04A1_LED_ON( BLUE_LED );
HAL_Delay( 300 );
NFC04A1_LED_ON( YELLOW_LED );
HAL_Delay( 300 );
/* Init UART for display message on console */
UARTConsoleConfig();
UARTConsolePrint(uartmsg);
UARTConsolePrint("HELLO");
UARTConsolePrint( "----------------------------------------" );
/* Init ST25DV driver */
while( BSP_NFCTAG_Init( ) != NFCTAG_OK );
/* Reset Mailbox enable to allow write to EEPROM */
BSP_NFCTAG_GetExtended_Drv()->ResetMBEN_Dyn( );
/* Check if no NDEF detected, init mem in Tag Type 5 */
if( NfcType5_NDEFDetection( ) != NDEF_OK )
{
CCFileStruct.MagicNumber = NFCT5_MAGICNUMBER_E1_CCFILE;
CCFileStruct.Version = NFCT5_VERSION_V1_0;
CCFileStruct.MemorySize = ( ST25DV_MAX_SIZE / 8 ) & 0xFF;
CCFileStruct.TT5Tag = 0x05;
/* Init of the Type Tag 5 component (M24LR) */
while( NfcType5_TT5Init( ) != NFCTAG_OK );
}
/* Init done */
NFC04A1_LED_OFF( GREEN_LED );
HAL_Delay( 300 );
NFC04A1_LED_OFF( BLUE_LED );
HAL_Delay( 300 );
NFC04A1_LED_OFF( YELLOW_LED );
HAL_Delay( 300 );
/* Prepare URI NDEF message content */
strcpy( URI.protocol,URI_ID_0x01_STRING );
strcpy( URI.URI_Message,"st.com/st25" );
strcpy( URI.Information,"\0" );
/* Write NDEF to EEPROM */
while( NDEF_WriteURI( &URI ) != NDEF_OK );
/* Set the LED3 on to indicate Programing done */
NFC04A1_LED_ON( YELLOW_LED );
/* Infinite loop */
while (1)
{
}
}
void UARTConsoleConfig( void )
{
if(HAL_UART_GetState(&huart) == HAL_UART_STATE_RESET)
{
huart.Instance = USART2;
huart.Init.BaudRate = 115200;
huart.Init.WordLength = UART_WORDLENGTH_8B;
huart.Init.StopBits = UART_STOPBITS_1;
huart.Init.Parity = UART_PARITY_NONE;
huart.Init.Mode = UART_MODE_TX_RX;
huart.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart.Init.OverSampling = UART_OVERSAMPLING_16;
HAL_UART_Init(&huart);
}
}
HAL_StatusTypeDef UARTConsolePrint( char *puartmsg )
{
return HAL_UART_Transmit( &huart, (uint8_t *)puartmsg, strlen( puartmsg ), 500);
}
HAL_StatusTypeDef UARTConsoleScan( uint8_t uartchar )
{
while( HAL_UART_Receive( &huart, &uartchar, 1, 500) == HAL_TIMEOUT );
return HAL_OK;
}
#ifdef USE_FULL_ASSERT
void assert_failed( uint8_t* file, uint32_t line )
{
/* Infinite loop */
while( 1 )
{
}
}
#endif
