fifocommon.h File Reference

low level FIFO API. More...

#include "ndstypes.h"

Typedefs

typedef void(* FifoAddressHandlerFunc )(void *address, void *userdata)
 fifo callback function pointer with the sent address and the callback's user data.
typedef void(* FifoDatamsgHandlerFunc )(int num_bytes, void *userdata)
 fifo callback function pointer with the number of bytes sent and the callback's user data
typedef void(* FifoValue32HandlerFunc )(u32 value32, void *userdata)
 fifo callback function pointer with the sent value and the callback's user data.

Enumerations

enum  FifoChannels {
  FIFO_PM = 0,
  FIFO_SOUND = 1,
  FIFO_SYSTEM = 2,
  FIFO_MAXMOD = 3,
  FIFO_DSWIFI = 4,
  FIFO_RSVD_01 = 5,
  FIFO_RSVD_02 = 6,
  FIFO_RSVD_03 = 7,
  FIFO_USER_01 = 8,
  FIFO_USER_02 = 9,
  FIFO_USER_03 = 10,
  FIFO_USER_04 = 11,
  FIFO_USER_05 = 12,
  FIFO_USER_06 = 13,
  FIFO_USER_07 = 14,
  FIFO_USER_08 = 15
}
 

Enum values for the different fifo channels.

More...
enum  FifoPMCommands
 

Enum values for the fifo power management commands.


enum  FifoSoundCommand
 

Enum values for the fifo sound commands.


enum  FifoSystemCommands
 

Enum values for the fifo system commands.


enum  FifoWifiCommands
 

Enum values for the fifo wifi commands.


enum  PM_LedBlinkMode {
  PM_LED_ON = (0<<4),
  PM_LED_SLEEP = (1<<4),
  PM_LED_BLINK = (3<<4)
}
 

Power Management LED blink mode control bits.

More...

Functions

bool fifoCheckAddress (int channel)
 checks if there is any addresses in the fifo queue.
bool fifoCheckDatamsg (int channel)
 checks if there is any data messages in the fifo queue.
int fifoCheckDatamsgLength (int channel)
 gets the number of bytes in the queue for the first data entry.
bool fifoCheckValue32 (int channel)
 checks if there is any values in the fifo queue.
void * fifoGetAddress (int channel)
 Get the first address in queue for a specific channel.
int fifoGetDatamsg (int channel, int buffersize, u8 *destbuffer)
 Reads a data message in a given buffer and returns the number of bytes written.
u32 fifoGetValue32 (int channel)
 Get the first value32 in queue for a specific channel.
bool fifoInit ()
 Initializes the fifo system.
bool fifoSendAddress (int channel, void *address)
 Send an address to an channel.
bool fifoSendDatamsg (int channel, int num_bytes, u8 *data_array)
 Send a sequence of bytes to the other CPU.
bool fifoSendValue32 (int channel, u32 value32)
 Send a 32bit value.
bool fifoSetAddressHandler (int channel, FifoAddressHandlerFunc newhandler, void *userdata)
 Set user address message callback.
bool fifoSetDatamsgHandler (int channel, FifoDatamsgHandlerFunc newhandler, void *userdata)
 Set user data message callback.
bool fifoSetValue32Handler (int channel, FifoValue32HandlerFunc newhandler, void *userdata)
 Set user value32 message callback.

Detailed Description

low level FIFO API.


Typedef Documentation

typedef void(* FifoAddressHandlerFunc)(void *address, void *userdata)

fifo callback function pointer with the sent address and the callback's user data.

The handler is called when new data arrives.

Note:
callback functions are called from interrupt level, but are well secured. not too much caution is necessary, but don't call alloc, free or printf from within them, just to be safe.
typedef void(* FifoDatamsgHandlerFunc)(int num_bytes, void *userdata)

fifo callback function pointer with the number of bytes sent and the callback's user data

The handler is called when new data arrives. This callback must call fifoGetData to actually retrieve the data. If it doesn't, the data will be destroyed on return.

Note:
callback functions are called from interrupt level, but are well secured. not too much caution is necessary, but don't call alloc, free or printf from within them, just to be safe.
typedef void(* FifoValue32HandlerFunc)(u32 value32, void *userdata)

fifo callback function pointer with the sent value and the callback's user data.

The handler is called when new data arrives.

Note:
callback functions are called from interrupt level, but are well secured. not too much caution is necessary, but don't call alloc, free or printf from within them, just to be safe.

Enumeration Type Documentation

Enum values for the different fifo channels.

Enumerator:
FIFO_PM 

fifo channel reserved for power management.

FIFO_SOUND 

fifo channel reserved for sound access.

FIFO_SYSTEM 

fifo channel reserved for system functions.

FIFO_MAXMOD 

fifo channel reserved for the maxmod library.

FIFO_DSWIFI 

fifo channel reserved for the dswifi library.

FIFO_RSVD_01 

fifo channel reserved for future use.

FIFO_RSVD_02 

fifo channel reserved for future use.

FIFO_RSVD_03 

fifo channel reserved for future use.

FIFO_USER_01 

fifo channel available for users.

FIFO_USER_02 

fifo channel available for users.

FIFO_USER_03 

fifo channel available for users.

FIFO_USER_04 

