LARD API
   

The LARD API is designed to implement the standard Arduino function calls but with many extra features and for the most case improved error handling.

The goal of this project is to allow Arduino code to port across to the LPC122x, it is unlikely though that a simple cut from the Arduino IDE and paste into LPCXpresso will produce code that compiles with no errors, but it should be close.

Below is a table indicating the current state of the port, the symbol means that the function has been written and at least partly debugged, no symbol means it will be written but hasn't been yet, and means it won't be written for the reason stated.

The symbol indicates a standard Arduino library function.

Obviously there are a lot of features yet to be implemented, this is definately a work in progress

Pin
pinMode()  
digitalWrite()  
digitalRead()  
pinConfig()   Set a pin's attributes, ie pullup resistor, open collector.
pinFunc()   Set a pin's function, ie GPIO, UART Rx, timer output..
pinHigh()   Drive a digital pin high.
pinLow()   Drive a digital pin low.
pinRead()   Read the value of a digital pin.
pinWrite()   Write a value to a digital pin.
pinMask()   Mask a pin from all reads and writes.
pinToggle()   Toggle the state of a digital pin.
pinSetAsDigitalInput()   Set a pin as a digital output.
pinSetAsDigitalOutput()   Set a pin as a digital input.
pinSetAsAnalogInput()   Set a pin as an analog input.
pinSetInterruptMode()   Set the pin's interrupt mode.
pinEnableInterrupt()   Enable a pin's interrupt.
pinDisableInterrupt()   Disable a pin's interrupt.
pinClearInterrupt()   Clear a pin's interrupt.
pinPort()   Get the pin's IO port.
pinPos()   Get the pin's bit position on the port.
pinXtoggle()   Fast IO to toggle a pin.
pinXhigh()   Fast IO to set a pin high.
pinXlow()   Fast IO to set a pin low.
pinGetPhysicalPin()   Get the physical pin number for a logical pin.
nativeDpins()      
       
Virtual pins
enableVpins()   Create an array of virtual pin handlers.
attachVpinHandler()   Update the array of virtual pin handlers.
vpinHigh()     Drive a virtual pin high.
vpinLow()     Drive a virtual pin low.
vpinRead()     Read the virtual of a digital pin.
vpinWrite()     Write a virtual to a digital pin.
       
Pin Group
pinGroupCreate()   Create a new pin group.
pinGroupWrite()   Write a value to a pin group.
pinGroupRead()   Read the current value of a pin group.
pinGroupInc()   Increment a pin group.
pinGroupDec()   Decrement a pin group.
pinGroupClear()   Clear all bits in pin group.
pinGroupSet()   Set all bits in pin group.
pinGroupShiftLeft()   Shift a pin group to the left.
pinGroupShiftRight()   Shift a pin group to the right.
pinGroupRotateLeft()   Rotate a pin group to the left.
pinGroupRotateRight()   Rotate a pin group to the right.
pinGroupInvert()   Perform inversion of all pin group bits.
pinGroupOR()   OR the pin group with a value.
pinGroupAND()   AND the pin group with a value.
pinGroupXOR()   XOR the pin group with a value.
       
Analog I/O
analogReference() LPC has no AREF pin or changable internal reference
analogRead() Read a 10-bit value from an ADC channel.
analogWrite()    
       
Analog comparators
       
Time
millis()  
micros()    
delay()    
delayMicroseconds()    
msTicks()   Get the current millisecond tick value.
delayMilliseconds()   Blocking delay for N milliseconds.
       
