orcus
Macros | Enumerations | Functions | Variables
orcus.h File Reference

Main header file for Orcus functions. More...

#include <stdint.h>
#include <stdbool.h>

Macros

#define NAND_BLOCK_SIZE   512
 Number of bytes in a NAND block.
 
#define TIMER_NS_PER_TICK   135
 Nanoseconds per timer tick. More...
 
#define A   (1<<0)
 Button.
 
#define B   (1<<1)
 Button.
 
#define DOWN   (1<<7)
 Button.
 
#define DOWN_LEFT   (1<<12)
 Button.
 
#define DOWN_RIGHT   (1<<13)
 Button.
 
#define L   (1<<17)
 Button.
 
#define LEFT   (1<<8)
 Button.
 
#define R   (1<<18)
 Button.
 
#define RIGHT   (1<<9)
 Button.
 
#define SELECT   (1<<5)
 Button.
 
#define START   (1<<4)
 Button.
 
#define STICK   (1<<16)
 Button.
 
#define UP   (1<<6)
 Button.
 
#define UP_LEFT   (1<<10)
 Button.
 
#define UP_RIGHT   (1<<11)
 Button.
 
#define VOL_DOWN   (1<<15)
 Button.
 
#define VOL_UP   (1<<14)
 Button.
 
#define X   (1<<2)
 Button.
 
#define Y   (1<<3)
 Button.
 

Enumerations

enum  BlendingMode { NO_BLENDING = 0, COLOUR_KEY = 1, ALPHA = 2 }
 Blending modes for combining regions on-screen. More...
 
enum  BurstMode { , WORDS_4 = 0x1 }
 DMA burst mode (RAM->RAM only). More...
 
enum  Parity { NONE, ODD, EVEN }
 UART parity settings. More...
 
enum  Peripheral
 MMSP2 peripherals available for DMA transfers.
 
enum  RgbFormat { P4BPP = 0, P8BPP = 1, RGB565 = 2, RGB888 = 3 }
 Bit formats in RGB region. More...
 
enum  RgbRegion {
  REGION1 = 1, REGION2 = 2, REGION3 = 3, REGION4 = 4,
  REGION5 = 5
}
 Regions available in RGB hardware. More...
 

Functions

uint16_t ac97GetReg (uint8_t reg)
 Read register value from AC97 codec. More...
 
void ac97SetReg (uint8_t reg, uint16_t value)
 Set register value in AC97 codec. More...
 
void ac97Start ()
 Start AC97 codec. More...
 
void ac97Stop ()
 Stop AC97 codec. More...
 
void arm940ClockOff ()
 Pause execution on the ARM940T. More...
 
void arm940ClockOn ()
 Resume execution on the ARM940T. More...
 
void arm940Halt ()
 Halt the ARM940T. More...
 
bool arm940HasClock ()
 Check if the ARM940T has a clock signal. More...
 
int arm940Init (int memoryBank)
 Initialise ARM940T. More...
 
bool arm940IsThis ()
 Check if executing on the ARM940T. More...
 
void arm940Run ()
 Start execution on the ARM940T. More...
 
bool arm940Running ()
 Check if the ARM940T is running. More...
 
bool audioHeadphonesConnected ()
 Check if headphones are connected (F100 only). More...
 
void audioInit (int dmaChannel)
 Initialise audio subsystem. More...
 
void audioMuteHeadphones ()
 Mute headphones. More...
 
void audioMuteSpeakers ()
 Mute speakers. More...
 
void audioPlaySample (uint16_t bytes, void *data)
 Play a PCM sample. More...
 
bool audioSamplePlaying ()
 Check if a sample is currently playing. More...
 
void audioSetSampleRate (uint16_t khz)
 Set sample rate for AC97 codec. More...
 
void audioSetVolume (uint8_t left, uint8_t right)
 Set volume. More...
 
void audioUnmuteHeadphones ()
 Unmute headphones. More...
 
