Skip to content

Commit

Permalink
Duktape added, peripheral modules corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
Catethysis committed Jun 10, 2016
1 parent f470c18 commit 5ecf50d
Show file tree
Hide file tree
Showing 10 changed files with 91,861 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1 +1 @@
node_modules
node_modules
16 changes: 16 additions & 0 deletions examples/app.js
@@ -0,0 +1,16 @@
const uart = require('../peripheral/uart');
const SysTick = require('../peripheral/systick');

var FT232 = new uart(2, 115200, {split: '\n'});

FT232.on('data', (data) => {
print(data);
FT232.send(432);
});

() => {
print('hello');
FT232.send([0x61, 0x62, 0x63, 0x64, 0x65, 0x31]);
FT232.send(['a', 'b', 'c', 'd', 'e', '2']);
FT232.send('abcde3');
}
2 changes: 1 addition & 1 deletion examples/systick.js
@@ -1,4 +1,4 @@
const SysTick = require('../peripheral/systick.js');
const SysTick = require('../peripheral/systick');

var sysTick = new SysTick(500);

Expand Down
2 changes: 1 addition & 1 deletion examples/uart.js
@@ -1,4 +1,4 @@
const uart = require('../peripheral/uart.js');
const uart = require('../peripheral/uart');

var FT232 = new uart(2, 115200, {split: '\n'});
FT232.send([0x61, 0x62, 0x63, 0x64, 0x65, 0x31]);
Expand Down
6 changes: 3 additions & 3 deletions gulpfile.js
Expand Up @@ -3,12 +3,12 @@ const browserify = require('browserify');
const uglify = require('gulp-uglify');
const source = require('vinyl-source-stream');
const streamify = require('gulp-streamify');
const rename = require("gulp-rename");
const rename = require('gulp-rename');
const babelify = require('babelify');

gulp.task('default', () => {
browserify('app.js', { debug: true })
.transform("babelify", {presets: ["es2015"]})
browserify('examples/app')
.transform('babelify', {presets: ['es2015']})
.bundle()
.pipe(source('bundle.js'))
.pipe(streamify(uglify()))
Expand Down
14 changes: 9 additions & 5 deletions peripheral/systick.js
@@ -1,10 +1,14 @@
const events = require('events');

SysTick = function(milliseconds) {
var systick = function(milliseconds) {
events.EventEmitter.call(this);
__C_SysTick_init(milliseconds);
return new events.EventEmitter();
};

SysTick_irq = function() {
SysTick.emit('tick');
};
systick.prototype = Object.create(events.EventEmitter.prototype);

var systick_irq = function() {
systick.emit('tick');
};

module.exports = systick;
9 changes: 6 additions & 3 deletions peripheral/uart.js
@@ -1,6 +1,7 @@
const events = require('events');

uart = function(module, params, parser) {
var uart = function(module, params, parser) {
events.EventEmitter.call(this);
var baudrate = 9600, byte_bits = 8, parity = 'N' /* N (no), O (odd), E (even), M (mark), S (space) */, stop_bits = 1;
switch(typeof params) {
case "number":
Expand Down Expand Up @@ -33,6 +34,8 @@ uart.prototype.send = function(data) {
__C_UART_Send(2, new Uint8Array(data), data.length, this.split);
}

uart_data_irq = function(data) {
var uart_data_irq = function(data) {
uart.emit('data', data);
}
}

module.exports = uart;

0 comments on commit 5ecf50d

Please sign in to comment.