FIFO buffers
fifoXCreate()   Create a FIFO buffer.
fifoXRead()   Read an item from a buffer.
fifoXWrite()   Write an item to a buffer.
fifoXIsEmpty()   Test for an empty buffer.
fifoXgetHighwater()   Get the maximum number of items that has ever been in the buffer.
fifoXnItems()   Get the number of items currently in the buffer.
fifoPeek     Look at the next item to be read from the FIFO.
       
       
Interrupts
attachInterrupt() Bind an interrupt to a function, all 55 GPIO pins allowed.
detachInterrupt() Remove function binding from interrupt.
interrupts() Unconditional enabling of all interrupts.
noInterrupts() Unconditional disabling of all interrupts.
enableInterrupts()   Alias for ATOMIC_START.
restoreInterrupts()   Alias for ATOMIC_END.
ATOMIC_START   Save interrupt status and disable interrupts.
ATOMIC_END   Restore interrupt status.
ATOMIC()   Create an atomic code block.
forceFullInterruptScan()    
       
Events
attachEventHandler()   Bind a handler to one of about 50 system events.
detachEventHandler()   Remove function binding from an event.
       
String
stringCreate()   Create a string object.
stringLoadFromArray()   Populate a string object from a character array.
stringCopyTorArray()   Copy a string object to a character array.
stringGetCharAt()   Get the character at an offset in the string.
stringSetCharAt()      
stringCompare()   Compare two strings.
stringEqualsArray()   Compare a string with a character array.
stringAppend()   Concatenate a string and a character array.
stringEndsWith()      
stringStartsWith()      
stringIndexOf()      
stringLastIndexOf()      
stringLength()      
stringReplace()      
stringSubstring()      
stringToUpper()   Convert a string to lower case.
stringToLower()   Convert a string to upper case.
stringTrim()      
stringLeftTrim()      
stringRightTrim()      
stringGetFirstField()   Get the first field from a string based on a caller-supplied delimiter.
stringGetNextField()   Get the next field from a string based on a caller-supplied delimiter.
stringGetField()      
stringSetField()      
stringRemoveField()      
stringTranslate()   Convert individual characters in a string.
       
Button
buttonCreate()      
buttonOnPressed()      
buttonOnReleased()      
buttonWhilePressed()      
       
Finite State Machine
fsmCreate()   Create an FSM object.
fsmRaiseEvent()   Raise an FSM event.
fsmHandleEvents()   Action a defined event.
FSM_TABLE_BEGIN    
FSM_STATE_BEGIN    
FSM_ACTION    
FSM_STATE_END    
FSM_TABLE_END    
       
Async serial
serialCreate()   Create a serial object.
serialBegin()    
serialAvailable()    
serialRead()    
serialWrite()    
serialPrintString()   Send a NULL-terminated string to a serial port.
serialSetUartPins()   Set the pins used by the two UARTs.
serialWriteFifo()   Write a byte directly into the UART FIFO.
serialStartBreak()   Start a break condition on the Tx line.
serialEndBreak()   End a break condition on the Tx line.
serialSetDataLength()   Set number of data data.
serialSetStopBits()   Set number of stop bits.
serialSetBitRate()   Set the UART's bit rate.
serialSetParity()   Set parity type.
serialEnableParity()   Enable parity.
serialDisableParity()   Disable parity.
serialLoopbackOn()   Set internal Tx/Rx loopback mode.
serialLoopbackOff()   Clear internal Tx/Rx loopback mode.
serialWaitForTxToClear()   Block until all transmitted bytes have gone.
serialTxInProgress()   Report if bytes still being transmitted.
serialTxIsIdle()   Report if no bytes are being transmitted.
serialGetMaxBufferLevel()   Get the maximum number of elements that has ever been in the buffer.
serialResetMaxBufferLevel()   Reset the maximum elements counter.
serialAttachCallback()   Bind a user function to a serial event.
       
Hardware SPI (SSP on the LPCs)
spiCreate()   Create an SPI object.
spiFlush()   Flush both Rx and Tx FIFOs.
spiWrite()   Write up to 8 values into the spi FIFO.
spiExchange()   Exchange up to 8 values with a slave device,
spiRead()   Read up to 8 values from the spi FIFO.
spiEnable()   Enable the SPI hardware.
spiDisable()   Disable the SPI hardware.
spiLoopbackOn()   Set loopback mode for testing.
spiLoopbackOff()   Clear loopback mode.
spiMisoDisable()   Disable the MISO pin.
spiMisoEnable()   Enable the MISO pin.
       