void audioUnmuteSpeakers ()
 Unmute speakers. More...
 
uint32_t btnState ()
 Get current button state. More...
 
uint32_t btnStateDebounced ()
 Get current button state (debounced). More...
 
void dmaConfigureChannelIO (int channel, BurstMode burstMode, int8_t srcIncrement, int8_t destIncrement, Peripheral peripheral)
 Configure a DMA channel for memory-to-peripheral transfer. More...
 
void dmaConfigureChannelMem (int channel, BurstMode burstMode, int8_t srcIncrement, int8_t destIncrement)
 Configure a DMA channel for memory-to-memory transfer. More...
 
bool dmaHasFinished (int channel)
 Check if a DMA channel has finished transferring data. More...
 
bool dmaIsTransferring (int channel)
 Check if a DMA channel is transferring data. More...
 
void dmaStart (int channel, uint16_t length, uint32_t src, uint32_t dest)
 Initiate a DMA transfer. More...
 
void dmaStop (int channel)
 Stop a DMA transfer. More...
 
void enableICache ()
 Enable icache on ARM920T. More...
 
uint32_t exportPointer (void *ptr)
 Export a pointer to the other CPU. More...
 
void gp2xInit ()
 Initialise GP2X. More...
 
bool gp2xIsF200 ()
 Check if running on an F200. More...
 
void gp2xSetDefaultRamTimings ()
 Set default recommended RAM timings. More...
 
void gp2xSetFastRamTimings ()
 Set faster RAM timings. More...
 
void gp2xSetRamTimings (int tRC, int tRAS, int tWR, int tMRD, int tRFC, int tRP, int tRCD)
 Set custom RAM timings. More...
 
void * importPointer (uint32_t addr)
 Import a pointer from the other CPU. More...
 
bool lcdHSync ()
 Check if LCD is currently in hsync period. More...
 
bool lcdVSync ()
 Check if LCD is currently in vsync period. More...
 
void lcdWaitNextHSync ()
 Wait until LCD is in next hsync period. More...
 
void lcdWaitNextVSync ()
 Wait until LCD is in next vsync period. More...
 
void nandErase (uint32_t startAdddr, int numberOfBlocks)
 Erase blocks on NAND. More...
 
void nandRead (uint32_t startAddr, int numberOfBlocks, void *dest)
 Read blocks from NAND. More...
 
void nandWrite (uint32_t startAddr, int numberOfBlocks, void *src)
 Write blocks to NAND. More...
 
void rgbColourKey (uint8_t r, uint8_t g, uint8_t b)
 Set global colour key for blending. More...
 
void rgbPrintf (uint16_t *fb, int x, int y, uint16_t colour, const char *format,...)
 printf directly to RGB565 framebuffer. More...
 
void rgbPrintfBg (uint16_t *fb, int x, int y, uint16_t colour, uint16_t bgColour, const char *format,...)
 printf directly to RGB565 framebuffer with a background colour. More...
 
void rgbPutc (uint16_t *fb, int x, int y, uint16_t colour, char c)
 Render a font character on the screen. More...
 
void rgbPutcBg (uint16_t *fb, int x, int y, uint16_t colour, uint16_t bgColour, char c)
 Render a font character on the screen with a background colour. More...
 
void rgbRegionBlendAlpha (RgbRegion region, uint4_t alpha)
 Enable alpha blending for this region. More...
 
void rgbRegionBlendColourKey (RgbRegion region)
 Enable colour key blending for region. More...
 
void rgbRegionNoBlend (RgbRegion region)
 Disable blending for a region. More...
 
void rgbSetFbAddress (void *fb)
 Set RGB framebuffer address. More...
 
void rgbSetFont (uint16_t *font, int charWidth, int charHeight)
 Set font data to use. More...
 
void rgbSetPixelFormat (RgbFormat format)
 Configure RGB pixel format for all regions. More...
 
