Skip to content

Commit

Permalink
use gpio15 and fix reversing signedness bug (ah, C)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnemote committed May 24, 2016
1 parent 478ae49 commit 8582e99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions esp8266/user/user_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ void user_init(void) {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14);
//WRITE_PERI_REG(RTC_GPIO_CONF, READ_PERI_REG(RTC_GPIO_CONF) & ~1);
//WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1) | out_en);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15);

}
12 changes: 6 additions & 6 deletions esp8266/vm/virtual.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@

// None of this stepper stuff should be here, it should be its own file.

int8_t stepper_states[] = { 8, 12, 4, 6, 2, 3, 1, 9 };
uint8_t stepper_states[] = { 8, 12, 4, 6, 2, 3, 1, 9 };

typedef struct stepper_s {
int8_t pin_a, pin_b, pin_c, pin_d;
int8_t phase;
uint8_t pin_a, pin_b, pin_c, pin_d;
uint8_t phase;
int8_t direction;
} stepper_t;

stepper_t step_left = { 13, 14, 16, 12, 0, 0 };
stepper_t step_left = { 13, 14, 15, 12, 0, 0 };
stepper_t step_right = { 0, 5, 4, 2, 0, 0 };

void stepper_update(stepper_t *x) {
x->phase = (x->phase + x->direction) % 8;
int8_t state = x->direction ? stepper_states[x->phase] : 0;
x->phase = (x->phase + x->direction) & 7;
uint8_t state = x->direction ? stepper_states[x->phase] : 0;
GPIO_OUTPUT_SET(x->pin_a, (state & 8) ? 1 : 0);
GPIO_OUTPUT_SET(x->pin_b, (state & 4) ? 1 : 0);
GPIO_OUTPUT_SET(x->pin_c, (state & 2) ? 1 : 0);
Expand Down

0 comments on commit 8582e99

Please sign in to comment.