Shift (software SPI)
shiftCreate()      
shiftOut32()   Shift 32 bits out a pin.
shiftOut16()   Shift 16bits out a pin.
shiftOut8()   Shift 8 bits out a pin.
shiftOutN()   Shift N (1-32) bits out a pin.
shiftOut() Shift 8 bits out a pin.
shiftIn() Shift 8 bits in from a pin.
shiftExchange32()      
shiftExchange16()      
shiftExchange8()      
shiftExchangeN()      
       
Hardware timers
hwTimerCreate()   Create a new timer object.
hwTimerAttachCallback()   Set the function to be called when a timer expires.
hwTimerSetReLoadVal()   Change a timer's reload value.
hwTimerReload()   Write the reload value into a timer's counter.
hwTimerStart()   Enable a timer.
hwTimerRestart()   Allow a stopped timer to continue counting.
hwTimerStop()   Disable a timer.
       
Hardware counter
       
PWM
       
Soft timers
swTimerCreate()   Create a new timer object.
swTimerAttachCallback()   Set the function to be called when a timer expires.
swTimerExecuteCallbacks()   Test callback flags, run callback functions that are flagged.
swTimerScan()   Scan and update all timers.
swTimerSetReLoadVal()   Change a timer's reload value.
swTimerReload()   Write the reload value into a timer's counter.
swTimerStart()   Enable a timer.
swTimerRestart()   Allow a stopped timer to continue counting.
swTimerStop()   Disable a timer.
       
I2C
       
Errors
sysErrInit()   Initailize the error stack.
sysErrRaise()   Push an error onto the error stack.
sysErrGetCount()   Get the number of errors on the error stack.
sysErrPeek()   Read the error on the top of the error stack.
sysErrRead()   Read and remove the error on the top of the error stack.
sysErrDump()   Serially dump all error codes to a pin.
TRY   Start an error-trapping block of code.
CATCH   End a block of code, call system handler if error.
CATCH_TO   End a block of code, call user handler if error.
VERIFY_STRUCTURE   Verify a structure's guard bytes.
       
Resources
resourceRecordUsage()   Record the use of a system resource.
resourceCheckForClashes()   Check for usage clashes in system resources.
resourceMask()   Hide resource from usage clash testing.
resourceUnmask()   Expose resource to usage clash testing.
       
Bits and bytes
lowByte() Return the least significant byte of a 16-bit value.
highByte() Return the second least significant byte of a 16-bit value.
bitRead() Return a bit in a value.
bitWrite() Write a bit in a value.
bitSet() Set a bit in a value.
bitClear() Clear a bit in a value.
byte0()   Return byte 0 of a 32-bit value.
byte1()   Return byte 1 of a 32-bit value.
byte2()   Return byte 2 of a 32-bit value.
byte3()   Return byte 3 of a 32-bit value.
       
Memory
safeMalloc()   Calls malloc() but only if in setup().
heapGuardInit()   Add a block of guard bytes at the top of the heap.
heapGuardCheck()   Check the heap guard bytes for corruption.
freeRamLowest()     Get the lowest amount of free RAM.
freeRam()   Get the current amount of free RAM.
stackPointer()   Get the current stack pointer.
       
Debug
debugPrintVar()   Serially dump a 32-bit value to a pin.
stackPointer()   Return the current value of stack pointer.
       
Debounce
debounceCreate()   Create the arrays used for debouncing input pins.
debouncePinRead()   Read the debounced value of a digital pin.
       
Misc
tone()    
noTone()    
pulseIn()    
map() Map a value from one range to another.
random()    
randomSeed()    
crcCalculate()     Calculate a CRC-CCITT, CRC-16 or CRC-32.
getUID()     Get the processor's Unique identifier.
nativeDpins()   Get the max number of digital IO pins on the chip.
nativeApins()   Get the max number of analog input pins on the chip.
celcius2fahrenheit()