void rgbSetRegionPosition (RgbRegion region, int x, int y, int width, int height)
 Set region coordinates and size. More...
 
void rgbSetScale (int srcW, int srcH)
 Set source with for scaling region. More...
 
void rgbToggleRegion (RgbRegion region, bool onOff)
 Enable or disable an RGB region. More...
 
int sdInit ()
 Initialise SD card. More...
 
bool sdIsInserted ()
 Check if SD card is inserted. More...
 
int sdReadBlocks (int startBlock, int numberOfBlocks, uint8_t *dest)
 Read blocks from SD card. More...
 
uint32_t timerGet ()
 Get current timer tick. More...
 
unsigned int timerNsSince (uint32_t lastTick, uint32_t *storeCurrent)
 Calculate nanoseconds elapsed since a given tick. More...
 
uint32_t timerSet (uint32_t count)
 Reset timer to count from specific tick. More...
 
void timerSleepNs (unsigned int ns)
 Wait for a given number of nanoseconds. More...
 
void uartConfigure (int baudRate, int bitsPerFrame, Parity parity, int stopBits)
 Configure UART parameters. More...
 
int uartGetc (bool isBlocking)
 Get a character from UART. More...
 
void uartPrintf (const char *format,...)
 printf over UART. More...
 
char uartPutc (char c, bool isBlocking)
 Output character over UART. More...
 
void uartSetEcho (bool isEnabled)
 Set UART echoing. More...
 

Variables

volatile uint16_t * arm920Data
 Pointer to start of 16x 16-bit shared data registers. More...
 
volatile uint16_t * arm940Data
 Pointer to start of 16x 16-bit shared data registers. More...
 

Macro Definition Documentation

◆ TIMER_NS_PER_TICK

#define TIMER_NS_PER_TICK   135

Nanoseconds per timer tick. Timer ticks once every 0.135uS.

Enumeration Type Documentation

◆ BlendingMode

Enumerator
NO_BLENDING 

No blending between regions.

COLOUR_KEY 

Exclude pixels of a particular colour.

ALPHA 

Alpha blending.

◆ BurstMode

enum BurstMode
Enumerator
WORDS_4 

Copy one word at a time.

◆ Parity

enum Parity
Enumerator
NONE 

No parity bit.

ODD 

Odd parity bit.

EVEN 

Even parity bit.

◆ RgbFormat

enum RgbFormat
Enumerator
P4BPP 

4-bit palette mode, each 4 bit value (X, Y) is an index into the palette 0xXY

P8BPP 

8-bit palette mode, each byte is an index into the palette

RGB565 

16-bit RGB565 mode

RGB888 

24-bit RGB888 mode

◆ RgbRegion

enum RgbRegion
Enumerator
REGION1 

First RGB region.

REGION2 

Second RGB region.

REGION3 

Third RGB region.

REGION4 

Fourth RGB region.

REGION5 

Fifth RGB region.

Function Documentation

◆ ac97GetReg()

uint16_t ac97GetReg ( uint8_t  reg)

Read register value from AC97 codec

Note
Must have called ac97Start() or audioInit() before using this.
Parameters
regRegister to read
Returns
Register value
See also
ac97Start
audioInit

◆ ac97SetReg()

void ac97SetReg ( uint8_t  reg,
uint16_t  value 
)

Set register value in AC97 codec.

Note
Must have called ac97Start() or audioInit() before using this.
Parameters
regRegister to set
valueValue to set
See also
ac97Start
audioInit

◆ ac97Start()

void ac97Start ( )

Start AC97 codec, will restart codec if it was previously started.

Note
DMA channels must have been set up before calling this.

◆ ac97Stop()

void ac97Stop ( )

Stop AC97 codec.

◆ arm940ClockOff()

void arm940ClockOff ( )

Pause execution on the ARM940T by disabling its clock.

