Permalink
Browse files

Raw 3-wire support (#52)

* Initial 3-wire support

* 3-wire BBIO support

* BBIO timer cleanup
  • Loading branch information...
Baldanos authored and bvernoux committed May 12, 2016
1 parent 5a5751b commit a9681c5e39155f7ae1b6e1b2668950ef70b1223b
View
@@ -243,6 +243,7 @@ static struct cmd_map {
{ T_JTAG, cmd_mode_init },
{ T_RNG, cmd_rng },
{ T_TWOWIRE, cmd_mode_init },
{ T_THREEWIRE, cmd_mode_init },
{ 0, NULL }
};
View
@@ -134,6 +134,7 @@ t_token_dict tl_dict[] = {
{ T_FILTER, "filter" },
{ T_LOW, "low" },
{ T_HIGH, "high" },
{ T_THREEWIRE, "3-wire" },
{ T_LEFT_SQ, "[" },
{ T_RIGHT_SQ, "]" },
@@ -911,6 +912,107 @@ t_token tokens_twowire[] = {
{ }
};
#define THREEWIRE_PARAMETERS \
{ T_DEVICE, \
.arg_type = T_ARG_UINT, \
.help = "3-wire device (1)" }, \
{ T_PULL, \
.arg_type = T_ARG_TOKEN, \
.subtokens = tokens_gpio_pull, \
.help = "GPIO pull (up/down/floating)" }, \
{ T_MSB_FIRST, \
.help = "Send/receive MSB first" }, \
{ T_LSB_FIRST, \
.help = "Send/receive LSB first" },
t_token tokens_mode_threewire[] = {
{
T_SHOW,
.subtokens = tokens_mode_show,
.help = "Show 3-wire parameters"
},
THREEWIRE_PARAMETERS
/* 3-wire-specific commands */
{
T_READ,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Read byte (repeat with :<num>)"
},
{
T_WRITE,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Write byte (repeat with :<num>)"
},
{
T_FREQUENCY,
.arg_type = T_ARG_FLOAT,
.help = "Bus frequency"
},
{
T_ARG_UINT,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Write byte (repeat with :<num>)"
},
{
T_ARG_STRING,
.help = "Write string"
},
/* BP commands */
{
T_CARET,
.help = "Send one clock tick"
},
{
T_SLASH,
.help = "Toggle clock level high"
},
{
T_BACKSLASH,
.help = "Toggle clock level low"
},
{
T_MINUS,
.help = "Toggle SDO high"
},
{
T_UNDERSCORE,
.help = "Toggle SDO low"
},
{
T_EXCLAMATION,
.help = "Read bit with clock"
},
{
T_DOT,
.help = "Read bit without clock"
},
{
T_AMPERSAND,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Delay 1 usec (repeat with :<num>)"
},
{
T_PERCENT,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Delay 1 msec (repeat with :<num>)"
},
{
T_TILDE,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Write a random byte (repeat with :<num>)"
},
{
T_EXIT,
.help = "Exit 3-wire mode"
},
{ }
};
t_token tokens_threewire[] = {
THREEWIRE_PARAMETERS
{ }
};
t_token tokens_gpio_mode[] = {
{
T_IN,
@@ -1247,6 +1349,11 @@ t_token tl_tokens[] = {
.subtokens = tokens_twowire,
.help = "2-wire mode"
},
{
T_THREEWIRE,
.subtokens = tokens_threewire,
.help = "3-wire mode"
},
{
T_UART,
.subtokens = tokens_uart,
View
@@ -127,6 +127,7 @@ enum {
T_FILTER,
T_LOW,
T_HIGH,
T_THREEWIRE,
/* BP-compatible commands */
T_LEFT_SQ,
View
@@ -13,14 +13,15 @@ HYDRABUSSRC = hydrabus/hydrabus.c \
hydrabus/hydrabus_mode_jtag.c \
hydrabus/hydrabus_rng.c \
hydrabus/hydrabus_mode_twowire.c \
hydrabus/hydrabus_mode_threewire.c \
hydrabus/hydrabus_mode_can.c \
hydrabus/hydrabus_bbio.c \
hydrabus/hydrabus_bbio_spi.c \
hydrabus/hydrabus_bbio_pin.c \
hydrabus/hydrabus_bbio_can.c \
hydrabus/hydrabus_bbio_uart.c \
hydrabus/hydrabus_bbio_i2c.c \
hydrabus/hydrabus_bbio_twowire.c
hydrabus/hydrabus_bbio_rawwire.c
# Required include directories
HYDRABUSINC = ./hydrabus
View
@@ -31,7 +31,7 @@
#include "hydrabus_bbio_can.h"
#include "hydrabus_bbio_uart.h"
#include "hydrabus_bbio_i2c.h"
#include "hydrabus_bbio_twowire.h"
#include "hydrabus_bbio_rawwire.h"
int cmd_bbio(t_hydra_console *con)
{
@@ -59,7 +59,7 @@ int cmd_bbio(t_hydra_console *con)
break;
case BBIO_RAWWIRE:
cprint(con, "RAW1", 4);
bbio_mode_twowire(con);
bbio_mode_rawwire(con);
break;
case BBIO_JTAG:
cprint(con, "OCD1", 4);
View
@@ -105,23 +105,23 @@
/*
* 2-Wire-specific commands
*/
#define BBIO_2WIRE_I2C_START 0b00000010
#define BBIO_2WIRE_I2C_STOP 0b00000011
#define BBIO_2WIRE_CS_LOW 0b00000100
#define BBIO_2WIRE_CS_HIGH 0b00000101
#define BBIO_2WIRE_READ_BYTE 0b00000110
#define BBIO_2WIRE_READ_BIT 0b00000111
#define BBIO_2WIRE_PEEK_INPUT 0b00001000
#define BBIO_2WIRE_CLK_TICK 0b00001001
#define BBIO_2WIRE_CLK_LOW 0b00001010
#define BBIO_2WIRE_CLK_HIGH 0b00001011
#define BBIO_2WIRE_DATA_LOW 0b00001100
#define BBIO_2WIRE_DATA_HIGH 0b00001101
#define BBIO_2WIRE_BULK_TRANSFER 0b00010000
#define BBIO_2WIRE_BULK_CLK 0b00100000
#define BBIO_2WIRE_BULK_BIT 0b00110000
#define BBIO_2WIRE_CONFIG_PERIPH 0b01000000
#define BBIO_2WIRE_SET_SPEED 0b01100000
#define BBIO_2WIRE_CONFIG 0b10000000
#define BBIO_RAWWIRE_I2C_START 0b00000010
#define BBIO_RAWWIRE_I2C_STOP 0b00000011
#define BBIO_RAWWIRE_CS_LOW 0b00000100
#define BBIO_RAWWIRE_CS_HIGH 0b00000101
#define BBIO_RAWWIRE_READ_BYTE 0b00000110
#define BBIO_RAWWIRE_READ_BIT 0b00000111
#define BBIO_RAWWIRE_PEEK_INPUT 0b00001000
#define BBIO_RAWWIRE_CLK_TICK 0b00001001
#define BBIO_RAWWIRE_CLK_LOW 0b00001010
#define BBIO_RAWWIRE_CLK_HIGH 0b00001011
#define BBIO_RAWWIRE_DATA_LOW 0b00001100
#define BBIO_RAWWIRE_DATA_HIGH 0b00001101
#define BBIO_RAWWIRE_BULK_TRANSFER 0b00010000
#define BBIO_RAWWIRE_BULK_CLK 0b00100000
#define BBIO_RAWWIRE_BULK_BIT 0b00110000
#define BBIO_RAWWIRE_CONFIG_PERIPH 0b01000000
#define BBIO_RAWWIRE_SET_SPEED 0b01100000
#define BBIO_RAWWIRE_CONFIG 0b10000000
int cmd_bbio(t_hydra_console *con);
Oops, something went wrong.

0 comments on commit a9681c5

Please sign in to comment.