diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index aedb3d84..dd2c5ae5 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -163,6 +163,9 @@ ".json", ".lock" ], + "JSON5": [ + ".json5" + ], "Julia": [ ".jl" ], @@ -509,8 +512,8 @@ ".gemrc" ] }, - "tokens_total": 428226, - "languages_total": 503, + "tokens_total": 436793, + "languages_total": 508, "tokens": { "ABAP": { "*/**": 1, @@ -8560,179 +8563,1650 @@ "C++": { "class": 40, "Bar": 2, - "{": 562, + "{": 580, "protected": 4, - "char": 126, + "char": 127, "*name": 6, - ";": 2383, + ";": 2471, "public": 33, - "void": 169, + "void": 225, "hello": 2, - "(": 2498, - ")": 2500, - "}": 562, - "#pragma": 2, - "once": 2, - "#include": 117, + "(": 2729, + ")": 2731, + "}": 580, + "//": 278, + "///": 843, + "mainpage": 1, + "C": 6, + "library": 14, + "for": 98, + "Broadcom": 3, + "BCM": 14, + "as": 28, + "used": 17, + "in": 165, + "Raspberry": 6, + "Pi": 5, + "This": 18, + "is": 100, + "a": 156, + "RPi": 17, + ".": 16, + "It": 7, + "provides": 3, + "access": 17, + "to": 253, + "GPIO": 87, + "and": 118, + "other": 17, + "IO": 2, + "functions": 19, + "on": 55, + "the": 537, + "chip": 9, + "allowing": 3, + "pins": 40, + "pin": 90, + "IDE": 4, + "plug": 3, + "board": 2, + "so": 2, + "you": 29, + "can": 21, + "control": 17, + "interface": 9, + "with": 32, + "various": 4, + "external": 3, + "devices.": 1, + "reading": 3, + "digital": 2, + "inputs": 2, + "setting": 2, + "outputs": 1, + "using": 11, + "SPI": 44, + "I2C": 29, + "accessing": 2, + "system": 9, + "timers.": 1, + "Pin": 65, + "event": 3, + "detection": 2, + "supported": 3, + "by": 53, + "polling": 1, + "interrupts": 1, + "are": 36, + "not": 26, + "+": 60, + "compatible": 1, + "installs": 1, + "header": 7, + "file": 31, + "non": 2, + "-": 349, + "shared": 2, + "any": 23, + "Linux": 2, + "based": 4, + "distro": 1, + "but": 5, + "clearly": 1, + "no": 7, + "use": 34, + "except": 2, + "or": 44, + "another": 1, + "The": 50, + "version": 38, + "of": 211, + "package": 1, + "that": 33, + "this": 52, + "documentation": 3, + "refers": 1, + "be": 35, + "downloaded": 1, + "from": 91, + "http": 11, + "//www.airspayce.com/mikem/bcm2835/bcm2835": 1, + "tar.gz": 1, + "You": 9, + "find": 2, + "latest": 2, + "at": 20, + "//www.airspayce.com/mikem/bcm2835": 1, + "Several": 1, + "example": 3, + "programs": 4, + "provided.": 1, + "Based": 1, + "data": 26, + "//elinux.org/RPi_Low": 1, + "level_peripherals": 1, + "//www.raspberrypi.org/wp": 1, + "content/uploads/2012/02/BCM2835": 1, + "ARM": 5, + "Peripherals.pdf": 1, + "//www.scribd.com/doc/101830961/GPIO": 2, + "Pads": 3, + "Control2": 2, + "also": 3, + "online": 1, + "help": 1, + "discussion": 1, + "//groups.google.com/group/bcm2835": 1, + "Please": 4, + "group": 23, + "all": 11, + "questions": 1, + "discussions": 1, + "topic.": 1, + "Do": 1, + "contact": 1, + "author": 3, + "directly": 2, + "unless": 1, + "it": 19, + "discuss": 1, + "commercial": 1, + "licensing.": 1, + "Tested": 1, + "debian6": 1, + "wheezy": 3, + "raspbian": 3, + "Occidentalisv01": 2, + "CAUTION": 1, + "has": 29, + "been": 14, + "observed": 1, + "when": 22, + "detect": 3, + "enables": 3, + "such": 4, + "bcm2835_gpio_len": 5, + "pulled": 1, + "LOW": 8, + "cause": 1, + "temporary": 1, + "hangs": 1, + "Occidentalisv01.": 1, + "Reason": 1, + "yet": 1, + "determined": 1, + "suspect": 1, + "an": 23, + "interrupt": 1, + "handler": 1, + "hitting": 1, + "hard": 1, + "loop": 2, + "those": 3, + "OSs.": 1, + "If": 11, + "must": 6, + "friends": 2, + "make": 6, + "sure": 3, + "disable": 2, + "bcm2835_gpio_cler_len": 1, + "after": 18, + "use.": 1, + "par": 9, + "Installation": 1, + "consists": 1, + "single": 2, + "which": 14, + "will": 15, + "installed": 1, + "usual": 3, + "places": 1, + "install": 3, + "code": 12, + "#": 1, + "download": 2, + "say": 1, + "bcm2835": 7, + "xx.tar.gz": 2, + "then": 15, + "tar": 1, + "zxvf": 1, + "cd": 1, + "xx": 2, + "./configure": 1, + "sudo": 2, + "check": 3, + "endcode": 2, + "Physical": 21, + "Addresses": 6, + "bcm2835_peri_read": 3, + "bcm2835_peri_write": 3, + "bcm2835_peri_set_bits": 2, + "low": 2, + "level": 10, + "peripheral": 14, + "register": 17, + "functions.": 4, + "They": 1, + "designed": 3, + "physical": 4, + "addresses": 4, + "described": 1, + "section": 6, + "BCM2835": 2, + "Peripherals": 1, + "manual.": 1, + "range": 3, + "FFFFFF": 1, + "peripherals.": 1, + "bus": 4, + "peripherals": 2, + "set": 18, + "up": 18, + "map": 3, + "onto": 1, + "address": 13, + "starting": 1, + "E000000.": 1, + "Thus": 1, + "advertised": 1, + "manual": 8, + "Ennnnnn": 1, + "available": 6, + "nnnnnn.": 1, + "base": 4, + "registers": 12, + "following": 2, + "externals": 1, + "bcm2835_gpio": 2, + "bcm2835_pwm": 2, + "bcm2835_clk": 2, + "bcm2835_pads": 2, + "bcm2835_spio0": 1, + "bcm2835_st": 1, + "bcm2835_bsc0": 1, + "bcm2835_bsc1": 1, + "Numbering": 1, + "numbering": 1, + "different": 5, + "inconsistent": 1, + "underlying": 4, + "numbering.": 1, + "//elinux.org/RPi_BCM2835_GPIOs": 1, + "some": 4, + "well": 1, + "power": 1, + "ground": 1, + "pins.": 1, + "Not": 4, + "header.": 1, + "Version": 40, + "P5": 6, + "connector": 1, + "V": 2, + "Gnd.": 1, + "passed": 4, + "number": 52, + "_not_": 1, + "number.": 1, + "There": 1, + "symbolic": 1, + "definitions": 3, + "each": 7, + "should": 10, + "convenience.": 1, + "See": 7, + "ref": 32, + "RPiGPIOPin.": 22, + "Pins": 2, + "bcm2835_spi_*": 1, + "allow": 5, + "SPI0": 17, + "send": 3, + "received": 3, + "Serial": 3, + "Peripheral": 6, + "Interface": 2, + "For": 6, + "more": 4, + "information": 3, + "about": 6, + "see": 14, + "//en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus": 1, + "When": 12, + "bcm2835_spi_begin": 3, + "called": 13, + "changes": 2, + "bahaviour": 1, + "their": 6, + "default": 14, + "behaviour": 1, + "order": 14, + "support": 4, + "SPI.": 1, + "While": 1, + "able": 2, + "state": 22, + "through": 4, + "bcm2835_spi_gpio_write": 1, + "bcm2835_spi_end": 4, + "revert": 1, + "configured": 1, + "controled": 1, + "bcm2835_gpio_*": 1, + "calls.": 1, + "P1": 56, + "MOSI": 8, + "MISO": 6, + "CLK": 6, + "CE0": 5, + "CE1": 6, + "bcm2835_i2c_*": 2, + "BSC": 10, + "generically": 1, + "referred": 1, + "I": 4, + "//en.wikipedia.org/wiki/I": 1, + "%": 6, + "C2": 1, + "B2C": 1, + "V2": 2, + "SDA": 3, + "SLC": 1, + "Real": 1, + "Time": 1, + "performance": 2, + "constraints": 2, + "user": 3, + "i.e.": 1, + "they": 2, + "run": 1, + "Such": 1, + "part": 1, + "kernel": 4, + "usually": 2, + "subject": 1, + "paging": 1, + "swapping": 2, + "while": 12, + "does": 4, + "things": 1, + "besides": 1, + "running": 1, + "your": 12, + "program.": 1, + "means": 8, + "expect": 2, + "get": 5, + "real": 4, + "time": 10, + "timing": 3, + "programs.": 1, + "In": 2, + "particular": 1, + "there": 4, + "guarantee": 1, + "bcm2835_delay": 5, + "bcm2835_delayMicroseconds": 6, + "return": 164, + "exactly": 2, + "requested.": 1, + "fact": 2, + "depending": 1, + "activity": 1, + "host": 1, + "etc": 1, + "might": 1, + "significantly": 1, + "longer": 1, + "delay": 9, + "times": 2, + "than": 5, + "one": 73, + "asked": 1, + "for.": 1, + "So": 1, + "please": 2, + "dont": 1, + "request.": 1, + "Arjan": 2, + "reports": 1, + "prevent": 4, + "fragment": 2, + "struct": 12, + "sched_param": 1, + "sp": 4, + "memset": 3, + "&": 149, + "sizeof": 15, + "sp.sched_priority": 1, + "sched_get_priority_max": 1, + "SCHED_FIFO": 2, + "sched_setscheduler": 1, + "mlockall": 1, + "MCL_CURRENT": 1, + "|": 14, + "MCL_FUTURE": 1, + "Open": 2, + "Source": 2, + "Licensing": 2, + "GPL": 2, + "appropriate": 7, + "option": 1, + "if": 306, + "want": 5, + "share": 2, + "source": 12, + "application": 2, + "everyone": 1, + "distribute": 1, + "give": 2, + "them": 1, + "right": 9, + "who": 1, + "uses": 4, + "it.": 3, + "wish": 2, + "software": 1, + "under": 2, + "contribute": 1, + "open": 6, + "community": 1, + "accordance": 1, + "distributed.": 1, + "//www.gnu.org/copyleft/gpl.html": 1, + "COPYING": 1, + "Acknowledgements": 1, + "Some": 1, + "inspired": 2, + "Dom": 1, + "Gert.": 1, + "Alan": 1, + "Barr.": 1, + "Revision": 1, + "History": 1, + "Initial": 1, + "release": 1, + "Minor": 1, + "bug": 1, + "fixes": 1, + "Added": 11, + "bcm2835_spi_transfern": 3, + "Fixed": 4, + "problem": 2, + "prevented": 1, + "being": 4, + "used.": 2, + "Reported": 5, + "David": 1, + "Robinson.": 1, + "bcm2835_close": 4, + "deinit": 1, + "library.": 3, + "Suggested": 1, + "sar": 1, + "Ortiz": 1, + "Document": 1, + "testing": 1, + "Functions": 1, + "bcm2835_gpio_ren": 3, + "bcm2835_gpio_fen": 3, + "bcm2835_gpio_hen": 3, + "bcm2835_gpio_aren": 3, + "bcm2835_gpio_afen": 3, + "now": 4, + "only": 6, + "specified.": 1, + "Other": 1, + "were": 1, + "already": 1, + "previously": 10, + "enabled": 4, + "stay": 1, + "enabled.": 1, + "bcm2835_gpio_clr_ren": 2, + "bcm2835_gpio_clr_fen": 2, + "bcm2835_gpio_clr_hen": 2, + "bcm2835_gpio_clr_len": 2, + "bcm2835_gpio_clr_aren": 2, + "bcm2835_gpio_clr_afen": 2, + "clear": 3, + "enable": 3, + "individual": 1, + "suggested": 3, + "Andreas": 1, + "Sundstrom.": 1, + "bcm2835_spi_transfernb": 2, + "buffers": 3, + "read": 21, + "write.": 1, + "Improvements": 3, + "barrier": 3, + "maddin.": 1, + "contributed": 1, + "mikew": 1, + "noticed": 1, + "was": 6, + "mallocing": 1, + "memory": 14, + "mmaps": 1, + "/dev/mem.": 1, + "ve": 4, + "removed": 1, + "mallocs": 1, + "frees": 1, + "found": 1, + "calling": 8, + "nanosleep": 7, + "takes": 1, + "least": 2, + "us.": 1, + "need": 3, + "link": 3, + "version.": 1, + "s": 18, + "doc": 1, + "Also": 1, + "added": 2, + "define": 2, + "passwrd": 1, + "value": 50, + "Gert": 1, + "says": 1, + "needed": 3, + "change": 3, + "pad": 4, + "settings.": 1, + "Changed": 1, + "names": 3, + "collisions": 1, + "wiringPi.": 1, + "Macros": 2, + "delayMicroseconds": 3, + "disabled": 2, + "defining": 1, + "BCM2835_NO_DELAY_COMPATIBILITY": 2, + "incorrect": 2, + "New": 6, + "mapping": 3, + "Hardware": 1, + "pointers": 2, + "initialisation": 2, + "externally": 1, + "bcm2835_spi0.": 1, + "Now": 4, + "compiles": 1, + "even": 2, + "CLOCK_MONOTONIC_RAW": 1, + "CLOCK_MONOTONIC": 1, + "instead.": 1, + "errors": 1, + "divider": 15, + "frequencies": 2, + "MHz": 14, + "clock.": 6, + "Ben": 1, + "Simpson.": 1, + "end": 23, + "examples": 1, + "Mark": 5, + "Wolfe.": 1, + "bcm2835_gpio_set_multi": 2, + "bcm2835_gpio_clr_multi": 2, + "bcm2835_gpio_write_multi": 4, + "mask": 20, + "once.": 1, + "Requested": 2, + "Sebastian": 2, + "Loncar.": 2, + "bcm2835_gpio_write_mask.": 1, + "Changes": 1, + "timer": 2, + "counter": 1, + "instead": 1, + "clock_gettime": 1, + "improved": 1, + "accuracy.": 1, + "No": 2, + "lrt": 1, + "now.": 1, + "Contributed": 1, + "van": 1, + "Vught.": 1, + "Removed": 1, + "inlines": 1, + "previous": 6, + "patch": 1, + "since": 3, + "don": 1, + "t": 15, + "seem": 1, + "work": 1, + "everywhere.": 1, + "olly.": 1, + "Patch": 2, + "Dootson": 2, + "close": 3, + "/dev/mem": 4, + "granted.": 1, + "susceptible": 1, + "bit": 19, + "overruns.": 1, + "courtesy": 1, + "Jeremy": 1, + "Mortis.": 1, + "definition": 3, + "BCM2835_GPFEN0": 2, + "broke": 1, + "ability": 1, + "falling": 4, + "edge": 8, + "events.": 1, + "Dootson.": 2, + "bcm2835_i2c_set_baudrate": 2, + "bcm2835_i2c_read_register_rs.": 1, + "bcm2835_i2c_read": 4, + "bcm2835_i2c_write": 4, + "fix": 1, + "ocasional": 1, + "reads": 2, + "completing.": 1, + "Patched": 1, + "p": 6, + "[": 274, + "atched": 1, + "his": 1, + "submitted": 1, + "high": 1, + "load": 1, + "processes.": 1, + "Updated": 1, + "distribution": 1, + "location": 6, + "details": 1, + "airspayce.com": 1, + "missing": 1, + "unmapmem": 1, + "pads": 7, + "leak.": 1, + "Hartmut": 1, + "Henkel.": 1, + "Mike": 1, + "McCauley": 1, + "mikem@airspayce.com": 1, + "DO": 1, + "NOT": 3, + "CONTACT": 1, + "THE": 2, + "AUTHOR": 1, + "DIRECTLY": 1, + "USE": 1, + "LISTS": 1, + "#ifndef": 27, + "BCM2835_H": 3, + "#define": 341, + "#include": 120, + "": 2, + "defgroup": 7, + "constants": 1, + "Constants": 1, + "passing": 1, + "values": 3, + "here": 1, + "@": 14, + "HIGH": 12, + "true": 41, + "volts": 2, + "pin.": 21, + "false": 45, + "Speed": 1, + "core": 1, + "clock": 21, + "core_clk": 1, + "BCM2835_CORE_CLK_HZ": 1, + "<": 247, + "Base": 17, + "Address": 10, + "BCM2835_PERI_BASE": 9, + "System": 10, + "Timer": 9, + "BCM2835_ST_BASE": 1, + "BCM2835_GPIO_PADS": 2, + "Clock/timer": 1, + "BCM2835_CLOCK_BASE": 1, + "BCM2835_GPIO_BASE": 6, + "BCM2835_SPI0_BASE": 1, + "BSC0": 2, + "BCM2835_BSC0_BASE": 1, + "PWM": 2, + "BCM2835_GPIO_PWM": 1, + "C000": 1, + "BSC1": 2, + "BCM2835_BSC1_BASE": 1, + "ST": 1, + "registers.": 10, + "Available": 8, + "bcm2835_init": 11, + "extern": 72, + "volatile": 13, + "uint32_t": 37, + "*bcm2835_st": 1, + "*bcm2835_gpio": 1, + "*bcm2835_pwm": 1, + "*bcm2835_clk": 1, + "PADS": 1, + "*bcm2835_pads": 1, + "*bcm2835_spi0": 1, + "*bcm2835_bsc0": 1, + "*bcm2835_bsc1": 1, + "Size": 2, + "page": 5, + "BCM2835_PAGE_SIZE": 1, + "*1024": 2, + "block": 4, + "BCM2835_BLOCK_SIZE": 1, + "offsets": 2, + "BCM2835_GPIO_BASE.": 1, + "Offsets": 1, + "into": 6, + "bytes": 29, + "per": 3, + "Register": 1, + "View": 1, + "BCM2835_GPFSEL0": 1, + "Function": 8, + "Select": 49, + "BCM2835_GPFSEL1": 1, + "BCM2835_GPFSEL2": 1, + "BCM2835_GPFSEL3": 1, + "c": 62, + "BCM2835_GPFSEL4": 1, + "BCM2835_GPFSEL5": 1, + "BCM2835_GPSET0": 1, + "Output": 6, + "Set": 2, + "BCM2835_GPSET1": 1, + "BCM2835_GPCLR0": 1, + "Clear": 18, + "BCM2835_GPCLR1": 1, + "BCM2835_GPLEV0": 1, + "Level": 2, + "BCM2835_GPLEV1": 1, + "BCM2835_GPEDS0": 1, + "Event": 11, + "Detect": 35, + "Status": 6, + "BCM2835_GPEDS1": 1, + "BCM2835_GPREN0": 1, + "Rising": 8, + "Edge": 16, + "Enable": 38, + "BCM2835_GPREN1": 1, + "Falling": 8, + "BCM2835_GPFEN1": 1, + "BCM2835_GPHEN0": 1, + "High": 4, + "BCM2835_GPHEN1": 1, + "BCM2835_GPLEN0": 1, + "Low": 5, + "BCM2835_GPLEN1": 1, + "BCM2835_GPAREN0": 1, + "Async.": 4, + "BCM2835_GPAREN1": 1, + "BCM2835_GPAFEN0": 1, + "BCM2835_GPAFEN1": 1, + "BCM2835_GPPUD": 1, + "Pull": 11, + "up/down": 10, + "BCM2835_GPPUDCLK0": 1, + "Clock": 11, + "BCM2835_GPPUDCLK1": 1, + "brief": 12, + "bcm2835PortFunction": 1, + "Port": 1, + "function": 18, + "select": 9, + "modes": 1, + "bcm2835_gpio_fsel": 2, + "typedef": 50, + "enum": 17, + "BCM2835_GPIO_FSEL_INPT": 1, + "b000": 1, + "Input": 2, + "BCM2835_GPIO_FSEL_OUTP": 1, + "b001": 1, + "BCM2835_GPIO_FSEL_ALT0": 1, + "b100": 1, + "Alternate": 6, + "BCM2835_GPIO_FSEL_ALT1": 1, + "b101": 1, + "BCM2835_GPIO_FSEL_ALT2": 1, + "b110": 1, + "BCM2835_GPIO_FSEL_ALT3": 1, + "b111": 2, + "BCM2835_GPIO_FSEL_ALT4": 1, + "b011": 1, + "BCM2835_GPIO_FSEL_ALT5": 1, + "b010": 1, + "BCM2835_GPIO_FSEL_MASK": 1, + "bits": 11, + "bcm2835FunctionSelect": 2, + "bcm2835PUDControl": 4, + "Pullup/Pulldown": 1, + "defines": 3, + "bcm2835_gpio_pud": 5, + "BCM2835_GPIO_PUD_OFF": 1, + "b00": 1, + "Off": 3, + "pull": 1, + "BCM2835_GPIO_PUD_DOWN": 1, + "b01": 1, + "Down": 1, + "BCM2835_GPIO_PUD_UP": 1, + "b10": 1, + "Up": 1, + "Pad": 11, + "BCM2835_PADS_GPIO_0_27": 1, + "BCM2835_PADS_GPIO_28_45": 1, + "BCM2835_PADS_GPIO_46_53": 1, + "Control": 6, + "masks": 1, + "BCM2835_PAD_PASSWRD": 1, + "A": 7, + "<<": 29, + "Password": 1, + "BCM2835_PAD_SLEW_RATE_UNLIMITED": 1, + "Slew": 1, + "rate": 3, + "unlimited": 1, + "BCM2835_PAD_HYSTERESIS_ENABLED": 1, + "Hysteresis": 1, + "BCM2835_PAD_DRIVE_2mA": 1, + "mA": 8, + "drive": 8, + "current": 26, + "BCM2835_PAD_DRIVE_4mA": 1, + "BCM2835_PAD_DRIVE_6mA": 1, + "BCM2835_PAD_DRIVE_8mA": 1, + "BCM2835_PAD_DRIVE_10mA": 1, + "BCM2835_PAD_DRIVE_12mA": 1, + "BCM2835_PAD_DRIVE_14mA": 1, + "BCM2835_PAD_DRIVE_16mA": 1, + "bcm2835PadGroup": 4, + "specification": 1, + "bcm2835_gpio_pad": 2, + "BCM2835_PAD_GROUP_GPIO_0_27": 1, + "BCM2835_PAD_GROUP_GPIO_28_45": 1, + "BCM2835_PAD_GROUP_GPIO_46_53": 1, + "Numbers": 1, + "Here": 1, + "we": 4, + "terms": 4, + "numbers.": 1, + "These": 6, + "requiring": 1, + "bin": 1, + "connected": 1, + "adopt": 1, + "alternate": 7, + "function.": 3, + "slightly": 1, + "pinouts": 1, + "these": 1, + "RPI_V2_*.": 1, + "At": 1, + "bootup": 1, + "UART0_TXD": 3, + "UART0_RXD": 3, + "ie": 3, + "alt0": 1, + "respectively": 1, + "dedicated": 1, + "cant": 1, + "controlled": 1, + "independently": 1, + "RPI_GPIO_P1_03": 6, + "RPI_GPIO_P1_05": 6, + "RPI_GPIO_P1_07": 1, + "RPI_GPIO_P1_08": 1, + "defaults": 4, + "alt": 4, + "RPI_GPIO_P1_10": 1, + "RPI_GPIO_P1_11": 1, + "RPI_GPIO_P1_12": 1, + "RPI_GPIO_P1_13": 1, + "RPI_GPIO_P1_15": 1, + "RPI_GPIO_P1_16": 1, + "RPI_GPIO_P1_18": 1, + "RPI_GPIO_P1_19": 1, + "RPI_GPIO_P1_21": 1, + "RPI_GPIO_P1_22": 1, + "RPI_GPIO_P1_23": 1, + "RPI_GPIO_P1_24": 1, + "RPI_GPIO_P1_26": 1, + "RPI_V2_GPIO_P1_03": 1, + "RPI_V2_GPIO_P1_05": 1, + "RPI_V2_GPIO_P1_07": 1, + "RPI_V2_GPIO_P1_08": 1, + "RPI_V2_GPIO_P1_10": 1, + "RPI_V2_GPIO_P1_11": 1, + "RPI_V2_GPIO_P1_12": 1, + "RPI_V2_GPIO_P1_13": 1, + "RPI_V2_GPIO_P1_15": 1, + "RPI_V2_GPIO_P1_16": 1, + "RPI_V2_GPIO_P1_18": 1, + "RPI_V2_GPIO_P1_19": 1, + "RPI_V2_GPIO_P1_21": 1, + "RPI_V2_GPIO_P1_22": 1, + "RPI_V2_GPIO_P1_23": 1, + "RPI_V2_GPIO_P1_24": 1, + "RPI_V2_GPIO_P1_26": 1, + "RPI_V2_GPIO_P5_03": 1, + "RPI_V2_GPIO_P5_04": 1, + "RPI_V2_GPIO_P5_05": 1, + "RPI_V2_GPIO_P5_06": 1, + "RPiGPIOPin": 1, + "BCM2835_SPI0_CS": 1, + "Master": 12, + "BCM2835_SPI0_FIFO": 1, + "TX": 5, + "RX": 7, + "FIFOs": 1, + "BCM2835_SPI0_CLK": 1, + "Divider": 2, + "BCM2835_SPI0_DLEN": 1, + "Data": 9, + "Length": 2, + "BCM2835_SPI0_LTOH": 1, + "LOSSI": 1, + "mode": 24, + "TOH": 1, + "BCM2835_SPI0_DC": 1, + "DMA": 3, + "DREQ": 1, + "Controls": 1, + "BCM2835_SPI0_CS_LEN_LONG": 1, + "Long": 1, + "word": 7, + "Lossi": 2, + "DMA_LEN": 1, + "BCM2835_SPI0_CS_DMA_LEN": 1, + "BCM2835_SPI0_CS_CSPOL2": 1, + "Chip": 9, + "Polarity": 5, + "BCM2835_SPI0_CS_CSPOL1": 1, + "BCM2835_SPI0_CS_CSPOL0": 1, + "BCM2835_SPI0_CS_RXF": 1, + "RXF": 2, + "FIFO": 25, + "Full": 1, + "BCM2835_SPI0_CS_RXR": 1, + "RXR": 3, + "needs": 3, + "Reading": 1, + "full": 9, + "BCM2835_SPI0_CS_TXD": 1, + "TXD": 2, + "accept": 2, + "BCM2835_SPI0_CS_RXD": 1, + "RXD": 2, + "contains": 2, + "BCM2835_SPI0_CS_DONE": 1, + "Done": 3, + "transfer": 8, + "BCM2835_SPI0_CS_TE_EN": 1, + "Unused": 2, + "BCM2835_SPI0_CS_LMONO": 1, + "BCM2835_SPI0_CS_LEN": 1, + "LEN": 1, + "LoSSI": 1, + "BCM2835_SPI0_CS_REN": 1, + "REN": 1, + "Read": 3, + "BCM2835_SPI0_CS_ADCS": 1, + "ADCS": 1, + "Automatically": 1, + "Deassert": 1, + "BCM2835_SPI0_CS_INTR": 1, + "INTR": 1, + "Interrupt": 5, + "BCM2835_SPI0_CS_INTD": 1, + "INTD": 1, + "BCM2835_SPI0_CS_DMAEN": 1, + "DMAEN": 1, + "BCM2835_SPI0_CS_TA": 1, + "Transfer": 3, + "Active": 2, + "BCM2835_SPI0_CS_CSPOL": 1, + "BCM2835_SPI0_CS_CLEAR": 1, + "BCM2835_SPI0_CS_CLEAR_RX": 1, + "BCM2835_SPI0_CS_CLEAR_TX": 1, + "BCM2835_SPI0_CS_CPOL": 1, + "BCM2835_SPI0_CS_CPHA": 1, + "Phase": 1, + "BCM2835_SPI0_CS_CS": 1, + "bcm2835SPIBitOrder": 3, + "Bit": 1, + "Specifies": 5, + "ordering": 4, + "bcm2835_spi_setBitOrder": 2, + "BCM2835_SPI_BIT_ORDER_LSBFIRST": 1, + "LSB": 1, + "First": 2, + "BCM2835_SPI_BIT_ORDER_MSBFIRST": 1, + "MSB": 1, + "Specify": 2, + "bcm2835_spi_setDataMode": 2, + "BCM2835_SPI_MODE0": 1, + "CPOL": 4, + "CPHA": 4, + "BCM2835_SPI_MODE1": 1, + "BCM2835_SPI_MODE2": 1, + "BCM2835_SPI_MODE3": 1, + "bcm2835SPIMode": 2, + "bcm2835SPIChipSelect": 3, + "BCM2835_SPI_CS0": 1, + "BCM2835_SPI_CS1": 1, + "BCM2835_SPI_CS2": 1, + "CS1": 1, + "CS2": 1, + "asserted": 3, + "BCM2835_SPI_CS_NONE": 1, + "CS": 5, + "yourself": 1, + "bcm2835SPIClockDivider": 3, + "generate": 2, + "Figures": 1, + "below": 1, + "period": 1, + "frequency.": 1, + "divided": 2, + "nominal": 2, + "reported": 2, + "contrary": 1, + "may": 9, + "shown": 1, + "have": 4, + "confirmed": 1, + "measurement": 2, + "BCM2835_SPI_CLOCK_DIVIDER_65536": 1, + "us": 12, + "kHz": 10, + "BCM2835_SPI_CLOCK_DIVIDER_32768": 1, + "BCM2835_SPI_CLOCK_DIVIDER_16384": 1, + "BCM2835_SPI_CLOCK_DIVIDER_8192": 1, + "/51757813kHz": 1, + "BCM2835_SPI_CLOCK_DIVIDER_4096": 1, + "BCM2835_SPI_CLOCK_DIVIDER_2048": 1, + "BCM2835_SPI_CLOCK_DIVIDER_1024": 1, + "BCM2835_SPI_CLOCK_DIVIDER_512": 1, + "BCM2835_SPI_CLOCK_DIVIDER_256": 1, + "BCM2835_SPI_CLOCK_DIVIDER_128": 1, + "ns": 9, + "BCM2835_SPI_CLOCK_DIVIDER_64": 1, + "BCM2835_SPI_CLOCK_DIVIDER_32": 1, + "BCM2835_SPI_CLOCK_DIVIDER_16": 1, + "BCM2835_SPI_CLOCK_DIVIDER_8": 1, + "BCM2835_SPI_CLOCK_DIVIDER_4": 1, + "BCM2835_SPI_CLOCK_DIVIDER_2": 1, + "fastest": 1, + "BCM2835_SPI_CLOCK_DIVIDER_1": 1, + "same": 3, + "/65536": 1, + "BCM2835_BSC_C": 1, + "BCM2835_BSC_S": 1, + "BCM2835_BSC_DLEN": 1, + "BCM2835_BSC_A": 1, + "Slave": 1, + "BCM2835_BSC_FIFO": 1, + "BCM2835_BSC_DIV": 1, + "BCM2835_BSC_DEL": 1, + "Delay": 4, + "BCM2835_BSC_CLKT": 1, + "Stretch": 2, + "Timeout": 2, + "BCM2835_BSC_C_I2CEN": 1, + "BCM2835_BSC_C_INTR": 1, + "BCM2835_BSC_C_INTT": 1, + "BCM2835_BSC_C_INTD": 1, + "DONE": 2, + "BCM2835_BSC_C_ST": 1, + "Start": 4, + "new": 13, + "BCM2835_BSC_C_CLEAR_1": 1, + "BCM2835_BSC_C_CLEAR_2": 1, + "BCM2835_BSC_C_READ": 1, + "BCM2835_BSC_S_CLKT": 1, + "stretch": 1, + "timeout": 1, + "BCM2835_BSC_S_ERR": 1, + "ACK": 1, + "error": 2, + "BCM2835_BSC_S_RXF": 1, + "BCM2835_BSC_S_TXE": 1, + "TXE": 1, + "BCM2835_BSC_S_RXD": 1, + "BCM2835_BSC_S_TXD": 1, + "BCM2835_BSC_S_RXR": 1, + "BCM2835_BSC_S_TXW": 1, + "TXW": 1, + "writing": 2, + "BCM2835_BSC_S_DONE": 1, + "BCM2835_BSC_S_TA": 1, + "BCM2835_BSC_FIFO_SIZE": 1, + "size": 13, + "bcm2835I2CClockDivider": 3, + "BCM2835_I2C_CLOCK_DIVIDER_2500": 1, + "BCM2835_I2C_CLOCK_DIVIDER_626": 1, + "BCM2835_I2C_CLOCK_DIVIDER_150": 1, + "reset": 1, + "BCM2835_I2C_CLOCK_DIVIDER_148": 1, + "bcm2835I2CReasonCodes": 5, + "reason": 4, + "codes": 1, + "BCM2835_I2C_REASON_OK": 1, + "Success": 1, + "BCM2835_I2C_REASON_ERROR_NACK": 1, + "Received": 4, + "NACK": 1, + "BCM2835_I2C_REASON_ERROR_CLKT": 1, + "BCM2835_I2C_REASON_ERROR_DATA": 1, + "sent": 1, + "/": 14, + "BCM2835_ST_CS": 1, + "Control/Status": 1, + "BCM2835_ST_CLO": 1, + "Counter": 4, + "Lower": 2, + "BCM2835_ST_CHI": 1, + "Upper": 1, + "BCM2835_PWM_CONTROL": 1, + "BCM2835_PWM_STATUS": 1, + "BCM2835_PWM0_RANGE": 1, + "BCM2835_PWM0_DATA": 1, + "BCM2835_PWM1_RANGE": 1, + "BCM2835_PWM1_DATA": 1, + "BCM2835_PWMCLK_CNTL": 1, + "BCM2835_PWMCLK_DIV": 1, + "BCM2835_PWM1_MS_MODE": 1, + "Run": 4, + "MS": 2, + "BCM2835_PWM1_USEFIFO": 1, + "BCM2835_PWM1_REVPOLAR": 1, + "Reverse": 2, + "polarity": 3, + "BCM2835_PWM1_OFFSTATE": 1, + "Ouput": 2, + "BCM2835_PWM1_REPEATFF": 1, + "Repeat": 2, + "last": 6, + "empty": 2, + "BCM2835_PWM1_SERIAL": 1, + "serial": 2, + "BCM2835_PWM1_ENABLE": 1, + "Channel": 2, + "BCM2835_PWM0_MS_MODE": 1, + "BCM2835_PWM0_USEFIFO": 1, + "BCM2835_PWM0_REVPOLAR": 1, + "BCM2835_PWM0_OFFSTATE": 1, + "BCM2835_PWM0_REPEATFF": 1, + "BCM2835_PWM0_SERIAL": 1, + "BCM2835_PWM0_ENABLE": 1, + "x": 48, + "#endif": 89, + "#ifdef": 19, + "__cplusplus": 12, + "init": 2, + "Library": 1, + "management": 1, + "intialise": 1, + "Initialise": 1, + "opening": 1, + "getting": 1, + "internal": 47, + "device": 7, + "call": 4, + "successfully": 1, + "before": 7, + "bcm2835_set_debug": 2, + "fails": 1, + "returning": 1, + "result": 2, + "crashes": 1, + "failures.": 1, + "Prints": 1, + "messages": 1, + "stderr": 1, + "case": 34, + "errors.": 1, + "successful": 2, + "else": 48, + "int": 161, + "Close": 1, + "deallocating": 1, + "allocated": 2, + "closing": 1, + "Sets": 24, + "debug": 6, + "prevents": 1, + "makes": 1, + "print": 5, + "out": 5, + "what": 2, + "would": 2, + "do": 9, + "rather": 2, + "causes": 1, + "normal": 1, + "operation.": 2, + "Call": 2, + "param": 72, + "]": 273, + "level.": 3, + "uint8_t": 43, + "lowlevel": 2, + "provide": 1, + "generally": 1, + "Reads": 5, + "done": 3, + "twice": 3, + "therefore": 6, + "always": 3, + "safe": 4, + "precautions": 3, + "correct": 3, + "paddr": 10, + "from.": 6, + "etc.": 5, + "sa": 30, + "uint32_t*": 7, + "without": 3, + "within": 4, + "occurred": 2, + "since.": 2, + "bcm2835_peri_read_nb": 1, + "Writes": 2, + "write": 8, + "bcm2835_peri_write_nb": 1, + "Alters": 1, + "regsiter.": 1, + "valu": 1, + "alters": 1, + "deines": 1, + "according": 1, + "value.": 2, + "All": 1, + "unaffected.": 1, + "Use": 8, + "alter": 2, + "subset": 1, + "register.": 3, + "masked": 2, + "mask.": 1, + "Bitmask": 1, + "altered": 1, + "gpio": 1, + "interface.": 3, + "input": 12, + "output": 21, + "state.": 1, + "given": 16, + "configures": 1, + "RPI_GPIO_P1_*": 21, + "Mode": 1, + "BCM2835_GPIO_FSEL_*": 1, + "specified": 27, + "HIGH.": 2, + "bcm2835_gpio_write": 3, + "bcm2835_gpio_set": 1, + "LOW.": 5, + "bcm2835_gpio_clr": 1, + "first": 13, + "Mask": 6, + "affect.": 4, + "eg": 5, + "returns": 4, + "either": 4, + "Works": 1, + "whether": 4, + "output.": 1, + "bcm2835_gpio_lev": 1, + "Status.": 7, + "Tests": 1, + "detected": 7, + "requested": 1, + "flag": 1, + "bcm2835_gpio_set_eds": 2, + "status": 1, + "th": 1, + "true.": 2, + "bcm2835_gpio_eds": 1, + "effect": 3, + "clearing": 1, + "flag.": 1, + "afer": 1, + "seeing": 1, + "rising": 3, + "sets": 8, + "GPRENn": 2, + "synchronous": 2, + "detection.": 2, + "signal": 4, + "sampled": 6, + "looking": 2, + "pattern": 2, + "signal.": 2, + "suppressing": 2, + "glitches.": 2, + "Disable": 6, + "Asynchronous": 6, + "incoming": 2, + "As": 2, + "edges": 2, + "very": 2, + "short": 5, + "duration": 2, + "detected.": 2, + "bcm2835_gpio_pudclk": 3, + "resistor": 1, + "However": 3, + "convenient": 2, + "bcm2835_gpio_set_pud": 4, + "pud": 4, + "desired": 7, + "mode.": 4, + "One": 3, + "BCM2835_GPIO_PUD_*": 2, + "Clocks": 3, + "earlier": 1, + "remove": 2, + "group.": 2, + "BCM2835_PAD_GROUP_GPIO_*": 2, + "BCM2835_PAD_*": 2, + "bcm2835_gpio_set_pad": 1, + "Delays": 3, + "milliseconds.": 1, + "Uses": 4, + "CPU": 5, + "until": 1, + "up.": 1, + "mercy": 2, + "From": 2, + "interval": 4, + "req": 2, + "exact": 2, + "multiple": 2, + "granularity": 2, + "rounded": 2, + "next": 9, + "multiple.": 2, + "Furthermore": 2, + "sleep": 2, + "completes": 2, + "still": 3, + "becomes": 2, + "free": 4, + "once": 5, + "again": 2, + "execute": 3, + "thread.": 2, + "millis": 2, + "milliseconds": 1, + "unsigned": 22, + "microseconds.": 2, + "combination": 2, + "busy": 2, + "wait": 2, + "timers": 1, + "less": 1, + "microseconds": 6, + "Timer.": 1, + "RaspberryPi": 1, + "Your": 1, + "mileage": 1, + "vary.": 1, + "micros": 5, + "uint64_t": 8, + "required": 2, + "bcm2835_gpio_write_mask": 1, + "clocking": 1, + "spi": 1, + "let": 2, + "device.": 2, + "operations.": 4, + "Forces": 2, + "ALT0": 2, + "funcitons": 1, + "complete": 2, + "End": 2, + "returned": 5, + "INPUT": 2, + "behaviour.": 2, + "NOTE": 1, + "effect.": 1, + "SPI0.": 1, + "Defaults": 1, + "BCM2835_SPI_BIT_ORDER_*": 1, + "speed.": 2, + "BCM2835_SPI_CLOCK_DIVIDER_*": 1, + "bcm2835_spi_setClockDivider": 1, + "uint16_t": 2, + "polariy": 1, + "phase": 1, + "BCM2835_SPI_MODE*": 1, + "bcm2835_spi_transfer": 5, + "made": 1, + "selected": 13, + "during": 4, + "transfer.": 4, + "cs": 4, + "activate": 1, + "slave.": 7, + "BCM2835_SPI_CS*": 1, + "bcm2835_spi_chipSelect": 4, + "occurs": 1, + "currently": 12, + "active.": 1, + "transfers": 1, + "happening": 1, + "complement": 1, + "inactive": 1, + "affect": 1, + "active": 3, + "Whether": 1, + "bcm2835_spi_setChipSelectPolarity": 1, + "Transfers": 6, + "byte": 6, + "Asserts": 3, + "simultaneously": 3, + "clocks": 2, + "MISO.": 2, + "Returns": 2, + "polled": 2, + "Peripherls": 2, + "len": 15, + "slave": 8, + "placed": 1, + "rbuf.": 1, + "rbuf": 3, + "long": 11, + "tbuf": 4, + "Buffer": 10, + "send.": 5, + "put": 1, + "buffer": 9, + "Number": 8, + "send/received": 2, + "char*": 24, + "bcm2835_spi_transfernb.": 1, + "replaces": 1, + "transmitted": 1, + "buffer.": 1, + "buf": 14, + "replace": 1, + "contents": 3, + "eh": 2, + "bcm2835_spi_writenb": 1, + "i2c": 1, + "Philips": 1, + "bus/interface": 1, + "January": 1, + "SCL": 2, + "bcm2835_i2c_end": 3, + "bcm2835_i2c_begin": 1, + "address.": 2, + "addr": 2, + "bcm2835_i2c_setSlaveAddress": 4, + "BCM2835_I2C_CLOCK_DIVIDER_*": 1, + "bcm2835_i2c_setClockDivider": 2, + "converting": 1, + "baudrate": 4, + "parameter": 1, + "equivalent": 1, + "divider.": 1, + "standard": 2, + "khz": 1, + "corresponds": 1, + "its": 1, + "driver.": 1, + "Of": 1, + "course": 2, + "nothing": 1, + "driver": 1, + "const": 170, + "*": 161, + "receive.": 2, + "received.": 2, + "Allows": 2, + "slaves": 1, + "require": 3, + "repeated": 1, + "start": 12, + "prior": 1, + "stop": 1, + "set.": 1, + "popular": 1, + "MPL3115A2": 1, + "pressure": 1, + "temperature": 1, + "sensor.": 1, + "Note": 1, + "combined": 1, + "better": 1, + "choice.": 1, + "Will": 1, + "regaddr": 2, + "containing": 2, + "bcm2835_i2c_read_register_rs": 1, + "st": 1, + "delays": 1, + "Counter.": 1, + "bcm2835_st_read": 1, + "offset.": 1, + "offset_micros": 2, + "Offset": 1, + "bcm2835_st_delay": 1, + "@example": 5, + "blink.c": 1, + "Blinks": 1, + "off": 1, + "input.c": 1, + "event.c": 1, + "Shows": 3, + "how": 3, + "spi.c": 1, + "spin.c": 1, + "#pragma": 3, "": 4, "": 4, "": 2, - "using": 4, "namespace": 30, "std": 52, - "#define": 197, "DEFAULT_DELIMITER": 1, "CsvStreamer": 5, "private": 16, "ofstream": 1, - "file": 28, - "//": 268, "File": 1, - "output": 11, "stream": 6, "vector": 16, "row_buffer": 1, - "Buffer": 3, - "which": 6, "stores": 3, - "a": 105, "row": 12, - "s": 11, - "data": 8, - "before": 3, - "being": 3, "flushed/written": 1, - "int": 157, "fields": 4, - "Number": 2, - "of": 73, "columns": 2, - "long": 10, "rows": 3, "records": 2, "including": 2, - "header": 4, "delimiter": 2, "Delimiter": 1, "character": 10, "comma": 2, - "by": 7, - "default": 7, "string": 24, "sanitize": 1, - "Returns": 1, "ready": 1, - "for": 27, - "into": 2, - "the": 238, "Empty": 1, "CSV": 4, "streamer...": 1, - "be": 12, - "sure": 2, - "to": 88, - "open": 5, - "writing": 1, "Same": 1, - "as": 5, "...": 1, "Opens": 3, - "an": 8, - "given": 4, "path/name": 3, "Ensures": 1, - "is": 40, "closed": 1, - "and": 20, "saved": 1, "delimiting": 1, "add_field": 1, - "If": 5, - "still": 1, - "on": 3, - "first": 9, "line": 11, "adds": 1, - "new": 11, "field": 5, "save_fields": 1, - "Call": 1, - "this": 35, "save": 1, - "all": 2, "writes": 2, - "should": 3, - "through": 3, "append": 8, "Appends": 5, - "current": 15, - "with": 12, - "next": 7, "quoted": 1, - "only": 3, - "if": 298, - "needed": 2, "leading/trailing": 1, "spaces": 3, - "are": 4, "trimmed": 1, "bool": 104, "Like": 1, - "but": 3, - "can": 5, "specify": 1, - "whether": 2, "trim": 2, - "at": 8, - "either": 2, - "end": 20, - "false": 44, "keep": 1, "float": 8, - "number": 11, "double": 25, "writeln": 1, "Flushes": 1, - "what": 1, - "was": 5, - "in": 19, - "buffer": 2, - "close": 2, "Saves": 1, "closes": 1, "field_count": 1, "Gets": 2, "row_count": 1, - "-": 236, - "NOT": 2, "": 1, "": 1, "": 2, "static": 262, "Env": 13, "*env_instance": 1, - "*": 160, "NULL": 109, "*Env": 1, "instance": 4, "env_instance": 3, - "return": 148, "QObject": 2, "QCoreApplication": 1, "parse": 3, - "const": 169, "**envp": 1, "**env": 1, "**": 2, "QString": 20, "envvar": 2, "name": 25, - "value": 18, "indexOfEquals": 5, "env": 3, "envp": 4, "*env": 1, - "+": 50, "envvar.indexOf": 1, "continue": 2, "envvar.left": 1, @@ -8741,24 +10215,19 @@ "QVariantMap": 3, "asVariantMap": 2, "m_map": 2, - "#ifndef": 25, "ENV_H": 3, "": 1, "Q_OBJECT": 1, "*instance": 1, - "#endif": 85, - "enum": 7, "Field": 2, "Free": 1, "Black": 1, "White": 1, "Illegal": 1, - "typedef": 39, "Player": 1, "GDSDBREADER_H": 3, "": 1, "GDS_DIR": 1, - "level": 1, "LEVEL_ONE": 1, "LEVEL_TWO": 1, "LEVEL_THREE": 1, @@ -8768,7 +10237,6 @@ "depth": 1, "userIndex": 1, "QByteArray": 1, - "This": 6, "COMPRESSED": 1, "optimize": 1, "ram": 1, @@ -8790,16 +10258,12 @@ "tell": 1, "node": 1, "root": 1, - "so": 1, "hasn": 1, - "t": 14, "argument": 1, "list": 3, "operator": 10, "overload.": 1, - "A": 4, "friend": 10, - "<<": 18, "myclass.label": 2, "myclass.depth": 2, "myclass.userIndex": 2, @@ -8813,11 +10277,8 @@ "myclass.firstLineData": 4, "myclass.linesNumbers": 2, "QDataStream": 2, - "&": 147, "myclass": 1, "//Don": 1, - "read": 1, - "it": 7, "qUncompress": 2, "": 2, "main": 2, @@ -8846,7 +10307,6 @@ "err": 26, "pub_key": 6, "EC_POINT_new": 4, - "group": 12, "EC_POINT_mul": 3, "priv_key": 2, "EC_KEY_set_private_key": 1, @@ -8856,11 +10316,9 @@ "ECDSA_SIG_recover_key_GFp": 3, "ECDSA_SIG": 3, "*ecsig": 1, - "unsigned": 21, "*msg": 2, "msglen": 2, "recid": 3, - "check": 2, "ret": 24, "*x": 1, "*e": 1, @@ -8875,12 +10333,9 @@ "*zero": 1, "n": 28, "i": 47, - "/": 13, "BN_CTX_start": 1, - "order": 8, "BN_CTX_get": 8, "EC_GROUP_get_order": 1, - "x": 44, "BN_copy": 1, "BN_mul_word": 1, "BN_add": 1, @@ -8890,7 +10345,6 @@ "BN_cmp": 1, "R": 6, "EC_POINT_set_compressed_coordinates_GFp": 1, - "%": 4, "O": 5, "EC_POINT_is_at_infinity": 1, "Q": 5, @@ -8915,7 +10369,6 @@ "pkey": 14, "POINT_CONVERSION_COMPRESSED": 1, "fCompressedPubKey": 5, - "true": 40, "Reset": 5, "EC_KEY_new_by_curve_name": 2, "NID_secp256k1": 2, @@ -8928,29 +10381,23 @@ "b.fSet": 2, "EC_KEY_copy": 1, "hash": 20, - "sizeof": 14, "vchSig": 18, - "[": 201, - "]": 201, "nSize": 2, "vchSig.clear": 2, "vchSig.resize": 2, "Shrink": 1, "fit": 1, "actual": 1, - "size": 12, "SignCompact": 2, "uint256": 10, "": 19, "fOk": 3, "*sig": 2, "ECDSA_do_sign": 1, - "char*": 17, "sig": 11, "nBitsR": 3, "BN_num_bits": 2, "nBitsS": 3, - "<": 53, "&&": 23, "nRecId": 4, "<4;>": 1, @@ -8984,7 +10431,6 @@ "BITCOIN_KEY_H": 2, "": 1, "": 1, - "definition": 2, "runtime_error": 2, "explicit": 4, "str": 2, @@ -9027,7 +10473,6 @@ "int64": 1, "//#define": 1, "DEBUG": 5, - "#ifdef": 17, "dout": 2, "#else": 25, "cerr": 1, @@ -9036,9 +10481,7 @@ "canmem": 22, "object": 3, "generic": 1, - "memory": 5, "container": 2, - "used": 7, "commonly": 1, "//throughout": 1, "canister": 14, @@ -9046,20 +10489,15 @@ "hold": 1, "uncertain": 1, "//length": 1, - "may": 4, - "or": 13, - "not": 6, "contain": 1, "null": 3, "bytes.": 1, "raw": 2, - "block": 2, "absolute": 1, "length": 10, "//creates": 3, "unallocated": 1, "allocsize": 1, - "allocated": 1, "blank": 1, "strdata": 1, "//automates": 1, @@ -9067,24 +10505,18 @@ "limited": 2, "canmems": 1, "//cleans": 1, - "up": 15, "zeromem": 1, "//overwrites": 2, "fragmem": 1, - "fragment": 1, "notation": 1, "countlen": 1, "//counts": 1, "strings": 1, "//removes": 1, - "any": 8, "nulls": 1, - "from": 28, "//returns": 2, "singleton": 2, "//contains": 2, - "information": 1, - "about": 2, "caninfo": 2, "path": 8, "//physical": 1, @@ -9093,20 +10525,16 @@ "numfiles": 1, "files": 6, "//necessary": 1, - "use": 3, "type": 7, "canfile": 7, "//this": 1, "holds": 2, - "within": 2, "//canister": 1, "canister*": 1, "parent": 1, - "that": 11, "//internal": 1, "id": 1, "//use": 1, - "their": 1, "own.": 1, "newline": 2, "delimited": 2, @@ -9116,28 +10544,18 @@ "general": 1, "canfiles": 1, "recommended": 1, - "programs": 1, - "do": 7, "modify": 1, "//these": 1, - "directly": 1, "enforced.": 1, "canfile*": 1, "readonly": 3, "//if": 1, - "then": 7, - "no": 2, - "write": 1, "routines": 1, - "will": 3, "anything": 1, "//maximum": 1, - "have": 3, "//time": 1, - "change": 2, "whatever": 1, "suits": 1, - "your": 4, "application.": 1, "cachemax": 2, "cachecnt": 1, @@ -9146,15 +10564,10 @@ "modified": 3, "//both": 1, "initialize": 1, - "physical": 1, - "location": 5, "fspath": 3, "//destroys": 1, - "after": 2, "flushing": 1, "modded": 1, - "buffers": 2, - "course": 1, "//open": 1, "//does": 1, "exist": 2, @@ -9165,17 +10578,13 @@ "inside": 1, "delFile": 1, "//pulls": 1, - "contents": 2, - "returns": 2, "getFile": 1, - "does": 1, "otherwise": 1, "overwrites": 1, "operation": 1, "succeeded": 2, "writeFile": 2, "//get": 1, - "containing": 1, "//list": 1, "paths": 1, "getTOC": 1, @@ -9184,10 +10593,7 @@ "limit": 1, "//important": 1, "sCFID": 2, - "safe": 1, "CFID": 2, - "we": 3, - "want": 3, "avoid": 1, "uncaching": 1, "//really": 1, @@ -9205,7 +10611,6 @@ "Something": 1, "wrong": 1, "setup.": 1, - "Please": 3, "report": 3, "mailing": 1, "argc": 2, @@ -9213,7 +10618,6 @@ "argv": 2, "google_breakpad": 1, "ExceptionHandler": 1, - "eh": 1, "Utils": 4, "exceptionHandler": 2, "qInstallMsgHandler": 1, @@ -9237,33 +10641,20 @@ "app.exec": 1, "phantom.returnValue": 1, "NINJA_METRICS_H_": 3, - "For": 1, "int64_t.": 1, - "///": 17, - "The": 11, "Metrics": 2, "module": 1, - "debug": 1, - "mode": 5, "dumps": 1, - "timing": 2, "stats": 2, - "various": 1, "actions.": 1, "To": 1, - "see": 1, "METRIC_RECORD": 4, "below.": 1, - "single": 1, "metrics": 2, - "ve": 2, "hit": 1, - "code": 2, "path.": 2, "count": 1, "Total": 1, - "time": 3, - "micros": 1, "spent": 1, "int64_t": 3, "sum": 1, @@ -9272,15 +10663,11 @@ "metric": 2, "across": 1, "body": 1, - "function.": 2, "macro.": 1, - "struct": 11, "ScopedMetric": 4, "Metric*": 4, "metric_": 1, "Timestamp": 1, - "when": 6, - "measurement": 1, "started.": 1, "Value": 24, "platform": 2, @@ -9297,7 +10684,6 @@ "metrics_": 1, "Get": 1, "relative": 2, - "some": 1, "epoch.": 1, "Epoch": 1, "varies": 1, @@ -9311,7 +10697,6 @@ "simple": 1, "stopwatch": 1, "seconds": 1, - "since": 2, "Restart": 3, "called.": 1, "Stopwatch": 2, @@ -9321,22 +10706,13 @@ "Elapsed": 1, "static_cast": 8, "": 1, - "Now": 3, - "uint64_t": 4, "primary": 1, - "interface": 1, "metrics.": 1, - "Use": 2, "top": 1, - "function": 1, - "get": 1, "recorded": 1, - "each": 3, - "call": 1, "metrics_h_metric": 2, "g_metrics": 3, "metrics_h_scoped": 1, - "extern": 5, "Metrics*": 1, "INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION": 1, "": 1, @@ -9353,7 +10729,6 @@ "protobuf": 72, "Descriptor*": 3, "Person_descriptor_": 6, - "internal": 46, "GeneratedMessageReflection*": 1, "Person_reflection_": 4, "protobuf_AssignDesc_protocol_2dbuffer_2eproto": 4, @@ -9401,7 +10776,6 @@ "const_cast": 3, "string*": 11, "kEmptyString": 12, - "memset": 2, "SharedDtor": 3, "SetCachedSize": 2, "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN": 2, @@ -9409,26 +10783,20 @@ "descriptor": 2, "*default_instance_": 1, "Person*": 7, - "New": 4, - "Clear": 5, "xffu": 3, "has_name": 6, - "clear": 2, "mutable_unknown_fields": 4, "MergePartialFromCodedStream": 2, "io": 4, "CodedInputStream*": 2, - "input": 6, "DO_": 4, "EXPRESSION": 2, "uint32": 2, "tag": 6, - "while": 11, "ReadTag": 1, "switch": 3, "WireFormatLite": 9, "GetTagFieldNumber": 1, - "case": 33, "GetTagWireType": 2, "WIRETYPE_LENGTH_DELIMITED": 1, "ReadString": 1, @@ -9438,7 +10806,6 @@ ".data": 3, ".length": 3, "PARSE": 1, - "else": 46, "handle_uninterpreted": 2, "ExpectAtEnd": 1, "WIRETYPE_END_GROUP": 1, @@ -9461,7 +10828,6 @@ "StringSize": 1, "ComputeUnknownFieldsSize": 1, "GOOGLE_CHECK_NE": 2, - "source": 9, "dynamic_cast_if_available": 1, "": 12, "ReflectionOps": 1, @@ -9474,7 +10840,6 @@ "CopyFrom": 5, "IsInitialized": 3, "Swap": 2, - "other": 7, "swap": 3, "_unknown_fields_.Swap": 1, "Metadata": 3, @@ -9486,7 +10851,6 @@ "GOOGLE_PROTOBUF_VERSION": 1, "generated": 2, "newer": 2, - "version": 4, "protoc": 2, "incompatible": 2, "Protocol": 2, @@ -9514,7 +10878,6 @@ "clear_has_name": 5, "mutable": 1, "u": 9, - "|": 8, "*name_": 1, "assign": 3, "reinterpret_cast": 7, @@ -9526,30 +10889,21 @@ "": 2, "": 1, "QsciScintilla": 7, - "brief": 2, "QsciCommand": 7, "represents": 1, "editor": 1, "command": 9, - "one": 42, "two": 1, "keys": 3, "bound": 4, - "it.": 2, "Methods": 1, "provided": 1, - "remove": 1, "binding.": 1, "Each": 1, - "has": 2, - "user": 2, "friendly": 2, "description": 3, - "mapping": 1, "dialogs.": 1, "QSCINTILLA_EXPORT": 2, - "defines": 1, - "different": 1, "commands": 1, "assigned": 1, "key.": 1, @@ -9579,7 +10933,6 @@ "SCI_LINEUPRECTEXTEND": 1, "LineScrollUp": 1, "SCI_LINESCROLLUP": 1, - "start": 11, "document.": 8, "ScrollToStart": 1, "SCI_SCROLLTOSTART": 1, @@ -9606,7 +10959,6 @@ "SCI_CHARLEFTEXTEND": 1, "CharLeftRectExtend": 1, "SCI_CHARLEFTRECTEXTEND": 1, - "right": 8, "CharRight": 1, "SCI_CHARRIGHT": 1, "CharRightExtend": 1, @@ -9622,7 +10974,6 @@ "SCI_WORDRIGHT": 1, "WordRightExtend": 1, "SCI_WORDRIGHTEXTEND": 1, - "previous": 5, "WordLeftEnd": 1, "SCI_WORDLEFTEND": 1, "WordLeftEndExtend": 1, @@ -9631,7 +10982,6 @@ "SCI_WORDRIGHTEND": 1, "WordRightEndExtend": 1, "SCI_WORDRIGHTENDEXTEND": 1, - "word": 6, "part.": 4, "WordPartLeft": 1, "SCI_WORDPARTLEFT": 1, @@ -9748,11 +11098,9 @@ "Duplicate": 2, "LineDuplicate": 1, "SCI_LINEDUPLICATE": 1, - "Select": 33, "whole": 2, "SelectAll": 1, "SCI_SELECTALL": 1, - "selected": 2, "lines": 3, "MoveSelectedLinesUp": 1, "SCI_MOVESELECTEDLINESUP": 1, @@ -9788,7 +11136,6 @@ "Formfeed": 1, "SCI_FORMFEED": 1, "Indent": 1, - "level.": 2, "Tab": 1, "SCI_TAB": 1, "De": 1, @@ -9796,10 +11143,8 @@ "Backtab": 1, "SCI_BACKTAB": 1, "Cancel": 2, - "operation.": 1, "SCI_CANCEL": 1, "Undo": 2, - "last": 4, "command.": 5, "SCI_UNDO": 1, "Redo": 2, @@ -9816,15 +11161,12 @@ "instance.": 2, "scicmd": 2, "Execute": 1, - "execute": 1, "Binds": 2, "binding": 3, "removed.": 2, "invalid": 5, "unchanged.": 1, "Valid": 1, - "control": 1, - "c": 50, "Key_Down": 1, "Key_Up": 1, "Key_Left": 1, @@ -9840,19 +11182,15 @@ "Key_Tab": 1, "Key_Return.": 1, "Keys": 1, - "combination": 1, "SHIFT": 1, "CTRL": 1, "ALT": 1, "META.": 1, - "sa": 8, "setAlternateKey": 3, "validKey": 3, "setKey": 3, - "alternate": 3, "altkey": 3, "alternateKey": 3, - "currently": 2, "returned.": 4, "qkey": 2, "qaltkey": 2, @@ -9879,13 +11217,10 @@ "sub": 2, "Qt": 1, "QPrinter": 3, - "able": 1, - "print": 4, "text": 5, "Scintilla": 2, "further": 1, "classed": 1, - "alter": 1, "layout": 1, "adding": 2, "headers": 3, @@ -9894,14 +11229,10 @@ "Constructs": 1, "printer": 1, "paint": 1, - "device": 1, - "mode.": 1, "PrinterMode": 1, "ScreenResolution": 1, "Destroys": 1, "Format": 1, - "page": 4, - "example": 1, "drawn": 2, "painter": 4, "add": 3, @@ -9909,13 +11240,8 @@ "graphics.": 2, "drawing": 4, "actually": 1, - "rather": 1, - "than": 1, "sized.": 1, "methods": 1, - "must": 1, - "called": 1, - "true.": 1, "area": 5, "draw": 1, "text.": 3, @@ -9925,9 +11251,7 @@ "printable": 1, "setFullPage": 1, "because": 2, - "calling": 1, "printRange": 2, - "you": 1, "try": 1, "over": 1, "pagenr": 2, @@ -9939,15 +11263,11 @@ "setMagnification": 2, "magnification": 3, "mag": 2, - "Sets": 2, "printing": 2, "magnification.": 1, - "range": 1, "qsb.": 1, "negative": 2, "signifies": 2, - "returned": 2, - "there": 1, "error.": 1, "*qsb": 1, "wrap": 4, @@ -9957,6 +11277,8 @@ "wrapMode": 2, "wmode.": 1, "wmode": 1, + "rpc_init": 1, + "rpc_server_loop": 1, "v8": 9, "Scanner": 16, "UnicodeCache*": 4, @@ -9977,7 +11299,6 @@ "ScanHexNumber": 2, "expected_length": 4, "ASSERT": 17, - "prevent": 1, "overflow": 1, "digits": 3, "c0_": 64, @@ -9989,7 +11310,6 @@ "STATIC_ASSERT": 5, "Token": 212, "NUM_TOKENS": 1, - "byte": 1, "one_char_tokens": 2, "ILLEGAL": 120, "LPAREN": 2, @@ -10079,9 +11399,7 @@ "IsLineFeed": 2, "fall": 2, "v": 3, - "xx": 1, "xxx": 1, - "error": 1, "immediately": 1, "octal": 1, "escape": 1, @@ -10089,11 +11407,9 @@ "consume": 2, "LiteralScope": 4, "literal": 2, - ".": 2, "X": 2, "E": 3, "l": 1, - "p": 5, "w": 1, "y": 13, "keyword": 1, @@ -10112,7 +11428,6 @@ "CLASSIC_MODE": 2, "STRICT_MODE": 2, "EXTENDED_MODE": 2, - "detect": 1, "x16": 1, "x36.": 1, "Utf16CharacterStream": 3, @@ -10162,7 +11477,6 @@ "backing_store_.Dispose": 3, "INLINE": 2, "AddChar": 2, - "uint32_t": 8, "ExpandBuffer": 2, "kMaxAsciiCharCodeU": 1, "": 6, @@ -10260,6 +11574,8 @@ "desc": 2, "look": 1, "ahead": 1, + "": 1, + "smallPrime_t": 1, "UTILS_H": 3, "": 1, "": 1, @@ -10296,7 +11612,6 @@ "QTemporaryFile*": 2, "m_tempHarness": 1, "We": 1, - "make": 1, "ourselves": 1, "m_tempWrapper": 1, "V8_DECLARE_ONCE": 1, @@ -10340,8 +11655,6 @@ "UnregisterAll": 1, "OS": 3, "seed_random": 2, - "uint32_t*": 2, - "state": 15, "FLAG_random_seed": 2, "val": 3, "ScopedLock": 1, @@ -10402,8 +11715,6 @@ "SetUp": 4, "FLAG_crankshaft": 1, "Serializer": 1, - "enabled": 1, - "CPU": 2, "SupportsCrankshaft": 1, "PostSetUp": 1, "RuntimeProfiler": 1, @@ -10423,7 +11734,6 @@ "GOOGLE3": 2, "NDEBUG": 4, "both": 1, - "set": 1, "Deserializer": 1, "AllStatic": 1, "IsRunning": 1, @@ -10440,10 +11750,7 @@ "Py_PYTHON_H": 1, "Python": 1, "compile": 1, - "C": 1, "extensions": 1, - "please": 1, - "install": 1, "development": 1, "Python.": 1, "": 1, @@ -10502,7 +11809,6 @@ "*buf": 1, "PyObject": 221, "*obj": 2, - "len": 1, "itemsize": 2, "ndim": 2, "*format": 1, @@ -10628,7 +11934,6 @@ "PyObject_DelAttrString": 2, "__Pyx_NAMESTR": 3, "__Pyx_DOCSTR": 3, - "__cplusplus": 10, "__PYX_EXTERN_C": 2, "_USE_MATH_DEFINES": 1, "": 1, @@ -10723,7 +12028,6 @@ "complex": 2, "__pyx_t_float_complex": 27, "_Complex": 2, - "real": 2, "imag": 2, "__pyx_t_double_complex": 27, "npy_cfloat": 1, @@ -10833,7 +12137,6 @@ "cabs": 1, "cpow": 1, "__Pyx_PyInt_AsUnsignedChar": 1, - "short": 3, "__Pyx_PyInt_AsUnsignedShort": 1, "__Pyx_PyInt_AsUnsignedInt": 1, "__Pyx_PyInt_AsChar": 1, @@ -11055,7 +12358,6 @@ "NPY_F_CONTIGUOUS": 1, "__pyx_k_tuple_8": 1, "__pyx_L7": 2, - "buf": 1, "PyArray_DATA": 1, "strides": 5, "malloc": 2, @@ -11102,7 +12404,6 @@ "__pyx_L2": 2, "__pyx_pf_5numpy_7ndarray_1__releasebuffer__": 2, "PyArray_HASFIELDS": 1, - "free": 2, "*__pyx_f_5numpy_PyArray_MultiIterNew1": 1, "*__pyx_v_a": 5, "PyArray_MultiIterNew": 5, @@ -11129,7 +12430,6 @@ "__pyx_v_fields": 7, "__pyx_v_childname": 4, "__pyx_v_new_offset": 5, - "names": 2, "PyTuple_GET_SIZE": 2, "PyTuple_GET_ITEM": 3, "PyObject_GetItem": 1, @@ -23686,6 +24986,50 @@ "}": 73, "true": 3 }, + "JSON5": { + "{": 6, + "foo": 1, + "while": 1, + "true": 1, + "this": 1, + "here": 1, + "//": 2, + "inline": 1, + "comment": 1, + "hex": 1, + "xDEADbeef": 1, + "half": 1, + ".5": 1, + "delta": 1, + "+": 1, + "to": 1, + "Infinity": 1, + "and": 1, + "beyond": 1, + "finally": 1, + "oh": 1, + "[": 3, + "]": 3, + "}": 6, + "name": 1, + "version": 1, + "description": 1, + "keywords": 1, + "author": 1, + "contributors": 1, + "main": 1, + "bin": 1, + "dependencies": 1, + "devDependencies": 1, + "mocha": 1, + "scripts": 1, + "build": 1, + "test": 1, + "homepage": 1, + "repository": 1, + "type": 1, + "url": 1 + }, "Julia": { "##": 5, "Test": 1, @@ -45100,7 +46444,7 @@ "Bluespec": 1298, "Brightscript": 579, "C": 58858, - "C++": 22665, + "C++": 31175, "Ceylon": 50, "Clojure": 510, "COBOL": 90, @@ -45134,6 +46478,7 @@ "Java": 8987, "JavaScript": 76934, "JSON": 183, + "JSON5": 57, "Julia": 247, "Kotlin": 155, "KRL": 25, @@ -45235,7 +46580,7 @@ "Bluespec": 2, "Brightscript": 1, "C": 26, - "C++": 23, + "C++": 26, "Ceylon": 1, "Clojure": 7, "COBOL": 4, @@ -45269,6 +46614,7 @@ "Java": 6, "JavaScript": 20, "JSON": 4, + "JSON5": 2, "Julia": 1, "Kotlin": 1, "KRL": 1, @@ -45356,5 +46702,5 @@ "Xtend": 2, "YAML": 1 }, - "md5": "7e305e6e7267f7d227fa871bf83546b8" + "md5": "8cc4a1e6f0dba44440f3ab7733486b8b" } \ No newline at end of file diff --git a/samples/C++/Types.h b/samples/C++/Types.h new file mode 100644 index 00000000..e2675538 --- /dev/null +++ b/samples/C++/Types.h @@ -0,0 +1,32 @@ +/***************************************************************************** +* Dwarf Mine - The 13-11 Benchmark +* +* Copyright (c) 2013 Bünger, Thomas; Kieschnick, Christian; Kusber, +* Michael; Lohse, Henning; Wuttke, Nikolai; Xylander, Oliver; Yao, Gary; +* Zimmermann, Florian +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*****************************************************************************/ + +#pragma once + +#include + +typedef uint32_t smallPrime_t; diff --git a/samples/C++/bcm2835.h b/samples/C++/bcm2835.h new file mode 100644 index 00000000..e5330933 --- /dev/null +++ b/samples/C++/bcm2835.h @@ -0,0 +1,1129 @@ +// bcm2835.h +// +// C and C++ support for Broadcom BCM 2835 as used in Raspberry Pi +// +// Author: Mike McCauley +// Copyright (C) 2011-2013 Mike McCauley +// $Id: bcm2835.h,v 1.8 2013/02/15 22:06:09 mikem Exp mikem $ +// +/// \mainpage C library for Broadcom BCM 2835 as used in Raspberry Pi +/// +/// This is a C library for Raspberry Pi (RPi). It provides access to +/// GPIO and other IO functions on the Broadcom BCM 2835 chip, +/// allowing access to the GPIO pins on the +/// 26 pin IDE plug on the RPi board so you can control and interface with various external devices. +/// +/// It provides functions for reading digital inputs and setting digital outputs, using SPI and I2C, +/// and for accessing the system timers. +/// Pin event detection is supported by polling (interrupts are not supported). +/// +/// It is C++ compatible, and installs as a header file and non-shared library on +/// any Linux-based distro (but clearly is no use except on Raspberry Pi or another board with +/// BCM 2835). +/// +/// The version of the package that this documentation refers to can be downloaded +/// from http://www.airspayce.com/mikem/bcm2835/bcm2835-1.26.tar.gz +/// You can find the latest version at http://www.airspayce.com/mikem/bcm2835 +/// +/// Several example programs are provided. +/// +/// Based on data in http://elinux.org/RPi_Low-level_peripherals and +/// http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf +/// and http://www.scribd.com/doc/101830961/GPIO-Pads-Control2 +/// +/// You can also find online help and discussion at http://groups.google.com/group/bcm2835 +/// Please use that group for all questions and discussions on this topic. +/// Do not contact the author directly, unless it is to discuss commercial licensing. +/// +/// Tested on debian6-19-04-2012, 2012-07-15-wheezy-raspbian and Occidentalisv01 +/// CAUTION: it has been observed that when detect enables such as bcm2835_gpio_len() +/// are used and the pin is pulled LOW +/// it can cause temporary hangs on 2012-07-15-wheezy-raspbian and Occidentalisv01. +/// Reason for this is not yet determined, but suspect that an interrupt handler is +/// hitting a hard loop on those OSs. +/// If you must use bcm2835_gpio_len() and friends, make sure you disable the pins with +/// bcm2835_gpio_cler_len() and friends after use. +/// +/// \par Installation +/// +/// This library consists of a single non-shared library and header file, which will be +/// installed in the usual places by make install +/// +/// \code +/// # download the latest version of the library, say bcm2835-1.xx.tar.gz, then: +/// tar zxvf bcm2835-1.xx.tar.gz +/// cd bcm2835-1.xx +/// ./configure +/// make +/// sudo make check +/// sudo make install +/// \endcode +/// +/// \par Physical Addresses +/// +/// The functions bcm2835_peri_read(), bcm2835_peri_write() and bcm2835_peri_set_bits() +/// are low level peripheral register access functions. They are designed to use +/// physical addresses as described in section 1.2.3 ARM physical addresses +/// of the BCM2835 ARM Peripherals manual. +/// Physical addresses range from 0x20000000 to 0x20FFFFFF for peripherals. The bus +/// addresses for peripherals are set up to map onto the peripheral bus address range starting at +/// 0x7E000000. Thus a peripheral advertised in the manual at bus address 0x7Ennnnnn is available at +/// physical address 0x20nnnnnn. +/// +/// The base address of the various peripheral registers are available with the following +/// externals: +/// bcm2835_gpio +/// bcm2835_pwm +/// bcm2835_clk +/// bcm2835_pads +/// bcm2835_spio0 +/// bcm2835_st +/// bcm2835_bsc0 +/// bcm2835_bsc1 +/// +/// \par Pin Numbering +/// +/// The GPIO pin numbering as used by RPi is different to and inconsistent with the underlying +/// BCM 2835 chip pin numbering. http://elinux.org/RPi_BCM2835_GPIOs +/// +/// RPi has a 26 pin IDE header that provides access to some of the GPIO pins on the BCM 2835, +/// as well as power and ground pins. Not all GPIO pins on the BCM 2835 are available on the +/// IDE header. +/// +/// RPi Version 2 also has a P5 connector with 4 GPIO pins, 5V, 3.3V and Gnd. +/// +/// The functions in this library are designed to be passed the BCM 2835 GPIO pin number and _not_ +/// the RPi pin number. There are symbolic definitions for each of the available pins +/// that you should use for convenience. See \ref RPiGPIOPin. +/// +/// \par SPI Pins +/// +/// The bcm2835_spi_* functions allow you to control the BCM 2835 SPI0 interface, +/// allowing you to send and received data by SPI (Serial Peripheral Interface). +/// For more information about SPI, see http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus +/// +/// When bcm2835_spi_begin() is called it changes the bahaviour of the SPI interface pins from their +/// default GPIO behaviour in order to support SPI. While SPI is in use, you will not be able +/// to control the state of the SPI pins through the usual bcm2835_spi_gpio_write(). +/// When bcm2835_spi_end() is called, the SPI pins will all revert to inputs, and can then be +/// configured and controled with the usual bcm2835_gpio_* calls. +/// +/// The Raspberry Pi GPIO pins used for SPI are: +/// +/// - P1-19 (MOSI) +/// - P1-21 (MISO) +/// - P1-23 (CLK) +/// - P1-24 (CE0) +/// - P1-26 (CE1) +/// +/// \par I2C Pins +/// +/// The bcm2835_i2c_* functions allow you to control the BCM 2835 BSC interface, +/// allowing you to send and received data by I2C ("eye-squared cee"; generically referred to as "two-wire interface") . +/// For more information about I?C, see http://en.wikipedia.org/wiki/I%C2%B2C +/// +/// The Raspberry Pi V2 GPIO pins used for I2C are: +/// +/// - P1-03 (SDA) +/// - P1-05 (SLC) +/// +/// \par Real Time performance constraints +/// +/// The bcm2835 is a library for user programs (i.e. they run in 'userland'). +/// Such programs are not part of the kernel and are usually +/// subject to paging and swapping by the kernel while it does other things besides running your program. +/// This means that you should not expect to get real-time performance or +/// real-time timing constraints from such programs. In particular, there is no guarantee that the +/// bcm2835_delay() and bcm2835_delayMicroseconds() will return after exactly the time requested. +/// In fact, depending on other activity on the host, IO etc, you might get significantly longer delay times +/// than the one you asked for. So please dont expect to get exactly the time delay you request. +/// +/// Arjan reports that you can prevent swapping on Linux with the following code fragment: +/// +/// \code +/// struct sched_param sp; +/// memset(&sp, 0, sizeof(sp)); +/// sp.sched_priority = sched_get_priority_max(SCHED_FIFO); +/// sched_setscheduler(0, SCHED_FIFO, &sp); +/// mlockall(MCL_CURRENT | MCL_FUTURE); +/// \endcode +/// +/// \par Open Source Licensing GPL V2 +/// +/// This is the appropriate option if you want to share the source code of your +/// application with everyone you distribute it to, and you also want to give them +/// the right to share who uses it. If you wish to use this software under Open +/// Source Licensing, you must contribute all your source code to the open source +/// community in accordance with the GPL Version 2 when your application is +/// distributed. See http://www.gnu.org/copyleft/gpl.html and COPYING +/// +/// \par Acknowledgements +/// +/// Some of this code has been inspired by Dom and Gert. +/// The I2C code has been inspired by Alan Barr. +/// +/// \par Revision History +/// +/// \version 1.0 Initial release +/// \version 1.1 Minor bug fixes +/// \version 1.2 Added support for SPI +/// \version 1.3 Added bcm2835_spi_transfern() +/// \version 1.4 Fixed a problem that prevented SPI CE1 being used. Reported by David Robinson. +/// \version 1.5 Added bcm2835_close() to deinit the library. Suggested by C?sar Ortiz +/// \version 1.6 Document testing on 2012-07-15-wheezy-raspbian and Occidentalisv01 +/// Functions bcm2835_gpio_ren(), bcm2835_gpio_fen(), bcm2835_gpio_hen() +/// bcm2835_gpio_len(), bcm2835_gpio_aren() and bcm2835_gpio_afen() now +/// changes only the pin specified. Other pins that were already previously +/// enabled stay enabled. +/// Added bcm2835_gpio_clr_ren(), bcm2835_gpio_clr_fen(), bcm2835_gpio_clr_hen() +/// bcm2835_gpio_clr_len(), bcm2835_gpio_clr_aren(), bcm2835_gpio_clr_afen() +/// to clear the enable for individual pins, suggested by Andreas Sundstrom. +/// \version 1.7 Added bcm2835_spi_transfernb to support different buffers for read and write. +/// \version 1.8 Improvements to read barrier, as suggested by maddin. +/// \version 1.9 Improvements contributed by mikew: +/// I noticed that it was mallocing memory for the mmaps on /dev/mem. +/// It's not necessary to do that, you can just mmap the file directly, +/// so I've removed the mallocs (and frees). +/// I've also modified delayMicroseconds() to use nanosleep() for long waits, +/// and a busy wait on a high resolution timer for the rest. This is because +/// I've found that calling nanosleep() takes at least 100-200 us. +/// You need to link using '-lrt' using this version. +/// I've added some unsigned casts to the debug prints to silence compiler +/// warnings I was getting, fixed some typos, and changed the value of +/// BCM2835_PAD_HYSTERESIS_ENABLED to 0x08 as per Gert van Loo's doc at +/// http://www.scribd.com/doc/101830961/GPIO-Pads-Control2 +/// Also added a define for the passwrd value that Gert says is needed to +/// change pad control settings. +/// \version 1.10 Changed the names of the delay functions to bcm2835_delay() +/// and bcm2835_delayMicroseconds() to prevent collisions with wiringPi. +/// Macros to map delay()-> bcm2835_delay() and +/// Macros to map delayMicroseconds()-> bcm2835_delayMicroseconds(), which +/// can be disabled by defining BCM2835_NO_DELAY_COMPATIBILITY +/// \version 1.11 Fixed incorrect link to download file +/// \version 1.12 New GPIO pin definitions for RPi version 2 (which has a different GPIO mapping) +/// \version 1.13 New GPIO pin definitions for RPi version 2 plug P5 +/// Hardware base pointers are now available (after initialisation) externally as bcm2835_gpio +/// bcm2835_pwm bcm2835_clk bcm2835_pads bcm2835_spi0. +/// \version 1.14 Now compiles even if CLOCK_MONOTONIC_RAW is not available, uses CLOCK_MONOTONIC instead. +/// Fixed errors in documentation of SPI divider frequencies based on 250MHz clock. +/// Reported by Ben Simpson. +/// \version 1.15 Added bcm2835_close() to end of examples as suggested by Mark Wolfe. +/// \version 1.16 Added bcm2835_gpio_set_multi, bcm2835_gpio_clr_multi and bcm2835_gpio_write_multi +/// to allow a mask of pins to be set all at once. Requested by Sebastian Loncar. +/// \version 1.17 Added bcm2835_gpio_write_mask. Requested by Sebastian Loncar. +/// \version 1.18 Added bcm2835_i2c_* functions. Changes to bcm2835_delayMicroseconds: +/// now uses the RPi system timer counter, instead of clock_gettime, for improved accuracy. +/// No need to link with -lrt now. Contributed by Arjan van Vught. +/// \version 1.19 Removed inlines added by previous patch since they don't seem to work everywhere. +/// Reported by olly. +/// \version 1.20 Patch from Mark Dootson to close /dev/mem after access to the peripherals has been granted. +/// \version 1.21 delayMicroseconds is now not susceptible to 32 bit timer overruns. +/// Patch courtesy Jeremy Mortis. +/// \version 1.22 Fixed incorrect definition of BCM2835_GPFEN0 which broke the ability to set +/// falling edge events. Reported by Mark Dootson. +/// \version 1.23 Added bcm2835_i2c_set_baudrate and bcm2835_i2c_read_register_rs. +/// Improvements to bcm2835_i2c_read and bcm2835_i2c_write functions +/// to fix ocasional reads not completing. Patched by Mark Dootson. +/// \version 1.24 Mark Dootson p[atched a problem with his previously submitted code +/// under high load from other processes. +/// \version 1.25 Updated author and distribution location details to airspayce.com +/// \version 1.26 Added missing unmapmem for pads in bcm2835_close to prevent a memory leak. +/// Reported by Hartmut Henkel. +/// \author Mike McCauley (mikem@airspayce.com) DO NOT CONTACT THE AUTHOR DIRECTLY: USE THE LISTS + + + +// Defines for BCM2835 +#ifndef BCM2835_H +#define BCM2835_H + +#include + +/// \defgroup constants Constants for passing to and from library functions +/// The values here are designed to be passed to various functions in the bcm2835 library. +/// @{ + + +/// This means pin HIGH, true, 3.3volts on a pin. +#define HIGH 0x1 +/// This means pin LOW, false, 0volts on a pin. +#define LOW 0x0 + +/// Speed of the core clock core_clk +#define BCM2835_CORE_CLK_HZ 250000000 ///< 250 MHz + +// Physical addresses for various peripheral register sets +/// Base Physical Address of the BCM 2835 peripheral registers +#define BCM2835_PERI_BASE 0x20000000 +/// Base Physical Address of the System Timer registers +#define BCM2835_ST_BASE (BCM2835_PERI_BASE + 0x3000) +/// Base Physical Address of the Pads registers +#define BCM2835_GPIO_PADS (BCM2835_PERI_BASE + 0x100000) +/// Base Physical Address of the Clock/timer registers +#define BCM2835_CLOCK_BASE (BCM2835_PERI_BASE + 0x101000) +/// Base Physical Address of the GPIO registers +#define BCM2835_GPIO_BASE (BCM2835_PERI_BASE + 0x200000) +/// Base Physical Address of the SPI0 registers +#define BCM2835_SPI0_BASE (BCM2835_PERI_BASE + 0x204000) +/// Base Physical Address of the BSC0 registers +#define BCM2835_BSC0_BASE (BCM2835_PERI_BASE + 0x205000) +/// Base Physical Address of the PWM registers +#define BCM2835_GPIO_PWM (BCM2835_PERI_BASE + 0x20C000) + /// Base Physical Address of the BSC1 registers +#define BCM2835_BSC1_BASE (BCM2835_PERI_BASE + 0x804000) + + +/// Base of the ST (System Timer) registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_st; + +/// Base of the GPIO registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_gpio; + +/// Base of the PWM registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_pwm; + +/// Base of the CLK registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_clk; + +/// Base of the PADS registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_pads; + +/// Base of the SPI0 registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_spi0; + +/// Base of the BSC0 registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_bsc0; + +/// Base of the BSC1 registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_bsc1; + +/// Size of memory page on RPi +#define BCM2835_PAGE_SIZE (4*1024) +/// Size of memory block on RPi +#define BCM2835_BLOCK_SIZE (4*1024) + + +// Defines for GPIO +// The BCM2835 has 54 GPIO pins. +// BCM2835 data sheet, Page 90 onwards. +/// GPIO register offsets from BCM2835_GPIO_BASE. Offsets into the GPIO Peripheral block in bytes per 6.1 Register View +#define BCM2835_GPFSEL0 0x0000 ///< GPIO Function Select 0 +#define BCM2835_GPFSEL1 0x0004 ///< GPIO Function Select 1 +#define BCM2835_GPFSEL2 0x0008 ///< GPIO Function Select 2 +#define BCM2835_GPFSEL3 0x000c ///< GPIO Function Select 3 +#define BCM2835_GPFSEL4 0x0010 ///< GPIO Function Select 4 +#define BCM2835_GPFSEL5 0x0014 ///< GPIO Function Select 5 +#define BCM2835_GPSET0 0x001c ///< GPIO Pin Output Set 0 +#define BCM2835_GPSET1 0x0020 ///< GPIO Pin Output Set 1 +#define BCM2835_GPCLR0 0x0028 ///< GPIO Pin Output Clear 0 +#define BCM2835_GPCLR1 0x002c ///< GPIO Pin Output Clear 1 +#define BCM2835_GPLEV0 0x0034 ///< GPIO Pin Level 0 +#define BCM2835_GPLEV1 0x0038 ///< GPIO Pin Level 1 +#define BCM2835_GPEDS0 0x0040 ///< GPIO Pin Event Detect Status 0 +#define BCM2835_GPEDS1 0x0044 ///< GPIO Pin Event Detect Status 1 +#define BCM2835_GPREN0 0x004c ///< GPIO Pin Rising Edge Detect Enable 0 +#define BCM2835_GPREN1 0x0050 ///< GPIO Pin Rising Edge Detect Enable 1 +#define BCM2835_GPFEN0 0x0058 ///< GPIO Pin Falling Edge Detect Enable 0 +#define BCM2835_GPFEN1 0x005c ///< GPIO Pin Falling Edge Detect Enable 1 +#define BCM2835_GPHEN0 0x0064 ///< GPIO Pin High Detect Enable 0 +#define BCM2835_GPHEN1 0x0068 ///< GPIO Pin High Detect Enable 1 +#define BCM2835_GPLEN0 0x0070 ///< GPIO Pin Low Detect Enable 0 +#define BCM2835_GPLEN1 0x0074 ///< GPIO Pin Low Detect Enable 1 +#define BCM2835_GPAREN0 0x007c ///< GPIO Pin Async. Rising Edge Detect 0 +#define BCM2835_GPAREN1 0x0080 ///< GPIO Pin Async. Rising Edge Detect 1 +#define BCM2835_GPAFEN0 0x0088 ///< GPIO Pin Async. Falling Edge Detect 0 +#define BCM2835_GPAFEN1 0x008c ///< GPIO Pin Async. Falling Edge Detect 1 +#define BCM2835_GPPUD 0x0094 ///< GPIO Pin Pull-up/down Enable +#define BCM2835_GPPUDCLK0 0x0098 ///< GPIO Pin Pull-up/down Enable Clock 0 +#define BCM2835_GPPUDCLK1 0x009c ///< GPIO Pin Pull-up/down Enable Clock 1 + +/// \brief bcm2835PortFunction +/// Port function select modes for bcm2835_gpio_fsel() +typedef enum +{ + BCM2835_GPIO_FSEL_INPT = 0b000, ///< Input + BCM2835_GPIO_FSEL_OUTP = 0b001, ///< Output + BCM2835_GPIO_FSEL_ALT0 = 0b100, ///< Alternate function 0 + BCM2835_GPIO_FSEL_ALT1 = 0b101, ///< Alternate function 1 + BCM2835_GPIO_FSEL_ALT2 = 0b110, ///< Alternate function 2 + BCM2835_GPIO_FSEL_ALT3 = 0b111, ///< Alternate function 3 + BCM2835_GPIO_FSEL_ALT4 = 0b011, ///< Alternate function 4 + BCM2835_GPIO_FSEL_ALT5 = 0b010, ///< Alternate function 5 + BCM2835_GPIO_FSEL_MASK = 0b111 ///< Function select bits mask +} bcm2835FunctionSelect; + +/// \brief bcm2835PUDControl +/// Pullup/Pulldown defines for bcm2835_gpio_pud() +typedef enum +{ + BCM2835_GPIO_PUD_OFF = 0b00, ///< Off ? disable pull-up/down + BCM2835_GPIO_PUD_DOWN = 0b01, ///< Enable Pull Down control + BCM2835_GPIO_PUD_UP = 0b10 ///< Enable Pull Up control +} bcm2835PUDControl; + +/// Pad control register offsets from BCM2835_GPIO_PADS +#define BCM2835_PADS_GPIO_0_27 0x002c ///< Pad control register for pads 0 to 27 +#define BCM2835_PADS_GPIO_28_45 0x0030 ///< Pad control register for pads 28 to 45 +#define BCM2835_PADS_GPIO_46_53 0x0034 ///< Pad control register for pads 46 to 53 + +/// Pad Control masks +#define BCM2835_PAD_PASSWRD (0x5A << 24) ///< Password to enable setting pad mask +#define BCM2835_PAD_SLEW_RATE_UNLIMITED 0x10 ///< Slew rate unlimited +#define BCM2835_PAD_HYSTERESIS_ENABLED 0x08 ///< Hysteresis enabled +#define BCM2835_PAD_DRIVE_2mA 0x00 ///< 2mA drive current +#define BCM2835_PAD_DRIVE_4mA 0x01 ///< 4mA drive current +#define BCM2835_PAD_DRIVE_6mA 0x02 ///< 6mA drive current +#define BCM2835_PAD_DRIVE_8mA 0x03 ///< 8mA drive current +#define BCM2835_PAD_DRIVE_10mA 0x04 ///< 10mA drive current +#define BCM2835_PAD_DRIVE_12mA 0x05 ///< 12mA drive current +#define BCM2835_PAD_DRIVE_14mA 0x06 ///< 14mA drive current +#define BCM2835_PAD_DRIVE_16mA 0x07 ///< 16mA drive current + +/// \brief bcm2835PadGroup +/// Pad group specification for bcm2835_gpio_pad() +typedef enum +{ + BCM2835_PAD_GROUP_GPIO_0_27 = 0, ///< Pad group for GPIO pads 0 to 27 + BCM2835_PAD_GROUP_GPIO_28_45 = 1, ///< Pad group for GPIO pads 28 to 45 + BCM2835_PAD_GROUP_GPIO_46_53 = 2 ///< Pad group for GPIO pads 46 to 53 +} bcm2835PadGroup; + +/// \brief GPIO Pin Numbers +/// +/// Here we define Raspberry Pin GPIO pins on P1 in terms of the underlying BCM GPIO pin numbers. +/// These can be passed as a pin number to any function requiring a pin. +/// Not all pins on the RPi 26 bin IDE plug are connected to GPIO pins +/// and some can adopt an alternate function. +/// RPi version 2 has some slightly different pinouts, and these are values RPI_V2_*. +/// At bootup, pins 8 and 10 are set to UART0_TXD, UART0_RXD (ie the alt0 function) respectively +/// When SPI0 is in use (ie after bcm2835_spi_begin()), pins 19, 21, 23, 24, 26 are dedicated to SPI +/// and cant be controlled independently +typedef enum +{ + RPI_GPIO_P1_03 = 0, ///< Version 1, Pin P1-03 + RPI_GPIO_P1_05 = 1, ///< Version 1, Pin P1-05 + RPI_GPIO_P1_07 = 4, ///< Version 1, Pin P1-07 + RPI_GPIO_P1_08 = 14, ///< Version 1, Pin P1-08, defaults to alt function 0 UART0_TXD + RPI_GPIO_P1_10 = 15, ///< Version 1, Pin P1-10, defaults to alt function 0 UART0_RXD + RPI_GPIO_P1_11 = 17, ///< Version 1, Pin P1-11 + RPI_GPIO_P1_12 = 18, ///< Version 1, Pin P1-12 + RPI_GPIO_P1_13 = 21, ///< Version 1, Pin P1-13 + RPI_GPIO_P1_15 = 22, ///< Version 1, Pin P1-15 + RPI_GPIO_P1_16 = 23, ///< Version 1, Pin P1-16 + RPI_GPIO_P1_18 = 24, ///< Version 1, Pin P1-18 + RPI_GPIO_P1_19 = 10, ///< Version 1, Pin P1-19, MOSI when SPI0 in use + RPI_GPIO_P1_21 = 9, ///< Version 1, Pin P1-21, MISO when SPI0 in use + RPI_GPIO_P1_22 = 25, ///< Version 1, Pin P1-22 + RPI_GPIO_P1_23 = 11, ///< Version 1, Pin P1-23, CLK when SPI0 in use + RPI_GPIO_P1_24 = 8, ///< Version 1, Pin P1-24, CE0 when SPI0 in use + RPI_GPIO_P1_26 = 7, ///< Version 1, Pin P1-26, CE1 when SPI0 in use + + // RPi Version 2 + RPI_V2_GPIO_P1_03 = 2, ///< Version 2, Pin P1-03 + RPI_V2_GPIO_P1_05 = 3, ///< Version 2, Pin P1-05 + RPI_V2_GPIO_P1_07 = 4, ///< Version 2, Pin P1-07 + RPI_V2_GPIO_P1_08 = 14, ///< Version 2, Pin P1-08, defaults to alt function 0 UART0_TXD + RPI_V2_GPIO_P1_10 = 15, ///< Version 2, Pin P1-10, defaults to alt function 0 UART0_RXD + RPI_V2_GPIO_P1_11 = 17, ///< Version 2, Pin P1-11 + RPI_V2_GPIO_P1_12 = 18, ///< Version 2, Pin P1-12 + RPI_V2_GPIO_P1_13 = 27, ///< Version 2, Pin P1-13 + RPI_V2_GPIO_P1_15 = 22, ///< Version 2, Pin P1-15 + RPI_V2_GPIO_P1_16 = 23, ///< Version 2, Pin P1-16 + RPI_V2_GPIO_P1_18 = 24, ///< Version 2, Pin P1-18 + RPI_V2_GPIO_P1_19 = 10, ///< Version 2, Pin P1-19, MOSI when SPI0 in use + RPI_V2_GPIO_P1_21 = 9, ///< Version 2, Pin P1-21, MISO when SPI0 in use + RPI_V2_GPIO_P1_22 = 25, ///< Version 2, Pin P1-22 + RPI_V2_GPIO_P1_23 = 11, ///< Version 2, Pin P1-23, CLK when SPI0 in use + RPI_V2_GPIO_P1_24 = 8, ///< Version 2, Pin P1-24, CE0 when SPI0 in use + RPI_V2_GPIO_P1_26 = 7, ///< Version 2, Pin P1-26, CE1 when SPI0 in use + + // RPi Version 2, new plug P5 + RPI_V2_GPIO_P5_03 = 28, ///< Version 2, Pin P5-03 + RPI_V2_GPIO_P5_04 = 29, ///< Version 2, Pin P5-04 + RPI_V2_GPIO_P5_05 = 30, ///< Version 2, Pin P5-05 + RPI_V2_GPIO_P5_06 = 31, ///< Version 2, Pin P5-06 + +} RPiGPIOPin; + +// Defines for SPI +// GPIO register offsets from BCM2835_SPI0_BASE. +// Offsets into the SPI Peripheral block in bytes per 10.5 SPI Register Map +#define BCM2835_SPI0_CS 0x0000 ///< SPI Master Control and Status +#define BCM2835_SPI0_FIFO 0x0004 ///< SPI Master TX and RX FIFOs +#define BCM2835_SPI0_CLK 0x0008 ///< SPI Master Clock Divider +#define BCM2835_SPI0_DLEN 0x000c ///< SPI Master Data Length +#define BCM2835_SPI0_LTOH 0x0010 ///< SPI LOSSI mode TOH +#define BCM2835_SPI0_DC 0x0014 ///< SPI DMA DREQ Controls + +// Register masks for SPI0_CS +#define BCM2835_SPI0_CS_LEN_LONG 0x02000000 ///< Enable Long data word in Lossi mode if DMA_LEN is set +#define BCM2835_SPI0_CS_DMA_LEN 0x01000000 ///< Enable DMA mode in Lossi mode +#define BCM2835_SPI0_CS_CSPOL2 0x00800000 ///< Chip Select 2 Polarity +#define BCM2835_SPI0_CS_CSPOL1 0x00400000 ///< Chip Select 1 Polarity +#define BCM2835_SPI0_CS_CSPOL0 0x00200000 ///< Chip Select 0 Polarity +#define BCM2835_SPI0_CS_RXF 0x00100000 ///< RXF - RX FIFO Full +#define BCM2835_SPI0_CS_RXR 0x00080000 ///< RXR RX FIFO needs Reading ( full) +#define BCM2835_SPI0_CS_TXD 0x00040000 ///< TXD TX FIFO can accept Data +#define BCM2835_SPI0_CS_RXD 0x00020000 ///< RXD RX FIFO contains Data +#define BCM2835_SPI0_CS_DONE 0x00010000 ///< Done transfer Done +#define BCM2835_SPI0_CS_TE_EN 0x00008000 ///< Unused +#define BCM2835_SPI0_CS_LMONO 0x00004000 ///< Unused +#define BCM2835_SPI0_CS_LEN 0x00002000 ///< LEN LoSSI enable +#define BCM2835_SPI0_CS_REN 0x00001000 ///< REN Read Enable +#define BCM2835_SPI0_CS_ADCS 0x00000800 ///< ADCS Automatically Deassert Chip Select +#define BCM2835_SPI0_CS_INTR 0x00000400 ///< INTR Interrupt on RXR +#define BCM2835_SPI0_CS_INTD 0x00000200 ///< INTD Interrupt on Done +#define BCM2835_SPI0_CS_DMAEN 0x00000100 ///< DMAEN DMA Enable +#define BCM2835_SPI0_CS_TA 0x00000080 ///< Transfer Active +#define BCM2835_SPI0_CS_CSPOL 0x00000040 ///< Chip Select Polarity +#define BCM2835_SPI0_CS_CLEAR 0x00000030 ///< Clear FIFO Clear RX and TX +#define BCM2835_SPI0_CS_CLEAR_RX 0x00000020 ///< Clear FIFO Clear RX +#define BCM2835_SPI0_CS_CLEAR_TX 0x00000010 ///< Clear FIFO Clear TX +#define BCM2835_SPI0_CS_CPOL 0x00000008 ///< Clock Polarity +#define BCM2835_SPI0_CS_CPHA 0x00000004 ///< Clock Phase +#define BCM2835_SPI0_CS_CS 0x00000003 ///< Chip Select + +/// \brief bcm2835SPIBitOrder SPI Bit order +/// Specifies the SPI data bit ordering for bcm2835_spi_setBitOrder() +typedef enum +{ + BCM2835_SPI_BIT_ORDER_LSBFIRST = 0, ///< LSB First + BCM2835_SPI_BIT_ORDER_MSBFIRST = 1 ///< MSB First +}bcm2835SPIBitOrder; + +/// \brief SPI Data mode +/// Specify the SPI data mode to be passed to bcm2835_spi_setDataMode() +typedef enum +{ + BCM2835_SPI_MODE0 = 0, ///< CPOL = 0, CPHA = 0 + BCM2835_SPI_MODE1 = 1, ///< CPOL = 0, CPHA = 1 + BCM2835_SPI_MODE2 = 2, ///< CPOL = 1, CPHA = 0 + BCM2835_SPI_MODE3 = 3, ///< CPOL = 1, CPHA = 1 +}bcm2835SPIMode; + +/// \brief bcm2835SPIChipSelect +/// Specify the SPI chip select pin(s) +typedef enum +{ + BCM2835_SPI_CS0 = 0, ///< Chip Select 0 + BCM2835_SPI_CS1 = 1, ///< Chip Select 1 + BCM2835_SPI_CS2 = 2, ///< Chip Select 2 (ie pins CS1 and CS2 are asserted) + BCM2835_SPI_CS_NONE = 3, ///< No CS, control it yourself +} bcm2835SPIChipSelect; + +/// \brief bcm2835SPIClockDivider +/// Specifies the divider used to generate the SPI clock from the system clock. +/// Figures below give the divider, clock period and clock frequency. +/// Clock divided is based on nominal base clock rate of 250MHz +/// It is reported that (contrary to the documentation) any even divider may used. +/// The frequencies shown for each divider have been confirmed by measurement +typedef enum +{ + BCM2835_SPI_CLOCK_DIVIDER_65536 = 0, ///< 65536 = 262.144us = 3.814697260kHz + BCM2835_SPI_CLOCK_DIVIDER_32768 = 32768, ///< 32768 = 131.072us = 7.629394531kHz + BCM2835_SPI_CLOCK_DIVIDER_16384 = 16384, ///< 16384 = 65.536us = 15.25878906kHz + BCM2835_SPI_CLOCK_DIVIDER_8192 = 8192, ///< 8192 = 32.768us = 30/51757813kHz + BCM2835_SPI_CLOCK_DIVIDER_4096 = 4096, ///< 4096 = 16.384us = 61.03515625kHz + BCM2835_SPI_CLOCK_DIVIDER_2048 = 2048, ///< 2048 = 8.192us = 122.0703125kHz + BCM2835_SPI_CLOCK_DIVIDER_1024 = 1024, ///< 1024 = 4.096us = 244.140625kHz + BCM2835_SPI_CLOCK_DIVIDER_512 = 512, ///< 512 = 2.048us = 488.28125kHz + BCM2835_SPI_CLOCK_DIVIDER_256 = 256, ///< 256 = 1.024us = 976.5625MHz + BCM2835_SPI_CLOCK_DIVIDER_128 = 128, ///< 128 = 512ns = = 1.953125MHz + BCM2835_SPI_CLOCK_DIVIDER_64 = 64, ///< 64 = 256ns = 3.90625MHz + BCM2835_SPI_CLOCK_DIVIDER_32 = 32, ///< 32 = 128ns = 7.8125MHz + BCM2835_SPI_CLOCK_DIVIDER_16 = 16, ///< 16 = 64ns = 15.625MHz + BCM2835_SPI_CLOCK_DIVIDER_8 = 8, ///< 8 = 32ns = 31.25MHz + BCM2835_SPI_CLOCK_DIVIDER_4 = 4, ///< 4 = 16ns = 62.5MHz + BCM2835_SPI_CLOCK_DIVIDER_2 = 2, ///< 2 = 8ns = 125MHz, fastest you can get + BCM2835_SPI_CLOCK_DIVIDER_1 = 1, ///< 0 = 262.144us = 3.814697260kHz, same as 0/65536 +} bcm2835SPIClockDivider; + +// Defines for I2C +// GPIO register offsets from BCM2835_BSC*_BASE. +// Offsets into the BSC Peripheral block in bytes per 3.1 BSC Register Map +#define BCM2835_BSC_C 0x0000 ///< BSC Master Control +#define BCM2835_BSC_S 0x0004 ///< BSC Master Status +#define BCM2835_BSC_DLEN 0x0008 ///< BSC Master Data Length +#define BCM2835_BSC_A 0x000c ///< BSC Master Slave Address +#define BCM2835_BSC_FIFO 0x0010 ///< BSC Master Data FIFO +#define BCM2835_BSC_DIV 0x0014 ///< BSC Master Clock Divider +#define BCM2835_BSC_DEL 0x0018 ///< BSC Master Data Delay +#define BCM2835_BSC_CLKT 0x001c ///< BSC Master Clock Stretch Timeout + +// Register masks for BSC_C +#define BCM2835_BSC_C_I2CEN 0x00008000 ///< I2C Enable, 0 = disabled, 1 = enabled +#define BCM2835_BSC_C_INTR 0x00000400 ///< Interrupt on RX +#define BCM2835_BSC_C_INTT 0x00000200 ///< Interrupt on TX +#define BCM2835_BSC_C_INTD 0x00000100 ///< Interrupt on DONE +#define BCM2835_BSC_C_ST 0x00000080 ///< Start transfer, 1 = Start a new transfer +#define BCM2835_BSC_C_CLEAR_1 0x00000020 ///< Clear FIFO Clear +#define BCM2835_BSC_C_CLEAR_2 0x00000010 ///< Clear FIFO Clear +#define BCM2835_BSC_C_READ 0x00000001 ///< Read transfer + +// Register masks for BSC_S +#define BCM2835_BSC_S_CLKT 0x00000200 ///< Clock stretch timeout +#define BCM2835_BSC_S_ERR 0x00000100 ///< ACK error +#define BCM2835_BSC_S_RXF 0x00000080 ///< RXF FIFO full, 0 = FIFO is not full, 1 = FIFO is full +#define BCM2835_BSC_S_TXE 0x00000040 ///< TXE FIFO full, 0 = FIFO is not full, 1 = FIFO is full +#define BCM2835_BSC_S_RXD 0x00000020 ///< RXD FIFO contains data +#define BCM2835_BSC_S_TXD 0x00000010 ///< TXD FIFO can accept data +#define BCM2835_BSC_S_RXR 0x00000008 ///< RXR FIFO needs reading (full) +#define BCM2835_BSC_S_TXW 0x00000004 ///< TXW FIFO needs writing (full) +#define BCM2835_BSC_S_DONE 0x00000002 ///< Transfer DONE +#define BCM2835_BSC_S_TA 0x00000001 ///< Transfer Active + +#define BCM2835_BSC_FIFO_SIZE 16 ///< BSC FIFO size + +/// \brief bcm2835I2CClockDivider +/// Specifies the divider used to generate the I2C clock from the system clock. +/// Clock divided is based on nominal base clock rate of 250MHz +typedef enum +{ + BCM2835_I2C_CLOCK_DIVIDER_2500 = 2500, ///< 2500 = 10us = 100 kHz + BCM2835_I2C_CLOCK_DIVIDER_626 = 626, ///< 622 = 2.504us = 399.3610 kHz + BCM2835_I2C_CLOCK_DIVIDER_150 = 150, ///< 150 = 60ns = 1.666 MHz (default at reset) + BCM2835_I2C_CLOCK_DIVIDER_148 = 148, ///< 148 = 59ns = 1.689 MHz +} bcm2835I2CClockDivider; + +/// \brief bcm2835I2CReasonCodes +/// Specifies the reason codes for the bcm2835_i2c_write and bcm2835_i2c_read functions. +typedef enum +{ + BCM2835_I2C_REASON_OK = 0x00, ///< Success + BCM2835_I2C_REASON_ERROR_NACK = 0x01, ///< Received a NACK + BCM2835_I2C_REASON_ERROR_CLKT = 0x02, ///< Received Clock Stretch Timeout + BCM2835_I2C_REASON_ERROR_DATA = 0x04, ///< Not all data is sent / received +} bcm2835I2CReasonCodes; + +// Defines for ST +// GPIO register offsets from BCM2835_ST_BASE. +// Offsets into the ST Peripheral block in bytes per 12.1 System Timer Registers +// The System Timer peripheral provides four 32-bit timer channels and a single 64-bit free running counter. +// BCM2835_ST_CLO is the System Timer Counter Lower bits register. +// The system timer free-running counter lower register is a read-only register that returns the current value +// of the lower 32-bits of the free running counter. +// BCM2835_ST_CHI is the System Timer Counter Upper bits register. +// The system timer free-running counter upper register is a read-only register that returns the current value +// of the upper 32-bits of the free running counter. +#define BCM2835_ST_CS 0x0000 ///< System Timer Control/Status +#define BCM2835_ST_CLO 0x0004 ///< System Timer Counter Lower 32 bits +#define BCM2835_ST_CHI 0x0008 ///< System Timer Counter Upper 32 bits + +/// @} + + +// Defines for PWM +#define BCM2835_PWM_CONTROL 0 +#define BCM2835_PWM_STATUS 1 +#define BCM2835_PWM0_RANGE 4 +#define BCM2835_PWM0_DATA 5 +#define BCM2835_PWM1_RANGE 8 +#define BCM2835_PWM1_DATA 9 + +#define BCM2835_PWMCLK_CNTL 40 +#define BCM2835_PWMCLK_DIV 41 + +#define BCM2835_PWM1_MS_MODE 0x8000 /// Run in MS mode +#define BCM2835_PWM1_USEFIFO 0x2000 /// Data from FIFO +#define BCM2835_PWM1_REVPOLAR 0x1000 /// Reverse polarity +#define BCM2835_PWM1_OFFSTATE 0x0800 /// Ouput Off state +#define BCM2835_PWM1_REPEATFF 0x0400 /// Repeat last value if FIFO empty +#define BCM2835_PWM1_SERIAL 0x0200 /// Run in serial mode +#define BCM2835_PWM1_ENABLE 0x0100 /// Channel Enable + +#define BCM2835_PWM0_MS_MODE 0x0080 /// Run in MS mode +#define BCM2835_PWM0_USEFIFO 0x0020 /// Data from FIFO +#define BCM2835_PWM0_REVPOLAR 0x0010 /// Reverse polarity +#define BCM2835_PWM0_OFFSTATE 0x0008 /// Ouput Off state +#define BCM2835_PWM0_REPEATFF 0x0004 /// Repeat last value if FIFO empty +#define BCM2835_PWM0_SERIAL 0x0002 /// Run in serial mode +#define BCM2835_PWM0_ENABLE 0x0001 /// Channel Enable + +// Historical name compatibility +#ifndef BCM2835_NO_DELAY_COMPATIBILITY +#define delay(x) bcm2835_delay(x) +#define delayMicroseconds(x) bcm2835_delayMicroseconds(x) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + /// \defgroup init Library initialisation and management + /// These functions allow you to intialise and control the bcm2835 library + /// @{ + + /// Initialise the library by opening /dev/mem and getting pointers to the + /// internal memory for BCM 2835 device registers. You must call this (successfully) + /// before calling any other + /// functions in this library (except bcm2835_set_debug). + /// If bcm2835_init() fails by returning 0, + /// calling any other function may result in crashes or other failures. + /// Prints messages to stderr in case of errors. + /// \return 1 if successful else 0 + extern int bcm2835_init(void); + + /// Close the library, deallocating any allocated memory and closing /dev/mem + /// \return 1 if successful else 0 + extern int bcm2835_close(void); + + /// Sets the debug level of the library. + /// A value of 1 prevents mapping to /dev/mem, and makes the library print out + /// what it would do, rather than accessing the GPIO registers. + /// A value of 0, the default, causes normal operation. + /// Call this before calling bcm2835_init(); + /// \param[in] debug The new debug level. 1 means debug + extern void bcm2835_set_debug(uint8_t debug); + + /// @} // end of init + + /// \defgroup lowlevel Low level register access + /// These functions provide low level register access, and should not generally + /// need to be used + /// + /// @{ + + /// Reads 32 bit value from a peripheral address + /// The read is done twice, and is therefore always safe in terms of + /// manual section 1.3 Peripheral access precautions for correct memory ordering + /// \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc. + /// \return the value read from the 32 bit register + /// \sa Physical Addresses + extern uint32_t bcm2835_peri_read(volatile uint32_t* paddr); + + + /// Reads 32 bit value from a peripheral address without the read barrier + /// You should only use this when your code has previously called bcm2835_peri_read() + /// within the same peripheral, and no other peripheral access has occurred since. + /// \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc. + /// \return the value read from the 32 bit register + /// \sa Physical Addresses + extern uint32_t bcm2835_peri_read_nb(volatile uint32_t* paddr); + + + /// Writes 32 bit value from a peripheral address + /// The write is done twice, and is therefore always safe in terms of + /// manual section 1.3 Peripheral access precautions for correct memory ordering + /// \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc. + /// \param[in] value The 32 bit value to write + /// \sa Physical Addresses + extern void bcm2835_peri_write(volatile uint32_t* paddr, uint32_t value); + + /// Writes 32 bit value from a peripheral address without the write barrier + /// You should only use this when your code has previously called bcm2835_peri_write() + /// within the same peripheral, and no other peripheral access has occurred since. + /// \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc. + /// \param[in] value The 32 bit value to write + /// \sa Physical Addresses + extern void bcm2835_peri_write_nb(volatile uint32_t* paddr, uint32_t value); + + /// Alters a number of bits in a 32 peripheral regsiter. + /// It reads the current valu and then alters the bits deines as 1 in mask, + /// according to the bit value in value. + /// All other bits that are 0 in the mask are unaffected. + /// Use this to alter a subset of the bits in a register. + /// The write is done twice, and is therefore always safe in terms of + /// manual section 1.3 Peripheral access precautions for correct memory ordering + /// \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc. + /// \param[in] value The 32 bit value to write, masked in by mask. + /// \param[in] mask Bitmask that defines the bits that will be altered in the register. + /// \sa Physical Addresses + extern void bcm2835_peri_set_bits(volatile uint32_t* paddr, uint32_t value, uint32_t mask); + /// @} // end of lowlevel + + /// \defgroup gpio GPIO register access + /// These functions allow you to control the GPIO interface. You can set the + /// function of each GPIO pin, read the input state and set the output state. + /// @{ + + /// Sets the Function Select register for the given pin, which configures + /// the pin as Input, Output or one of the 6 alternate functions. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from RPiGPIOPin. + /// \param[in] mode Mode to set the pin to, one of BCM2835_GPIO_FSEL_* from \ref bcm2835FunctionSelect + extern void bcm2835_gpio_fsel(uint8_t pin, uint8_t mode); + + /// Sets the specified pin output to + /// HIGH. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \sa bcm2835_gpio_write() + extern void bcm2835_gpio_set(uint8_t pin); + + /// Sets the specified pin output to + /// LOW. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \sa bcm2835_gpio_write() + extern void bcm2835_gpio_clr(uint8_t pin); + + /// Sets any of the first 32 GPIO output pins specified in the mask to + /// HIGH. + /// \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05) + /// \sa bcm2835_gpio_write_multi() + extern void bcm2835_gpio_set_multi(uint32_t mask); + + /// Sets any of the first 32 GPIO output pins specified in the mask to + /// LOW. + /// \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05) + /// \sa bcm2835_gpio_write_multi() + extern void bcm2835_gpio_clr_multi(uint32_t mask); + + /// Reads the current level on the specified + /// pin and returns either HIGH or LOW. Works whether or not the pin + /// is an input or an output. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \return the current level either HIGH or LOW + extern uint8_t bcm2835_gpio_lev(uint8_t pin); + + /// Event Detect Status. + /// Tests whether the specified pin has detected a level or edge + /// as requested by bcm2835_gpio_ren(), bcm2835_gpio_fen(), bcm2835_gpio_hen(), + /// bcm2835_gpio_len(), bcm2835_gpio_aren(), bcm2835_gpio_afen(). + /// Clear the flag for a given pin by calling bcm2835_gpio_set_eds(pin); + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \return HIGH if the event detect status for th given pin is true. + extern uint8_t bcm2835_gpio_eds(uint8_t pin); + + /// Sets the Event Detect Status register for a given pin to 1, + /// which has the effect of clearing the flag. Use this afer seeing + /// an Event Detect Status on the pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_set_eds(uint8_t pin); + + /// Enable Rising Edge Detect Enable for the specified pin. + /// When a rising edge is detected, sets the appropriate pin in Event Detect Status. + /// The GPRENn registers use + /// synchronous edge detection. This means the input signal is sampled using the + /// system clock and then it is looking for a ?011? pattern on the sampled signal. This + /// has the effect of suppressing glitches. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_ren(uint8_t pin); + + /// Disable Rising Edge Detect Enable for the specified pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_clr_ren(uint8_t pin); + + /// Enable Falling Edge Detect Enable for the specified pin. + /// When a falling edge is detected, sets the appropriate pin in Event Detect Status. + /// The GPRENn registers use + /// synchronous edge detection. This means the input signal is sampled using the + /// system clock and then it is looking for a ?100? pattern on the sampled signal. This + /// has the effect of suppressing glitches. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_fen(uint8_t pin); + + /// Disable Falling Edge Detect Enable for the specified pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_clr_fen(uint8_t pin); + + /// Enable High Detect Enable for the specified pin. + /// When a HIGH level is detected on the pin, sets the appropriate pin in Event Detect Status. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_hen(uint8_t pin); + + /// Disable High Detect Enable for the specified pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_clr_hen(uint8_t pin); + + /// Enable Low Detect Enable for the specified pin. + /// When a LOW level is detected on the pin, sets the appropriate pin in Event Detect Status. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_len(uint8_t pin); + + /// Disable Low Detect Enable for the specified pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_clr_len(uint8_t pin); + + /// Enable Asynchronous Rising Edge Detect Enable for the specified pin. + /// When a rising edge is detected, sets the appropriate pin in Event Detect Status. + /// Asynchronous means the incoming signal is not sampled by the system clock. As such + /// rising edges of very short duration can be detected. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_aren(uint8_t pin); + + /// Disable Asynchronous Rising Edge Detect Enable for the specified pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_clr_aren(uint8_t pin); + + /// Enable Asynchronous Falling Edge Detect Enable for the specified pin. + /// When a falling edge is detected, sets the appropriate pin in Event Detect Status. + /// Asynchronous means the incoming signal is not sampled by the system clock. As such + /// falling edges of very short duration can be detected. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_afen(uint8_t pin); + + /// Disable Asynchronous Falling Edge Detect Enable for the specified pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_clr_afen(uint8_t pin); + + /// Sets the Pull-up/down register for the given pin. This is + /// used with bcm2835_gpio_pudclk() to set the Pull-up/down resistor for the given pin. + /// However, it is usually more convenient to use bcm2835_gpio_set_pud(). + /// \param[in] pud The desired Pull-up/down mode. One of BCM2835_GPIO_PUD_* from bcm2835PUDControl + /// \sa bcm2835_gpio_set_pud() + extern void bcm2835_gpio_pud(uint8_t pud); + + /// Clocks the Pull-up/down value set earlier by bcm2835_gpio_pud() into the pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \param[in] on HIGH to clock the value from bcm2835_gpio_pud() into the pin. + /// LOW to remove the clock. + /// \sa bcm2835_gpio_set_pud() + extern void bcm2835_gpio_pudclk(uint8_t pin, uint8_t on); + + /// Reads and returns the Pad Control for the given GPIO group. + /// \param[in] group The GPIO pad group number, one of BCM2835_PAD_GROUP_GPIO_* + /// \return Mask of bits from BCM2835_PAD_* from \ref bcm2835PadGroup + extern uint32_t bcm2835_gpio_pad(uint8_t group); + + /// Sets the Pad Control for the given GPIO group. + /// \param[in] group The GPIO pad group number, one of BCM2835_PAD_GROUP_GPIO_* + /// \param[in] control Mask of bits from BCM2835_PAD_* from \ref bcm2835PadGroup + extern void bcm2835_gpio_set_pad(uint8_t group, uint32_t control); + + /// Delays for the specified number of milliseconds. + /// Uses nanosleep(), and therefore does not use CPU until the time is up. + /// However, you are at the mercy of nanosleep(). From the manual for nanosleep(): + /// If the interval specified in req is not an exact multiple of the granularity + /// underlying clock (see time(7)), then the interval will be + /// rounded up to the next multiple. Furthermore, after the sleep completes, + /// there may still be a delay before the CPU becomes free to once + /// again execute the calling thread. + /// \param[in] millis Delay in milliseconds + extern void bcm2835_delay (unsigned int millis); + + /// Delays for the specified number of microseconds. + /// Uses a combination of nanosleep() and a busy wait loop on the BCM2835 system timers, + /// However, you are at the mercy of nanosleep(). From the manual for nanosleep(): + /// If the interval specified in req is not an exact multiple of the granularity + /// underlying clock (see time(7)), then the interval will be + /// rounded up to the next multiple. Furthermore, after the sleep completes, + /// there may still be a delay before the CPU becomes free to once + /// again execute the calling thread. + /// For times less than about 450 microseconds, uses a busy wait on the System Timer. + /// It is reported that a delay of 0 microseconds on RaspberryPi will in fact + /// result in a delay of about 80 microseconds. Your mileage may vary. + /// \param[in] micros Delay in microseconds + extern void bcm2835_delayMicroseconds (uint64_t micros); + + /// Sets the output state of the specified pin + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \param[in] on HIGH sets the output to HIGH and LOW to LOW. + extern void bcm2835_gpio_write(uint8_t pin, uint8_t on); + + /// Sets any of the first 32 GPIO output pins specified in the mask to the state given by on + /// \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05) + /// \param[in] on HIGH sets the output to HIGH and LOW to LOW. + extern void bcm2835_gpio_write_multi(uint32_t mask, uint8_t on); + + /// Sets the first 32 GPIO output pins specified in the mask to the value given by value + /// \param[in] value values required for each bit masked in by mask, eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05) + /// \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05) + extern void bcm2835_gpio_write_mask(uint32_t value, uint32_t mask); + + /// Sets the Pull-up/down mode for the specified pin. This is more convenient than + /// clocking the mode in with bcm2835_gpio_pud() and bcm2835_gpio_pudclk(). + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \param[in] pud The desired Pull-up/down mode. One of BCM2835_GPIO_PUD_* from bcm2835PUDControl + extern void bcm2835_gpio_set_pud(uint8_t pin, uint8_t pud); + + /// @} + + /// \defgroup spi SPI access + /// These functions let you use SPI0 (Serial Peripheral Interface) to + /// interface with an external SPI device. + /// @{ + + /// Start SPI operations. + /// Forces RPi SPI0 pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1) + /// to alternate function ALT0, which enables those pins for SPI interface. + /// You should call bcm2835_spi_end() when all SPI funcitons are complete to return the pins to + /// their default functions + /// \sa bcm2835_spi_end() + extern void bcm2835_spi_begin(void); + + /// End SPI operations. + /// SPI0 pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1) + /// are returned to their default INPUT behaviour. + extern void bcm2835_spi_end(void); + + /// Sets the SPI bit order + /// NOTE: has no effect. Not supported by SPI0. + /// Defaults to + /// \param[in] order The desired bit order, one of BCM2835_SPI_BIT_ORDER_*, + /// see \ref bcm2835SPIBitOrder + extern void bcm2835_spi_setBitOrder(uint8_t order); + + /// Sets the SPI clock divider and therefore the + /// SPI clock speed. + /// \param[in] divider The desired SPI clock divider, one of BCM2835_SPI_CLOCK_DIVIDER_*, + /// see \ref bcm2835SPIClockDivider + extern void bcm2835_spi_setClockDivider(uint16_t divider); + + /// Sets the SPI data mode + /// Sets the clock polariy and phase + /// \param[in] mode The desired data mode, one of BCM2835_SPI_MODE*, + /// see \ref bcm2835SPIMode + extern void bcm2835_spi_setDataMode(uint8_t mode); + + /// Sets the chip select pin(s) + /// When an bcm2835_spi_transfer() is made, the selected pin(s) will be asserted during the + /// transfer. + /// \param[in] cs Specifies the CS pins(s) that are used to activate the desired slave. + /// One of BCM2835_SPI_CS*, see \ref bcm2835SPIChipSelect + extern void bcm2835_spi_chipSelect(uint8_t cs); + + /// Sets the chip select pin polarity for a given pin + /// When an bcm2835_spi_transfer() occurs, the currently selected chip select pin(s) + /// will be asserted to the + /// value given by active. When transfers are not happening, the chip select pin(s) + /// return to the complement (inactive) value. + /// \param[in] cs The chip select pin to affect + /// \param[in] active Whether the chip select pin is to be active HIGH + extern void bcm2835_spi_setChipSelectPolarity(uint8_t cs, uint8_t active); + + /// Transfers one byte to and from the currently selected SPI slave. + /// Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect) + /// during the transfer. + /// Clocks the 8 bit value out on MOSI, and simultaneously clocks in data from MISO. + /// Returns the read data byte from the slave. + /// Uses polled transfer as per section 10.6.1 of the BCM 2835 ARM Peripherls manual + /// \param[in] value The 8 bit data byte to write to MOSI + /// \return The 8 bit byte simultaneously read from MISO + /// \sa bcm2835_spi_transfern() + extern uint8_t bcm2835_spi_transfer(uint8_t value); + + /// Transfers any number of bytes to and from the currently selected SPI slave. + /// Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect) + /// during the transfer. + /// Clocks the len 8 bit bytes out on MOSI, and simultaneously clocks in data from MISO. + /// The data read read from the slave is placed into rbuf. rbuf must be at least len bytes long + /// Uses polled transfer as per section 10.6.1 of the BCM 2835 ARM Peripherls manual + /// \param[in] tbuf Buffer of bytes to send. + /// \param[out] rbuf Received bytes will by put in this buffer + /// \param[in] len Number of bytes in the tbuf buffer, and the number of bytes to send/received + /// \sa bcm2835_spi_transfer() + extern void bcm2835_spi_transfernb(char* tbuf, char* rbuf, uint32_t len); + + /// Transfers any number of bytes to and from the currently selected SPI slave + /// using bcm2835_spi_transfernb. + /// The returned data from the slave replaces the transmitted data in the buffer. + /// \param[in,out] buf Buffer of bytes to send. Received bytes will replace the contents + /// \param[in] len Number of bytes int eh buffer, and the number of bytes to send/received + /// \sa bcm2835_spi_transfer() + extern void bcm2835_spi_transfern(char* buf, uint32_t len); + + /// Transfers any number of bytes to the currently selected SPI slave. + /// Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect) + /// during the transfer. + /// \param[in] buf Buffer of bytes to send. + /// \param[in] len Number of bytes in the tbuf buffer, and the number of bytes to send + extern void bcm2835_spi_writenb(char* buf, uint32_t len); + + /// @} + + /// \defgroup i2c I2C access + /// These functions let you use I2C (The Broadcom Serial Control bus with the Philips + /// I2C bus/interface version 2.1 January 2000.) to interface with an external I2C device. + /// @{ + + /// Start I2C operations. + /// Forces RPi I2C pins P1-03 (SDA) and P1-05 (SCL) + /// to alternate function ALT0, which enables those pins for I2C interface. + /// You should call bcm2835_i2c_end() when all I2C functions are complete to return the pins to + /// their default functions + /// \sa bcm2835_i2c_end() + extern void bcm2835_i2c_begin(void); + + /// End I2C operations. + /// I2C pins P1-03 (SDA) and P1-05 (SCL) + /// are returned to their default INPUT behaviour. + extern void bcm2835_i2c_end(void); + + /// Sets the I2C slave address. + /// \param[in] addr The I2C slave address. + extern void bcm2835_i2c_setSlaveAddress(uint8_t addr); + + /// Sets the I2C clock divider and therefore the I2C clock speed. + /// \param[in] divider The desired I2C clock divider, one of BCM2835_I2C_CLOCK_DIVIDER_*, + /// see \ref bcm2835I2CClockDivider + extern void bcm2835_i2c_setClockDivider(uint16_t divider); + + /// Sets the I2C clock divider by converting the baudrate parameter to + /// the equivalent I2C clock divider. ( see \sa bcm2835_i2c_setClockDivider) + /// For the I2C standard 100khz you would set baudrate to 100000 + /// The use of baudrate corresponds to its use in the I2C kernel device + /// driver. (Of course, bcm2835 has nothing to do with the kernel driver) + extern void bcm2835_i2c_set_baudrate(uint32_t baudrate); + + /// Transfers any number of bytes to the currently selected I2C slave. + /// (as previously set by \sa bcm2835_i2c_setSlaveAddress) + /// \param[in] buf Buffer of bytes to send. + /// \param[in] len Number of bytes in the buf buffer, and the number of bytes to send. + /// \return reason see \ref bcm2835I2CReasonCodes + extern uint8_t bcm2835_i2c_write(const char * buf, uint32_t len); + + /// Transfers any number of bytes from the currently selected I2C slave. + /// (as previously set by \sa bcm2835_i2c_setSlaveAddress) + /// \param[in] buf Buffer of bytes to receive. + /// \param[in] len Number of bytes in the buf buffer, and the number of bytes to received. + /// \return reason see \ref bcm2835I2CReasonCodes + extern uint8_t bcm2835_i2c_read(char* buf, uint32_t len); + + /// Allows reading from I2C slaves that require a repeated start (without any prior stop) + /// to read after the required slave register has been set. For example, the popular + /// MPL3115A2 pressure and temperature sensor. Note that your device must support or + /// require this mode. If your device does not require this mode then the standard + /// combined: + /// \sa bcm2835_i2c_write + /// \sa bcm2835_i2c_read + /// are a better choice. + /// Will read from the slave previously set by \sa bcm2835_i2c_setSlaveAddress + /// \param[in] regaddr Buffer containing the slave register you wish to read from. + /// \param[in] buf Buffer of bytes to receive. + /// \param[in] len Number of bytes in the buf buffer, and the number of bytes to received. + /// \return reason see \ref bcm2835I2CReasonCodes + extern uint8_t bcm2835_i2c_read_register_rs(char* regaddr, char* buf, uint32_t len); + + /// @} + + /// \defgroup st System Timer access + /// Allows access to and delays using the System Timer Counter. + /// @{ + + /// Read the System Timer Counter register. + /// \return the value read from the System Timer Counter Lower 32 bits register + uint64_t bcm2835_st_read(void); + + /// Delays for the specified number of microseconds with offset. + /// \param[in] offset_micros Offset in microseconds + /// \param[in] micros Delay in microseconds + extern void bcm2835_st_delay(uint64_t offset_micros, uint64_t micros); + + /// @} + +#ifdef __cplusplus +} +#endif + +#endif // BCM2835_H + +/// @example blink.c +/// Blinks RPi GPIO pin 11 on and off + +/// @example input.c +/// Reads the state of an RPi input pin + +/// @example event.c +/// Shows how to use event detection on an input pin + +/// @example spi.c +/// Shows how to use SPI interface to transfer a byte to and from an SPI device + +/// @example spin.c +/// Shows how to use SPI interface to transfer a number of bytes to and from an SPI device diff --git a/samples/C++/rpc.h b/samples/C++/rpc.h new file mode 100644 index 00000000..ce810992 --- /dev/null +++ b/samples/C++/rpc.h @@ -0,0 +1,26 @@ +// Copyright (C) 2013 Simon Que +// +// This file is part of DuinoCube. +// +// DuinoCube is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// DuinoCube is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with DuinoCube. If not, see . + +// DuinoCube remote procedure call functions. + +#include + +// Initializes RPC system. +void rpc_init(); + +// Runs the RPC server loop forever. +void rpc_server_loop();