Note
You can call this from the ARM940T but you won't get control back until the ARM920 calls arm940ClockOn()
See also
arm940ClockOn

◆ arm940ClockOn()

void arm940ClockOn ( )

Enable the clock on the ARM940T to resume execution at the same point it was at when the clock was disabled.

Note
It makes no sense to call this from the ARM940T.
See also
arm940ClockOff

◆ arm940Halt()

void arm940Halt ( )

Halt the ARM940T and hold it in RESET state.

Note
You can call this from the ARM940T but you won't get control back afterwards.

◆ arm940HasClock()

bool arm940HasClock ( )

Check if the ARM940T has a clock signal, to see if execution is paused.

Returns
true if the ARM940T has a clock signal, false otherwise (i.e. it is paused)

◆ arm940Init()

int arm940Init ( int  memoryBank)

Initialise the ARM940T second CPU and configure the base address (in 16M increments) in physical memory which will appear as 0x0 from the perspective of the ARM940T.

This leaves the ARM940T in RESET state, and enables the clock.

Valid base addresses are 16M, 32M and 48M (banks 1, 2 and 3 respectively) to prevent overlapping with the ARM920T vector table (always stored at 0x0 in physical memory). It is possible to set both CPUs to start at 0x0 physical but in this case they will share a RESET vector and will execute the same code so it is highly discouraged unless you have an unusual use case in mind, and is not supported with this function.

Further documentation can be found on the Orcus wiki regarding using the ARM940T.

Note
This should only be called from the ARM920T.
Parameters
memoryBankMemory bank to use as start of ARM940T address range (1 - 3)
Returns
0 if successful, non-zero otherwise

◆ arm940IsThis()

bool arm940IsThis ( )

Check if this call is being executed on the ARM940T.

Returns
true if this is called from the ARM940T, false if called from the ARM920T

◆ arm940Run()

void arm940Run ( )

Start execution on the ARM940T from its RESET vector entry (0x0) by releasing it from RESET state.

Note
It makes no sense to call this from the ARM940T.

◆ arm940Running()

bool arm940Running ( )

Check if the ARM940T is running.

Note
It makes no sense to call this from the ARM940T.
Returns
true if the ARM940T is running, false if it is being held in RESET state

◆ audioHeadphonesConnected()

bool audioHeadphonesConnected ( )

Check if headphones are connected. This works on the F100 only, the F200 physically switches the DAC output between the speakers and headphones when you insert the jack.

Note
F100 only
Returns
true if headphones are connected, false otherwise

◆ audioInit()

void audioInit ( int  dmaChannel)

Initialise auto subsystem.

Parameters
dmaChannelDMA channel to use for audio (0 - 15, recommend 0 - 3)

◆ audioMuteHeadphones()

void audioMuteHeadphones ( )

Mute headphones.

◆ audioMuteSpeakers()

void audioMuteSpeakers ( )

Mute speakers.

◆ audioPlaySample()

void audioPlaySample ( uint16_t  bytes,
void *  data 
)

Play a PCM sample. Non-blocking, see if the sample has finished playing with audioSamplePlaying().

Parameters
bytesNumber of bytes in sample (max 0xFFFF)
dataPointer to sample data
See also
audioSamplePlaying

◆ audioSamplePlaying()

bool audioSamplePlaying ( )

Check if a sample is currently playing.

Returns
true if a sample is currently playing, false otherwise

◆ audioSetSampleRate()

void audioSetSampleRate ( uint16_t  khz)

Set sample rate for AC97 codec.

Note
Must have called audioInit() before using this.
Parameters
khzSample rate to set
See also
ac97Start
audioInit

◆ audioSetVolume()

void audioSetVolume ( uint8_t  left,
uint8_t  right 
)

Set volume.

@warn You may not wish to allow the volume to reach 31, with headphones connected this could do damage to somebody's hearing!

Parameters
leftVolume level for left channel (0 [lowest] - 31 [highest])
rightVolume level for right channel (0 [lowest] - 31 [highest])

