Remove SWSPI which is not used/implemented
This commit is contained in:
parent
2b38080c7e
commit
355b670cd4
|
|
@ -178,7 +178,6 @@ set(FW_SOURCES
|
|||
SpoolJoin.cpp
|
||||
stepper.cpp
|
||||
swi2c.c
|
||||
swspi.cpp
|
||||
Tcodes.cpp
|
||||
temperature.cpp
|
||||
timer02.c
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
#define SWI2C_TMO 2048 //2048 cycles timeout
|
||||
|
||||
//PAT9125 configuration
|
||||
//#define PAT9125_SWSPI // software SPI mode (incomplete)
|
||||
#ifdef SWI2C_SCL
|
||||
#define PAT9125_SWI2C // software I2C mode
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -27,10 +27,7 @@
|
|||
#define PAT9125_ORIENTATION 0x19
|
||||
#define PAT9125_BANK_SELECTION 0x7f
|
||||
|
||||
|
||||
#if defined(PAT9125_SWSPI)
|
||||
#include "swspi.h"
|
||||
#elif defined(PAT9125_SWI2C)
|
||||
#if defined(PAT9125_SWI2C)
|
||||
#include "swi2c.h"
|
||||
#elif defined(PAT9125_I2C)
|
||||
#include "twi.h"
|
||||
|
|
@ -109,10 +106,7 @@ extern FILE _uartout;
|
|||
|
||||
uint8_t pat9125_probe()
|
||||
{
|
||||
#if defined(PAT9125_SWSPI)
|
||||
swspi_init();
|
||||
#error not implemented
|
||||
#elif defined(PAT9125_SWI2C)
|
||||
#if defined(PAT9125_SWI2C)
|
||||
swi2c_init();
|
||||
return swi2c_check(PAT9125_I2C_ADDR) == 0;
|
||||
#elif defined(PAT9125_I2C)
|
||||
|
|
@ -247,12 +241,7 @@ uint8_t pat9125_update_bs(void)
|
|||
static uint8_t pat9125_rd_reg(uint8_t addr)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
#if defined(PAT9125_SWSPI)
|
||||
swspi_start();
|
||||
swspi_tx(addr & 0x7f);
|
||||
data = swspi_rx();
|
||||
swspi_stop();
|
||||
#elif defined(PAT9125_SWI2C)
|
||||
#if defined(PAT9125_SWI2C)
|
||||
if (!swi2c_readByte_A8(PAT9125_I2C_ADDR, addr, &data)) //NO ACK error
|
||||
goto error;
|
||||
#elif defined(PAT9125_I2C)
|
||||
|
|
@ -269,12 +258,7 @@ static uint8_t pat9125_rd_reg(uint8_t addr)
|
|||
|
||||
static void pat9125_wr_reg(uint8_t addr, uint8_t data)
|
||||
{
|
||||
#if defined(PAT9125_SWSPI)
|
||||
swspi_start();
|
||||
swspi_tx(addr | 0x80);
|
||||
swspi_tx(data);
|
||||
swspi_stop();
|
||||
#elif defined(PAT9125_SWI2C)
|
||||
#if defined(PAT9125_SWI2C)
|
||||
if (!swi2c_writeByte_A8(PAT9125_I2C_ADDR, addr, &data)) //NO ACK error
|
||||
goto error;
|
||||
#elif defined(PAT9125_I2C)
|
||||
|
|
|
|||
|
|
@ -1,93 +0,0 @@
|
|||
#include "uni_avr_rpi.h"
|
||||
|
||||
#ifdef __SWSPI
|
||||
#include "swspi.h"
|
||||
|
||||
#ifdef __RPI
|
||||
//#define swspi_miso 9
|
||||
#define swspi_miso 10
|
||||
#define swspi_mosi 10
|
||||
#define swspi_sck 11
|
||||
#define SWSPI_CS 7
|
||||
#endif //__RPI
|
||||
|
||||
|
||||
#define SWSPI_DEL 0x0f //delay mask (0-3. bit, delay = 1 << DEL [us])
|
||||
#define SWSPI_POL 0x10 //polarity mask (4. bit, 1=inverted)
|
||||
#define SWSPI_PHA 0x20 //phase mask (5. bit)
|
||||
#define SWSPI_DOR 0x40 //data order mask (6. bit, 0=MSB first, 1=LSB first)
|
||||
|
||||
#define SWSPI_SCK_UP if (swspi_cfg & SWSPI_POL) GPIO_CLR(swspi_sck); else GPIO_SET(swspi_sck);
|
||||
#define SWSPI_SCK_DN if (swspi_cfg & SWSPI_POL) GPIO_SET(swspi_sck); else GPIO_CLR(swspi_sck);
|
||||
|
||||
unsigned char swspi_miso = 0;
|
||||
unsigned char swspi_mosi = 0;
|
||||
unsigned char swspi_sck = 0;
|
||||
unsigned char swspi_cfg = 0;
|
||||
|
||||
void swspi_init(unsigned char miso, unsigned char mosi, unsigned char sck, unsigned char cfg)
|
||||
{
|
||||
swspi_miso = miso;
|
||||
swspi_mosi = mosi;
|
||||
swspi_sck = sck;
|
||||
swspi_cfg = cfg;
|
||||
GPIO_INP(swspi_miso);
|
||||
GPIO_OUT(swspi_mosi);
|
||||
GPIO_OUT(swspi_sck);
|
||||
GPIO_CLR(swspi_mosi);
|
||||
SWSPI_SCK_DN;
|
||||
}
|
||||
|
||||
void swspi_tx(unsigned char tx)
|
||||
{
|
||||
int delay = 1 << (swspi_cfg & SWSPI_DEL));
|
||||
if (swspi_miso == swspi_mosi) GPIO_OUT(swspi_mosi);
|
||||
unsigned char i = 0; for (; i < 8; i++)
|
||||
{
|
||||
if (tx & 0x80) GPIO_SET(swspi_mosi);
|
||||
else GPIO_CLR(swspi_mosi);
|
||||
DELAY(delay);
|
||||
SWSPI_SCK_UP;
|
||||
DELAY(delay);
|
||||
SWSPI_SCK_DN;
|
||||
tx <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char swspi_rx()
|
||||
{
|
||||
int delay = 1 << (swspi_cfg & SWSPI_DEL));
|
||||
if (swspi_miso == swspi_mosi) GPIO_OUT(swspi_mosi);
|
||||
unsigned char rx = 0;
|
||||
unsigned char i = 0; for (; i < 8; i++)
|
||||
{
|
||||
rx <<= 1;
|
||||
DELAY(delay);
|
||||
SWSPI_SCK_UP;
|
||||
DELAY(delay);
|
||||
rx |= GPIO_GET(swspi_miso)?1:0;
|
||||
SWSPI_SCK_DN;
|
||||
}
|
||||
return rx;
|
||||
}
|
||||
|
||||
unsigned char swspi_txrx(unsigned char tx)
|
||||
{
|
||||
int delay = 1 << (swspi_cfg & SWSPI_DEL));
|
||||
unsigned char rx = 0;
|
||||
unsigned char i = 0; for (; i < 8; i++)
|
||||
{
|
||||
rx <<= 1;
|
||||
if (tx & 0x80) GPIO_SET(swspi_mosi);
|
||||
else GPIO_CLR(swspi_mosi);
|
||||
DELAY(delay);
|
||||
SWSPI_SCK_UP;
|
||||
DELAY(delay);
|
||||
rx |= GPIO_GET(swspi_miso)?1:0;
|
||||
SWSPI_SCK_DN;
|
||||
tx <<= 1;
|
||||
}
|
||||
return rx;
|
||||
}
|
||||
|
||||
#endif //__SWSPI
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
// Software SPI
|
||||
#ifndef SWSPI_H
|
||||
#define SWSPI_H
|
||||
|
||||
//initialize gpio
|
||||
extern void swspi_init(unsigned char miso, unsigned char mosi, unsigned char sck, unsigned char cfg);
|
||||
//transmit and receive (full duplex mode)
|
||||
extern unsigned char swspi_txrx(unsigned char tx);
|
||||
//transmit (half dublex mode, miso == mosi)
|
||||
extern void swspi_tx(unsigned char tx);
|
||||
//receive (half dublex mode, miso == mosi)
|
||||
extern unsigned char swspi_rx();
|
||||
|
||||
#endif //SWSPI_H
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
// unification for AVR and RPI
|
||||
|
||||
#ifdef __AVR
|
||||
//#include "Arduino.h"
|
||||
#include "Marlin.h"
|
||||
#define GPIO_INP(gpio) pinMode(gpio, INPUT)
|
||||
#define GPIO_OUT(gpio) pinMode(gpio, OUTPUT)
|
||||
#define GPIO_SET(gpio) digitalWrite(gpio, HIGH)
|
||||
#define GPIO_CLR(gpio) digitalWrite(gpio, LOW)
|
||||
#define GPIO_GET(gpio) (digitalRead(gpio) != LOW)
|
||||
#define DELAY(delay) delayMicroseconds(delay)
|
||||
#define PRINT MYSERIAL.print
|
||||
#endif //RC522_AVR
|
||||
|
||||
#ifdef __RPI
|
||||
#include <bcm2835.h>
|
||||
#define GPIO_INP(gpio) bcm2835_gpio_fsel(gpio, BCM2835_GPIO_FSEL_INPT)
|
||||
#define GPIO_OUT(gpio) bcm2835_gpio_fsel(gpio, BCM2835_GPIO_FSEL_OUTP)
|
||||
#define GPIO_SET(gpio) bcm2835_gpio_write(gpio, HIGH)
|
||||
#define GPIO_CLR(gpio) bcm2835_gpio_write(gpio, LOW)
|
||||
#define GPIO_GET(gpio) (bcm2835_gpio_lev(gpio) != LOW)
|
||||
#include <unistd.h>
|
||||
#define DELAY(delay) usleep(delay)
|
||||
#define PRINT(p) print(p)
|
||||
#define DEC 10
|
||||
#define HEX 16
|
||||
void print(const char* pc) { printf("%s", pc); }
|
||||
void print(int v) { printf("%d", v); }
|
||||
void print(float v) { printf("%f", v); }
|
||||
#endif //RC522_RPI
|
||||
|
||||
Loading…
Reference in New Issue