Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
2f5240f
Transition lf_* funcs to accept a device pointer.
georgemorgan Feb 18, 2018
d25ea63
Fix Python bindings
georgemorgan Feb 18, 2018
b79390d
Pass explicit device pointer to lf_invoke in rust bindings
nicholastmosher Feb 18, 2018
9027646
Update makefile, clean up files
georgemorgan Mar 10, 2018
402bf01
Clean up makefile
georgemorgan Mar 10, 2018
995a119
pip2 -> pip
georgemorgan Mar 10, 2018
dd694de
Move modules to api folder.
georgemorgan Mar 10, 2018
d7eff0a
Add new LF_FUNC macro to builtins
georgemorgan Mar 10, 2018
b1f70d1
Generate the standard modules!
georgemorgan Mar 10, 2018
301c6f4
Generate top level carbon.c temporarily
georgemorgan Mar 11, 2018
fb443ab
Update travis and makefile
georgemorgan Mar 11, 2018
6a882f3
Update makefile to add help
georgemorgan Mar 12, 2018
1cc9d8c
Dynamic load overhaul. Standard module == user module. Modules loaded…
georgemorgan Mar 13, 2018
2bde467
Update python bindings
georgemorgan Mar 13, 2018
e2fe590
Travis install python3-pip and pyelftools
nicholastmosher Mar 13, 2018
be25d62
Auto generate the standard modules instead of creating them at runtime
georgemorgan Mar 13, 2018
f313df5
Update FVM for module loading.
georgemorgan Mar 13, 2018
38662a1
Update to python3
georgemorgan Mar 13, 2018
1418ad2
Fix rust bindings, remove all '_lf_module'
georgemorgan Mar 13, 2018
f695478
Update python bindings to python 3
georgemorgan Mar 13, 2018
a6be02e
Clean up rust bindings, add module specific device field
georgemorgan Mar 13, 2018
811abca
Update FVM. Fix dyld index error.
georgemorgan Mar 13, 2018
5714108
Add toolchain makefile, update fdwarf for multifile gen, and update m…
georgemorgan Mar 14, 2018
5e07668
Remove unused module files
georgemorgan Mar 14, 2018
83d1138
Makefile remakes generated sources - now in multiple dirs
georgemorgan Mar 14, 2018
6514c0c
Update module+app example for new dynamic loading. Update module buil…
georgemorgan Mar 14, 2018
b7dfaae
Configure ALL the modules!
georgemorgan Mar 21, 2018
81434a8
drivers->asf, update fload, remove fld, move hal headers
georgemorgan Mar 21, 2018
7534479
Rip up unneeded scheduler stuff.
georgemorgan Mar 21, 2018
6dabbb6
Fix up section patching
georgemorgan Mar 21, 2018
f839406
Register FVM modules.
georgemorgan Mar 21, 2018
a11f27e
LF_FUNC for FVM, .lf.modules. -> .lm.
georgemorgan Mar 21, 2018
ccf21c6
Organize libflipper.h
georgemorgan Mar 21, 2018
6de8b06
I changed my mind about FVM dyld_register
georgemorgan Mar 21, 2018
8200e08
Pass index during module creation. jumptable->interface
georgemorgan Mar 21, 2018
3444b49
Fix strcpy error
georgemorgan Mar 21, 2018
9ce2948
Add initial tests.
georgemorgan Mar 23, 2018
76dc6ec
Everything is libflipper. Libflipper is one.
georgemorgan Mar 23, 2018
3e9bc14
U2 is restored.
georgemorgan Mar 23, 2018
90d6b8e
Restore pushing/pulling
georgemorgan Mar 23, 2018
be130d6
Restore FDFU. Fix FDFU failure bug.
georgemorgan Mar 27, 2018
b0551dd
GC sections for now. Add peripheral configurations.
georgemorgan Mar 27, 2018
ec3b9b3
Add variable baudrate
georgemorgan Mar 27, 2018
144a785
Endpoints take device reference.
georgemorgan Mar 27, 2018
e1a7795
Default to POSIX.
georgemorgan Apr 2, 2018
fa76164
Rip out event system.
georgemorgan Apr 2, 2018
8250118
Remove unneded helper functions.
georgemorgan Apr 2, 2018
ed896d9
Separate debug, &_packet, remove event list
georgemorgan Apr 2, 2018
859ca59
runtime.c -> libflipper.c (merge)
georgemorgan Apr 2, 2018
08432a0
Remove stray flipper.h include
georgemorgan Apr 2, 2018
4f2983b
Unifiy implementation for fmr_push and fmr_pull
georgemorgan Apr 2, 2018
b8034c9
Fixing lf_push lf_pull
georgemorgan Apr 2, 2018
1d6d80a
Fix usart in FVM, fix FMR packet parsing issue.
georgemorgan Apr 3, 2018
92b94e4
Fix int return type issue
georgemorgan Apr 3, 2018
670b8a9
Select u2 in sam for carbon hal
georgemorgan Apr 3, 2018
72f5749
Remove unneeded files
georgemorgan Apr 3, 2018
dec8c6c
Merge endpoint with device, push->write, pull->read
georgemorgan Apr 12, 2018
038d798
Restore U2 comms
georgemorgan Apr 12, 2018
c1b4868
Split device and endpoint contexts, restore carbon HAL
georgemorgan Apr 12, 2018
965063c
Update FMR signals.
georgemorgan Apr 16, 2018
c5c549f
Add force erase to makefile
georgemorgan Apr 16, 2018
19bbcee
Change push,pull mechanics. push,pull->write,read
georgemorgan Apr 17, 2018
f4d0653
Remove lf_size_t type. source->src, destination->dst
georgemorgan Apr 17, 2018
b76962d
Fix size_t discrepancy
georgemorgan Apr 18, 2018
0c083a8
push,pull now return int for error
georgemorgan Apr 20, 2018
0e97d06
Module name is now const char *
georgemorgan Apr 20, 2018
f91d19b
Fix literal suffix problem.
georgemorgan Apr 23, 2018
282a6ef
Remove libc shim, add lf_malloc and lf_free
georgemorgan Apr 23, 2018
1188c17
Implement malloc and free on device side.
georgemorgan Apr 23, 2018
4f414b5
Update lf_invoke API to return retval, update carbon API
georgemorgan Apr 23, 2018
55ddb49
Fix invoke return value
georgemorgan Apr 23, 2018
c0c1b95
fmr_execute -> fmr_invoke
georgemorgan Apr 23, 2018
0e338f7
Silence some warnings
georgemorgan Apr 23, 2018
4916e4d
Change push pull size type, add uart0 debugging to fvm
georgemorgan Apr 23, 2018
c1fcc1a
current_device()->fvm
georgemorgan Apr 26, 2018
14dd5ac
fvm target for module building
georgemorgan Apr 26, 2018
18d4b64
Adjust malloc sizes
georgemorgan Apr 26, 2018
22d438e
Return once buffer copied in uart0
georgemorgan Apr 26, 2018
fcdd784
Update u2 return value to uint64_t
georgemorgan Apr 26, 2018
b1f8faa
Add FMR pin check back
georgemorgan Apr 26, 2018
b214f7f
-Wpedantic, remove stragglers from libflipper.h
georgemorgan May 24, 2018
eeb6d2c
lf_get_current_device -> lf_get_selected
georgemorgan May 24, 2018
3d4cd59
failure -> fail
georgemorgan May 24, 2018
0045a7f
Remove ~ from comments
georgemorgan May 24, 2018
a2f4f39
Fix find-and-replace fail back to failure
nicholastmosher Jun 10, 2018
e1b5976
[WIP] Swift bindings
harlanhaskins Feb 9, 2018
a5acb76
Replace UnsafePointer conformances with a DevicePointer struct.
harlanhaskins Feb 9, 2018
e3affe7
Fix types
harlanhaskins Feb 9, 2018
205b9f6
Fix build errors
harlanhaskins Feb 9, 2018
fb67129
Publicize ModuleFFI
harlanhaskins Feb 9, 2018
b3257b5
Publicize ModuleFFI methods
harlanhaskins Feb 9, 2018
87b36a9
asdf
harlanhaskins Feb 11, 2018
a366853
add test LED module
harlanhaskins Feb 18, 2018
479ba0c
add test LED module
harlanhaskins Feb 18, 2018
c521e2b
Fix LED Example
harlanhaskins Feb 18, 2018
ae2a860
Update for Clibflipper's separate package
harlanhaskins Apr 20, 2018
1753958
Publicize LED
harlanhaskins Apr 20, 2018
8dc61f3
Update for the new libflipper API
harlanhaskins Apr 20, 2018
c1d9b11
Rearrange pull(from:byteCount:) API
harlanhaskins Apr 20, 2018
26109dc
Remove file comments
harlanhaskins Apr 20, 2018
846baa7
Update for the new libflipper API
harlanhaskins Apr 26, 2018
66a07df
Create lf_arg objects when populating an lf_ll
harlanhaskins Jun 7, 2018
127daac
Flip order of LED module functions
harlanhaskins Jun 7, 2018
12fe776
Make Bool LFArg and LFReturnable
harlanhaskins Jun 7, 2018
3dd4e32
WIP: Module generation for Swift
harlanhaskins Jun 10, 2018
0f1a374
Update Swift bindings to point to a system Clibflipper target
georgemorgan Sep 10, 2018
3a32845
drivers->asf, update fload, remove fld, move hal headers
georgemorgan Mar 21, 2018
f5c71a0
Cleanup and API revisions
georgemorgan Jun 10, 2018
182a72c
revert drivers
georgemorgan Jun 10, 2018
b0fff14
format improvements
georgemorgan Jun 10, 2018
242e16b
remove cross platform dfu boot
georgemorgan Jun 10, 2018
e5c3365
update libusb, add term color flag
georgemorgan Jun 10, 2018
a355f1f
update libusb error strings
georgemorgan Jun 10, 2018
5efffaf
wow how did that work
georgemorgan Jun 10, 2018
0e9df33
double newline for error
georgemorgan Jun 10, 2018
dc19bc0
sanitize libflipper.h, remove types.h
georgemorgan Jun 10, 2018
0f29ce0
whitespace in libflipper.c
georgemorgan Jun 10, 2018
534dc6a
update comments in fmr.h
georgemorgan Jun 10, 2018
f91d6fe
update comments in fmr.c
georgemorgan Jun 10, 2018
8f6bad3
update libusb
georgemorgan Jun 10, 2018
9e0e416
WIP
georgemorgan Jun 10, 2018
8d61eb1
make error uint8_t
georgemorgan Jun 10, 2018
bdb17bb
error strings use PROGMEM on AVR
georgemorgan Jun 10, 2018
ca82132
Update error code, fix USB
georgemorgan Jun 10, 2018
452d497
remove unnecessary error include
georgemorgan Jun 10, 2018
ea7d987
prettify errors with line number
georgemorgan Jun 10, 2018
0788ae4
Remove dupe endpoint info
georgemorgan Jun 10, 2018
c5d4a63
Clean up FVM
georgemorgan Jun 10, 2018
d65f453
Fix test errors
georgemorgan Jun 13, 2018
0f582f4
restructure headers, rip out custom drivers, move language files
georgemorgan Jun 16, 2018
e63d9fa
restructure project, separate makefiles, fix asf
georgemorgan Jun 24, 2018
930f9ec
move api to top, move langs and library, arch->kernel, add tests, sta…
georgemorgan Jul 4, 2018
da87d04
fix typedef, add platforms for now
georgemorgan Jul 4, 2018
5157338
fix atmegau2
georgemorgan Jul 4, 2018
399998d
update posix + carbon hal
georgemorgan Jul 4, 2018
3791c14
fix utils, usb changes, update hal
georgemorgan Jul 4, 2018
888b90b
fix includes for local build
georgemorgan Jul 4, 2018
22ffc57
add fpic
georgemorgan Jul 4, 2018
ffe0e6f
flipper.h -> libflipper.h
georgemorgan Jul 4, 2018
1bc67d1
fix includes for atmegau2 and move descriptor extern
georgemorgan Jul 4, 2018
bd751bd
minor changes
georgemorgan Jul 4, 2018
4dbbba7
drop '<flipper/' from includes
georgemorgan Aug 2, 2018
98dce09
remove error E_OK from fvm
georgemorgan Aug 16, 2018
f3b8695
fix whitespace, minor changes to fvm
georgemorgan Aug 18, 2018
3494519
cleanup includes, fix examples
georgemorgan Aug 18, 2018
1097618
fix module example build
georgemorgan Aug 18, 2018
a2d5c89
update debugging to print only used bytes
georgemorgan Aug 20, 2018
470366e
remove stray runtime file
georgemorgan Aug 20, 2018
30c92c9
never ending header fixery
georgemorgan Aug 21, 2018
aa6a7e2
fix pin namespace collision
georgemorgan Aug 21, 2018
9a4477e
fix atmegau2 ram overflow
georgemorgan Aug 24, 2018
ea22590
fix undefined behavior + pack structs again + no access to fmr_call
georgemorgan Sep 1, 2018
e91f0bb
fix cross platform error logic w/ atmegau2
georgemorgan Sep 2, 2018
1e3d688
restore the old bulk
georgemorgan Sep 3, 2018
d6c8d41
Clean up lf_dyld
georgemorgan Sep 9, 2018
b0685c5
Convert tabs to spaces
georgemorgan Sep 9, 2018
98f664a
Convert null statement while loops to empty block while loops
georgemorgan Sep 9, 2018
2f3df26
Simplify strings in error assertions
georgemorgan Sep 9, 2018
3d2fd94
Run clang-format over whole codebase
georgemorgan Sep 9, 2018
cdb41f2
address signedness and pointer comparison warnings
georgemorgan Sep 9, 2018
39993ae
Update Swift bindings to work with dyld_wip + rebase
georgemorgan Sep 10, 2018
06a64a6
try to fix bulk
georgemorgan Sep 10, 2018
9da9410
update swift bindings, fix bulk on atmega
georgemorgan Sep 11, 2018
1f89b74
move swift to library
georgemorgan Sep 11, 2018
3cb1181
fix atsam4s build
georgemorgan Sep 11, 2018
20b32f1
fix pointer size issue
georgemorgan Sep 11, 2018
d2bb729
restore fdfu
georgemorgan Sep 11, 2018
96c0903
move carbon IO defs
georgemorgan Sep 11, 2018
0fa8da2
Move rust API and examples to library/rust
nicholastmosher Sep 21, 2018
6dcd399
Add Rust macro for generating invocation implementations
nicholastmosher Sep 22, 2018
3cfacec
Fix lf_invoke wrapper for Rust
nicholastmosher Sep 22, 2018
36e0be8
Split Rust bindings into core and api
nicholastmosher Sep 23, 2018
4d3d8fd
Adds py3 packages and pkg-config to dependencies
wasv Jul 23, 2018
559f6bd
Moves LD_FLAGS to end of linking command.
wasv Jul 23, 2018
b317d8b
Only link asan if debug flag is defined
wasv Nov 10, 2018
8efbcda
Merge pull request #156 from wastevensv/wasv_dyld
georgemorgan Nov 10, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 15 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 120
IndentCaseLabels: true
AllowShortFunctionsOnASingleLine: None
IncludeCategories:
- Regex: '.*libflipper.*'
Priority: -1
- Regex: '.*'
Priority: 1
Cpp11BracedListStyle: false
AllowShortBlocksOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
KeepEmptyLinesAtTheStartOfBlocks: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
.clang_complete
.build/
*.so
*.bin
*.hex
Expand All @@ -11,6 +12,8 @@ xcuserdata
__pycache__
*.pyc
.idea/
Flipper.xcodeproj
Package.resolved
cmake-build-debug/
TAGS
.#*
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ install:
- sudo apt-get install libusb-1.0-0-dev
- sudo apt-get install avr-libc binutils-avr gcc-avr
- sudo apt-get install libnewlib-arm-none-eabi binutils-arm-none-eabi gcc-arm-none-eabi
- sudo apt-get install python3-pip
- sudo pip3 install pyelftools