◆ audioUnmuteHeadphones()

void audioUnmuteHeadphones ( )

Unmute headphones.

◆ audioUnmuteSpeakers()

void audioUnmuteSpeakers ( )

Unmute speakers.

◆ btnState()

uint32_t btnState ( )

Get current button state (raw).

One can check for a particular button state using &.

For example:

Returns
Currently pressed buttons OR-ed together.
See also
A

◆ btnStateDebounced()

uint32_t btnStateDebounced ( )

Get current button state. This function debounces presses to give a reliable indicator.

One can check for a particular button state using &.

For example:

Returns
Currently pressed buttons OR-ed together.
See also
A

◆ dmaConfigureChannelIO()

void dmaConfigureChannelIO ( int  channel,
BurstMode  burstMode,
int8_t  srcIncrement,
int8_t  destIncrement,
Peripheral  peripheral 
)

Configure a DMA channel for memory-to-peripheral transfer.

Parameters
channelDMA channel to configure (0 - 15)
burstModeNumber of words to copy at a time
srcIncrementNumber of words to increment source address after each transfer (negative values and zero are permitted)
destIncrementNumber of words to increment destination address after each transfer (negative values and zero are permitted)
peripheralMMSP2 peripheral to write to

◆ dmaConfigureChannelMem()

void dmaConfigureChannelMem ( int  channel,
BurstMode  burstMode,
int8_t  srcIncrement,
int8_t  destIncrement 
)

Configure a DMA channel for memory-to-memory transfer.

Parameters
channelDMA channel to configure (0 - 15)
burstModeNumber of words to copy at a time
srcIncrementNumber of words to increment source address after each transfer (negative values and zero are permitted)
destIncrementNumber of words to increment destination address after each transfer (negative values and zero are permitted)

◆ dmaHasFinished()

bool dmaHasFinished ( int  channel)

Check if a DMA channel has finished transferring data.

Parameters
channelDMA channel to check (0 - 15)

◆ dmaIsTransferring()

bool dmaIsTransferring ( int  channel)

Check if a DMA channel is transferring data.

Parameters
channelDMA channel to check (0 - 15)

◆ dmaStart()

void dmaStart ( int  channel,
uint16_t  length,
uint32_t  src,
uint32_t  dest 
)

Initiate a DMA transfer on a previously configured channel.

Parameters
channelDMA channel to initiate transfer on (0 - 15)
lengthNumber of bytes to transfer (maximum 64K)
srcSource address (aligned to 4 byte word boundary)
dstDestination address (aligned to 4 byte word boundary)
See also
dmaConfigureChanelMem

◆ dmaStop()

void dmaStop ( int  channel)

Stop a DMA transfer.

Parameters
channelDMA channel to stop (0 - 15)

◆ enableICache()

void enableICache ( )

Enable icache on ARM920T. This is enabled by default in gp2xInit.

Warning
This may have unexpected effects if called from the ARM940T

◆ exportPointer()

uint32_t exportPointer ( void *  ptr)

Export a pointer to the address space of the other CPU.

Warning
It may not be possible to export a pointer from memory which is only viewable from the ARM920T to the ARM940T. It is always possible to export from the ARM940T to the ARM920T however.
Parameters
ptrPointer to export
Returns
Address of ptr within the address space of the other CPU

◆ gp2xInit()

void gp2xInit ( )

Initialise the GP2X hardware and set up system calls. This must be called before using any other functions from Orcus.

◆ gp2xIsF200()

bool gp2xIsF200 ( )

Check if running on an F200. This tests to see if the NET2272 chip (only fitted to F100s) is present.

Returns
true if running on an F200, false if running on an F100

◆ gp2xSetDefaultRamTimings()

void gp2xSetDefaultRamTimings ( )

Equivalent to gp2xSetRamTimings(7, 15, 2, 7, 7, 7, 7)