fifo channel available for users.

FIFO_USER_05 

fifo channel available for users.

FIFO_USER_06 

fifo channel available for users.

FIFO_USER_07 

fifo channel available for users.

FIFO_USER_08 

fifo channel available for users.

Power Management LED blink mode control bits.

Enumerator:
PM_LED_ON 

Steady on.

PM_LED_SLEEP 

Blinking, mostly off.

PM_LED_BLINK 

Blinking, mostly on.


Function Documentation

bool fifoCheckAddress ( int  channel  ) 

checks if there is any addresses in the fifo queue.

Parameters:
channel the channel to check.
Returns:
true if there is any addresses in the queue and if there isn't an address handler in place for the channel.
bool fifoCheckDatamsg ( int  channel  ) 

checks if there is any data messages in the fifo queue.

Parameters:
channel the channel to check.
Returns:
true if there is any data messages in the queue and if there isn't a data message handler in place for the channel.
int fifoCheckDatamsgLength ( int  channel  ) 

gets the number of bytes in the queue for the first data entry.

Parameters:
channel the channel to check.
Returns:
the number of bytes in the queue for the first data entry, or -1 if there are no entries.
bool fifoCheckValue32 ( int  channel  ) 

checks if there is any values in the fifo queue.

Parameters:
channel the channel to check.
Returns:
true if there is any values in the queue and if there isn't a value handler in place for the channel.
void* fifoGetAddress ( int  channel  ) 

Get the first address in queue for a specific channel.

Parameters:
channel the channel to check.
Returns:
the first address in queue, or NULL if there is none.
int fifoGetDatamsg ( int  channel,
int  buffersize,
u8 destbuffer 
)

Reads a data message in a given buffer and returns the number of bytes written.

Parameters:
channel the channel to check.
buffersize the size of the buffer where the message will be copied to.
destbuffer a pointer to the buffer where the message will be copied to.
Returns:
the number of bytes written, or -1 if there is no message.
Warning:
If your buffer is not big enough, you may lose data! Check the data length first if you're not sure what the size is.
u32 fifoGetValue32 ( int  channel  ) 

Get the first value32 in queue for a specific channel.

Parameters:
channel the channel to check.
Returns:
the first value32 in queue, or 0 if there is no message.
bool fifoInit (  ) 

Initializes the fifo system.

Attempts to sync with the other CPU, if it fails, fifo services won't be provided.

Note:
call irqInit() before calling this function.
Returns:
true if syncing worked, false if something went wrong.
bool fifoSendAddress ( int  channel,
void *  address 
)

Send an address to an channel.

Transmits an address in the range 0x02000000-0x023FFFFF to the other CPU.

Parameters:
channel channel number to send to.
address address to send.
Returns:
true if the address has been send, false if something went wrong.
bool fifoSendDatamsg ( int  channel,
int  num_bytes,
u8 data_array 
)

Send a sequence of bytes to the other CPU.

num_bytes can be between 0 and FIFO_MAX_DATA_BYTES - sending 0 bytes can be useful sometimes...

Parameters:
channel channel number to send to
num_bytes number of bytes to send
data_array pointer to data array
Returns:
true if the data message has been send, false if something went wrong.
bool fifoSendValue32 ( int  channel,
u32  value32 
)

Send a 32bit value.

Transmits a 32bit value to the other CPU.

Parameters:
channel channel number to send to
value32 32bit value to send
Returns:
true if the value has been send, false if something went wrong.
Note:
Transfer is more efficient if the top 8 bits are zero. So sending smaller values or bitmasks that don't include the top bits is preferred.
bool fifoSetAddressHandler ( int  channel,
FifoAddressHandlerFunc  newhandler,
void *  userdata 
)

Set user address message callback.

Set a callback to receive incoming address messages on a specific channel.

Parameters:
channel channel number to send to.
newhandler a function pointer to the new handler function.
userdata a pointer that will be passed on to the handler when it will be called.
Returns:
true if the handler has been set, false if something went wrong.
Note:
Setting the handler for a channel feeds the queue of buffered messages to the new handler, if there are any unread messages.
bool fifoSetDatamsgHandler ( int  channel,
FifoDatamsgHandlerFunc  newhandler,
void *  userdata 
)

Set user data message callback.

Set a callback to receive incoming data messages on a specific channel.

Parameters:
channel channel number to send to.
newhandler a function pointer to the new handler function.
userdata a pointer that will be passed on to the handler when it will be called.
Returns:
true if the handler has been set, false if something went wrong.
Note:
Setting the handler for a channel feeds the queue of buffered messages to the new handler, if there are any unread messages.
bool fifoSetValue32Handler ( int  channel,
FifoValue32HandlerFunc  newhandler,
void *  userdata 
)

Set user value32 message callback.

Set a callback to receive incoming value32 messages on a specific channel.

Parameters:
channel channel number to send to.
newhandler a function pointer to the new handler function.
userdata a pointer that will be passed on to the handler when it will be called.
Returns:
true if the handler has been set, false if something went wrong.
Note:
Setting the handler for a channel feeds the queue of buffered messages to the new handler, if there are any unread messages.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated on Sat Oct 2 12:55:13 2010 for libnds by  doxygen 1.6.3