Skip to content

Commit

Permalink
spi & i2c fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandru Radovici committed Jul 6, 2014
1 parent 683d66f commit 4d01e8d
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 18 deletions.
3 changes: 3 additions & 0 deletions src/libraries/Adafruit_PCD8544.h
Expand Up @@ -18,6 +18,8 @@ All text above, and the splash screen must be included in any redistribution
#ifndef _ADAFRUIT_PCD8544_H
#define _ADAFRUIT_PCD8544_H

#include "SPI.h"

#define BLACK 1
#define WHITE 0

Expand Down Expand Up @@ -71,6 +73,7 @@ class Adafruit_PCD8544 : public Adafruit_GFX {
uint8_t getPixel(int8_t x, int8_t y);

private:
SPIClass SPI;
int8_t _din, _sclk, _dc, _rst, _cs;
volatile uint8_t *mosiport, *clkport;
uint8_t mosipinmask, clkpinmask;
Expand Down
3 changes: 3 additions & 0 deletions src/libraries/Adafruit_ST7735.h
Expand Up @@ -20,6 +20,7 @@
#define _ADAFRUIT_ST7735H_

#include "Adafruit_GFX.h"
#include "SPI.h"

#define PROGMEM
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
Expand Down Expand Up @@ -122,6 +123,8 @@ class Adafruit_ST7735 : public Adafruit_GFX {
*/

private:

SPIClass SPI;
uint8_t tabcolor;

void spiwrite(uint8_t),
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/Pixy.h
Expand Up @@ -42,6 +42,7 @@

class LinkSPI
{

public:
void init()
{
Expand Down Expand Up @@ -101,6 +102,7 @@ class LinkSPI
}

private:
SPIClass SPI;
uint8_t outBuf[PIXY_OUTBUF_SIZE];
uint8_t outLen;
uint8_t outIndex;
Expand Down
6 changes: 1 addition & 5 deletions src/libraries/SPI.cpp
Expand Up @@ -32,14 +32,11 @@

#define SPI_SS_GPIO_PIN 10

// SPIClass SPI;
SPIClass SPI;

/* Constructor - establish defaults */
SPIClass::SPIClass()
{
static int i;
i++;
this->id = i;
/* reflect Arduino's default behaviour where possible */
this->mode = SPI_MODE0;
this->bitOrder = MSBFIRST;
Expand Down Expand Up @@ -149,7 +146,6 @@ void SPIClass::setClockDivider(uint8_t clkDiv)

uint8_t SPIClass::transfer(uint8_t txData)
{
printf ("id: %d\n", this->id);
char s = spi_writebyte (this->fd, txData);
return s;
}
Expand Down
6 changes: 1 addition & 5 deletions src/libraries/SPI.h
Expand Up @@ -47,15 +47,11 @@ class SPIClass {

private:
int fd;
int id;
uint8_t mode;
uint8_t bitOrder;
uint8_t clkDiv;
};

namespace
{
SPIClass SPI;
}
extern SPIClass SPI;

#endif
2 changes: 1 addition & 1 deletion src/libraries/Wire.cpp
Expand Up @@ -243,7 +243,7 @@ static void Wire_Init(void)
{
}

// TwoWire Wire = TwoWire(Wire_Init);
TwoWire Wire = TwoWire(Wire_Init);

void WIRE_ISR_HANDLER(void) {
Wire.onService();
Expand Down
5 changes: 1 addition & 4 deletions src/libraries/Wire.h
Expand Up @@ -93,10 +93,7 @@ class TwoWire : public Stream {
};

//#if WIRE_INTERFACES_COUNT > 0
namespace
{
TwoWire Wire = TwoWire(NULL);
}
extern TwoWire Wire;
//#endif
#if WIRE_INTERFACES_COUNT > 1
extern TwoWire Wire1;
Expand Down
5 changes: 2 additions & 3 deletions src/wyliodrin.i
Expand Up @@ -9,6 +9,7 @@
#include "wiring/wiring.h"
#include "libraries/lcd.h"
#include "libraries/Print.h"
#include "libraries/SPI.h"
#include "libraries/Wire.h"
#include "libraries/Servo.h"
#include "libraries/Stepper.h"
Expand All @@ -18,9 +19,6 @@
#include "libraries/Adafruit_GFX.h"
#include "libraries/Adafruit_PCD8544.h"
#include "libraries/Adafruit_ST7735.h"

SPIClass SPI;
TwoWire Wire = TwoWire (NULL);
%}

%init %{
Expand All @@ -35,6 +33,7 @@
%include "libraries/lcd.h"
%include "libraries/Print.h"
%include "libraries/Stream.h"
%include "libraries/SPI.h"
%include "libraries/Wire.h"
%include "libraries/Servo.h"
%include "libraries/Stepper.h"
Expand Down

0 comments on commit 4d01e8d

Please sign in to comment.