See also
gp2xSetRamTimings

◆ gp2xSetFastRamTimings()

void gp2xSetFastRamTimings ( )

Equivalent to gp2xSetRamTimings(5, 3, 0, 0, 0, 1, 1)

See also
gp2xSetRamTimings

◆ gp2xSetRamTimings()

void gp2xSetRamTimings ( int  tRC,
int  tRAS,
int  tWR,
int  tMRD,
int  tRFC,
int  tRP,
int  tRCD 
)

Sets RAM timing registers in MMSP2.

◆ importPointer()

void* importPointer ( uint32_t  addr)

Import a pointer from the other CPU into the address space of the CPU we are running on.

Warning
It may not be possible to import a pointer from memory which is only viewable from the ARM920T when on the ARM940T. It is always possible to import from the ARM940T to the ARM920T however.
Parameters
addrAddress to import from other CPU
Returns
Pointer to the given address within the address space of the current CPU

◆ lcdHSync()

bool lcdHSync ( )

Check if LCD is currently in hsync period.

Returns
true if LCD is currently in hsync period, otherwise false

◆ lcdVSync()

bool lcdVSync ( )

Check if LCD is currently in vsync period.

Returns
true if LCD is currently in vsync period, otherwise false

◆ lcdWaitNextHSync()

void lcdWaitNextHSync ( )

Wait until LCD is in next hsync period. If LCD is currently in hsync when this is called, it will wait until it has ended, and then again until the next one begins.

◆ lcdWaitNextVSync()

void lcdWaitNextVSync ( )

Wait until LCD is in next vsync period. If LCD is currently in vsync when this is called, it will wait until it has ended, and then again until the next one begins.

◆ nandErase()

void nandErase ( uint32_t  startAdddr,
int  numberOfBlocks 
)

Erase (set to 0xFF) 512B blocks on NAND. You must do this before writing due to the nature of NAND storage where a write operating can only unset bits.

Warning
You can brick a GP2X if you erase the first 512K of NAND, where the bootloader is stored.
Parameters
startAddrAddress to start erasing from (absolute, not in terms of blocks)
numberOfBlocksNumber of 512B blocks to erase
See also
nandWrite

◆ nandRead()

void nandRead ( uint32_t  startAddr,
int  numberOfBlocks,
void *  dest 
)

Read 512B blocks from NAND.

Parameters
startAddrAddress to start reading from (absolute, not in terms of blocks)
numberOfBlocksNumber of 512B blocks to read
destPointer to memory location to store data

◆ nandWrite()

void nandWrite ( uint32_t  startAddr,
int  numberOfBlocks,
void *  src 
)

Write 512B blocks to NAND. You must first erase the blocks.

Warning
You can brick a GP2X if you write to the first 512K of NAND, where the bootloader is stored.
Parameters
startAddrAddress to start start writing to (absolute, not in terms of blocks)
numberOfBlocksNumber of 512B blocks to write
srcPointer to memory location holding data to write
See also
nandWrite

◆ rgbColourKey()

void rgbColourKey ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Set global colour key for blending RGB regions (all regions share the same key).

Parameters
rRed value to match
gGreen value to match
bBlue value to match

◆ rgbPrintf()

void rgbPrintf ( uint16_t *  fb,
int  x,
int  y,
uint16_t  colour,
const char *  format,
  ... 
)

printf directly to RGB565 framebuffer. Must have configured font first using rgbSetFont.

Note
This only works in RGB565 mode.
This has a maximum output buffer of 256 bytes.
Parameters
fbPointer to RGB565 framebuffer in which to render character
xX-coordinate at which to draw font
yY-coordinate at which to draw font
colourRGB565 colour to draw character
See also
rgbSetFont
rgbPrintfBg

◆ rgbPrintfBg()

void rgbPrintfBg ( uint16_t *  fb,
int  x,
int  y,
uint16_t  colour,
uint16_t  bgColour,
const char *  format,
  ... 
)

