Maple Reference Documentation

# Maple Reference Documentation: Language

This page will briefly summarize the Wiring/Arduino programming language and give some implementation details. Until it's written please see the extensive docs on the Arduino website (or follow a direct link from below).

- Unique Maple Additions
- Arduino Doc Links
- Recommended Reading

## Unique Maple Additions

`ASSERT(...)`
  The `ASSERT()` function can be very useful for basic program debugging. The function accepts a boolean (eg, `ASSERT(state == WAIT);`); zero is false and any other number is true. If the boolean is true the assertion passes and the program continues as usual. If it is false the assertion fails: the program is halted, debug information is printed to USART2, and the status LED begins to throb in intensity (it's noticably different from blinking). The debug information is printed at 9600 baud and consists of the filename and line number where the particular assertion failed.
  Including assertions in a program increases the program size. When using libmaple from the command line they can be silently disabled by setting the `MAPLE_DEBUG` variable to 0 in src/lib/util.h; in this case all assertions pass without any lost clock cycles.

## Arduino Doc Links

(this table pulled straight from http://arduino.cc/en/Reference/Extended; functions with a strike are unimplemented)

## Structure setup() loop() #### Control Structures if if...else for switch case while do... while break continue return goto #### Further Syntax ; (semicolon) {} (curly braces) // (single line comment) /* */ (multi-line comment) #define #include #### Arithmetic Operators = (assignment operator) + (addition) - (subtraction) * (multiplication) / (division) % (modulo) #### Comparison Operators == (equal to) != (not equal to) < (less than) > (greater than) <= (less than or equal to) >= (greater than or equal to) #### Boolean Operators && (and) || (or) ! (not) #### Pointer Access Operators * dereference operator & reference operator #### Bitwise Operators & (bitwise and) | (bitwise or) ^ (bitwise xor) ~ (bitwise not) << (bitshift left) >> (bitshift right) #### Compound Operators ++ (increment) -- (decrement) += (compound addition) -= (compound subtraction) *= (compound multiplication) /= (compound division) &= (compound bitwise and) |= (compound bitwise or) | ## Variables #### Constants HIGH | LOW INPUT | OUTPUT true | false integer constants floating point constants #### Data Types void boolean char unsigned char byte int unsigned int word long unsigned long float double string array #### Conversion char() byte() int() word() long() float() #### Variable Scope & Qualifiers variable scope static volatile const #### Utilities sizeof() (sizeof operator) | ## Functions Digital I/O pinMode() digitalWrite() digitalRead() Analog I/O analogReference() analogRead() analogWrite() - PWM Advanced I/O tone() noTone() shiftOut() pulseIn() Time millis() micros() delay() delayMicroseconds() Math min() max() abs() constrain() map() pow() sqrt() Trigonometry sin() cos() tan() Random Numbers randomSeed() random() Bits and Bytes lowByte() highByte() bitRead() bitWrite() bitSet() bitClear() bit() External Interrupts attachInterrupt() detachInterrupt() Interrupts interrupts() noInterrupts() Communication Serial Looking for something else? Try the list of community-contributed code.

## Recommended Reading

- newlib Documentation
- STMicro documentation for STM32F103RB microcontroller:
  - All
  - Datasheet (pdf)
  - Reference Manual (pdf)
  - Programming Manual (pdf) (assembler instruction and register reference)

### About this Document

A more recent version of this document may be available from the LeafLabs website. Our documentation is versioned on github; you can track changes to the master branch at this link.

This documentation is released under a Creative Commons Attribution-Share Alike 3.0 license.

Translations are welcomed; give us a ping to make sure we aren't in the process of revising or editing first.