as3993 ST25RU3993 Firmware
Functions | Variables
main.c File Reference
#include "as3993_config.h"
#include "platform.h"
#include "stream_dispatcher.h"
#include "usb_hid_stream_driver.h"
#include "logger.h"
#include "uart_driver.h"
#include "errno.h"
#include "as3993_public.h"
#include "as3993.h"
#include "gen2.h"
#include "global.h"
#include "timer.h"
#include "appl_commands.h"
#include "tuner.h"
#include "iso6b.h"

Go to the source code of this file.

Functions

void systemInit (void)
 
static void morse_nibble (u8 nibble)
 
static void showError (u8 errorCode, u8 blinkState)
 
int main (void)
 
u8 applPeripheralReset (void)
 
u8 applProcessCmd (u8 protocol, u16 rxSize, const u8 *rxData, u16 *txSize, u8 *txData)
 
u8 applProcessCyclic (u8 *protocol, u16 *txSize, u8 *txData, u16 remainingSize)
 
const char * applFirmwareInformation ()
 
u8 cmdReadReg (u16 rxSize, const u8 *rxData, u16 *txSize, u8 *txData)
 
u8 applReadReg (u16 rxSize, const u8 *rxData, u16 *txSize, u8 *txData)
 
u8 cmdWriteReg (u16 rxSize, const u8 *rxData, u16 *txSize, u8 *txData)
 
u8 applWriteReg (u16 rxSize, const u8 *rxData, u16 *txSize, u8 *txData)
 

Variables

Freq Frequencies
 
Tag tags_ [MAXTAG]
 
static const char gAS3993FwInfo [] = FIRMWARE_ID"||"HARDWARE_ID
 
static const char gLogStartup [] = FIRMWARE_ID" %hhx.%hhx.%hhx on "HARDWARE_ID"\n"
 
const u32 firmwareNumber = FIRMWARE_VERSION
 
static const u8 codes [0x10]
 

Detailed Description

System initialization and main loop.

Author
Ulrich Herrmann
Bernhard Breinbauer

Definition in file main.c.

Function Documentation

const char* applFirmwareInformation ( )

get firmware information (zero-terminated) string

function which can be implemented by the application to return the firmware inforamtion string (zero-terminated). E.g. information about the chip and board.

Returns
the a pointer to the firmware information

Definition at line 408 of file main.c.

u8 applPeripheralReset ( )

reset peripherals of board

function which can be implemented by the application to reset the board peripherals.

Returns
AMS_STREAM_UNHANDLED_PROTOCOL if function was not overloaded by application

Definition at line 390 of file main.c.

u8 applProcessCmd ( u8  protocol,
u16  rxSize,
const u8 *  rxData,
u16 *  txSize,
u8 *  txData 
)

Command dispatcher for application-specific commands.

function which can be implemented by the application process application- specific commands for I/O. If data should be returned, the txData buffer can be filled with data which should be sent to the PC. In argument txSize, the size is returned.

Parameters
[in]protocol: the protocol byte which needs to be processed
[in]rxData: pointer to payload for appl commands (in stream protocol buffer).
[in]rxSize: size of rxData
[out]txData: pointer to buffer to store returned data (payload only)
[out]txSize: size of returned data
Returns
the status byte to be interpreted by the stream layer on the host

Definition at line 396 of file main.c.

u8 applProcessCyclic ( u8 *  protocol,
u16 *  txSize,
u8 *  txData,
u16  remainingSize 
)

Called cyclic (even when no full usb packet was received). Use this is you need to send several packets (time delayed) in response to one usb request.