printf directly to RGB565 framebuffer with a background colour. Must have configured font first using rgbSetFont.

Note
This only works in RGB565 mode.
This has a maximum output buffer of 256 bytes.
Parameters
fbPointer to RGB565 framebuffer in which to render character
xX-coordinate at which to draw font
yY-coordinate at which to draw font
colourRGB565 colour to draw character
bgColourRGB565 colour to use for background
See also
rgbSetFont
rgbPrintf

◆ rgbPutc()

void rgbPutc ( uint16_t *  fb,
int  x,
int  y,
uint16_t  colour,
char  c 
)

Render a font character on the screen. Must have configured font first using rgbSetFont.

Note
This only works in RGB565 mode.
Parameters
fbPointer to RGB565 framebuffer in which to render character
xX-coordinate at which to draw font
yY-coordinate at which to draw font
colourRGB565 colour to draw character
cCharacter to draw
See also
rgbSetFont
rgbPutcBg

◆ rgbPutcBg()

void rgbPutcBg ( uint16_t *  fb,
int  x,
int  y,
uint16_t  colour,
uint16_t  bgColour,
char  c 
)

Render a font character on the screen with a background colour. Must have configured font first using rgbSetFont.

Note
This only works in RGB565 mode.
Parameters
fbPointer to RGB565 framebuffer in which to render character
xX-coordinate at which to draw font
yY-coordinate at which to draw font
colourRGB565 colour to draw character
bgColourRGB565 colour to use for background
cCharacter to draw
See also
rgbSetFont
rgbPutc

◆ rgbRegionBlendAlpha()

void rgbRegionBlendAlpha ( RgbRegion  region,
uint4_t  alpha 
)

Enable alpha blending for this region, and set alpha value.

Parameters
regionRegion to alter
alphaAlpha value (0 - 16)

◆ rgbRegionBlendColourKey()

void rgbRegionBlendColourKey ( RgbRegion  region)

Enable colour key blending for region.

Parameters
regionRegion to alter

◆ rgbRegionNoBlend()

void rgbRegionNoBlend ( RgbRegion  region)

Disable blending for a region.

Parameters
regionRegion to alter

◆ rgbSetFbAddress()

void rgbSetFbAddress ( void *  fb)

Set RGB framebuffer address. The regions all share the same base pointer and are accessed sequentially from that location.

Parameters
fbPointer to memory region which should be used as source of RGB data

◆ rgbSetFont()

void rgbSetFont ( uint16_t *  font,
int  charWidth,
int  charHeight 
)

Set font data to use for text drawing utility functions.

Note
This only works in RGB565 mode.
Parameters
fontPointer to font graphic data
charWidthWidth of font character in pixels
charHeightHeight of font character in pixels

◆ rgbSetPixelFormat()

void rgbSetPixelFormat ( RgbFormat  format)

Configure RGB pixel format for all regions.

Parameters
formatFormat to use when interpreting RGB data

◆ rgbSetRegionPosition()

void rgbSetRegionPosition ( RgbRegion  region,
int  x,
int  y,
int  width,
int  height 
)

Set region coordinates and size.

Parameters
regionRegion to alter
xX-coordinate of start of region
yY-coordinate of start of region
widthWidth in pixels of region
heightHeight in pixels of region

◆ rgbSetScale()

void rgbSetScale ( int  srcW,
int  srcH 
)

Sets source width for scaling region.

Parameters
srcWSource width in pixels, scaling in X dimension disabled if set to 0
srcHSource height in pixels, scaling in Y dimension disabled if set to 0

◆ rgbToggleRegion()

void rgbToggleRegion ( RgbRegion  region,
bool  onOff 
)

Enable or disable an RGB region.

Parameters
regionRegion to alter
onOfftrue to enable a region, false to disable it

◆ sdInit()

int sdInit ( )

Initialise SD card.

