Skip to content

Commit

Permalink
Merge branch 'release-2.0-nightly' into release-2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidZemon committed Apr 17, 2014
2 parents d997e35 + f878a82 commit 5802baf
Show file tree
Hide file tree
Showing 46 changed files with 3,919 additions and 4,236 deletions.
17 changes: 13 additions & 4 deletions Examples/Concurrency/Concurrency_Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,27 @@

volatile int lock = locknew();

const PropWare::Pin g_pin1(PropWare::Pin::P23, PropWare::Pin::OUT);
const PropWare::Pin g_pin2(PropWare::Pin::P16, PropWare::Pin::OUT);
// NOTE!!! The direction of a pin (or port) is not a member variable of the pin
// or port. Therefore, if you're going to declare a pin (or port) in one cog
// and use it in another, you MUST set the direction in the new port. Look at
// how g_pin2.set_dir() is called within blinkAnLEDSome() instead of the
// direction being set in the constructor
PropWare::Pin g_pin1(PropWare::Port::P16, PropWare::Port::OUT);
PropWare::Pin g_pin2(PropWare::Port::P17);
const int g_someStackSpace = 64;

// Main function
int main () {

cog_run((void (*) (void *)) &blinkAnLEDSome, g_someStackSpace);

waitcnt(20*MICROSECOND + CNT);

while(lockset(lock));

for (int i = 0; i < 40; ++i) {
waitcnt(50 * MILLISECOND + CNT);
g_pin2.toggle();
g_pin1.toggle();
}

lockclr(lock);
Expand All @@ -35,9 +42,11 @@ int main () {
void blinkAnLEDSome (void) {
while(lockset(lock));

g_pin2.set_dir(PropWare::Port::OUT);

for (int i = 0; i < 40; ++i) {
waitcnt(50 * MILLISECOND + CNT);
g_pin1.toggle();
g_pin2.toggle();
}

lockclr(lock);
Expand Down
6 changes: 6 additions & 0 deletions Examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ all:
$(shell mkdir $(MKDIR_FLAG) PropWare_SPI$(DIR_DIV)Debug $(NULL))
$(MAKE) -C PropWare_SPI/Debug -f ../Makefile

$(shell mkdir $(MKDIR_FLAG) PropWare_I2C_HD44780$(DIR_DIV)Debug $(NULL))
$(MAKE) -C Concurrency/Debug -f ../Makefile

$(shell mkdir $(MKDIR_FLAG) PropWare$(DIR_DIV)Debug $(NULL))
$(MAKE) -C PropWare/Debug -f ../Makefile

Expand Down Expand Up @@ -60,6 +63,9 @@ clean:
$(shell mkdir $(MKDIR_FLAG) PropWare_SPI$(DIR_DIV)Debug $(NULL))
$(MAKE) -C PropWare_SPI/Debug -f ../Makefile clean

$(shell mkdir $(MKDIR_FLAG) PropWare_I2C_HD44780$(DIR_DIV)Debug $(NULL))
$(MAKE) -C Concurrency/Debug -f ../Makefile clean

$(shell mkdir $(MKDIR_FLAG) PropWare$(DIR_DIV)Debug $(NULL))
$(MAKE) -C PropWare/Debug -f ../Makefile clean

Expand Down
16 changes: 8 additions & 8 deletions Examples/PropWare/PropWare_Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ int main (int argc, char* argv[]) {
int8_t cog;
PropWare::Pin pin;
static volatile PropWare::Pin::Mask pins[] = {
PropWare::Pin::P16,
PropWare::Pin::P17,
PropWare::Pin::P18,
PropWare::Pin::P19,
PropWare::Pin::P20,
PropWare::Pin::P21,
PropWare::Pin::P22,
PropWare::Pin::P23 };
PropWare::Port::P16,
PropWare::Port::P17,
PropWare::Port::P18,
PropWare::Port::P19,
PropWare::Port::P20,
PropWare::Port::P21,
PropWare::Port::P22,
PropWare::Port::P23 };
uint32_t nextcnt;

wait_time = 50 * MILLISECOND;
Expand Down
2 changes: 1 addition & 1 deletion Examples/PropWare_HD44780/HD44780_Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int main () {
}

void error (const PropWare::ErrorCode err) {
PropWare::SimplePort debugLEDs(PropWare::Pin::P16, 8, PropWare::Pin::OUT);
PropWare::SimplePort debugLEDs(PropWare::Port::P16, 8, PropWare::Pin::OUT);

PropWare::HD44780::print_error_str((PropWare::HD44780::ErrorCode) err);

Expand Down
8 changes: 4 additions & 4 deletions Examples/PropWare_HD44780/HD44780_Demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
#include <PropWare/PropWare.h>
#include <PropWare/hd44780.h>

#define RS PropWare::Pin::P14
#define RW PropWare::Pin::P12
#define EN PropWare::Pin::P10
#define RS PropWare::Port::P14
#define RW PropWare::Port::P12
#define EN PropWare::Port::P10

#define FIRST_DATA_PIN PropWare::Pin::P19
#define FIRST_DATA_PIN PropWare::Port::P19
#define BITMODE PropWare::HD44780::BM_8
#define DIMENSIONS PropWare::HD44780::DIM_16x2

Expand Down
17 changes: 11 additions & 6 deletions Examples/PropWare_L3G/L3G_Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/

// Includes
#include <tinyio.h>
#include <simpletools.h>
#include "L3G_Demo.h"

// Main function
Expand All @@ -36,7 +36,9 @@ int main () {
PropWare::SPI *spi = PropWare::SPI::getInstance();
PropWare::L3G gyro(spi);

if ((err = gyro.start(MOSI, MISO, SCLK, CS, PropWare::L3G::DPS_2000)))
if ((err = gyro.start(MOSI, MISO, SCLK, CS)))
error(err);
if ((err = gyro.set_dps(PropWare::L3G::DPS_500)))
error(err);

// Though this functional call is not necessary (default value is 0), I
Expand All @@ -49,17 +51,20 @@ int main () {
while (1) {
if ((err = gyro.read_all(gyroVals)))
error(err);
printf("Gyro vals... X: %i\tY: %i\tZ: %i\n", gyroVals[0], gyroVals[1],
gyroVals[2]);
waitcnt(CLKFREQ/20 + CNT);
print("Gyro vals DPS... X: %2.3f\tY: %2.3f\tZ: %2.3f\n",
gyro.convert_to_dps(gyroVals[0]),
gyro.convert_to_dps(gyroVals[1]),
gyro.convert_to_dps(gyroVals[2]));

// waitcnt(50*MILLISECOND + CNT);
}

return 0;
}

void error (const PropWare::ErrorCode err) {
// Set the Quickstart LEDs for output (used to display the error code)
PropWare::SimplePort debugLEDs(PropWare::Pin::P16, 8, PropWare::Pin::OUT);
PropWare::SimplePort debugLEDs(PropWare::Port::P16, 8, PropWare::Pin::OUT);

while (1) {
debugLEDs.write(err);
Expand Down
8 changes: 4 additions & 4 deletions Examples/PropWare_L3G/L3G_Demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
#include <PropWare/port.h>

/** Pin number for MOSI (master out - slave in) */
#define MOSI PropWare::Pin::P0
#define MOSI PropWare::Port::P0
/** Pin number for MISO (master in - slave out) */
#define MISO PropWare::Pin::P1
#define MISO PropWare::Port::P1
/** Pin number for the clock signal */
#define SCLK PropWare::Pin::P2
#define SCLK PropWare::Port::P2
/** Pin number for chip select */
#define CS PropWare::Pin::P4
#define CS PropWare::Port::P6
/** Frequency (in Hertz) to run the SPI protocol */
#define FREQ 10000

Expand Down
2 changes: 1 addition & 1 deletion Examples/PropWare_MAX6675/MAX6675_Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int main () {

void error (const PropWare::ErrorCode err) {
// Set the Quickstart LEDs for output (used to display the error code)
PropWare::SimplePort debugLEDs(PropWare::Pin::P16, 8, PropWare::Pin::OUT);
PropWare::SimplePort debugLEDs(PropWare::Port::P16, 8, PropWare::Pin::OUT);

while (1) {
debugLEDs.write(err);
Expand Down
16 changes: 8 additions & 8 deletions Examples/PropWare_MAX6675/MAX6675_Demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@
#include <PropWare/spi.h>

/** Pin number for MOSI (master out - slave in) */
#define MOSI PropWare::Pin::P0
#define MOSI PropWare::Port::P0
/** Pin number for MISO (master in - slave out) */
#define MISO PropWare::Pin::P1
#define MISO PropWare::Port::P1
/** Pin number for the clock signal */
#define SCLK PropWare::Pin::P2
#define SCLK PropWare::Port::P2
/** Pin number for chip select */
#define CS PropWare::Pin::P5
#define CS PropWare::Port::P5
#define FREQ 10000

#define DEBUG_LEDS PropWare::BYTE_2

#define RS PropWare::Pin::P14
#define RW PropWare::Pin::P12
#define EN PropWare::Pin::P10
#define RS PropWare::Port::P14
#define RW PropWare::Port::P12
#define EN PropWare::Port::P10

#define FIRST_DATA_PIN PropWare::Pin::P19
#define FIRST_DATA_PIN PropWare::Port::P19
#define BITMODE PropWare::HD44780::BM_8

#define DIMENSIONS PropWare::HD44780::DIM_16x2
Expand Down
4 changes: 2 additions & 2 deletions Examples/PropWare_MCP3000/MCP3000_Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int main () {
PropWare::MCP3000 adc(spi, PART_NUMBER);

// Set the Quickstart LEDs for output (used as a secondary display)
PropWare::SimplePort scale(PropWare::Pin::P16, 8, PropWare::Pin::OUT);
PropWare::SimplePort scale(PropWare::Port::P16, 8, PropWare::Pin::OUT);

if ((err = adc.start(MOSI, MISO, SCLK, CS)))
error(err);
Expand Down Expand Up @@ -80,7 +80,7 @@ int main () {
}

void error (const PropWare::ErrorCode err) {
PropWare::SimplePort debugLEDs(PropWare::Pin::P16, 8, PropWare::Pin::OUT);
PropWare::SimplePort debugLEDs(PropWare::Port::P16, 8, PropWare::Pin::OUT);

while (1) {
debugLEDs.write(err);
Expand Down
8 changes: 4 additions & 4 deletions Examples/PropWare_MCP3000/MCP3000_Demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
#define PART_NUMBER PropWare::MCP3000::MCP300x

/** Pin number for MOSI (master out - slave in) */
#define MOSI PropWare::Pin::P0
#define MOSI PropWare::Port::P0
/** Pin number for MISO (master in - slave out) */
#define MISO PropWare::Pin::P1
#define MISO PropWare::Port::P1
/** Pin number for the clock signal */
#define SCLK PropWare::Pin::P2
#define SCLK PropWare::Port::P2
/** Pin number for chip select */
#define CS PropWare::Pin::P3
#define CS PropWare::Port::P3
#define FREQ 100000

// We're going to read from just channel 1 in this demo, but feel free to read
Expand Down
2 changes: 1 addition & 1 deletion Examples/PropWare_SD/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PRJ = SD_Demo
NAME = $(PRJ)
OBJS = $(PRJ).o
BOARD = QUICKSTART
MODEL = lmm
MODEL = cmm
CFLAGS = -Os

# Insert your own path here - it should be the same directory that contains "common.mk"
Expand Down
43 changes: 22 additions & 21 deletions Examples/PropWare_SD/SD_Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main () {
PropWare::ErrorCode err;
char c;

PropWare::Pin statusLED(PropWare::Pin::P16, PropWare::Pin::OUT);
PropWare::Pin statusLED(PropWare::Port::P16, PropWare::Pin::OUT);

PropWare::SPI *spi = PropWare::SPI::getInstance();
PropWare::SD sd(spi);
Expand All @@ -58,8 +58,8 @@ int main () {
* decreased when multiple files are used often.
*
*/
f.buf = sd.getGlobalBuffer();
f2.buf = sd.getGlobalBuffer();
f.buf = sd.get_global_buffer();
f2.buf = sd.get_global_buffer();
#endif

#ifdef DEBUG
Expand All @@ -83,16 +83,16 @@ int main () {
sd.shell(&f);
#elif (defined TEST_WRITE)
// Create a blank file and copy the contents of STUFF.TXT into it
SDfopen(OLD_FILE, &f, SD_FILE_MODE_R);
SDfopen(NEW_FILE, &f2, SD_FILE_MODE_R_PLUS);
sd.fopen(OLD_FILE, &f, PropWare::SD::FILE_MODE_R);
sd.fopen(NEW_FILE, &f2, PropWare::SD::FILE_MODE_R_PLUS);

#ifdef DEBUG
printf("Both files opened...\n");
#endif

while (!SDfeof(&f)) {
c = SDfgetc(&f);
SDfputc(c, &f2);
while (!sd.feof(&f)) {
c = sd.fgetc(&f);
sd.fputc(c, &f2);
#ifdef _STDIO_H
putchar(SDfgetc(&f2));
#endif
Expand All @@ -103,30 +103,30 @@ int main () {

printf("Now closing read-only file!\n");
#endif
SDfclose(&f);
sd.fclose(&f);
#ifdef DEBUG
printf("***Now closing the modified file!***\n");
#endif
SDfclose(&f2);
sd.fclose(&f2);

#ifdef DEBUG
printf("Files closed...\n");

SDfopen(NEW_FILE, &f2, SD_FILE_MODE_R);
sd.fopen(NEW_FILE, &f2, PropWare::SD::FILE_MODE_R);
printf("File opened for a second time, now printing new contents...\n");
while (!SDfeof(&f2))
putchar(SDfgetc(&f2));
SDfclose(&f2);
while (!sd.feof(&f2))
putchar(sd.fgetc(&f2));
sd.fclose(&f2);
#endif

SDUnmount();
sd.unmount();
#else
SDchdir("JAZZ");
SDfopen("DESKTOP.INI", &f, SD_FILE_MODE_R);
sd.chdir("JAZZ");
sd.fopen("DESKTOP.INI", &f, PropWare::SD::FILE_MODE_R);

while (!SDfeof(&f))
while (!sd.feof(&f))
#ifdef DEBUG
putchar(SDfgetc(&f));
putchar(sd.fgetc(&f));
#endif
#endif

Expand All @@ -143,13 +143,14 @@ int main () {
}

void error (const PropWare::ErrorCode err, const PropWare::SD *sd) {
PropWare::SimplePort debugLEDs(PropWare::Pin::P16, 8, PropWare::Pin::OUT);
PropWare::SimplePort debugLEDs(PropWare::Port::P16, 8, PropWare::Pin::OUT);

if (PropWare::SPI::BEG_ERROR <= err && err < PropWare::SPI::END_ERROR)
PropWare::SPI::getInstance()->print_error_str(
(PropWare::SPI::ErrorCode) err);
else if (PropWare::SD::BEG_ERROR <= err && err < PropWare::SD::END_ERROR)
sd->print_error_str((PropWare::SD::ErrorCode) err);
// sd->print_error_str((PropWare::SD::ErrorCode) err);
;

while (1) {
debugLEDs.write(err);
Expand Down
19 changes: 12 additions & 7 deletions Examples/PropWare_SD/SD_Demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,29 @@
//#define TEST_WRITE
#define TEST_SHELL

// Includes
#include <propeller.h>
#ifdef DEBUG
//#define USE_PRINTF

#ifdef USE_PRINTF
#include <tinyio.h>
#else
#include <simpletext.h>
#endif

// Includes
#include <propeller.h>
#include <PropWare/PropWare.h>
#include <PropWare/sd.h>
#include <PropWare/pin.h>
#include <PropWare/port.h>

/** Pin number for MOSI (master out - slave in) */
#define MOSI PropWare::Pin::P0
#define MOSI PropWare::Port::P0
/** Pin number for MISO (master in - slave out) */
#define MISO PropWare::Pin::P1
#define MISO PropWare::Port::P1
/** Pin number for the clock signal */
#define SCLK PropWare::Pin::P2
#define SCLK PropWare::Port::P2
/** Pin number for chip select */
#define CS PropWare::Pin::P4
#define CS PropWare::Port::P4

#define OLD_FILE "STUFF.TXT"
#define NEW_FILE "TEST.TXT"
Expand Down
Loading

0 comments on commit 5802baf

Please sign in to comment.