function which can be implemented by the application process If data should be returned, the txData buffer must be filled with the data to be sent to the PC. In argument txSize, the size is returned. The function also must fill in the protocol byte (this is the protocol value that is filled in in the protocol header.

Parameters
[out]protocol: protocol byte to be used for the packet header
[out]txData: pointer to buffer to store returned data (payload only)
[out]txSize: size of returned data
[in]remainingSize: how many bytes are free in the buffer txData
Returns
the status byte to be interpreted by the stream layer on the host

Definition at line 403 of file main.c.

u8 applReadReg ( u16  rxSize,
const u8 *  rxData,
u16 *  txSize,
u8 *  txData 
)

Generic function to read one or more registers.

Function which can be implemented by the application to read registers. If data should be returned, the txData buffer must be filled with the data to be sent to the PC. In argument txSize, the size is returned. The function also must fill in the protocol byte (this is the protocol value that is filled in in the protocol header.

Parameters
[in]rxData: pointer to payload for appl commands (in stream protocol buffer).
[in]rxSize: size of rxData
[out]txData: pointer to buffer to store returned data (payload only)
[out]txSize: size of returned data
Returns
the status byte to be interpreted by the stream layer on the host

Definition at line 480 of file main.c.

u8 applWriteReg ( u16  rxSize,
const u8 *  rxData,
u16 *  txSize,
u8 *  txData 
)

Generic function to write one or more registers.

Function which can be implemented by the application to write registers. If data should be returned, the txData buffer must be filled with the data to be sent to the PC. In argument txSize, the size is returned. The function also must fill in the protocol byte (this is the protocol value that is filled in in the protocol header.

Parameters
[in]rxData: pointer to payload for appl commands (in stream protocol buffer).
[in]rxSize: size of rxData
[out]txData: pointer to buffer to store returned data (payload only)
[out]txSize: size of returned data
Returns
the status byte to be interpreted by the stream layer on the host

Definition at line 509 of file main.c.

u8 cmdReadReg ( u16  rxSize,
const u8 *  rxData,
u16 *  txSize,
u8 *  txData 
)

This function reads one or all registers from the AS3993. See also applReadReg().
The format of the report from the host is as follows:

Byte01
Contentmode reg_addr

Where mode = 0 requests to read all registers and mode = 1 requests to read only the register with address reg_addr. If mode = 0 reg_addr is ignored.
If mode = 0 the device sends back:

Byte 0 .. 29 30 31 .. 36 37 38 48
Content reg 0x00 .. reg 0x1D reg 0x22 reg 0x29 .. reg 0x2E reg 0x33 reg 0x35 .. reg 0x3F

If mode = 1 the device sends back:

Byte0
Contentreg value

returns ERR_NONE if operation was successful, ERR_PARAM is invalid mode was set.

Definition at line 460 of file main.c.

u8 cmdWriteReg ( u16  rxSize,
const u8 *  rxData,
u16 *  txSize,
u8 *  txData 
)

This function writes one register on the AS3993. See also applWriteReg().
The format of the report from the host is as follows:

Byte01
Contentreg_addrvalue

if reg_addr > 0x80, then an immediate command is executed.
The device sends back:

Byte0
Content0

returns ERR_NONE if operation was successful.

Definition at line 500 of file main.c.

int main ( void  )

main function Initializes board, cpu, reader, host communication, ...
After initialization a loop which waits for commands from host and performs cyclic inventory rounds is entered.

Definition at line 276 of file main.c.

static void morse_nibble ( u8  nibble)
static

This function will morse an error code on either the MCULED() or on LED1()

Definition at line 128 of file main.c.

static void showError ( u8  errorCode,
u8  blinkState 
)
static

This function displays error codes. If the number of LEDs available on the board is sufficient, those LEDs will be used to show the error code binary coded. If there are too few LEDs on the board the error code will be morsed via morse_nibble();

Parameters
errorCodeThe error code to display.
blinkStateIndicates if the LEDs should be turned on or off (for blinking).

Definition at line 176 of file main.c.

void systemInit ( void  )

Basic system initialization.

Definition at line 386 of file main.c.

Variable Documentation

const u8 codes[0x10]
static
Initial value:
=
{
0xbf,
0xaf,
0xa7,
0xa3,
0xa1,
0xa0,
0xb0,
0xb8,
0xbc,
0xbe,
0x41,
0x88,
0x8a,
0x64,
0x20,
0x82,
}

morse codes for hex numbers.

Definition at line 106 of file main.c.

const u32 firmwareNumber = FIRMWARE_VERSION

FW version which will be reported to host

Definition at line 78 of file main.c.

Freq Frequencies

Contains the list of used frequencies.

Definition at line 170 of file appl_commands.c.

const char gAS3993FwInfo[] = FIRMWARE_ID"||"HARDWARE_ID
static

FW information which will be reported to host.

Definition at line 74 of file main.c.

const char gLogStartup[] = FIRMWARE_ID" %hhx.%hhx.%hhx on "HARDWARE_ID"\n"
static

FW information which will be logged on startup. Version information is included in logger.

Definition at line 76 of file main.c.

Tag tags_[MAXTAG]

Array of Structures which stores all necessary Information about the Tags.

Definition at line 164 of file appl_commands.c.