Returns
0 if successful, non-zero otherwise

◆ sdIsInserted()

bool sdIsInserted ( )

Check if an SD card is physically inserted into the slot (reads the state of the mechanical switch).

Returns
true if an SD card is inserted, false otherwise

◆ sdReadBlocks()

int sdReadBlocks ( int  startBlock,
int  numberOfBlocks,
uint8_t *  dest 
)

Read blocks (512B) from SD card.

Note
Must have called sdInit first
Parameters
startBlockBlock to start reading from (i.e. address / 512)
numberOfBlocksNumber of 512B blocks to read
destPointer to memory location to store data
Returns
0 if successful, non-zero otherwise
See also
sdInit

◆ timerGet()

uint32_t timerGet ( )

Get current timer tick.

Timer ticks every 0.135uS and overflows at 0xFFFFFFFF then carries on counting.

Returns
Current timer tick

◆ timerNsSince()

unsigned int timerNsSince ( uint32_t  lastTick,
uint32_t *  storeCurrent 
)

Calculate nanoseconds elapsed since a given tick. Optionally store the current tick.

Useful for timeouts, or calculating time between frames.

Note
This function won't work correctly for periods longer than 579.82s due to timer overflow.

◆ timerSet()

uint32_t timerSet ( uint32_t  count)

Reset timer to count from specific tick.

Note
There is a bug in the MMSP2 silicon which prevents starting the timer from 0, so this function will start it from 1 if you try to pass 0.
Parameters
countTick to start counting from
Returns
Tick the timer was at before being reset

◆ timerSleepNs()

void timerSleepNs ( unsigned int  ns)

Wait for a given number of nanoseconds.

Note
This function won't work correctly if you try to wait for longer than 579.82s due to timer overflow.
Parameters
nsNanoseconds to wait

◆ uartConfigure()

void uartConfigure ( int  baudRate,
int  bitsPerFrame,
Parity  parity,
int  stopBits 
)

Configures UART parameters.

Example (115200 8N1):

uartConfigure(115200, 8, NONE, 1)

◆ uartGetc()

int uartGetc ( bool  isBlocking)

Gets a single character from UART.

Parameters
isBlockingIf true, will wait for a character to become available, otherwise will return immediately if no character is in the input buffer.
Returns
The next character from the input buffer. If non-blocking operation is used and the buffer is empty, EOF.

◆ uartPrintf()

void uartPrintf ( const char *  format,
  ... 
)

As per the standard printf, with output directly to UART.

Note
This has a maximum output buffer of 256 bytes so you may be better off using the newlib printf.

◆ uartPutc()

char uartPutc ( char  c,
bool  isBlocking 
)

Outputs a single character over UART.

Parameters
cCharacter to output
isBlockingIf true will wait until the output buffer has space for this character, will fail fast if false
Returns
The character sent if successful. If non-blocking operation is used and the buffer is full, -1.

◆ uartSetEcho()

void uartSetEcho ( bool  isEnabled)

If enabled, uartGetc will echo any character received back out to the UART. This is handy when implementing a command line interface over UART.

Parameters
isEnabledIf true, UART echoing will be enabled.

Variable Documentation

◆ arm920Data

arm920Data

Pointer to start of 16x 16-bit shared data registers. These can be written to from either CPU, but can only trigger an interrupt on the ARM920T.

◆ arm940Data

arm940Data

Pointer to start of 16x 16-bit shared data registers. These can be written to from either CPU, but can only trigger an interrupt on the ARM940T.

uartConfigure
void uartConfigure(int baudRate, int bitsPerFrame, Parity parity, int stopBits)
Configure UART parameters.
NONE
@ NONE
No parity bit.
Definition: orcus.h:47
btnStateDebounced
uint32_t btnStateDebounced()
Get current button state (debounced).
btnState
uint32_t btnState()
Get current button state.
START
#define START
Button.
Definition: orcus.h:139