matrix:
include:
- language: c
compiler:
- clang
- gcc
compiler: gcc
script: make libflipper atmegau2 atsam4s utils VERBOSE=1

- language: rust
Expand Down
28 changes: 28 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version:4.2

import PackageDescription

let package = Package(
name: "Flipper",
products: [
.library(
name: "Flipper",
targets: ["Flipper"]),
],
dependencies: [
],
targets: [
.systemLibrary(
name: "Clibflipper",
path: "library/swift/Clibflipper",
pkgConfig: "flipper"),
.target(
name: "Flipper",
dependencies: ["Clibflipper"],
path: "library/swift/Flipper"),
.target(
name: "Example",
dependencies: ["Flipper"],
path: "library/swift/Example"),
]
)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ brew install rust libusb avr-gcc dfu-programmer arm-gcc-bin
apt-get install build-essential libusb-1.0-0-dev
apt-get install dfu-programmer avr-libc binutils-avr gcc-avr
apt-get install libnewlib-arm-none-eabi binutils-arm-none-eabi gcc-arm-none-eabi
apt-get install pkg-config python-pip python-pyelftools
apt-get install pkg-config python3-pip python3-pyelftools
```

#### dnf (Fedora 28)
Expand Down
5 changes: 5 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Flipper API

The Flipper API is how you interact with the Flipper platform.

The API lets you use the language of your choice to interact with a variety of embedded hardware peripherals. This directory contains all of the hardware peripheral APIs and bindings to them for all of the languages that we currently support.
15 changes: 15 additions & 0 deletions api/c/adc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "libflipper.h"

enum { _adc_configure };

int adc_configure(void);

void *adc_interface[] = { &adc_configure };

LF_MODULE(adc, "adc", adc_interface);

LF_WEAK int adc_configure(void) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "adc", _adc_configure, lf_int_t, &retval, NULL);
return (int)retval;
}
7 changes: 7 additions & 0 deletions api/c/adc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef __adc_h__
#define __adc_h__

/* Declare the prototypes for all of the functions within this module. */
int adc_configure(void);

#endif
22 changes: 22 additions & 0 deletions api/c/button.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "libflipper.h"

enum { _button_read, _button_configure };

uint8_t button_read(void);
int button_configure(void);

void *button_interface[] = { &button_read, &button_configure };

LF_MODULE(button, "button", button_interface);

LF_WEAK uint8_t button_read(void) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "button", _button_read, lf_int8_t, &retval, NULL);
return (uint8_t)retval;
}

LF_WEAK int button_configure(void) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "button", _button_configure, lf_int_t, &retval, NULL);
return (int)retval;
}
8 changes: 8 additions & 0 deletions api/c/button.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef __button_h__
#define __button_h__

/* Declare the prototypes for all of the functions within this module. */
int button_configure(void);
uint8_t button_read(void);

#endif
15 changes: 15 additions & 0 deletions api/c/dac.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "libflipper.h"

enum { _dac_configure };

int dac_configure(void);

void *dac_interface[] = { &dac_configure };

LF_MODULE(dac, "dac", dac_interface);

LF_WEAK int dac_configure(void) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "dac", _dac_configure, lf_int_t, &retval, NULL);
return (int)retval;
}
7 changes: 7 additions & 0 deletions api/c/dac.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef __dac_h__
#define __dac_h__

/* Declare the prototypes for all of the functions within this module. */
int dac_configure(void);

#endif
35 changes: 35 additions & 0 deletions api/c/gpio.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "libflipper.h"

enum { _gpio_read, _gpio_write, _gpio_enable, _gpio_configure };

uint32_t gpio_read(uint32_t mask);
void gpio_write(uint32_t set, uint32_t clear);
void gpio_enable(uint32_t enable, uint32_t disable);
int gpio_configure(void);

void *gpio_interface[] = { &gpio_read, &gpio_write, &gpio_enable, &gpio_configure };

LF_MODULE(gpio, "gpio", gpio_interface);

LF_WEAK uint32_t gpio_read(uint32_t mask) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "gpio", _gpio_read, lf_int32_t, &retval, lf_args(lf_infer(mask)));
return (uint32_t)retval;
}

LF_WEAK void gpio_write(uint32_t set, uint32_t clear) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "gpio", _gpio_write, lf_void_t, &retval, lf_args(lf_infer(set), lf_infer(clear)));
}

LF_WEAK void gpio_enable(uint32_t enable, uint32_t disable) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "gpio", _gpio_enable, lf_void_t, &retval,
lf_args(lf_infer(enable), lf_infer(disable)));
}

LF_WEAK int gpio_configure(void) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "gpio", _gpio_configure, lf_int_t, &retval, NULL);
return (int)retval;
}
10 changes: 10 additions & 0 deletions api/c/gpio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef __gpio_h__
#define __gpio_h__

/* Declare each prototype for all functgpions within this driver. */
int gpio_configure(void);
void gpio_enable(uint32_t enable, uint32_t disable);
void gpio_write(uint32_t set, uint32_t clear);
uint32_t gpio_read(uint32_t mask);

#endif
41 changes: 41 additions & 0 deletions api/c/i2c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "libflipper.h"

enum { _i2c_stop, _i2c_write, _i2c_read, _i2c_configure, _i2c_start_read };

void i2c_stop(void);
void i2c_write(uint8_t byte);
uint8_t i2c_read(void);
int i2c_configure(void);
void i2c_start_read(uint8_t address, uint8_t length);

void *i2c_interface[] = { &i2c_stop, &i2c_write, &i2c_read, &i2c_configure, &i2c_start_read };

LF_MODULE(i2c, "i2c", i2c_interface);

LF_WEAK void i2c_stop(void) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "i2c", _i2c_stop, lf_void_t, &retval, NULL);
}

LF_WEAK void i2c_write(uint8_t byte) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "i2c", _i2c_write, lf_void_t, &retval, lf_args(lf_infer(byte)));
}

LF_WEAK uint8_t i2c_read(void) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "i2c", _i2c_read, lf_int8_t, &retval, NULL);
return (uint8_t)retval;
}

LF_WEAK int i2c_configure(void) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "i2c", _i2c_configure, lf_int_t, &retval, NULL);
return (int)retval;
}

LF_WEAK void i2c_start_read(uint8_t address, uint8_t length) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "i2c", _i2c_start_read, lf_void_t, &retval,
lf_args(lf_infer(address), lf_infer(length)));
}
12 changes: 12 additions & 0 deletions api/c/i2c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef __i2c_h__
#define __i2c_h__

/* Declare the prototypes for all of the functions within this module. */
int i2c_configure(void);
void i2c_start_read(uint8_t address, uint8_t length);
uint8_t i2c_read(void);
void i2c_start_write(uint8_t address, uint8_t length);
void i2c_write(uint8_t byte);
void i2c_stop(void);

#endif
21 changes: 21 additions & 0 deletions api/c/led.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "libflipper.h"

enum { _led_rgb, _led_configure };

void led_rgb(uint8_t r, uint8_t g, uint8_t b);
int led_configure(void);

void *led_interface[] = { &led_rgb, &led_configure };

LF_MODULE(led, "led", led_interface);

LF_WEAK void led_rgb(uint8_t r, uint8_t g, uint8_t b) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "led", _led_rgb, lf_void_t, &retval, lf_args(lf_infer(r), lf_infer(g), lf_infer(b)));
}

LF_WEAK int led_configure(void) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "led", _led_configure, lf_int_t, &retval, NULL);
return (int)retval;
}
16 changes: 16 additions & 0 deletions api/c/led.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef __led_h__
#define __led_h__

/* Declare all public macros for this driver. */
#define LED_OFF 0, 0, 0
#define LED_COLOR_BUSY 25, 0, 0
#define LED_COLOR_SUCCESS 0, 25, 0
#define LED_COLOR_ERROR 25, 0, 0

#define LED_GREEN 0, 10, 0

/* Declare the prototypes for all of the functions within this module. */
int led_configure(void);
void led_rgb(uint8_t r, uint8_t g, uint8_t b);

#endif
15 changes: 15 additions & 0 deletions api/c/pwm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "libflipper.h"

enum { _pwm_configure };

int pwm_configure(void);

void *pwm_interface[] = { &pwm_configure };

LF_MODULE(pwm, "pwm", pwm_interface);

LF_WEAK int pwm_configure(void) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "pwm", _pwm_configure, lf_int_t, &retval, NULL);
return (int)retval;
}
7 changes: 7 additions & 0 deletions api/c/pwm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef __pwm_h__
#define __pwm_h__

/* Declare the prototypes for all of the functions within this module. */
int pwm_configure(void);

#endif
15 changes: 15 additions & 0 deletions api/c/rtc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "libflipper.h"

enum { _rtc_configure };

int rtc_configure(void);

void *rtc_interface[] = { &rtc_configure };

LF_MODULE(rtc, "rtc", rtc_interface);

LF_WEAK int rtc_configure(void) {
lf_return_t retval;
lf_invoke(lf_get_selected(), "rtc", _rtc_configure, lf_int_t, &retval, NULL);
return (int)retval;
}
7 changes: 7 additions & 0 deletions api/c/rtc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef __rtc_h__
#define __rtc_h__

/* Declare the prototypes for all of the functions within this module. */
int rtc_configure(void);

#endif
Loading